Returns true if the image can be encoded with a MinimizedImageBox instead of a full regular MetaBox.
| 2355 | #if defined(AVIF_ENABLE_EXPERIMENTAL_MINI) |
| 2356 | // Returns true if the image can be encoded with a MinimizedImageBox instead of a full regular MetaBox. |
| 2357 | static avifBool avifEncoderIsMiniCompatible(const avifEncoder * encoder) |
| 2358 | { |
| 2359 | // The MinimizedImageBox ("mif3" brand) only supports non-layered, still images. |
| 2360 | if (encoder->extraLayerCount || (encoder->data->frames.count != 1)) { |
| 2361 | return AVIF_FALSE; |
| 2362 | } |
| 2363 | |
| 2364 | if (encoder->sampleTransformRecipe != AVIF_SAMPLE_TRANSFORM_NONE) { |
| 2365 | return AVIF_FALSE; |
| 2366 | } |
| 2367 | |
| 2368 | // Check for maximum field values and maximum chunk sizes. |
| 2369 | |
| 2370 | // width_minus1 and height_minus1 |
| 2371 | if (encoder->data->imageMetadata->width > (1 << 15) || encoder->data->imageMetadata->height > (1 << 15)) { |
| 2372 | return AVIF_FALSE; |
| 2373 | } |
| 2374 | // icc_data_size_minus1, exif_data_size_minus1 and xmp_data_size_minus1 |
| 2375 | if (encoder->data->imageMetadata->icc.size > (1 << 20) || encoder->data->imageMetadata->exif.size > (1 << 20) || |
| 2376 | encoder->data->imageMetadata->xmp.size > (1 << 20)) { |
| 2377 | return AVIF_FALSE; |
| 2378 | } |
| 2379 | // gainmap_width_minus1 and gainmap_height_minus1 |
| 2380 | if (encoder->data->imageMetadata->gainMap != NULL && encoder->data->imageMetadata->gainMap->image != NULL && |
| 2381 | (encoder->data->imageMetadata->gainMap->image->width > (1 << 15) || |
| 2382 | encoder->data->imageMetadata->gainMap->image->height > (1 << 15))) { |
| 2383 | return AVIF_FALSE; |
| 2384 | } |
| 2385 | // tmap_icc_data_size_minus1 |
| 2386 | if (encoder->data->altImageMetadata->icc.size > (1 << 20)) { |
| 2387 | return AVIF_FALSE; |
| 2388 | } |
| 2389 | // gainmap_metadata_size |
| 2390 | if (encoder->data->imageMetadata->gainMap != NULL && avifGainMapMetadataSize(encoder->data->imageMetadata->gainMap) >= (1 << 20)) { |
| 2391 | return AVIF_FALSE; |
| 2392 | } |
| 2393 | |
| 2394 | // 4:4:4, 4:2:2, 4:2:0 and 4:0:0 are supported by a MinimizedImageBox. |
| 2395 | // chroma_subsampling |
| 2396 | if (encoder->data->imageMetadata->yuvFormat != AVIF_PIXEL_FORMAT_YUV444 && |
| 2397 | encoder->data->imageMetadata->yuvFormat != AVIF_PIXEL_FORMAT_YUV422 && |
| 2398 | encoder->data->imageMetadata->yuvFormat != AVIF_PIXEL_FORMAT_YUV420 && |
| 2399 | encoder->data->imageMetadata->yuvFormat != AVIF_PIXEL_FORMAT_YUV400) { |
| 2400 | return AVIF_FALSE; |
| 2401 | } |
| 2402 | // gainmap_chroma_subsampling |
| 2403 | if (encoder->data->imageMetadata->gainMap != NULL && encoder->data->imageMetadata->gainMap->image != NULL && |
| 2404 | (encoder->data->imageMetadata->gainMap->image->yuvFormat != AVIF_PIXEL_FORMAT_YUV444 && |
| 2405 | encoder->data->imageMetadata->gainMap->image->yuvFormat != AVIF_PIXEL_FORMAT_YUV422 && |
| 2406 | encoder->data->imageMetadata->gainMap->image->yuvFormat != AVIF_PIXEL_FORMAT_YUV420 && |
| 2407 | encoder->data->imageMetadata->gainMap->image->yuvFormat != AVIF_PIXEL_FORMAT_YUV400)) { |
| 2408 | return AVIF_FALSE; |
| 2409 | } |
| 2410 | |
| 2411 | // colour_primaries, transfer_characteristics and matrix_coefficients |
| 2412 | if (encoder->data->imageMetadata->colorPrimaries > 255 || encoder->data->imageMetadata->transferCharacteristics > 255 || |
| 2413 | encoder->data->imageMetadata->matrixCoefficients > 255) { |
| 2414 | return AVIF_FALSE; |
no test coverage detected