githubのコードからのfolk
Revision | 2f6992459212e48a2642251e639a00a2f3ee3e10 (tree) |
---|---|
Time | 2010-10-07 07:59:17 |
Author | jstebbins <jstebbins@b64f...> |
Commiter | jstebbins |
LinGui: centralize min/max audio bitrate limit calculation to one place
git-svn-id: svn://localhost/HandBrake/trunk@3575 b64f7644-9d1e-0410-96f1-a4d463321fa5
@@ -50,7 +50,9 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) | ||
50 | 50 | mix = ghb_lookup_combo_int("AudioMixdown", gval); |
51 | 51 | ghb_value_free(gval); |
52 | 52 | |
53 | - bitrate = ghb_settings_combo_int(ud->settings, "AudioBitrate"); | |
53 | + widget = GHB_WIDGET(ud->builder, "AudioBitrate"); | |
54 | + gval = ghb_widget_value(widget); | |
55 | + bitrate = ghb_lookup_combo_int("AudioBitrate", gval); | |
54 | 56 | |
55 | 57 | select_acodec = acodec; |
56 | 58 | if (mux == HB_MUX_MP4) |
@@ -107,25 +109,11 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) | ||
107 | 109 | gint channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mix); |
108 | 110 | bitrate = ghb_get_best_audio_bitrate(select_acodec, bitrate, channels); |
109 | 111 | ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate)); |
110 | - if (select_acodec == HB_ACODEC_FAAC) | |
111 | - { | |
112 | - gint last = 320, first = 0; | |
113 | 112 | |
114 | - if (mix == HB_AMIXDOWN_6CH) | |
115 | - { | |
116 | - first = 192; | |
117 | - last = 768; | |
118 | - } | |
119 | - ghb_set_default_bitrate_opts (ud->builder, first, last); | |
120 | - } | |
121 | - else if (select_acodec == HB_ACODEC_AC3) | |
122 | - { | |
123 | - ghb_set_default_bitrate_opts (ud->builder, 0, 640); | |
124 | - } | |
125 | - else | |
126 | - { | |
127 | - ghb_set_default_bitrate_opts (ud->builder, 0, -1); | |
128 | - } | |
113 | + int low, high; | |
114 | + ghb_get_audio_bitrate_limits(select_acodec, channels, &low, &high); | |
115 | + ghb_set_default_bitrate_opts (ud->builder, low, high); | |
116 | + | |
129 | 117 | ghb_settings_take_value(ud->settings, "AudioEncoderActual", |
130 | 118 | ghb_lookup_acodec_value(select_acodec)); |
131 | 119 | ghb_check_dependency(ud, NULL, "AudioEncoderActual"); |
@@ -1610,6 +1610,31 @@ ghb_grey_combo_options(GtkBuilder *builder) | ||
1610 | 1610 | grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_6CH, !allow_6ch); |
1611 | 1611 | } |
1612 | 1612 | |
1613 | +void | |
1614 | +ghb_get_audio_bitrate_limits(gint acodec, gint channels, gint *low, gint *high) | |
1615 | +{ | |
1616 | + if (acodec & HB_ACODEC_FAAC) | |
1617 | + { | |
1618 | + *low = 32 * channels; | |
1619 | + if (channels >= 6) | |
1620 | + *high = 768; | |
1621 | + else if (channels >= 2) | |
1622 | + *high = 320; | |
1623 | + else | |
1624 | + *high = 160; | |
1625 | + } | |
1626 | + else if (acodec & HB_ACODEC_AC3) | |
1627 | + { | |
1628 | + *low = 32 * channels; | |
1629 | + *high = 640; | |
1630 | + } | |
1631 | + else | |
1632 | + { | |
1633 | + *low = hb_audio_bitrates[0].rate; | |
1634 | + *high = hb_audio_bitrates[hb_audio_bitrates_count-1].rate; | |
1635 | + } | |
1636 | +} | |
1637 | + | |
1613 | 1638 | gint |
1614 | 1639 | ghb_find_closest_audio_bitrate(gint codec, gint rate) |
1615 | 1640 | { |
@@ -189,6 +189,7 @@ gint ghb_find_closest_audio_bitrate(gint codec, gint rate); | ||
189 | 189 | gint ghb_find_closest_audio_rate(gint rate); |
190 | 190 | gint ghb_get_best_audio_bitrate(gint acodec, gint br, gint channels); |
191 | 191 | gint ghb_get_default_audio_bitrate(gint acodec, gint sr, gint br, gint channels); |
192 | +void ghb_get_audio_bitrate_limits(gint acodec, gint channels, gint *low, gint *high); | |
192 | 193 | GValue* ghb_lookup_acodec_value(gint val); |
193 | 194 | |
194 | 195 | #endif // _HBBACKEND_H_ |