[FFmpeg-devel] [PATCH] vc1dec: propagate error codes
wm4
nfxjfg at googlemail.com
Thu Aug 6 11:27:00 CEST 2015
Also fix some instances of returning -1 as error code.
---
Note that not all of the mpegvideo functions return meaningful error
codes, but that should be ok for now.
---
libavcodec/vc1dec.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 653ce9e..11092a6 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -283,7 +283,7 @@ static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb)
if (!s->current_picture.f || !s->current_picture.f->data[0]) {
av_log(avctx, AV_LOG_ERROR, "Got no sprites\n");
- return -1;
+ return AVERROR_UNKNOWN;
}
if (v->two_sprites && (!s->last_picture_ptr || !s->last_picture.f->data[0])) {
@@ -615,7 +615,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
- int buf_size = avpkt->size, n_slices = 0, i, ret;
+ int buf_size = avpkt->size, n_slices = 0, i, ret = AVERROR_UNKNOWN;
VC1Context *v = avctx->priv_data;
MpegEncContext *s = &v->s;
AVFrame *pict = data;
@@ -783,9 +783,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
}
if (!s->context_initialized) {
- if (ff_msmpeg4_decode_init(avctx) < 0)
+ if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
goto err;
- if (ff_vc1_decode_init_alloc_tables(v) < 0) {
+ if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0) {
ff_mpv_common_end(s);
goto err;
}
@@ -804,11 +804,11 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
v->pic_header_flag = 0;
v->first_pic_header_flag = 1;
if (v->profile < PROFILE_ADVANCED) {
- if (ff_vc1_parse_frame_header(v, &s->gb) < 0) {
+ if ((ret = ff_vc1_parse_frame_header(v, &s->gb)) < 0) {
goto err;
}
} else {
- if (ff_vc1_parse_frame_header_adv(v, &s->gb) < 0) {
+ if ((ret = ff_vc1_parse_frame_header_adv(v, &s->gb)) < 0) {
goto err;
}
}
@@ -850,7 +850,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
s->next_p_frame_damaged = 0;
}
- if (ff_mpv_frame_start(s, avctx) < 0) {
+ if ((ret = ff_mpv_frame_start(s, avctx)) < 0) {
goto err;
}
@@ -885,11 +885,11 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
if (v->field_mode && buf_start_second_field) {
// decode first field
s->picture_structure = PICT_BOTTOM_FIELD - v->tff;
- if (avctx->hwaccel->start_frame(avctx, buf_start, buf_start_second_field - buf_start) < 0)
+ if ((ret = avctx->hwaccel->start_frame(avctx, buf_start, buf_start_second_field - buf_start)) < 0)
goto err;
- if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_start_second_field - buf_start) < 0)
+ if ((ret = avctx->hwaccel->decode_slice(avctx, buf_start, buf_start_second_field - buf_start)) < 0)
goto err;
- if (avctx->hwaccel->end_frame(avctx) < 0)
+ if ((ret = avctx->hwaccel->end_frame(avctx)) < 0)
goto err;
// decode second field
@@ -903,19 +903,19 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
}
v->s.current_picture_ptr->f->pict_type = v->s.pict_type;
- if (avctx->hwaccel->start_frame(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field) < 0)
+ if ((ret = avctx->hwaccel->start_frame(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field)) < 0)
goto err;
- if (avctx->hwaccel->decode_slice(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field) < 0)
+ if ((ret = avctx->hwaccel->decode_slice(avctx, buf_start_second_field, (buf + buf_size) - buf_start_second_field)) < 0)
goto err;
- if (avctx->hwaccel->end_frame(avctx) < 0)
+ if ((ret = avctx->hwaccel->end_frame(avctx)) < 0)
goto err;
} else {
s->picture_structure = PICT_FRAME;
- if (avctx->hwaccel->start_frame(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
+ if ((ret = avctx->hwaccel->start_frame(avctx, buf_start, (buf + buf_size) - buf_start)) < 0)
goto err;
- if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
+ if ((ret = avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start)) < 0)
goto err;
- if (avctx->hwaccel->end_frame(avctx) < 0)
+ if ((ret = avctx->hwaccel->end_frame(avctx)) < 0)
goto err;
}
} else {
@@ -1027,7 +1027,7 @@ image:
if (avctx->skip_frame >= AVDISCARD_NONREF)
goto end;
#if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
- if (vc1_decode_sprites(v, &s->gb))
+ if ((ret = vc1_decode_sprites(v, &s->gb)) < 0)
goto err;
#endif
if ((ret = av_frame_ref(pict, v->sprite_output_frame)) < 0)
@@ -1059,7 +1059,7 @@ err:
for (i = 0; i < n_slices; i++)
av_free(slices[i].buf);
av_free(slices);
- return -1;
+ return ret;
}
--
2.5.0
More information about the ffmpeg-devel
mailing list