From f5f665474b2fbe5e1674936907a4c596bf29dfe4 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Sat, 28 May 2016 08:12:34 -0700 Subject: libhb: pass through "default" subtitle flag ... (#203) ... when applying presets --- libhb/preset.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'libhb/preset.c') diff --git a/libhb/preset.c b/libhb/preset.c index 3c9a32b4d..11e82e071 100644 --- a/libhb/preset.c +++ b/libhb/preset.c @@ -771,6 +771,23 @@ typedef struct subtitle_behavior_s uint8_t *used; } subtitle_behavior_t; +static int has_default_subtitle(hb_value_array_t *list) +{ + int ii, count, def; + + count = hb_value_array_len(list); + for (ii = 0; ii < count; ii++) + { + hb_value_t *sub = hb_value_array_get(list, ii); + def = hb_value_get_int(hb_dict_get(sub, "Default")); + if (def) + { + return def; + } + } + return 0; +} + static void add_subtitle_for_lang(hb_value_array_t *list, hb_title_t *title, int mux, const char *lang, subtitle_behavior_t *behavior) @@ -795,7 +812,12 @@ static void add_subtitle_for_lang(hb_value_array_t *list, hb_title_t *title, (subtitle->source == PGSSUB && behavior->burn_bd) || !hb_subtitle_can_pass(subtitle->source, mux) || behavior->burn_first || behavior->burn_foreign); - make_default = !burn && behavior->make_default; + // If the subtitle is added for foreign audio, or the source + // subtitle was the default subtitle, mark this subtitle as + // default. + make_default = (!burn && behavior->make_default) || + (!has_default_subtitle(list) && + subtitle->config.default_track); behavior->burn_first &= !burn; behavior->one_burned |= burn; behavior->used[t] = 1; -- cgit v1.2.3