Ejemplo n.º 1
0
gint
ghb_widget_int(GtkWidget *widget)
{
    GValue *value;
    gint ival;

    value = ghb_widget_value(widget);
    ival = (gint)ghb_value_int64(value);
    ghb_value_free(value);
    return ival;
}
Ejemplo n.º 2
0
gint
ghb_widget_boolean(GtkWidget *widget)
{
    GValue *value;
    gboolean bval;

    value = ghb_widget_value(widget);
    bval = ghb_value_boolean(value);
    ghb_value_free(value);
    return bval;
}
Ejemplo n.º 3
0
gdouble
ghb_widget_double(GtkWidget *widget)
{
    GValue *value;
    gdouble dval;

    value = ghb_widget_value(widget);
    dval = ghb_value_double(value);
    ghb_value_free(value);
    return dval;
}
Ejemplo n.º 4
0
gchar*
ghb_widget_string(GtkWidget *widget)
{
    GValue *value;
    gchar *sval;

    value = ghb_widget_value(widget);
    sval = ghb_value_string(value);
    ghb_value_free(value);
    return sval;
}
Ejemplo n.º 5
0
G_MODULE_EXPORT void
audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
    // Add the current audio settings to the list.
    GValue *asettings;
    GtkWidget *widget;
    
    g_debug("audio_add_clicked_cb ()");
    asettings = ghb_dict_value_new();
    widget = GHB_WIDGET(ud->builder, "AudioTrack");
    ghb_settings_take_value(asettings, "AudioTrack", ghb_widget_value(widget));
    widget = GHB_WIDGET(ud->builder, "AudioEncoder");
    ghb_settings_take_value(asettings, "AudioEncoder", ghb_widget_value(widget));
    ghb_settings_set_value(asettings, "AudioEncoderActual", 
        ghb_settings_get_value(ud->settings, "AudioEncoderActual"));
    widget = GHB_WIDGET(ud->builder, "AudioTrackQualityEnable");
    ghb_settings_take_value(asettings, "AudioTrackQualityEnable", ghb_widget_value(widget));
    widget = GHB_WIDGET(ud->builder, "AudioTrackQuality");
    ghb_settings_take_value(asettings, "AudioTrackQuality", ghb_widget_value(widget));
    widget = GHB_WIDGET(ud->builder, "AudioBitrate");
    ghb_settings_take_value(asettings, "AudioBitrate", ghb_widget_value(widget));
    widget = GHB_WIDGET(ud->builder, "AudioSamplerate");
    ghb_settings_take_value(asettings, "AudioSamplerate", ghb_widget_value(widget));
    widget = GHB_WIDGET(ud->builder, "AudioMixdown");
    ghb_settings_take_value(asettings, "AudioMixdown", ghb_widget_value(widget));
    widget = GHB_WIDGET(ud->builder, "AudioTrackGain");
    ghb_settings_take_value(asettings, "AudioTrackGain", ghb_widget_value(widget));
    widget = GHB_WIDGET(ud->builder, "AudioTrackDRCSlider");
    ghb_settings_take_value(asettings, "AudioTrackDRCSlider", ghb_widget_value(widget));

    if (!ghb_add_audio_to_settings(ud->settings, asettings))
        return;

    ghb_add_audio_to_ui(ud->builder, asettings);
    check_list_full(ud);
}
Ejemplo n.º 6
0
void
ghb_widget_to_setting(GValue *settings, GtkWidget *widget)
{
    const gchar *key = NULL;
    GValue *value;

    if (widget == NULL) return;
    g_debug("ghb_widget_to_setting");
    // Find corresponding setting
    key = ghb_get_setting_key(widget);
    if (key == NULL) return;
    value = ghb_widget_value(widget);
    if (value != NULL)
    {
        ghb_settings_take_value(settings, key, value);
    }
    else
    {
        g_debug("No value found for %s\n", key);
    }
}
Ejemplo n.º 7
0
static void
x264_opt_update(signal_user_data_t *ud, GtkWidget *widget)
{
    gint jj;
    const gchar *name = ghb_get_setting_key(widget);
    gchar **opt_syns = NULL;
    const gchar *def_val = NULL;
    gint type;
    trans_table_t *trans;

    for (jj = 0; jj < X264_OPT_MAP_SIZE; jj++)
    {
        if (strcmp(name, x264_opt_map[jj].name) == 0)
        {
            // found the options that needs updating
            opt_syns = x264_opt_map[jj].opt_syns;
            def_val = x264_opt_map[jj].def_val;
            type = x264_opt_map[jj].type;
            trans = x264_opt_map[jj].translation;
            break;
        }
    }
    if (opt_syns != NULL)
    {
        GString *x264opts = g_string_new("");
        const gchar *options;
        gchar **split = NULL;
        gint ii;
        gboolean foundit = FALSE;

        options = ghb_dict_get_string(ud->settings, "x264Option");
        if (options)
        {
            split = g_strsplit(options, ":", -1);
        }
        for (ii = 0; split && split[ii] != NULL; ii++)
        {
            gint syn;
            gchar *val = NULL;
            gchar *pos = strchr(split[ii], '=');
            if (pos != NULL)
            {
                val = pos + 1;
                *pos = 0;
            }
            syn = find_syn_match(split[ii], opt_syns);
            if (syn >= 0)
            { // Updating this option
                gchar *val;
                foundit = TRUE;
                if (type == X264_OPT_DEBLOCK)
                    val = get_deblock_val(ud);
                else if (type == X264_OPT_PSY)
                    val = get_psy_val(ud);
                else
                {
                    GhbValue *gval;
                    gval = ghb_widget_value(widget);
                    if (ghb_value_type(gval) == GHB_BOOL)
                    {
                        if (ghb_value_get_bool(gval))
                            val = g_strdup("1");
                        else
                            val = g_strdup("0");
                    }
                    else
                    {
                        val = ghb_widget_string(widget);
                    }
                    ghb_value_free(&gval);
                }
                if (type == X264_OPT_TRANS)
                {
                    gchar *tmp;
                    tmp = g_strdup(trans_ui_val(trans, val));
                    if (tmp)
                    {
                        g_free(val);
                        val = tmp;
                    }
                }
                if (strcmp(def_val, val) != 0)
                {
                    g_string_append_printf(x264opts, "%s=%s:", opt_syns[syn], val);
                }
                g_free(val);
            }
            else if (val != NULL)
                g_string_append_printf(x264opts, "%s=%s:", split[ii], val);
            else
                g_string_append_printf(x264opts, "%s:", split[ii]);

        }
        if (split) g_strfreev(split);
        if (!foundit)
        {
            gchar *val;
            if (type == X264_OPT_DEBLOCK)
                val = get_deblock_val(ud);
            else if (type == X264_OPT_PSY)
                val = get_psy_val(ud);
            else
            {
                GhbValue *gval;
                gval = ghb_widget_value(widget);
                if (ghb_value_type(gval) == GHB_BOOL)
                {
                    if (ghb_value_get_bool(gval))
                        val = g_strdup("1");
                    else
                        val = g_strdup("0");
                }
                else
                {
                    val = ghb_widget_string(widget);
                }
                ghb_value_free(&gval);
            }
            if (type == X264_OPT_TRANS)
            {
                gchar *tmp;
                tmp = g_strdup(trans_ui_val(trans, val));
                if (tmp)
                {
                    g_free(val);
                    val = tmp;
                }
            }
            if (strcmp(def_val, val) != 0)
            {
                g_string_append_printf(x264opts, "%s=%s:", opt_syns[0], val);
            }
            g_free(val);
        }
        // Update the options value
        // strip the trailing ":"
        gchar *result;
        gint len;
        result = g_string_free(x264opts, FALSE);
        len = strlen(result);
        if (len > 0) result[len - 1] = 0;
        gchar *sopts;
        sopts = sanitize_x264opts(ud, result);
        ghb_update_x264Option(ud, sopts);
        ghb_x264_parse_options(ud, sopts);
        g_free(sopts);
        g_free(result);
    }
}
Ejemplo n.º 8
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);
}
Ejemplo n.º 9
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");
}