diff options
author | jstebbins <[email protected]> | 2012-04-26 19:11:03 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2012-04-26 19:11:03 +0000 |
commit | 143f723b12881a8ab3732386785a00840bb2c934 (patch) | |
tree | c1bfd505f424c241a34ed5f90e474efac637c4fc /gtk/src | |
parent | 3f9828657ded40e2eabfef8f01fa2182a4eccd36 (diff) |
PGS (bluray) subtitle support \o/
Thanks to patches supplied by David Mitchell and Rob McMullen
we finally have PGS support.
I added a fix for libav pgs timestamp processing and
detection of forced subtitles to their work, then
made foreign audio search work with PGS subs.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4605 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/callbacks.c | 1 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 53 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 1 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.c | 126 | ||||
-rw-r--r-- | gtk/src/subtitlehandler.h | 4 |
5 files changed, 95 insertions, 90 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 94a932d67..ba0d569cc 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1268,6 +1268,7 @@ container_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_clear_presets_selection(ud); ghb_live_reset(ud); ghb_subtitle_prune(ud); + ghb_subtitle_list_refresh_selected(ud); ghb_audio_list_refresh_selected(ud); } diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 2b2b66348..af1b890e5 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -1423,37 +1423,6 @@ ghb_subtitle_track_source(GValue *settings, gint track) } const char* -ghb_subtitle_source_name(gint source) -{ - const gchar * name = "Unknown"; - switch (source) - { - case VOBSUB: - name = "VOBSUB"; - break; - case TX3GSUB: - name = "TX3G"; - break; - case UTF8SUB: - name = "UTF8"; - break; - case CC708SUB: - case CC608SUB: - name = "CC"; - break; - case SRTSUB: - name = "SRT"; - break; - case SSASUB: - name = "SSA"; - break; - default: - break; - } - return name; -} - -const char* ghb_subtitle_track_source_name(GValue *settings, gint track) { gint titleindex; @@ -1491,7 +1460,7 @@ ghb_subtitle_track_source_name(GValue *settings, gint track) sub = hb_list_item( title->list_subtitle, track); if (sub != NULL) { - name = ghb_subtitle_source_name(sub->source); + name = hb_subsource_name(sub->source); } done: @@ -2304,7 +2273,7 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex) subtitle = (hb_subtitle_t *)hb_list_item(title->list_subtitle, ii); options[ii] = g_strdup_printf("%d - %s (%s)", ii+1, subtitle->lang, - ghb_subtitle_source_name(subtitle->source)); + hb_subsource_name(subtitle->source)); subtitle_opts.map[ii+1].option = options[ii]; subtitle_opts.map[ii+1].shortOpt = index_str[ii]; subtitle_opts.map[ii+1].ivalue = ii; @@ -2681,18 +2650,6 @@ ghb_find_cc_track(gint titleindex) return -2; } -static gboolean -canForce(int source) -{ - return (source == VOBSUB); -} - -static gboolean -canBurn(int source) -{ - return (source == VOBSUB || source == SSASUB); -} - gint ghb_find_subtitle_track( gint titleindex, @@ -2745,8 +2702,8 @@ ghb_find_subtitle_track( continue; subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii ); - if (((!force || (force && canForce(subtitle->source))) && - (!burn || (burn && canBurn(subtitle->source)))) && + if (((!force || (force && ghb_canForceSub(subtitle->source))) && + (!burn || (burn && ghb_canBurnSub(subtitle->source)))) && ((strcmp(lang, subtitle->iso639_2) == 0) || (strcmp(lang, "und") == 0))) { @@ -5106,7 +5063,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) { sub_config.dest = PASSTHRUSUB; } - else if ( burned && canBurn(subt->source) ) + else if ( burned && ghb_canBurnSub(subt->source) ) { // Only allow one subtitle to be burned into the video if (one_burned) diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 407dc7315..22f3f6770 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -163,7 +163,6 @@ gint ghb_get_title_number(gint titleindex); int ghb_get_title_count(); gint ghb_subtitle_track_source(GValue *settings, gint track); const char* ghb_subtitle_track_source_name(GValue *settings, gint track); -const char* ghb_subtitle_source_name(gint source); gchar* ghb_subtitle_track_lang(GValue *settings, gint track); gboolean ghb_validate_vquality(GValue *settings); diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c index ffe38a0e6..5b5036520 100644 --- a/gtk/src/subtitlehandler.c +++ b/gtk/src/subtitlehandler.c @@ -42,16 +42,22 @@ free_subtitle_key(gpointer data) g_free(data); } -static gboolean -canBurn(int source) +gboolean +ghb_canPassSub(int source, int mux) { - return (source == VOBSUB || source == SSASUB); + return hb_subtitle_can_pass(source, mux); } -static gboolean -canForce(int source) +gboolean +ghb_canBurnSub(int source) { - return (source == VOBSUB); + return hb_subtitle_can_burn(source); +} + +gboolean +ghb_canForceSub(int source) +{ + return hb_subtitle_can_force(source); } gboolean @@ -86,7 +92,6 @@ ghb_subtitle_exclusive_burn_settings(GValue *settings, gint index) { if (ii != index) { -printf("settings burn %d also %d\n", index, ii); subsettings = ghb_array_get_nth(subtitle_list, ii); ghb_settings_set_boolean(subsettings, "SubtitleBurned", FALSE); } @@ -114,7 +119,6 @@ ghb_subtitle_exclusive_burn(signal_user_data_t *ud, gint index) gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii); if (ii != index) { -printf("ui burn %d also %d\n", index, ii); subsettings = ghb_array_get_nth(subtitle_list, ii); ghb_settings_set_boolean(subsettings, "SubtitleBurned", FALSE); gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 2, FALSE, -1); @@ -226,7 +230,8 @@ ghb_add_subtitle_to_settings(GValue *settings, GValue *subsettings) // Add the current subtitle settings to the list. GValue *subtitle_list; gint count; - gboolean burned; + gboolean burned, forced; + gint source, mux; const gchar *track; const gchar *lang; @@ -256,9 +261,29 @@ ghb_add_subtitle_to_settings(GValue *settings, GValue *subsettings) lang = ghb_settings_combo_string(subsettings, "SubtitleTrack"); ghb_settings_set_string(subsettings, "SubtitleLanguage", lang); + mux = ghb_settings_combo_int(settings, "FileFormat"); + source = ghb_settings_get_int(subsettings, "SubtitleSource"); + burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned"); + if (burned && !ghb_canBurnSub(source)) + { + burned = FALSE; + ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned); + } + if (!burned && !ghb_canPassSub(source, mux)) + { + burned = TRUE; + ghb_settings_set_boolean(subsettings, "SubtitleBurned", burned); + ghb_settings_set_boolean(subsettings, "SubtitleDefaultTrack", FALSE); + } + forced = ghb_settings_get_boolean(subsettings, "SubtitleForced"); + if (forced && !ghb_canForceSub(source)) + { + forced = FALSE; + ghb_settings_set_boolean(subsettings, "SubtitleForced", forced); + } + ghb_array_append(subtitle_list, subsettings); - burned = ghb_settings_get_boolean(subsettings, "SubtitleBurned"); if (burned) ghb_subtitle_exclusive_burn_settings(settings, count); return TRUE; @@ -300,6 +325,7 @@ add_all_pref_subtitles(signal_user_data_t *ud) for (ii = 0; ii < count; ii++) { subtitle = ghb_value_dup(ghb_array_get_nth(pref_subtitle, ii)); + gboolean force = ghb_settings_get_boolean(subtitle, "SubtitleForced"); lang = ghb_settings_get_string(subtitle, "SubtitleLanguage"); // If there are multiple subtitles using the same language, then // select sequential tracks for each. The hash keeps track @@ -417,7 +443,7 @@ ghb_set_pref_subtitle_settings(gint titleindex, GValue *settings) GValue *subsettings; gboolean burn; - track = ghb_find_subtitle_track(titleindex, pref_lang, FALSE, FALSE, VOBSUB, track_indices); + track = ghb_find_subtitle_track(titleindex, pref_lang, FALSE, FALSE, PGSSUB, track_indices); if (track >= -1) { int source; @@ -463,7 +489,6 @@ ghb_set_pref_subtitle_settings(gint titleindex, GValue *settings) if (track >= 0) { int source; - subsettings = ghb_dict_value_new(); ghb_settings_set_int(subsettings, "SubtitleTrack", track); source = ghb_subtitle_track_source(settings, track); @@ -606,8 +631,10 @@ subtitle_forced_toggled_cb( settings = ghb_array_get_nth(subtitle_list, row); source = ghb_settings_get_int(settings, "SubtitleSource"); - if (!canForce(source)) + if (!ghb_canForceSub(source)) + { return; + } ghb_settings_set_boolean(settings, "SubtitleForced", active); gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 1, active, -1); @@ -630,7 +657,7 @@ subtitle_burned_toggled_cb( GValue *subtitle_list; gint count; GValue *settings; - gint source; + gint source, mux; g_debug("burned toggled"); tp = gtk_tree_path_new_from_string (path); @@ -654,7 +681,10 @@ subtitle_burned_toggled_cb( settings = ghb_array_get_nth(subtitle_list, row); source = ghb_settings_get_int(settings, "SubtitleSource"); - if (!canBurn(source)) + if (!ghb_canBurnSub(source)) + return; + mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + if (!active && !hb_subtitle_can_pass(source, mux)) return; ghb_settings_set_boolean(settings, "SubtitleBurned", active); @@ -711,6 +741,12 @@ subtitle_default_toggled_cb( settings = ghb_array_get_nth(subtitle_list, row); + int source, mux; + source = ghb_settings_get_int(settings, "SubtitleSource"); + mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + if (active && !hb_subtitle_can_pass(source, mux)) + return; + ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", active); gtk_list_store_set(GTK_LIST_STORE(tm), &ti, 3, active, -1); @@ -724,8 +760,8 @@ subtitle_default_toggled_cb( ghb_live_reset(ud); } -static void -subtitle_list_refresh_selected(signal_user_data_t *ud) +void +ghb_subtitle_list_refresh_selected(signal_user_data_t *ud) { GtkTreeView *treeview; GtkTreePath *treepath; @@ -760,22 +796,34 @@ subtitle_list_refresh_selected(signal_user_data_t *ud) return; settings = ghb_array_get_nth(subtitle_list, row); - def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack"); + burned = ghb_settings_get_boolean(settings, "SubtitleBurned"); gint i_source; i_source = ghb_settings_get_int(settings, "SubtitleSource"); - if (!canBurn(i_source)) + if (!ghb_canBurnSub(i_source)) { burned = FALSE; ghb_settings_set_boolean(settings, "SubtitleBurned", burned); } - if (!canForce(i_source)) + + gint i_mux; + i_mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + if (!burned && !ghb_canPassSub(i_source, i_mux)) + { + burned = TRUE; + ghb_settings_set_boolean(settings, "SubtitleBurned", burned); + ghb_settings_set_boolean(settings, "SubtitleDefaultTrack", FALSE); + } + + forced = ghb_settings_get_boolean(settings, "SubtitleForced"); + if (!ghb_canForceSub(i_source)) { - // Force only apply to VOBSUBS forced = FALSE; ghb_settings_set_boolean(settings, "SubtitleForced", forced); } + def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack"); + if (i_source == SRTSUB) { const gchar *lang; @@ -801,24 +849,18 @@ subtitle_list_refresh_selected(signal_user_data_t *ud) } g_free(code); offset = ghb_settings_get_int(settings, "SrtOffset"); - - forced = FALSE; - burned = FALSE; } else { track = g_strdup( ghb_settings_combo_option(settings, "SubtitleTrack")); - source = g_strdup(ghb_subtitle_source_name(i_source)); + source = g_strdup(hb_subsource_name(i_source)); s_track = ghb_settings_get_string(settings, "SubtitleTrack"); - - forced = ghb_settings_get_boolean(settings, "SubtitleForced"); - burned = ghb_settings_get_boolean(settings, "SubtitleBurned"); } - if (canBurn(i_source)) + if (ghb_canBurnSub(i_source)) allow_burn = TRUE; - if (canForce(i_source)) + if (ghb_canForceSub(i_source)) allow_force = TRUE; gtk_list_store_set(GTK_LIST_STORE(store), &iter, @@ -864,7 +906,7 @@ subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_settings_set_int(settings, "SubtitleSource", source); lang = ghb_settings_combo_string(settings, "SubtitleTrack"); ghb_settings_set_string(settings, "SubtitleLanguage", lang); - subtitle_list_refresh_selected(ud); + ghb_subtitle_list_refresh_selected(ud); ghb_live_reset(ud); } ghb_live_reset(ud); @@ -882,7 +924,7 @@ srt_changed_cb(GtkWidget *widget, signal_user_data_t *ud) if (settings != NULL) { ghb_widget_to_setting(settings, widget); - subtitle_list_refresh_selected(ud); + ghb_subtitle_list_refresh_selected(ud); ghb_live_reset(ud); } @@ -902,7 +944,7 @@ srt_file_changed_cb(GtkWidget *widget, signal_user_data_t *ud) gchar *filename, *dirname; ghb_widget_to_setting(settings, widget); - subtitle_list_refresh_selected(ud); + ghb_subtitle_list_refresh_selected(ud); ghb_live_reset(ud); @@ -936,7 +978,7 @@ srt_lang_changed_cb(GtkWidget *widget, signal_user_data_t *ud) const gchar *lang; ghb_widget_to_setting(settings, widget); - subtitle_list_refresh_selected(ud); + ghb_subtitle_list_refresh_selected(ud); ghb_live_reset(ud); @@ -982,7 +1024,7 @@ add_to_subtitle_list( GtkTreeIter iter; GtkListStore *store; GtkTreeSelection *selection; - const gchar *track, *source; + const gchar *track; gboolean forced, burned, def; gchar *s_track; gint i_source; @@ -1001,11 +1043,10 @@ add_to_subtitle_list( s_track = ghb_settings_get_string(settings, "SubtitleTrack"); i_source = ghb_settings_get_int(settings, "SubtitleSource"); - source = ghb_subtitle_source_name(i_source); - if (canBurn(i_source)) + if (ghb_canBurnSub(i_source)) allow_burn = TRUE; - if (canForce(i_source)) + if (ghb_canForceSub(i_source)) allow_force = TRUE; gtk_list_store_append(store, &iter); @@ -1251,7 +1292,7 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) // Add the current subtitle settings to the list. GValue *settings; gboolean burned = FALSE; - gint track, source; + gint track, source, mux; g_debug("subtitle_add_clicked_cb ()"); @@ -1260,6 +1301,11 @@ subtitle_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud) settings = ghb_dict_value_new(); ghb_settings_set_int(settings, "SubtitleTrack", track); source = ghb_subtitle_track_source(ud->settings, track); + + // Initialize to passthru if possible, else burn + mux = ghb_settings_combo_int(ud->settings, "FileFormat"); + burned = !hb_subtitle_can_pass(source, mux); + ghb_settings_set_int(settings, "SubtitleSource", source); ghb_settings_take_value(settings, "SubtitleForced", ghb_boolean_value_new(FALSE)); @@ -1331,7 +1377,6 @@ void ghb_subtitle_prune(signal_user_data_t *ud) { GtkTreeView *tv; - GtkTreeModel *tm; GValue *subtitle_list; gint count, ii; gint first_track = 0, one_burned = 0; @@ -1343,7 +1388,6 @@ ghb_subtitle_prune(signal_user_data_t *ud) tv = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "subtitle_list")); g_return_if_fail(tv != NULL); - tm = gtk_tree_view_get_model(tv); for (ii = count-1; ii >= 0; ii--) { gboolean burned; diff --git a/gtk/src/subtitlehandler.h b/gtk/src/subtitlehandler.h index ac662499f..267b79bc2 100644 --- a/gtk/src/subtitlehandler.h +++ b/gtk/src/subtitlehandler.h @@ -35,5 +35,9 @@ gint ghb_selected_subtitle_row(signal_user_data_t *ud); void ghb_reset_subtitles(signal_user_data_t *ud, GValue *settings); void ghb_subtitle_prune(signal_user_data_t *ud); gboolean ghb_soft_in_subtitle_list(GValue *subtitle_list); +gboolean ghb_canBurnSub(int source); +gboolean ghb_canForceSub(int source); +gboolean ghb_canPassSub(int source, int mux); +void ghb_subtitle_list_refresh_selected(signal_user_data_t *ud); #endif // _SUBTITLEHANDLER_H_ |