summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-11-24 04:08:41 +0000
committerjstebbins <[email protected]>2009-11-24 04:08:41 +0000
commit980a31be4e0dae47cb0f7fa600b4ef51dd4fbcf1 (patch)
tree3703705ad5fafe7bb10bdecce5d953f563c9bae4
parent156acb8d52d8e517a1b4745396ddcea687472ccb (diff)
LinGui: make smarter bitrate choice when automatically selecting audio settings
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2967 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--gtk/src/audiohandler.c11
-rw-r--r--gtk/src/hb-backend.c28
-rw-r--r--gtk/src/hb-backend.h1
3 files changed, 38 insertions, 2 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index fbe5e90c7..935d961c5 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -52,10 +52,17 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
{
gint br = ainfo.bitrate / 1000;
// Set the values for bitrate and samplerate to the input rates
- if (br >= 8)
+ if (br < 8)
+ br = 160;
+ if (ghb_audio_is_passthru (ainfo.codec))
+ {
ghb_set_passthru_bitrate_opts (ud->builder, br);
+ }
else
- br = 160;
+ {
+ acodec = ghb_select_audio_codec(ud, audioindex);
+ br = ghb_find_closest_audio_bitrate(acodec, br);
+ }
ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(br));
ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0));
ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0));
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index bb41aa4cc..142264165 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -926,6 +926,33 @@ lookup_audio_rate_option(const GValue *rate)
return result;
}
+gint
+ghb_find_closest_audio_bitrate(gint codec, gint rate)
+{
+ gint ii;
+ gint low = 32;
+ gint high = 768;
+ gint result;
+
+ if (codec == HB_ACODEC_FAAC)
+ high = 160;
+
+ result = high;
+ for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ {
+ if (hb_audio_bitrates[ii].rate < low)
+ continue;
+ if (hb_audio_bitrates[ii].rate > high)
+ break;
+ if (rate <= hb_audio_bitrates[ii].rate)
+ {
+ result = hb_audio_bitrates[ii].rate;
+ break;
+ }
+ }
+ return result;
+}
+
static gint
lookup_audio_bitrate_int(const GValue *rate)
{
@@ -3053,6 +3080,7 @@ ghb_get_audio_info(ghb_audio_info_t *ainfo, gint titleindex, gint audioindex)
if (audio == NULL) return FALSE; // Bad audioindex
ainfo->codec = audio->in.codec;
ainfo->bitrate = audio->in.bitrate;
+ ainfo->bitrate = 436000;
ainfo->samplerate = audio->in.samplerate;
return TRUE;
}
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 92b006f4f..d279b6468 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -174,5 +174,6 @@ const gchar* ghb_lookup_combo_string(const gchar *name, const GValue *gval);
gchar* ghb_get_tmp_dir();
gint ghb_select_audio_codec(signal_user_data_t *ud, gint track);
const gchar* ghb_select_audio_codec_str(signal_user_data_t *ud, gint track);
+gint ghb_find_closest_audio_bitrate(gint codec, gint rate);
#endif // _HBBACKEND_H_