Use avifDecoderItemShouldBeSkipped when harvesting ispe
This function has the same conditions as the ones that are
explicitly re-written with one extra condition (thumbnailForID
!= 0). This extra condition is okay to be checked too in this
case since we anyway do not process such items.
diff --git a/src/read.c b/src/read.c
index 32e279b..ce09af4 100644
--- a/src/read.c
+++ b/src/read.c
@@ -4355,6 +4355,17 @@
return AVIF_RESULT_OK;
}
+// Returns AVIF_TRUE if the item should be skipped. Items should be skipped for one of the following reasons:
+// * Size is 0.
+// * Has an essential property that isn't supported by libavif.
+// * Item is not a single image or a grid.
+// * Item is a thumbnail.
+static avifBool avifDecoderItemShouldBeSkipped(const avifDecoderItem * item)
+{
+ return !item->size || item->hasUnsupportedEssentialProperty ||
+ (avifGetCodecType(item->type) == AVIF_CODEC_TYPE_UNKNOWN && memcmp(item->type, "grid", 4)) || item->thumbnailForID != 0;
+}
+
avifResult avifDecoderParse(avifDecoder * decoder)
{
avifDiagnosticsClearError(&decoder->diag);
@@ -4384,16 +4395,7 @@
avifDecoderData * data = decoder->data;
for (uint32_t itemIndex = 0; itemIndex < data->meta->items.count; ++itemIndex) {
avifDecoderItem * item = data->meta->items.item[itemIndex];
- if (!item->size) {
- continue;
- }
- if (item->hasUnsupportedEssentialProperty) {
- // An essential property isn't supported by libavif; ignore the item.
- continue;
- }
- avifBool isGrid = (memcmp(item->type, "grid", 4) == 0);
- if ((avifGetCodecType(item->type) == AVIF_CODEC_TYPE_UNKNOWN) && !isGrid) {
- // probably exif or some other data
+ if (avifDecoderItemShouldBeSkipped(item)) {
continue;
}
@@ -4539,17 +4541,6 @@
return AVIF_RESULT_OK;
}
-// Returns AVIF_TRUE if the item should be skipped. Items should be skipped for one of the following reasons:
-// * Size is 0.
-// * Has an essential property that isn't supported by libavif.
-// * Item is not a single image or a grid.
-// * Item is a thumbnail.
-static avifBool avifDecoderItemShouldBeSkipped(const avifDecoderItem * item)
-{
- return !item->size || item->hasUnsupportedEssentialProperty ||
- (avifGetCodecType(item->type) == AVIF_CODEC_TYPE_UNKNOWN && memcmp(item->type, "grid", 4)) || item->thumbnailForID != 0;
-}
-
// Returns the primary color item if found, or NULL.
static avifDecoderItem * avifMetaFindColorItem(avifMeta * meta)
{