Skip to content

Commit 1109e13

Browse files
committed
Improve libaom decoder error handling consistency
1 parent 3b1384c commit 1109e13

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/codec_aom.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ static avifBool aomCodecGetNextImage(struct avifCodec * codec,
101101
assert(sample);
102102

103103
aom_codec_iface_t * const decoderInterface = aom_codec_av1_dx();
104+
if (!decoderInterface) {
105+
avifDiagnosticsPrintf(codec->diag, "aom_codec_av1_dx() failed");
106+
return AVIF_FALSE;
107+
}
104108
struct aom_codec_stream_info streamInfo = { 0 };
105109
aom_codec_err_t err = aom_codec_peek_stream_info(decoderInterface, sample->data.data, sample->data.size, &streamInfo);
106110
if (err != AOM_CODEC_OK) {
@@ -127,11 +131,21 @@ static avifBool aomCodecGetNextImage(struct avifCodec * codec,
127131
cfg.allow_lowbitdepth = 1;
128132

129133
if (aom_codec_dec_init(&codec->internal->decoder, decoderInterface, &cfg, 0)) {
134+
const char * error_detail = aom_codec_error_detail(&codec->internal->decoder);
135+
avifDiagnosticsPrintf(codec->diag,
136+
"aom_codec_dec_init() failed: %s: %s",
137+
aom_codec_error(&codec->internal->decoder),
138+
error_detail ? error_detail : "no error detail");
130139
return AVIF_FALSE;
131140
}
132141
codec->internal->decoderInitialized = AVIF_TRUE;
133142

134143
if (aom_codec_control(&codec->internal->decoder, AV1D_SET_OUTPUT_ALL_LAYERS, codec->allLayers)) {
144+
const char * error_detail = aom_codec_error_detail(&codec->internal->decoder);
145+
avifDiagnosticsPrintf(codec->diag,
146+
"aom_codec_control(AV1D_SET_OUTPUT_ALL_LAYERS) failed: %s: %s",
147+
aom_codec_error(&codec->internal->decoder),
148+
error_detail ? error_detail : "no error detail");
135149
return AVIF_FALSE;
136150
}
137151
if (aom_codec_control(&codec->internal->decoder, AV1D_SET_OPERATING_POINT, codec->operatingPoint)) {
@@ -183,7 +197,6 @@ static avifBool aomCodecGetNextImage(struct avifCodec * codec,
183197
return AVIF_FALSE;
184198
}
185199
}
186-
187200
avifBool isColor = !alpha;
188201
if (isColor) {
189202
// Color (YUV) planes - set image to correct size / format, fill color

0 commit comments

Comments
 (0)