static void
ghb_add_audio_to_ui(GtkBuilder *builder, const GValue *settings)
{
    GtkTreeView *treeview;
    GtkTreeIter iter;
    GtkListStore *store;
    GtkTreeSelection *selection;
    const gchar *track, *codec, *br = NULL, *sr, *mix;
    gchar *s_drc, *s_gain, *s_quality = NULL;
    gdouble drc;
    gdouble gain;
    
    g_debug("ghb_add_audio_to_ui ()");
    treeview = GTK_TREE_VIEW(GHB_WIDGET(builder, "audio_list"));
    selection = gtk_tree_view_get_selection (treeview);
    store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));

    track = ghb_settings_combo_option(settings, "AudioTrack");
    codec = ghb_settings_combo_option(settings, "AudioEncoderActual");
    double quality = ghb_settings_get_double(settings, "AudioTrackQuality");
    if (ghb_settings_get_boolean(settings, "AudioTrackQualityEnable") &&
        quality != HB_INVALID_AUDIO_QUALITY)
    {
        int codec = ghb_settings_combo_int(settings, "AudioEncoderActual");
        s_quality = ghb_format_quality("Q/", codec, quality);
    }
    else
    {
        br = ghb_settings_combo_option(settings, "AudioBitrate");
    }
    sr = ghb_settings_combo_option(settings, "AudioSamplerate");
    mix = ghb_settings_combo_option(settings, "AudioMixdown");
    gain = ghb_settings_get_double(settings, "AudioTrackGain");
    s_gain = g_strdup_printf("%ddB", (int)gain);

    drc = ghb_settings_get_double(settings, "AudioTrackDRCSlider");
    if (drc < 1.0)
        s_drc = g_strdup("Off");
    else
        s_drc = g_strdup_printf("%.1f", drc);

    gtk_list_store_append(store, &iter);
    gtk_list_store_set(store, &iter, 
        // These are displayed in list
        0, track,
        1, codec,
        2, s_quality ? s_quality : br,
        3, sr,
        4, mix,
        5, s_gain,
        6, s_drc,
        -1);
    gtk_tree_selection_select_iter(selection, &iter);
    g_free(s_drc);
    g_free(s_gain);
    g_free(s_quality);
}
Exemple #2
0
gchar*
get_psy_val(signal_user_data_t *ud)
{
    gdouble rd, trell;
    gchar *result;
    rd = ghb_settings_get_double(ud->x264_priv, "x264_psy_rd");
    trell = ghb_settings_get_double(ud->x264_priv, "x264_psy_trell");
    result = g_strdup_printf("%g|%g", rd, trell);
    return result;
}
Exemple #3
0
static void
add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
{
    GtkTreeView *treeview;
    GtkTreeIter iter;
    GtkTreeStore *store;
    gchar *info;
    gint status;
    GtkTreeIter citer;
    gchar *dest, *preset, *vol_name, *basename;
    const gchar *vcodec, *container;
    gchar *fps, *vcodec_abbr;
    gint title, start_point, end_point, width, height;
    gint source_width, source_height;
    gboolean pass2 = FALSE, keep_aspect, vqtype, turbo;
    gint pic_par;
    gchar *escape, *escape2;
    
    g_debug("update_queue_list ()");
    if (settings == NULL) return;
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "queue_list"));
    store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
        
    title = ghb_settings_get_int(settings, "titlenum");
    start_point = ghb_settings_get_int(settings, "start_point");
    end_point = ghb_settings_get_int(settings, "end_point");
    vol_name = ghb_settings_get_string(settings, "volume_label");
    dest = ghb_settings_get_string(settings, "destination");
    basename = g_path_get_basename(dest);
    escape = g_markup_escape_text(basename, -1);
    escape2 = g_markup_escape_text(vol_name, -1);

    vqtype = ghb_settings_get_boolean(settings, "vquality_type_constant");
    if (!vqtype)
        pass2 = ghb_settings_get_boolean(settings, "VideoTwoPass");
    const gchar *points = "Chapters";
    if (ghb_settings_combo_int(settings, "PtoPType") == 0)
        points = "Chapters";
    else if (ghb_settings_combo_int(settings, "PtoPType") == 1)
        points = "Seconds";
    else if (ghb_settings_combo_int(settings, "PtoPType") == 2)
        points = "Frames";
    info = g_strdup_printf 
    (
        "<big><b>%s</b></big> "
        "<small>(Title %d, %s %d through %d, %d Video %s)"
        " --> %s</small>",
         escape2, title, points, start_point, end_point, 
         pass2 ? 2:1, pass2 ? "Passes":"Pass", escape
    );
    g_free(basename);
    g_free(escape);
    g_free(escape2);

    if (piter)
        iter = *piter;
    else
        gtk_tree_store_append(store, &iter, NULL);

    gtk_tree_store_set(store, &iter, 1, info, 2, "hb-queue-delete", -1);
    g_free(info);
    status = ghb_settings_get_int(settings, "job_status");
    switch (status)
    {
        case GHB_QUEUE_PENDING:
            gtk_tree_store_set(store, &iter, 0, "hb-queue-job", -1);
            break;
        case GHB_QUEUE_CANCELED:
            gtk_tree_store_set(store, &iter, 0, "hb-canceled", -1);
            break;
        case GHB_QUEUE_RUNNING:
            gtk_tree_store_set(store, &iter, 0, "hb-working0", -1);
            break;
        case GHB_QUEUE_DONE:
            gtk_tree_store_set(store, &iter, 0, "hb-complete", -1);
            break;
        default:
            gtk_tree_store_set(store, &iter, 0, "hb-queue-job", -1);
            break;
    }

    GString *str = g_string_new("");
    gboolean markers;
    gboolean preset_modified;
    gint mux;
    const GValue *path;

    container = ghb_settings_combo_option(settings, "FileFormat");
    mux = ghb_settings_combo_int(settings, "FileFormat");
    preset_modified = ghb_settings_get_boolean(settings, "preset_modified");
    path = ghb_settings_get_value(settings, "preset");
    preset = ghb_preset_path_string(path);
    markers = ghb_settings_get_boolean(settings, "ChapterMarkers");

    if (preset_modified)
        g_string_append_printf(str, 
            "<b>Modified Preset Based On:</b> <small>%s</small>\n", 
            preset);
    else
        g_string_append_printf(str, 
            "<b>Preset:</b> <small>%s</small>\n", 
            preset);

    if (markers)
    {
        g_string_append_printf(str, 
            "<b>Format:</b> <small>%s Container, Chapter Markers</small>\n", 
            container);
    }
    else
    {
        g_string_append_printf(str, 
            "<b>Format:</b> <small>%s Container</small>\n", container);
    }
    if (mux == HB_MUX_MP4)
    {
        gboolean ipod, http, large;

        ipod = ghb_settings_get_boolean(settings, "Mp4iPodCompatible");
        http = ghb_settings_get_boolean(settings, "Mp4HttpOptimize");
        large = ghb_settings_get_boolean(settings, "Mp4LargeFile");
        if (http || ipod || large)
        {
            g_string_append_printf(str, "<b>MP4 Options:</b><small>");
            if (ipod)
                g_string_append_printf(str, " - iPod 5G Support");
            if (http)
                g_string_append_printf(str, " - Web Optimized");
            if (large)
                g_string_append_printf(str, " - Large File Size (>4GB)");
            g_string_append_printf(str, "</small>\n");
        }
    }
    escape = g_markup_escape_text(dest, -1);
    g_string_append_printf(str, 
        "<b>Destination:</b> <small>%s</small>\n", escape);

    width = ghb_settings_get_int(settings, "scale_width");
    height = ghb_settings_get_int(settings, "scale_height");
    pic_par = ghb_settings_combo_int(settings, "PicturePAR");
    keep_aspect = ghb_settings_get_boolean(settings, "PictureKeepRatio");

    gchar *aspect_desc;
    switch (pic_par)
    {
    case 0:
    {
        if (keep_aspect)
        {
            aspect_desc = "(Aspect Preserved)";
        }
        else
        {
            aspect_desc = "(Aspect Lost)";
        }
    } break;

    case 1:
    {
        aspect_desc = "(Strict Anamorphic)";
    } break;

    case 2:
    {
        aspect_desc = "(Loose Anamorphic)";
    } break;

    case 3:
    {
        aspect_desc = "(Custom Anamorphic)";
    } break;

    default:
    {
        aspect_desc = "(Unknown)";
    } break;
    }
    vqtype = ghb_settings_get_boolean(settings, "vquality_type_constant");
    vcodec = ghb_settings_combo_option(settings, "VideoEncoder");
    vcodec_abbr = ghb_settings_get_string(settings, "VideoEncoder");

    gchar *vq_desc = "Error";
    gchar *vq_units = "";
    gchar *vqstr;
    gdouble vqvalue;
    if (!vqtype)
    {
        // Has to be bitrate
        vqvalue = ghb_settings_get_int(settings, "VideoAvgBitrate");
        vq_desc = "Bitrate:";
        vq_units = "kbps";
        vqstr = g_strdup_printf("%d", (gint)vqvalue);
    }
    else
    {
        // Constant quality
        vqvalue = ghb_settings_get_double(settings, "VideoQualitySlider");
        vq_desc = "Constant Quality:";
        vqstr = g_strdup_printf("%d", (gint)vqvalue);
        if (strcmp(vcodec_abbr, "x264") == 0)
        {
            vq_units = "(RF)";
        }
        else
        {
            vq_units = "(QP)";
        }
    }
    fps = ghb_settings_get_string(settings, "VideoFramerate");
    if (strcmp("source", fps) == 0)
    {
        g_free(fps);
        if (ghb_settings_get_boolean(settings, "VideoFramerateCFR"))
            fps = g_strdup("Same As Source (constant)");
        else
            fps = g_strdup("Same As Source (variable)");
    }
    else
    {
        if (ghb_settings_get_boolean(settings, "VideoFrameratePFR"))
        {
            gchar *tmp;
            tmp = g_strdup_printf("Peak %s (may be lower)", fps);
            g_free(fps);
            fps = tmp;
        }
        else
        {
            gchar *tmp;
            tmp = g_strdup_printf("%s (constant frame rate)", fps);
            g_free(fps);
            fps = tmp;
        }
    }
    source_width = ghb_settings_get_int(settings, "source_width");
    source_height = ghb_settings_get_int(settings, "source_height");
    g_string_append_printf(str,
        "<b>Picture:</b> Source: <small>%d x %d, Output %d x %d %s</small>\n",
         source_width, source_height, width, height, aspect_desc);

    gint decomb, detel;
    gboolean decomb_deint;
    gboolean filters = FALSE;

    decomb_deint = ghb_settings_get_boolean(settings, "PictureDecombDeinterlace");
    decomb = ghb_settings_combo_int(settings, "PictureDecomb");
    g_string_append_printf(str, "<b>Filters:</b><small>");
    detel = ghb_settings_combo_int(settings, "PictureDetelecine");
    if (detel)
    {
        g_string_append_printf(str, " - Detelecine");
        if (detel == 1)
        {
            gchar *cust;
            cust = ghb_settings_get_string(settings, "PictureDetelecineCustom");
            g_string_append_printf(str, ": %s", cust);
            g_free(cust);
        }
        filters = TRUE;
    }
    if (decomb_deint && decomb)
    {
        g_string_append_printf(str, " - Decomb");
        if (decomb == 1)
        {
            gchar *cust;
            cust = ghb_settings_get_string(settings, "PictureDecombCustom");
            g_string_append_printf(str, ": %s", cust);
            g_free(cust);
        }
        filters = TRUE;
    }
    else if (!decomb_deint)
    {
        gint deint = ghb_settings_combo_int(settings, "PictureDeinterlace");
        if (deint)
        {
            if (deint == 1)
            {
                gchar *cust = ghb_settings_get_string(settings,
                                                "PictureDeinterlaceCustom");
                g_string_append_printf(str, " - Deinterlace: %s", cust);
                g_free(cust);
            }
            else
            {
                const gchar *opt = ghb_settings_combo_option(settings,
                                                    "PictureDeinterlace");
                g_string_append_printf(str, " - Deinterlace: %s", opt);
            }
            filters = TRUE;
        }
    }
    gint denoise = ghb_settings_combo_int(settings, "PictureDenoise");
    if (denoise)
    {
        if (denoise == 1)
        {
            gchar *cust = ghb_settings_get_string(settings,
                                                    "PictureDenoiseCustom");
            g_string_append_printf(str, " - Denoise: %s", cust);
            g_free(cust);
        }
        else
        {
            const gchar *opt = ghb_settings_combo_option(settings,
                                                    "PictureDenoise");
            g_string_append_printf(str, " - Denoise: %s", opt);
        }
        filters = TRUE;
    }
    gint deblock = ghb_settings_get_int(settings, "PictureDeblock");
    if (deblock >= 5)
    {
        g_string_append_printf(str, " - Deblock (%d)", deblock);
        filters = TRUE;
    }
    if (ghb_settings_get_boolean(settings, "VideoGrayScale"))
    {
        g_string_append_printf(str, " - Grayscale");
        filters = TRUE;
    }
    if (!filters)
        g_string_append_printf(str, " None");
    g_string_append_printf(str, "</small>\n");

    g_string_append_printf(str,
        "<b>Video:</b> <small>%s, Framerate: %s, %s %s%s</small>\n",
         vcodec, fps, vq_desc, vqstr, vq_units);

    turbo = ghb_settings_get_boolean(settings, "VideoTurboTwoPass");
    if (turbo)
    {
        g_string_append_printf(str, "<b>Turbo:</b> <small>On</small>\n");
    }
    if (strcmp(vcodec_abbr, "x264") == 0 ||
        strcmp(vcodec_abbr, "ffmpeg") == 0)
    {
        gchar *opts = ghb_build_advanced_opts_string(settings);
        g_string_append_printf(str, 
            "<b>Advanced Options:</b> <small>%s</small>\n", opts);
        g_free(opts);
    }
    // Add the audios
    gint count, ii;
    const GValue *audio_list;

    audio_list = ghb_settings_get_value(settings, "audio_list");
    count = ghb_array_len(audio_list);
    for (ii = 0; ii < count; ii++)
    {
        gchar *quality = NULL, *samplerate, *track;
        const gchar *acodec, *mix;
        GValue *asettings;
        gdouble sr;

        asettings = ghb_array_get_nth(audio_list, ii);

        acodec = ghb_settings_combo_option(asettings, "AudioEncoderActual");
        double q = ghb_settings_get_double(asettings, "AudioTrackQuality");
        if (ghb_settings_get_boolean(asettings, "AudioTrackQualityEnable") &&
            q != HB_INVALID_AUDIO_QUALITY)
        {
            int codec = ghb_settings_combo_int(asettings, "AudioEncoderActual");
            quality = ghb_format_quality("Quality: ", codec, q);
        }
        else
        {
            const char *br;
            br = ghb_settings_get_string(asettings, "AudioBitrate");
            quality = g_strdup_printf("Bitrate: %s", br);
        }
        sr = ghb_settings_get_double(asettings, "AudioSamplerate");
        samplerate = ghb_settings_get_string(asettings, "AudioSamplerate");
        if ((int)sr == 0)
        {
            samplerate = g_strdup("Same As Source");
        }
        else
        {
            samplerate = g_strdup_printf("%.4g", sr);
        }
        track = ghb_settings_get_string(asettings, "AudioTrackDescription");
        mix = ghb_settings_combo_option(asettings, "AudioMixdown");
        if (count == 1)
            g_string_append_printf(str, "<b>Audio:</b>");
        else if (ii == 0)
            g_string_append_printf(str, "<b>Audio:</b>\n");
        if (count != 1)
            g_string_append_printf(str, "\t");

        g_string_append_printf(str,
            "<small> %s, Encoder: %s, Mixdown: %s, SampleRate: %s, %s</small>\n",
             track, acodec, mix, samplerate, quality);
        g_free(track);
        g_free(quality);
        g_free(samplerate);
    }

    // Add the audios
    const GValue *sub_list;

    sub_list = ghb_settings_get_value(settings, "subtitle_list");
    count = ghb_array_len(sub_list);
    for (ii = 0; ii < count; ii++)
    {
        GValue *settings;
        gchar *track;
        gboolean force, burn, def;
        gint source;

        settings = ghb_array_get_nth(sub_list, ii);
        track = ghb_settings_get_string(settings, "SubtitleTrackDescription");
        source = ghb_settings_get_int(settings, "SubtitleSource");
        force = ghb_settings_get_boolean(settings, "SubtitleForced");
        burn = ghb_settings_get_boolean(settings, "SubtitleBurned");
        def = ghb_settings_get_boolean(settings, "SubtitleDefaultTrack");
        if (count == 1)
            g_string_append_printf(str, "<b>Subtitle:</b>");
        else if (ii == 0)
            g_string_append_printf(str, "<b>Subtitles:</b>\n");
        if (count != 1)
            g_string_append_printf(str, "\t");

        if (source != SRTSUB)
        {
            g_string_append_printf(str,
                "<small> %s%s%s%s</small>",
                track, 
                force ? " (Force)":"",
                burn  ? " (Burn)":"",
                def   ? " (Default)":""
            );
        }
        else
        {
            gint offset;
            gchar *filename, *basename, *code;

            offset = ghb_settings_get_int(settings, "SrtOffset");
            filename = ghb_settings_get_string(settings, "SrtFile");
            basename = g_path_get_basename(filename);
            code = ghb_settings_get_string(settings, "SrtCodeset");
            g_string_append_printf(str,
                "<small> %s (%s), %s, Offset (ms) %d%s</small>",
                track, code, basename, offset,
                def   ? " (Default)":""
            );
            g_free(filename);
            g_free(basename);
            g_free(code);
        }
        if (ii < count-1)
            g_string_append_printf(str, "\n");
        g_free(track);
    }

    info = g_string_free(str, FALSE);
    gtk_tree_store_append(store, &citer, &iter);
    gtk_tree_store_set(store, &citer, 1, info, -1);
    g_free(info);
    g_free(fps);
    g_free(vcodec_abbr);
    g_free(vol_name);
    g_free(dest);
    g_free(preset);
}
void
ghb_audio_list_refresh(signal_user_data_t *ud)
{
    GtkTreeView *treeview;
    GtkTreeIter iter;
    GtkListStore *store;
    gboolean done;
    gint row = 0;
    const GValue *audio_list;

    g_debug("ghb_audio_list_refresh ()");
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
    store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview));
    if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
    {
        do
        {
            const gchar *track, *codec, *br = NULL, *sr, *mix;
            gchar *s_drc, *s_gain, *s_quality = NULL;
            gdouble drc, gain;
            GValue *asettings;

            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);

            track = ghb_settings_combo_option(asettings, "AudioTrack");
            codec = ghb_settings_combo_option(asettings, "AudioEncoderActual");
            double quality = ghb_settings_get_double(asettings, "AudioTrackQuality");
            if (ghb_settings_get_boolean(asettings, "AudioTrackQualityEnable") &&
                quality != HB_INVALID_AUDIO_QUALITY)
            {
                int codec = ghb_settings_combo_int(asettings, "AudioEncoderActual");
                s_quality = ghb_format_quality("Q/", codec, quality);
            }
            else
            {
                br = ghb_settings_get_string(asettings, "AudioBitrate");
            }
            sr = ghb_settings_combo_option(asettings, "AudioSamplerate");
            mix = ghb_settings_combo_option(asettings, "AudioMixdown");
            gain = ghb_settings_get_double(asettings, "AudioTrackGain");
            s_gain = g_strdup_printf("%.fdB", gain);

            drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
            if (drc < 1.0)
                s_drc = g_strdup("Off");
            else
                s_drc = g_strdup_printf("%.1f", drc);

            gtk_list_store_set(GTK_LIST_STORE(store), &iter, 
                // These are displayed in list
                0, track,
                1, codec,
                2, s_quality ? s_quality : br,
                3, sr,
                4, mix,
                5, s_gain,
                6, s_drc,
                -1);
            g_free(s_drc);
            g_free(s_gain);
            done = !gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
            row++;
        } while (!done);
    }
}
void
ghb_audio_list_refresh_selected(signal_user_data_t *ud)
{
    GtkTreeView *treeview;
    GtkTreePath *treepath;
    GtkTreeSelection *selection;
    GtkTreeModel *store;
    GtkTreeIter iter;
    gint *indices;
    gint row;
    GValue *asettings = NULL;
    const GValue *audio_list;
    
    g_debug("ghb_audio_list_refresh_selected ()");
    treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
    selection = gtk_tree_view_get_selection (treeview);
    if (gtk_tree_selection_get_selected(selection, &store, &iter))
    {
        const gchar *track, *codec, *br = NULL, *sr, *mix;
        gchar *s_drc, *s_gain, *s_quality = NULL;
        gdouble drc, gain;
        // 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);

        track = ghb_settings_combo_option(asettings, "AudioTrack");
        codec = ghb_settings_combo_option(asettings, "AudioEncoderActual");
        double quality = ghb_settings_get_double(asettings, "AudioTrackQuality");
        if (ghb_settings_get_boolean(asettings, "AudioTrackQualityEnable") &&
            quality != HB_INVALID_AUDIO_QUALITY)
        {
            int codec = ghb_settings_combo_int(asettings, "AudioEncoderActual");
            s_quality = ghb_format_quality("Q/", codec, quality);
        }
        else
        {
            br = ghb_settings_combo_option(asettings, "AudioBitrate");
        }
        sr = ghb_settings_combo_option(asettings, "AudioSamplerate");
        mix = ghb_settings_combo_option(asettings, "AudioMixdown");
        gain = ghb_settings_get_double(asettings, "AudioTrackGain");
        s_gain = g_strdup_printf("%ddB", (int)gain);

        drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
        if (drc < 1.0)
            s_drc = g_strdup("Off");
        else
            s_drc = g_strdup_printf("%.1f", drc);

        gtk_list_store_set(GTK_LIST_STORE(store), &iter, 
            // These are displayed in list
            0, track,
            1, codec,
            2, s_quality ? s_quality : br,
            3, sr,
            4, mix,
            5, s_gain,
            6, s_drc,
            -1);
        g_free(s_drc);
        g_free(s_gain);
        g_free(s_quality);
    }
}
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);
}