]> granicus.if.org Git - handbrake/commitdiff
softsubtitles:
authorjstebbins <jstebbins.hb@gmail.com>
Tue, 2 Jun 2009 15:32:01 +0000 (15:32 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Tue, 2 Jun 2009 15:32:01 +0000 (15:32 +0000)
- when doing an indepth scan, do not scan CC tracks
- separate subtitle configureation attributes into separate
  hb_subtitle_config_t.  Add an instance of this to hb_job_t for
  setting the attributes of the subtitle found through an indepth scan
- Add a default_track flag to hb_subtitle_config_t that tells the muxer
  that the track should be flaged as the default. muxmkv uses this.
- When an indepth scan is complete, check to see if the autoselected
  subtitle matchces (by id) one of the manually selected subtitles.
  If a match is found, the autoselected subtitle with all the attributes
  the user assigned to it replaces the manually selected subtitle.
- LinGui: Add "Default" column to subtitle tab.  This is a radio that lets
  the user choose which subtitle should be displayed by default.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2468 b64f7644-9d1e-0410-96f1-a4d463321fa5

19 files changed:
gtk/src/hb-backend.c
gtk/src/internal_defaults.xml
gtk/src/main.c
gtk/src/presets.c
gtk/src/subtitlehandler.c
libhb/common.h
libhb/decmpeg2.c
libhb/decvobsub.c
libhb/dvd.c
libhb/dvdnav.c
libhb/hb.c
libhb/muxcommon.c
libhb/muxmkv.c
libhb/muxmp4.c
libhb/reader.c
libhb/sync.c
libhb/work.c
macosx/Controller.mm
test/test.c

index 3fbc03ad31e10b8dd08649e42810e99e896f006d..fa38a20cec62dd85dc8769a9d2d95b7629ddee9d 100644 (file)
@@ -1992,6 +1992,7 @@ ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex)
        ghb_settings_set_int(subdict, "SubtitleTrack", -1);
        ghb_settings_set_boolean(subdict, "SubtitleForced", FALSE);
        ghb_settings_set_boolean(subdict, "SubtitleBurned", FALSE);
+       ghb_settings_set_boolean(subdict, "SubtitleDefaultTrack", FALSE);
        ghb_settings_set_string(subdict, "SubtitleLanguage", "auto");
        ghb_add_subtitle(ud, subdict, FALSE);
 
@@ -2004,6 +2005,7 @@ ghb_add_all_subtitles(signal_user_data_t *ud, gint titleindex)
                ghb_settings_set_int(subdict, "SubtitleTrack", ii);
                ghb_settings_set_boolean(subdict, "SubtitleForced", FALSE);
                ghb_settings_set_boolean(subdict, "SubtitleBurned", FALSE);
+               ghb_settings_set_boolean(subdict, "SubtitleDefaultTrack", FALSE);
                ghb_settings_set_string(subdict, "SubtitleLanguage", 
                                                                subtitle->iso639_2);
                ghb_add_subtitle(ud, subdict, FALSE);
@@ -3913,18 +3915,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
                job->cfr = 1;
        }
 
-       // First remove any audios that are already in the list
-       // This happens if you are encoding the same title a second time.
-       gint num_audio_tracks = hb_list_count(job->list_audio);
-       gint ii;
-    for(ii = 0; ii < num_audio_tracks; ii++)
-    {
-        hb_audio_t *audio = (hb_audio_t*)hb_list_item(job->list_audio, 0);
-        hb_list_rem(job->list_audio, audio);
-    }
-
        const GValue *audio_list;
-       gint count;
+       gint count, ii;
        gint tcount = 0;
        
        audio_list = ghb_settings_get_value(js, "audio_list");
@@ -4043,12 +4035,13 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
        const GValue *subtitle_list;
        gint subtitle;
        
+       job->select_subtitle = NULL;
        subtitle_list = ghb_settings_get_value(js, "subtitle_list");
        count = ghb_array_len(subtitle_list);
        for (ii = 0; ii < count; ii++)
        {
                GValue *ssettings;
-               gboolean burned, enabled, one_burned = FALSE;
+               gboolean enabled, force, burned, def, one_burned = FALSE;
 
                ssettings = ghb_array_get_nth(subtitle_list, ii);
 
@@ -4058,11 +4051,33 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
                        continue;
 
                subtitle = ghb_settings_get_int(ssettings, "SubtitleTrack");
+               force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
                burned = ghb_settings_get_boolean(ssettings, "SubtitleBurned");
+               def = ghb_settings_get_boolean(ssettings, "SubtitleDefaultTrack");
 
                if (subtitle == -1)
                {
+                       if (!burned && job->mux == HB_MUX_MKV)
+                       {
+                               job->select_subtitle_config.dest = PASSTHRUSUB;
+                       }
+                       else if (!burned && job->mux == HB_MUX_MP4)
+                       {
+                               // Skip any non-burned vobsubs when output is mp4
+                               continue;
+                       }
+                       else
+                       {
+                               // Only allow one subtitle to be burned into the video
+                               if (one_burned)
+                                       continue;
+                               one_burned = TRUE;
+                       }
+                       job->select_subtitle_config.force = force;
+                       job->select_subtitle_config.default_track = def;
                        job->indepth_scan = 1;
+                       job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
+                       *job->select_subtitle = NULL;
                }
                else if (subtitle >= 0)
                {
@@ -4074,7 +4089,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
                                if (!burned && job->mux == HB_MUX_MKV && 
                                        subt->format == PICTURESUB)
                                {
-                                       subt->dest = PASSTHRUSUB;
+                                       subt->config.dest = PASSTHRUSUB;
                                }
                                else if (!burned && job->mux == HB_MUX_MP4 && 
                                        subt->format == PICTURESUB)
@@ -4089,7 +4104,8 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
                                                continue;
                                        one_burned = TRUE;
                                }
-                               subt->force = ghb_settings_get_boolean(ssettings, "SubtitleForced");
+                               subt->config.force = force;
+                               subt->config.default_track = def;
                                hb_list_add(job->list_subtitle, subt);
                        }
                }
@@ -4110,8 +4126,6 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
                x264opts_tmp = job->x264opts;
                job->x264opts = NULL;
 
-               job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
-               *(job->select_subtitle) = NULL;
 
                /*
                 * Add the pre-scan job
@@ -4123,10 +4137,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
 
                job->x264opts = x264opts_tmp;
        }
-       else
-       {
-               job->select_subtitle = NULL;
-       }
+
        if( ghb_settings_get_boolean(js, "VideoTwoPass") &&
                !ghb_settings_get_boolean(js, "vquality_type_constant"))
        {
@@ -4198,6 +4209,17 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
                //if (job->x264opts != NULL)
                //      g_free(job->x264opts);
        }
+
+       // First remove any audios that are already in the list
+       // This happens if you are encoding the same title a second time.
+       gint num_audio_tracks = hb_list_count(job->list_audio);
+       for(ii = 0; ii < num_audio_tracks; ii++)
+       {
+               hb_audio_t *audio = (hb_audio_t*)hb_list_item(job->list_audio, 0);
+               hb_list_rem(job->list_audio, audio);
+               free(audio);
+       }
+
        if (detel_str) g_free(detel_str);
        if (decomb_str) g_free(decomb_str);
        if (deint_str) g_free(deint_str);
index 3349c30c6f53979ad828a67012dab209f170e29d..a216f73aa0af8f354c5efbcdbef36057eb4de0aa 100644 (file)
                                <true />
                                <key>SubtitleBurned</key>
                                <true />
+                               <key>SubtitleDefaultTrack</key>
+                               <false />
                        </dict>
                </array>
                <key>VideoTurboTwoPass</key>
index ef0dc18c25455f55589c26855e612bac213dff19..7331c0b7e511ac4020f72d81591f73d245f2ff4f 100644 (file)
@@ -384,6 +384,7 @@ extern G_MODULE_EXPORT void subtitle_list_selection_changed_cb(void);
 extern G_MODULE_EXPORT void subtitle_enable_toggled_cb(void);
 extern G_MODULE_EXPORT void subtitle_forced_toggled_cb(void);
 extern G_MODULE_EXPORT void subtitle_burned_toggled_cb(void);
+extern G_MODULE_EXPORT void subtitle_default_toggled_cb(void);
 extern G_MODULE_EXPORT void subtitle_track_changed_cb(void);
 
 // Create and bind the tree model to the tree view for the subtitle track list
@@ -403,16 +404,17 @@ bind_subtitle_tree_model (signal_user_data_t *ud)
        selection = gtk_tree_view_get_selection (treeview);
        // 6 columns in model.  4 are visible, the other 2 is for storing
        // values that I need
-       treestore = gtk_list_store_new(7, 
+       // Enable, Track, force, burn, default, type, track short, can delete
+       treestore = gtk_list_store_new(8, 
                                                                        G_TYPE_BOOLEAN, G_TYPE_STRING,
                                                                        G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
-                                                                       G_TYPE_STRING,  G_TYPE_STRING,
-                                                                       G_TYPE_BOOLEAN);
+                                                                       G_TYPE_BOOLEAN, G_TYPE_STRING,  
+                                                                       G_TYPE_STRING, G_TYPE_BOOLEAN);
        gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(treestore));
 
        cell = gtk_cell_renderer_toggle_new();
        column = gtk_tree_view_column_new_with_attributes(
-                                                                       _("On"), cell, "active", 0, NULL);
+                                                                       _("Enable"), cell, "active", 0, NULL);
        gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
        g_signal_connect(cell, "toggled", subtitle_enable_toggled_cb, ud);
 
@@ -438,9 +440,16 @@ bind_subtitle_tree_model (signal_user_data_t *ud)
        gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
        g_signal_connect(cell, "toggled", subtitle_burned_toggled_cb, ud);
 
+       cell = gtk_cell_renderer_toggle_new();
+       gtk_cell_renderer_toggle_set_radio(GTK_CELL_RENDERER_TOGGLE(cell), TRUE);
+       column = gtk_tree_view_column_new_with_attributes(
+                               _("Default"), cell, "active", 4, NULL);
+       gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
+       g_signal_connect(cell, "toggled", subtitle_default_toggled_cb, ud);
+
        cell = gtk_cell_renderer_text_new();
        column = gtk_tree_view_column_new_with_attributes(
-                                                                       _("Type"), cell, "text", 4, NULL);
+                                                                       _("Type"), cell, "text", 5, NULL);
        gtk_tree_view_append_column(treeview, GTK_TREE_VIEW_COLUMN(column));
 
 
index be028f6bc23531c05de388acd1d8533adeb81c1a..505ce023e40c0889202cbf929bfac7c8ff4abd7c 100644 (file)
@@ -2274,6 +2274,8 @@ import_value_xlat(GValue *dict)
                                        }
                                        ghb_dict_insert(sdict, g_strdup("SubtitleBurned"),
                                                                        ghb_boolean_value_new(TRUE));
+                                       ghb_dict_insert(sdict, g_strdup("SubtitleDefaultTrack"),
+                                                                       ghb_boolean_value_new(FALSE));
                                }
                                else
                                {
index 255da4744499e0f4747e4bd7a2b00fa5c9405b7d..c40e880e71b036e2bcac11229879f02b82665b91 100644 (file)
@@ -245,6 +245,40 @@ ghb_subtitle_exclusive_burn(signal_user_data_t *ud, gint track)
        }
 }
 
+void
+ghb_subtitle_exclusive_default(signal_user_data_t *ud, gint track)
+{
+       GValue *subtitle_list;
+       GValue *settings;
+       gint ii, count, tt;
+       GtkTreeView  *tv;
+       GtkTreeModel *tm;
+       GtkTreeIter   ti;
+       gboolean def;
+
+       g_debug("ghb_subtitle_exclusive_default");
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       count = ghb_array_len(subtitle_list);
+       for (ii = 0; ii < count; ii++)
+       {
+               settings = ghb_array_get_nth(subtitle_list, ii);
+               tt = ghb_settings_combo_int(settings, "SubtitleTrack");
+               def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
+
+               tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+               g_return_if_fail(tv != NULL);
+               tm = gtk_tree_view_get_model(tv);
+               gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii);
+               if (def && tt != track)
+               {
+
+                       ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", FALSE);
+                       def = FALSE;
+                       gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 4, FALSE, -1);
+               }
+       }
+}
+
 G_MODULE_EXPORT void
 subtitle_enable_toggled_cb(
        GtkCellRendererToggle *cell, 
@@ -395,6 +429,53 @@ subtitle_burned_toggled_cb(
        ghb_subtitle_exclusive_burn(ud, track);
 }
 
+G_MODULE_EXPORT void
+subtitle_default_toggled_cb(
+       GtkCellRendererToggle *cell, 
+       gchar                 *path,
+       signal_user_data_t    *ud)
+{
+       GtkTreeView  *tv;
+       GtkTreeModel *tm;
+       GtkTreeIter   ti;
+       GtkTreePath  *tp;
+       gboolean      active;
+       gint          row;
+       gint *indices;
+       GValue *subtitle_list;
+       gint count, track;
+       GValue *settings;
+
+       g_debug("default toggled");
+       tp = gtk_tree_path_new_from_string (path);
+       tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
+       g_return_if_fail(tv != NULL);
+       tm = gtk_tree_view_get_model(tv);
+       g_return_if_fail(tm != NULL);
+       gtk_tree_model_get_iter(tm, &ti, tp);
+       gtk_tree_model_get(tm, &ti, 4, &active, -1);
+       active ^= 1;
+
+       // Get the row number
+       indices = gtk_tree_path_get_indices (tp);
+       row = indices[0];
+       gtk_tree_path_free(tp);
+
+       subtitle_list = ghb_settings_get_value(ud->settings, "subtitle_list");
+       count = ghb_array_len(subtitle_list);
+       if (row < 0 || row >= count)
+               return;
+
+       settings = ghb_array_get_nth(subtitle_list, row);
+       track = ghb_settings_combo_int(settings, "SubtitleTrack");
+
+       ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", active);
+
+       gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 4, active, -1);
+       // allow only one default
+       ghb_subtitle_exclusive_default(ud, track);
+}
+
 static gboolean
 trackUsed(signal_user_data_t *ud, gint track)
 {
@@ -484,9 +565,9 @@ subtitle_track_changed_cb(
                        // These are displayed in list
                        1, track,
                        3, burned,
-                       4, source,
+                       5, source,
                        // These are used to set combo values when a list item is selected
-                       5, s_track,
+                       6, s_track,
                        -1);
        g_free(s_track);
        ghb_live_reset(ud);
@@ -586,7 +667,7 @@ add_to_subtitle_list(
        GtkListStore *store;
        GtkTreeSelection *selection;
        const gchar *track, *source;
-       gboolean forced, burned, enabled;
+       gboolean forced, burned, enabled, def;
        gchar *s_track;
        gint i_track;
        
@@ -599,6 +680,7 @@ add_to_subtitle_list(
        enabled = ghb_settings_get_boolean(settings, "SubtitleEnabled");
        forced = ghb_settings_get_boolean(settings, "SubtitleForced");
        burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+       def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
 
        s_track = ghb_settings_get_string(settings, "SubtitleTrack");
        i_track = ghb_settings_get_int(settings, "SubtitleTrack");
@@ -611,10 +693,11 @@ add_to_subtitle_list(
                1, track,
                2, forced,
                3, burned,
-               4, source,
+               4, def,
+               5, source,
                // These are used to set combo box values when a list item is selected
-               5, s_track,
-               6, can_delete,
+               6, s_track,
+               7, can_delete,
                -1);
        gtk_tree_selection_select_iter(selection, &iter);
        g_free(s_track);
@@ -635,7 +718,7 @@ subtitle_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data
                const gchar *track;
                gboolean can_delete;
 
-               gtk_tree_model_get(store, &iter, 5, &track, 6, &can_delete, -1);
+               gtk_tree_model_get(store, &iter, 6, &track, 7, &can_delete, -1);
                ghb_settings_set_string(ud->settings, "SubtitleTrack", track);
 
                if (can_delete)
@@ -749,7 +832,7 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
        GValue *slist;
        GValue *subtitle;
        gint count, ii, tt;
-       gboolean forced, burned, enabled;
+       gboolean enabled, forced, burned, def;
        
        g_debug("ghb_set_subtitle");
        slist = ghb_settings_get_value(ud->settings, "subtitle_list");
@@ -765,6 +848,7 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
                enabled = ghb_settings_get_boolean(settings, "SubtitleEnabled");
                forced = ghb_settings_get_boolean(settings, "SubtitleForced");
                burned = ghb_settings_get_boolean(settings, "SubtitleBurned");
+               def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
 
                tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list"));
                g_return_if_fail(tv != NULL);
@@ -774,11 +858,13 @@ ghb_set_subtitle(signal_user_data_t *ud, gint track, GValue *settings)
                ghb_settings_set_boolean(subtitle, "SubtitleEnabled", enabled);
                ghb_settings_set_boolean(subtitle, "SubtitleForced", forced);
                ghb_settings_set_boolean(subtitle, "SubtitleBurned", burned);
+               ghb_settings_set_boolean(subtitle, "SubtitleDefaultTrack", def);
                gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 
                        0, enabled, 
                        2, forced, 
                        3, burned, 
-                       6, FALSE, 
+                       4, def, 
+                       7, FALSE, 
                        -1);
                break;
        }
index 83460653a107b6e7091ef50d24c7a18ef3f46868..b9e26682efe2ce79fc5ae851f9111e2070d98b19 100644 (file)
@@ -55,6 +55,7 @@ typedef struct hb_chapter_s hb_chapter_t;
 typedef struct hb_audio_s hb_audio_t;
 typedef struct hb_audio_config_s hb_audio_config_t;
 typedef struct hb_subtitle_s hb_subtitle_t;
+typedef struct hb_subtitle_config_s hb_subtitle_config_t;
 typedef struct hb_metadata_s hb_metadata_t;
 typedef struct hb_state_s hb_state_t;
 typedef union  hb_esconfig_u     hb_esconfig_t;
@@ -108,6 +109,13 @@ struct hb_mixdown_s
     int    amixdown;
 };
 
+struct hb_subtitle_config_s
+{
+    enum subdest { RENDERSUB, PASSTHRUSUB } dest;
+    int  force;
+    int  default_track;
+};
+
 #define HB_VIDEO_RATE_BASE   27000000
 
 extern hb_rate_t    hb_video_rates[];
@@ -235,9 +243,10 @@ struct hb_job_s
     int             mp4_optimize;
     int             ipod_atom;
 
-    int indepth_scan;
-    hb_subtitle_t ** select_subtitle;
-    char * native_language;
+    int                     indepth_scan;
+    hb_subtitle_config_t    select_subtitle_config;
+    hb_subtitle_t        ** select_subtitle;
+    char                  * native_language;
 
     int             angle;              // dvd angle to encode
     int             frame_to_stop;       // declare eof when we hit this frame
@@ -439,12 +448,13 @@ struct hb_chapter_s
 
 struct hb_subtitle_s
 {
-    int track;
     int  id;
+    int track;
+
+    hb_subtitle_config_t config;
+
     enum subtype { PICTURESUB, TEXTSUB } format;
     enum subsource { VOBSUB, SRTSUB, CC608SUB, CC708SUB } source;
-    enum subdest { RENDERSUB, PASSTHRUSUB } dest;
-    int  force;
     char lang[1024];
     char iso639_2[4];
     uint8_t type; /* Closed Caption, Childrens, Directors etc */
index b719370e84e29edd6acd0008be0de136fb57c2bc..cd3c5a324e35fe7d59e4e8a68d7649e0630115e9 100644 (file)
@@ -472,7 +472,7 @@ static int hb_libmpeg2_decode( hb_libmpeg2_t * m, hb_buffer_t * buf_es,
                     }
                     subtitle->format = TEXTSUB;
                     subtitle->source = CC608SUB;
-                    subtitle->dest   = PASSTHRUSUB;
+                    subtitle->config.dest   = PASSTHRUSUB;
                     subtitle->type = 5; 
                     
                     hb_list_add( m->title->list_subtitle, subtitle );
index e5633d54d28f5dee91d02c0ec193da86ba8fc18c..2a5ccab0182442370877cfc011a0fca45f9419b2 100644 (file)
@@ -484,7 +484,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
     /* Get infos about the subtitle */
     ParseControls( w );
 
-    if( job->indepth_scan || ( w->subtitle->force && pv->pts_forced == 0 ) )
+    if( job->indepth_scan || ( w->subtitle->config.force && pv->pts_forced == 0 ) )
     {
         /*
          * Don't encode subtitles when doing a scan.
@@ -495,7 +495,7 @@ static hb_buffer_t * Decode( hb_work_object_t * w )
         return NULL;
     }
 
-    if (w->subtitle->dest == PASSTHRUSUB)
+    if (w->subtitle->config.dest == PASSTHRUSUB)
     {
         pv->buf->start  = pv->pts_start;
         pv->buf->stop   = pv->pts_stop;
index fc267778e02e07a6fb191c67b26adc6ab1deb02a..d07ccc61f9392d9413a808d6261363ee26d477e3 100644 (file)
@@ -471,7 +471,7 @@ static hb_title_t * hb_dvdread_title_scan( hb_dvd_t * e, int t )
                   lang->iso639_2);
         subtitle->format = PICTURESUB;
         subtitle->source = VOBSUB;
-        subtitle->dest   = RENDERSUB;  // By default render (burn-in) the VOBSUB.
+        subtitle->config.dest   = RENDERSUB;  // By default render (burn-in) the VOBSUB.
 
         subtitle->type = lang_extension;
 
index 589c9160e51e039c7a245b070fc22b3948487d68..2236f6d10ef33db112a9c16e3f2509e6f697fcd4 100644 (file)
@@ -638,7 +638,7 @@ static hb_title_t * hb_dvdnav_title_scan( hb_dvd_t * e, int t )
                   lang->iso639_2);
         subtitle->format = PICTURESUB;
         subtitle->source = VOBSUB;
-        subtitle->dest   = RENDERSUB;  // By default render (burn-in) the VOBSUB.
+        subtitle->config.dest   = RENDERSUB;  // By default render (burn-in) the VOBSUB.
 
         subtitle->type = lang_extension;
 
index c4045170c9901307d0acff62de14e32d40a18919..9fdfe90f416c9400c27c2b562b077357bf2b8364 100644 (file)
@@ -1066,7 +1066,8 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
         for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
         {
             subtitle = hb_list_item( title->list_subtitle, i );
-            if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
+            if( strcmp( subtitle->iso639_2, audio_lang ) == 0 &&
+                subtitle->source == VOBSUB )
             {
                 /*
                  * Matched subtitle language with audio language, so
@@ -1093,56 +1094,45 @@ void hb_add( hb_handle_t * h, hb_job_t * job )
          * Not doing a subtitle scan in this pass, but maybe we are in the
          * first pass?
          */
-        if( job->select_subtitle )
+        if( job->pass != 1 && job->native_language )
         {
             /*
-             * Don't add subtitles here, we'll add them via select_subtitle
-             * at the end of the subtitle_scan.
+             * We are not doing a subtitle scan but do want the
+             * native langauge subtitle selected, so select it
+             * for pass 0 or pass 2 of a two pass.
              */
+            for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
+            {
+                subtitle = hb_list_item( title->list_subtitle, i );
+                if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
+                {
+                    /*
+                     * Matched subtitle language with audio language, so
+                     * add this to our list to scan.
+                     */
+                    subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
+                    memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
+                    hb_list_add( title_copy->list_subtitle, subtitle_copy );
+                    break;
+                }
+            }
         } else {
             /*
-             * Definitely not doing a subtitle scan.
+             * Manually selected subtitles, in which case only
+             * bother adding them for pass 0 or pass 2 of a two
+             * pass.
              */
-            if( job->pass != 1 && job->native_language )
+            if( job->pass != 1 )
             {
                 /*
-                 * We are not doing a subtitle scan but do want the
-                 * native langauge subtitle selected, so select it
-                 * for pass 0 or pass 2 of a two pass.
+                 * Copy all of them from the input job, to the title_copy/job_copy.
                  */
-                for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
-                {
-                    subtitle = hb_list_item( title->list_subtitle, i );
-                    if( strcmp( subtitle->iso639_2, audio_lang ) == 0 )
+                for(  i = 0; i < hb_list_count(job->list_subtitle); i++ ) {
+                    if( ( subtitle = hb_list_item( job->list_subtitle, i ) ) )
                     {
-                        /*
-                         * Matched subtitle language with audio language, so
-                         * add this to our list to scan.
-                         */
                         subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
                         memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
                         hb_list_add( title_copy->list_subtitle, subtitle_copy );
-                        break;
-                    }
-                }
-            } else {
-                /*
-                 * Manually selected subtitles, in which case only
-                 * bother adding them for pass 0 or pass 2 of a two
-                 * pass.
-                 */
-                if( job->pass != 1 )
-                {
-                    /*
-                     * Copy all of them from the input job, to the title_copy/job_copy.
-                     */
-                    for(  i = 0; i < hb_list_count(job->list_subtitle); i++ ) {
-                        if( ( subtitle = hb_list_item( job->list_subtitle, i ) ) )
-                        {
-                            subtitle_copy = malloc( sizeof( hb_subtitle_t ) );
-                            memcpy( subtitle_copy, subtitle, sizeof( hb_subtitle_t ) );
-                            hb_list_add( title_copy->list_subtitle, subtitle_copy );
-                        }
                     }
                 }
             }
index a404911af77de24512903532050673b209c2e668..da390c500482c3647ab6437a8124fdf954bb640f 100644 (file)
@@ -262,7 +262,7 @@ static void MuxerFunc( void * _mux )
     {
         hb_subtitle_t  *subtitle = hb_list_item( title->list_subtitle, i );
 
-        if (subtitle->dest != PASSTHRUSUB)
+        if (subtitle->config.dest != PASSTHRUSUB)
             continue;
         add_mux_track( mux, subtitle->fifo_out, subtitle->mux_data, 0 );
     }
index ace68f4540b9aa12fb5a716786e3cf8665fbfc95..2e8814ca9283ad588ade2aaad6ecbf4711bfa855 100644 (file)
@@ -287,7 +287,7 @@ static int MKVInit( hb_mux_object_t * m )
         int             len;
 
         subtitle = hb_list_item( title->list_subtitle, i );
-        if (subtitle->dest != PASSTHRUSUB)
+        if (subtitle->config.dest != PASSTHRUSUB)
             continue;
 
         memset(track, 0, sizeof(mk_TrackConfig));
@@ -313,6 +313,10 @@ static int MKVInit( hb_mux_object_t * m )
             default:
                 continue;
         }
+        if ( subtitle->config.default_track )
+        {
+            track->flagDefault = 1;
+        }
 
         mux_data = calloc(1, sizeof( hb_mux_data_t ) );
         subtitle->mux_data = mux_data;
index 1511713b3a41bbeda6ab5877eb95239a3334734f..cdb9ce7aef9b08da1d2bfa0b5d769957ab63ac01 100644 (file)
@@ -408,7 +408,7 @@ static int MP4Init( hb_mux_object_t * m )
         hb_subtitle_t *subtitle = hb_list_item( job->list_subtitle, i );
 
         if( subtitle && subtitle->format == TEXTSUB && 
-            subtitle->dest == PASSTHRUSUB )
+            subtitle->config.dest == PASSTHRUSUB )
         {
             uint64_t width, height = 60;
             if( job->anamorphic.mode )
index c865ea85f8575331fe4ea96dcff5ebb33e9a1c9b..9ac515c4e57bf0603277f5e822edb5880e35aaac 100644 (file)
@@ -527,7 +527,7 @@ static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
         subtitle =  hb_list_item( title->list_subtitle, i );
         if (id == subtitle->id) {
             subtitle->hits++;
-            if( !job->indepth_scan || subtitle->force )
+            if( !job->indepth_scan || subtitle->config.force )
             {
                 /*
                  * Pass the subtitles to be processed if we are not scanning, or if
index c4ef6d6dfd8efcd2faf90977aadbdaf3c0ff5e9a..8ae1b78e84f74a64dde9365ce2ab4bf9780e148d 100644 (file)
@@ -303,7 +303,7 @@ static void SyncVideo( hb_work_object_t * w )
         for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
         {
             subtitle = hb_list_item( job->list_subtitle, i );
-            if( subtitle->dest == PASSTHRUSUB )
+            if( subtitle->config.dest == PASSTHRUSUB )
             {
                 hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
             }
@@ -336,7 +336,7 @@ static void SyncVideo( hb_work_object_t * w )
             for( i = 0; i < hb_list_count( job->list_subtitle ); i++)
             {
                 subtitle = hb_list_item( job->list_subtitle, i );
-                if( subtitle->dest == PASSTHRUSUB )
+                if( subtitle->config.dest == PASSTHRUSUB )
                 {
                     hb_fifo_push( subtitle->fifo_out, hb_buffer_init( 0 ) );
                 }
@@ -627,7 +627,7 @@ static void SyncVideo( hb_work_object_t * w )
                 {
                     if( sub->size > 0 )
                     {
-                        if( subtitle->dest == RENDERSUB )
+                        if( subtitle->config.dest == RENDERSUB )
                         {
                             if ( cur->sub == NULL )
                             {
@@ -660,7 +660,7 @@ static void SyncVideo( hb_work_object_t * w )
                         /*
                         * EOF - consume for rendered, else pass through
                         */
-                        if( subtitle->dest == RENDERSUB )
+                        if( subtitle->config.dest == RENDERSUB )
                         {
                             sub = hb_fifo_get( subtitle->fifo_raw );
                             hb_buffer_close( &sub );
index 848c798e4a944697a5bbc5adf858b3358dbe46ed..5be4bdf9f958414f04503779cea8f988adebf099 100644 (file)
@@ -280,7 +280,7 @@ void hb_display_job_info( hb_job_t * job )
                     subtitle->source == VOBSUB ? "VOBSUB" : 
                     ((subtitle->source == CC608SUB ||
                       subtitle->source == CC708SUB) ? "CC" : "SRT"),
-                    subtitle->dest == RENDERSUB ? "Render/Burn in" : "Pass-Through");
+                    subtitle->config.dest == RENDERSUB ? "Render/Burn in" : "Pass-Through");
         }
     }
 
@@ -466,18 +466,64 @@ static void do_job( hb_job_t * job, int cpu_count )
         hb_list_add( job->list_work, w );
     }
 
-    if( job->select_subtitle && !job->indepth_scan )
+    /*
+     * Look for the scanned subtitle in the existing subtitle list
+     */
+    if ( !job->indepth_scan && job->select_subtitle && *(job->select_subtitle) )
     {
         /*
-         * Must be second pass of a two pass with subtitle scan enabled, so
-         * add the subtitle that we found on the first pass for use in this
-         * pass.
+         * Disable forced subtitles if we didn't find any in the scan
+         * so that we display normal subtitles instead.
+         *
+         * select_subtitle implies that we did a scan.
          */
-        if (*(job->select_subtitle))
+        if( (*job->select_subtitle)->config.force && 
+            (*job->select_subtitle)->forced_hits == 0 )
         {
-            hb_list_add( title->list_subtitle, *( job->select_subtitle ) );
+            (*job->select_subtitle)->config.force = 0;
+        }
+        for( i=0; i < hb_list_count(title->list_subtitle); i++ )
+        {
+            subtitle =  hb_list_item( title->list_subtitle, i );
+
+            if( subtitle )
+            {
+                /*
+                * Disable forced subtitles if we didn't find any in the scan
+                * so that we display normal subtitles instead.
+                *
+                * select_subtitle implies that we did a scan.
+                */
+                if( (*job->select_subtitle)->id == subtitle->id )
+                {
+                    *subtitle = *(*job->select_subtitle);
+                    free( *job->select_subtitle );
+                    free( job->select_subtitle );
+                    job->select_subtitle = NULL;
+                }
+            }
+        }
+
+        if( job->select_subtitle )
+        {
+            /*
+             * Its not in the existing list
+             *
+             * Must be second pass of a two pass with subtitle scan enabled, so
+             * add the subtitle that we found on the first pass for use in this
+             * pass.
+             */
+            hb_list_add( title->list_subtitle, *job->select_subtitle );
+            free( job->select_subtitle );
+            job->select_subtitle = NULL;
         }
     }
+    else if ( !job->indepth_scan && job->select_subtitle )
+    {
+        free( job->select_subtitle );
+        job->select_subtitle = NULL;
+    }
+
 
     for( i=0; i < hb_list_count(title->list_subtitle); i++ )
     {
@@ -490,22 +536,7 @@ static void do_job( hb_job_t * job, int cpu_count )
             subtitle->fifo_sync = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
             subtitle->fifo_out  = hb_fifo_init( FIFO_CPU_MULT * cpu_count );
 
-            /*
-             * Disable forced subtitles if we didn't find any in the scan
-             * so that we display normal subtitles instead.
-             *
-             * select_subtitle implies that we did a scan.
-             */
-            if( !job->indepth_scan && subtitle->force &&
-                job->select_subtitle )
-            {
-                if( subtitle->forced_hits == 0 )
-                {
-                    subtitle->force = 0;
-                }
-            }
-
-            if( (!job->indepth_scan || subtitle->force) && 
+            if( (!job->indepth_scan || subtitle->config.force) && 
                 subtitle->source == VOBSUB ) {
                 /*
                  * Don't add threads for subtitles when we are scanning, unless
@@ -528,7 +559,7 @@ static void do_job( hb_job_t * job, int cpu_count )
 
             if( !job->indepth_scan && 
                 subtitle->format == PICTURESUB
-                && subtitle->dest == PASSTHRUSUB )
+                && subtitle->config.dest == PASSTHRUSUB )
             {
                 /*
                  * Passing through a subtitle picture, this will have to
@@ -910,9 +941,14 @@ cleanup:
         for( i=0; i < hb_list_count( title->list_subtitle ); i++ )
         {
             subtitle =  hb_list_item( title->list_subtitle, i );
+
             hb_log( "Subtitle stream 0x%x '%s': %d hits (%d forced)",
                     subtitle->id, subtitle->lang, subtitle->hits,
                     subtitle->forced_hits );
+
+            if( subtitle->hits == 0 )
+                continue;
+
             if( subtitle->hits > subtitle_highest )
             {
                 subtitle_highest = subtitle->hits;
@@ -982,19 +1018,12 @@ cleanup:
                 subtitle =  hb_list_item( title->list_subtitle, i );
                 if( subtitle->id == subtitle_hit )
                 {
+                    subtitle->config = job->select_subtitle_config;
                     hb_list_rem( title->list_subtitle, subtitle );
-                    *( job->select_subtitle ) = subtitle;
+                    *job->select_subtitle = subtitle;
+                    break;
                 }
             }
-        } else {
-            /*
-             * Must be the end of pass 0 or 2 - we don't need this anymore.
-             *
-             * Have to put the subtitle list back together in the title though
-             * or the GUI will have a hissy fit.
-             */
-            free( job->select_subtitle );
-            job->select_subtitle = NULL;
         }
     }
 
index 7c64e2a3e2c907e21f6f67b2e0295453ad1a1d58..150d23381214770f5baee6a252157b32f7ad2a56 100644 (file)
@@ -3230,9 +3230,9 @@ fWorkingCount = 0;
         hb_subtitle_t *subtitle = (hb_subtitle_t *) hb_list_item( title->list_subtitle, 
                                                                   [[queueToApply objectForKey:@"JobSubtitlesIndex"] intValue] - 2 );
         if( [[queueToApply objectForKey:@"SubtitlesForced"] intValue] == 1 )
-            subtitle->force = 1;
+            subtitle->config.force = 1;
         else
-            subtitle->force = 0;
+            subtitle->config.force = 0;
         hb_list_add( job->list_subtitle, subtitle );
         break;
     }
index ab08750e2e3d30c6420b9abc7d371b447b47b0a8..fc915d45e7ccb71f448e41377a0941679eba73af 100644 (file)
@@ -1656,7 +1656,7 @@ static int HandleEvents( hb_handle_t * h )
                 subtitle = hb_list_item( title->list_subtitle, sub-1 );
                 if( subtitle ) {
                     if( subtitle_force ) {
-                        subtitle->force = subtitle_force;
+                        subtitle->config.force = subtitle_force;
                     }
                     hb_list_add( job->list_subtitle, subtitle );
                 } else {
@@ -1750,6 +1750,10 @@ static int HandleEvents( hb_handle_t * h )
                 job->select_subtitle = malloc(sizeof(hb_subtitle_t*));
                 *(job->select_subtitle) = NULL;
 
+                job->select_subtitle_config.dest = RENDERSUB;
+                job->select_subtitle_config.default_track = 0;
+                job->select_subtitle_config.force = subtitle_force;
+
                 /*
                  * Add the pre-scan job
                  */