Skip to content

Commit

Permalink
Data size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Johnson authored and Bob Johnson committed Dec 28, 2023
1 parent 633629b commit 7239f55
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Source/com/drew/metadata/mp4/media/Mp4UuidBoxHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private CanonCrxTiffHandler createCanonHandler(String type) {
case CANON_METADATA_GPS:
return new CanonCrxTiffHandler(new GpsDirectory(), metadata, null, 0);
}

return null;
}

Expand All @@ -192,11 +192,8 @@ private void processCanonRawV3(SequentialReader reader, long atomEnd)
{
try {
while (atomEnd == -1 || reader.getPosition() < atomEnd) {

long boxSize = reader.getUInt32();

String boxType = reader.getString(4);

boolean isLargeSize = boxSize == 1;

if (isLargeSize) {
Expand All @@ -215,11 +212,12 @@ private void processCanonRawV3(SequentialReader reader, long atomEnd)

// Determine if fourCC is container/atom and process accordingly.
// Unknown atoms will be skipped

long dataSize = (isLargeSize ? boxSize - 16 : boxSize - 8);

if (CANON_METADATA_BOXES.contains(boxType)) {
CanonCrxTiffHandler subHandler = createCanonHandler(boxType);
RandomAccessStreamReader subReader = new RandomAccessStreamReader(new ByteArrayInputStream(reader.getBytes((int) boxSize - 8)));
RandomAccessStreamReader subReader = new RandomAccessStreamReader(new ByteArrayInputStream(reader.getBytes((int) dataSize)));

try {
new TiffReader().processTiff(subReader, subHandler, 0);
}
Expand All @@ -232,9 +230,9 @@ else if (isLargeSize) {
// TODO capture this error in a directory
break;
}
reader.skip(boxSize - 16);
reader.skip(dataSize);
} else {
reader.skip(boxSize - 8);
reader.skip(dataSize);
}
}
} catch (IOException e) {
Expand Down

0 comments on commit 7239f55

Please sign in to comment.