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. --- demux/demux.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'demux/demux.c') diff --git a/demux/demux.c b/demux/demux.c index b251674496..19ad6970b0 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -214,13 +214,9 @@ struct sh_stream *demux_alloc_sh_stream(enum stream_type type) .index = -1, .ff_index = -1, // may be overwritten by demuxer .demuxer_id = -1, // ... same + .codec = talloc_zero(sh, struct mp_codec_params), }; - switch (sh->type) { - case STREAM_VIDEO: sh->video = talloc_zero(sh, struct sh_video); break; - case STREAM_AUDIO: sh->audio = talloc_zero(sh, struct sh_audio); break; - case STREAM_SUB: sh->sub = talloc_zero(sh, struct sh_sub); break; - } - + sh->codec->type = type; return sh; } @@ -241,6 +237,9 @@ void demux_add_sh_stream(struct demuxer *demuxer, struct sh_stream *sh) .selected = in->autoselect, }; + if (!sh->codec->codec) + sh->codec->codec = ""; + sh->index = in->num_streams; if (sh->ff_index < 0) sh->ff_index = sh->index; @@ -855,11 +854,11 @@ static void apply_replaygain(demuxer_t *demuxer, struct replaygain_data *rg) struct demux_internal *in = demuxer->in; for (int n = 0; n < in->num_streams; n++) { struct sh_stream *sh = in->streams[n]; - if (sh->audio && !sh->audio->replaygain_data) { + if (sh->type == STREAM_AUDIO && !sh->codec->replaygain_data) { MP_VERBOSE(demuxer, "Replaygain: Track=%f/%f Album=%f/%f\n", rg->track_gain, rg->track_peak, rg->album_gain, rg->album_peak); - sh->audio->replaygain_data = talloc_memdup(in, rg, sizeof(*rg)); + sh->codec->replaygain_data = talloc_memdup(in, rg, sizeof(*rg)); } } } -- cgit v1.2.3