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

Function avifDecoderCheckGainMapProperties

src/read.c:5966–6001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5964}
5965
5966static avifResult avifDecoderCheckGainMapProperties(avifDecoder * decoder, const avifPropertyArray * gainMapProperties)
5967{
5968 const avifImage * image = decoder->image;
5969 // libavif requires the bitstream contain the same 'pasp', 'clap', 'irot', 'imir'
5970 // properties for both the base and gain map image items used as input to
5971 // the tone-mapped derived image item. libavif also requires the tone-mapped
5972 // derived image item itself not be associated with these properties. This is
5973 // enforced at encoding. Other patterns are rejected at decoding.
5974 const avifProperty * paspProp = avifPropertyArrayFind(gainMapProperties, "pasp");
5975 if (!paspProp != !(image->transformFlags & AVIF_TRANSFORM_PASP) ||
5976 (paspProp && (paspProp->u.pasp.hSpacing != image->pasp.hSpacing || paspProp->u.pasp.vSpacing != image->pasp.vSpacing))) {
5977 avifDiagnosticsPrintf(&decoder->diag,
5978 "Pixel aspect ratio property mismatch between input items of tone-mapping derived image item");
5979 return AVIF_RESULT_DECODE_GAIN_MAP_FAILED;
5980 }
5981 const avifProperty * clapProp = avifPropertyArrayFind(gainMapProperties, "clap");
5982 if (!clapProp != !(image->transformFlags & AVIF_TRANSFORM_CLAP) ||
5983 (clapProp && (clapProp->u.clap.widthN != image->clap.widthN || clapProp->u.clap.widthD != image->clap.widthD ||
5984 clapProp->u.clap.heightN != image->clap.heightN || clapProp->u.clap.heightD != image->clap.heightD ||
5985 clapProp->u.clap.horizOffN != image->clap.horizOffN || clapProp->u.clap.horizOffD != image->clap.horizOffD ||
5986 clapProp->u.clap.vertOffN != image->clap.vertOffN || clapProp->u.clap.vertOffD != image->clap.vertOffD))) {
5987 avifDiagnosticsPrintf(&decoder->diag, "Clean aperture property mismatch between input items of tone-mapping derived image item");
5988 return AVIF_RESULT_DECODE_GAIN_MAP_FAILED;
5989 }
5990 const avifProperty * irotProp = avifPropertyArrayFind(gainMapProperties, "irot");
5991 if (!irotProp != !(image->transformFlags & AVIF_TRANSFORM_IROT) || (irotProp && irotProp->u.irot.angle != image->irot.angle)) {
5992 avifDiagnosticsPrintf(&decoder->diag, "Rotation property mismatch between input items of tone-mapping derived image item");
5993 return AVIF_RESULT_DECODE_GAIN_MAP_FAILED;
5994 }
5995 const avifProperty * imirProp = avifPropertyArrayFind(gainMapProperties, "imir");
5996 if (!imirProp != !(image->transformFlags & AVIF_TRANSFORM_IMIR) || (imirProp && imirProp->u.imir.axis != image->imir.axis)) {
5997 avifDiagnosticsPrintf(&decoder->diag, "Mirroring property mismatch between input items of tone-mapping derived image item");
5998 return AVIF_RESULT_DECODE_GAIN_MAP_FAILED;
5999 }
6000 return AVIF_RESULT_OK;
6001}
6002
6003// Finds any 'sato' Sample Transform derived image item, distinct from the primary image item,
6004// and in the same 'altr' group as the primary image item. Returns NULL otherwise.

Callers 1

avifDecoderResetFunction · 0.85

Calls 2

avifPropertyArrayFindFunction · 0.85
avifDiagnosticsPrintfFunction · 0.85

Tested by

no test coverage detected