summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-13 22:00:42 +0100
committerwm4 <wm4@nowhere>2014-12-13 22:00:42 +0100
commitaaa319fcbdaf7ef5bcf76c6e8727532ebee2c973 (patch)
tree72562268ea003784c212c026c771a15ba6818ead /video
parent291ae3d65991a8f70ac44167236823331d0ec97c (diff)
downloadmpv-aaa319fcbdaf7ef5bcf76c6e8727532ebee2c973.tar.bz2
mpv-aaa319fcbdaf7ef5bcf76c6e8727532ebee2c973.tar.xz
vd_lavc: fix error handling path
The ctx->pic check must uninitialize the decoder.
Diffstat (limited to 'video')
-rw-r--r--video/decode/vd_lavc.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 3201ac85cf..2716a848e7 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -354,7 +354,7 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
ctx->avctx = avcodec_alloc_context3(lavc_codec);
AVCodecContext *avctx = ctx->avctx;
if (!ctx->avctx)
- return;
+ goto error;
avctx->bit_rate = 0;
avctx->opaque = vd;
avctx->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -363,16 +363,14 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
avctx->refcounted_frames = 1;
ctx->pic = av_frame_alloc();
if (!ctx->pic)
- return;
+ goto error;
if (ctx->hwdec) {
avctx->thread_count = 1;
avctx->get_format = get_format_hwdec;
avctx->get_buffer2 = get_buffer2_hwdec;
- if (ctx->hwdec->init(ctx) < 0) {
- uninit_avctx(vd);
- return;
- }
+ if (ctx->hwdec->init(ctx) < 0)
+ goto error;
} else {
mp_set_avcodec_threads(avctx, lavc_param->threads);
}
@@ -422,11 +420,14 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
mp_copy_lav_codec_headers(avctx, sh->lav_headers);
/* open it */
- if (avcodec_open2(avctx, lavc_codec, NULL) < 0) {
- MP_ERR(vd, "Could not open codec.\n");
- uninit_avctx(vd);
- return;
- }
+ if (avcodec_open2(avctx, lavc_codec, NULL) < 0)
+ goto error;
+
+ return;
+
+error:
+ MP_ERR(vd, "Could not open codec.\n");
+ uninit_avctx(vd);
}
static void uninit_avctx(struct dec_video *vd)