Move checks to avifAreGridDimensionsValid() (#834)
It was possible to encode a 65x65 4:2:0 image with avifenc that could
not be decoded with avifdec. Calling avifAreGridDimensionsValid() from
both encoding and decoding pipelines removes this asymmetric behavior.
Add tests/avifgridapitest.c.
diff --git a/include/avif/internal.h b/include/avif/internal.h
index b71cdaf..f88e4e3 100644
--- a/include/avif/internal.h
+++ b/include/avif/internal.h
@@ -169,6 +169,18 @@
avifBool avifImageScale(avifImage * image, uint32_t dstWidth, uint32_t dstHeight, uint32_t imageSizeLimit, avifDiagnostics * diag);
// ---------------------------------------------------------------------------
+// Grid AVIF images
+
+// Returns false if the tiles in a grid image violate any standards.
+// The image contains imageW*imageH pixels. The tiles are of tileW*tileH pixels each.
+AVIF_API avifBool avifAreGridDimensionsValid(avifPixelFormat yuvFormat,
+ uint32_t imageW,
+ uint32_t imageH,
+ uint32_t tileW,
+ uint32_t tileH,
+ avifDiagnostics * diag);
+
+// ---------------------------------------------------------------------------
// avifCodecDecodeInput
// Legal spatial_id values are [0,1,2,3], so this serves as a sentinel value for "do not filter by spatial_id"