Switch from "skip" (index-based) lsel implementation to spatial_id matching
diff --git a/include/avif/internal.h b/include/avif/internal.h
index 3515b41..93a4d8e 100644
--- a/include/avif/internal.h
+++ b/include/avif/internal.h
@@ -164,19 +164,21 @@
// ---------------------------------------------------------------------------
// avifCodecDecodeInput
+// Legal spatial_id values are [0,1,2,3], so this serves as a sentinel value for "do not filter by spatial_id"
+#define AVIF_SPATIAL_ID_UNSET 0xff
+
typedef struct avifDecodeSample
{
avifROData data;
avifBool ownsData;
avifBool partialData; // if true, data exists but doesn't have all of the sample in it
- uint32_t itemID; // if non-zero, data comes from a mergedExtents buffer in an avifDecoderItem, not a file offset
- uint64_t offset; // additional offset into data. Can be used to offset into an itemID's payload as well.
- size_t size; //
- uint8_t skip; // After feeding this sample, this is how many frames must be skipped before returning a frame
- // This is used in layer selection, as layer selection requires that decoders decode all
- // layers sequentially, but only a specific layer index is actually wanted.
- avifBool sync; // is sync sample (keyframe)
+ uint32_t itemID; // if non-zero, data comes from a mergedExtents buffer in an avifDecoderItem, not a file offset
+ uint64_t offset; // additional offset into data. Can be used to offset into an itemID's payload as well.
+ size_t size; //
+ uint8_t spatialID; // If set to a value other than AVIF_SPATIAL_ID_UNSET, the output frame's spatial_id must match
+ // this ID, otherwise output frames from this sample should be skipped until it does.
+ avifBool sync; // is sync sample (keyframe)
} avifDecodeSample;
AVIF_ARRAY_DECLARE(avifDecodeSampleArray, avifDecodeSample, sample);