Пример #1
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);
}
Пример #2
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);
}