OSDN Git Service

LinGui: centralize min/max audio bitrate limit calculation to one place
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 6 Oct 2010 22:59:17 +0000 (22:59 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Wed, 6 Oct 2010 22:59:17 +0000 (22:59 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@3575 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/audiohandler.c
gtk/src/hb-backend.c
gtk/src/hb-backend.h

index 82273e2..78d405f 100644 (file)
@@ -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");
index ea99e0c..20ced8f 100644 (file)
@@ -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)
 {
index 48d7152..e5a816b 100644 (file)
@@ -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_