This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 6881d37044fe8238c72bc8ec6cc91b0ffe37d943 Author: jsorel <johann.so...@geomatys.com> AuthorDate: Thu Jul 25 16:40:08 2024 +0200 Regroup heif item propertiesin Item class, start grid image support --- .../org.apache.sis.storage.DataStoreProvider | 4 + ...org.apache.sis.storage.gimi.isobmff.BoxRegistry | 8 + .../main/module-info.java | 2 + .../org/apache/sis/storage/gimi/GimiStore.java | 262 ++++++++++++++++----- .../org/apache/sis/storage/gimi/isobmff/Box.java | 19 +- .../gimi/isobmff/iso14496_12/GeneralType.java | 11 +- ...eItemTypeReferenceLarge.java => GroupList.java} | 15 +- .../gimi/isobmff/iso14496_12/ISO14496_12.java | 2 + .../gimi/isobmff/iso14496_12/ItemLocation.java | 63 ++++- .../gimi/isobmff/iso14496_12/ItemReference.java | 19 -- .../iso14496_12/SingleItemTypeReference.java | 2 +- .../iso14496_12/SingleItemTypeReferenceLarge.java | 6 +- .../DerivedImageReference.java} | 23 +- .../gimi/isobmff/iso23008_12/ISO23008_12.java | 4 +- 14 files changed, 317 insertions(+), 123 deletions(-) diff --git a/incubator/src/org.apache.sis.storage.gimi/main/META-INF/services/org.apache.sis.storage.DataStoreProvider b/incubator/src/org.apache.sis.storage.gimi/main/META-INF/services/org.apache.sis.storage.DataStoreProvider new file mode 100644 index 0000000000..44db0e8f82 --- /dev/null +++ b/incubator/src/org.apache.sis.storage.gimi/main/META-INF/services/org.apache.sis.storage.DataStoreProvider @@ -0,0 +1,4 @@ +# Workaround for Maven bug https://issues.apache.org/jira/browse/MNG-7855 +# The content of this file is automatically derived from module-info.class file. +# Should be used only if the JAR file was on class-path rather than module-path. +org.apache.sis.storage.gimi.GimiProvider diff --git a/incubator/src/org.apache.sis.storage.gimi/main/META-INF/services/org.apache.sis.storage.gimi.isobmff.BoxRegistry b/incubator/src/org.apache.sis.storage.gimi/main/META-INF/services/org.apache.sis.storage.gimi.isobmff.BoxRegistry new file mode 100644 index 0000000000..593fdb10db --- /dev/null +++ b/incubator/src/org.apache.sis.storage.gimi/main/META-INF/services/org.apache.sis.storage.gimi.isobmff.BoxRegistry @@ -0,0 +1,8 @@ +# Workaround for Maven bug https://issues.apache.org/jira/browse/MNG-7855 +# The content of this file is automatically derived from module-info.class file. +# Should be used only if the JAR file was on class-path rather than module-path. +org.apache.sis.storage.gimi.isobmff.gimi.GIMI +org.apache.sis.storage.gimi.isobmff.iso14496_10.ISO14496_10 +org.apache.sis.storage.gimi.isobmff.iso14496_12.ISO14496_12 +org.apache.sis.storage.gimi.isobmff.iso23001_17.ISO23001_17 +org.apache.sis.storage.gimi.isobmff.iso23008_12.ISO23008_12 diff --git a/incubator/src/org.apache.sis.storage.gimi/main/module-info.java b/incubator/src/org.apache.sis.storage.gimi/main/module-info.java index 7d4608978f..c3b6f462db 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/module-info.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/module-info.java @@ -25,6 +25,8 @@ module org.apache.sis.storage.gimi { requires transitive org.apache.sis.referencing; requires transitive org.apache.sis.storage; + exports org.apache.sis.storage.gimi.isobmff; + provides org.apache.sis.storage.DataStoreProvider with org.apache.sis.storage.gimi.GimiProvider; diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/GimiStore.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/GimiStore.java index 8307fcd2ef..0387851d39 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/GimiStore.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/GimiStore.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Optional; +import java.util.stream.IntStream; import org.apache.sis.coverage.SampleDimension; import org.apache.sis.coverage.grid.GridCoverage; import org.apache.sis.coverage.grid.GridCoverageBuilder; @@ -40,6 +41,7 @@ import org.apache.sis.storage.DataStore; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.Resource; import org.apache.sis.storage.StorageConnector; +import org.apache.sis.storage.base.StoreResource; import org.apache.sis.storage.gimi.isobmff.Box; import org.apache.sis.storage.gimi.isobmff.ISOBMFFReader; import org.apache.sis.storage.gimi.isobmff.gimi.ModelTiePointProperty; @@ -47,13 +49,20 @@ import org.apache.sis.storage.gimi.isobmff.gimi.ModelTransformationProperty; import org.apache.sis.storage.gimi.isobmff.gimi.WellKnownText2Property; import org.apache.sis.storage.gimi.isobmff.iso14496_12.ItemInfo; import org.apache.sis.storage.gimi.isobmff.iso14496_12.ItemInfoEntry; +import org.apache.sis.storage.gimi.isobmff.iso14496_12.ItemLocation; import org.apache.sis.storage.gimi.isobmff.iso14496_12.ItemProperties; +import org.apache.sis.storage.gimi.isobmff.iso14496_12.ItemPropertyAssociation; import org.apache.sis.storage.gimi.isobmff.iso14496_12.ItemPropertyContainer; +import org.apache.sis.storage.gimi.isobmff.iso14496_12.ItemReference; import org.apache.sis.storage.gimi.isobmff.iso14496_12.MediaData; import org.apache.sis.storage.gimi.isobmff.iso14496_12.Meta; +import org.apache.sis.storage.gimi.isobmff.iso14496_12.PrimaryItem; +import org.apache.sis.storage.gimi.isobmff.iso14496_12.SingleItemTypeReference; import org.apache.sis.storage.gimi.isobmff.iso23001_17.ComponentDefinition; import org.apache.sis.storage.gimi.isobmff.iso23001_17.UncompressedFrameConfig; import org.apache.sis.storage.gimi.isobmff.iso23008_12.ImageSpatialExtents; +import org.apache.sis.storage.tiling.TileMatrixSet; +import org.apache.sis.storage.tiling.TiledResource; import org.opengis.metadata.Metadata; import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.crs.CoordinateReferenceSystem; @@ -102,7 +111,7 @@ public final class GimiStore extends DataStore implements Aggregate { } } - private synchronized ISOBMFFReader getReader() throws IllegalArgumentException, DataStoreException { + private synchronized ISOBMFFReader getReader() throws DataStoreException { if (reader == null) { final StorageConnector cnx = new StorageConnector(gimiPath); final ChannelDataInput cdi = cnx.getStorageAs(ChannelDataInput.class); @@ -131,9 +140,13 @@ public final class GimiStore extends DataStore implements Aggregate { ItemInfo iinf = (ItemInfo) meta.getChild(ItemInfo.FCC, null, reader.channel); iinf.readPayload(reader.channel); for (ItemInfoEntry iie : iinf.entries) { - if ("unci".equals(iie.itemType)) { + final Item item = new Item(iie); + if (UncompressedImage.TYPE.equals(iie.itemType)) { //uncompressed image - components.add(new Picture(iie)); + components.add(new UncompressedImage(item)); + } else if (Grid.TYPE.equals(iie.itemType)) { + //tiled image + components.add(new Grid(item)); } else { //TODO //ignore all others for now @@ -147,44 +160,41 @@ public final class GimiStore extends DataStore implements Aggregate { return components; } - private final class Picture extends AbstractGridCoverageResource { + /** + * A single uncompressed image. + */ + private final class UncompressedImage extends AbstractGridCoverageResource implements StoreResource { + + public static final String TYPE = "unci"; - private final ComponentDefinition compDef; - private final ImageSpatialExtents imageExt; - private final UncompressedFrameConfig frameConf; - private final ModelTransformationProperty modelTrs; - private final ModelTiePointProperty modelTp; - private final WellKnownText2Property modelWkt; - private final MediaData mediaData; + private final Item item; + private ComponentDefinition compDef; + private ImageSpatialExtents imageExt; + private UncompressedFrameConfig frameConf; + private ModelTransformationProperty modelTrs; + private ModelTiePointProperty modelTp; + private WellKnownText2Property modelWkt; + private MediaData mediaData; - public Picture(ItemInfoEntry entry) throws DataStoreException { + public UncompressedImage(Item item) throws DataStoreException { super(GimiStore.this); - final ISOBMFFReader reader = getReader(); - try { - Box meta = root.getChild(Meta.FCC, null, reader.channel); - Box itemProp = meta.getChild(ItemProperties.FCC, null, reader.channel); - itemProp.readPayload(reader.channel); - Box itemPropCont = itemProp.getChild(ItemPropertyContainer.FCC, null, reader.channel); - itemPropCont.readPayload(reader.channel); - compDef = (ComponentDefinition) itemPropCont.getChild(ComponentDefinition.FCC, null, reader.channel); - compDef.readPayload(reader.channel); - imageExt = (ImageSpatialExtents) itemPropCont.getChild(ImageSpatialExtents.FCC, null, reader.channel); - imageExt.readPayload(reader.channel); - frameConf = (UncompressedFrameConfig) itemPropCont.getChild(UncompressedFrameConfig.FCC, null, reader.channel); - frameConf.readPayload(reader.channel); - modelTrs = (ModelTransformationProperty) itemPropCont.getChild("uuid", ModelTransformationProperty.UUID, reader.channel); - modelTrs.readPayload(reader.channel); - modelTp = (ModelTiePointProperty) itemPropCont.getChild("uuid", ModelTiePointProperty.UUID, reader.channel); - modelTp.readPayload(reader.channel); - modelWkt = (WellKnownText2Property) itemPropCont.getChild("uuid", WellKnownText2Property.UUID, reader.channel); - modelWkt.readPayload(reader.channel); - mediaData = (MediaData) root.getChild(MediaData.FCC, null, reader.channel); - mediaData.readPayload(reader.channel); - } catch (IOException ex) { - throw new DataStoreException(ex); + this.item = item; + + for (Box box : item.properties) { + if (box instanceof ComponentDefinition) compDef = (ComponentDefinition) box; + else if (box instanceof ImageSpatialExtents) imageExt = (ImageSpatialExtents) box; + else if (box instanceof UncompressedFrameConfig) frameConf = (UncompressedFrameConfig) box; + else if (box instanceof ModelTransformationProperty) modelTrs = (ModelTransformationProperty) box; + else if (box instanceof ModelTiePointProperty) modelTp = (ModelTiePointProperty) box; + else if (box instanceof WellKnownText2Property) modelWkt = (WellKnownText2Property) box; } } + @Override + public DataStore getOriginator() { + return GimiStore.this; + } + @Override public GridGeometry getGridGeometry() throws DataStoreException { @@ -220,36 +230,174 @@ public final class GimiStore extends DataStore implements Aggregate { @Override public GridCoverage read(GridGeometry gg, int... ints) throws DataStoreException { + final byte[] data = item.getData(); + + final BufferedImage img = new BufferedImage(2048, 1024, BufferedImage.TYPE_3BYTE_BGR); + final WritableRaster raster = img.getRaster(); + + for (int y = 0; y < 1024; y++) { + for (int x = 0; x < 2048; x++) { + int offset = y*2048 + x; + raster.setSample(x, y, 0, mediaData.data[offset*3] & 0xFF); + raster.setSample(x, y, 1, mediaData.data[offset*3+1] & 0xFF); + raster.setSample(x, y, 2, mediaData.data[offset*3+2] & 0xFF); + } + } + + final GridGeometry gridGeometry = getGridGeometry(); + + GridCoverageBuilder gcb = new GridCoverageBuilder(); + gcb.setDomain(gridGeometry); + //gcb.setRanges(getSampleDimensions()); + //gcb.setValues(db, new Dimension((int)gridGeometry.getExtent().getSize(0), (int)gridGeometry.getExtent().getSize(1))); + gcb.setValues(img); + return gcb.build(); + } + + } + + private final class Grid extends AbstractGridCoverageResource implements TiledResource, StoreResource { + + public static final String TYPE = "grid"; + + private final Item item; + + public Grid(Item item) throws DataStoreException { + super(GimiStore.this); + this.item = item; + } + + @Override + public GridGeometry getGridGeometry() throws DataStoreException { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public List<SampleDimension> getSampleDimensions() throws DataStoreException { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public GridCoverage read(GridGeometry domain, int... ranges) throws DataStoreException { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public Collection<? extends TileMatrixSet> getTileMatrixSets() throws DataStoreException { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public DataStore getOriginator() { + return GimiStore.this; + } + + } + + /** + * Regroup properties of a single item in the file. + */ + private final class Item { + + public final ItemInfoEntry entry; + public final boolean isPrimary; + public final List<Box> properties = new ArrayList<>(); + public final List<SingleItemTypeReference> references = new ArrayList<>(); + public final ItemLocation.Item location; + + public Item(ItemInfoEntry entry) throws IllegalArgumentException, DataStoreException, IOException { + this.entry = entry; + + final ISOBMFFReader reader = getReader(); + final Box meta = root.getChild(Meta.FCC, null, reader.channel); + + //is item primary + final PrimaryItem primaryItem = (PrimaryItem) meta.getChild(PrimaryItem.FCC, null, reader.channel); + if (primaryItem != null) { + primaryItem.readPayload(reader.channel); + isPrimary = primaryItem.itemId == entry.itemId; + } else { + isPrimary = true; + } + + //extract properties + final Box itemProperties = meta.getChild(ItemProperties.FCC, null, reader.channel); + if (itemProperties != null) { + itemProperties.readPayload(reader.channel); + final ItemPropertyContainer itemPropertiesContainer = (ItemPropertyContainer) itemProperties.getChild(ItemPropertyContainer.FCC, null, reader.channel); + itemPropertiesContainer.readPayload(reader.channel); + final List<Box> allProperties = itemPropertiesContainer.getChildren(reader.channel); + final ItemPropertyAssociation itemPropertiesAssociations = (ItemPropertyAssociation) itemProperties.getChild(ItemPropertyAssociation.FCC, null, reader.channel); + itemPropertiesAssociations.readPayload(reader.channel); + + for (ItemPropertyAssociation.Entry en : itemPropertiesAssociations.entries) { + if (en.itemId == entry.itemId) { + for(int i : en.propertyIndex) { + properties.add(allProperties.get(i-1)); //starts at 1 + } + break; + } + } + } + + //extract outter references + final ItemReference itemReferences = (ItemReference) meta.getChild(ItemReference.FCC, null, reader.channel); + if (itemReferences != null) { + + } + + + //extract location + ItemLocation.Item loc = null; + final ItemLocation itemLocation = (ItemLocation) meta.getChild(ItemLocation.FCC, null, reader.channel); + if (itemLocation != null) { + for (ItemLocation.Item en : itemLocation.items) { + if (en.itemId == entry.itemId) { + loc = en; + break; + } + } + } + this.location = loc; + } + + public byte[] getData() throws DataStoreException { try { final ISOBMFFReader reader = getReader(); - mediaData.readPayload(reader.channel); - //DataBufferByte db = new DataBufferByte(mediaData.data, mediaData.data.length); - - final BufferedImage img = new BufferedImage(2048, 1024, BufferedImage.TYPE_3BYTE_BGR); - final WritableRaster raster = img.getRaster(); - - for (int y = 0; y < 1024; y++) { - for (int x = 0; x < 2048; x++) { - int offset = y*2048 + x; - raster.setSample(x, y, 0, mediaData.data[offset*3] & 0xFF); - raster.setSample(x, y, 1, mediaData.data[offset*3+1] & 0xFF); - raster.setSample(x, y, 2, mediaData.data[offset*3+2] & 0xFF); + + if (location == null) { + //read data from the default mediadata box + MediaData mediaData = (MediaData) root.getChild(MediaData.FCC, null, getReader().channel); + mediaData.readPayload(getReader().channel); + return mediaData.data; + } else if (location.constructionMethod == 0) { + //absolute location + if (location.dataReferenceIndex == 0) { + //compute total size + final int length = IntStream.of(location.extentLength).sum(); + //read datas + final byte[] data = new byte[length]; + for (int i = 0, offset = 0; i < location.extentLength.length; i++) { + reader.channel.seek(location.baseOffset + location.extentOffset[i]); + reader.channel.readFully(data, offset, location.extentLength[i]); + } + return data; + } else { + throw new IOException("Not supported yet"); } - } - final GridGeometry gridGeometry = getGridGeometry(); + } else if (location.constructionMethod == 1) { + throw new IOException("Not supported yet"); + } else if (location.constructionMethod == 2) { + throw new IOException("Not supported yet"); + } else { + throw new DataStoreException("Unexpected construction method " + location.constructionMethod); + } - GridCoverageBuilder gcb = new GridCoverageBuilder(); - gcb.setDomain(gridGeometry); - //gcb.setRanges(getSampleDimensions()); - //gcb.setValues(db, new Dimension((int)gridGeometry.getExtent().getSize(0), (int)gridGeometry.getExtent().getSize(1))); - gcb.setValues(img); - return gcb.build(); } catch (IOException ex) { - throw new DataStoreException(ex); + throw new DataStoreException("Failed reading data", ex); } } } - } diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/Box.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/Box.java index ad605541bf..37318ac1a4 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/Box.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/Box.java @@ -62,6 +62,8 @@ public class Box { */ private List<Box> children; + private boolean loaded; + /** * Read box payload, may be values or children boxes. * @@ -69,6 +71,8 @@ public class Box { * @throws java.io.IOException */ public final void readPayload(ChannelDataInput cdi) throws IOException { + if (loaded) return; + loaded = true; if (isContainer()) { getChildren(cdi); } else { @@ -234,10 +238,16 @@ public class Box { } public static String beanToString(Object obj) { - final Class<? extends Object> clazz = obj.getClass(); + Class<? extends Object> clazz = obj.getClass(); if (!(clazz == Box.class || clazz == FullBox.class)) { + + final List<Field> fields = new ArrayList<>(); + while (!(clazz == Box.class || clazz == FullBox.class) && clazz != null) { + fields.addAll(Arrays.asList(clazz.getDeclaredFields())); + clazz = clazz.getSuperclass(); + } + final StringBuilder sb = new StringBuilder(); - final Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { if (Modifier.isStatic(field.getModifiers())) continue; if (!Modifier.isPublic(field.getModifiers())) continue; @@ -260,11 +270,12 @@ public class Box { sb.append(Arrays.toString((String[])value)); } else { if (length > 0) { - for (int i = 0; i < length && i < 20; i++) { + int maxCount = 2000000000; + for (int i = 0; i < length && i < maxCount; i++) { String str = String.valueOf(Array.get(value, i)); sb.append("\n [").append(i).append("]:").append(str.replaceAll("\n", "\n ")); } - if (length >= 20) sb.append("\n [...").append(length).append("]: ... more values..."); + if (length >= maxCount) sb.append("\n [...").append(length).append("]: ... more values..."); } } diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/GeneralType.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/GeneralType.java index 0bb15821ae..ef5157eb00 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/GeneralType.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/GeneralType.java @@ -28,7 +28,7 @@ public class GeneralType extends Box { /** * Brand identifier */ - public int majorBrand; + public String majorBrand; /** * Minor version of the major brand. */ @@ -36,14 +36,17 @@ public class GeneralType extends Box { /** * List of compatible brands. */ - public int[] compatibleBrands; + public String[] compatibleBrands; @Override public void readProperties(ChannelDataInput cdi) throws IOException { - majorBrand = cdi.readInt(); + majorBrand = intToFourCC(cdi.readInt()); minorVersion = cdi.readInt(); int nbCmp = Math.toIntExact( ((boxOffset + size) - cdi.getStreamPosition()) / 4); - compatibleBrands = cdi.readInts(nbCmp); + compatibleBrands = new String[nbCmp]; + for (int i = 0; i < nbCmp; i++) { + compatibleBrands[i] = intToFourCC(cdi.readInt()); + } } } diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/GroupList.java similarity index 68% copy from incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java copy to incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/GroupList.java index c9acad3741..8d34d2d6a5 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/GroupList.java @@ -16,26 +16,19 @@ */ package org.apache.sis.storage.gimi.isobmff.iso14496_12; -import java.io.IOException; -import org.apache.sis.io.stream.ChannelDataInput; import org.apache.sis.storage.gimi.isobmff.Box; /** * * @author Johann Sorel (Geomatys) */ -public final class SingleItemTypeReferenceLarge extends Box { +public class GroupList extends Box { - public int fromItemId; - public int[] toItemId; + public static final String FCC = "grpl"; @Override - public void readProperties(ChannelDataInput cdi) throws IOException { - fromItemId = cdi.readInt(); - toItemId = new int[cdi.readUnsignedShort()]; - for (int i = 0; i < toItemId.length; i++) { - toItemId[i] = cdi.readInt(); - } + public boolean isContainer() { + return true; } } diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ISO14496_12.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ISO14496_12.java index be939cc110..007551144b 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ISO14496_12.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ISO14496_12.java @@ -43,6 +43,7 @@ public final class ISO14496_12 implements BoxRegistry { TrackHeader.FCC, Meta.FCC, HandlerReference.FCC, + GroupList.FCC, PrimaryItem.FCC, ItemInfo.FCC, ItemInfoEntry.FCC, @@ -90,6 +91,7 @@ public final class ISO14496_12 implements BoxRegistry { else if (TrackHeader.FCC.equals(fourCC)) return new TrackHeader(); else if (Meta.FCC.equals(fourCC)) return new Meta(); else if (HandlerReference.FCC.equals(fourCC)) return new HandlerReference(); + else if (GroupList.FCC.equals(fourCC)) return new GroupList(); else if (PrimaryItem.FCC.equals(fourCC)) return new PrimaryItem(); else if (ItemInfo.FCC.equals(fourCC)) return new ItemInfo(); else if (ItemInfoEntry.FCC.equals(fourCC)) return new ItemInfoEntry(); diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ItemLocation.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ItemLocation.java index 596c8e1851..1391038439 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ItemLocation.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ItemLocation.java @@ -37,13 +37,70 @@ public class ItemLocation extends FullBox { public Item[] items; public static class Item { - public int itemID; + public int itemId; + /** + * How data should be accessed. + * <br> + * 0 : file_offset: by absolute byte offsets into the file or the payload + * of IdentifiedMediaDataBox referenced by data_reference_index. + * <br> + * 1 : idat_offset: by byte offsets into the ItemDataBox of the current MetaBox. + * <br> + * 2 : item_offset: by byte offset into the items indicated by item_reference_index. + */ public int constructionMethod; + /** + * Values : <br> + * 0 : this file + * <br> + * 1 : the item at given index minus one. + * <br> + * Method 0 : + * <br> + * Method 1 : not used + * <br> + * Method 2 : + */ public int dataReferenceIndex; + /** + * Method 0 : absolute file offset + * <br> + * Method 1 : byte offset in the ItemDataBox + * <br> + * Method 2 : byte offset in the items + */ public long baseOffset; + /** + * Method 0 : + * <br> + * Method 1 : + * <br> + * Method 2 : + */ public int extentCount; + /** + * Method 0 : not used + * <br> + * Method 1 : not used + * <br> + * Method 2 : item index to use + */ public int[] itemReferenceIndex; + /** + * Method 0 : + * <br> + * Method 1 : + * <br> + * Method 2 : + */ public int[] extentOffset; + /** + * Method 0 : + * <br> + * Method 1 : + * <br> + * Method 2 : + */ public int[] extentLength; @Override @@ -71,9 +128,9 @@ public class ItemLocation extends FullBox { for (int i = 0; i < itemCount; i++) { items[i] = new Item(); if (version < 2) { - items[i].itemID = cdi.readUnsignedShort(); + items[i].itemId = cdi.readUnsignedShort(); } else if (version == 2) { - items[i].itemID = cdi.readInt(); + items[i].itemId = cdi.readInt(); } if (version == 1 || version == 2) { cdi.readBits(12); diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ItemReference.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ItemReference.java index 8a15c64a99..405e7bf6d2 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ItemReference.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/ItemReference.java @@ -44,24 +44,5 @@ public class ItemReference extends FullBox { cdi.seek(box.boxOffset + box.size); references.add(box); } - - if (version == 0) { - - } else if (version == 1) { - - } } - - @Override - protected String propertiesToString() { - final StringBuilder sb = new StringBuilder(); - if (references != null) { - sb.append("references :"); - for (Box b : references) { - sb.append(b); - } - } - return sb.toString(); - } - } diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReference.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReference.java index 32e9324356..cb19ef2d9e 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReference.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReference.java @@ -24,7 +24,7 @@ import org.apache.sis.storage.gimi.isobmff.Box; * * @author Johann Sorel (Geomatys) */ -public final class SingleItemTypeReference extends Box { +public class SingleItemTypeReference extends Box { public int fromItemId; public int[] toItemId; diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java index c9acad3741..9468861945 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java @@ -18,16 +18,12 @@ package org.apache.sis.storage.gimi.isobmff.iso14496_12; import java.io.IOException; import org.apache.sis.io.stream.ChannelDataInput; -import org.apache.sis.storage.gimi.isobmff.Box; /** * * @author Johann Sorel (Geomatys) */ -public final class SingleItemTypeReferenceLarge extends Box { - - public int fromItemId; - public int[] toItemId; +public class SingleItemTypeReferenceLarge extends SingleItemTypeReference { @Override public void readProperties(ChannelDataInput cdi) throws IOException { diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso23008_12/DerivedImageReference.java similarity index 58% copy from incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java copy to incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso23008_12/DerivedImageReference.java index c9acad3741..c9b5824758 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso14496_12/SingleItemTypeReferenceLarge.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso23008_12/DerivedImageReference.java @@ -1,6 +1,6 @@ /* * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with + * contributor license agreements. See the NOTICE file distributed withz * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with @@ -14,28 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.storage.gimi.isobmff.iso14496_12; +package org.apache.sis.storage.gimi.isobmff.iso23008_12; -import java.io.IOException; -import org.apache.sis.io.stream.ChannelDataInput; -import org.apache.sis.storage.gimi.isobmff.Box; +import org.apache.sis.storage.gimi.isobmff.iso14496_12.SingleItemTypeReference; /** * * @author Johann Sorel (Geomatys) */ -public final class SingleItemTypeReferenceLarge extends Box { - - public int fromItemId; - public int[] toItemId; - - @Override - public void readProperties(ChannelDataInput cdi) throws IOException { - fromItemId = cdi.readInt(); - toItemId = new int[cdi.readUnsignedShort()]; - for (int i = 0; i < toItemId.length; i++) { - toItemId[i] = cdi.readInt(); - } - } +public final class DerivedImageReference extends SingleItemTypeReference { + public static final String FCC = "dimg"; } diff --git a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso23008_12/ISO23008_12.java b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso23008_12/ISO23008_12.java index c81218d693..fca0498f3e 100644 --- a/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso23008_12/ISO23008_12.java +++ b/incubator/src/org.apache.sis.storage.gimi/main/org/apache/sis/storage/gimi/isobmff/iso23008_12/ISO23008_12.java @@ -28,6 +28,7 @@ import org.apache.sis.storage.gimi.isobmff.BoxRegistry; public final class ISO23008_12 implements BoxRegistry { private static final Set<String> BOXES = Set.of( + DerivedImageReference.FCC, ImageSpatialExtents.FCC, PixelInformationProperty.FCC, UserDescriptionProperty.FCC @@ -52,7 +53,8 @@ public final class ISO23008_12 implements BoxRegistry { @Override public Box create(String fourCC) throws IllegalNameException { //TODO replace by String switch when SIS minimum java is updated - if (ImageSpatialExtents.FCC.equals(fourCC)) return new ImageSpatialExtents(); + if (DerivedImageReference.FCC.equals(fourCC)) return new DerivedImageReference(); + else if (ImageSpatialExtents.FCC.equals(fourCC)) return new ImageSpatialExtents(); else if (PixelInformationProperty.FCC.equals(fourCC)) return new PixelInformationProperty(); else if (UserDescriptionProperty.FCC.equals(fourCC)) return new UserDescriptionProperty(); //TODO other box types