ExifInvalidFormatException {
int type = ifdParser.next();
int tagNumber=0;
+ boolean isEnterNextIfd = false;
+ boolean isEnterExifIfd = false;
while (type != IfdParser.TYPE_END) {
switch (type) {
case IfdParser.TYPE_NEW_TAG:
break;
case IfdParser.TYPE_NEXT_IFD:
parseIfd1(ifdParser.parseIfdBlock());
+ isEnterNextIfd = true;
break;
case IfdParser.TYPE_VALUE_OF_PREV_TAG:
tag = ifdParser.getCorrespodingExifTag();
if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) {
parseExifIfd(ifdParser.parseIfdBlock());
+ isEnterExifIfd = true;
} else {
checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mIfd0Value);
tagNumber++;
type = ifdParser.next();
}
assertEquals(mIfd0Value.size(), tagNumber);
+ assertTrue(isEnterNextIfd);
+ assertTrue(isEnterExifIfd);
}
private void parseIfd1(IfdParser ifdParser) throws IOException,
ExifInvalidFormatException {
int type = ifdParser.next();
int tagNumber = 0;
+ boolean isHasInterIfd = false;
+ boolean isEnterInterIfd = false;
while (type != IfdParser.TYPE_END) {
switch (type) {
case IfdParser.TYPE_NEW_TAG:
ExifTag tag = ifdParser.readTag();
- if (tag.getDataSize() > 4
- || tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) {
+ if (tag.getDataSize() > 4) {
long offset = ifdParser.readUnsignedInt();
assertTrue(offset <= Integer.MAX_VALUE);
ifdParser.waitValueOfTag(tag, offset);
+ } else if (tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) {
+ long offset = ifdParser.readUnsignedInt();
+ assertTrue(offset <= Integer.MAX_VALUE);
+ ifdParser.waitValueOfTag(tag, offset);
+ isHasInterIfd = true;
} else {
checkTag(tag, ifdParser, mExifIfdValue);
tagNumber++;
tag = ifdParser.getCorrespodingExifTag();
if (tag.getTagId() == ExifTag.EXIF_TAG.TAG_INTEROPERABILITY_IFD) {
parseInteroperabilityIfd(ifdParser.parseIfdBlock());
+ isEnterInterIfd = true;
} else {
checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mExifIfdValue);
tagNumber++;
type = ifdParser.next();
}
assertEquals(mExifIfdValue.size(), tagNumber);
+ if (isHasInterIfd) {
+ assertTrue(isEnterInterIfd);
+ }
}
private void parseInteroperabilityIfd(IfdParser ifdParser) throws IOException,
ExifInvalidFormatException {
ExifParser exifParser = new ExifParser();
IfdParser ifdParser = exifParser.parse(mImageInputStream);
int type = ifdParser.next();
+ boolean isEnterNextIfd = false;
while (type != IfdParser.TYPE_END) {
switch (type) {
case IfdParser.TYPE_NEW_TAG:
break;
case IfdParser.TYPE_NEXT_IFD:
parseIfd1(ifdParser.parseIfdBlock());
+ isEnterNextIfd = true;
break;
case IfdParser.TYPE_VALUE_OF_PREV_TAG:
// We won't get this since to skip everything
}
type = ifdParser.next();
}
+ assertTrue(isEnterNextIfd);
}
public void testOnlySaveSomeValue() throws ExifInvalidFormatException, IOException {
ExifParser exifParser = new ExifParser();
IfdParser ifdParser = exifParser.parse(mImageInputStream);
+ boolean isEnterNextIfd = false;
+ boolean isEnterExifIfd = false;
int type = ifdParser.next();
while (type != IfdParser.TYPE_END) {
switch (type) {
break;
case IfdParser.TYPE_NEXT_IFD:
parseIfd1(ifdParser.parseIfdBlock());
+ isEnterNextIfd = true;
break;
case IfdParser.TYPE_VALUE_OF_PREV_TAG:
tag = ifdParser.getCorrespodingExifTag();
if(tag.getTagId() == ExifTag.TIFF_TAG.TAG_EXIF_IFD) {
parseExifIfd(ifdParser.parseIfdBlock());
+ isEnterExifIfd = true;
} else {
checkTag(ifdParser.getCorrespodingExifTag(), ifdParser, mIfd0Value);
}
}
type = ifdParser.next();
}
+ assertTrue(isEnterNextIfd);
+ assertTrue(isEnterExifIfd);
}
public void testReadThumbnail() throws ExifInvalidFormatException, IOException {