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.
This commit is contained in:
wm4 2013-06-03 02:05:55 +02:00
parent 8c63b318dc
commit 3289be9a28
1 changed files with 8 additions and 4 deletions

View File

@ -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;
}