Add IO stats to avif to see how large OBUs are after read/write
diff --git a/include/avif/avif.h b/include/avif/avif.h index 5fd3471..4b1953b 100644 --- a/include/avif/avif.h +++ b/include/avif/avif.h
@@ -281,6 +281,13 @@ avifProfileFormat profileFormat; avifRawData icc; avifNclxColorProfile nclx; + + // Useful stats from the most recent read/write + struct IOStats + { + size_t colorOBUSize; + size_t alphaOBUSize; + } ioStats; } avifImage; avifImage * avifImageCreate(int width, int height, int depth, avifPixelFormat yuvFormat);
diff --git a/src/read.c b/src/read.c index 7f5d03e..c87a079 100644 --- a/src/read.c +++ b/src/read.c
@@ -707,5 +707,8 @@ if (codec) { avifCodecDestroy(codec); } + + image->ioStats.colorOBUSize = colorOBU.size; + image->ioStats.alphaOBUSize = alphaOBU.size; return AVIF_RESULT_OK; }
diff --git a/src/write.c b/src/write.c index 9719a7b..700867e 100644 --- a/src/write.c +++ b/src/write.c
@@ -285,6 +285,13 @@ avifStreamFinishBox(&s, meta); avifStreamFinishWrite(&s); + + // ----------------------------------------------------------------------- + // IO stats + + image->ioStats.colorOBUSize = colorOBU.size; + image->ioStats.alphaOBUSize = alphaOBU.size; + result = AVIF_RESULT_OK; // -----------------------------------------------------------------------