From 671df54e4dcf0675c335483d26f7f6ff9baaf76a Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 12 Jan 2016 23:48:19 +0100 Subject: demux: merge sh_video/sh_audio/sh_sub This is mainly a refactor. I'm hoping it will make some things easier in the future due to cleanly separating codec metadata and stream metadata. Also, declare that the "codec" field can not be NULL anymore. demux.c will set it to "" if it's NULL when added. This gets rid of a corner case everything had to handle, but which rarely happened. --- audio/decode/ad_lavc.c | 31 +++++++++++++++---------------- audio/decode/dec_audio.c | 4 ++-- 2 files changed, 17 insertions(+), 18 deletions(-) (limited to 'audio') diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c index f4a0a243d1..7e5c8d5aa5 100644 --- a/audio/decode/ad_lavc.c +++ b/audio/decode/ad_lavc.c @@ -79,12 +79,12 @@ static int init(struct dec_audio *da, const char *decoder) AVCodecContext *lavc_context; AVCodec *lavc_codec; struct sh_stream *sh = da->header; - struct sh_audio *sh_audio = sh->audio; + struct mp_codec_params *c = sh->codec; struct priv *ctx = talloc_zero(NULL, struct priv); da->priv = ctx; - ctx->force_channel_map = sh_audio->force_channels; + ctx->force_channel_map = c->force_channels; lavc_codec = avcodec_find_decoder_by_name(decoder); if (!lavc_codec) { @@ -116,20 +116,20 @@ static int init(struct dec_audio *da, const char *decoder) mp_set_avopts(da->log, lavc_context, opts->avopts); - lavc_context->codec_tag = sh->codec_tag; - lavc_context->sample_rate = sh_audio->samplerate; - lavc_context->bit_rate = sh_audio->bitrate; - lavc_context->block_align = sh_audio->block_align; - lavc_context->bits_per_coded_sample = sh_audio->bits_per_coded_sample; - lavc_context->channels = sh_audio->channels.num; - if (!mp_chmap_is_unknown(&sh_audio->channels)) - lavc_context->channel_layout = mp_chmap_to_lavc(&sh_audio->channels); + lavc_context->codec_tag = c->codec_tag; + lavc_context->sample_rate = c->samplerate; + lavc_context->bit_rate = c->bitrate; + lavc_context->block_align = c->block_align; + lavc_context->bits_per_coded_sample = c->bits_per_coded_sample; + lavc_context->channels = c->channels.num; + if (!mp_chmap_is_unknown(&c->channels)) + lavc_context->channel_layout = mp_chmap_to_lavc(&c->channels); // demux_mkv - mp_lavc_set_extradata(lavc_context, sh->extradata, sh->extradata_size); + mp_lavc_set_extradata(lavc_context, c->extradata, c->extradata_size); - if (sh->lav_headers) - mp_copy_lav_codec_headers(lavc_context, sh->lav_headers); + if (c->lav_headers) + mp_copy_lav_codec_headers(lavc_context, c->lav_headers); mp_set_avcodec_threads(da->log, lavc_context, opts->threads); @@ -228,9 +228,8 @@ static int decode_packet(struct dec_audio *da, struct mp_audio **out) if (lavc_chmap.num != avctx->channels) mp_chmap_from_channels(&lavc_chmap, avctx->channels); if (priv->force_channel_map) { - struct sh_audio *sh_audio = da->header->audio; - if (lavc_chmap.num == sh_audio->channels.num) - lavc_chmap = sh_audio->channels; + if (lavc_chmap.num == da->header->codec->channels.num) + lavc_chmap = da->header->codec->channels; } mp_audio_set_channels(mpframe, &lavc_chmap); diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 99c01b408e..f774ed1abd 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -88,7 +88,7 @@ struct mp_decoder_list *audio_decoder_list(void) static struct mp_decoder_list *audio_select_decoders(struct dec_audio *d_audio) { struct MPOpts *opts = d_audio->opts; - const char *codec = d_audio->header->codec; + const char *codec = d_audio->header->codec->codec; struct mp_decoder_list *list = audio_decoder_list(); struct mp_decoder_list *new = @@ -146,7 +146,7 @@ int audio_init_best_codec(struct dec_audio *d_audio) MP_VERBOSE(d_audio, "Selected audio codec: %s\n", d_audio->decoder_desc); } else { MP_ERR(d_audio, "Failed to initialize an audio decoder for codec '%s'.\n", - d_audio->header->codec ? d_audio->header->codec : ""); + d_audio->header->codec->codec); } talloc_free(list); -- cgit v1.2.3