예제 #1
0
G_MODULE_EXPORT void
audio_track_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GValue *asettings;

    g_debug("audio_track_changed_cb ()");
    if (block_updates)
    {
        ghb_check_dependency(ud, widget, NULL);
        ghb_grey_combo_options (ud);
        return;
    }

    ghb_adjust_audio_rate_combos(ud);
    ghb_check_dependency(ud, widget, NULL);
    ghb_grey_combo_options(ud);
    asettings = get_selected_asettings(ud);
    if (asettings != NULL)
    {
        const gchar *track;

        ghb_widget_to_setting(asettings, widget);
        ghb_audio_list_refresh_selected(ud);
        track = ghb_settings_combo_option(asettings, "AudioTrack");
        ghb_settings_set_string(asettings, "AudioTrackDescription", track);
    }
    ghb_live_reset(ud);
}
예제 #2
0
G_MODULE_EXPORT void
x264_me_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    gint me;

    ghb_widget_to_setting(ud->x264_priv, widget);
    if (!ignore_options_update)
    {
        ignore_options_update = TRUE;
        x264_opt_update(ud, widget);
        ignore_options_update = FALSE;
    }
    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
    widget = GHB_WIDGET(ud->builder, "x264_merange");
    me = ghb_settings_combo_int(ud->x264_priv, "x264_me");
    if (me < 2)
    {   // me < umh
        // me_range 4 - 16
        gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 4, 16);
    }
    else
    {
        // me_range 4 - 64
        gtk_spin_button_set_range(GTK_SPIN_BUTTON(widget), 4, 64);
    }
}
예제 #3
0
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);
}
예제 #4
0
G_MODULE_EXPORT void
fullscreen_clicked_cb(GtkWidget *toggle, signal_user_data_t *ud)
{
    gboolean active;
    GtkWindow *window;

    g_debug("fullscreen_clicked_cb()");
    ghb_widget_to_setting (ud->prefs, toggle);
    ghb_check_dependency(ud, toggle, NULL);
    const gchar *name = ghb_get_setting_key(toggle);
    ghb_pref_save(ud->prefs, name);

    window = GTK_WINDOW(GHB_WIDGET (ud->builder, "preview_window"));
    active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle));
    if (active)
    {
        gtk_window_set_resizable(window, TRUE);
        gtk_button_set_label(GTK_BUTTON(toggle), _("Windowed"));
        // Changing resizable property doesn't take effect immediately
        // need to delay fullscreen till after this callback returns
        // to mainloop
        g_idle_add((GSourceFunc)go_full, ud);
    }
    else
    {
        gtk_window_unfullscreen(window);
        gtk_window_set_resizable(window, FALSE);
        gtk_button_set_label(GTK_BUTTON(toggle), _("Fullscreen"));
        ghb_set_preview_image(ud);
    }
}
예제 #5
0
G_MODULE_EXPORT void
gain_widget_changed_cb(GtkWidget *widget, gdouble gain, signal_user_data_t *ud)
{
    GValue *asettings;

    g_debug("gain_widget_changed_cb ()");

    ghb_check_dependency(ud, widget, NULL);
    if (block_updates) return;
    asettings = get_selected_asettings(ud);

    char *s_gain;
    if ( gain >= 21.0 )
        s_gain = g_strdup_printf("*11*");
    else
        s_gain = g_strdup_printf("%ddB", (int)gain);
    ghb_ui_update( ud, "AudioTrackGainValue", ghb_string_value(s_gain));
    g_free(s_gain);

    if (asettings != NULL)
    {
        ghb_widget_to_setting(asettings, widget);
        ghb_audio_list_refresh_selected(ud);
    }
    ghb_live_reset(ud);
}
예제 #6
0
G_MODULE_EXPORT void
drc_widget_changed_cb(GtkWidget *widget, gdouble drc, signal_user_data_t *ud)
{
    GValue *asettings;

    g_debug("drc_widget_changed_cb ()");

    ghb_check_dependency(ud, widget, NULL);
    if (block_updates) return;

    char *s_drc;
    if (drc < 0.99)
        s_drc = g_strdup("Off");
    else
        s_drc = g_strdup_printf("%.1f", drc);
    ghb_ui_update( ud, "AudioTrackDRCValue", ghb_string_value(s_drc));
    g_free(s_drc);

    asettings = get_selected_asettings(ud);
    if (asettings != NULL)
    {
        ghb_widget_to_setting(asettings, widget);
        ghb_audio_list_refresh_selected(ud);
    }
    ghb_live_reset(ud);
}
예제 #7
0
G_MODULE_EXPORT void
quality_widget_changed_cb(GtkWidget *widget, gdouble quality, signal_user_data_t *ud)
{
    GValue *asettings;

    g_debug("quality_widget_changed_cb ()");

    ghb_check_dependency(ud, widget, NULL);
    float low, high, gran;
    int dir;
    int codec = ghb_settings_combo_int(ud->settings, "AudioEncoderActual");
    hb_audio_quality_get_limits(codec, &low, &high, &gran, &dir);
    if (dir)
    {
        // Quality values are inverted
        quality = high - quality + low;
    }
    char *s_quality = ghb_format_quality("", codec, quality);
    ghb_ui_update( ud, "AudioTrackQualityValue", ghb_string_value(s_quality));
    g_free(s_quality);

    if (block_updates) return;

    asettings = get_selected_asettings(ud);
    if (asettings != NULL)
    {
        ghb_settings_set_double(asettings, "AudioTrackQuality", quality);
        ghb_audio_list_refresh_selected(ud);
    }
    ghb_live_reset(ud);
}
예제 #8
0
G_MODULE_EXPORT void
srt_file_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GValue *subsettings;

    g_debug("srt_file_changed_cb()");
    ghb_check_dependency(ud, widget, NULL);
    ghb_widget_to_setting(ud->settings, widget);
    subsettings = subtitle_get_selected_settings(ud, NULL);
    if (subsettings != NULL)
    {
        gchar *filename, *dirname;

        ghb_widget_to_setting(subsettings, widget);
        subtitle_set_track_description(ud->settings, subsettings);
        ghb_subtitle_list_refresh_selected(ud);
        ghb_live_reset(ud);

        // Update SrtDir preference
        filename = ghb_settings_get_string(subsettings, "SrtFile");
        if (g_file_test(filename, G_FILE_TEST_IS_DIR))
        {
            ghb_settings_set_string(ud->prefs, "SrtDir", filename);
        }
        else
        {
            dirname = g_path_get_dirname(filename);
            ghb_settings_set_string(ud->prefs, "SrtDir", dirname);
            g_free(dirname);
        }
        ghb_pref_save(ud->prefs, "SrtDir");
        g_free(filename);
    }
}
예제 #9
0
G_MODULE_EXPORT void
video_preset_slider_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    ghb_widget_to_setting(ud->settings, widget);

    int presetIndex = ghb_dict_get_int(ud->settings, "VideoPresetSlider");
    const char * const *video_presets;
    const char *preset = "medium";
    int count;

    int encoder = ghb_get_video_encoder(ud->settings);
    video_presets = hb_video_encoder_get_presets(encoder);
    if (video_presets != NULL)
    {
        for (count = 0; video_presets[count]; count++);
        if (presetIndex < count)
        {
            preset = video_presets[presetIndex];
        }
    }

    ghb_set_video_preset(ud->settings, encoder, preset);
    GhbValue *gval = ghb_dict_get_value(ud->settings, "VideoPresetSlider");
    ghb_ui_settings_update(ud, ud->settings, "VideoPresetSlider", gval);

    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
    update_adv_settings_tooltip(ud);
}
예제 #10
0
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)
    {
        ghb_check_dependency(ud, widget, NULL);
        return;
    }

    ghb_check_dependency(ud, widget, NULL);
    ghb_widget_to_setting(ud->settings, widget);
    ghb_adjust_audio_rate_combos(ud);
    ghb_grey_combo_options (ud);
    ghb_audio_list_refresh_selected(ud);
    ghb_live_reset(ud);
}
예제 #11
0
void
ghb_video_setting_changed(GtkWidget *widget, signal_user_data_t *ud)
{
    ghb_widget_to_setting(ud->settings, widget);
    update_adv_settings_tooltip(ud);

    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
}
예제 #12
0
G_MODULE_EXPORT void
framerate_mode_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    ghb_widget_to_setting(ud->settings, widget);
    ghb_update_summary_info(ud);
    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
    ghb_live_reset(ud);
}
예제 #13
0
G_MODULE_EXPORT void
audio_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_t *ud)
{
    GtkTreeModel *store;
    GtkTreeIter iter;
    GtkWidget *widget;
    
    GtkTreePath *treepath;
    gint *indices;
    gint row;
    GValue *asettings = NULL;

    const GValue *audio_list;
    g_debug("audio_list_selection_changed_cb ()");
    if (gtk_tree_selection_get_selected(selection, &store, &iter))
    {
        //const gchar *actual_codec, *track, *codec, *bitrate, *sample_rate, *mix;
        //gdouble drc;

        // Get the row number
        treepath = gtk_tree_model_get_path (store, &iter);
        indices = gtk_tree_path_get_indices (treepath);
        row = indices[0];
        gtk_tree_path_free(treepath);
        // find audio settings
        if (row < 0) return;
        audio_list = ghb_settings_get_value(ud->settings, "audio_list");
        if (row >= ghb_array_len(audio_list))
            return;
        asettings = ghb_array_get_nth(audio_list, row);

        block_updates = TRUE;
        ghb_ui_update(ud, "AudioTrack", ghb_settings_get_value(asettings, "AudioTrack"));
        ghb_ui_update(ud, "AudioEncoder", ghb_settings_get_value(asettings, "AudioEncoder"));
        ghb_settings_set_value(ud->settings, "AudioEncoderActual", ghb_settings_get_value(asettings, "AudioEncoderActual"));
        ghb_check_dependency(ud, NULL, "AudioEncoderActual");
        ghb_ui_update(ud, "AudioBitrate", ghb_settings_get_value(asettings, "AudioBitrate"));
        ghb_ui_update(ud, "AudioTrackName", ghb_settings_get_value(asettings, "AudioTrackName"));
        ghb_ui_update(ud, "AudioSamplerate", ghb_settings_get_value(asettings, "AudioSamplerate"));
        ghb_ui_update(ud, "AudioMixdown", ghb_settings_get_value(asettings, "AudioMixdown"));
        ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_settings_get_value(asettings, "AudioTrackDRCSlider"));
        ghb_ui_update(ud, "AudioTrackGain", ghb_settings_get_value(asettings, "AudioTrackGain"));
        ghb_ui_update(ud, "AudioTrackQuality", ghb_settings_get_value(asettings, "AudioTrackQuality"));
        ghb_ui_update(ud, "AudioTrackQualityEnable", ghb_settings_get_value(asettings, "AudioTrackQualityEnable"));
        block_updates = FALSE;
        widget = GHB_WIDGET (ud->builder, "audio_remove");
        gtk_widget_set_sensitive(widget, TRUE);

        ghb_adjust_audio_rate_combos(ud);
    }
    else
    {
        widget = GHB_WIDGET (ud->builder, "audio_remove");
        gtk_widget_set_sensitive(widget, FALSE);
    }
}
예제 #14
0
static void
x264_update_bool_setting(signal_user_data_t *ud, const gchar *name, const gchar *val)
{
    if (val == NULL)
        ghb_dict_set_bool(ud->x264_priv, name, TRUE);
    else
        ghb_dict_set_bool(ud->x264_priv, name, str_is_true(val));

    ghb_check_dependency(ud, NULL, name);
}
예제 #15
0
static void
x264_update_int_setting(signal_user_data_t *ud, const gchar *name, const gchar *val)
{
    gint ival;

    if (val == NULL) return;
    ival = g_strtod (val, NULL);
    ghb_dict_set(ud->x264_priv, name, ghb_int_value_new(ival));
    ghb_check_dependency(ud, NULL, name);
}
예제 #16
0
G_MODULE_EXPORT void
preview_duration_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    g_debug("preview_duration_changed_cb ()");
    ghb_live_reset(ud);
    ghb_widget_to_setting (ud->prefs, widget);
    ghb_check_dependency(ud, widget, NULL);
    const gchar *name = ghb_get_setting_key(widget);
    ghb_pref_save(ud->prefs, name);
}
예제 #17
0
G_MODULE_EXPORT void
show_crop_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    g_debug("show_crop_changed_cb ()");
    ghb_widget_to_setting(ud->prefs, widget);
    ghb_check_dependency(ud, widget, NULL);
    ghb_live_reset(ud);
    if (gtk_widget_is_sensitive(widget))
        ghb_set_scale(ud, GHB_PIC_KEEP_PAR);
    ghb_pref_save(ud->prefs, "preview_show_crop");
    ghb_rescale_preview_image(ud);
}
예제 #18
0
G_MODULE_EXPORT void
audio_mix_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GValue *asettings;

    g_debug("audio_mix_changed_cb ()");
    if (block_updates)
    {
        ghb_check_dependency(ud, widget, NULL);
        return;
    }

    ghb_adjust_audio_rate_combos(ud);
    ghb_check_dependency(ud, widget, NULL);
    asettings = get_selected_asettings(ud);
    if (asettings != NULL)
    {
        ghb_widget_to_setting(asettings, widget);
        ghb_audio_list_refresh_selected(ud);
    }
    ghb_live_reset(ud);
}
예제 #19
0
G_MODULE_EXPORT void
x264_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    ghb_widget_to_setting(ud->x264_priv, widget);
    if (!ignore_options_update)
    {
        ignore_options_update = TRUE;
        x264_opt_update(ud, widget);
        ignore_options_update = FALSE;
    }
    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
}
예제 #20
0
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));
    }
}
예제 #21
0
G_MODULE_EXPORT void
srt_lang_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    GValue *subsettings;

    g_debug("srt_lang_changed_cb()");
    ghb_check_dependency(ud, widget, NULL);
    ghb_widget_to_setting(ud->settings, widget);
    subsettings = subtitle_get_selected_settings(ud, NULL);
    if (subsettings != NULL)
    {
        ghb_widget_to_setting(subsettings, widget);
        subtitle_set_track_description(ud->settings, subsettings);
        ghb_subtitle_list_refresh_selected(ud);
        ghb_live_reset(ud);
    }
}
예제 #22
0
G_MODULE_EXPORT void
framerate_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    ghb_widget_to_setting(ud->settings, widget);
    ghb_update_summary_info(ud);

    if (ghb_settings_video_framerate_rate(ud->settings, "VideoFramerate") != 0)
    {
        if (!ghb_dict_get_bool(ud->settings, "VideoFrameratePFR"))
        {
            ghb_ui_update(ud, "VideoFramerateCFR", ghb_boolean_value(TRUE));
        }
    }
    if (ghb_settings_video_framerate_rate(ud->settings, "VideoFramerate") == 0 &&
        ghb_dict_get_bool(ud->settings, "VideoFrameratePFR"))
    {
        ghb_ui_update(ud, "VideoFramerateVFR", ghb_boolean_value(TRUE));
    }
    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
    ghb_live_reset(ud);
}
예제 #23
0
G_MODULE_EXPORT void
x264_slider_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    ghb_widget_to_setting(ud->x264_priv, widget);

    // Lock slider values to multiples of step_increment
    GtkAdjustment * adj = gtk_range_get_adjustment(GTK_RANGE(widget));
    gdouble step = gtk_adjustment_get_step_increment(adj);
    gdouble val = gtk_range_get_value(GTK_RANGE(widget));
    gdouble new_val = ((int)((val + step / 2) / step)) * step;
    gdouble diff = val - new_val;
    if ( diff > 0.0001 || diff < -0.0001 )
    {
        gtk_range_set_value(GTK_RANGE(widget), new_val);
    }
    else if (!ignore_options_update)
    {
        ignore_options_update = TRUE;
        x264_opt_update(ud, widget);
        ignore_options_update = FALSE;
    }
    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
}
예제 #24
0
G_MODULE_EXPORT void
audio_codec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    static gint prev_acodec = 0;
    gint acodec_code;
    GValue *asettings, *gval;
    
    g_debug("audio_codec_changed_cb ()");
    gval = ghb_widget_value(widget);
    acodec_code = ghb_lookup_combo_int("AudioEncoder", gval);
    ghb_value_free(gval);

    if (block_updates)
    {
        prev_acodec = acodec_code;
        ghb_grey_combo_options (ud);
        ghb_check_dependency(ud, widget, NULL);
        return;
    }

    asettings = get_selected_asettings(ud);
    if (ghb_audio_is_passthru (prev_acodec) && 
        !ghb_audio_is_passthru (acodec_code))
    {
        // Transition from passthru to not, put some audio settings back to 
        // pref settings
        gint titleindex;
        gint track;
        gint br, sr, mix_code;

        if (asettings != NULL)
        {
            br = ghb_settings_get_int(asettings, "AudioBitrate");
            sr = ghb_settings_combo_int(asettings, "AudioSamplerate");
            mix_code = ghb_settings_combo_int(asettings, "AudioMixdown");
        }
        else
        {
            br = 160;
            sr = 0;
            mix_code = 0;
        }

        titleindex = ghb_settings_combo_int(ud->settings, "title");
        track = ghb_settings_combo_int(ud->settings, "AudioTrack");
        if (sr)
        {
            sr = ghb_find_closest_audio_samplerate(sr);
        }
        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)
        {
            sr = aconfig ? aconfig->in.samplerate : 48000;
        }
        mix_code = ghb_get_best_mix( aconfig, acodec_code, mix_code);
        br = hb_audio_bitrate_get_best(acodec_code, br, sr, mix_code);
        ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(br));

        ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix_code));
    }
    ghb_adjust_audio_rate_combos(ud);
    ghb_grey_combo_options (ud);
    ghb_check_dependency(ud, widget, NULL);
    prev_acodec = acodec_code;
    if (asettings != NULL)
    {
        ghb_widget_to_setting(asettings, widget);
        ghb_settings_set_value(asettings, "AudioEncoderActual", ghb_settings_get_value(ud->settings, "AudioEncoderActual"));
        ghb_audio_list_refresh_selected(ud);
    }
    ghb_live_reset(ud);

    float low, high, gran, defval;
    int dir;
    hb_audio_quality_get_limits(acodec_code, &low, &high, &gran, &dir);
    defval = hb_audio_quality_get_default(acodec_code);
    GtkScaleButton *sb;
    GtkAdjustment *adj;
    sb = GTK_SCALE_BUTTON(GHB_WIDGET(ud->builder, "AudioTrackQuality"));
    adj = gtk_scale_button_get_adjustment(sb);
    if (dir)
    {
        // Quality values are inverted
        defval = high - defval + low;
    }
    gtk_adjustment_configure (adj, defval, low, high, gran, gran * 10, 0);
}
예제 #25
0
G_MODULE_EXPORT void
x264_setting_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
{
    static char *tt = NULL;


    if (tt == NULL)
    {
        GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra"));
        tt = gtk_widget_get_tooltip_text(eo);
    }

    ghb_widget_to_setting(ud->settings, widget);

    int x264Preset = ghb_settings_get_int(ud->settings, "x264PresetSlider");
    const char *preset;
    preset = hb_video_encoder_get_presets(HB_VCODEC_X264)[x264Preset];
    ghb_settings_set_string(ud->settings, "x264Preset", preset);

    if (!ghb_settings_get_boolean(ud->settings, "x264UseAdvancedOptions"))
    {
        GString *str = g_string_new("");
        char *preset;
        char *tune;
        char *profile;
        char *level;
        char *opts;
        char *tunes;

        preset = ghb_settings_get_string(ud->settings, "x264Preset");
        tune = ghb_settings_get_string(ud->settings, "x264Tune");
        profile = ghb_settings_get_string(ud->settings, "h264Profile");
        level = ghb_settings_get_string(ud->settings, "h264Level");
        opts = ghb_settings_get_string(ud->settings, "x264OptionExtra");

        if (tune[0] && strcmp(tune, "none"))
        {
            g_string_append_printf(str, "%s", tune);
        }
        if (ghb_settings_get_boolean(ud->settings, "x264FastDecode"))
        {
            g_string_append_printf(str, "%s%s", str->str[0] ? "," : "", "fastdecode");
        }
        if (ghb_settings_get_boolean(ud->settings, "x264ZeroLatency"))
        {
            g_string_append_printf(str, "%s%s", str->str[0] ? "," : "", "zerolatency");
        }
        tunes = g_string_free(str, FALSE);

        char * new_opts;

        int w = ghb_settings_get_int(ud->settings, "scale_width");
        int h = ghb_settings_get_int(ud->settings, "scale_height");

        if (w == 0 || h == 0)
        {
            if (!ghb_settings_get_boolean(ud->settings, "autoscale"))
            {
                w = ghb_settings_get_int(ud->settings, "PictureWidth");
                h = ghb_settings_get_int(ud->settings, "PictureHeight");

                if (h == 0 && w != 0)
                {
                    h = w * 9 / 16;
                }
                if (w == 0 && h != 0)
                {
                    w = h * 16 / 9;
                }
            }
            if (w == 0 || h == 0)
            {
                w = 1280;
                h = 720;
            }
        }

        if (!strcasecmp(profile, "auto"))
        {
            profile[0] = 0;
        }
        if (!strcasecmp(level, "auto"))
        {
            level[0] = 0;
        }
        new_opts = hb_x264_param_unparse(
                        preset, tunes, opts, profile, level, w, h);
        if (new_opts)
            ghb_ui_update(ud, "x264Option", ghb_string_value(new_opts));
        else
            ghb_ui_update(ud, "x264Option", ghb_string_value(""));

        GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra"));

        char * new_tt;
        if (new_opts)
            new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"%s\"", tt, new_opts);
        else
            new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"\"", tt);
        gtk_widget_set_tooltip_text(eo, new_tt);

        g_free(new_tt);
        g_free(new_opts);

        g_free(preset);
        g_free(tune);
        g_free(profile);
        g_free(level);
        g_free(opts);
        g_free(tunes);
    }
    else
    {
        char *opts = ghb_settings_get_string(ud->settings, "x264Option");

        GtkWidget *eo = GTK_WIDGET(GHB_WIDGET(ud->builder, "x264OptionExtra"));
        char * new_tt;
        if (opts)
            new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"%s\"", tt, opts);
        else
            new_tt = g_strdup_printf("%s\n\nExpanded Options:\n\"\"", tt);
        gtk_widget_set_tooltip_text(eo, new_tt);
        g_free(new_tt);

        g_free(opts);
    }

    ghb_check_dependency(ud, widget, NULL);
    ghb_clear_presets_selection(ud);
}
예제 #26
0
void
ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
{
    gint titleindex, track, acodec, select_acodec, mix;
    hb_audio_config_t *aconfig;
    GtkWidget *widget;
    GValue *gval;
    gint mux;
    gint bitrate;
    gint sr = 48000;
    
    g_debug("ghb_adjust_audio_rate_combos ()");
    mux = ghb_settings_combo_int(ud->settings, "FileFormat");
    titleindex = ghb_settings_combo_int(ud->settings, "title");

    widget = GHB_WIDGET(ud->builder, "AudioTrack");
    gval = ghb_widget_value(widget);
    track = ghb_lookup_combo_int("AudioTrack", gval);
    ghb_value_free(gval);

    widget = GHB_WIDGET(ud->builder, "AudioEncoder");
    gval = ghb_widget_value(widget);
    acodec = ghb_lookup_combo_int("AudioEncoder", gval);
    ghb_value_free(gval);
    widget = GHB_WIDGET(ud->builder, "AudioMixdown");
    gval = ghb_widget_value(widget);
    mix = ghb_lookup_combo_int("AudioMixdown", gval);
    ghb_value_free(gval);

    widget = GHB_WIDGET(ud->builder, "AudioBitrate");
    gval = ghb_widget_value(widget);
    bitrate = ghb_lookup_combo_int("AudioBitrate", gval);

    widget = GHB_WIDGET(ud->builder, "AudioSamplerate");
    gval = ghb_widget_value(widget);
    sr = ghb_lookup_combo_int("AudioSamplerate", gval);


    aconfig = ghb_get_scan_audio_info(titleindex, track);
    if (sr == 0)
    {
        sr = aconfig ? aconfig->in.samplerate : 48000;
    }
    gint fallback = ghb_select_fallback( ud->settings, mux, acodec );
    gint copy_mask = ghb_get_copy_mask(ud->settings);
    select_acodec = ghb_select_audio_codec(mux, aconfig, acodec, fallback, copy_mask);
    gboolean codec_defined_bitrate = FALSE;
    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
            ghb_set_bitrate_opts (ud->builder, bitrate, bitrate, 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));
            mix = 0;
            ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix));
            bitrate = 448;
        }
        ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(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_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_audio_bitrate_get_limits(select_acodec, sr, mix, &low, &high);
        ghb_set_bitrate_opts (ud->builder, low, high, -1);
    }
    ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate));

    ghb_settings_take_value(ud->settings, "AudioEncoderActual", 
                            ghb_lookup_audio_encoder_value(select_acodec));
    GValue *asettings = get_selected_asettings(ud);
    if (asettings)
    {
        ghb_settings_take_value(asettings, "AudioEncoderActual", 
                            ghb_lookup_audio_encoder_value(select_acodec));
    }
    ghb_audio_list_refresh_selected(ud);
    ghb_check_dependency(ud, NULL, "AudioEncoderActual");
}