]> granicus.if.org Git - handbrake/commitdiff
libhb: pass through "default" subtitle flag ... (#203)
authorJohn Stebbins <jstebbins.hb@gmail.com>
Sat, 28 May 2016 15:12:34 +0000 (08:12 -0700)
committerJohn Stebbins <jstebbins.hb@gmail.com>
Sat, 28 May 2016 15:12:34 +0000 (08:12 -0700)
... when applying presets

libhb/preset.c
libhb/stream.c

index 3c9a32b4d9ec7ac7002a32b9275926192dda8c0d..11e82e0711a7dca97cba117768d31ea85042a122 100644 (file)
@@ -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;
index 5cc2d66183ab80da624157deee6855aa07e80613..f885cae3d1b30045317a1f6a8a97059b82d31612 100644 (file)
@@ -5349,6 +5349,11 @@ static void add_ffmpeg_subtitle( hb_title_t *title, hb_stream_t *stream, int id
         subtitle->extradata_size = codec->extradata_size;
     }
 
+    if (st->disposition & AV_DISPOSITION_DEFAULT)
+    {
+        subtitle->config.default_track = 1;
+    }
+
     subtitle->track = id;
     hb_list_add(title->list_subtitle, subtitle);
 }