summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-02-23 21:04:26 +0000
committerjstebbins <[email protected]>2014-02-23 21:04:26 +0000
commitee29f5abf647c269f07277d39ec5347d5cca51ae (patch)
tree2138afade0f4dceaa22735b7cd04b49386eb588f /gtk
parenta02aaa8231cac7e63f3768f43a04616073c49cd5 (diff)
LinGui: rework how hb audio mixdowns are referenced from lingui
Cleans up interface and fixes faulure to use fallbacks properly git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6070 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/audiohandler.c68
-rw-r--r--gtk/src/hb-backend.c146
-rw-r--r--gtk/src/hb-backend.h5
-rw-r--r--gtk/src/internal_defaults.xml18
-rw-r--r--gtk/src/queuehandler.c6
5 files changed, 100 insertions, 143 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index 8a1879a9c..8be0cd82f 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -223,7 +223,7 @@ audio_sanitize_settings(GValue *settings, GValue *asettings)
title = ghb_lookup_title(title_id, &titleindex);
track = ghb_settings_get_int(asettings, "AudioTrack");
acodec = ghb_settings_audio_encoder_codec(asettings, "AudioEncoder");
- mix = ghb_settings_combo_int(asettings, "AudioMixdown");
+ mix = ghb_settings_mixdown_mix(asettings, "AudioMixdown");
bitrate = ghb_settings_combo_int(asettings, "AudioBitrate");
sr = ghb_settings_combo_int(asettings, "AudioSamplerate");
@@ -243,18 +243,18 @@ audio_sanitize_settings(GValue *settings, GValue *asettings)
bitrate = aconfig->in.bitrate / 1000;
// Set the values for bitrate and samplerate to the input rates
- mix = 0;
+ mix = HB_AMIXDOWN_NONE;
ghb_settings_set_string(asettings, "AudioMixdown",
- ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix)));
+ hb_mixdown_get_short_name(mix));
select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG;
ghb_settings_set_string(asettings, "AudioSamplerate",
ghb_lookup_combo_string("AudioSamplerate", ghb_int_value(0)));
}
else
{
- mix = 0;
+ mix = HB_AMIXDOWN_NONE;
ghb_settings_set_string(asettings, "AudioMixdown",
- ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix)));
+ hb_mixdown_get_short_name(mix));
ghb_settings_set_string(asettings, "AudioSamplerate",
ghb_lookup_combo_string("AudioSamplerate", ghb_int_value(0)));
bitrate = 448;
@@ -263,11 +263,11 @@ audio_sanitize_settings(GValue *settings, GValue *asettings)
}
else
{
- if (mix == 0)
- mix = ghb_get_best_mix( aconfig, select_acodec, 0);
+ if (mix == HB_AMIXDOWN_NONE)
+ mix = ghb_get_best_mix(aconfig, select_acodec, mix);
bitrate = hb_audio_bitrate_get_best(select_acodec, bitrate, sr, mix);
ghb_settings_set_string(asettings, "AudioMixdown",
- ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix)));
+ hb_mixdown_get_short_name(mix));
}
ghb_settings_set_string(asettings, "AudioBitrate",
ghb_lookup_combo_string("AudioBitrate", ghb_int_value(bitrate)));
@@ -303,11 +303,7 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
ghb_value_free(gval);
acodec = ghb_settings_audio_encoder_codec(ud->settings, "AudioEncoder");
-
- widget = GHB_WIDGET(ud->builder, "AudioMixdown");
- gval = ghb_widget_value(widget);
- mix = ghb_lookup_combo_int("AudioMixdown", gval);
- ghb_value_free(gval);
+ mix = ghb_settings_mixdown_mix(ud->settings, "AudioMixdown");
widget = GHB_WIDGET(ud->builder, "AudioBitrate");
gval = ghb_widget_value(widget);
@@ -337,8 +333,9 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
// Set the values for bitrate and samplerate to the input rates
ghb_set_bitrate_opts (ud->builder, bitrate, bitrate, bitrate);
- mix = 0;
- ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix));
+ mix = HB_AMIXDOWN_NONE;
+ ghb_ui_update(ud, "AudioMixdown",
+ ghb_string_value(hb_mixdown_get_short_name(mix)));
select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG;
codec_defined_bitrate = TRUE;
ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0));
@@ -346,18 +343,20 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
else
{
ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0));
- mix = 0;
- ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix));
+ mix = HB_AMIXDOWN_NONE;
+ ghb_ui_update(ud, "AudioMixdown",
+ ghb_string_value(hb_mixdown_get_short_name(mix)));
bitrate = 448;
}
ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(0));
}
else
{
- if (mix == 0)
- mix = ghb_get_best_mix( aconfig, select_acodec, 0);
+ if (mix == HB_AMIXDOWN_NONE)
+ mix = ghb_get_best_mix( aconfig, select_acodec, mix);
bitrate = hb_audio_bitrate_get_best(select_acodec, bitrate, sr, mix);
- ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix));
+ ghb_ui_update(ud, "AudioMixdown",
+ ghb_string_value(hb_mixdown_get_short_name(mix)));
}
if (!codec_defined_bitrate)
{
@@ -489,7 +488,7 @@ audio_add_track(
mix = ghb_get_best_mix(aconfig, encoder, mix);
}
ghb_settings_set_string(asettings, "AudioMixdown",
- ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix)));
+ hb_mixdown_get_short_name(mix));
ghb_settings_set_double(asettings, "AudioTrackDRCSlider", drc);
@@ -533,7 +532,7 @@ audio_select_and_add_track(
bitrate = ghb_settings_combo_int(audio, "AudioBitrate");
samplerate = ghb_settings_combo_int(audio, "AudioSamplerate");
- mix = ghb_settings_combo_int(audio, "AudioMixdown");
+ mix = ghb_settings_mixdown_mix(audio, "AudioMixdown");
drc = ghb_settings_get_double(audio, "AudioTrackDRCSlider");
gain = ghb_settings_get_double(audio, "AudioTrackGainSlider");
enable_quality = ghb_settings_get_boolean(audio, "AudioTrackQualityEnable");
@@ -600,7 +599,7 @@ static void set_pref_audio_with_lang(
copy_mask = ghb_get_copy_mask(settings);
bitrate = ghb_settings_combo_int(audio, "AudioBitrate");
samplerate = ghb_settings_combo_int(audio, "AudioSamplerate");
- mix = ghb_settings_combo_int(audio, "AudioMixdown");
+ mix = ghb_settings_mixdown_mix(audio, "AudioMixdown");
drc = ghb_settings_get_double(audio, "AudioTrackDRCSlider");
gain = ghb_settings_get_double(audio, "AudioTrackGainSlider");
enable_quality = ghb_settings_get_boolean(audio,
@@ -758,7 +757,7 @@ audio_refresh_list_row_ui(
info_src_2 = NULL;
info_dst_2 = NULL;
- const gchar *s_track, *s_mix;
+ const gchar *s_track;
gchar *s_drc, *s_gain, *s_br_quality, *s_sr, *s_track_name;
gdouble drc, gain;
hb_audio_config_t *aconfig;
@@ -799,7 +798,8 @@ audio_refresh_list_row_ui(
}
s_sr = g_strdup_printf("%.4gkHz", (double)sr/1000);
- s_mix = ghb_settings_combo_option(settings, "AudioMixdown");
+ const hb_mixdown_t *mix;
+ mix = ghb_settings_mixdown(settings, "AudioMixdown");
gain = ghb_settings_get_double(settings, "AudioTrackGainSlider");
s_gain = g_strdup_printf("%ddB", (int)gain);
@@ -827,7 +827,8 @@ audio_refresh_list_row_ui(
}
else
{
- info_dst = g_strdup_printf("%s (%s) (%s)", encoder->name, s_mix, s_sr);
+ info_dst = g_strdup_printf("%s (%s) (%s)",
+ encoder->name, mix->name, s_sr);
if (s_track_name && s_track_name[0])
{
info_dst_2 = g_strdup_printf(
@@ -988,7 +989,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
const hb_title_t *title;
gint titleindex;
gint track;
- gint br, sr, mix_code;
+ gint br, sr, mix;
title_id = ghb_settings_get_int(ud->settings, "title");
title = ghb_lookup_title(title_id, &titleindex);
@@ -997,13 +998,13 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
br = ghb_settings_get_int(asettings, "AudioBitrate");
sr = ghb_settings_combo_int(asettings, "AudioSamplerate");
- mix_code = ghb_settings_combo_int(asettings, "AudioMixdown");
+ mix = ghb_settings_mixdown_mix(asettings, "AudioMixdown");
}
else
{
br = 160;
sr = 0;
- mix_code = 0;
+ mix = HB_AMIXDOWN_NONE;
}
track = ghb_settings_get_int(ud->settings, "AudioTrack");
@@ -1019,11 +1020,12 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
sr = aconfig ? aconfig->in.samplerate : 48000;
}
- mix_code = ghb_get_best_mix( aconfig, acodec, mix_code);
- br = hb_audio_bitrate_get_best(acodec, br, sr, mix_code);
+ mix = ghb_get_best_mix( aconfig, acodec, mix);
+ br = hb_audio_bitrate_get_best(acodec, br, sr, mix);
ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(br));
- ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix_code));
+ ghb_ui_update(ud, "AudioMixdown",
+ ghb_string_value(hb_mixdown_get_short_name(mix)));
}
prev_acodec = acodec;
if (asettings != NULL)
@@ -2150,7 +2152,7 @@ void audio_def_set_limits(signal_user_data_t *ud, GtkWidget *widget)
{
sr = 48000;
}
- int mix = ghb_settings_combo_int(adict, "AudioMixdown");
+ int mix = ghb_settings_mixdown_mix(adict, "AudioMixdown");
int low, high;
hb_audio_bitrate_get_limits(enc, sr, mix, &low, &high);
GtkWidget *w = find_widget(GTK_WIDGET(row), "AudioBitrate");
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index e0d871290..aaa04cd4a 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -861,76 +861,6 @@ lookup_generic_option(combo_opts_t *opts, const GValue *gval)
return result;
}
-static const hb_mixdown_t *
-lookup_mixdown_by_int(int imix)
-{
- const hb_mixdown_t *mix;
- for (mix = hb_mixdown_get_next(NULL); mix != NULL;
- mix = hb_mixdown_get_next(mix))
- {
- if (mix->amixdown == imix)
- {
- return mix;
- }
- }
- return NULL;
-}
-
-static const hb_mixdown_t *
-lookup_mixdown(const GValue *gmix)
-{
- const hb_mixdown_t *mix;
-
- if (G_VALUE_TYPE(gmix) == G_TYPE_STRING)
- {
- gchar * str = ghb_value_string(gmix);
- for (mix = hb_mixdown_get_next(NULL); mix != NULL;
- mix = hb_mixdown_get_next(mix))
- {
- if (strcmp(mix->short_name, str) == 0)
- {
- g_free(str);
- return mix;
- }
- }
- g_free(str);
- }
- else if (G_VALUE_TYPE(gmix) == G_TYPE_INT ||
- G_VALUE_TYPE(gmix) == G_TYPE_INT64 ||
- G_VALUE_TYPE(gmix) == G_TYPE_DOUBLE)
- {
- return lookup_mixdown_by_int(ghb_value_int(gmix));
- }
- return NULL;
-}
-
-static gint
-lookup_mixdown_int(const GValue *gmix)
-{
- const hb_mixdown_t *mix = lookup_mixdown(gmix);
- if (mix != NULL)
- return mix->amixdown;
- return 0;
-}
-
-static const gchar*
-lookup_mixdown_option(const GValue *gmix)
-{
- const hb_mixdown_t *mix = lookup_mixdown(gmix);
- if (mix != NULL)
- return mix->name;
- return "None";
-}
-
-static const gchar*
-lookup_mixdown_string(const GValue *gmix)
-{
- const hb_mixdown_t *mix = lookup_mixdown(gmix);
- if (mix != NULL)
- return mix->short_name;
- return "none";
-}
-
static const hb_rate_t *
lookup_video_framerate(const GValue *grate)
{
@@ -1160,15 +1090,6 @@ lookup_audio_lang_option(const GValue *glang)
return "Any";
}
-static GValue*
-lookup_mixdown_value(gint imix)
-{
- const hb_mixdown_t *mix = lookup_mixdown_by_int(imix);
- if (mix != NULL)
- return ghb_string_value_new(mix->short_name);
- return NULL;
-}
-
// Handle for libhb. Gets set by ghb_backend_init()
static hb_handle_t * h_scan = NULL;
static hb_handle_t * h_queue = NULL;
@@ -1407,7 +1328,7 @@ ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix)
if (mix == HB_AMIXDOWN_NONE)
mix = HB_INVALID_AMIXDOWN;
- return hb_mixdown_get_best( acodec, layout, mix );
+ return hb_mixdown_get_best(acodec, layout, mix);
}
// Set up the model for the combo box
@@ -1812,19 +1733,43 @@ ghb_mix_opts_set(GtkComboBox *combo)
}
const hb_mixdown_t*
-ghb_lookup_mix(const char *name)
+ghb_lookup_mixdown(const char *name)
{
- const hb_mixdown_t *mix;
- for (mix = hb_mixdown_get_next(NULL); mix != NULL;
- mix = hb_mixdown_get_next(mix))
+ // First find an enabled mixdown
+ int mix = hb_mixdown_get_from_name(name);
+
+ // Now find the matching mixdown info
+ const hb_mixdown_t *mixdown, *first;
+ for (first = mixdown = hb_mixdown_get_next(NULL); mixdown != NULL;
+ mixdown = hb_mixdown_get_next(mixdown))
{
- if (!strncmp(name, mix->short_name, 80) ||
- !strncmp(name, mix->name, 80))
+ if (mix == mixdown->amixdown)
{
- return mix;
+ return mixdown;
}
}
- return NULL;
+ // Return a default mixdown if nothing matches
+ return first;
+}
+
+int
+ghb_lookup_mixdown_mix(const char *name)
+{
+ return ghb_lookup_mixdown(name)->amixdown;
+}
+
+int
+ghb_settings_mixdown_mix(const GValue *settings, const char *name)
+{
+ const char *mixdown_id = ghb_settings_get_const_string(settings, name);
+ return ghb_lookup_mixdown_mix(mixdown_id);
+}
+
+const hb_mixdown_t*
+ghb_settings_mixdown(const GValue *settings, const char *name)
+{
+ const char *mixdown_id = ghb_settings_get_const_string(settings, name);
+ return ghb_lookup_mixdown(mixdown_id);
}
static void
@@ -2587,8 +2532,6 @@ ghb_lookup_combo_int(const gchar *name, const GValue *gval)
return lookup_audio_samplerate_int(gval);
else if (strcmp(name, "VideoFramerate") == 0)
return lookup_video_framerate_int(gval);
- else if (strcmp(name, "AudioMixdown") == 0)
- return lookup_mixdown_int(gval);
else if (strcmp(name, "SrtLanguage") == 0)
return lookup_audio_lang_int(gval);
else
@@ -2610,8 +2553,6 @@ ghb_lookup_combo_double(const gchar *name, const GValue *gval)
return lookup_audio_samplerate_int(gval);
else if (strcmp(name, "VideoFramerate") == 0)
return lookup_video_framerate_int(gval);
- else if (strcmp(name, "AudioMixdown") == 0)
- return lookup_mixdown_int(gval);
else if (strcmp(name, "SrtLanguage") == 0)
return lookup_audio_lang_int(gval);
else
@@ -2633,8 +2574,6 @@ ghb_lookup_combo_option(const gchar *name, const GValue *gval)
return lookup_audio_samplerate_option(gval);
else if (strcmp(name, "VideoFramerate") == 0)
return lookup_video_framerate_option(gval);
- else if (strcmp(name, "AudioMixdown") == 0)
- return lookup_mixdown_option(gval);
else if (strcmp(name, "SrtLanguage") == 0)
return lookup_audio_lang_option(gval);
else
@@ -2656,8 +2595,6 @@ ghb_lookup_combo_string(const gchar *name, const GValue *gval)
return lookup_audio_samplerate_string(gval);
else if (strcmp(name, "VideoFramerate") == 0)
return lookup_video_framerate_option(gval);
- else if (strcmp(name, "AudioMixdown") == 0)
- return lookup_mixdown_string(gval);
else if (strcmp(name, "SrtLanguage") == 0)
return lookup_audio_lang_option(gval);
else
@@ -4321,14 +4258,13 @@ ghb_validate_audio(GValue *settings)
ghb_settings_set_string(asettings, "AudioEncoder", name);
}
- gint mix = ghb_settings_combo_int (asettings, "AudioMixdown");
+ const hb_mixdown_t *mix;
+ mix = ghb_settings_mixdown(asettings, "AudioMixdown");
const gchar *mix_unsup = NULL;
- if (!hb_mixdown_is_supported(mix, codec, aconfig->in.channel_layout))
+ if (!hb_mixdown_is_supported(mix->amixdown, codec, aconfig->in.channel_layout))
{
- const hb_mixdown_t *hb_mix = lookup_mixdown_by_int(mix);
- if (hb_mix != NULL)
- mix_unsup = hb_mix->name;
+ mix_unsup = mix->name;
}
if (mix_unsup)
{
@@ -4342,9 +4278,9 @@ ghb_validate_audio(GValue *settings)
return FALSE;
}
g_free(message);
- mix = ghb_get_best_mix(aconfig, codec, mix);
- GValue *value = lookup_mixdown_value(mix);
- ghb_settings_take_value(asettings, "AudioMixdown", value);
+ int amixdown = ghb_get_best_mix(aconfig, codec, mix->amixdown);
+ ghb_settings_set_string(asettings, "AudioMixdown",
+ hb_mixdown_get_short_name(amixdown));
}
}
return TRUE;
@@ -4772,7 +4708,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, int titleindex)
}
else
{
- audio.out.mixdown = ghb_settings_combo_int(asettings, "AudioMixdown");
+ audio.out.mixdown = ghb_settings_mixdown_mix(asettings, "AudioMixdown");
// Make sure the mixdown is valid and pick a new one if not.
audio.out.mixdown = ghb_get_best_mix(aconfig, audio.out.codec,
audio.out.mixdown);
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 71435588c..1eb4f01e8 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -183,5 +183,10 @@ int ghb_lookup_video_encoder_codec(const char *name);
int ghb_settings_video_encoder_codec(const GValue *settings, const char *name);
const hb_encoder_t* ghb_settings_video_encoder(
const GValue *settings, const char *name);
+const hb_mixdown_t* ghb_lookup_mixdown(const char *name);
+int ghb_lookup_mixdown_mix(const char *name);
+int ghb_settings_mixdown_mix(const GValue *settings, const char *name);
+const hb_mixdown_t* ghb_settings_mixdown(
+ const GValue *settings, const char *name);
#endif // _HBBACKEND_H_
diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml
index 665a20adc..c8430fda4 100644
--- a/gtk/src/internal_defaults.xml
+++ b/gtk/src/internal_defaults.xml
@@ -13,10 +13,24 @@
</dict>
<key>Initialization</key>
<dict>
- <key>AudioTrackName</key>
- <string></string>
+ <key>AudioBitrate</key>
+ <string>192</string>
<key>AudioEncoder</key>
<string>copy:ac3</string>
+ <key>AudioTrackQualityEnable</key>
+ <false />
+ <key>AudioTrackQuality</key>
+ <real>-1</real>
+ <key>AudioTrackGainSlider</key>
+ <real>0</real>
+ <key>AudioTrackDRCSlider</key>
+ <real>0</real>
+ <key>AudioMixdown</key>
+ <string>dpl2</string>
+ <key>AudioSamplerate</key>
+ <string>source</string>
+ <key>AudioTrackName</key>
+ <string></string>
<key>angle_count</key>
<integer>1</integer>
<key>angle</key>
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 4507aee6c..94f56ed7c 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -529,7 +529,6 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
for (ii = 0; ii < count; ii++)
{
gchar *quality = NULL, *samplerate, *track;
- const gchar *mix;
GValue *asettings;
gdouble sr;
const hb_encoder_t *audio_encoder;
@@ -560,7 +559,8 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
samplerate = g_strdup_printf("%.4g", sr);
}
track = ghb_settings_get_string(asettings, "AudioTrackDescription");
- mix = ghb_settings_combo_option(asettings, "AudioMixdown");
+ const hb_mixdown_t *mix;
+ mix = ghb_settings_mixdown(asettings, "AudioMixdown");
if (count > 1)
XPRINT("\t");
@@ -573,7 +573,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
{
XPRINT(
"<small>%s, Encoder: %s, Mixdown: %s, SampleRate: %s, %s</small>\n",
- track, audio_encoder->name, mix, samplerate, quality);
+ track, audio_encoder->name, mix->name, samplerate, quality);
}
g_free(track);
g_free(quality);