diff options
author | wm4 <wm4@nowhere> | 2013-02-09 15:15:37 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-02-10 17:25:57 +0100 |
commit | 01869d1391fc5cc843e132f9d05d6896ba5b4d6b (patch) | |
tree | 52220117ec9cb63328ab2a7cbbbcbec0ade61a85 /video/decode | |
parent | dd61fac9438a0ba83513c9346debf73e7f9d2b4d (diff) | |
download | mpv-01869d1391fc5cc843e132f9d05d6896ba5b4d6b.tar.bz2 mpv-01869d1391fc5cc843e132f9d05d6896ba5b4d6b.tar.xz |
demux_lavf, ad_lavc, vd_lavc: pass codec header data directly
Instead of putting codec header data into WAVEFORMATEX and
BITMAPINFOHEADER, pass it directly via AVCodecContext. To do this, we
add mp_copy_lav_codec_headers(), which copies the codec header data
from one AVCodecContext to another (originally, the plan was to use
avcodec_copy_context() for this, but it looks like this would turn
decoder initialization into an even worse mess).
Get rid of the silly CodecID <-> codec_tag mapping. This was originally
needed for codecs.conf: codec tags were used to identify codecs, but
libavformat didn't always return useful codec tags (different file
formats can have different, overlapping tag numbers). Since we don't
go through WAVEFORMATEX etc. and pass all header data directly via
AVCodecContext, we can be absolutely sure that the codec tag mapping is
not needed anymore.
Note that this also destroys the "standard" MPlayer method of exporting
codec header data. WAVEFORMATEX and BITMAPINFOHEADER made sure that
other non-libavcodec decoders could be initialized. However, all these
decoders have been removed, so this is just cruft full of old hacks that
are not needed anymore. There's still ad_spdif and ad_mpg123, bu neither
of these need codec header data. Should we ever add non-libavcodec
decoders, better data structures without the past hacks could be added
to export the headers.
Diffstat (limited to 'video/decode')
-rw-r--r-- | video/decode/vd_lavc.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 9801361cb2..9a8aa41888 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -297,16 +297,10 @@ static int init_avctx(sh_video_t *sh, const char *decoder, struct hwdec *hwdec) avctx->flags |= lavc_param->bitexact; - avctx->coded_width = sh->disp_w; - avctx->coded_height = sh->disp_h; avctx->workaround_bugs = lavc_param->workaround_bugs; if (lavc_param->gray) avctx->flags |= CODEC_FLAG_GRAY; avctx->flags2 |= lavc_param->fast; - avctx->codec_tag = sh->format; - if (sh->gsh->lavf_codec_tag) - avctx->codec_tag = sh->gsh->lavf_codec_tag; - avctx->stream_codec_tag = sh->video.fccHandler; avctx->idct_algo = lavc_param->idct_algo; avctx->error_concealment = lavc_param->error_concealment; avctx->debug = lavc_param->debug; @@ -332,6 +326,14 @@ static int init_avctx(sh_video_t *sh, const char *decoder, struct hwdec *hwdec) // Do this after the above avopt handling in case it changes values ctx->skip_frame = avctx->skip_frame; + avctx->codec_tag = sh->format; + avctx->coded_width = sh->disp_w; + avctx->coded_height = sh->disp_h; + + // demux_avi only + avctx->stream_codec_tag = sh->video.fccHandler; + + // demux_mkv, demux_avi, demux_asf if (sh->bih) set_from_bih(avctx, sh->format, sh->bih); @@ -340,6 +342,9 @@ static int init_avctx(sh_video_t *sh, const char *decoder, struct hwdec *hwdec) avctx->codec_tag = 0; } + if (sh->gsh->lav_headers) + mp_copy_lav_codec_headers(avctx, sh->gsh->lav_headers); + /* open it */ if (avcodec_open2(avctx, lavc_codec, NULL) < 0) { mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Could not open codec.\n"); |