summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/src/audiohandler.c26
-rw-r--r--gtk/src/hb-backend.c25
-rw-r--r--gtk/src/hb-backend.h1
3 files changed, 33 insertions, 19 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index 82273e2af..78d405fd8 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -50,7 +50,9 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
mix = ghb_lookup_combo_int("AudioMixdown", gval);
ghb_value_free(gval);
- bitrate = ghb_settings_combo_int(ud->settings, "AudioBitrate");
+ widget = GHB_WIDGET(ud->builder, "AudioBitrate");
+ gval = ghb_widget_value(widget);
+ bitrate = ghb_lookup_combo_int("AudioBitrate", gval);
select_acodec = acodec;
if (mux == HB_MUX_MP4)
@@ -107,25 +109,11 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
gint channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mix);
bitrate = ghb_get_best_audio_bitrate(select_acodec, bitrate, channels);
ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate));
- if (select_acodec == HB_ACODEC_FAAC)
- {
- gint last = 320, first = 0;
- if (mix == HB_AMIXDOWN_6CH)
- {
- first = 192;
- last = 768;
- }
- ghb_set_default_bitrate_opts (ud->builder, first, last);
- }
- else if (select_acodec == HB_ACODEC_AC3)
- {
- ghb_set_default_bitrate_opts (ud->builder, 0, 640);
- }
- else
- {
- ghb_set_default_bitrate_opts (ud->builder, 0, -1);
- }
+ int low, high;
+ ghb_get_audio_bitrate_limits(select_acodec, channels, &low, &high);
+ ghb_set_default_bitrate_opts (ud->builder, low, high);
+
ghb_settings_take_value(ud->settings, "AudioEncoderActual",
ghb_lookup_acodec_value(select_acodec));
ghb_check_dependency(ud, NULL, "AudioEncoderActual");
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index ea99e0c57..20ced8f69 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1610,6 +1610,31 @@ ghb_grey_combo_options(GtkBuilder *builder)
grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_6CH, !allow_6ch);
}
+void
+ghb_get_audio_bitrate_limits(gint acodec, gint channels, gint *low, gint *high)
+{
+ if (acodec & HB_ACODEC_FAAC)
+ {
+ *low = 32 * channels;
+ if (channels >= 6)
+ *high = 768;
+ else if (channels >= 2)
+ *high = 320;
+ else
+ *high = 160;
+ }
+ else if (acodec & HB_ACODEC_AC3)
+ {
+ *low = 32 * channels;
+ *high = 640;
+ }
+ else
+ {
+ *low = hb_audio_bitrates[0].rate;
+ *high = hb_audio_bitrates[hb_audio_bitrates_count-1].rate;
+ }
+}
+
gint
ghb_find_closest_audio_bitrate(gint codec, gint rate)
{
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 48d71528e..e5a816b10 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -189,6 +189,7 @@ gint ghb_find_closest_audio_bitrate(gint codec, gint rate);
gint ghb_find_closest_audio_rate(gint rate);
gint ghb_get_best_audio_bitrate(gint acodec, gint br, gint channels);
gint ghb_get_default_audio_bitrate(gint acodec, gint sr, gint br, gint channels);
+void ghb_get_audio_bitrate_limits(gint acodec, gint channels, gint *low, gint *high);
GValue* ghb_lookup_acodec_value(gint val);
#endif // _HBBACKEND_H_