summaryrefslogtreecommitdiffstats
path: root/sub
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 /sub
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 'sub')
-rw-r--r--sub/dec_sub.c6
-rw-r--r--sub/sd.h2
-rw-r--r--sub/sd_ass.c10
-rw-r--r--sub/sd_lavc.c4
4 files changed, 11 insertions, 11 deletions
diff --git a/sub/dec_sub.c b/sub/dec_sub.c
index c0c98c42cc..561f8b8be8 100644
--- a/sub/dec_sub.c
+++ b/sub/dec_sub.c
@@ -81,7 +81,7 @@ void sub_destroy(struct dec_sub *sub)
struct dec_sub *sub_create(struct mpv_global *global, struct demuxer *demuxer,
struct sh_stream *sh)
{
- assert(demuxer && sh && sh->sub);
+ assert(demuxer && sh && sh->type == STREAM_SUB);
struct mp_log *log = mp_log_new(NULL, global->log, "sub");
@@ -101,7 +101,7 @@ struct dec_sub *sub_create(struct mpv_global *global, struct demuxer *demuxer,
.opts = sub->opts,
.driver = driver,
.demuxer = demuxer,
- .sh = sh,
+ .codec = sh->codec,
};
if (sh->codec && sub->sd->driver->init(sub->sd) >= 0)
@@ -113,7 +113,7 @@ struct dec_sub *sub_create(struct mpv_global *global, struct demuxer *demuxer,
}
mp_err(log, "Could not find subtitle decoder for format '%s'.\n",
- sh->codec ? sh->codec : "<unknown>");
+ sh->codec->codec);
talloc_free(log);
return NULL;
}
diff --git a/sub/sd.h b/sub/sd.h
index 5945b00483..b142654ed1 100644
--- a/sub/sd.h
+++ b/sub/sd.h
@@ -18,7 +18,7 @@ struct sd {
void *priv;
struct demuxer *demuxer;
- struct sh_stream *sh;
+ struct mp_codec_params *codec;
};
struct sd_functions {
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 658e952c28..2358ba45f6 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -165,12 +165,12 @@ static int init(struct sd *sd)
struct sd_ass_priv *ctx = talloc_zero(sd, struct sd_ass_priv);
sd->priv = ctx;
- char *extradata = sd->sh->extradata;
- int extradata_size = sd->sh->extradata_size;
+ char *extradata = sd->codec->extradata;
+ int extradata_size = sd->codec->extradata_size;
- if (strcmp(sd->sh->codec, "ass") != 0) {
+ if (strcmp(sd->codec->codec, "ass") != 0) {
ctx->is_converted = true;
- ctx->converter = lavc_conv_create(sd->log, sd->sh->codec, extradata,
+ ctx->converter = lavc_conv_create(sd->log, sd->codec->codec, extradata,
extradata_size);
if (!ctx->converter)
return -1;
@@ -203,7 +203,7 @@ static int init(struct sd *sd)
ass_set_check_readorder(ctx->ass_track, sd->opts->sub_clear_on_seek ? 0 : 1);
#endif
- ctx->frame_fps = sd->sh->sub->frame_based;
+ ctx->frame_fps = sd->codec->frame_based;
update_subtitle_speed(sd);
enable_output(sd, true);
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index ae08026d9a..2da69e937e 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -95,7 +95,7 @@ static void get_resolution(struct sd *sd, int wh[2])
static int init(struct sd *sd)
{
- enum AVCodecID cid = mp_codec_to_av_codec_id(sd->sh->codec);
+ enum AVCodecID cid = mp_codec_to_av_codec_id(sd->codec->codec);
// Supported codecs must be known to decode to paletted bitmaps
switch (cid) {
@@ -116,7 +116,7 @@ static int init(struct sd *sd)
ctx = avcodec_alloc_context3(sub_codec);
if (!ctx)
goto error;
- mp_lavc_set_extradata(ctx, sd->sh->extradata, sd->sh->extradata_size);
+ mp_lavc_set_extradata(ctx, sd->codec->extradata, sd->codec->extradata_size);
if (avcodec_open2(ctx, sub_codec, NULL) < 0)
goto error;
priv->avctx = ctx;