OSDN Git Service

LinGui: make smarter bitrate choice when automatically selecting audio settings
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 24 Nov 2009 04:08:41 +0000 (04:08 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Tue, 24 Nov 2009 04:08:41 +0000 (04:08 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@2967 b64f7644-9d1e-0410-96f1-a4d463321fa5

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

index fbe5e90..935d961 100644 (file)
@@ -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));
index bb41aa4..1422641 100644 (file)
@@ -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;
 }
index 92b006f..d279b64 100644 (file)
@@ -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_