path: root/audio/decode
diff options
authorwm4 <wm4@nowhere>2013-02-09 15:15:37 +0100
committerwm4 <wm4@nowhere>2013-02-10 17:25:57 +0100
commit01869d1391fc5cc843e132f9d05d6896ba5b4d6b (patch)
tree52220117ec9cb63328ab2a7cbbbcbec0ade61a85 /audio/decode
parentdd61fac9438a0ba83513c9346debf73e7f9d2b4d (diff)
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 'audio/decode')
1 files changed, 10 insertions, 8 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index f6efde4437..1f59280275 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -221,24 +221,23 @@ static int init(sh_audio_t *sh_audio, const char *decoder)
lavc_context = avcodec_alloc_context3(lavc_codec);
ctx->avctx = lavc_context;
ctx->avframe = avcodec_alloc_frame();
+ lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
+ lavc_context->codec_id = lavc_codec->id;
+ lavc_context->request_channels = opts->audio_output_channels;
// Always try to set - option only exists for AC3 at the moment
av_opt_set_double(lavc_context, "drc_scale", opts->drc_level,
+ lavc_context->codec_tag = sh_audio->format;
lavc_context->sample_rate = sh_audio->samplerate;
lavc_context->bit_rate = sh_audio->i_bps * 8;
- lavc_context->request_channels = opts->audio_output_channels;
- lavc_context->codec_tag = sh_audio->format; //FOURCC
- if (sh_audio->gsh->lavf_codec_tag)
- lavc_context->codec_tag = sh_audio->gsh->lavf_codec_tag;
- lavc_context->codec_type = AVMEDIA_TYPE_AUDIO;
- lavc_context->codec_id = lavc_codec->id; // not sure if required, imho not --A'rpi
if (sh_audio->wf)
set_from_wf(lavc_context, sh_audio->wf);
- // for QDM2
+ // demux_mkv, demux_mpg
if (sh_audio->codecdata_len && sh_audio->codecdata &&
!lavc_context->extradata) {
lavc_context->extradata = av_malloc(sh_audio->codecdata_len +
@@ -248,6 +247,9 @@ static int init(sh_audio_t *sh_audio, const char *decoder)
+ if (sh_audio->gsh->lav_headers)
+ mp_copy_lav_codec_headers(lavc_context, sh_audio->gsh->lav_headers);
/* open it */
if (avcodec_open2(lavc_context, lavc_codec, NULL) < 0) {
mp_tmsg(MSGT_DECAUDIO, MSGL_ERR, "Could not open codec.\n");