Expose avifDecoderItemExtent as avifExtent, and add avifDecoderNthImageMaxExtent() streaming helper function
diff --git a/include/avif/avif.h b/include/avif/avif.h
index 930a34a..806fd29 100644
--- a/include/avif/avif.h
+++ b/include/avif/avif.h
@@ -747,6 +747,34 @@
 avifResult avifDecoderNthImageTiming(const avifDecoder * decoder, uint32_t frameIndex, avifImageTiming * outTiming);
 
 // ---------------------------------------------------------------------------
+// avifExtent
+
+typedef struct avifExtent
+{
+    uint64_t offset;
+    size_t size;
+} avifExtent;
+
+// Streaming data helper - Use this to calculate the maximal AVIF data extent encompassing all AV1
+// sample data needed to decode the Nth image. The offset will be the earliest offset of all required
+// AV1 extents for this frame, and the size will create a range including the last byte of the last AV1
+// sample needed. Note that this extent may include non-sample data, as a frame's sample data
+// may be broken into multiple extents and interleaved with other data, or in non-sequential order.
+//
+// If includeDependentFrameExtents is true (recommended), this extent will also encompass all AV1
+// samples that this frame's sample depends on to decode, from the nearest keyframe up to this Nth
+// frame.
+//
+// If avifDecoderNthImageMaxExtent() returns AVIF_RESULT_OK and the extent's size is 0 bytes, the
+// data for this frame was read as a part of avifDecoderParse() (typically in an idat box inside of
+// a meta box) and no additional data will need to be read to decode this frame, assuming
+// includeDependentFrameExtents is true or this frameIndex is a keyframe.
+avifResult avifDecoderNthImageMaxExtent(const avifDecoder * decoder,
+                                        uint32_t frameIndex,
+                                        avifBool includeDependentFrameExtents,
+                                        avifExtent * outExtent);
+
+// ---------------------------------------------------------------------------
 // avifEncoder
 
 struct avifEncoderData;
diff --git a/include/avif/internal.h b/include/avif/internal.h
index 3aae746..3d0cab5 100644
--- a/include/avif/internal.h
+++ b/include/avif/internal.h
@@ -13,6 +13,7 @@
 // Yes, clamp macros are nasty. Do not use them.
 #define AVIF_CLAMP(x, low, high) (((x) < (low))) ? (low) : (((high) < (x)) ? (high) : (x))
 #define AVIF_MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define AVIF_MAX(a, b) (((a) > (b)) ? (a) : (b))
 
 // Used by stream related things.
 #define CHECK(A)               \