From 3289be9a2856c0f935fcb49768fc39d878044202 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 3 Jun 2013 02:05:55 +0200 Subject: sd_ass: add default style if there aren't any styles The default style is added by mp_ass_default_track(), but not by ass_new_track(). Considering this, the previous condition at this point didn't make much sense anymore: the actual (converted) subtitle format doesn't matter much for what styling should be applied. What matters is if the subtitle was originally ASS, or if it was converted to it. Change the code such that the default style is added if there aren't any, even after reading sub extradata. (The extradata contains the ASS header, including the style section.) This might change behavior with scripts that don't define any styles. The change is either with this commit or with an earlier commit in this branch, depending on the situation - there are multiple places where default styles are added in libass API functions, and it's all a big mess. Other than with very old or broken files (where different behavior doesn't matter much), the current code should be pretty safe, though. --- sub/sd_ass.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'sub') diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 1f7f33b026..c4373d4511 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -63,25 +63,29 @@ static void free_last_event(ASS_Track *track) static int init(struct sd *sd) { + struct MPOpts *opts = sd->opts; if (!sd->ass_library || !sd->ass_renderer) return -1; - bool ass = is_native_ass(sd->codec); bool is_converted = sd->converted_from != NULL; + struct sd_ass_priv *ctx = talloc_zero(NULL, struct sd_ass_priv); sd->priv = ctx; if (sd->ass_track) { ctx->ass_track = sd->ass_track; - } else if (ass) { + } else { ctx->ass_track = ass_new_track(sd->ass_library); - } else - ctx->ass_track = mp_ass_default_track(sd->ass_library, sd->opts); + if (!is_converted) + ctx->ass_track->track_type = TRACK_TYPE_ASS; + } if (sd->extradata) { ass_process_codec_private(ctx->ass_track, sd->extradata, sd->extradata_len); } + mp_ass_add_default_styles(ctx->ass_track, opts); + ctx->vsfilter_aspect = !is_converted; return 0; } -- cgit v1.2.3