summaryrefslogtreecommitdiffstats
path: root/demux/demux.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-12 23:48:19 +0100
committerwm4 <wm4@nowhere>2016-01-12 23:48:19 +0100
commit671df54e4dcf0675c335483d26f7f6ff9baaf76a (patch)
tree6a206ddf489474150fffa2eac651b5e8915b969c /demux/demux.c
parent81f3b3aafe72e5ca9ac79d29246e70dce76ebca9 (diff)
downloadmpv-671df54e4dcf0675c335483d26f7f6ff9baaf76a.tar.bz2
mpv-671df54e4dcf0675c335483d26f7f6ff9baaf76a.tar.xz
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.
Diffstat (limited to 'demux/demux.c')
-rw-r--r--demux/demux.c15
1 files changed, 7 insertions, 8 deletions
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));
}
}
}