MCPcopy Create free account
hub / github.com/AOMediaCodec/libavif / avifDecoderCheckAlphaProperties

Function avifDecoderCheckAlphaProperties

src/read.c:5921–5964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5919}
5920
5921static avifResult avifDecoderCheckAlphaProperties(avifDecoder * decoder, const avifPropertyArray * alphaProperties)
5922{
5923 const avifImage * image = decoder->image;
5924 // The 'clap', 'irot' and 'imir' transformative properties should be applied to the alpha
5925 // auxiliary image item before considering it a plane of the color image item.
5926 // Alternatively, inequality with the transformative properties attached to the color image item
5927 // should be treated as AVIF_RESULT_NOT_IMPLEMENTED.
5928 // The latter is easier and is the behavior of libavif.
5929
5930 const avifProperty * clapProp = avifPropertyArrayFind(alphaProperties, "clap");
5931 const avifProperty * irotProp = avifPropertyArrayFind(alphaProperties, "irot");
5932 const avifProperty * imirProp = avifPropertyArrayFind(alphaProperties, "imir");
5933 if (clapProp == NULL && irotProp == NULL && imirProp == NULL) {
5934 // However, libavif up to version 1.3.0 generated images lacking transformative property
5935 // associations with alpha auxiliary image items, so be lenient on their absence for
5936 // backward compatibility with previously generated images.
5937 return AVIF_RESULT_OK;
5938 }
5939
5940 // HEIF (ISO/IEC 23008-12), Section 6.9.1:
5941 // When the width or the height of the alpha plane differs from the width or the height of the
5942 // master image, respectively, the alpha plane is resized to have the same width and height as
5943 // those of the master image.
5944 // There is no need to enforce specific 'ispe' values describing the alpha item because
5945 // the alpha item must be resized to the dimensions of the associated color item.
5946
5947 if (!clapProp != !(image->transformFlags & AVIF_TRANSFORM_CLAP) ||
5948 (clapProp && (clapProp->u.clap.widthN != image->clap.widthN || clapProp->u.clap.widthD != image->clap.widthD ||
5949 clapProp->u.clap.heightN != image->clap.heightN || clapProp->u.clap.heightD != image->clap.heightD ||
5950 clapProp->u.clap.horizOffN != image->clap.horizOffN || clapProp->u.clap.horizOffD != image->clap.horizOffD ||
5951 clapProp->u.clap.vertOffN != image->clap.vertOffN || clapProp->u.clap.vertOffD != image->clap.vertOffD))) {
5952 avifDiagnosticsPrintf(&decoder->diag, "Clean aperture property mismatch between alpha auxiliary image item and color item");
5953 return AVIF_RESULT_NOT_IMPLEMENTED;
5954 }
5955 if (!irotProp != !(image->transformFlags & AVIF_TRANSFORM_IROT) || (irotProp && irotProp->u.irot.angle != image->irot.angle)) {
5956 avifDiagnosticsPrintf(&decoder->diag, "Rotation property mismatch between alpha auxiliary image item and color item");
5957 return AVIF_RESULT_NOT_IMPLEMENTED;
5958 }
5959 if (!imirProp != !(image->transformFlags & AVIF_TRANSFORM_IMIR) || (imirProp && imirProp->u.imir.axis != image->imir.axis)) {
5960 avifDiagnosticsPrintf(&decoder->diag, "Mirroring property mismatch between alpha auxiliary image item and color item");
5961 return AVIF_RESULT_NOT_IMPLEMENTED;
5962 }
5963 return AVIF_RESULT_OK;
5964}
5965
5966static avifResult avifDecoderCheckGainMapProperties(avifDecoder * decoder, const avifPropertyArray * gainMapProperties)
5967{

Callers 1

avifDecoderResetFunction · 0.85

Calls 2

avifPropertyArrayFindFunction · 0.85
avifDiagnosticsPrintfFunction · 0.85

Tested by

no test coverage detected