• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

githubのコードからのfolk


Commit MetaInfo

Revision0acc920cdafa286ec11f84a68eb017858846e1de (tree)
Time2010-10-06 07:30:37
Authorjstebbins <jstebbins@b64f...>
Commiterjstebbins

Log Message

LinGui: fix a display problem in the audio list
And tweak default bitrate choices. likely to change :P

git-svn-id: svn://localhost/HandBrake/trunk@3573 b64f7644-9d1e-0410-96f1-a4d463321fa5

Change Summary

Incremental Difference

--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -30,6 +30,7 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
3030 GtkWidget *widget;
3131 GValue *gval;
3232 int mux;
33+ gint bitrate;
3334
3435 g_debug("ghb_adjust_audio_rate_combos ()");
3536 mux = ghb_settings_combo_int(ud->settings, "FileFormat");
@@ -49,6 +50,8 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
4950 mix = ghb_lookup_combo_int("AudioMixdown", gval);
5051 ghb_value_free(gval);
5152
53+ bitrate = ghb_settings_combo_int(ud->settings, "AudioBitrate");
54+
5255 select_acodec = acodec;
5356 if (mux == HB_MUX_MP4)
5457 {
@@ -66,12 +69,12 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
6669 ghb_set_default_bitrate_opts (ud->builder, 0, -1);
6770 if (ghb_get_audio_info (&ainfo, titleindex, track))
6871 {
69- gint br = ainfo.bitrate / 1000;
72+ bitrate = ainfo.bitrate / 1000;
7073
7174 // Set the values for bitrate and samplerate to the input rates
7275 if (ainfo.codec & select_acodec & HB_ACODEC_PASS_MASK)
7376 {
74- ghb_set_passthru_bitrate_opts (ud->builder, br);
77+ ghb_set_passthru_bitrate_opts (ud->builder, bitrate);
7578 ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0));
7679 select_acodec &= ainfo.codec | HB_ACODEC_PASS_FLAG;
7780 }
@@ -83,17 +86,13 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
8386 ghb_ui_update(ud, "AudioEncoder", ghb_int64_value(select_acodec));
8487 }
8588
86- int channels, min_rate;
89+ int channels;
8790 mix = ghb_get_best_mix( titleindex, track, select_acodec, mix);
8891 channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mix);
89- br = ainfo.bitrate / 1000;
90- min_rate = channels * 32;
91- if (br < min_rate)
92- br = min_rate;
93- br = ghb_find_closest_audio_bitrate(select_acodec, br);
92+ bitrate = ghb_get_default_audio_bitrate(select_acodec, ainfo.samplerate, bitrate, channels);
9493 ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix));
9594 }
96- ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(br));
95+ ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate));
9796 ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0));
9897 }
9998 else
@@ -105,6 +104,9 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
105104 }
106105 ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(0));
107106 }
107+ gint channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mix);
108+ bitrate = ghb_get_best_audio_bitrate(select_acodec, bitrate, channels);
109+ ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate));
108110 if (select_acodec == HB_ACODEC_FAAC)
109111 {
110112 gint br, last = 320, first = 0;
@@ -114,15 +116,6 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
114116 first = 192;
115117 last = 768;
116118 }
117-
118- widget = GHB_WIDGET(ud->builder, "AudioBitrate");
119- gval = ghb_widget_value(widget);
120- br = ghb_lookup_combo_int("AudioBitrate", gval);
121- ghb_value_free(gval);
122- if (br > last)
123- ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(last));
124- if (br < first)
125- ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(first));
126119 ghb_set_default_bitrate_opts (ud->builder, first, last);
127120 }
128121 else if (select_acodec == HB_ACODEC_AC3)
@@ -257,15 +250,16 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud)
257250 }
258251 else
259252 {
260- int channels, min_rate;
253+ int channels, min_rate, max_rate;
261254 mix = ghb_get_best_mix( titleindex, track, mix_acodec, mix);
262255 channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mix);
263256 bitrate = ainfo.bitrate / 1000;
264- min_rate = channels * 32;
257+ min_rate = channels * 64;
258+ max_rate = channels * 160;
265259 if (bitrate < min_rate)
266260 bitrate = min_rate;
267- if (bitrate > 640)
268- bitrate = 640;
261+ if (bitrate > max_rate)
262+ bitrate = max_rate;
269263 rate = 0;
270264 }
271265 }
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1096,35 +1096,6 @@ lookup_audio_rate_option(const GValue *rate)
10961096 }
10971097
10981098 gint
1099-ghb_find_closest_audio_bitrate(gint codec, gint rate)
1100-{
1101- gint ii;
1102- gint low = 32;
1103- gint high = 768;
1104- gint result;
1105-
1106- if (codec == HB_ACODEC_FAAC)
1107- high = 320;
1108- else if (codec == HB_ACODEC_AC3)
1109- high = 640;
1110-
1111- result = high;
1112- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
1113- {
1114- if (hb_audio_bitrates[ii].rate < low)
1115- continue;
1116- if (hb_audio_bitrates[ii].rate > high)
1117- break;
1118- if (rate <= hb_audio_bitrates[ii].rate)
1119- {
1120- result = hb_audio_bitrates[ii].rate;
1121- break;
1122- }
1123- }
1124- return result;
1125-}
1126-
1127-gint
11281099 ghb_find_closest_audio_rate(gint rate)
11291100 {
11301101 gint ii;
@@ -1640,6 +1611,35 @@ ghb_grey_combo_options(GtkBuilder *builder)
16401611 }
16411612
16421613 gint
1614+ghb_find_closest_audio_bitrate(gint codec, gint rate)
1615+{
1616+ gint ii;
1617+ gint low = 32;
1618+ gint high = 768;
1619+ gint result;
1620+
1621+ if (codec == HB_ACODEC_FAAC)
1622+ high = 320;
1623+ else if (codec == HB_ACODEC_AC3)
1624+ high = 640;
1625+
1626+ result = high;
1627+ for (ii = 0; ii < hb_audio_bitrates_count; ii++)
1628+ {
1629+ if (hb_audio_bitrates[ii].rate < low)
1630+ continue;
1631+ if (hb_audio_bitrates[ii].rate > high)
1632+ break;
1633+ if (rate <= hb_audio_bitrates[ii].rate)
1634+ {
1635+ result = hb_audio_bitrates[ii].rate;
1636+ break;
1637+ }
1638+ }
1639+ return result;
1640+}
1641+
1642+gint
16431643 ghb_get_best_audio_bitrate(gint acodec, gint br, gint channels)
16441644 {
16451645 if (acodec & HB_ACODEC_FAAC)
@@ -1653,6 +1653,57 @@ ghb_get_best_audio_bitrate(gint acodec, gint br, gint channels)
16531653 if (br > maxbr)
16541654 br = maxbr;
16551655 }
1656+ if (acodec & HB_ACODEC_AC3)
1657+ {
1658+ if (br > 640)
1659+ br = 640;
1660+ }
1661+ br = ghb_find_closest_audio_bitrate(acodec, br);
1662+ return br;
1663+}
1664+
1665+gint
1666+ghb_get_default_audio_bitrate(gint acodec, gint sr, gint br, gint channels)
1667+{
1668+ gint min_rate, max_rate;
1669+ gint sr_div = 1;
1670+
1671+ // Min bitrate is established such that we get good quality
1672+ // audio as a minimum. If the input bitrate is higher than
1673+ // the output codec allows, we will cap the bitrate.
1674+ if (sr <= 24000)
1675+ {
1676+ sr_div = 2;
1677+ }
1678+ if (acodec & HB_ACODEC_AC3)
1679+ {
1680+ switch (channels)
1681+ {
1682+ case 1:
1683+ min_rate = 96;
1684+ break;
1685+ case 2:
1686+ min_rate = 224;
1687+ break;
1688+ case 6:
1689+ default:
1690+ min_rate = 448;
1691+ break;
1692+ }
1693+ max_rate = channels * 160;
1694+ }
1695+ else
1696+ {
1697+ min_rate = channels * 64;
1698+ max_rate = channels * 160;
1699+ }
1700+ max_rate /= sr_div;
1701+ min_rate /= sr_div;
1702+ if ( br < min_rate )
1703+ br = min_rate;
1704+ if ( br > max_rate )
1705+ br = max_rate;
1706+ br = ghb_get_best_audio_bitrate(acodec, br, channels);
16561707 return br;
16571708 }
16581709
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -187,6 +187,8 @@ gint ghb_select_audio_codec(GValue *settings, gint acodec, gint track);
187187 const gchar* ghb_select_audio_codec_str(GValue *settings, gint acodec, gint track);
188188 gint ghb_find_closest_audio_bitrate(gint codec, gint rate);
189189 gint ghb_find_closest_audio_rate(gint rate);
190+gint ghb_get_best_audio_bitrate(gint acodec, gint br, gint channels);
191+gint ghb_get_default_audio_bitrate(gint acodec, gint sr, gint br, gint channels);
190192 GValue* ghb_lookup_acodec_value(gint val);
191193
192194 #endif // _HBBACKEND_H_
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -549,7 +549,7 @@ audio_list_refresh(signal_user_data_t *ud)
549549 else
550550 s_drc = g_strdup_printf("%.1f", drc);
551551
552- if (icodec == HB_ACODEC_MASK)
552+ if (icodec == HB_ACODEC_ANY)
553553 codec = ghb_select_audio_codec_str(ud->settings, icodec, itrack);
554554
555555 gtk_list_store_set(GTK_LIST_STORE(store), &iter,