Skip to content

Commit

Permalink
Inline avifCodecConfigurationBoxGetFormat()
Browse files Browse the repository at this point in the history
Unused unless AVIF_ENABLE_EXPERIMENTAL_MINI is defined.
  • Loading branch information
y-guyon committed Nov 22, 2024
1 parent 7766d13 commit 858b0cd
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,6 @@ static uint32_t avifCodecConfigurationBoxGetDepth(const avifCodecConfigurationBo
return 8;
}

// This is used as a hint to validating the clap box in avifDecoderItemValidateProperties.
static avifPixelFormat avifCodecConfigurationBoxGetFormat(const avifCodecConfigurationBox * av1C)
{
if (av1C->monochrome) {
return AVIF_PIXEL_FORMAT_YUV400;
} else if (av1C->chromaSubsamplingY == 1) {
return AVIF_PIXEL_FORMAT_YUV420;
} else if (av1C->chromaSubsamplingX == 1) {
return AVIF_PIXEL_FORMAT_YUV422;
}
return AVIF_PIXEL_FORMAT_YUV444;
}

static const avifPropertyArray * avifSampleTableGetProperties(const avifSampleTable * sampleTable, avifCodecType codecType)
{
for (uint32_t i = 0; i < sampleTable->sampleDescriptions.count; ++i) {
Expand Down Expand Up @@ -1231,9 +1218,19 @@ static avifResult avifDecoderItemValidateProperties(const avifDecoderItem * item
if (item->miniBoxPixelFormat != AVIF_PIXEL_FORMAT_NONE) {
// This is a MinimizedImageBox ('mini').

if (item->miniBoxPixelFormat != avifCodecConfigurationBoxGetFormat(&configProp->u.av1C)) {
avifPixelFormat av1CPixelFormat;
if (configProp->u.av1C.monochrome) {
av1CPixelFormat = AVIF_PIXEL_FORMAT_YUV400;
} else if (configProp->u.av1C.chromaSubsamplingY == 1) {
av1CPixelFormat = AVIF_PIXEL_FORMAT_YUV420;
} else if (configProp->u.av1C.chromaSubsamplingX == 1) {
av1CPixelFormat = AVIF_PIXEL_FORMAT_YUV422;
} else {
av1CPixelFormat = AVIF_PIXEL_FORMAT_YUV444;
}
if (item->miniBoxPixelFormat != av1CPixelFormat) {
if (!memcmp(configPropName, "av2C", 4) && item->miniBoxPixelFormat == AVIF_PIXEL_FORMAT_YUV400 &&
avifCodecConfigurationBoxGetFormat(&configProp->u.av1C) == AVIF_PIXEL_FORMAT_YUV420) {
av1CPixelFormat == AVIF_PIXEL_FORMAT_YUV420) {
// avm does not handle monochrome as of research-v8.0.0.
// 4:2:0 is used instead.
} else {
Expand All @@ -1242,7 +1239,7 @@ static avifResult avifDecoderItemValidateProperties(const avifDecoderItem * item
item->id,
avifPixelFormatToString(item->miniBoxPixelFormat),
configPropName,
avifPixelFormatToString(avifCodecConfigurationBoxGetFormat(&configProp->u.av1C)));
avifPixelFormatToString(av1CPixelFormat));
return AVIF_RESULT_BMFF_PARSE_FAILED;
}
}
Expand Down

0 comments on commit 858b0cd

Please sign in to comment.