diff options
author | jstebbins <[email protected]> | 2011-08-01 18:06:22 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-08-01 18:06:22 +0000 |
commit | 76d480815a9c6773e0fa5bcffaded04646279b8a (patch) | |
tree | 01fb72f321632a8bfb928bb3cfc40448f371eb0c /gtk | |
parent | 7a083edaa1a8d331ca8eb2878f051a4fc1966d43 (diff) |
add more audio passthru options
adds aac and mp3 passthru for mp4 and mkv containers
adds dts and dtshd for mp4 container (mkv already had it)
Note: The only player known (to me) to support dts(hd) in mp4 is ff/avplay
In LinGui there is a new option to limit which passthru codecs
will be used by the "Auto Passthru" audio codec options. The CLI
already has this ability with "--audio_copy-mask" which is use
in conjunction with the "copy" audio codec option.
Also corrects some A/V sync issues when video frames are dropped due to
a gap detected in the audio.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4149 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/audiohandler.c | 239 | ||||
-rw-r--r-- | gtk/src/audiohandler.h | 2 | ||||
-rw-r--r-- | gtk/src/callbacks.c | 7 | ||||
-rw-r--r-- | gtk/src/ghb.ui | 144 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 189 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 3 | ||||
-rw-r--r-- | gtk/src/internal_defaults.xml | 12 | ||||
-rw-r--r-- | gtk/src/makedeps.py | 19 | ||||
-rw-r--r-- | gtk/src/presets.c | 8 |
9 files changed, 417 insertions, 206 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 54cd1a496..ee84a798f 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -25,6 +25,130 @@ static GValue* get_selected_asettings(signal_user_data_t *ud); static gboolean block_updates = FALSE; +gint +ghb_select_audio_codec(int mux, hb_audio_config_t *aconfig, gint acodec, gint fallback) +{ + guint32 in_codec = aconfig ? aconfig->in.codec : HB_ACODEC_MASK; + if (mux == HB_MUX_MP4) + { + if (acodec & HB_ACODEC_PASS_FLAG) + { + if ((acodec & in_codec & HB_ACODEC_MASK & ~HB_ACODEC_VORBIS)) + { + return acodec & (in_codec | HB_ACODEC_PASS_FLAG); + } + else if (fallback & (HB_ACODEC_AC3 | HB_ACODEC_LAME | HB_ACODEC_FAAC | HB_ACODEC_FFAAC)) + { + return fallback; + } + else + { + return HB_ACODEC_FAAC; + } + } + else if (acodec & HB_ACODEC_AC3) + { + return HB_ACODEC_AC3; + } + else if (acodec & HB_ACODEC_LAME) + { + return HB_ACODEC_LAME; + } + else if (acodec & HB_ACODEC_FAAC) + { + return HB_ACODEC_FAAC; + } + else if (acodec & HB_ACODEC_FFAAC) + { + return HB_ACODEC_FFAAC; + } + else if (fallback & (HB_ACODEC_AC3 | HB_ACODEC_LAME | HB_ACODEC_FAAC | HB_ACODEC_FFAAC)) + { + return fallback; + } + else + { + return HB_ACODEC_FAAC; + } + } + else + { + if (acodec & HB_ACODEC_PASS_FLAG) + { + if ((acodec & in_codec & HB_ACODEC_PASS_MASK)) + { + return acodec & (in_codec | HB_ACODEC_PASS_FLAG); + } + else if (fallback) + { + return fallback; + } + else + { + return HB_ACODEC_FAAC; + } + } + else if (acodec & HB_ACODEC_AC3) + { + return HB_ACODEC_AC3; + } + else if (acodec & HB_ACODEC_LAME) + { + return HB_ACODEC_LAME; + } + else if (acodec & HB_ACODEC_VORBIS) + { + return HB_ACODEC_VORBIS; + } + else if (acodec & HB_ACODEC_FAAC) + { + return HB_ACODEC_FAAC; + } + else if (acodec & HB_ACODEC_FFAAC) + { + return HB_ACODEC_FFAAC; + } + else if (fallback ) + { + return fallback; + } + else + { + return HB_ACODEC_LAME; + } + } +} + +int ghb_allowed_passthru_mask(GValue *settings, int acodec) +{ + gint ret = acodec; + + if (acodec == HB_ACODEC_ANY) + { + if (!ghb_settings_get_boolean(settings, "AudioAllowMP3Pass")) + { + ret &= ~HB_ACODEC_MP3; + } + if (!ghb_settings_get_boolean(settings, "AudioAllowAACPass")) + { + ret &= ~HB_ACODEC_FFAAC; + } + if (!ghb_settings_get_boolean(settings, "AudioAllowAC3Pass")) + { + ret &= ~HB_ACODEC_AC3; + } + if (!ghb_settings_get_boolean(settings, "AudioAllowDTSPass")) + { + ret &= ~HB_ACODEC_DCA; + } + if (!ghb_settings_get_boolean(settings, "AudioAllowDTSHDPass")) + { + ret &= ~HB_ACODEC_DCA_HD; + } + } + return ret; +} + void ghb_adjust_audio_rate_combos(signal_user_data_t *ud) { @@ -32,7 +156,7 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) hb_audio_config_t *aconfig; GtkWidget *widget; GValue *gval; - int mux; + gint mux; gint bitrate; gint sr = 48000; @@ -62,25 +186,15 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) gval = ghb_widget_value(widget); sr = ghb_lookup_combo_int("AudioSamplerate", gval); - select_acodec = acodec; - if (mux == HB_MUX_MP4) - { - select_acodec &= ~HB_ACODEC_DCA; - } - if ((select_acodec & HB_ACODEC_MASK) == 0) - { - // Unsuported codec in this container. - select_acodec |= HB_ACODEC_AC3; - acodec = select_acodec; - } aconfig = ghb_get_scan_audio_info(titleindex, track); if (sr == 0) { sr = aconfig ? aconfig->in.samplerate : 48000; } - if (aconfig) - select_acodec = ghb_select_audio_codec(mux, aconfig, select_acodec); + gint fallback = ghb_settings_combo_int(ud->settings, "AudioEncoderFallback"); + select_acodec = ghb_allowed_passthru_mask(ud->settings, acodec); + select_acodec = ghb_select_audio_codec(mux, aconfig, select_acodec, fallback); gboolean codec_defined_bitrate = FALSE; if (ghb_audio_is_passthru (select_acodec)) { @@ -89,44 +203,33 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) bitrate = aconfig->in.bitrate / 1000; // Set the values for bitrate and samplerate to the input rates - if (aconfig->in.codec & select_acodec & HB_ACODEC_PASS_MASK) - { - ghb_set_passthru_bitrate_opts (ud->builder, bitrate); - ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0)); - select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG; - codec_defined_bitrate = TRUE; - } - else - { - gint mux = ghb_settings_get_int(ud->settings, "FileFormat"); - select_acodec = ghb_select_audio_codec(mux, aconfig, acodec); - if (acodec != HB_ACODEC_ANY) - { - ghb_ui_update(ud, "AudioEncoder", ghb_int64_value(select_acodec)); - } - - mix = ghb_get_best_mix( aconfig, select_acodec, mix); - bitrate = hb_get_default_audio_bitrate(select_acodec, sr, mix); - ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix)); - } + ghb_set_passthru_bitrate_opts (ud->builder, bitrate); + mix = 0; + ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix)); + select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG; + codec_defined_bitrate = TRUE; ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0)); } else { ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0)); - ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0)); + mix = 0; + ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix)); bitrate = 448; - mix = ghb_get_best_mix( aconfig, select_acodec, 0); } ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(0)); } else { + if (mix == 0) + mix = ghb_get_best_mix( aconfig, select_acodec, 0); bitrate = hb_get_best_audio_bitrate(select_acodec, bitrate, sr, mix); + ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix)); } if (!codec_defined_bitrate) { int low, high; + mix = ghb_get_best_mix( aconfig, select_acodec, mix); hb_get_audio_bitrate_limits(select_acodec, sr, mix, &low, &high); ghb_set_default_bitrate_opts (ud->builder, low, high); } @@ -182,14 +285,7 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) g_debug("set_pref_audio"); mux = ghb_settings_combo_int(ud->settings, "FileFormat"); - if (mux == HB_MUX_MP4) - { - fallback_acodec = HB_ACODEC_FAAC; - } - else - { - fallback_acodec = HB_ACODEC_LAME; - } + fallback_acodec = ghb_settings_combo_int(ud->settings, "AudioEncoderFallback"); track_indices = g_hash_table_new_full(g_int_hash, g_int_equal, free_audio_hash_key_value, free_audio_hash_key_value); // Clear the audio list @@ -208,24 +304,12 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) count = ghb_array_len(pref_audio); for (ii = 0; ii < count; ii++) { - int select_acodec; + gint select_acodec; audio = ghb_array_get_nth(pref_audio, ii); - select_acodec = acodec = ghb_settings_combo_int(audio, "AudioEncoder"); - if (mux == HB_MUX_MP4) - { - select_acodec &= ~HB_ACODEC_DCA; - } - if ((select_acodec & HB_ACODEC_MASK) == 0) - { - // Unsuported codec in this container. - select_acodec |= HB_ACODEC_AC3; - acodec = select_acodec; - } - if ( ghb_audio_can_passthru( select_acodec ) ) - { - fallback_acodec = HB_ACODEC_AC3; - } + acodec = ghb_settings_combo_int(audio, "AudioEncoder"); + select_acodec = ghb_allowed_passthru_mask(ud->settings, acodec); + select_acodec = ghb_select_audio_codec(mux, NULL, select_acodec, fallback_acodec); bitrate = ghb_settings_combo_int(audio, "AudioBitrate"); rate = ghb_settings_combo_double(audio, "AudioSamplerate"); mix = ghb_settings_combo_int(audio, "AudioMixdown"); @@ -260,17 +344,13 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) } else { - int channels, min_rate, max_rate; + int channels; select_acodec = fallback_acodec; mix = ghb_get_best_mix(aconfig, select_acodec, mix); channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mix); bitrate = aconfig->in.bitrate / 1000; - min_rate = channels * 64; - max_rate = channels * 160; - if (bitrate < min_rate) - bitrate = min_rate; - if (bitrate > max_rate) - bitrate = max_rate; + bitrate = hb_get_best_audio_bitrate(select_acodec, bitrate, + aconfig->in.samplerate, mix); rate = 0; } } @@ -417,7 +497,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) if (block_updates) { prev_acodec = acodec_code; - ghb_grey_combo_options (ud->builder); + ghb_grey_combo_options (ud); return; } @@ -469,7 +549,7 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix_code)); } ghb_adjust_audio_rate_combos(ud); - ghb_grey_combo_options (ud->builder); + ghb_grey_combo_options (ud); ghb_check_dependency(ud, widget, NULL); prev_acodec = acodec_code; if (asettings != NULL) @@ -488,11 +568,15 @@ audio_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud) GValue *asettings; g_debug("audio_track_changed_cb ()"); - if (block_updates) return; + if (block_updates) + { + ghb_grey_combo_options (ud); + return; + } ghb_adjust_audio_rate_combos(ud); ghb_check_dependency(ud, widget, NULL); - ghb_grey_combo_options(ud->builder); + ghb_grey_combo_options(ud); asettings = get_selected_asettings(ud); if (asettings != NULL) { @@ -544,6 +628,19 @@ audio_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_live_reset(ud); } +G_MODULE_EXPORT void +global_audio_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud) +{ + g_debug("global_audio_widget_changed_cb ()"); + if (block_updates) return; + + ghb_check_dependency(ud, widget, NULL); + ghb_widget_to_setting(ud->settings, widget); + ghb_adjust_audio_rate_combos(ud); + ghb_audio_list_refresh_selected(ud); + ghb_live_reset(ud); +} + G_MODULE_EXPORT gchar* format_drc_cb(GtkScale *scale, gdouble val, signal_user_data_t *ud) { diff --git a/gtk/src/audiohandler.h b/gtk/src/audiohandler.h index 87b9612f7..74df87a3d 100644 --- a/gtk/src/audiohandler.h +++ b/gtk/src/audiohandler.h @@ -34,5 +34,7 @@ void ghb_set_audio(signal_user_data_t *ud, GValue *settings); gchar* ghb_get_user_audio_lang( signal_user_data_t *ud, gint titleindex, gint track); void ghb_audio_list_refresh_selected(signal_user_data_t *ud); +int ghb_allowed_passthru_mask(GValue *settings, int acodec); +gint ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec, int fallback_acodec); #endif // _AUDIOHANDLER_H_ diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index 0fd92a9e6..03d576603 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -1250,7 +1250,8 @@ window_delete_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *u static void update_acodec_combo(signal_user_data_t *ud) { - ghb_grey_combo_options (ud->builder); + ghb_adjust_audio_rate_combos(ud); + ghb_grey_combo_options (ud); } G_MODULE_EXPORT void @@ -1507,7 +1508,7 @@ title_changed_cb(GtkWidget *widget, signal_user_data_t *ud) update_chapter_list (ud); ghb_adjust_audio_rate_combos(ud); ghb_set_pref_audio(titleindex, ud); - ghb_grey_combo_options (ud->builder); + ghb_grey_combo_options (ud); ghb_set_pref_subtitle(titleindex, ud); // Unfortunately, there is no way to query how many frames were @@ -1662,7 +1663,7 @@ http_opt_changed_cb(GtkWidget *widget, signal_user_data_t *ud) ghb_clear_presets_selection(ud); ghb_live_reset(ud); // AC3 is not allowed when Web optimized - ghb_grey_combo_options (ud->builder); + ghb_grey_combo_options (ud); } G_MODULE_EXPORT void diff --git a/gtk/src/ghb.ui b/gtk/src/ghb.ui index 999f3c621..7d037434b 100644 --- a/gtk/src/ghb.ui +++ b/gtk/src/ghb.ui @@ -1716,7 +1716,7 @@ <object class="GtkLabel" id="label46"> <property name="visible">True</property> <property name="xalign">0</property> - <property name="label" translatable="yes">Video Codec:</property> + <property name="label" translatable="yes">Video Encoder:</property> <property name="width_chars">11</property> </object> <packing> @@ -2113,9 +2113,10 @@ FFMpeg's and Theora's scale is more linear. These encoders do not have a lossle <object class="GtkTable" id="table14"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="n_rows">2</property> + <property name="n_rows">4</property> <property name="n_columns">5</property> <property name="row_spacing">5</property> + <property name="column_spacing">5</property> <child> <object class="GtkLabel" id="audio_name_label"> <property name="visible">True</property> @@ -2228,7 +2229,7 @@ FFMpeg's and Theora's scale is more linear. These encoders do not have a lossle <child> <object class="GtkHScale" id="AudioTrackGain"> <property name="visible">True</property> - <property name="width-request">200</property> + <property name="width-request">150</property> <property name="orientation">horizontal</property> <property name="adjustment">adjustment35</property> <property name="value_pos">right</property> @@ -2282,6 +2283,141 @@ FFMpeg's and Theora's scale is more linear. These encoders do not have a lossle <property name="x_options">GTK_FILL</property> </packing> </child> + <child> + <object class="GtkHBox" id="hbox40"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="spacing">5</property> + <child> + <object class="GtkLabel" id="labela3"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Auto Passthru:</property> + </object> + <packing> + <property name="position">0</property> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="AudioAllowMP3Pass"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Enable this if your playback device supports AAC. This permits AAC passthru to be selected when automatic passthru selection is enabled.</property> + <property name="label" translatable="yes">MP3</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal handler="global_audio_widget_changed_cb" name="toggled"/> + </object> + <packing> + <property name="position">1</property> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="AudioAllowAACPass"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Enable this if your playback device supports AAC. This permits AAC passthru to be selected when automatic passthru selection is enabled.</property> + <property name="label" translatable="yes">AAC</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal handler="global_audio_widget_changed_cb" name="toggled"/> + </object> + <packing> + <property name="position">2</property> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="AudioAllowAC3Pass"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Enable this if your playback device supports AC-3. This permits AC-3 passthru to be selected when automatic passthru selection is enabled.</property> + <property name="label" translatable="yes">AC-3</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal handler="global_audio_widget_changed_cb" name="toggled"/> + </object> + <packing> + <property name="position">3</property> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="AudioAllowDTSPass"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Enable this if your playback device supports DTS. This permits DTS passthru to be selected when automatic passthru selection is enabled.</property> + <property name="label" translatable="yes">DTS</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal handler="global_audio_widget_changed_cb" name="toggled"/> + </object> + <packing> + <property name="position">4</property> + <property name="expand">False</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="AudioAllowDTSHDPass"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Enable this if your playback device supports DTS-HD. This permits DTS-HD passthru to be selected when automatic passthru selection is enabled.</property> + <property name="label" translatable="yes">DTS-HD</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <signal handler="global_audio_widget_changed_cb" name="toggled"/> + </object> + <packing> + <property name="position">5</property> + <property name="expand">False</property> + </packing> + </child> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + <property name="left_attach">0</property> + <property name="right_attach">4</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="labela4"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Passthru Fallback:</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="left_attach">0</property> + <property name="right_attach">1</property> + <property name="x_options">GTK_FILL</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="AudioEncoderFallback"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="tooltip-text" translatable="yes">Set the audio codec to encode with when a suitable track can not be found for audio passthru.</property> + <signal handler="global_audio_widget_changed_cb" name="changed"/> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="x_options">GTK_FILL</property> + </packing> + </child> </object> </child> </object> @@ -2323,7 +2459,7 @@ FFMpeg's and Theora's scale is more linear. These encoders do not have a lossle <object class="GtkLabel" id="label68"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="label" translatable="yes">Codec</property> + <property name="label" translatable="yes">Encoder</property> </object> <packing> <property name="top_attach">0</property> diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 8a90d4ece..a3b9e5106 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -57,7 +57,7 @@ static gint index_str_size = 0; static void index_str_init(gint max_index) { - int ii; + gint ii; if (max_index+1 > index_str_size) { @@ -256,10 +256,12 @@ static options_map_t d_acodec_opts[] = {"MP3 (lame)", "lame", HB_ACODEC_LAME, "lame"}, {"Vorbis", "vorbis", HB_ACODEC_VORBIS, "vorbis"}, {"AC3 (ffmpeg)", "ac3", HB_ACODEC_AC3, "ac3"}, - {"AC3 (pass-thru)", "ac3pass", HB_ACODEC_AC3_PASS, "ac3pass"}, - {"DTS (pass-thru)", "dtspass", HB_ACODEC_DCA_PASS, "dtspass"}, - {"DTS-HD (pass-thru)", "dtshdpass", HB_ACODEC_DCA_HD_PASS, "dtshdpass"}, - {"Choose For Me", "auto", HB_ACODEC_ANY, "auto"}, + {"MP3 Passthru", "mp3pass", HB_ACODEC_MP3_PASS, "mp3pass"}, + {"AAC Passthru", "aacpass", HB_ACODEC_AAC_PASS, "aacpass"}, + {"AC3 Passthru", "ac3pass", HB_ACODEC_AC3_PASS, "ac3pass"}, + {"DTS Passthru", "dtspass", HB_ACODEC_DCA_PASS, "dtspass"}, + {"DTS-HD Passthru", "dtshdpass", HB_ACODEC_DCA_HD_PASS, "dtshdpass"}, + {"Auto Passthru", "auto", HB_ACODEC_ANY, "auto"}, }; combo_opts_t acodec_opts = { @@ -267,6 +269,20 @@ combo_opts_t acodec_opts = d_acodec_opts }; +static options_map_t d_acodec_fallback_opts[] = +{ + {"AAC (faac)", "faac", HB_ACODEC_FAAC, "faac"}, + {"AAC (ffmpeg)", "ffaac", HB_ACODEC_FFAAC, "ffaac"}, + {"MP3 (lame)", "lame", HB_ACODEC_LAME, "lame"}, + {"Vorbis", "vorbis", HB_ACODEC_VORBIS, "vorbis"}, + {"AC3 (ffmpeg)", "ac3", HB_ACODEC_AC3, "ac3"}, +}; +combo_opts_t acodec_fallback_opts = +{ + sizeof(d_acodec_fallback_opts)/sizeof(options_map_t), + d_acodec_fallback_opts +}; + static options_map_t d_direct_opts[] = { {"None", "none", 0, "none"}, @@ -418,6 +434,7 @@ combo_name_map_t combo_name_map[] = {"VideoEncoder", &vcodec_opts}, {"AudioEncoder", &acodec_opts}, {"AudioEncoderActual", &acodec_opts}, + {"AudioEncoderFallback", &acodec_fallback_opts}, {"x264_direct", &direct_opts}, {"x264_b_adapt", &badapt_opts}, {"x264_bpyramid", &bpyramid_opts}, @@ -1535,71 +1552,75 @@ grey_combo_box_item(GtkBuilder *builder, const gchar *name, gint value, gboolean } void -ghb_grey_combo_options(GtkBuilder *builder) +ghb_grey_combo_options(signal_user_data_t *ud) { GtkWidget *widget; - gint mux, track, titleindex, acodec; - hb_audio_config_t *aconfig = NULL; + gint mux, track, titleindex, acodec, fallback; + hb_audio_config_t *aconfig = NULL; GValue *gval; - widget = GHB_WIDGET (builder, "title"); + widget = GHB_WIDGET (ud->builder, "title"); gval = ghb_widget_value(widget); titleindex = ghb_lookup_combo_int("title", gval); ghb_value_free(gval); - widget = GHB_WIDGET (builder, "AudioTrack"); + widget = GHB_WIDGET (ud->builder, "AudioTrack"); gval = ghb_widget_value(widget); track = ghb_lookup_combo_int("AudioTrack", gval); ghb_value_free(gval); aconfig = get_hb_audio(h_scan, titleindex, track); - widget = GHB_WIDGET (builder, "FileFormat"); + widget = GHB_WIDGET (ud->builder, "FileFormat"); gval = ghb_widget_value(widget); mux = ghb_lookup_combo_int("FileFormat", gval); ghb_value_free(gval); - grey_combo_box_item(builder, "x264_analyse", 4, TRUE); - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_FFAAC, FALSE); - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_FAAC, FALSE); - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_LAME, FALSE); - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_VORBIS, FALSE); - - gboolean allow_dca = TRUE; - allow_dca = (mux != HB_MUX_MP4); + grey_combo_box_item(ud->builder, "x264_analyse", 4, TRUE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_FFAAC, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_FAAC, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_LAME, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_VORBIS, FALSE); - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_AC3_PASS, FALSE); - if (allow_dca) - { - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_PASS, FALSE); - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, FALSE); - } - else - { - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE); - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, TRUE); - } + grey_combo_box_item(ud->builder, "AudioEncoderFallback", HB_ACODEC_FFAAC, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoderFallback", HB_ACODEC_FAAC, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoderFallback", HB_ACODEC_LAME, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoderFallback", HB_ACODEC_VORBIS, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_MP3_PASS, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_AAC_PASS, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_AC3_PASS, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_DCA_PASS, FALSE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, FALSE); + if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_MP3) + { + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_MP3_PASS, TRUE); + } + if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_FFAAC) + { + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_AAC_PASS, TRUE); + } if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_AC3) { - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_AC3_PASS, TRUE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_AC3_PASS, TRUE); } if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_DCA) { - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE); } if (aconfig && (aconfig->in.codec & HB_ACODEC_MASK) != HB_ACODEC_DCA_HD) { - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, TRUE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_DCA_HD_PASS, TRUE); } - grey_combo_box_item(builder, "VideoEncoder", HB_VCODEC_THEORA, FALSE); + grey_combo_box_item(ud->builder, "VideoEncoder", HB_VCODEC_THEORA, FALSE); - widget = GHB_WIDGET (builder, "AudioEncoder"); + widget = GHB_WIDGET (ud->builder, "AudioEncoder"); gval = ghb_widget_value(widget); acodec = ghb_lookup_combo_int("AudioEncoder", gval); ghb_value_free(gval); - grey_combo_box_item(builder, "AudioMixdown", 0, TRUE); + grey_combo_box_item(ud->builder, "AudioMixdown", 0, TRUE); if (mux == HB_MUX_MP4) { - grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_VORBIS, TRUE); - grey_combo_box_item(builder, "VideoEncoder", HB_VCODEC_THEORA, TRUE); + grey_combo_box_item(ud->builder, "AudioEncoder", HB_ACODEC_VORBIS, TRUE); + grey_combo_box_item(ud->builder, "AudioEncoderFallback", HB_ACODEC_VORBIS, TRUE); + grey_combo_box_item(ud->builder, "VideoEncoder", HB_VCODEC_THEORA, TRUE); } gboolean allow_mono = TRUE; @@ -1610,7 +1631,9 @@ ghb_grey_combo_options(GtkBuilder *builder) allow_6ch = acodec & ~HB_ACODEC_LAME; if (aconfig) { - acodec = ghb_select_audio_codec(mux, aconfig, acodec); + acodec = ghb_allowed_passthru_mask(ud->settings, acodec); + fallback = ghb_settings_combo_int(ud->settings, "AudioEncoderFallback"); + acodec = ghb_select_audio_codec(mux, aconfig, acodec, fallback); gint best = hb_get_best_mixdown(acodec, aconfig->in.channel_layout, 0); allow_stereo = best >= HB_AMIXDOWN_STEREO; @@ -1619,17 +1642,17 @@ ghb_grey_combo_options(GtkBuilder *builder) allow_6ch = best >= HB_AMIXDOWN_6CH; allow_mono = best >= HB_AMIXDOWN_MONO; } - grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_MONO, !allow_mono); - grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_STEREO, !allow_stereo); - grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_DOLBY, !allow_dolby); - grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_DOLBYPLII, !allow_dpl2); - grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_6CH, !allow_6ch); + grey_combo_box_item(ud->builder, "AudioMixdown", HB_AMIXDOWN_MONO, !allow_mono); + grey_combo_box_item(ud->builder, "AudioMixdown", HB_AMIXDOWN_STEREO, !allow_stereo); + grey_combo_box_item(ud->builder, "AudioMixdown", HB_AMIXDOWN_DOLBY, !allow_dolby); + grey_combo_box_item(ud->builder, "AudioMixdown", HB_AMIXDOWN_DOLBYPLII, !allow_dpl2); + grey_combo_box_item(ud->builder, "AudioMixdown", HB_AMIXDOWN_6CH, !allow_6ch); } gint ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix) { - int layout; + gint layout; layout = aconfig ? aconfig->in.channel_layout : HB_INPUT_CH_LAYOUT_3F2R | HB_INPUT_CH_LAYOUT_HAS_LFE; return hb_get_best_mixdown( acodec, layout, mix ); @@ -2780,6 +2803,7 @@ ghb_update_ui_combo_box( generic_opts_set(ud->builder, "PictureDenoise", &denoise_opts); generic_opts_set(ud->builder, "VideoEncoder", &vcodec_opts); small_opts_set(ud->builder, "AudioEncoder", &acodec_opts); + small_opts_set(ud->builder, "AudioEncoderFallback", &acodec_fallback_opts); small_opts_set(ud->builder, "x264_direct", &direct_opts); small_opts_set(ud->builder, "x264_b_adapt", &badapt_opts); small_opts_set(ud->builder, "x264_bpyramid", &bpyramid_opts); @@ -4135,70 +4159,6 @@ ghb_validate_subtitles(signal_user_data_t *ud) return TRUE; } -gint -ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec) -{ - guint32 in_codec = aconfig ? aconfig->in.codec : HB_ACODEC_MASK; - if (mux == HB_MUX_MP4) - { - if ((acodec & in_codec & HB_ACODEC_AC3)) - { - return acodec & (in_codec | HB_ACODEC_PASS_FLAG); - } - else if (acodec & HB_ACODEC_AC3) - { - return HB_ACODEC_AC3; - } - else if (acodec & HB_ACODEC_LAME) - { - return HB_ACODEC_LAME; - } - else if (acodec & HB_ACODEC_FAAC) - { - return HB_ACODEC_FAAC; - } - else if (acodec & HB_ACODEC_FFAAC) - { - return HB_ACODEC_FFAAC; - } - else - { - return HB_ACODEC_FAAC; - } - } - else - { - if ((acodec & in_codec & HB_ACODEC_PASS_MASK)) - { - return acodec & (in_codec | HB_ACODEC_PASS_FLAG); - } - else if (acodec & HB_ACODEC_AC3) - { - return HB_ACODEC_AC3; - } - else if (acodec & HB_ACODEC_VORBIS) - { - return HB_ACODEC_VORBIS; - } - else if (acodec & HB_ACODEC_LAME) - { - return HB_ACODEC_LAME; - } - else if (acodec & HB_ACODEC_FAAC) - { - return HB_ACODEC_FAAC; - } - else if (acodec & HB_ACODEC_FFAAC) - { - return HB_ACODEC_FFAAC; - } - else - { - return HB_ACODEC_LAME; - } - } -} - gboolean ghb_validate_audio(signal_user_data_t *ud) { @@ -4283,11 +4243,6 @@ ghb_validate_audio(signal_user_data_t *ud) a_unsup = "Vorbis"; codec = HB_ACODEC_FAAC; } - if (codec == HB_ACODEC_DCA) - { - a_unsup = "DTS"; - codec = HB_ACODEC_AC3; - } } if (a_unsup) { @@ -4711,7 +4666,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) GValue *asettings; hb_audio_config_t audio; hb_audio_config_t *aconfig; - gint acodec; + gint acodec, fallback; hb_audio_config_init(&audio); asettings = ghb_array_get_nth(audio_list, ii); @@ -4735,7 +4690,9 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) acodec = ghb_settings_combo_int(asettings, "AudioEncoder"); - audio.out.codec = ghb_select_audio_codec(job->mux, aconfig, acodec); + acodec = ghb_allowed_passthru_mask(js, acodec); + fallback = ghb_settings_combo_int(js, "AudioEncoderFallback"); + audio.out.codec = ghb_select_audio_codec(job->mux, aconfig, acodec, fallback); audio.out.gain = ghb_settings_get_double(asettings, "AudioTrackGain"); diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 6733ad306..f59d821a6 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -137,7 +137,7 @@ hb_audio_config_t* ghb_get_scan_audio_info(gint titleindex, gint audioindex); void ghb_set_passthru_bitrate_opts(GtkBuilder *builder, gint bitrate); void ghb_set_default_bitrate_opts( GtkBuilder *builder, gint first_rate, gint last_rate); -void ghb_grey_combo_options(GtkBuilder *builder); +void ghb_grey_combo_options(signal_user_data_t *ud); void ghb_update_ui_combo_box( signal_user_data_t *ud, const gchar *name, gint user_data, gboolean all); gchar* ghb_get_source_audio_lang(gint titleindex, gint track); @@ -175,7 +175,6 @@ gdouble ghb_lookup_combo_double(const gchar *name, const GValue *gval); const gchar* ghb_lookup_combo_option(const gchar *name, const GValue *gval); const gchar* ghb_lookup_combo_string(const gchar *name, const GValue *gval); gchar* ghb_get_tmp_dir(); -gint ghb_select_audio_codec(gint mux, hb_audio_config_t *aconfig, gint acodec); gint ghb_find_closest_audio_rate(gint rate); GValue* ghb_lookup_acodec_value(gint val); diff --git a/gtk/src/internal_defaults.xml b/gtk/src/internal_defaults.xml index e4a4a72b6..b4d06694d 100644 --- a/gtk/src/internal_defaults.xml +++ b/gtk/src/internal_defaults.xml @@ -295,6 +295,18 @@ <true /> <key>Mp4LargeFile</key> <false /> + <key>AudioAllowMP3Pass</key> + <true /> + <key>AudioAllowAACPass</key> + <true /> + <key>AudioAllowAC3Pass</key> + <true /> + <key>AudioAllowDTSPass</key> + <true /> + <key>AudioAllowDTSHDPass</key> + <true /> + <key>AudioEncoderFallback</key> + <string>ac3</string> <key>AudioList</key> <array> <dict> diff --git a/gtk/src/makedeps.py b/gtk/src/makedeps.py index a16b28ca5..65d398eca 100644 --- a/gtk/src/makedeps.py +++ b/gtk/src/makedeps.py @@ -49,13 +49,18 @@ dep_map = ( DepEntry("VideoEncoder", "x264_tab", "x264", False, True), DepEntry("VideoEncoder", "lavc_mpeg4_tab", "ffmpeg|ffmpeg2", False, True), DepEntry("VideoEncoder", "Mp4iPodCompatible", "x264", False, False), - DepEntry("AudioEncoderActual", "AudioBitrate", "ac3pass|dtspass", True, False), - DepEntry("AudioEncoderActual", "AudioSamplerate", "ac3pass|dtspass", True, False), - DepEntry("AudioEncoderActual", "AudioMixdown", "ac3pass|dtspass", True, False), - DepEntry("AudioEncoderActual", "AudioTrackDRCSlider", "ac3pass|dtspass", True, False), - DepEntry("AudioEncoderActual", "drc_label", "ac3pass|dtspass", True, False), - DepEntry("AudioEncoderActual", "AudioTrackGain", "ac3pass|dtspass", True, False), - DepEntry("AudioEncoderActual", "gain_label", "ac3pass|dtspass", True, False), + DepEntry("AudioEncoderActual", "AudioBitrate", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False), + DepEntry("AudioEncoderActual", "AudioSamplerate", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False), + DepEntry("AudioEncoderActual", "AudioMixdown", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False), + DepEntry("AudioEncoderActual", "AudioTrackDRCSlider", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False), + DepEntry("AudioEncoderActual", "drc_label", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False), + DepEntry("AudioEncoderActual", "AudioTrackGain", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False), + DepEntry("AudioEncoderActual", "gain_label", "mp3pass|aacpass|ac3pass|dtspass|dtshdpass", True, False), + DepEntry("AudioEncoder", "AudioAllowMP3Pass", "auto", False, False), + DepEntry("AudioEncoder", "AudioAllowAACPass", "auto", False, False), + DepEntry("AudioEncoder", "AudioAllowAC3Pass", "auto", False, False), + DepEntry("AudioEncoder", "AudioAllowDTSPass", "auto", False, False), + DepEntry("AudioEncoder", "AudioAllowDTSHDPass", "auto", False, False), DepEntry("x264_bframes", "x264_bpyramid", "<2", True, False), DepEntry("x264_bframes", "x264_direct", "0", True, False), DepEntry("x264_bframes", "x264_b_adapt", "0", True, False), diff --git a/gtk/src/presets.c b/gtk/src/presets.c index 064d27323..0a4d46745 100644 --- a/gtk/src/presets.c +++ b/gtk/src/presets.c @@ -2004,6 +2004,8 @@ static value_map_t acodec_xlat[] = {"HE-AAC (CoreAudio)", "faac"}, {"AC3", "ac3"}, // Backwards compatibility with mac ui {"AC3 (ffmpeg)", "ac3"}, + {"MP3 Passthru", "mp3pass"}, + {"AAC Passthru", "aacpass"}, {"AC3 Passthru", "ac3pass"}, {"DTS Passthru", "dtspass"}, {"DTS-HD Passthru", "dtshdpass"}, @@ -2055,10 +2057,10 @@ value_map_t mix_xlat[] = {"Dolby Surround", "dpl1"}, {"Dolby Pro Logic II", "dpl2"}, {"6-channel discrete", "6ch"}, - {"AC3 Passthru", "none"}, - {"DTS Passthru", "none"}, - {"DTS-HD Passthru", "none"}, {"None", "none"}, + {"AC3 Passthru", "none"}, // Backwards compatibility with mac ui + {"DTS Passthru", "none"}, // Backwards compatibility with mac ui + {"DTS-HD Passthru", "none"}, // Backwards compatibility with mac ui {NULL, NULL} }; |