diff options
author | wm4 <wm4@nowhere> | 2017-01-25 08:24:19 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-01-25 08:24:19 +0100 |
commit | 801fa486b0b43badd05cbab64d796b3eb5a2d129 (patch) | |
tree | 15c9b086a51d50fadb7d03e52e81632907848b42 /video/decode/vd_lavc.c | |
parent | ce803da90d432cef7befa3eee3b359e14cdacccb (diff) | |
download | mpv-801fa486b0b43badd05cbab64d796b3eb5a2d129.tar.bz2 mpv-801fa486b0b43badd05cbab64d796b3eb5a2d129.tar.xz |
ad_lavc, vd_lavc: move mpv->lavc decoder parameter setup to common code
This can be useful in other contexts.
Note that we end up setting AVCodecContext.width/height instead of
coded_width/coded_height now. AVCodecParameters can't set coded_width,
but this is probably more correct anyway.
Diffstat (limited to 'video/decode/vd_lavc.c')
-rw-r--r-- | video/decode/vd_lavc.c | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index c4cfbc30d3..7e3c36ecfc 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -468,15 +468,12 @@ static void init_avctx(struct dec_video *vd, const char *decoder, { vd_ffmpeg_ctx *ctx = vd->priv; struct vd_lavc_params *lavc_param = vd->opts->vd_lavc_params; - bool mp_rawvideo = false; struct mp_codec_params *c = vd->codec; assert(!ctx->avctx); - if (strcmp(decoder, "mp-rawvideo") == 0) { - mp_rawvideo = true; + if (strcmp(decoder, "mp-rawvideo") == 0) decoder = "rawvideo"; - } AVCodec *lavc_codec = avcodec_find_decoder_by_name(decoder); if (!lavc_codec) @@ -536,23 +533,11 @@ static void init_avctx(struct dec_video *vd, const char *decoder, // Do this after the above avopt handling in case it changes values ctx->skip_frame = avctx->skip_frame; - avctx->codec_tag = c->codec_tag; - avctx->coded_width = c->disp_w; - avctx->coded_height = c->disp_h; - avctx->bits_per_coded_sample = c->bits_per_coded_sample; - - mp_lavc_set_extradata(avctx, c->extradata, c->extradata_size); - - if (mp_rawvideo) { - avctx->pix_fmt = imgfmt2pixfmt(c->codec_tag); - avctx->codec_tag = 0; - if (avctx->pix_fmt == AV_PIX_FMT_NONE && c->codec_tag) - MP_ERR(vd, "Image format %s not supported by lavc.\n", - mp_imgfmt_to_name(c->codec_tag)); + if (mp_set_avctx_codec_headers(avctx, c) < 0) { + MP_ERR(vd, "Could not set codec parameters.\n"); + goto error; } - mp_set_lav_codec_headers(avctx, c); - /* open it */ if (avcodec_open2(avctx, lavc_codec, NULL) < 0) goto error; |