G_MODULE_EXPORT void vcodec_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { float val, vqmin, vqmax, step, page; int inverted, digits; ghb_widget_to_setting(ud->settings, widget); ghb_check_dependency(ud, widget, NULL); ghb_show_container_options(ud); ghb_update_summary_info(ud); ghb_clear_presets_selection(ud); ghb_live_reset(ud); // Set the range of the video quality slider val = ghb_vquality_default(ud); ghb_vquality_range(ud, &vqmin, &vqmax, &step, &page, &digits, &inverted); ghb_scale_configure(ud, "VideoQualitySlider", val, vqmin, vqmax, step, page, digits, inverted); ghb_update_ui_combo_box(ud, "VideoTune", NULL, FALSE); ghb_update_ui_combo_box(ud, "VideoProfile", NULL, FALSE); ghb_update_ui_combo_box(ud, "VideoLevel", NULL, FALSE); ghb_ui_update(ud, "VideoTune", ghb_int_value(0)); ghb_ui_update(ud, "VideoProfile", ghb_int_value(0)); ghb_ui_update(ud, "VideoLevel", ghb_int_value(0)); ghb_ui_update(ud, "VideoOptionExtra", ghb_string_value("")); // Set the range of the preset slider int encoder = ghb_get_video_encoder(ud->settings); GtkWidget *presetSlider = GHB_WIDGET(ud->builder, "VideoPresetSlider"); GtkWidget *presetLabel = GHB_WIDGET(ud->builder, "VideoPresetLabel"); const char * const *video_presets; int count = 0; video_presets = hb_video_encoder_get_presets(encoder); while (video_presets && video_presets[count]) count++; gtk_widget_set_visible(presetSlider, count > 0); gtk_widget_set_visible(presetLabel, count > 0); if (count) { gtk_range_set_range(GTK_RANGE(presetSlider), 0, count-1); } ghb_set_video_preset(ud->settings, encoder, "medium"); GhbValue *gval = ghb_dict_get_value(ud->settings, "VideoPresetSlider"); ghb_ui_settings_update(ud, ud->settings, "VideoPresetSlider", gval); // Advanced options are only for x264 if (!(encoder & HB_VCODEC_X264_MASK)) { ghb_ui_update(ud, "x264UseAdvancedOptions", ghb_boolean_value(FALSE)); } }
G_MODULE_EXPORT void x264_use_advanced_options_changed_cb(GtkWidget *widget, signal_user_data_t *ud) { ghb_widget_to_setting(ud->settings, widget); if (ghb_dict_get_bool(ud->prefs, "HideAdvancedVideoSettings") && ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions")) { ghb_ui_update(ud, "x264UseAdvancedOptions", ghb_boolean_value(FALSE)); return; } if (ghb_dict_get_bool(ud->settings, "x264UseAdvancedOptions")) { ghb_ui_update(ud, "VideoPresetSlider", ghb_int_value(5)); ghb_ui_update(ud, "VideoTune", ghb_string_value("none")); ghb_ui_update(ud, "VideoProfile", ghb_string_value("auto")); ghb_ui_update(ud, "VideoLevel", ghb_string_value("auto")); const char *options = ghb_dict_get_string(ud->settings, "x264Option"); ghb_ui_update(ud, "VideoOptionExtra", ghb_string_value(options)); } ghb_check_dependency(ud, widget, NULL); ghb_clear_presets_selection(ud); }
void ghb_set_pref_audio_settings(gint titleindex, GValue *settings) { gint track; gchar *source_lang; hb_audio_config_t *aconfig; GHashTable *track_indices; gint mux; const GValue *pref_audio; const GValue *audio, *drc, *gain, *enable_qual; gint acodec, bitrate, mix; gdouble rate, quality; gint count, ii, list_count; g_debug("set_pref_audio"); mux = ghb_settings_combo_int(settings, "FileFormat"); 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 ghb_clear_audio_list_settings(settings); // Find "best" audio based on audio preferences if (!ghb_settings_get_boolean(settings, "AudioDUB")) { source_lang = g_strdup(ghb_get_source_audio_lang(titleindex, 0)); } else { source_lang = ghb_settings_get_string(settings, "PreferredLanguage"); } pref_audio = ghb_settings_get_value(settings, "AudioList"); list_count = 0; count = ghb_array_len(pref_audio); for (ii = 0; ii < count; ii++) { gint select_acodec; gint fallback; audio = ghb_array_get_nth(pref_audio, ii); acodec = ghb_settings_combo_int(audio, "AudioEncoder"); fallback = ghb_select_fallback(settings, mux, acodec); gint copy_mask = ghb_get_copy_mask(settings); select_acodec = ghb_select_audio_codec(mux, NULL, acodec, fallback, copy_mask); bitrate = ghb_settings_combo_int(audio, "AudioBitrate"); rate = ghb_settings_combo_double(audio, "AudioSamplerate"); mix = ghb_settings_combo_int(audio, "AudioMixdown"); drc = ghb_settings_get_value(audio, "AudioTrackDRCSlider"); gain = ghb_settings_get_value(audio, "AudioTrackGain"); enable_qual = ghb_settings_get_value(audio, "AudioTrackQualityEnable"); quality = ghb_settings_get_double(audio, "AudioTrackQuality"); // If there are multiple audios using the same codec, then // select sequential tracks for each. The hash keeps track // of the tracks used for each codec. track = ghb_find_audio_track(titleindex, source_lang, select_acodec, fallback, track_indices); // Check to see if: // 1. pref codec is passthru // 2. source codec is not passthru // 3. next pref is enabled 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 (!(aconfig->in.codec & select_acodec & HB_ACODEC_PASS_MASK)) { if (acodec != HB_ACODEC_AUTO_PASS) acodec = fallback; // If we can't substitute the passthru with a suitable // encoder and // If there's more audio to process, or we've already // placed one in the list, then we can skip this one if (!(select_acodec & fallback) && ((ii + 1 < count) || (list_count != 0))) { // Skip this audio acodec = 0; } } else { select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG; } } if (titleindex >= 0 && track < 0) acodec = 0; if (acodec != 0) { GValue *asettings = ghb_dict_value_new(); ghb_settings_set_int(asettings, "AudioTrack", track); ghb_settings_set_string(asettings, "AudioEncoder", ghb_lookup_combo_string("AudioEncoder", ghb_int_value(acodec))); ghb_settings_set_value(asettings, "AudioEncoderActual", ghb_lookup_audio_encoder_value(select_acodec)); ghb_settings_set_value(asettings, "AudioTrackQualityEnable", enable_qual); ghb_settings_set_double(asettings, "AudioTrackQuality", quality); // This gets set autimatically if the codec is passthru ghb_settings_set_string(asettings, "AudioBitrate", ghb_lookup_combo_string("AudioBitrate", ghb_int_value(bitrate))); ghb_settings_set_string(asettings, "AudioSamplerate", ghb_lookup_combo_string("AudioSamplerate", ghb_int_value(rate))); mix = ghb_get_best_mix( aconfig, select_acodec, mix); ghb_settings_set_string(asettings, "AudioMixdown", ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix))); ghb_settings_set_value(asettings, "AudioTrackDRCSlider", drc); ghb_settings_set_value(asettings, "AudioTrackGain", gain); ghb_sanitize_audio(settings, asettings); ghb_add_audio_to_settings(settings, asettings); } } g_free(source_lang); g_hash_table_destroy(track_indices); }
void ghb_sanitize_audio(GValue *settings, GValue *asettings) { gint titleindex, track, acodec, select_acodec, mix; hb_audio_config_t *aconfig; gint mux; gint bitrate; gint sr; g_debug("ghb_santiize_audio ()"); mux = ghb_settings_combo_int(settings, "FileFormat"); titleindex = ghb_settings_get_int(settings, "title_no"); track = ghb_settings_combo_int(asettings, "AudioTrack"); acodec = ghb_settings_combo_int(asettings, "AudioEncoder"); mix = ghb_settings_combo_int(asettings, "AudioMixdown"); bitrate = ghb_settings_combo_int(asettings, "AudioBitrate"); sr = ghb_settings_combo_int(asettings, "AudioSamplerate"); aconfig = ghb_get_scan_audio_info(titleindex, track); if (sr == 0) { sr = aconfig ? aconfig->in.samplerate : 48000; } gint fallback = ghb_select_fallback(settings, mux, acodec); gint copy_mask = ghb_get_copy_mask(settings); select_acodec = ghb_select_audio_codec(mux, aconfig, acodec, fallback, copy_mask); if (ghb_audio_is_passthru (select_acodec)) { if (aconfig) { bitrate = aconfig->in.bitrate / 1000; // Set the values for bitrate and samplerate to the input rates mix = 0; ghb_settings_set_string(asettings, "AudioMixdown", ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix))); select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG; ghb_settings_set_string(asettings, "AudioSamplerate", ghb_lookup_combo_string("AudioSamplerate", ghb_int_value(0))); } else { mix = 0; ghb_settings_set_string(asettings, "AudioMixdown", ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix))); ghb_settings_set_string(asettings, "AudioSamplerate", ghb_lookup_combo_string("AudioSamplerate", ghb_int_value(0))); bitrate = 448; } ghb_settings_set_double(asettings, "AudioTrackDRCSlider", 0.0); } else { if (mix == 0) mix = ghb_get_best_mix( aconfig, select_acodec, 0); bitrate = hb_audio_bitrate_get_best(select_acodec, bitrate, sr, mix); ghb_settings_set_string(asettings, "AudioMixdown", ghb_lookup_combo_string("AudioMixdown", ghb_int_value(mix))); } ghb_settings_set_string(asettings, "AudioBitrate", ghb_lookup_combo_string("AudioBitrate", ghb_int_value(bitrate))); ghb_settings_take_value(asettings, "AudioEncoderActual", ghb_lookup_audio_encoder_value(select_acodec)); }