Skip to content

Commit 83fc735

Browse files
committed
codec_aom: unify decoder libaom diagnostics formatting
1 parent f0eb53e commit 83fc735

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

src/codec_aom.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ static void aomCodecDestroyInternal(avifCodec * codec)
9090
avifFree(codec->internal);
9191
}
9292

93+
// Writes a libaom error code and error detail into diagnostics.
94+
static void aomDiagPrintf(avifDiagnostics * diag, const char * func, const char * error, const char * detail)
95+
{
96+
avifDiagnosticsPrintf(diag, "%s failed: %s: %s", func, error, detail ? detail : "no error detail");
97+
}
98+
9399
#if defined(AVIF_CODEC_AOM_DECODE)
94100

95101
static avifBool aomCodecGetNextImage(struct avifCodec * codec,
@@ -127,14 +133,26 @@ static avifBool aomCodecGetNextImage(struct avifCodec * codec,
127133
cfg.allow_lowbitdepth = 1;
128134

129135
if (aom_codec_dec_init(&codec->internal->decoder, decoderInterface, &cfg, 0)) {
136+
aomDiagPrintf(codec->diag,
137+
"aom_codec_dec_init()",
138+
aom_codec_error(&codec->internal->decoder),
139+
aom_codec_error_detail(&codec->internal->decoder));
130140
return AVIF_FALSE;
131141
}
132142
codec->internal->decoderInitialized = AVIF_TRUE;
133143

134144
if (aom_codec_control(&codec->internal->decoder, AV1D_SET_OUTPUT_ALL_LAYERS, codec->allLayers)) {
145+
aomDiagPrintf(codec->diag,
146+
"aom_codec_control(AV1D_SET_OUTPUT_ALL_LAYERS)",
147+
aom_codec_error(&codec->internal->decoder),
148+
aom_codec_error_detail(&codec->internal->decoder));
135149
return AVIF_FALSE;
136150
}
137151
if (aom_codec_control(&codec->internal->decoder, AV1D_SET_OPERATING_POINT, codec->operatingPoint)) {
152+
aomDiagPrintf(codec->diag,
153+
"aom_codec_control(AV1D_SET_OPERATING_POINT)",
154+
aom_codec_error(&codec->internal->decoder),
155+
aom_codec_error_detail(&codec->internal->decoder));
138156
return AVIF_FALSE;
139157
}
140158

@@ -160,11 +178,10 @@ static avifBool aomCodecGetNextImage(struct avifCodec * codec,
160178
} else if (sample) {
161179
codec->internal->iter = NULL;
162180
if (aom_codec_decode(&codec->internal->decoder, sample->data.data, sample->data.size, NULL)) {
163-
const char * error_detail = aom_codec_error_detail(&codec->internal->decoder);
164-
avifDiagnosticsPrintf(codec->diag,
165-
"aom_codec_decode() failed: %s: %s",
166-
aom_codec_error(&codec->internal->decoder),
167-
error_detail ? error_detail : "no error detail");
181+
aomDiagPrintf(codec->diag,
182+
"aom_codec_decode()",
183+
aom_codec_error(&codec->internal->decoder),
184+
aom_codec_error_detail(&codec->internal->decoder));
168185
return AVIF_FALSE;
169186
}
170187
spatialID = sample->spatialID;

0 commit comments

Comments
 (0)