From 7239f55f9d5f1c1c8b36960ddb69280dcbbd79fe Mon Sep 17 00:00:00 2001 From: Bob Johnson Date: Wed, 27 Dec 2023 22:47:34 -0800 Subject: [PATCH] Data size calculation --- .../metadata/mp4/media/Mp4UuidBoxHandler.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/com/drew/metadata/mp4/media/Mp4UuidBoxHandler.java b/Source/com/drew/metadata/mp4/media/Mp4UuidBoxHandler.java index 1a8c31fac..950cfb79f 100644 --- a/Source/com/drew/metadata/mp4/media/Mp4UuidBoxHandler.java +++ b/Source/com/drew/metadata/mp4/media/Mp4UuidBoxHandler.java @@ -181,7 +181,7 @@ private CanonCrxTiffHandler createCanonHandler(String type) { case CANON_METADATA_GPS: return new CanonCrxTiffHandler(new GpsDirectory(), metadata, null, 0); } - + return null; } @@ -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) { @@ -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); } @@ -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) {