summaryrefslogtreecommitdiffstats
path: root/gtk/src/hb-backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'gtk/src/hb-backend.c')
-rw-r--r--gtk/src/hb-backend.c1008
1 files changed, 453 insertions, 555 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 393aad0e5..c857884e4 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -71,6 +71,30 @@ index_str_init(gint max_index)
}
}
+static options_map_t d_subtitle_track_sel_opts[] =
+{
+ {N_("None"), "none", 0, "0"},
+ {N_("First Track Matching Selected Languages"), "first", 1, "1"},
+ {N_("All Tracks Matching Selected Languages"), "all", 2, "2"},
+};
+combo_opts_t subtitle_track_sel_opts =
+{
+ sizeof(d_subtitle_track_sel_opts)/sizeof(options_map_t),
+ d_subtitle_track_sel_opts
+};
+
+static options_map_t d_audio_track_sel_opts[] =
+{
+ {N_("None"), "none", 0, "0"},
+ {N_("First Track Matching Selected Languages"), "first", 1, "1"},
+ {N_("All Tracks Matching Selected Languages"), "all", 2, "2"},
+};
+combo_opts_t audio_track_sel_opts =
+{
+ sizeof(d_audio_track_sel_opts)/sizeof(options_map_t),
+ d_audio_track_sel_opts
+};
+
static options_map_t d_point_to_point_opts[] =
{
{N_("Chapters:"), "chapter", 0, "0"},
@@ -365,6 +389,8 @@ typedef struct
combo_name_map_t combo_name_map[] =
{
+ {"SubtitleTrackSelectionBehavior", &subtitle_track_sel_opts},
+ {"AudioTrackSelectionBehavior", &audio_track_sel_opts},
{"PtoPType", &point_to_point_opts},
{"WhenComplete", &when_complete_opts},
{"PicturePAR", &par_opts},
@@ -1028,62 +1054,33 @@ ghb_find_closest_audio_samplerate(gint irate)
return result;
}
-hb_rate_t *ghb_audio_bitrates = NULL;
-int ghb_audio_bitrates_count = 0;
-int ghb_abr_count = 0;
-
-static const hb_rate_t *
-lookup_audio_bitrate(const GValue *grate)
-{
- gint ii;
- const hb_rate_t *result = NULL;
-
- if (G_VALUE_TYPE(grate) == G_TYPE_STRING)
- {
- // Coincidentally, the string "source" will return 0
- // which is our flag to use "same as source"
- gchar *str = ghb_value_string(grate);
- for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
- {
- if (strcmp(ghb_audio_bitrates[ii].name, str) == 0)
- {
- g_free(str);
- return &ghb_audio_bitrates[ii];
- }
- }
- g_free(str);
- }
- else if (G_VALUE_TYPE(grate) == G_TYPE_INT ||
- G_VALUE_TYPE(grate) == G_TYPE_INT64 ||
- G_VALUE_TYPE(grate) == G_TYPE_DOUBLE)
- {
- gint val = ghb_value_int(grate);
- for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
- {
- if (ghb_audio_bitrates[ii].rate == val)
- {
- return &ghb_audio_bitrates[ii];
- }
- }
- }
- return result;
-}
+int ghb_custom_bitrate = 0;
+gchar *ghb_custom_bitrate_str = NULL;
static gint
lookup_audio_bitrate_int(const GValue *grate)
{
- const hb_rate_t *rate = lookup_audio_bitrate(grate);
- if (rate != NULL)
- return rate->rate;
- return 160;
+ return ghb_value_int(grate);
}
static const gchar*
lookup_audio_bitrate_option(const GValue *grate)
{
- const hb_rate_t *rate = lookup_audio_bitrate(grate);
- if (rate != NULL)
- return rate->name;
+ int rate = ghb_value_int(grate);
+
+ if (rate == ghb_custom_bitrate && ghb_custom_bitrate_str != NULL)
+ return ghb_custom_bitrate_str;
+
+ const hb_rate_t *hbrate;
+ for (hbrate = hb_audio_bitrate_get_next(NULL); hbrate != NULL;
+ hbrate = hb_audio_bitrate_get_next(hbrate))
+ {
+ if (rate == hbrate->rate)
+ {
+ return hbrate->name;
+ }
+ }
+
return "160";
}
@@ -1199,7 +1196,7 @@ lookup_audio_encoder_option(const GValue *genc)
const hb_encoder_t *enc = lookup_audio_encoder(genc);
if (enc != NULL)
return enc->name;
- return NULL;
+ return "None";
}
static const gchar*
@@ -1217,7 +1214,7 @@ lookup_audio_encoder_string(const GValue *genc)
const hb_encoder_t *enc = lookup_audio_encoder(genc);
if (enc != NULL)
return enc->short_name;
- return NULL;
+ return "none";
}
static const gchar*
@@ -1229,8 +1226,13 @@ lookup_video_encoder_string(const GValue *genc)
return NULL;
}
-static int
-lookup_audio_lang(const GValue *glang)
+const iso639_lang_t* ghb_iso639_lookup_by_int(int idx)
+{
+ return &ghb_language_table[idx];
+}
+
+int
+ghb_lookup_audio_lang(const GValue *glang)
{
gint ii;
gchar *str;
@@ -1238,7 +1240,32 @@ lookup_audio_lang(const GValue *glang)
str = ghb_value_string(glang);
for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
{
- if (strcmp(ghb_language_table[ii].iso639_2, str) == 0)
+ if (ghb_language_table[ii].iso639_2 &&
+ strcmp(ghb_language_table[ii].iso639_2, str) == 0)
+ {
+ g_free(str);
+ return ii;
+ }
+ if (ghb_language_table[ii].iso639_2b &&
+ strcmp(ghb_language_table[ii].iso639_2b, str) == 0)
+ {
+ g_free(str);
+ return ii;
+ }
+ if (ghb_language_table[ii].iso639_1 &&
+ strcmp(ghb_language_table[ii].iso639_1, str) == 0)
+ {
+ g_free(str);
+ return ii;
+ }
+ if (ghb_language_table[ii].native_name &&
+ strcmp(ghb_language_table[ii].native_name, str) == 0)
+ {
+ g_free(str);
+ return ii;
+ }
+ if (ghb_language_table[ii].eng_name &&
+ strcmp(ghb_language_table[ii].eng_name, str) == 0)
{
g_free(str);
return ii;
@@ -1251,7 +1278,7 @@ lookup_audio_lang(const GValue *glang)
static int
lookup_audio_lang_int(const GValue *glang)
{
- gint ii = lookup_audio_lang(glang);
+ gint ii = ghb_lookup_audio_lang(glang);
if (ii >= 0)
return ii;
return 0;
@@ -1260,7 +1287,7 @@ lookup_audio_lang_int(const GValue *glang)
static const gchar*
lookup_audio_lang_option(const GValue *glang)
{
- gint ii = lookup_audio_lang(glang);
+ gint ii = ghb_lookup_audio_lang(glang);
if (ii >= 0)
{
if (ghb_language_table[ii].native_name[0] != 0)
@@ -1268,7 +1295,7 @@ lookup_audio_lang_option(const GValue *glang)
else
return ghb_language_table[ii].eng_name;
}
- return "Same as source";
+ return "Any";
}
GValue*
@@ -1277,7 +1304,7 @@ ghb_lookup_audio_encoder_value(gint ienc)
const hb_encoder_t *enc = lookup_audio_encoder_by_int(ienc);
if (enc != NULL)
return ghb_string_value_new(enc->short_name);
- return ghb_string_value_new("copy");
+ return ghb_string_value_new("none");
}
static GValue*
@@ -1413,21 +1440,20 @@ const gchar*
ghb_subtitle_track_lang(GValue *settings, gint track)
{
gint titleindex;
+ hb_title_t * title;
titleindex = ghb_settings_combo_int(settings, "title");
if (titleindex < 0)
goto fail;
+ title = ghb_get_title_info(titleindex);
+ if (title == NULL) // Bad titleindex
+ goto fail;
if (track == -1)
- return ghb_get_user_audio_lang(settings, titleindex, 0);
+ return ghb_get_user_audio_lang(settings, title, 0);
if (track < 0)
goto fail;
- hb_title_t * title;
hb_subtitle_t * sub;
-
- title = ghb_get_title_info( titleindex );
- if (title == NULL) // Bad titleindex
- goto fail;
sub = hb_list_item( title->list_subtitle, track);
if (sub != NULL)
return sub->iso639_2;
@@ -1471,39 +1497,27 @@ get_hb_audio(hb_handle_t *h, gint titleindex, gint track)
}
static gint
-search_rates(hb_rate_t *rates, gint rate, gint count)
+search_audio_bitrates(gint rate)
{
- gint ii;
- for (ii = 0; ii < count; ii++)
+ const hb_rate_t *hbrate;
+ for (hbrate = hb_audio_bitrate_get_next(NULL); hbrate != NULL;
+ hbrate = hb_audio_bitrate_get_next(hbrate))
{
- if (rates[ii].rate == rate)
- return ii;
+ if (hbrate->rate == rate)
+ return 1;
}
- return -1;
+ return 0;
}
static gboolean find_combo_item_by_int(GtkTreeModel *store, gint value, GtkTreeIter *iter);
-static GtkListStore*
-get_combo_box_store(GtkBuilder *builder, const gchar *name)
-{
- GtkComboBox *combo;
- GtkListStore *store;
-
- g_debug("get_combo_box_store() %s\n", name);
- // First modify the combobox model to allow greying out of options
- combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
- store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
- return store;
-}
-
static void
-grey_combo_box_item(GtkBuilder *builder, const gchar *name, gint value, gboolean grey)
+grey_combo_box_item(GtkComboBox *combo, gint value, gboolean grey)
{
GtkListStore *store;
GtkTreeIter iter;
- store = get_combo_box_store(builder, name);
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
if (find_combo_item_by_int(GTK_TREE_MODEL(store), value, &iter))
{
gtk_list_store_set(store, &iter,
@@ -1513,6 +1527,27 @@ grey_combo_box_item(GtkBuilder *builder, const gchar *name, gint value, gboolean
}
static void
+grey_builder_combo_box_item(GtkBuilder *builder, const gchar *name, gint value, gboolean grey)
+{
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ grey_combo_box_item(combo, value, grey);
+}
+
+void
+ghb_mix_opts_filter(GtkComboBox *combo, gint acodec)
+{
+ g_debug("ghb_mix_opts_filter()\n");
+
+ const hb_mixdown_t *mix;
+ for (mix = hb_mixdown_get_next(NULL); mix != NULL;
+ mix = hb_mixdown_get_next(mix))
+ {
+ grey_combo_box_item(combo, mix->amixdown,
+ !hb_mixdown_has_codec_support(mix->amixdown, acodec));
+ }
+}
+
+static void
grey_mix_opts(signal_user_data_t *ud, gint acodec, gint64 layout)
{
g_debug("grey_mix_opts()\n");
@@ -1521,7 +1556,7 @@ grey_mix_opts(signal_user_data_t *ud, gint acodec, gint64 layout)
for (mix = hb_mixdown_get_next(NULL); mix != NULL;
mix = hb_mixdown_get_next(mix))
{
- grey_combo_box_item(ud->builder, "AudioMixdown", mix->amixdown,
+ grey_builder_combo_box_item(ud->builder, "AudioMixdown", mix->amixdown,
!hb_mixdown_is_supported(mix->amixdown, acodec, layout));
}
}
@@ -1548,7 +1583,7 @@ ghb_grey_combo_options(signal_user_data_t *ud)
mux = ghb_lookup_combo_int("FileFormat", gval);
ghb_value_free(gval);
- grey_combo_box_item(ud->builder, "x264_analyse", 4, TRUE);
+ grey_builder_combo_box_item(ud->builder, "x264_analyse", 4, TRUE);
const hb_encoder_t *enc;
for (enc = hb_audio_encoder_get_next(NULL); enc != NULL;
@@ -1556,16 +1591,16 @@ ghb_grey_combo_options(signal_user_data_t *ud)
{
if (!(mux & enc->muxers))
{
- grey_combo_box_item(ud->builder, "AudioEncoder",
+ grey_builder_combo_box_item(ud->builder, "AudioEncoder",
enc->codec, TRUE);
- grey_combo_box_item(ud->builder, "AudioEncoderFallback",
+ grey_builder_combo_box_item(ud->builder, "AudioEncoderFallback",
enc->codec, TRUE);
}
else
{
- grey_combo_box_item(ud->builder, "AudioEncoder",
+ grey_builder_combo_box_item(ud->builder, "AudioEncoder",
enc->codec, FALSE);
- grey_combo_box_item(ud->builder, "AudioEncoderFallback",
+ grey_builder_combo_box_item(ud->builder, "AudioEncoderFallback",
enc->codec, FALSE);
}
}
@@ -1574,35 +1609,35 @@ ghb_grey_combo_options(signal_user_data_t *ud)
{
if (!(mux & enc->muxers))
{
- grey_combo_box_item(ud->builder, "VideoEncoder",
+ grey_builder_combo_box_item(ud->builder, "VideoEncoder",
enc->codec, TRUE);
}
else
{
- grey_combo_box_item(ud->builder, "VideoEncoder",
+ grey_builder_combo_box_item(ud->builder, "VideoEncoder",
enc->codec, FALSE);
}
}
if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_MP3)
{
- grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_MP3_PASS, TRUE);
+ grey_builder_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_MP3_PASS, TRUE);
}
if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_FFAAC)
{
- grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_AAC_PASS, TRUE);
+ grey_builder_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_AAC_PASS, TRUE);
}
if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_AC3)
{
- grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_AC3_PASS, TRUE);
+ grey_builder_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_AC3_PASS, TRUE);
}
if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_DCA)
{
- grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE);
+ grey_builder_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE);
}
if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_DCA_HD)
{
- grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, TRUE);
+ grey_builder_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, TRUE);
}
widget = GHB_WIDGET (ud->builder, "AudioEncoder");
@@ -1611,7 +1646,7 @@ ghb_grey_combo_options(signal_user_data_t *ud)
ghb_value_free(gval);
gint64 layout = aconfig != NULL ? aconfig->in.channel_layout : ~0;
- fallback = ghb_select_fallback(ud->settings, mux, acodec);
+ fallback = ghb_select_fallback(ud->settings, acodec);
gint copy_mask = ghb_get_copy_mask(ud->settings);
acodec = ghb_select_audio_codec(mux, aconfig, acodec, fallback, copy_mask);
grey_mix_opts(ud, acodec, layout);
@@ -1630,16 +1665,14 @@ ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix)
}
// Set up the model for the combo box
-static void
-init_combo_box(GtkBuilder *builder, const gchar *name)
+void
+ghb_init_combo_box(GtkComboBox *combo)
{
- GtkComboBox *combo;
GtkListStore *store;
GtkCellRenderer *cell;
- g_debug("init_combo_box() %s\n", name);
+ g_debug("ghb_init_combo_box()\n");
// First modify the combobox model to allow greying out of options
- combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
if (combo == NULL)
return;
// Store contains:
@@ -1666,15 +1699,27 @@ init_combo_box(GtkBuilder *builder, const gchar *name)
}
}
+// Set up the model for the combo box
static void
-audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name)
+init_combo_box(GtkBuilder *builder, const gchar *name)
+{
+ GtkComboBox *combo;
+
+ g_debug("init_combo_box() %s\n", name);
+ // First modify the combobox model to allow greying out of options
+ combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ ghb_init_combo_box(combo);
+}
+
+void
+ghb_audio_samplerate_opts_set(GtkComboBox *combo)
{
GtkTreeIter iter;
GtkListStore *store;
gchar *str;
g_debug("audio_samplerate_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
// Add an item for "Same As Source"
gtk_list_store_append(store, &iter);
@@ -1706,13 +1751,22 @@ audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name)
}
static void
+audio_samplerate_opts_set(GtkBuilder *builder, const gchar *name)
+{
+ g_debug("audio_samplerate_opts_set ()\n");
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ ghb_audio_samplerate_opts_set(combo);
+}
+
+static void
video_framerate_opts_set(GtkBuilder *builder, const gchar *name)
{
GtkTreeIter iter;
GtkListStore *store;
g_debug("video_framerate_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
// Add an item for "Same As Source"
gtk_list_store_append(store, &iter);
@@ -1765,7 +1819,8 @@ video_encoder_opts_set(
gchar *str;
g_debug("video_encoder_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
const hb_encoder_t *enc;
@@ -1785,10 +1840,9 @@ video_encoder_opts_set(
}
}
-static void
-audio_encoder_opts_set_with_mask(
- GtkBuilder *builder,
- const gchar *name,
+void
+ghb_audio_encoder_opts_set_with_mask(
+ GtkComboBox *combo,
int mask,
int neg_mask)
{
@@ -1796,8 +1850,8 @@ audio_encoder_opts_set_with_mask(
GtkListStore *store;
gchar *str;
- g_debug("audio_encoder_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ g_debug("ghb_audio_encoder_opts_set_with_mask()\n");
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
const hb_encoder_t *enc;
@@ -1821,11 +1875,54 @@ audio_encoder_opts_set_with_mask(
}
static void
+audio_encoder_opts_set_with_mask(
+ GtkBuilder *builder,
+ const gchar *name,
+ int mask,
+ int neg_mask)
+{
+ g_debug("audio_encoder_opts_set_with_mask()\n");
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ ghb_audio_encoder_opts_set_with_mask(combo, mask, neg_mask);
+}
+
+void
+ghb_audio_encoder_opts_set(GtkComboBox *combo)
+{
+ ghb_audio_encoder_opts_set_with_mask(combo, ~0, 0);
+}
+
+static void
audio_encoder_opts_set(
GtkBuilder *builder,
const gchar *name)
{
- audio_encoder_opts_set_with_mask(builder, name, ~0, 0);
+ GtkTreeIter iter;
+ GtkListStore *store;
+ gchar *str;
+
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
+ gtk_list_store_clear(store);
+
+ const hb_encoder_t *enc;
+ for (enc = hb_audio_encoder_get_next(NULL); enc != NULL;
+ enc = hb_audio_encoder_get_next(enc))
+ {
+ if (enc->codec != HB_ACODEC_AUTO_PASS)
+ {
+ gtk_list_store_append(store, &iter);
+ str = g_strdup_printf("<small>%s</small>", enc->name);
+ gtk_list_store_set(store, &iter,
+ 0, str,
+ 1, TRUE,
+ 2, enc->short_name,
+ 3, (gdouble)enc->codec,
+ 4, enc->short_name,
+ -1);
+ g_free(str);
+ }
+ }
}
static void
@@ -1834,15 +1931,15 @@ acodec_fallback_opts_set(GtkBuilder *builder, const gchar *name)
audio_encoder_opts_set_with_mask(builder, name, ~0, HB_ACODEC_PASS_FLAG);
}
-static void
-mix_opts_set(GtkBuilder *builder, const gchar *name)
+void
+ghb_mix_opts_set(GtkComboBox *combo)
{
GtkTreeIter iter;
GtkListStore *store;
gchar *str;
g_debug("mix_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
const hb_mixdown_t *mix;
@@ -1863,6 +1960,14 @@ mix_opts_set(GtkBuilder *builder, const gchar *name)
}
static void
+mix_opts_set(GtkBuilder *builder, const gchar *name)
+{
+ g_debug("mix_opts_set ()\n");
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ ghb_mix_opts_set(combo);
+}
+
+static void
container_opts_set(
GtkBuilder *builder,
const gchar *name)
@@ -1872,7 +1977,8 @@ container_opts_set(
gchar *str;
g_debug("hb_container_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
const hb_container_t *mux;
@@ -1900,7 +2006,8 @@ srt_codeset_opts_set(GtkBuilder *builder, const gchar *name)
gint ii;
g_debug("srt_codeset_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
for (ii = 0; ii < SRT_TABLE_SIZE; ii++)
{
@@ -1923,7 +2030,8 @@ language_opts_set(GtkBuilder *builder, const gchar *name)
gint ii;
g_debug("language_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
{
@@ -1958,7 +2066,8 @@ title_opts_set(GtkBuilder *builder, const gchar *name)
gint count = 0;
g_debug("title_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
if (h_scan != NULL)
{
@@ -2074,7 +2183,8 @@ x264_tune_opts_set(GtkBuilder *builder, const gchar *name)
while (tunes && tunes[count]) count++;
g_debug("x264_tune_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
gtk_list_store_append(store, &iter);
@@ -2114,7 +2224,8 @@ h264_profile_opts_set(GtkBuilder *builder, const gchar *name)
while (profiles && profiles[count]) count++;
g_debug("h264_profile_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
for (ii = 0; ii < count; ii++)
@@ -2142,7 +2253,8 @@ h264_level_opts_set(GtkBuilder *builder, const gchar *name)
while (levels && levels[count]) count++;
g_debug("h264_level_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
for (ii = 0; ii < count; ii++)
@@ -2197,7 +2309,8 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
gchar *str;
g_debug("audio_track_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
title = ghb_get_title_info(titleindex);
if (title != NULL)
@@ -2264,7 +2377,6 @@ audio_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
audio_track_opts.map[ii].ivalue = ii;
audio_track_opts.map[ii].svalue = index_str[ii];
}
- GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
gtk_combo_box_set_active (combo, 0);
}
@@ -2297,39 +2409,34 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
static char ** options = NULL;
g_debug("subtitle_track_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
title = ghb_get_title_info(titleindex);
if (title != NULL)
{
count = hb_list_count( title->list_subtitle );
}
- if (count > 100) count = 100;
if (subtitle_opts.map) g_free(subtitle_opts.map);
+
+ subtitle_opts.count = count+1;
+ subtitle_opts.map = g_malloc((subtitle_opts.count)*sizeof(options_map_t));
+
if (count > 0)
{
- subtitle_opts.count = count+1;
- subtitle_opts.map = g_malloc((count+1)*sizeof(options_map_t));
- }
- else
- {
- subtitle_opts.count = LANG_TABLE_SIZE+1;
- subtitle_opts.map = g_malloc((LANG_TABLE_SIZE+1)*sizeof(options_map_t));
- }
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- 0, _("Foreign Audio Search"),
- 1, TRUE,
- 2, "-1",
- 3, -1.0,
- 4, "auto",
- -1);
- subtitle_opts.map[0].option = "Foreign Audio Search";
- subtitle_opts.map[0].shortOpt = "-1";
- subtitle_opts.map[0].ivalue = -1;
- subtitle_opts.map[0].svalue = "auto";
- if (count > 0)
- {
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, _("Foreign Audio Search"),
+ 1, TRUE,
+ 2, "-1",
+ 3, -1.0,
+ 4, "auto",
+ -1);
+ subtitle_opts.map[0].option = "Foreign Audio Search";
+ subtitle_opts.map[0].shortOpt = "-1";
+ subtitle_opts.map[0].ivalue = -1;
+ subtitle_opts.map[0].svalue = "auto";
+
if (options != NULL)
g_strfreev(options);
options = g_malloc((count+1)*sizeof(gchar*));
@@ -2357,31 +2464,19 @@ subtitle_track_opts_set(GtkBuilder *builder, const gchar *name, gint titleindex)
}
else
{
- index_str_init(LANG_TABLE_SIZE-1);
- for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
- {
- const gchar *lang;
-
- if (ghb_language_table[ii].native_name[0] != 0)
- lang = ghb_language_table[ii].native_name;
- else
- lang = ghb_language_table[ii].eng_name;
-
- subtitle_opts.map[ii+1].option = (gchar*)lang;
- subtitle_opts.map[ii+1].shortOpt = index_str[ii];
- subtitle_opts.map[ii+1].ivalue = ii;
- subtitle_opts.map[ii+1].svalue = ghb_language_table[ii].iso639_2;
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter,
- 0, lang,
- 1, TRUE,
- 2, index_str[ii],
- 3, (gdouble)ii,
- 4, ghb_language_table[ii].iso639_2,
- -1);
- }
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, _("None"),
+ 1, TRUE,
+ 2, "0",
+ 3, 0.0,
+ 4, "none",
+ -1);
+ subtitle_opts.map[0].option = "None";
+ subtitle_opts.map[0].shortOpt = "0";
+ subtitle_opts.map[0].ivalue = 0;
+ subtitle_opts.map[0].svalue = "none";
}
- GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
gtk_combo_box_set_active (combo, 0);
}
@@ -2413,14 +2508,12 @@ ghb_longest_title()
}
const gchar*
-ghb_get_source_audio_lang(gint titleindex, gint track)
+ghb_get_source_audio_lang(hb_title_t *title, gint track)
{
- hb_title_t * title;
hb_audio_config_t * audio;
const gchar *lang = "und";
g_debug("ghb_lookup_1st_audio_lang ()\n");
- title = ghb_get_title_info( titleindex );
if (title == NULL)
return lang;
if (hb_list_count( title->list_audio ) <= track)
@@ -2434,236 +2527,26 @@ ghb_get_source_audio_lang(gint titleindex, gint track)
return lang;
}
-static gboolean*
-get_track_used(gint acodec, GHashTable *track_indices, gint count)
-{
- gboolean *used;
-
- used = g_hash_table_lookup(track_indices, &acodec);
- if (used == NULL)
- {
- gint *key;
-
- used = g_malloc0(count * sizeof(gboolean));
- key = g_malloc(sizeof(gint));
- *key = acodec;
- g_hash_table_insert(track_indices, key, used);
- }
- return used;
-}
-
gint
-ghb_find_audio_track(
- gint titleindex,
- const gchar *lang,
- gint acodec,
- gint fallback_acodec,
- GHashTable *track_indices)
+ghb_find_audio_track(hb_title_t *title, const gchar *lang, int start)
{
- hb_title_t * title;
hb_audio_config_t * audio;
- gint ii;
- gint count = 0;
- gint track = -1;
- gint max_chan;
- gboolean *used = NULL;
- gboolean *passthru_used;
- gint try_acodec;
- gint passthru_acodec;
- gboolean passthru;
- gint channels;
-
- g_debug("find_audio_track ()\n");
- title = ghb_get_title_info( titleindex );
+ gint ii, count = 0;
+
if (title != NULL)
{
- count = hb_list_count( title->list_audio );
+ count = hb_list_count(title->list_audio);
}
- if (count > 10) count = 10;
- // Try to find an item that matches the preferred language and
- // the passthru codec type
- max_chan = 0;
- passthru = (acodec & HB_ACODEC_PASS_FLAG) != 0;
- if (passthru)
- {
- for (ii = 0; ii < count; ii++)
- {
- audio = (hb_audio_config_t*)hb_list_audio_config_item(
- title->list_audio, ii );
- passthru_acodec = HB_ACODEC_PASS_MASK & acodec & audio->in.codec;
- // Is the source track use a passthru capable codec?
- if (passthru_acodec == 0)
- continue;
- used = get_track_used(passthru_acodec, track_indices, count);
- // Has the track already been used with this codec?
- if (used[ii])
- continue;
- channels = av_get_channel_layout_nb_channels(
- audio->in.channel_layout);
- // Find a track that is not visually impaired or dirctor's
- // commentary, and has the highest channel count.
- if ((audio->lang.type < 2) &&
- ((strcmp(lang, audio->lang.iso639_2) == 0) ||
- (strcmp(lang, "und") == 0)))
- {
- if (channels > max_chan)
- {
- track = ii;
- max_chan = channels;
- }
- }
- }
- try_acodec = fallback_acodec;
- }
- else
- {
- try_acodec = acodec;
- }
- if (track > -1)
- {
- used[track] = TRUE;
- return track;
- }
- // Try to find an item that matches the preferred language
- max_chan = 0;
- used = get_track_used(try_acodec, track_indices, count);
- for (ii = 0; ii < count; ii++)
- {
- // Has the track already been used with this codec?
- if (used[ii])
- continue;
- audio = (hb_audio_config_t*)hb_list_audio_config_item(
- title->list_audio, ii );
- passthru_acodec = HB_ACODEC_PASS_MASK & audio->in.codec;
- if (passthru_acodec && passthru)
- {
- passthru_used = get_track_used(passthru_acodec, track_indices, count);
- // Has the track already been used with this codec for passthru?
- if (passthru_used[ii])
- continue;
- }
- channels = av_get_channel_layout_nb_channels(
- audio->in.channel_layout);
- // Find a track that is not visually impaired or dirctor's commentary
- if ((audio->lang.type < 2) &&
- ((strcmp(lang, audio->lang.iso639_2) == 0) ||
- (strcmp(lang, "und") == 0)))
- {
- if (channels > max_chan)
- {
- track = ii;
- max_chan = channels;
- }
- }
- }
- if (track > -1)
+ for (ii = start; ii < count; ii++)
{
- used[track] = TRUE;
- return track;
- }
- // Try to fine an item that does not match the preferred language and
- // matches the passthru codec type
- max_chan = 0;
- if (passthru)
- {
- for (ii = 0; ii < count; ii++)
+ audio = hb_list_audio_config_item(title->list_audio, ii);
+ if (!strcmp(lang, audio->lang.iso639_2) || !strcmp(lang, "und"))
{
- audio = (hb_audio_config_t*)hb_list_audio_config_item(
- title->list_audio, ii );
- passthru_acodec = HB_ACODEC_PASS_MASK & acodec & audio->in.codec;
- // Is the source track use a passthru capable codec?
- if (passthru_acodec == 0)
- continue;
- used = get_track_used(passthru_acodec, track_indices, count);
- // Has the track already been used with this codec?
- if (used[ii])
- continue;
-
- channels = av_get_channel_layout_nb_channels(
- audio->in.channel_layout);
- // Find a track that is not visually impaired or dirctor's
- // commentary, and has the highest channel count.
- if (audio->lang.type < 2)
- {
- if (channels > max_chan)
- {
- track = ii;
- max_chan = channels;
- }
- }
- }
- try_acodec = fallback_acodec;
- }
- else
- {
- try_acodec = acodec;
- }
- if (track > -1)
- {
- used[track] = TRUE;
- return track;
- }
- // Try to fine an item that does not match the preferred language
- max_chan = 0;
- used = get_track_used(try_acodec, track_indices, count);
- for (ii = 0; ii < count; ii++)
- {
- // Has the track already been used with this codec?
- if (used[ii])
- continue;
- audio = (hb_audio_config_t*)hb_list_audio_config_item(
- title->list_audio, ii );
- passthru_acodec = HB_ACODEC_PASS_MASK & audio->in.codec;
- channels = av_get_channel_layout_nb_channels(
- audio->in.channel_layout);
- if (passthru_acodec && passthru)
- {
- passthru_used = get_track_used(passthru_acodec, track_indices, count);
- // Has the track already been used with this codec for passthru?
- if (passthru_used[ii])
- continue;
- }
- // Find a track that is not visually impaired or dirctor's commentary
- if (audio->lang.type < 2)
- {
- if (channels > max_chan)
- {
- track = ii;
- max_chan = channels;
- }
- }
- }
- if (track > -1)
- {
- used[track] = TRUE;
- return track;
- }
- // Last ditch, anything goes
- for (ii = 0; ii < count; ii++)
- {
- audio = (hb_audio_config_t*)hb_list_audio_config_item(
- title->list_audio, ii );
- passthru_acodec = HB_ACODEC_PASS_MASK & audio->in.codec;
- if (passthru_acodec && passthru)
- {
- passthru_used = get_track_used(passthru_acodec, track_indices, count);
- // Has the track already been used with this codec for passthru?
- if (passthru_used[ii])
- continue;
- }
- // Has the track already been used with this codec?
- if (!used[ii])
- {
- track = ii;
- break;
+ return ii;
}
}
- if (track > -1)
- {
- used[track] = TRUE;
- }
- return track;
+ return -1;
}
gint
@@ -2682,89 +2565,24 @@ ghb_find_pref_subtitle_track(const gchar *lang)
}
gint
-ghb_find_cc_track(gint titleindex)
+ghb_find_subtitle_track(hb_title_t * title, const gchar * lang, int start)
{
- hb_title_t * title;
hb_subtitle_t * subtitle;
gint count, ii;
-
- g_debug("ghb_find_cc_track ()\n");
- title = ghb_get_title_info( titleindex );
- if (title != NULL)
- {
- count = hb_list_count( title->list_subtitle );
- // Try to find an item that matches the preferred language
- for (ii = 0; ii < count; ii++)
- {
- subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
- if (subtitle->source == CC608SUB || subtitle->source == CC708SUB)
- return ii;
- }
- }
- return -2;
-}
-
-gint
-ghb_find_subtitle_track(
- gint titleindex,
- const gchar * lang,
- gboolean burn,
- gboolean force,
- gint source,
- GHashTable * track_indices)
-{
- hb_title_t * title;
- hb_subtitle_t * subtitle;
- gint count, ii;
- gboolean *used;
-
- g_debug("find_subtitle_track ()\n");
- if (strcmp(lang, "auto") == 0)
- return -1;
- title = ghb_get_title_info( titleindex );
- if (title == NULL)
- return -2;
-
- count = hb_list_count( title->list_subtitle );
- used = g_hash_table_lookup(track_indices, lang);
- if (used == NULL)
- {
- used = g_malloc0(count * sizeof(gboolean));
- g_hash_table_insert(track_indices, g_strdup(lang), used);
- }
- // Try to find an item that matches the preferred language and source
- for (ii = 0; ii < count; ii++)
- {
- if (used[ii])
- continue;
+ count = hb_list_count(title->list_subtitle);
- subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
- if (source == subtitle->source &&
- ((strcmp(lang, subtitle->iso639_2) == 0) ||
- (strcmp(lang, "und") == 0)))
- {
- used[ii] = TRUE;
- return ii;
- }
- }
// Try to find an item that matches the preferred language
- for (ii = 0; ii < count; ii++)
+ for (ii = start; ii < count; ii++)
{
- if (used[ii])
- continue;
-
subtitle = (hb_subtitle_t*)hb_list_item( title->list_subtitle, ii );
- if (((!force || (force && ghb_canForceSub(subtitle->source))) &&
- (!burn || (burn && ghb_canBurnSub(subtitle->source)))) &&
- ((strcmp(lang, subtitle->iso639_2) == 0) ||
- (strcmp(lang, "und") == 0)))
+ if (strcmp(lang, subtitle->iso639_2) == 0 ||
+ strcmp(lang, "und") == 0)
{
- used[ii] = TRUE;
return ii;
}
}
- return -2;
+ return -1;
}
static void
@@ -2776,13 +2594,14 @@ generic_opts_set(GtkBuilder *builder, const gchar *name, combo_opts_t *opts)
g_debug("generic_opts_set ()\n");
if (name == NULL || opts == NULL) return;
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
for (ii = 0; ii < opts->count; ii++)
{
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
- 0, _(opts->map[ii].option),
+ 0, gettext(opts->map[ii].option),
1, TRUE,
2, opts->map[ii].shortOpt,
3, opts->map[ii].ivalue,
@@ -2801,12 +2620,14 @@ small_opts_set(GtkBuilder *builder, const gchar *name, combo_opts_t *opts)
g_debug("small_opts_set ()\n");
if (name == NULL || opts == NULL) return;
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
for (ii = 0; ii < opts->count; ii++)
{
gtk_list_store_append(store, &iter);
- str = g_strdup_printf("<small>%s</small>", _(opts->map[ii].option));
+ str = g_strdup_printf("<small>%s</small>",
+ gettext(opts->map[ii].option));
gtk_list_store_set(store, &iter,
0, str,
1, TRUE,
@@ -2848,16 +2669,12 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval)
return lookup_mixdown_int(gval);
else if (strcmp(name, "SrtLanguage") == 0)
return lookup_audio_lang_int(gval);
- else if (strcmp(name, "PreferredLanguage") == 0)
- return lookup_audio_lang_int(gval);
else if (strcmp(name, "VideoEncoder") == 0)
return lookup_video_encoder_int(gval);
else if (strcmp(name, "AudioEncoder") == 0)
return lookup_audio_encoder_int(gval);
else if (strcmp(name, "AudioEncoderFallback") == 0)
return lookup_audio_encoder_int(gval);
- else if (strcmp(name, "AudioEncoderActual") == 0)
- return lookup_audio_encoder_int(gval);
else if (strcmp(name, "FileFormat") == 0)
return lookup_container_int(gval);
else
@@ -2883,16 +2700,12 @@ ghb_lookup_combo_double(const gchar *name, const GValue *gval)
return lookup_mixdown_int(gval);
else if (strcmp(name, "SrtLanguage") == 0)
return lookup_audio_lang_int(gval);
- else if (strcmp(name, "PreferredLanguage") == 0)
- return lookup_audio_lang_int(gval);
else if (strcmp(name, "VideoEncoder") == 0)
return lookup_video_encoder_int(gval);
else if (strcmp(name, "AudioEncoder") == 0)
return lookup_audio_encoder_int(gval);
else if (strcmp(name, "AudioEncoderFallback") == 0)
return lookup_audio_encoder_int(gval);
- else if (strcmp(name, "AudioEncoderActual") == 0)
- return lookup_audio_encoder_int(gval);
else if (strcmp(name, "FileFormat") == 0)
return lookup_container_int(gval);
else
@@ -2918,16 +2731,12 @@ ghb_lookup_combo_option(const gchar *name, const GValue *gval)
return lookup_mixdown_option(gval);
else if (strcmp(name, "SrtLanguage") == 0)
return lookup_audio_lang_option(gval);
- else if (strcmp(name, "PreferredLanguage") == 0)
- return lookup_audio_lang_option(gval);
else if (strcmp(name, "VideoEncoder") == 0)
return lookup_video_encoder_option(gval);
else if (strcmp(name, "AudioEncoder") == 0)
return lookup_audio_encoder_option(gval);
else if (strcmp(name, "AudioEncoderFallback") == 0)
return lookup_audio_encoder_option(gval);
- else if (strcmp(name, "AudioEncoderActual") == 0)
- return lookup_audio_encoder_option(gval);
else if (strcmp(name, "FileFormat") == 0)
return lookup_container_option(gval);
else
@@ -2953,16 +2762,12 @@ ghb_lookup_combo_string(const gchar *name, const GValue *gval)
return lookup_mixdown_string(gval);
else if (strcmp(name, "SrtLanguage") == 0)
return lookup_audio_lang_option(gval);
- else if (strcmp(name, "PreferredLanguage") == 0)
- return lookup_audio_lang_option(gval);
else if (strcmp(name, "VideoEncoder") == 0)
return lookup_video_encoder_string(gval);
else if (strcmp(name, "AudioEncoder") == 0)
return lookup_audio_encoder_string(gval);
else if (strcmp(name, "AudioEncoderFallback") == 0)
return lookup_audio_encoder_string(gval);
- else if (strcmp(name, "AudioEncoderActual") == 0)
- return lookup_audio_encoder_string(gval);
else if (strcmp(name, "FileFormat") == 0)
return lookup_container_string(gval);
else
@@ -2973,6 +2778,77 @@ ghb_lookup_combo_string(const gchar *name, const GValue *gval)
return NULL;
}
+#if 0
+static gboolean acodec_list_box_filter(GtkListBoxRow *row, gpointer data)
+{
+ GValue *settings = (GValue*)data;
+
+ int mux = ghb_settings_combo_int(settings, "FileFormat");
+
+ GtkWidget *label = gtk_bin_get_child(GTK_BIN(row));
+ int codec = (intptr_t)g_object_get_data(G_OBJECT(label), "codec");
+
+ const hb_encoder_t *enc;
+ for (enc = hb_audio_encoder_get_next(NULL); enc != NULL;
+ enc = hb_audio_encoder_get_next(enc))
+ {
+ if (enc->codec == codec && (mux & enc->muxers))
+ {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void ghb_update_acodec_list_box(GtkListBox *list_box)
+{
+ gtk_list_box_invalidate_filter(list_box);
+}
+
+void ghb_init_acodec_list_box(GtkListBox *list_box, GValue *settings)
+{
+ int mux = ghb_settings_combo_int(settings, "FileFormat");
+
+ const hb_encoder_t *enc;
+ for (enc = hb_audio_encoder_get_next(NULL); enc != NULL;
+ enc = hb_audio_encoder_get_next(enc))
+ {
+ if (mux & enc->muxers)
+ {
+ GtkWidget *label = gtk_label_new(enc->name);
+ g_object_set_data(G_OBJECT(label), "codec", (gpointer)(intptr_t)enc->codec);
+ gtk_widget_show(label);
+ gtk_list_box_insert(list_box, label, -1);
+ }
+ }
+ gtk_list_box_set_filter_func(list_box, acodec_list_box_filter,
+ settings, NULL);
+}
+#endif
+
+void ghb_init_lang_list_box(GtkListBox *list_box)
+{
+ int ii;
+
+ for (ii = 0; ii < LANG_TABLE_SIZE; ii++)
+ {
+ const char *lang;
+ if (ghb_language_table[ii].native_name != NULL &&
+ ghb_language_table[ii].native_name[0] != 0)
+ {
+ lang = ghb_language_table[ii].native_name;
+ }
+ else
+ {
+ lang = ghb_language_table[ii].eng_name;
+ }
+ GtkWidget *label = gtk_label_new(lang);
+ g_object_set_data(G_OBJECT(label), "lang_idx", (gpointer)(intptr_t)ii);
+ gtk_widget_show(label);
+ gtk_list_box_insert(list_box, label, -1);
+ }
+}
+
void
ghb_update_ui_combo_box(
signal_user_data_t *ud,
@@ -3014,12 +2890,13 @@ ghb_update_ui_combo_box(
audio_encoder_opts_set(ud->builder, "AudioEncoder");
acodec_fallback_opts_set(ud->builder, "AudioEncoderFallback");
language_opts_set(ud->builder, "SrtLanguage");
- language_opts_set(ud->builder, "PreferredLanguage");
srt_codeset_opts_set(ud->builder, "SrtCodeset");
title_opts_set(ud->builder, "title");
audio_track_opts_set(ud->builder, "AudioTrack", user_data);
subtitle_track_opts_set(ud->builder, "SubtitleTrack", user_data);
generic_opts_set(ud->builder, "VideoQualityGranularity", &vqual_granularity_opts);
+ generic_opts_set(ud->builder, "SubtitleTrackSelectionBehavior", &subtitle_track_sel_opts);
+ generic_opts_set(ud->builder, "AudioTrackSelectionBehavior", &audio_track_sel_opts);
generic_opts_set(ud->builder, "PtoPType", &point_to_point_opts);
generic_opts_set(ud->builder, "WhenComplete", &when_complete_opts);
generic_opts_set(ud->builder, "PicturePAR", &par_opts);
@@ -3062,8 +2939,6 @@ ghb_update_ui_combo_box(
acodec_fallback_opts_set(ud->builder, "AudioEncoderFallback");
else if (strcmp(name, "SrtLanguage") == 0)
language_opts_set(ud->builder, "SrtLanguage");
- else if (strcmp(name, "PreferredLanguage") == 0)
- language_opts_set(ud->builder, "PreferredLanguage");
else if (strcmp(name, "SrtCodeset") == 0)
srt_codeset_opts_set(ud->builder, "SrtCodeset");
else if (strcmp(name, "title") == 0)
@@ -3099,7 +2974,6 @@ init_ui_combo_boxes(GtkBuilder *builder)
init_combo_box(builder, "VideoFramerate");
init_combo_box(builder, "AudioMixdown");
init_combo_box(builder, "SrtLanguage");
- init_combo_box(builder, "PreferredLanguage");
init_combo_box(builder, "SrtCodeset");
init_combo_box(builder, "title");
init_combo_box(builder, "AudioTrack");
@@ -3354,38 +3228,68 @@ audio_bitrate_opts_add(GtkBuilder *builder, const gchar *name, gint rate)
if (rate >= 0 && rate < 8) return;
- if (ghb_audio_bitrates[ghb_abr_count].name)
+ if (ghb_custom_bitrate_str != NULL)
{
- g_free((char*)ghb_audio_bitrates[ghb_abr_count].name);
+ g_free(ghb_custom_bitrate_str);
}
- ghb_audio_bitrates[ghb_abr_count].rate = rate;
+ ghb_custom_bitrate = rate;
if (rate < 0)
{
- ghb_audio_bitrates[ghb_abr_count].name = g_strdup_printf("N/A");
+ ghb_custom_bitrate_str = g_strdup_printf("N/A");
}
else
{
- ghb_audio_bitrates[ghb_abr_count].name = g_strdup_printf("%d", rate);
+ ghb_custom_bitrate_str = g_strdup_printf("%d", rate);
}
- ghb_audio_bitrates_count = ghb_abr_count + 1;
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
if (!find_combo_item_by_int(GTK_TREE_MODEL(store), rate, &iter))
{
- str = g_strdup_printf ("<small>%s</small>",
- ghb_audio_bitrates[ghb_abr_count].name);
+ str = g_strdup_printf ("<small>%s</small>", ghb_custom_bitrate_str);
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
0, str,
1, TRUE,
- 2, ghb_audio_bitrates[ghb_abr_count].name,
+ 2, ghb_custom_bitrate_str,
3, (gdouble)rate,
- 4, ghb_audio_bitrates[ghb_abr_count].name,
+ 4, ghb_custom_bitrate_str,
-1);
g_free(str);
}
}
+void
+ghb_audio_bitrate_opts_filter(
+ GtkComboBox *combo,
+ gint first_rate,
+ gint last_rate)
+{
+ GtkTreeIter iter;
+ GtkListStore *store;
+ gdouble ivalue;
+ gboolean done = FALSE;
+
+ g_debug("audio_bitrate_opts_filter ()\n");
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(store), &iter))
+ {
+ do
+ {
+ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 3, &ivalue, -1);
+ if ((int)ivalue < first_rate || (int)ivalue > last_rate)
+ {
+ gtk_list_store_set(store, &iter, 1, FALSE, -1);
+ }
+ else
+ {
+ gtk_list_store_set(store, &iter, 1, TRUE, -1);
+ }
+ done = !gtk_tree_model_iter_next (GTK_TREE_MODEL(store), &iter);
+ } while (!done);
+ }
+}
+
static void
audio_bitrate_opts_update(
GtkBuilder *builder,
@@ -3398,91 +3302,85 @@ audio_bitrate_opts_update(
GtkListStore *store;
gdouble ivalue;
gboolean done = FALSE;
- gint ii = 0;
- guint last = (guint)last_rate;
- guint first = (guint)first_rate;
- ghb_audio_bitrates_count = ghb_abr_count;
-
g_debug("audio_bitrate_opts_clean ()\n");
- store = get_combo_box_store(builder, name);
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ ghb_audio_bitrate_opts_filter(combo, first_rate, last_rate);
+
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(store), &iter))
{
do
{
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 3, &ivalue, -1);
- if (ivalue != first_rate && ivalue != last_rate &&
- !(ivalue == extra_rate && extra_rate >= first_rate) &&
- search_rates(
- ghb_audio_bitrates, ivalue, ghb_audio_bitrates_count) < 0)
+ if (!search_audio_bitrates(ivalue) && (ivalue != extra_rate))
{
done = !gtk_list_store_remove(store, &iter);
}
- else if ((int)ivalue < first || (int)ivalue > last)
- {
- ii++;
- gtk_list_store_set(store, &iter, 1, FALSE, -1);
- done = !gtk_tree_model_iter_next (GTK_TREE_MODEL(store), &iter);
- }
else
{
- ii++;
- gtk_list_store_set(store, &iter, 1, TRUE, -1);
- done = !gtk_tree_model_iter_next (GTK_TREE_MODEL(store), &iter);
+ done = !gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
}
} while (!done);
}
- if (extra_rate >= first_rate)
+ if (extra_rate > 0 && !search_audio_bitrates(extra_rate))
+ {
audio_bitrate_opts_add(builder, name, extra_rate);
+ }
+ else
+ {
+ g_free(ghb_custom_bitrate_str);
+ ghb_custom_bitrate_str = NULL;
+ ghb_custom_bitrate = 0;
+ }
}
-static void
-audio_bitrate_opts_set(GtkBuilder *builder, const gchar *name)
+void
+ghb_audio_bitrate_opts_set(GtkComboBox *combo, gboolean extra)
{
GtkTreeIter iter;
GtkListStore *store;
- gint count = 0;
gchar *str;
- int ii;
- const hb_rate_t *rate;
-
- if (ghb_audio_bitrates == NULL)
- {
- // Count rates
- for (rate = hb_audio_bitrate_get_next(NULL); rate != NULL;
- rate = hb_audio_bitrate_get_next(rate))
- {
- count++;
- }
-
- ghb_audio_bitrates_count = ghb_abr_count = count;
- ghb_audio_bitrates = calloc(count+1, sizeof(hb_rate_t));
-
- for (ii = 0, rate = hb_audio_bitrate_get_next(NULL); rate != NULL;
- ii++, rate = hb_audio_bitrate_get_next(rate))
- {
- ghb_audio_bitrates[ii] = *rate;
- }
- }
-
g_debug("audio_bitrate_opts_set ()\n");
- store = get_combo_box_store(builder, name);
+ store = GTK_LIST_STORE(gtk_combo_box_get_model (combo));
gtk_list_store_clear(store);
- for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
+
+ const hb_rate_t *rate;
+ for (rate = hb_audio_bitrate_get_next(NULL); rate != NULL;
+ rate = hb_audio_bitrate_get_next(rate))
{
gtk_list_store_append(store, &iter);
- str = g_strdup_printf ("<small>%s</small>",
- ghb_audio_bitrates[ii].name);
+ str = g_strdup_printf ("<small>%s</small>", rate->name);
gtk_list_store_set(store, &iter,
0, str,
1, TRUE,
- 2, ghb_audio_bitrates[ii].name,
- 3, (gdouble)ghb_audio_bitrates[ii].rate,
- 4, ghb_audio_bitrates[ii].name,
+ 2, rate->name,
+ 3, (gdouble)rate->rate,
+ 4, rate->name,
-1);
g_free(str);
}
+ if (extra && ghb_custom_bitrate_str != NULL)
+ {
+ gtk_list_store_append(store, &iter);
+ str = g_strdup_printf ("<small>%s</small>", ghb_custom_bitrate_str);
+ gtk_list_store_set(store, &iter,
+ 0, str,
+ 1, TRUE,
+ 2, ghb_custom_bitrate_str,
+ 3, (gdouble)ghb_custom_bitrate,
+ 4, ghb_custom_bitrate_str,
+ -1);
+ g_free(str);
+ }
+}
+
+static void
+audio_bitrate_opts_set(GtkBuilder *builder, const gchar *name)
+{
+ GtkComboBox *combo = GTK_COMBO_BOX(GHB_WIDGET(builder, name));
+ ghb_audio_bitrate_opts_set(combo, TRUE);
}
void
@@ -4361,7 +4259,7 @@ ghb_validate_filters(GValue *settings)
if (!ghb_validate_filter_string(str, -1))
{
message = g_strdup_printf(
- N_("Invalid Decomb Settings:\n\n%s\n"),
+ _("Invalid Decomb Settings:\n\n%s\n"),
str);
ghb_message_dialog(GTK_MESSAGE_ERROR, message, _("Cancel"), NULL);
g_free(message);
@@ -5147,7 +5045,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex)
{
sub_config.dest = PASSTHRUSUB;
}
- else if ( burned && ghb_canBurnSub(subt->source) )
+ else if (burned && hb_subtitle_can_burn(subt->source))
{
// Only allow one subtitle to be burned into the video
if (one_burned)