| 1238 | } |
| 1239 | |
| 1240 | static avifResult avifDecoderItemValidateProperties(const avifDecoderItem * item, |
| 1241 | const char * configPropName, |
| 1242 | avifDiagnostics * diag, |
| 1243 | const avifStrictFlags strictFlags) |
| 1244 | { |
| 1245 | const avifProperty * const configProp = avifPropertyArrayFind(&item->properties, configPropName); |
| 1246 | if (!configProp) { |
| 1247 | // An item configuration property box is mandatory in all valid AVIF configurations. Bail out. |
| 1248 | avifDiagnosticsPrintf(diag, "Item ID %u of type '%.4s' is missing mandatory %s property", item->id, (const char *)item->type, configPropName); |
| 1249 | return AVIF_RESULT_BMFF_PARSE_FAILED; |
| 1250 | } |
| 1251 | |
| 1252 | if (!memcmp(item->type, "grid", 4)) { |
| 1253 | for (uint32_t i = 0; i < item->meta->items.count; ++i) { |
| 1254 | avifDecoderItem * tile = item->meta->items.item[i]; |
| 1255 | if (tile->dimgForID != item->id) { |
| 1256 | continue; |
| 1257 | } |
| 1258 | // Tile item types were checked in avifDecoderGenerateImageTiles(), no need to do it here. |
| 1259 | |
| 1260 | // MIAF (ISO 23000-22:2019), Section 7.3.11.4.1: |
| 1261 | // All input images of a grid image item shall use the same [...] chroma sampling format, |
| 1262 | // and the same decoder configuration (see 7.3.6.2). |
| 1263 | |
| 1264 | // The chroma sampling format is part of the decoder configuration. |
| 1265 | const avifProperty * tileConfigProp = avifPropertyArrayFind(&tile->properties, configPropName); |
| 1266 | if (!tileConfigProp) { |
| 1267 | avifDiagnosticsPrintf(diag, |
| 1268 | "Tile item ID %u of type '%.4s' is missing mandatory %s property", |
| 1269 | tile->id, |
| 1270 | (const char *)tile->type, |
| 1271 | configPropName); |
| 1272 | return AVIF_RESULT_BMFF_PARSE_FAILED; |
| 1273 | } |
| 1274 | // configProp was copied from a tile item to the grid item. Comparing tileConfigProp with it |
| 1275 | // is equivalent to comparing tileConfigProp with the configPropName from the first tile. |
| 1276 | if ((tileConfigProp->u.av1C.seqProfile != configProp->u.av1C.seqProfile) || |
| 1277 | (tileConfigProp->u.av1C.seqLevelIdx0 != configProp->u.av1C.seqLevelIdx0) || |
| 1278 | (tileConfigProp->u.av1C.seqTier0 != configProp->u.av1C.seqTier0) || |
| 1279 | (tileConfigProp->u.av1C.highBitdepth != configProp->u.av1C.highBitdepth) || |
| 1280 | (tileConfigProp->u.av1C.twelveBit != configProp->u.av1C.twelveBit) || |
| 1281 | (tileConfigProp->u.av1C.monochrome != configProp->u.av1C.monochrome) || |
| 1282 | (tileConfigProp->u.av1C.chromaSubsamplingX != configProp->u.av1C.chromaSubsamplingX) || |
| 1283 | (tileConfigProp->u.av1C.chromaSubsamplingY != configProp->u.av1C.chromaSubsamplingY) || |
| 1284 | (tileConfigProp->u.av1C.chromaSamplePosition != configProp->u.av1C.chromaSamplePosition)) { |
| 1285 | avifDiagnosticsPrintf(diag, |
| 1286 | "The fields of the %s property of tile item ID %u of type '%.4s' differs from other tiles", |
| 1287 | configPropName, |
| 1288 | tile->id, |
| 1289 | (const char *)tile->type); |
| 1290 | return AVIF_RESULT_BMFF_PARSE_FAILED; |
| 1291 | } |
| 1292 | } |
| 1293 | } |
| 1294 | |
| 1295 | const avifProperty * pixiProp = avifPropertyArrayFind(&item->properties, "pixi"); |
| 1296 | if (!pixiProp && (strictFlags & AVIF_STRICT_PIXI_REQUIRED)) { |
| 1297 | // A pixi box is mandatory in all valid AVIF configurations. Bail out. |
no test coverage detected