summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2015-05-20 17:52:51 +0000
committerjstebbins <[email protected]>2015-05-20 17:52:51 +0000
commit35cb55b6f77e21841fd46b666adc1888fcc81854 (patch)
tree493032b505051f0fb17f2b0105cba26ab368d960
parent448fcf8b021bbe59a413a033356f047eaf3343bc (diff)
LinGui: use libhb to init audio and subtitle lists
This eliminates a lot of essentially duplicate code in LinGui for initializing these lists. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7213 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--gtk/src/audiohandler.c329
-rw-r--r--gtk/src/audiohandler.h5
-rw-r--r--gtk/src/callbacks.c16
-rw-r--r--gtk/src/hb-backend.c47
-rw-r--r--gtk/src/hb-backend.h4
-rw-r--r--gtk/src/internal_defaults.json7
-rw-r--r--gtk/src/presets.c72
-rw-r--r--gtk/src/presets.h1
-rw-r--r--gtk/src/queuehandler.c46
-rw-r--r--gtk/src/settings.c12
-rw-r--r--gtk/src/settings.h1
-rw-r--r--gtk/src/subtitlehandler.c289
-rw-r--r--gtk/src/subtitlehandler.h1
-rw-r--r--libhb/preset.c13
14 files changed, 318 insertions, 525 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index 054bf59bf..067300f1c 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -31,6 +31,43 @@ static void ghb_adjust_audio_rate_combos(signal_user_data_t *ud);
static gboolean block_updates = FALSE;
+static GhbValue *get_audio_settings(GhbValue *settings)
+{
+ GhbValue *audio, *job;
+ job = ghb_get_job_settings(settings);
+ audio = ghb_dict_get(job, "Audio");
+ if (audio == NULL)
+ {
+ audio = ghb_dict_new();
+ ghb_dict_set(job, "Audio", audio);
+ }
+ return audio;
+}
+
+GhbValue *ghb_get_audio_settings(GhbValue *settings)
+{
+ return get_audio_settings(settings);
+}
+
+
+static GhbValue *get_audio_list(GhbValue *settings)
+{
+ GhbValue *audio_dict, *audio_list = NULL;
+ audio_dict = get_audio_settings(settings);
+ audio_list = ghb_dict_get(audio_dict, "AudioList");
+ if (audio_list == NULL)
+ {
+ audio_list = ghb_array_new();
+ ghb_dict_set(audio_dict, "AudioList", audio_list);
+ }
+ return audio_list;
+}
+
+GhbValue *ghb_get_audio_list(GhbValue *settings)
+{
+ return get_audio_list(settings);
+}
+
static void enable_quality_widget(signal_user_data_t *ud, int acodec)
{
GtkWidget *widget1, *widget2;
@@ -225,6 +262,7 @@ ghb_sanitize_audio_settings(GhbValue *settings, GhbValue *asettings)
hb_audio_config_t *aconfig;
gint bitrate;
gint sr;
+ GhbValue *val;
gboolean qe;
const char *mux_id;
@@ -236,12 +274,45 @@ ghb_sanitize_audio_settings(GhbValue *settings, GhbValue *asettings)
title_id = ghb_dict_get_int(settings, "title");
title = ghb_lookup_title(title_id, &titleindex);
- track = ghb_dict_get_int(asettings, "Track");
- acodec = ghb_settings_audio_encoder_codec(asettings, "Encoder");
- mix = ghb_settings_mixdown_mix(asettings, "Mixdown");
+ track = ghb_dict_get_int(asettings, "Track");
+ acodec = ghb_settings_audio_encoder_codec(asettings, "Encoder");
+ mix = ghb_settings_mixdown_mix(asettings, "Mixdown");
bitrate = ghb_dict_get_int(asettings, "Bitrate");
quality = ghb_dict_get_double(asettings, "Quality");
- sr = ghb_dict_get_int(asettings, "Samplerate");
+ sr = ghb_dict_get_int(asettings, "Samplerate");
+ val = ghb_dict_get(asettings, "Description");
+ if (val == NULL)
+ {
+ int title_id, track;
+ const hb_title_t *title;
+ hb_audio_config_t *aconfig;
+
+ title_id = ghb_dict_get_int(settings, "title");
+ title = ghb_lookup_title(title_id, NULL);
+ track = ghb_dict_get_int(asettings, "Track");
+ aconfig = ghb_get_audio_info(title, track);
+ if (aconfig != NULL)
+ {
+ char *desc;
+ desc = g_strdup_printf("%d - %s", track + 1,
+ aconfig->lang.description);
+ ghb_dict_set_string(asettings, "Description", desc);
+ g_free(desc);
+ }
+ }
+ val = ghb_dict_get(asettings, "QualityEnable");
+ if (val == NULL)
+ {
+ val = ghb_dict_get(asettings, "Quality");
+ if (bitrate > 0 || val == NULL || quality == HB_INVALID_AUDIO_QUALITY)
+ {
+ ghb_dict_set_bool(asettings, "QualityEnable", 0);
+ }
+ else
+ {
+ ghb_dict_set_bool(asettings, "QualityEnable", 1);
+ }
+ }
qe = ghb_dict_get_bool(asettings, "QualityEnable");
aconfig = ghb_get_audio_info(title, track);
@@ -249,10 +320,12 @@ ghb_sanitize_audio_settings(GhbValue *settings, GhbValue *asettings)
{
sr = aconfig->in.samplerate;
}
- gint fallback = ghb_select_fallback(settings, acodec);
- gint copy_mask = ghb_get_copy_mask(settings);
- acodec = ghb_select_audio_codec(mux->format, aconfig, acodec,
- fallback, copy_mask);
+
+ int fallback, copy_mask;
+ fallback = ghb_select_fallback(settings, acodec);
+ copy_mask = ghb_get_copy_mask(settings);
+ acodec = ghb_select_audio_codec(mux->format, aconfig, acodec,
+ fallback, copy_mask);
if (ghb_audio_is_passthru(acodec))
{
mix = HB_AMIXDOWN_NONE;
@@ -381,10 +454,10 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
}
}
-void ghb_santiize_audio_tracks(signal_user_data_t *ud)
+void ghb_sanitize_audio_tracks(signal_user_data_t *ud)
{
int ii;
- GhbValue *alist = ghb_dict_get_value(ud->settings, "audio_list");
+ GhbValue *alist = get_audio_list(ud->settings);
int count = ghb_array_len(alist);
for (ii = 0; ii < count; ii++)
@@ -392,7 +465,6 @@ void ghb_santiize_audio_tracks(signal_user_data_t *ud)
GhbValue *asettings = ghb_array_get(alist, ii);
ghb_sanitize_audio_settings(ud->settings, asettings);
}
- ghb_audio_list_refresh_all(ud);
GhbValue *asettings = audio_get_selected_settings(ud, NULL);
if (asettings != NULL)
@@ -496,19 +568,13 @@ audio_update_dialog_widgets(signal_user_data_t *ud, GhbValue *asettings)
audio_deps(ud, asettings, NULL);
}
-static void
-free_audio_hash_key_value(gpointer data)
-{
- g_free(data);
-}
-
const gchar*
ghb_get_user_audio_lang(GhbValue *settings, const hb_title_t *title, gint track)
{
GhbValue *audio_list, *asettings;
const gchar *lang;
- audio_list = ghb_dict_get_value(settings, "audio_list");
+ audio_list = get_audio_list(settings);
if (ghb_array_len(audio_list) <= track)
return "und";
asettings = ghb_array_get(audio_list, track);
@@ -517,24 +583,6 @@ ghb_get_user_audio_lang(GhbValue *settings, const hb_title_t *title, gint track)
return lang;
}
-static gboolean*
-get_track_used(gint settings, GHashTable *track_indices, gint count)
-{
- gboolean *used;
-
- used = g_hash_table_lookup(track_indices, &settings);
- if (used == NULL)
- {
- gint *key;
-
- used = g_malloc0(count * sizeof(gboolean));
- key = g_malloc(sizeof(gint));
- *key = settings;
- g_hash_table_insert(track_indices, key, used);
- }
- return used;
-}
-
static GhbValue*
audio_add_track(
GhbValue *settings,
@@ -638,89 +686,6 @@ audio_select_and_add_track(
return asettings;
}
-static void set_pref_audio_with_lang(
- const hb_title_t *title,
- GhbValue *settings,
- const char *lang,
- int behavior,
- gboolean secondary_audio_track_mode,
- GHashTable *track_used)
-{
- const GhbValue *pref_audio, *audio_list;
- int count, ii, track, track_count, audio_count;
-
- audio_list = ghb_dict_get_value(settings, "audio_list");
-
- const char *mux_id;
- const hb_container_t *mux;
-
- mux_id = ghb_dict_get_string(settings, "FileFormat");
- mux = ghb_lookup_container_by_name(mux_id);
-
- pref_audio = ghb_dict_get_value(settings, "AudioList");
- audio_count = hb_list_count(title->list_audio);
- count = ghb_array_len(pref_audio);
- int next_track = 0;
- track = ghb_find_audio_track(title, lang, next_track);
- while (track >= 0)
- {
- track_count = ghb_array_len(audio_list);
- count = (track_count && secondary_audio_track_mode) ? 1 : count;
- for (ii = 0; ii < count; ii++)
- {
- const GhbValue *audio;
- gint acodec, fallback, copy_mask, bitrate, samplerate, mix;
- gint select_acodec;
- gdouble drc, gain, quality;
- gboolean enable_quality;
-
- audio = ghb_array_get(pref_audio, ii);
- acodec = ghb_settings_audio_encoder_codec(audio, "AudioEncoder");
- fallback = ghb_select_fallback(settings, acodec);
- copy_mask = ghb_get_copy_mask(settings);
- bitrate = ghb_settings_audio_bitrate_rate(audio, "AudioBitrate");
- samplerate = ghb_settings_audio_samplerate_rate(audio,
- "AudioSamplerate");
- mix = ghb_settings_mixdown_mix(audio, "AudioMixdown");
- drc = ghb_dict_get_double(audio, "AudioTrackDRCSlider");
- gain = ghb_dict_get_double(audio, "AudioTrackGainSlider");
- enable_quality = ghb_dict_get_bool(audio,
- "AudioTrackQualityEnable");
- quality = ghb_dict_get_double(audio, "AudioTrackQuality");
-
- // Check to see if:
- // 1. pref codec is passthru
- // 2. source codec is not passthru
- // 3. next pref is enabled
- hb_audio_config_t *aconfig;
- aconfig = hb_list_audio_config_item(title->list_audio, track);
- select_acodec = ghb_select_audio_codec(
- mux->format, aconfig, acodec, fallback, copy_mask);
-
- // Was the source track already encoded
- // with the selected encode settings.
- gboolean *used = get_track_used(ii, track_used, audio_count);
- if (!used[track])
- {
- used[track] = TRUE;
- audio_add_track(settings, title, track, select_acodec,
- enable_quality, quality, bitrate,
- samplerate, mix, drc, gain);
- }
- }
-
- next_track = track + 1;
- if (behavior == 2)
- {
- track = ghb_find_audio_track(title, lang, next_track);
- }
- else
- {
- break;
- }
- }
-}
-
void ghb_audio_title_change(signal_user_data_t *ud, gboolean title_valid)
{
GtkWidget *w = GHB_WIDGET(ud->builder, "audio_add");
@@ -734,58 +699,15 @@ void ghb_audio_title_change(signal_user_data_t *ud, gboolean title_valid)
void
ghb_set_pref_audio_settings(GhbValue *settings)
{
- GHashTable *track_used;
- int title_id, titleindex;
- const hb_title_t *title;
-
- const GhbValue *lang_list;
- gint behavior;
- gint ii, audio_count, lang_count;
-
- g_debug("set_pref_audio");
- behavior = ghb_settings_combo_int(settings, "AudioTrackSelectionBehavior");
-
- // Clear the audio list
- ghb_clear_audio_list_settings(settings);
+ int title_id;
+ GhbValue *copy_mask;
+ copy_mask = ghb_create_copy_mask(settings);
+ ghb_dict_set(settings, "AudioCopyMask", copy_mask);
title_id = ghb_dict_get_int(settings, "title");
- title = ghb_lookup_title(title_id, &titleindex);
- if (behavior == 0 || title == NULL)
- {
- // None or no source title
- return;
- }
- audio_count = hb_list_count(title->list_audio);
- if (audio_count == 0)
- {
- // No source audio
- return;
- }
-
- track_used = g_hash_table_new_full(g_int_hash, g_int_equal,
- free_audio_hash_key_value, free_audio_hash_key_value);
-
- // Find "best" audio based on audio preset defaults
- lang_list = ghb_dict_get_value(settings, "AudioLanguageList");
-
- lang_count = ghb_array_len(lang_list);
- for (ii = 0; ii < lang_count; ii++)
- {
- const gchar *lang;
- gboolean mode;
- GhbValue *glang = ghb_array_get(lang_list, ii);
- lang = ghb_value_get_string(glang);
- mode = ghb_dict_get_bool(settings, "AudioSecondaryEncoderMode");
- set_pref_audio_with_lang(title, settings, lang, behavior, mode, track_used);
- }
- GhbValue *audio_list = ghb_dict_get_value(settings, "audio_list");
- if (audio_list == NULL || ghb_array_len(audio_list) == 0)
- {
- // No matching audio tracks found. Add first track matching
- // any language.
- set_pref_audio_with_lang(title, settings, "und", 1, FALSE, track_used);
- }
- g_hash_table_destroy(track_used);
+ GhbValue *job = ghb_get_job_settings(settings);
+ ghb_dict_remove(job, "Audio");
+ hb_preset_job_add_audio(ghb_scan_handle(), title_id, settings, job);
}
static GhbValue*
@@ -813,7 +735,7 @@ audio_get_selected_settings(signal_user_data_t *ud, int *index)
// find audio settings
if (row < 0) return NULL;
- audio_list = ghb_dict_get_value(ud->settings, "audio_list");
+ audio_list = get_audio_list(ud->settings);
if (row >= ghb_array_len(audio_list))
return NULL;
@@ -862,15 +784,19 @@ audio_refresh_list_row_ui(
encoder = ghb_settings_audio_encoder(settings, "Encoder");
double quality = ghb_dict_get_double(settings, "Quality");
- if (ghb_dict_get_bool(settings, "QualityEnable") &&
- quality != HB_INVALID_AUDIO_QUALITY)
+ int bitrate = ghb_dict_get_int(settings, "Bitrate");
+ if (bitrate > 0)
{
- s_br_quality = ghb_format_quality(_("Quality: "), encoder->codec, quality);
+ s_br_quality = g_strdup_printf(_("Bitrate: %dkbps"), bitrate);
+ }
+ else if (quality != HB_INVALID_AUDIO_QUALITY)
+ {
+ s_br_quality = ghb_format_quality(_("Quality: "),
+ encoder->codec, quality);
}
else
{
- s_br_quality = g_strdup_printf(_("Bitrate: %dkbps"),
- (int)ghb_dict_get_int(settings, "Bitrate"));
+ s_br_quality = g_strdup_printf(_("N/A"));
}
sr = ghb_dict_get_int(settings, "Samplerate");
@@ -995,7 +921,7 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud)
gtk_tree_path_free(tp);
if (row < 0) return;
- audio_list = ghb_dict_get_value(ud->settings, "audio_list");
+ audio_list = get_audio_list(ud->settings);
if (row >= ghb_array_len(audio_list))
return;
@@ -1019,7 +945,7 @@ audio_refresh_list_ui(signal_user_data_t *ud)
tm_count = gtk_tree_model_iter_n_children(tm, NULL);
- audio_list = ghb_dict_get_value(ud->settings, "audio_list");
+ audio_list = get_audio_list(ud->settings);
count = ghb_array_len(audio_list);
if (count != tm_count)
{
@@ -1040,6 +966,7 @@ audio_refresh_list_ui(signal_user_data_t *ud)
void
ghb_audio_list_refresh_all(signal_user_data_t *ud)
{
+ ghb_sanitize_audio_tracks(ud);
audio_refresh_list_ui(ud);
}
@@ -1251,17 +1178,17 @@ audio_quality_radio_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
ghb_widget_to_setting(ud->settings, widget);
audio_update_setting(ghb_widget_value(widget), "QualityEnable", ud);
- if (!ghb_dict_get_bool(ud->settings, "AudioQualityEnable"))
- {
- int br = ghb_settings_audio_bitrate_rate(ud->settings, "AudioBitrate");
- audio_update_setting(ghb_int_value_new(br), "Bitrate", ud);
- }
}
G_MODULE_EXPORT void
audio_passthru_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
+ GhbValue *copy_mask, *audio;
+
ghb_widget_to_setting(ud->settings, widget);
+ copy_mask = ghb_create_copy_mask(ud->settings);
+ audio = get_audio_settings(ud->settings);
+ ghb_dict_set(audio, "CopyMask", copy_mask);
ghb_clear_presets_selection(ud);
}
@@ -1354,14 +1281,8 @@ ghb_clear_audio_list_settings(GhbValue *settings)
GhbValue *audio_list;
g_debug("clear_audio_list_settings ()");
- audio_list = ghb_dict_get_value(settings, "audio_list");
- if (audio_list == NULL)
- {
- audio_list = ghb_array_new();
- ghb_dict_set(settings, "audio_list", audio_list);
- }
- else
- ghb_array_reset(audio_list);
+ audio_list = get_audio_list(settings);
+ ghb_array_reset(audio_list);
}
void
@@ -1454,7 +1375,7 @@ audio_list_selection_changed_cb(GtkTreeSelection *ts, signal_user_data_t *ud)
gtk_tree_path_free(tp);
if (row < 0) return;
- audio_list = ghb_dict_get_value(ud->settings, "audio_list");
+ audio_list = get_audio_list(ud->settings);
if (row >= 0 && row < ghb_array_len(audio_list))
asettings = ghb_array_get(audio_list, row);
}
@@ -1472,12 +1393,7 @@ audio_add_to_settings(GhbValue *settings, GhbValue *asettings)
title_id = ghb_dict_get_int(settings, "title");
title = ghb_lookup_title(title_id, &titleindex);
- audio_list = ghb_dict_get_value(settings, "audio_list");
- if (audio_list == NULL)
- {
- audio_list = ghb_array_new();
- ghb_dict_set(settings, "audio_list", audio_list);
- }
+ audio_list = get_audio_list(settings);
int track = ghb_dict_get_int(asettings, "Track");
aconfig = ghb_get_audio_info(title, track);
@@ -1496,7 +1412,7 @@ G_MODULE_EXPORT void
audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
// Add the current audio settings to the list.
- GhbValue *asettings, *backup;
+ GhbValue *asettings, *audio_dict, *backup;
int title_id, titleindex;
const hb_title_t *title;
@@ -1504,7 +1420,8 @@ audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
title = ghb_lookup_title(title_id, &titleindex);
// Back up settings in case we need to revert.
- backup = ghb_value_dup(ghb_dict_get_value(ud->settings, "audio_list"));
+ audio_dict = get_audio_settings(ud->settings);
+ backup = ghb_value_dup(get_audio_list(ud->settings));
GhbValue *pref_audio = ghb_dict_get_value(ud->settings, "AudioList");
asettings = audio_select_and_add_track(title, ud->settings, pref_audio,
"und", 0, 0);
@@ -1519,7 +1436,7 @@ audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
gtk_widget_hide(dialog);
if (response != GTK_RESPONSE_OK)
{
- ghb_dict_set(ud->settings, "audio_list", backup);
+ ghb_dict_set(audio_dict, "AudioList", backup);
asettings = audio_get_selected_settings(ud, NULL);
if (asettings != NULL)
{
@@ -1587,12 +1504,13 @@ audio_edit_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
if (gtk_tree_path_get_depth(tp) > 1) return;
if (gtk_tree_model_get_iter(tm, &ti, tp))
{
- GhbValue *asettings, *backup;
+ GhbValue *asettings, *audio_dict, *backup;
gtk_tree_selection_select_iter(ts, &ti);
+ audio_dict = get_audio_settings(ud->settings);
// Back up settings in case we need to revert.
- backup = ghb_value_dup(ghb_dict_get_value(ud->settings, "audio_list"));
+ backup = ghb_value_dup(get_audio_list(ud->settings));
// Pop up the edit dialog
GtkResponseType response;
@@ -1601,7 +1519,7 @@ audio_edit_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
gtk_widget_hide(dialog);
if (response != GTK_RESPONSE_OK)
{
- ghb_dict_set(ud->settings, "audio_list", backup);
+ ghb_dict_set(audio_dict, "AudioList", backup);
asettings = audio_get_selected_settings(ud, NULL);
if (asettings != NULL)
{
@@ -1649,7 +1567,7 @@ audio_remove_clicked_cb(GtkWidget *widget, gchar *path, signal_user_data_t *ud)
gtk_tree_selection_select_iter(ts, &nextIter);
}
- audio_list = ghb_dict_get_value(ud->settings, "audio_list");
+ audio_list = get_audio_list(ud->settings);
// Get the row number
indices = gtk_tree_path_get_indices (tp);
@@ -2297,6 +2215,9 @@ G_MODULE_EXPORT void
audio_fallback_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
ghb_widget_to_setting(ud->settings, widget);
+ GhbValue *audio = get_audio_settings(ud->settings);
+ ghb_dict_set(audio, "FallbackEncoder", ghb_value_dup(
+ ghb_dict_get(ud->settings, "AudioEncoderFallback")));
audio_def_set_all_limits(ud);
ghb_clear_presets_selection(ud);
}
diff --git a/gtk/src/audiohandler.h b/gtk/src/audiohandler.h
index a0098004d..16e6e0476 100644
--- a/gtk/src/audiohandler.h
+++ b/gtk/src/audiohandler.h
@@ -28,8 +28,9 @@
#include "values.h"
#include "settings.h"
-void ghb_santiize_audio_tracks(signal_user_data_t *ud);
-void ghb_set_pref_audio_settings(GhbValue *settings);
+GhbValue *ghb_get_audio_settings(GhbValue *settings);
+GhbValue *ghb_get_audio_list(GhbValue *settings);
+void ghb_sanitize_audio_tracks(signal_user_data_t *ud);
const gchar* ghb_get_user_audio_lang(GhbValue *settings, const hb_title_t *title, gint track);
void ghb_audio_list_refresh_selected(signal_user_data_t *ud);
gint ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec, gint fallback_acodec, gint copy_mask);
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 5b5db99af..5c5160880 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -1630,8 +1630,8 @@ window_delete_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *u
static void
update_acodec(signal_user_data_t *ud)
{
- ghb_santiize_audio_tracks(ud);
- ghb_grey_combo_options (ud);
+ ghb_audio_list_refresh_all(ud);
+ ghb_grey_combo_options(ud);
}
G_MODULE_EXPORT void
@@ -1820,6 +1820,11 @@ set_title_settings(signal_user_data_t *ud, GhbValue *settings)
ghb_subtitle_set_pref_lang(settings);
if (title != NULL)
{
+ GhbValue *job_dict;
+
+ job_dict = hb_preset_job_init(ghb_scan_handle(), title_id, settings);
+ ghb_dict_set(settings, "Job", job_dict);
+
gint num_chapters = hb_list_count(title->list_chapter);
ghb_dict_set_int(settings, "angle", 1);
@@ -1893,8 +1898,6 @@ set_title_settings(signal_user_data_t *ud, GhbValue *settings)
title->metadata->long_description);
}
update_chapter_list_settings(settings);
- ghb_set_pref_audio_settings(settings);
- ghb_set_pref_subtitle_settings(ud, title, settings);
}
set_destination_settings(ud, settings);
@@ -1942,13 +1945,10 @@ load_all_titles(signal_user_data_t *ud, int titleindex)
}
for (ii = 0; ii < count; ii++)
{
- int index;
GhbValue *settings = ghb_value_dup(ud->settings);
title = hb_list_item(list, ii);
- index = (title != NULL) ? title->index : -1;
-
- ghb_dict_set_int(settings, "title", index);
+ ghb_dict_set_int(settings, "title", title ? title->index : -1);
set_title_settings(ud, settings);
ghb_array_append(settings_array, settings);
}
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 3d8cdab7b..90d25f3ee 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -947,6 +947,21 @@ static hb_handle_t * h_scan = NULL;
static hb_handle_t * h_queue = NULL;
static hb_handle_t * h_live = NULL;
+hb_handle_t* ghb_scan_handle(void)
+{
+ return h_scan;
+}
+
+hb_handle_t* ghb_queue_handle(void)
+{
+ return h_queue;
+}
+
+hb_handle_t* ghb_live_handle(void)
+{
+ return h_live;
+}
+
extern void hb_get_temporary_directory(char path[512]);
gchar*
@@ -3761,8 +3776,8 @@ ghb_validate_subtitles(GhbValue *settings, GtkWindow *parent)
return FALSE;
}
- const GhbValue *slist, *subtitle;
- gint count, ii, source, track;
+ const GhbValue *slist, *subtitle, *srt;
+ gint count, ii, track;
gboolean burned, one_burned = FALSE;
slist = ghb_get_subtitle_list(settings);
@@ -3771,7 +3786,7 @@ ghb_validate_subtitles(GhbValue *settings, GtkWindow *parent)
{
subtitle = ghb_array_get(slist, ii);
track = ghb_dict_get_int(subtitle, "Track");
- source = ghb_dict_get_int(subtitle, "Source");
+ srt = ghb_dict_get(subtitle, "SRT");
burned = track != -1 && ghb_dict_get_bool(subtitle, "Burn");
if (burned && one_burned)
{
@@ -3794,10 +3809,9 @@ ghb_validate_subtitles(GhbValue *settings, GtkWindow *parent)
{
one_burned = TRUE;
}
- if (source == SRTSUB)
+ if (srt != NULL)
{
const gchar *filename;
- GhbValue *srt = ghb_dict_get(subtitle, "SRT");
filename = ghb_dict_get_string(srt, "Filename");
if (!g_file_test(filename, G_FILE_TEST_IS_REGULAR))
@@ -3845,7 +3859,7 @@ ghb_validate_audio(GhbValue *settings, GtkWindow *parent)
const GhbValue *audio_list;
gint count, ii;
- audio_list = ghb_dict_get_value(settings, "audio_list");
+ audio_list = ghb_get_audio_list(settings);
count = ghb_array_len(audio_list);
for (ii = 0; ii < count; ii++)
{
@@ -4022,10 +4036,8 @@ add_job(hb_handle_t *h, GhbValue *js, gint unique_id)
par.num = ghb_dict_get_int(js, "PicturePARWidth");
par.den = ghb_dict_get_int(js, "PicturePARHeight");
- int vcodec, acodec_copy_mask, acodec_fallback, grayscale;
+ int vcodec, grayscale;
vcodec = ghb_settings_video_encoder_codec(js, "VideoEncoder");
- acodec_copy_mask = ghb_get_copy_mask(js);
- acodec_fallback = ghb_settings_audio_encoder_codec(js, "AudioEncoderFallback");
grayscale = ghb_dict_get_bool(js, "VideoGrayScale");
dict = json_pack_ex(&error, 0,
@@ -4040,10 +4052,6 @@ add_job(hb_handle_t *h, GhbValue *js, gint unique_id)
"s:{s:o, s:o},"
// Video {Codec}
"s:{s:o},"
- // Audio {CopyMask, FallbackEncoder, AudioList []}
- "s:{s:o, s:o, s:[]},"
- // Subtitles {Search {Enable}, SubtitleList []}
- "s:{s:{s:o}, s:[]},"
// Metadata
"s:{},"
// Filters {Grayscale, FilterList []}
@@ -4063,14 +4071,6 @@ add_job(hb_handle_t *h, GhbValue *js, gint unique_id)
"Den", hb_value_int(par.den),
"Video",
"Encoder", hb_value_int(vcodec),
- "Audio",
- "CopyMask", hb_value_int(acodec_copy_mask),
- "FallbackEncoder", hb_value_int(acodec_fallback),
- "AudioList",
- "Subtitle",
- "Search",
- "Enable", hb_value_bool(FALSE),
- "SubtitleList",
"Metadata",
"Filters",
"Grayscale", hb_value_bool(grayscale),
@@ -4445,9 +4445,8 @@ add_job(hb_handle_t *h, GhbValue *js, gint unique_id)
g_free(filter_str);
// Create audio list
- hb_dict_t *audios_dict = hb_dict_get(dict, "Audio");
- hb_dict_set(audios_dict, "AudioList",
- ghb_value_dup(ghb_dict_get(js, "audio_list")));
+ hb_dict_t *audios_dict = ghb_get_audio_settings(js);
+ hb_dict_set(dict, "Audio", ghb_value_dup(audios_dict));
GhbValue *subtitle_dict = ghb_get_subtitle_settings(js);
hb_dict_set(dict, "Subtitle", ghb_value_dup(subtitle_dict));
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 0f5af71f4..84033cf65 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -212,4 +212,8 @@ const char* ghb_audio_bitrate_get_short_name(int rate);
hb_audio_config_t* ghb_get_audio_info(const hb_title_t *title, gint track);
hb_subtitle_t* ghb_get_subtitle_info(const hb_title_t *title, gint track);
+hb_handle_t* ghb_scan_handle(void);
+hb_handle_t* ghb_queue_handle(void);
+hb_handle_t* ghb_live_handle(void);
+
#endif // _HBBACKEND_H_
diff --git a/gtk/src/internal_defaults.json b/gtk/src/internal_defaults.json
index 4803c49a4..285d982b0 100644
--- a/gtk/src/internal_defaults.json
+++ b/gtk/src/internal_defaults.json
@@ -53,14 +53,7 @@
"start_frame": -1,
"title_selected": false,
"volume_label": "New Video",
- "audio_list": [],
"chapter_list": [],
- "Subtitle": {
- "Search": {
- "Enable": false
- },
- "SubtitleList": []
- },
"vquality_type_bitrate": false,
"vquality_type_constant": false,
"SrtLanguage": "und",
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 5bd032fca..9af423803 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -1319,6 +1319,44 @@ ghb_remove_old_queue_file(int pid)
g_free(name);
}
+GhbValue* ghb_create_copy_mask(GhbValue *settings)
+{
+ GhbValue *copy_mask = ghb_array_new();
+ if (ghb_dict_get_bool(settings, "AudioAllowMP3Pass"))
+ {
+ ghb_array_append(copy_mask, ghb_string_value_new("copy:mp3"));
+ }
+ if (ghb_dict_get_bool(settings, "AudioAllowAACPass"))
+ {
+ ghb_array_append(copy_mask, ghb_string_value_new("copy:aac"));
+ }
+ if (ghb_dict_get_bool(settings, "AudioAllowAC3Pass"))
+ {
+ ghb_array_append(copy_mask, ghb_string_value_new("copy:ac3"));
+ }
+ if (ghb_dict_get_bool(settings, "AudioAllowDTSPass"))
+ {
+ ghb_array_append(copy_mask, ghb_string_value_new("copy:dts"));
+ }
+ if (ghb_dict_get_bool(settings, "AudioAllowDTSHDPass"))
+ {
+ ghb_array_append(copy_mask, ghb_string_value_new("copy:dtshd"));
+ }
+ if (ghb_dict_get_bool(settings, "AudioAllowEAC3Pass"))
+ {
+ ghb_array_append(copy_mask, ghb_string_value_new("copy:eac3"));
+ }
+ if (ghb_dict_get_bool(settings, "AudioAllowFLACPass"))
+ {
+ ghb_array_append(copy_mask, ghb_string_value_new("copy:flac"));
+ }
+ if (ghb_dict_get_bool(settings, "AudioAllowTRUEHDPass"))
+ {
+ ghb_array_append(copy_mask, ghb_string_value_new("copy:truehd"));
+ }
+ return copy_mask;
+}
+
// Translate internal values to preset key, value pairs
static GhbValue*
settings_to_preset(GhbValue *settings)
@@ -1397,39 +1435,7 @@ settings_to_preset(GhbValue *settings)
}
}
- GhbValue *copy_mask = ghb_array_new();
- if (ghb_dict_get_bool(preset, "AudioAllowMP3Pass"))
- {
- ghb_array_append(copy_mask, ghb_string_value_new("copy:mp3"));
- }
- if (ghb_dict_get_bool(preset, "AudioAllowAACPass"))
- {
- ghb_array_append(copy_mask, ghb_string_value_new("copy:aac"));
- }
- if (ghb_dict_get_bool(preset, "AudioAllowAC3Pass"))
- {
- ghb_array_append(copy_mask, ghb_string_value_new("copy:ac3"));
- }
- if (ghb_dict_get_bool(preset, "AudioAllowDTSPass"))
- {
- ghb_array_append(copy_mask, ghb_string_value_new("copy:dts"));
- }
- if (ghb_dict_get_bool(preset, "AudioAllowDTSHDPass"))
- {
- ghb_array_append(copy_mask, ghb_string_value_new("copy:dtshd"));
- }
- if (ghb_dict_get_bool(preset, "AudioAllowEAC3Pass"))
- {
- ghb_array_append(copy_mask, ghb_string_value_new("copy:eac3"));
- }
- if (ghb_dict_get_bool(preset, "AudioAllowFLACPass"))
- {
- ghb_array_append(copy_mask, ghb_string_value_new("copy:flac"));
- }
- if (ghb_dict_get_bool(preset, "AudioAllowTRUEHDPass"))
- {
- ghb_array_append(copy_mask, ghb_string_value_new("copy:truehd"));
- }
+ GhbValue *copy_mask = ghb_create_copy_mask(preset);
ghb_dict_set(preset, "AudioCopyMask", copy_mask);
if (ghb_dict_get_bool(preset, "x264UseAdvancedOptions"))
diff --git a/gtk/src/presets.h b/gtk/src/presets.h
index 791900541..9cb546ca7 100644
--- a/gtk/src/presets.h
+++ b/gtk/src/presets.h
@@ -44,5 +44,6 @@ void ghb_preset_to_settings(GhbValue *settings, GhbValue *preset);
void ghb_prefs_to_settings(GhbValue *settings);
GhbValue* ghb_read_settings_file(const gchar *path);
void ghb_write_settings_file(const gchar *path, GhbValue *dict);
+GhbValue* ghb_create_copy_mask(GhbValue *settings);
#endif // _GHB_PRESETS_H_
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 19fce60d1..8e8a2b7ee 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -535,7 +535,7 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *settings, GtkTreeIter *piter
gint count, ii;
const GhbValue *audio_list;
- audio_list = ghb_dict_get_value(settings, "audio_list");
+ audio_list = ghb_get_audio_list(settings);
count = ghb_array_len(audio_list);
if (count == 1)
{
@@ -598,12 +598,12 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *settings, GtkTreeIter *piter
// Subtitle Tracks: count
// Subtitle description(Subtitle options)
// ...
- const GhbValue *sub_settings, *sub_list, *sub_search;
+ const GhbValue *sub_dict, *sub_list, *sub_search;
gboolean search;
- sub_settings = ghb_get_subtitle_settings(settings);
- sub_list = ghb_dict_get(sub_settings, "SubtitleList");
- sub_search = ghb_dict_get(sub_settings, "Search");
+ sub_dict = ghb_get_subtitle_settings(settings);
+ sub_list = ghb_dict_get(sub_dict, "SubtitleList");
+ sub_search = ghb_dict_get(sub_dict, "Search");
search = ghb_dict_get_bool(sub_search, "Enable");
count = ghb_array_len(sub_list);
if (count + search == 1)
@@ -633,21 +633,20 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *settings, GtkTreeIter *piter
}
for (ii = 0; ii < count; ii++)
{
- GhbValue *settings;
+ GhbValue *subsettings, *srt;
const gchar *track;
gboolean force, burn, def;
- gint source;
-
- settings = ghb_array_get(sub_list, ii);
- track = ghb_dict_get_string(settings, "Description");
- source = ghb_dict_get_int(settings, "Source");
- force = ghb_dict_get_bool(settings, "Forced");
- burn = ghb_dict_get_bool(settings, "Burn");
- def = ghb_dict_get_bool(settings, "Default");
+
+ subsettings = ghb_array_get(sub_list, ii);
+ track = ghb_dict_get_string(subsettings, "Description");
+ srt = ghb_dict_get(subsettings, "SRT");
+ force = ghb_dict_get_bool(subsettings, "Forced");
+ burn = ghb_dict_get_bool(subsettings, "Burn");
+ def = ghb_dict_get_bool(subsettings, "Default");
if (count + search > 1)
XPRINT("\t");
- if (source != SRTSUB)
+ if (srt == NULL)
{
XPRINT("<small>%s%s%s%s</small>\n", track,
force ? _(" (Forced Only)") : "",
@@ -657,21 +656,10 @@ add_to_queue_list(signal_user_data_t *ud, GhbValue *settings, GtkTreeIter *piter
}
else
{
- GhbValue *srt;
- gint offset;
- const gchar *filename, *code;
- gchar *basename;
-
- srt = ghb_dict_get(settings, "SRT");
- offset = ghb_dict_get_int(settings, "Offset");
- filename = ghb_dict_get_string(srt, "File");
- basename = g_path_get_basename(filename);
- code = ghb_dict_get_string(srt, "Codeset");
-
- XPRINT(_("<small> %s (%s), %s, Offset (ms) %d%s</small>\n"),
- track, code, basename, offset, def ? " (Default)":"");
+ int offset = ghb_dict_get_int(subsettings, "Offset");
- g_free(basename);
+ XPRINT(_("<small> %s, Offset (ms) %d%s</small>\n"),
+ track, offset, def ? " (Default)" : "");
}
}
diff --git a/gtk/src/settings.c b/gtk/src/settings.c
index 9349015a4..4fde72e7b 100644
--- a/gtk/src/settings.c
+++ b/gtk/src/settings.c
@@ -49,6 +49,18 @@ ghb_settings_combo_option(const GhbValue *settings, const gchar *key)
return ghb_lookup_combo_option(key, ghb_dict_get_value(settings, key));
}
+GhbValue *ghb_get_job_settings(GhbValue *settings)
+{
+ GhbValue *job;
+ job = ghb_dict_get(settings, "Job");
+ if (job == NULL)
+ {
+ job = ghb_dict_new();
+ ghb_dict_set(settings, "Job", job);
+ }
+ return job;
+}
+
// Map widget names to setting keys
// Widgets that map to settings have names
// of this format: s_<setting key>
diff --git a/gtk/src/settings.h b/gtk/src/settings.h
index 98e413492..c60d547f4 100644
--- a/gtk/src/settings.h
+++ b/gtk/src/settings.h
@@ -86,6 +86,7 @@ gint ghb_settings_combo_int(const GhbValue *settings, const gchar *key);
gdouble ghb_settings_combo_double(const GhbValue *settings, const gchar *key);
const gchar* ghb_settings_combo_option(const GhbValue *settings, const gchar *key);
+GhbValue *ghb_get_job_settings(GhbValue *settings);
GhbValue* ghb_widget_value(GtkWidget *widget);
gchar* ghb_widget_string(GtkWidget *widget);
gdouble ghb_widget_double(GtkWidget *widget);
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index 6d137757b..a5e837a9d 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -23,6 +23,8 @@
#include "audiohandler.h"
#include "subtitlehandler.h"
+static void subtitle_set_track_description(GhbValue *settings,
+ GhbValue *subsettings);
static void subtitle_list_refresh_selected(signal_user_data_t *ud,
GhbValue *subsettings);
static void subtitle_add_to_settings(GhbValue *settings, GhbValue *subsettings);
@@ -33,12 +35,13 @@ static void clear_subtitle_list_ui(GtkBuilder *builder);
static GhbValue *get_sub_settings(GhbValue *settings)
{
- GhbValue *sub;
- sub = ghb_dict_get(settings, "Subtitle");
+ GhbValue *sub, *job;
+ job = ghb_get_job_settings(settings);
+ sub = ghb_dict_get(job, "Subtitle");
if (sub == NULL)
{
sub = ghb_dict_new();
- ghb_dict_set(settings, "Subtitle", sub);
+ ghb_dict_set(job, "Subtitle", sub);
}
return sub;
}
@@ -81,16 +84,42 @@ static GhbValue *get_sub_search(GhbValue *settings)
return sub_search;
}
+static int get_sub_source(GhbValue *settings, GhbValue *subsettings)
+{
+ if (ghb_dict_get(subsettings, "SRT") != NULL)
+ {
+ return SRTSUB;
+ }
+
+ int title_id = ghb_dict_get_int(settings, "title");
+ const hb_title_t *title = ghb_lookup_title(title_id, NULL);
+ if (title == NULL) // No title, scan failure?
+ return VOBSUB;
+
+ GhbValue *val = ghb_dict_get(subsettings, "Track");
+ if (val == NULL) // No track, foreign audio search
+ return VOBSUB;
+
+ int track = ghb_dict_get_int(subsettings, "Track");
+ hb_subtitle_t *subtitle = hb_list_item(title->list_subtitle, track);
+ if (subtitle != NULL) // Invalid track, shouldn't happen
+ return subtitle->source;
+
+ return VOBSUB;
+}
+
static void
subtitle_refresh_list_row_ui(
GtkTreeModel *tm,
GtkTreeIter *ti,
+ GhbValue *settings,
GhbValue *subsettings)
{
GtkTreeIter cti;
gboolean forced, burned, def;
char *info_src, *info_src_2;
char *info_dst, *info_dst_2;
+ const char *desc;
info_src_2 = NULL;
@@ -99,9 +128,14 @@ subtitle_refresh_list_row_ui(
forced = ghb_dict_get_bool(subsettings, "Forced");
burned = ghb_dict_get_bool(subsettings, "Burn");
def = ghb_dict_get_bool(subsettings, "Default");
- info_src = g_strdup_printf("<small>%s</small>",
- ghb_dict_get_string(subsettings, "Description"));
- if (ghb_dict_get_int(subsettings, "Source") == SRTSUB)
+ desc = ghb_dict_get_string(subsettings, "Description");
+ if (desc == NULL)
+ {
+ subtitle_set_track_description(settings, subsettings);
+ desc = ghb_dict_get_string(subsettings, "Description");
+ }
+ info_src = g_strdup_printf("<small>%s</small>", desc);
+ if (ghb_dict_get(subsettings, "SRT") != NULL)
{
gint offset;
offset = ghb_dict_get_int(subsettings, "Offset");
@@ -203,13 +237,13 @@ subtitle_refresh_list_ui_from_settings(signal_user_data_t *ud, GhbValue *setting
{
gtk_tree_model_iter_nth_child(tm, &ti, NULL, 0);
- subtitle_refresh_list_row_ui(tm, &ti, subtitle_search);
+ subtitle_refresh_list_row_ui(tm, &ti, ud->settings, subtitle_search);
}
for (ii = 0; ii < count; ii++)
{
gtk_tree_model_iter_nth_child(tm, &ti, NULL, ii + search);
subsettings = ghb_array_get(subtitle_list, ii);
- subtitle_refresh_list_row_ui(tm, &ti, subsettings);
+ subtitle_refresh_list_row_ui(tm, &ti, ud->settings, subsettings);
}
}
@@ -305,7 +339,7 @@ subtitle_add_to_settings(GhbValue *settings, GhbValue *subsettings)
mux_id = ghb_dict_get_string(settings, "FileFormat");
mux = ghb_lookup_container_by_name(mux_id);
- source = ghb_dict_get_int(subsettings, "Source");
+ source = get_sub_source(settings, subsettings);
burn = ghb_dict_get_bool(subsettings, "Burn");
if (burn && !hb_subtitle_can_burn(source))
{
@@ -339,16 +373,16 @@ subtitle_add_to_settings(GhbValue *settings, GhbValue *subsettings)
static void
subtitle_set_track_description(GhbValue *settings, GhbValue *subsettings)
{
+ GhbValue *srt;
char *desc = NULL;
- if (ghb_dict_get_int(subsettings, "Source") == SRTSUB)
+ srt = ghb_dict_get(subsettings, "SRT");
+ if (srt != NULL)
{
- GhbValue *srt;
const gchar *filename, *code;
const gchar *lang;
const iso639_lang_t *iso;
- srt = ghb_dict_get(subsettings, "SRT");
lang = ghb_dict_get_string(srt, "Language");
code = ghb_dict_get_string(srt, "Codeset");
filename = ghb_dict_get_string(srt, "Filename");
@@ -426,7 +460,7 @@ static GhbValue* subtitle_add_track(
gboolean burn,
gboolean *burned)
{
- int source = 0;
+ int source = VOBSUB;
if (track >= 0 && !srt)
{
@@ -468,7 +502,6 @@ static GhbValue* subtitle_add_track(
}
ghb_dict_set_int(subsettings, "Track", track);
- ghb_dict_set_int(subsettings, "Source", source);
ghb_dict_set_int(subsettings, "Offset", 0);
ghb_dict_set_bool(subsettings, "Forced", track == -1);
ghb_dict_set_bool(subsettings, "Default", default_track);
@@ -499,9 +532,9 @@ ghb_subtitle_title_change(signal_user_data_t *ud, gboolean show)
w = GHB_WIDGET(ud->builder, "subtitle_reset");
gtk_widget_set_sensitive(w, show);
- int title_id, titleindex;
+ int title_id;
title_id = ghb_dict_get_int(ud->settings, "title");
- const hb_title_t *title = ghb_lookup_title(title_id, &titleindex);
+ const hb_title_t *title = ghb_lookup_title(title_id, NULL);
if (title != NULL)
{
w = GHB_WIDGET(ud->builder, "SubtitleSrtDisable");
@@ -510,175 +543,14 @@ ghb_subtitle_title_change(signal_user_data_t *ud, gboolean show)
}
void
-ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, GhbValue *settings)
+ghb_set_pref_subtitle(signal_user_data_t *ud)
{
- gint track;
- gboolean *used;
- const gchar *audio_lang, *pref_lang = NULL;
- gboolean foreign_audio_search, foreign_audio_subs;
- gboolean burn_foreign, burn_first, burn_dvd, burn_bd;
- gboolean one_burned = FALSE;
-
- const GhbValue *lang_list;
- gint lang_count, sub_count, ii;
- int behavior;
-
- behavior = ghb_settings_combo_int(settings,
- "SubtitleTrackSelectionBehavior");
- // Clear the subtitle list
- clear_subtitle_list_settings(settings);
-
- if (title == NULL)
- {
- // no source title
- return;
- }
- sub_count = hb_list_count(title->list_subtitle);
- if (sub_count == 0)
- {
- // No source subtitles
- return;
- }
-
- const char *mux_id;
- const hb_container_t *mux;
-
- mux_id = ghb_dict_get_string(settings, "FileFormat");
- mux = ghb_lookup_container_by_name(mux_id);
-
- // Check to see if we need to add a subtitle track for foreign audio
- // language films. A subtitle track will be added if:
- //
- // The first (default) audio track language does NOT match the users
- // chosen Preferred Language AND the Preferred Language is NOT Any (und).
- //
- audio_lang = ghb_get_user_audio_lang(settings, title, 0);
- foreign_audio_search = ghb_dict_get_bool(
- settings, "SubtitleAddForeignAudioSearch");
- foreign_audio_subs = ghb_dict_get_bool(
- settings, "SubtitleAddForeignAudioSubtitle");
- lang_list = ghb_dict_get_value(settings, "SubtitleLanguageList");
- lang_count = ghb_array_len(lang_list);
- if (lang_count > 0)
- {
- GhbValue *glang = ghb_array_get(lang_list, 0);
- pref_lang = ghb_value_get_string(glang);
- }
-
- if (pref_lang == NULL || !strncmp(pref_lang, "und", 4))
- {
- foreign_audio_search = foreign_audio_subs = FALSE;
- pref_lang = NULL;
- }
-
- used = g_malloc0(sub_count * sizeof(gboolean));
-
- int burn_behavior;
- burn_behavior = ghb_settings_combo_int(settings, "SubtitleBurnBehavior");
- burn_foreign = burn_behavior == 1 || burn_behavior == 3;
- burn_first = burn_behavior == 2 || burn_behavior == 3;
- burn_dvd = ghb_dict_get_bool(settings, "SubtitleBurnDVDSub");
- burn_bd = ghb_dict_get_bool(settings, "SubtitleBurnBDSub");
-
- if (foreign_audio_subs &&
- (audio_lang == NULL || strncmp(audio_lang, pref_lang, 4)))
- {
- // Add preferred language subtitle since first audio track
- // is foreign language.
- foreign_audio_search = FALSE;
- track = ghb_find_subtitle_track(title, pref_lang, 0);
- if (track >= 0)
- {
- gboolean burn;
- hb_subtitle_t *subtitle;
- subtitle = hb_list_item(title->list_subtitle, track);
- burn = (subtitle->source == VOBSUB && burn_dvd) ||
- (subtitle->source == PGSSUB && burn_bd) ||
- burn_foreign || burn_first;
- used[track] = TRUE;
- subtitle_add_track(ud, settings, title, track, mux->format,
- !burn, FALSE, burn, &one_burned);
- burn_first &= !burn;
- }
- }
-
- if (foreign_audio_search &&
- (audio_lang != NULL && !strncmp(audio_lang, pref_lang, 4)))
- {
- // Add search for foreign audio segments
- gboolean burn = burn_foreign || burn_first;
- GhbValue *subtitle_search = get_sub_search(settings);
-
- ghb_dict_set_bool(subtitle_search, "Enable", 1);
- ghb_dict_set_bool(subtitle_search, "Forced", 1);
- ghb_dict_set_bool(subtitle_search, "Default", !burn);
- ghb_dict_set_bool(subtitle_search, "Burn", burn);
- subtitle_set_track_description(settings, subtitle_search);
- burn_first &= !burn;
- }
-
- if (behavior != 0)
- {
- // Find "best" subtitle based on subtitle preferences
- for (ii = 0; ii < lang_count; ii++)
- {
- GhbValue *glang = ghb_array_get(lang_list, ii);
- const gchar *lang = ghb_value_get_string(glang);
-
- int next_track = 0;
- track = ghb_find_subtitle_track(title, lang, next_track);
- while (track >= 0)
- {
- if (!used[track])
- {
- gboolean burn;
- hb_subtitle_t *subtitle;
- subtitle = hb_list_item(title->list_subtitle, track);
- burn = (subtitle->source == VOBSUB && burn_dvd) ||
- (subtitle->source == PGSSUB && burn_bd) ||
- burn_first;
- used[track] = TRUE;
- subtitle_add_track(ud, settings, title, track, mux->format,
- FALSE, FALSE, burn, &one_burned);
- burn_first &= !burn;
- }
- next_track = track + 1;
- if (behavior == 2)
- {
- track = ghb_find_subtitle_track(title, lang, next_track);
- }
- else
- {
- break;
- }
- }
- }
- }
-
- if (ghb_dict_get_bool(settings, "SubtitleAddCC"))
- {
- for (track = 0; track < sub_count; track++)
- {
- hb_subtitle_t *subtitle = hb_list_item(title->list_subtitle, track);
- if (subtitle->source == CC608SUB || subtitle->source == CC708SUB)
- break;
- }
-
- if (track < sub_count && !used[track])
- {
- used[track] = TRUE;
- subtitle_add_track(ud, settings, title, track, mux->format,
- FALSE, FALSE, burn_first, &one_burned);
- }
- }
- g_free(used);
-}
+ int sub_count, title_id;
+ GtkWidget *widget;
+ const hb_title_t *title;
-void
-ghb_set_pref_subtitle(const hb_title_t *title, signal_user_data_t *ud)
-{
- int sub_count;
- GtkWidget *widget;
+ title_id = ghb_dict_get_int(ud->settings, "title");
+ title = ghb_lookup_title(title_id, NULL);
clear_subtitle_list_ui(ud->builder);
if (title == NULL)
@@ -699,7 +571,9 @@ ghb_set_pref_subtitle(const hb_title_t *title, signal_user_data_t *ud)
widget = GHB_WIDGET(ud->builder, "SubtitleSrtDisable");
gtk_widget_set_sensitive(widget, TRUE);
}
- ghb_set_pref_subtitle_settings(ud, title, ud->settings);
+ GhbValue *job = ghb_get_job_settings(ud->settings);
+ ghb_dict_remove(job, "Subtitle");
+ hb_preset_job_add_subtitles(ghb_scan_handle(), title_id, ud->settings, job);
subtitle_refresh_list_ui(ud);
}
@@ -783,29 +657,31 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GhbValue *subsettings)
if (subsettings != NULL)
{
// Update widgets with subsettings
- GhbValue *val;
+ GhbValue *val, *srt;
gboolean burn, force, def;
+ int source;
const char *mux_id;
const hb_container_t *mux;
mux_id = ghb_dict_get_string(ud->settings, "FileFormat");
- mux = ghb_lookup_container_by_name(mux_id);
+ mux = ghb_lookup_container_by_name(mux_id);
- int source = ghb_dict_get_int(subsettings, "Source");
+ srt = ghb_dict_get(subsettings, "SRT");
+ source = get_sub_source(ud->settings, subsettings);
+ val = ghb_dict_get(subsettings, "Track");
- val = ghb_dict_get(subsettings, "Track");
if (val != NULL)
{
ghb_ui_update(ud, "SubtitleTrack", val);
// Hide regular subtitle widgets
widget = GHB_WIDGET(ud->builder, "subtitle_track_box");
- gtk_widget_set_visible(widget, source != SRTSUB);
+ gtk_widget_set_visible(widget, srt == NULL);
// Show SRT subitle widgets
widget = GHB_WIDGET(ud->builder, "subtitle_srt_grid");
- gtk_widget_set_visible(widget, source == SRTSUB);
+ gtk_widget_set_visible(widget, srt != NULL);
widget = GHB_WIDGET(ud->builder, "subtitle_srt_switch_box");
gtk_widget_set_visible(widget, TRUE);
@@ -823,12 +699,8 @@ subtitle_update_dialog_widgets(signal_user_data_t *ud, GhbValue *subsettings)
gtk_widget_set_visible(widget, FALSE);
}
- if (source == SRTSUB)
+ if (srt != NULL)
{
- GhbValue *srt;
-
- srt = ghb_dict_get(subsettings, "SRT");
-
ghb_ui_update(ud, "SubtitleSrtEnable", ghb_boolean_value(TRUE));
val = ghb_dict_get(srt, "Language");
ghb_ui_update(ud, "SrtLanguage", val);
@@ -920,8 +792,6 @@ subtitle_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
"Track", ud);
if (subsettings != NULL)
{
- int source = ghb_subtitle_track_source(ud->settings, track);
- ghb_dict_set_int(subsettings, "Source", source);
subtitle_set_track_description(ud->settings, subsettings);
subtitle_update_dialog_widgets(ud, subsettings);
}
@@ -999,18 +869,10 @@ subtitle_srt_radio_toggled_cb(GtkWidget *widget, signal_user_data_t *ud)
filename = g_strdup_printf("%s/none", dir);
ghb_dict_set_string(srt, "Filename", filename);
g_free(filename);
-
- ghb_dict_set_int(subsettings, "Source", SRTSUB);
}
else
{
- int track, source;
-
ghb_dict_remove(subsettings, "SRT");
-
- track = ghb_dict_get_int(subsettings, "Track");
- source = ghb_subtitle_track_source(ud->settings, track);
- ghb_dict_set_int(subsettings, "Source", source);
}
subtitle_set_track_description(ud->settings, subsettings);
subtitle_update_dialog_widgets(ud, subsettings);
@@ -1019,7 +881,7 @@ subtitle_srt_radio_toggled_cb(GtkWidget *widget, signal_user_data_t *ud)
}
}
-void
+static void
subtitle_list_refresh_selected(signal_user_data_t *ud, GhbValue *subsettings)
{
GtkTreeView *tv;
@@ -1031,7 +893,7 @@ subtitle_list_refresh_selected(signal_user_data_t *ud, GhbValue *subsettings)
ts = gtk_tree_view_get_selection(tv);
if (gtk_tree_selection_get_selected(ts, &tm, &ti))
{
- subtitle_refresh_list_row_ui(tm, &ti, subsettings);
+ subtitle_refresh_list_row_ui(tm, &ti, ud->settings, subsettings);
}
}
@@ -1170,7 +1032,7 @@ add_to_subtitle_list_ui(signal_user_data_t *ud, GhbValue *subsettings)
tm = gtk_tree_view_get_model(tv);
gtk_tree_store_append(GTK_TREE_STORE(tm), &ti, NULL);
- subtitle_refresh_list_row_ui(tm, &ti, subsettings);
+ subtitle_refresh_list_row_ui(tm, &ti, ud->settings, subsettings);
gtk_tree_selection_select_iter(ts, &ti);
}
@@ -1317,7 +1179,7 @@ subtitle_add_fas_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
tm = gtk_tree_view_get_model(tv);
gtk_tree_store_prepend(GTK_TREE_STORE(tm), &ti, NULL);
- subtitle_refresh_list_row_ui(tm, &ti, subtitle_search);
+ subtitle_refresh_list_row_ui(tm, &ti, ud->settings, subtitle_search);
gtk_tree_selection_select_iter(ts, &ti);
ghb_live_reset(ud);
@@ -1380,12 +1242,7 @@ subtitle_add_all_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
G_MODULE_EXPORT void
subtitle_reset_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
- int title_id, titleindex;
- const hb_title_t *title;
-
- title_id = ghb_dict_get_int(ud->settings, "title");
- title = ghb_lookup_title(title_id, &titleindex);
- ghb_set_pref_subtitle(title, ud);
+ ghb_set_pref_subtitle(ud);
}
// When the container changes, it may be necessary to burn additional
@@ -1416,7 +1273,7 @@ ghb_subtitle_prune(signal_user_data_t *ud)
subsettings = ghb_array_get(subtitle_list, ii);
burned = ghb_dict_get_bool(subsettings, "Burn");
- source = ghb_dict_get_bool(subsettings, "Source");
+ source = get_sub_source(ud->settings, subsettings);
burned = burned || !hb_subtitle_can_pass(source, mux->format);
if (burned && one_burned)
{
diff --git a/gtk/src/subtitlehandler.h b/gtk/src/subtitlehandler.h
index 9235270af..f5dddfe31 100644
--- a/gtk/src/subtitlehandler.h
+++ b/gtk/src/subtitlehandler.h
@@ -28,7 +28,6 @@
#include "values.h"
#include "settings.h"
-void ghb_set_pref_subtitle_settings(signal_user_data_t *ud, const hb_title_t *title, GhbValue *settings);
void ghb_set_subtitle(signal_user_data_t *ud, gint track, GhbValue *settings);
void ghb_subtitle_prune(signal_user_data_t *ud);
void ghb_subtitle_list_refresh_all(signal_user_data_t *ud);
diff --git a/libhb/preset.c b/libhb/preset.c
index f42951df7..ef83ea3cc 100644
--- a/libhb/preset.c
+++ b/libhb/preset.c
@@ -542,7 +542,8 @@ static void add_audio_for_lang(hb_value_array_t *list, const hb_dict_t *preset,
out_codec = sanitize_audio_codec(aconfig->in.codec, out_codec,
copy_mask, fallback, mux);
hb_dict_set(audio_dict, "Track", hb_value_int(track));
- hb_dict_set(audio_dict, "Encoder", hb_value_int(out_codec));
+ hb_dict_set(audio_dict, "Encoder", hb_value_string(
+ hb_audio_encoder_get_short_name(out_codec)));
if (hb_dict_get(encoder_dict, "AudioTrackName") != NULL)
{
hb_dict_set(audio_dict, "Name", hb_value_dup(
@@ -633,6 +634,11 @@ int hb_preset_job_add_audio(hb_handle_t *h, int title_index,
}
hb_dict_t *audio_dict = hb_dict_get(job_dict, "Audio");
+ if (audio_dict == NULL)
+ {
+ audio_dict = hb_dict_init();
+ hb_dict_set(job_dict, "Audio", audio_dict);
+ }
int copy_mask = get_audio_copy_mask(preset);
if (copy_mask == HB_ACODEC_INVALID)
{
@@ -825,6 +831,11 @@ int hb_preset_job_add_subtitles(hb_handle_t *h, int title_index,
return 0;
hb_dict_t *subtitle_dict = hb_dict_get(job_dict, "Subtitle");
+ if (subtitle_dict == NULL)
+ {
+ subtitle_dict = hb_dict_init();
+ hb_dict_set(job_dict, "Subtitle", subtitle_dict);
+ }
hb_value_array_t *list = hb_dict_get(subtitle_dict, "SubtitleList");
if (list == NULL)
{