diff options
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/audiohandler.c | 100 | ||||
-rw-r--r-- | gtk/src/hb-backend.c | 121 | ||||
-rw-r--r-- | gtk/src/hb-backend.h | 16 | ||||
-rw-r--r-- | gtk/src/queuehandler.c | 10 |
4 files changed, 87 insertions, 160 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c index 5288e3178..7aede1ce9 100644 --- a/gtk/src/audiohandler.c +++ b/gtk/src/audiohandler.c @@ -26,7 +26,7 @@ void ghb_adjust_audio_rate_combos(signal_user_data_t *ud) { gint titleindex, track, acodec, select_acodec, mix; - ghb_audio_info_t ainfo; + hb_audio_config_t *aconfig; GtkWidget *widget; GValue *gval; int mux; @@ -71,44 +71,37 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) acodec = select_acodec; } - gboolean info_valid = FALSE; - if (ghb_get_audio_info (&ainfo, titleindex, track)) - { - info_valid = TRUE; - } + aconfig = ghb_get_scan_audio_info(titleindex, track); if (sr == 0) { - sr = info_valid ? ainfo.samplerate : 48000; + sr = aconfig ? aconfig->in.samplerate : 48000; } if (ghb_audio_is_passthru (select_acodec)) { ghb_set_default_bitrate_opts (ud->builder, 0, -1); - if (info_valid) + if (aconfig) { - bitrate = ainfo.bitrate / 1000; + bitrate = aconfig->in.bitrate / 1000; // Set the values for bitrate and samplerate to the input rates - if (ainfo.codec & select_acodec & HB_ACODEC_PASS_MASK) + 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 &= ainfo.codec | HB_ACODEC_PASS_FLAG; + select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG; } else { - select_acodec = ghb_select_audio_codec(ud->settings, acodec, track); + select_acodec = ghb_select_audio_codec(ud->settings, aconfig, acodec); if (acodec != HB_ACODEC_ANY) { ghb_ui_update(ud, "AudioEncoder", ghb_int64_value(select_acodec)); } - int channels; - mix = ghb_get_best_mix( titleindex, track, select_acodec, mix); - channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mix); + 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_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate)); ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0)); } else @@ -116,11 +109,14 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud) ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0)); ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0)); bitrate = 448; - mix = ghb_get_best_mix( titleindex, track, select_acodec, 0); + mix = ghb_get_best_mix( aconfig, select_acodec, 0); } ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(0)); } - bitrate = hb_get_best_audio_bitrate(select_acodec, bitrate, sr, mix); + else + { + bitrate = hb_get_best_audio_bitrate(select_acodec, bitrate, sr, mix); + } ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate)); int low, high; @@ -158,14 +154,13 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) { gint fallback_acodec, track; gchar *source_lang = NULL; - GtkWidget *button; - ghb_audio_info_t ainfo; + hb_audio_config_t *aconfig; GHashTable *track_indices; gint mux; const GValue *pref_audio; const GValue *audio, *drc; - gint mix_acodec, acodec, bitrate, mix; + gint acodec, bitrate, mix; gdouble rate; gint count, ii, list_count; @@ -184,7 +179,6 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) // Clear the audio list ghb_clear_audio_list(ud); // Find "best" audio based on audio preferences - button = GHB_WIDGET (ud->builder, "audio_add"); if (!ghb_settings_get_boolean(ud->settings, "AudioDUB")) { source_lang = ghb_get_source_audio_lang(titleindex, 0); @@ -216,7 +210,6 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) { fallback_acodec = HB_ACODEC_AC3; } - mix_acodec = acodec; bitrate = ghb_settings_combo_int(audio, "AudioBitrate"); rate = ghb_settings_combo_double(audio, "AudioSamplerate"); mix = ghb_settings_combo_int(audio, "AudioMixdown"); @@ -230,15 +223,14 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) // 1. pref codec is passthru // 2. source codec is not passthru // 3. next pref is enabled - if (ghb_get_audio_info (&ainfo, titleindex, track) && - ghb_audio_is_passthru (acodec)) + aconfig = ghb_get_scan_audio_info(titleindex, track); + if (aconfig && ghb_audio_is_passthru (acodec)) { // HB_ACODEC_* are bit fields. Treat acodec as mask - if (!(ainfo.codec & select_acodec & HB_ACODEC_PASS_MASK)) + if (!(aconfig->in.codec & select_acodec & HB_ACODEC_PASS_MASK)) { if (acodec != HB_ACODEC_ANY) acodec = fallback_acodec; - mix_acodec = fallback_acodec; // If we can't substitute the passthru with a suitable // encoder and // If there's more audio to process, or we've already @@ -252,9 +244,10 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) else { int channels, min_rate, max_rate; - mix = ghb_get_best_mix( titleindex, track, mix_acodec, mix); + select_acodec = fallback_acodec; + mix = ghb_get_best_mix(aconfig, select_acodec, mix); channels = HB_AMIXDOWN_GET_DISCRETE_CHANNEL_COUNT(mix); - bitrate = ainfo.bitrate / 1000; + bitrate = aconfig->in.bitrate / 1000; min_rate = channels * 64; max_rate = channels * 160; if (bitrate < min_rate) @@ -264,6 +257,10 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) rate = 0; } } + else + { + select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG; + } } if (titleindex >= 0 && track < 0) acodec = 0; @@ -274,13 +271,13 @@ ghb_set_pref_audio(gint titleindex, signal_user_data_t *ud) ghb_settings_set_string(settings, "AudioEncoder", ghb_lookup_combo_string("AudioEncoder", ghb_int_value(acodec))); ghb_settings_set_value(settings, "AudioEncoderActual", - ghb_settings_get_value(ud->settings, "AudioEncoderActual")); + ghb_lookup_acodec_value(select_acodec)); // This gets set autimatically if the codec is passthru ghb_settings_set_string(settings, "AudioBitrate", ghb_lookup_combo_string("AudioBitrate", ghb_int_value(bitrate))); ghb_settings_set_string(settings, "AudioSamplerate", ghb_lookup_combo_string("AudioSamplerate", ghb_int_value(rate))); - mix = ghb_get_best_mix( titleindex, track, mix_acodec, mix); + mix = ghb_get_best_mix( aconfig, select_acodec, mix); ghb_settings_set_string(settings, "AudioMixdown", ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix))); ghb_settings_set_value(settings, "AudioTrackDRCSlider", drc); @@ -345,7 +342,7 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud) { const gchar *track, *codec, *br, *sr, *mix; gchar *s_drc; - gint itrack, icodec; + gint itrack; gdouble drc; // Get the row number treepath = gtk_tree_model_get_path (store, &iter); @@ -361,8 +358,7 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud) track = ghb_settings_combo_option(asettings, "AudioTrack"); itrack = ghb_settings_combo_int(asettings, "AudioTrack"); - codec = ghb_settings_combo_option(asettings, "AudioEncoder"); - icodec = ghb_settings_combo_int(asettings, "AudioEncoder"); + codec = ghb_settings_combo_option(asettings, "AudioEncoderActual"); br = ghb_settings_combo_option(asettings, "AudioBitrate"); sr = ghb_settings_combo_option(asettings, "AudioSamplerate"); mix = ghb_settings_combo_option(asettings, "AudioMixdown"); @@ -373,9 +369,6 @@ ghb_audio_list_refresh_selected(signal_user_data_t *ud) else s_drc = g_strdup_printf("%.1f", drc); - if (icodec == HB_ACODEC_ANY) - codec = ghb_select_audio_codec_str(ud->settings, icodec, itrack); - gtk_list_store_set(GTK_LIST_STORE(store), &iter, // These are displayed in list 0, track, @@ -432,19 +425,13 @@ audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) } ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(sr)); + hb_audio_config_t *aconfig; + aconfig = ghb_get_scan_audio_info(titleindex, track); if (sr == 0) { - ghb_audio_info_t ainfo; - if (ghb_get_audio_info (&ainfo, titleindex, track)) - { - sr = ainfo.samplerate; - } - else - { - sr = 48000; - } + sr = aconfig ? aconfig->in.samplerate : 48000; } - mix_code = ghb_get_best_mix( titleindex, track, acodec_code, mix_code); + mix_code = ghb_get_best_mix( aconfig, acodec_code, mix_code); br = hb_get_best_audio_bitrate(acodec_code, br, sr, mix_code); ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(br)); @@ -576,7 +563,7 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings) GtkTreeSelection *selection; const gchar *track, *codec, *br, *sr, *mix; gchar *s_drc; - gint icodec, itrack; + gint itrack; gdouble drc; g_debug("add_to_audio_list ()"); @@ -586,8 +573,7 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings) track = ghb_settings_combo_option(settings, "AudioTrack"); itrack = ghb_settings_combo_int(settings, "AudioTrack"); - codec = ghb_settings_combo_option(settings, "AudioEncoder"); - icodec = ghb_settings_combo_int(settings, "AudioEncoder"); + codec = ghb_settings_combo_option(settings, "AudioEncoderActual"); br = ghb_settings_combo_option(settings, "AudioBitrate"); sr = ghb_settings_combo_option(settings, "AudioSamplerate"); mix = ghb_settings_combo_option(settings, "AudioMixdown"); @@ -598,11 +584,6 @@ add_to_audio_list(signal_user_data_t *ud, GValue *settings) else s_drc = g_strdup_printf("%.1f", drc); - if (icodec == HB_ACODEC_ANY) - { - codec = ghb_select_audio_codec_str(ud->settings, icodec, itrack); - } - gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, // These are displayed in list @@ -774,16 +755,14 @@ void ghb_set_audio(signal_user_data_t *ud, GValue *settings) { gint acodec_code; - GtkWidget *button; GValue *alist; - GValue *track, *audio, *acodec, *bitrate, *rate, *mix, *drc; + GValue *track, *audio, *acodec, *acodec_actual, *bitrate, *rate, *mix, *drc; gint count, ii; g_debug("set_audio"); // Clear the audio list ghb_clear_audio_list(ud); - button = GHB_WIDGET (ud->builder, "audio_add"); alist = ghb_settings_get_value(settings, "audio_list"); count = ghb_array_len(alist); @@ -792,6 +771,7 @@ ghb_set_audio(signal_user_data_t *ud, GValue *settings) audio = ghb_array_get_nth(alist, ii); track = ghb_settings_get_value(audio, "AudioTrack"); acodec = ghb_settings_get_value(audio, "AudioEncoder"); + acodec_actual = ghb_settings_get_value(audio, "AudioEncoderActual"); bitrate = ghb_settings_get_value(audio, "AudioBitrate"); rate = ghb_settings_get_value(audio, "AudioSamplerate"); mix = ghb_settings_get_value(audio, "AudioMixdown"); @@ -803,8 +783,8 @@ ghb_set_audio(signal_user_data_t *ud, GValue *settings) GValue *settings = ghb_dict_value_new(); ghb_settings_set_value(settings, "AudioTrack", track); ghb_settings_set_value(settings, "AudioEncoder", acodec); - ghb_settings_set_value(settings, "AudioEncoderActual", - ghb_settings_get_value(ud->settings, "AudioEncoderActual")); + ghb_settings_set_value(settings, "AudioEncoderActual", acodec_actual); + // This gets set autimatically if the codec is passthru ghb_settings_set_value(settings, "AudioBitrate", bitrate); ghb_settings_set_value(settings, "AudioSamplerate", rate); diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 310cce02d..a9a962c45 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -413,6 +413,7 @@ combo_name_map_t combo_name_map[] = {"PictureDenoise", &denoise_opts}, {"VideoEncoder", &vcodec_opts}, {"AudioEncoder", &acodec_opts}, + {"AudioEncoderActual", &acodec_opts}, {"x264_direct", &direct_opts}, {"x264_b_adapt", &badapt_opts}, {"x264_bpyramid", &bpyramid_opts}, @@ -1460,14 +1461,14 @@ ghb_get_title_number(gint titleindex) } static hb_audio_config_t* -get_hb_audio(gint titleindex, gint track) +get_hb_audio(hb_handle_t *h, gint titleindex, gint track) { hb_list_t * list; hb_title_t * title; hb_audio_config_t *audio = NULL; - if (h_scan == NULL) return NULL; - list = hb_get_titles( h_scan ); + if (h == NULL) return NULL; + list = hb_get_titles( h ); if( !hb_list_count( list ) ) { /* No valid title, stop right there */ @@ -1530,7 +1531,7 @@ ghb_grey_combo_options(GtkBuilder *builder) { GtkWidget *widget; gint container, track, titleindex, acodec; - hb_audio_config_t *audio = NULL; + hb_audio_config_t *aconfig = NULL; GValue *gval; widget = GHB_WIDGET (builder, "title"); @@ -1541,7 +1542,7 @@ ghb_grey_combo_options(GtkBuilder *builder) gval = ghb_widget_value(widget); track = ghb_lookup_combo_int("AudioTrack", gval); ghb_value_free(gval); - audio = get_hb_audio(titleindex, track); + aconfig = get_hb_audio(h_scan, titleindex, track); widget = GHB_WIDGET (builder, "FileFormat"); gval = ghb_widget_value(widget); container = ghb_lookup_combo_int("FileFormat", gval); @@ -1561,11 +1562,11 @@ ghb_grey_combo_options(GtkBuilder *builder) else grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE); - if (audio && audio->in.codec != HB_ACODEC_AC3) + if (aconfig && aconfig->in.codec != HB_ACODEC_AC3) { grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_AC3_PASS, TRUE); } - if (audio && audio->in.codec != HB_ACODEC_DCA) + if (aconfig && aconfig->in.codec != HB_ACODEC_DCA) { grey_combo_box_item(builder, "AudioEncoder", HB_ACODEC_DCA_PASS, TRUE); } @@ -1589,9 +1590,9 @@ ghb_grey_combo_options(GtkBuilder *builder) gboolean allow_6ch = TRUE; allow_mono = TRUE; allow_6ch = acodec & ~HB_ACODEC_LAME; - if (audio) + if (aconfig) { - gint layout = audio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK; + gint layout = aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK; allow_stereo = ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO); allow_dolby = @@ -1601,7 +1602,7 @@ ghb_grey_combo_options(GtkBuilder *builder) allow_dpl2 = (layout == HB_INPUT_CH_LAYOUT_3F2R); allow_6ch = allow_6ch && (layout == HB_INPUT_CH_LAYOUT_3F2R) && - (audio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE); + (aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE); } grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_MONO, !allow_mono); grey_combo_box_item(builder, "AudioMixdown", HB_AMIXDOWN_STEREO, !allow_stereo); @@ -1611,9 +1612,8 @@ ghb_grey_combo_options(GtkBuilder *builder) } gint -ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix) +ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix) { - hb_audio_config_t *audio = NULL; gboolean allow_mono = TRUE; gboolean allow_stereo = TRUE; gboolean allow_dolby = TRUE; @@ -1625,11 +1625,10 @@ ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix) // Audio codec pass-thru. No mixdown return 0; } - audio = get_hb_audio(titleindex, track); - if (audio) + if (aconfig) { allow_mono = TRUE; - gint layout = audio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK; + gint layout = aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK; allow_stereo = ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO); allow_dolby = @@ -1640,7 +1639,7 @@ ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix) allow_6ch = (acodec & ~HB_ACODEC_LAME) && (layout == HB_INPUT_CH_LAYOUT_3F2R) && - (audio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE); + (aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE); } gboolean greater = FALSE; if (mix == 0) @@ -3439,17 +3438,13 @@ ghb_get_title_info(ghb_title_info_t *tinfo, gint titleindex) return TRUE; } -gboolean -ghb_get_audio_info(ghb_audio_info_t *ainfo, gint titleindex, gint audioindex) +hb_audio_config_t* +ghb_get_scan_audio_info(gint titleindex, gint audioindex) { - hb_audio_config_t *audio; + hb_audio_config_t *aconfig; - audio = get_hb_audio(titleindex, audioindex); - if (audio == NULL) return FALSE; // Bad audioindex - ainfo->codec = audio->in.codec; - ainfo->bitrate = audio->in.bitrate; - ainfo->samplerate = audio->in.samplerate; - return TRUE; + aconfig = get_hb_audio(h_scan, titleindex, audioindex); + return aconfig; } gboolean @@ -4127,38 +4122,16 @@ ghb_validate_subtitles(signal_user_data_t *ud) } gint -ghb_select_audio_codec(GValue *settings, gint acodec, gint track) +ghb_select_audio_codec(GValue *settings, hb_audio_config_t *aconfig, gint acodec) { - hb_list_t * list; - hb_title_t * title; - hb_audio_config_t *audio; - - if (h_scan == NULL) return -1; - list = hb_get_titles( h_scan ); - if( !hb_list_count( list ) ) - { - return -1; - } - - gint titleindex; - - titleindex = ghb_settings_combo_int(settings, "title"); - title = hb_list_item( list, titleindex ); - if (title == NULL) return -1; - gint mux = ghb_settings_combo_int(settings, "FileFormat"); - if (track < 0 || track >= hb_list_count(title->list_audio)) - return -1; - - audio = (hb_audio_config_t *) hb_list_audio_config_item( - title->list_audio, track ); - + guint32 in_codec = aconfig ? aconfig->in.codec : HB_ACODEC_MASK; if (mux == HB_MUX_MP4) { - if ((acodec & audio->in.codec & HB_ACODEC_AC3)) + if ((acodec & in_codec & HB_ACODEC_AC3)) { - return acodec & (audio->in.codec | HB_ACODEC_PASS_FLAG); + return acodec & (in_codec | HB_ACODEC_PASS_FLAG); } else if (acodec & HB_ACODEC_AC3) { @@ -4175,9 +4148,9 @@ ghb_select_audio_codec(GValue *settings, gint acodec, gint track) } else { - if ((acodec & audio->in.codec & HB_ACODEC_PASS_MASK)) + if ((acodec & in_codec & HB_ACODEC_PASS_MASK)) { - return acodec & (audio->in.codec | HB_ACODEC_PASS_FLAG); + return acodec & (in_codec | HB_ACODEC_PASS_FLAG); } else if (acodec & HB_ACODEC_AC3) { @@ -4198,20 +4171,6 @@ ghb_select_audio_codec(GValue *settings, gint acodec, gint track) } } -const gchar* -ghb_select_audio_codec_str(GValue *settings, gint icodec, gint track) -{ - gint acodec, ii; - - acodec = ghb_select_audio_codec(settings, icodec, track); - for (ii = 0; ii < acodec_opts.count; ii++) - { - if (acodec_opts.map[ii].ivalue == acodec) - return acodec_opts.map[ii].option; - } - return "Unknown"; -} - gboolean ghb_validate_audio(signal_user_data_t *ud) { @@ -4244,7 +4203,7 @@ ghb_validate_audio(signal_user_data_t *ud) for (ii = 0; ii < count; ii++) { GValue *asettings; - hb_audio_config_t *taudio; + hb_audio_config_t *aconfig; asettings = ghb_array_get_nth(audio_list, ii); gint track = ghb_settings_combo_int(asettings, "AudioTrack"); @@ -4252,11 +4211,11 @@ ghb_validate_audio(signal_user_data_t *ud) if (codec == HB_ACODEC_ANY) continue; - taudio = (hb_audio_config_t *) hb_list_audio_config_item( + aconfig = (hb_audio_config_t *) hb_list_audio_config_item( title->list_audio, track ); if ( ghb_audio_is_passthru(codec) && - !(ghb_audio_can_passthru(taudio->in.codec) && - (taudio->in.codec & codec))) + !(ghb_audio_can_passthru(aconfig->in.codec) && + (aconfig->in.codec & codec))) { // Not supported. AC3 is passthrough only, so input must be AC3 message = g_strdup_printf( @@ -4270,7 +4229,7 @@ ghb_validate_audio(signal_user_data_t *ud) } g_free(message); if ((codec & HB_ACODEC_AC3) || - taudio->in.codec == HB_ACODEC_DCA) + aconfig->in.codec == HB_ACODEC_DCA) { codec = HB_ACODEC_AC3; } @@ -4324,7 +4283,7 @@ ghb_validate_audio(signal_user_data_t *ud) gboolean allow_dpl2 = TRUE; gboolean allow_6ch = TRUE; allow_mono = TRUE; - gint layout = taudio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK; + gint layout = aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK; allow_stereo = ((layout == HB_INPUT_CH_LAYOUT_MONO && !allow_mono) || layout >= HB_INPUT_CH_LAYOUT_STEREO); allow_dolby = @@ -4335,7 +4294,7 @@ ghb_validate_audio(signal_user_data_t *ud) allow_6ch = (codec & ~HB_ACODEC_LAME) && (layout == HB_INPUT_CH_LAYOUT_3F2R) && - (taudio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE); + (aconfig->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE); gchar *mix_unsup = NULL; if (mix == HB_AMIXDOWN_MONO && !allow_mono) @@ -4370,7 +4329,7 @@ ghb_validate_audio(signal_user_data_t *ud) return FALSE; } g_free(message); - mix = ghb_get_best_mix(titleindex, track, codec, mix); + mix = ghb_get_best_mix(aconfig, codec, mix); value = get_amix_value(mix); ghb_settings_take_value(asettings, "AudioMixdown", value); } @@ -4710,7 +4669,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 *taudio; + hb_audio_config_t *aconfig; gint acodec; hb_audio_config_init(&audio); @@ -4718,9 +4677,9 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) audio.in.track = ghb_settings_get_int(asettings, "AudioTrack"); audio.out.track = tcount; acodec = ghb_settings_combo_int(asettings, "AudioEncoder"); - audio.out.codec = ghb_select_audio_codec(js, acodec, audio.in.track); + audio.out.codec = ghb_select_audio_codec(js, aconfig, acodec); - taudio = (hb_audio_config_t *) hb_list_audio_config_item( + aconfig = (hb_audio_config_t *) hb_list_audio_config_item( title->list_audio, audio.in.track ); audio.out.dynamic_range_compression = ghb_settings_get_double(asettings, "AudioTrackDRCSlider"); @@ -4736,13 +4695,13 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) { audio.out.mixdown = ghb_settings_combo_int(asettings, "AudioMixdown"); // Make sure the mixdown is valid and pick a new one if not. - audio.out.mixdown = ghb_get_best_mix(titleindex, - audio.in.track, audio.out.codec, audio.out.mixdown); + audio.out.mixdown = ghb_get_best_mix(aconfig, audio.out.codec, + audio.out.mixdown); audio.out.bitrate = ghb_settings_combo_int(asettings, "AudioBitrate"); gint srate = ghb_settings_combo_int(asettings, "AudioSamplerate"); if (srate == 0) // 0 is same as source - audio.out.samplerate = taudio->in.samplerate; + audio.out.samplerate = aconfig->in.samplerate; else audio.out.samplerate = srate; diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h index 67874bb4e..547415cf3 100644 --- a/gtk/src/hb-backend.h +++ b/gtk/src/hb-backend.h @@ -18,6 +18,7 @@ #define _HBBACKEND_H_ #include "settings.h" +#include "hb.h" enum { @@ -83,13 +84,6 @@ typedef struct gint angle_count; } ghb_title_info_t; -typedef struct -{ - gint codec; - gint bitrate; - gint samplerate; -} ghb_audio_info_t; - #define GHB_AUDIO_SAMPLERATE 1 #define GHB_AUDIO_BITRATE 2 #define GHB_FRAMERATE 3 @@ -134,13 +128,12 @@ void ghb_set_scale(signal_user_data_t *ud, gint mode); GValue* ghb_get_chapters(gint titleindex); void ghb_get_chapter_duration(gint ti, gint ii, gint *hh, gint *mm, gint *ss); void ghb_part_duration(gint tt, gint sc, gint ec, gint *hh, gint *mm, gint *ss); -gint ghb_get_best_mix(gint titleindex, gint track, gint acodec, gint mix); +gint ghb_get_best_mix(hb_audio_config_t *aconfig, gint acodec, gint mix); gboolean ghb_ac3_in_audio_list(const GValue *audio_list); gboolean ghb_audio_is_passthru(gint acodec); gboolean ghb_audio_can_passthru(gint acodec); gint ghb_get_default_acodec(void); -gboolean ghb_get_audio_info( - ghb_audio_info_t *ainfo, gint titleindex, gint audioindex); +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); @@ -183,8 +176,7 @@ 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(GValue *settings, gint acodec, gint track); -const gchar* ghb_select_audio_codec_str(GValue *settings, gint acodec, gint track); +gint ghb_select_audio_codec(GValue *settings, 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/queuehandler.c b/gtk/src/queuehandler.c index 2232a219d..1cc0161eb 100644 --- a/gtk/src/queuehandler.c +++ b/gtk/src/queuehandler.c @@ -409,7 +409,7 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter) asettings = ghb_array_get_nth(audio_list, ii); - acodec = ghb_settings_combo_option(asettings, "AudioEncoder"); + acodec = ghb_settings_combo_option(asettings, "AudioEncoderActual"); bitrate = ghb_settings_get_string(asettings, "AudioBitrate"); sr = ghb_settings_get_double(asettings, "AudioSamplerate"); samplerate = ghb_settings_get_string(asettings, "AudioSamplerate"); @@ -526,7 +526,7 @@ audio_list_refresh(signal_user_data_t *ud) { const gchar *track, *codec, *br, *sr, *mix; gchar *s_drc; - gint itrack, icodec; + gint itrack; gdouble drc; GValue *asettings; @@ -537,8 +537,7 @@ audio_list_refresh(signal_user_data_t *ud) track = ghb_settings_combo_option(asettings, "AudioTrack"); itrack = ghb_settings_combo_int(asettings, "AudioTrack"); - codec = ghb_settings_combo_option(asettings, "AudioEncoder"); - icodec = ghb_settings_combo_int(asettings, "AudioEncoder"); + codec = ghb_settings_combo_option(asettings, "AudioEncoderActual"); br = ghb_settings_combo_option(asettings, "AudioBitrate"); sr = ghb_settings_combo_option(asettings, "AudioSamplerate"); mix = ghb_settings_combo_option(asettings, "AudioMixdown"); @@ -549,9 +548,6 @@ audio_list_refresh(signal_user_data_t *ud) else s_drc = g_strdup_printf("%.1f", drc); - if (icodec == HB_ACODEC_ANY) - codec = ghb_select_audio_codec_str(ud->settings, icodec, itrack); - gtk_list_store_set(GTK_LIST_STORE(store), &iter, // These are displayed in list 0, track, |