OSDN Git Service

LinGui: Picture Filter enhancements
[handbrake-jp/handbrake-jp-git.git] / gtk / src / queuehandler.c
index 6d56af7..05cae3b 100644 (file)
@@ -70,10 +70,11 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        gchar *dest, *preset, *vol_name, *basename;
        const gchar *vcodec, *container;
        gchar *fps, *vcodec_abbr;
-       gint title, start_chapter, end_chapter, width, height, vqvalue;
+       gint title, start_chapter, end_chapter, width, height;
        gint source_width, source_height;
        gboolean pass2, anamorphic, round_dim, keep_aspect, vqtype, turbo;
        gboolean tweaks;
+       gchar *escape;
        
        g_debug("update_queue_list ()");
        if (settings == NULL) return;
@@ -81,21 +82,24 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        store = GTK_TREE_STORE(gtk_tree_view_get_model(treeview));
                
        tweaks = ghb_settings_get_boolean(settings, "allow_tweaks");
-       title = ghb_settings_combo_int(settings, "title");
+       title = ghb_settings_get_int(settings, "titlenum");
        start_chapter = ghb_settings_get_int(settings, "start_chapter");
        end_chapter = ghb_settings_get_int(settings, "end_chapter");
-       pass2 = ghb_settings_get_boolean(settings, "two_pass");
+       pass2 = ghb_settings_get_boolean(settings, "VideoTwoPass");
        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);
        info = g_strdup_printf 
        (
                "<big><b>%s</b></big> "
                "<small>(Title %d, Chapters %d through %d, %d Video %s)"
                " --> %s</small>",
-                vol_name, title+1, start_chapter, end_chapter, 
-                pass2 ? 2:1, pass2 ? "Passes":"Pass", basename
+                vol_name, title, start_chapter, end_chapter, 
+                pass2 ? 2:1, pass2 ? "Passes":"Pass", escape
        );
+       g_free(basename);
+       g_free(escape);
 
        if (piter)
                iter = *piter;
@@ -130,16 +134,16 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        gint mux;
        const GValue *path;
 
-       container = ghb_settings_combo_option(settings, "container");
-       mux = ghb_settings_combo_int(settings, "container");
+       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, "chapter_markers");
+       markers = ghb_settings_get_boolean(settings, "ChapterMarkers");
 
        if (preset_modified)
                g_string_append_printf(str, 
-                       "<b>Customized Preset Based On:</b> <small>%s</small>\n", 
+                       "<b>Modified Preset Based On:</b> <small>%s</small>\n", 
                        preset);
        else
                g_string_append_printf(str, 
@@ -161,9 +165,9 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        {
                gboolean ipod, http, large;
 
-               ipod = ghb_settings_get_boolean(settings, "ipod_file");
-               http = ghb_settings_get_boolean(settings, "http_optimize_mp4");
-               large = ghb_settings_get_boolean(settings, "large_mp4");
+               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>");
@@ -176,14 +180,15 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
                        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", dest);
+               "<b>Destination:</b> <small>%s</small>\n", escape);
 
        width = ghb_settings_get_int(settings, "scale_width");
        height = ghb_settings_get_int(settings, "scale_height");
        anamorphic = ghb_settings_get_boolean(settings, "anamorphic");
-       round_dim = ghb_settings_get_boolean(settings, "round_dimensions");
-       keep_aspect = ghb_settings_get_boolean(settings, "keep_aspect");
+       round_dim = ghb_settings_get_boolean(settings, "ModDimensions");
+       keep_aspect = ghb_settings_get_boolean(settings, "PictureKeepRatio");
 
        gchar *aspect_desc;
        if (anamorphic)
@@ -209,39 +214,51 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
                }
        }
        vqtype = ghb_settings_get_boolean(settings, "vquality_type_constant");
-       vqvalue = 0;
 
        gchar *vq_desc = "Error";
        gchar *vq_units = "";
+       gchar *vqstr;
+       gdouble vqvalue;
        if (!vqtype)
        {
                vqtype = ghb_settings_get_boolean(settings, "vquality_type_target");
                if (!vqtype)
                {
                        // Has to be bitrate
-                       vqvalue = ghb_settings_get_int(settings, "video_bitrate");
+                       vqvalue = ghb_settings_get_int(settings, "VideoAvgBitrate");
                        vq_desc = "Bitrate:";
                        vq_units = "kbps";
                }
                else
                {
                        // Target file size
-                       vqvalue = ghb_settings_get_int(settings, "video_target_size");
+                       vqvalue = ghb_settings_get_int(settings, "VideoTargetSize");
                        vq_desc = "Target Size:";
                        vq_units = "MB";
                }
+               vqstr = g_strdup_printf("%d", (gint)vqvalue);
        }
        else
        {
                // Constant quality
-               vqvalue = ghb_settings_get_int(settings, "video_quality");
+               vqvalue = ghb_settings_get_double(settings, "VideoQualitySlider");
                vq_desc = "Constant Quality:";
+               if (ghb_settings_get_boolean(settings, "directqp"))
+               {
+                       vqstr = g_strdup_printf("%d", (gint)vqvalue);
+                       vq_units = "(crf)";
+               }
+               else
+               {
+                       vqstr = g_strdup_printf("%.1f", 100*vqvalue);
+                       vq_units = "%";
+               }
        }
-       fps = ghb_settings_get_string(settings, "framerate");
+       fps = ghb_settings_get_string(settings, "VideoFramerate");
        if (strcmp("source", fps) == 0)
        {
                g_free(fps);
-               if (ghb_settings_get_boolean(settings, "detelecine"))
+               if (ghb_settings_combo_int(settings, "PictureDetelecine"))
                        fps = g_strdup("Same As Source (vfr detelecine)");
                else
                        fps = g_strdup("Same As Source (variable)");
@@ -253,8 +270,8 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
                g_free(fps);
                fps = tmp;
        }
-       vcodec = ghb_settings_combo_option(settings, "video_codec");
-       vcodec_abbr = ghb_settings_get_string(settings, "video_codec");
+       vcodec = ghb_settings_combo_option(settings, "VideoEncoder");
+       vcodec_abbr = ghb_settings_get_string(settings, "VideoEncoder");
        source_width = ghb_settings_get_int(settings, "source_width");
        source_height = ghb_settings_get_int(settings, "source_height");
        g_string_append_printf(str,
@@ -264,9 +281,9 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        gboolean decomb;
        gboolean filters = FALSE;
 
-       decomb = ghb_settings_get_boolean(settings, "decomb");
+       decomb = ghb_settings_combo_int(settings, "PictureDecomb");
        g_string_append_printf(str, "<b>Filters:</b><small>");
-       if (ghb_settings_get_boolean(settings, "detelecine"))
+       if (ghb_settings_combo_int(settings, "PictureDetelecine"))
        {
                g_string_append_printf(str, " - Detelecine");
                filters = TRUE;
@@ -278,32 +295,30 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        }
        else
        {
-               gint deint = ghb_settings_combo_int(settings, 
-                                       tweaks ? "tweak_deinterlace":"deinterlace");
+               gint deint = ghb_settings_combo_int(settings, "PictureDeinterlace");
                if (deint)
                {
                        const gchar *opt = ghb_settings_combo_option(settings,
-                                       tweaks ? "tweak_deinterlace":"deinterlace");
+                                                                                                       "PictureDeinterlace");
                        g_string_append_printf(str, " - Deinterlace: %s", opt);
                        filters = TRUE;
                }
        }
-       gint denoise = ghb_settings_combo_int(settings, 
-                               tweaks ? "tweak_denoise":"denoise");
+       gint denoise = ghb_settings_combo_int(settings, "PictureDenoise");
        if (denoise)
        {
                const gchar *opt = ghb_settings_combo_option(settings,
-                               tweaks ? "tweak_denoise":"denoise");
+                                                                                                       "PictureDenoise");
                g_string_append_printf(str, " - Denoise: %s", opt);
                filters = TRUE;
        }
-       gint deblock = ghb_settings_get_int(settings, "deblock");
+       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, "grayscale"))
+       if (ghb_settings_get_boolean(settings, "VideoGrayScale"))
        {
                g_string_append_printf(str, " - Grayscale");
                filters = TRUE;
@@ -313,10 +328,10 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        g_string_append_printf(str, "</small>\n");
 
        g_string_append_printf(str,
-               "<b>Video:</b> <small>%s, Framerate: %s, %s %d%s</small>\n",
-                vcodec, fps, vq_desc, vqvalue, vq_units);
+               "<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, "turbo");
+       turbo = ghb_settings_get_boolean(settings, "VideoTurboTwoPass");
        if (turbo)
        {
                g_string_append_printf(str, "<b>Turbo:</b> <small>On</small>\n");
@@ -342,16 +357,16 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
 
                asettings = ghb_array_get_nth(audio_list, ii);
 
-               acodec = ghb_settings_combo_option(asettings, "audio_codec");
-               bitrate = ghb_settings_get_string(asettings, "audio_bitrate");
-               samplerate = ghb_settings_get_string(asettings, "audio_rate");
+               acodec = ghb_settings_combo_option(asettings, "AudioEncoder");
+               bitrate = ghb_settings_get_string(asettings, "AudioBitrate");
+               samplerate = ghb_settings_get_string(asettings, "AudioSamplerate");
                if (strcmp("source", samplerate) == 0)
                {
                        g_free(samplerate);
                        samplerate = g_strdup("Same As Source");
                }
-               track = ghb_settings_get_string(asettings, "audio_track_long");
-               mix = ghb_settings_combo_option(asettings, "audio_mix");
+               track = ghb_settings_get_string(asettings, "AudioTrackDescription");
+               mix = ghb_settings_combo_option(asettings, "AudioMixdown");
                g_string_append_printf(str,
                        "<b>Audio:</b><small> %s, Encoder: %s, Mixdown: %s, SampleRate: %s, Bitrate: %s</small>",
                         track, acodec, mix, samplerate, bitrate);
@@ -372,25 +387,6 @@ add_to_queue_list(signal_user_data_t *ud, GValue *settings, GtkTreeIter *piter)
        g_free(preset);
 }
 
-static gint64
-estimate_file_size(signal_user_data_t *ud)
-{
-       ghb_title_info_t tinfo;
-       gint duration;
-       gint bitrate;
-       gint64 size;
-       gint titleindex;
-
-       titleindex = ghb_settings_combo_int(ud->settings, "title");
-       if (titleindex < 0) return 0;
-                       
-       if (!ghb_get_title_info(&tinfo, titleindex)) return 0;
-       duration = ((tinfo.hours*60)+tinfo.minutes)*60+tinfo.seconds;
-       bitrate = ghb_guess_bitrate(ud->settings);
-       size = (gint64)duration * (gint64)bitrate/8;
-       return size;
-}
-
 void
 audio_list_refresh(signal_user_data_t *ud)
 {
@@ -399,7 +395,7 @@ audio_list_refresh(signal_user_data_t *ud)
        GtkListStore *store;
        gboolean done;
        gint row = 0;
-       GValue *audio_list;
+       const GValue *audio_list;
 
        g_debug("ghb_audio_list_refresh ()");
        treeview = GTK_TREE_VIEW(GHB_WIDGET(ud->builder, "audio_list"));
@@ -418,19 +414,19 @@ audio_list_refresh(signal_user_data_t *ud)
                                return;
                        asettings = ghb_array_get_nth(audio_list, row);
 
-                       track = ghb_settings_combo_option(asettings, "audio_track");
-                       codec = ghb_settings_combo_option(asettings, "audio_codec");
-                       br = ghb_settings_combo_option(asettings, "audio_bitrate");
-                       sr = ghb_settings_combo_option(asettings, "audio_rate");
-                       mix = ghb_settings_combo_option(asettings, "audio_mix");
-                       drc = ghb_settings_get_string(asettings, "audio_drc");
+                       track = ghb_settings_combo_option(asettings, "AudioTrack");
+                       codec = ghb_settings_combo_option(asettings, "AudioEncoder");
+                       br = ghb_settings_combo_option(asettings, "AudioBitrate");
+                       sr = ghb_settings_combo_option(asettings, "AudioSamplerate");
+                       mix = ghb_settings_combo_option(asettings, "AudioMixdown");
+                       drc = ghb_settings_get_string(asettings, "AudioTrackDRCSlider");
 
-                       s_track = ghb_settings_get_string(asettings, "audio_track");
-                       s_codec = ghb_settings_get_string(asettings, "audio_codec");
-                       s_br = ghb_settings_get_string(asettings, "audio_bitrate");
-                       s_sr = ghb_settings_get_string(asettings, "audio_rate");
-                       s_mix = ghb_settings_get_string(asettings, "audio_mix");
-                       s_drc = ghb_settings_get_double(asettings, "audio_drc");
+                       s_track = ghb_settings_get_string(asettings, "AudioTrack");
+                       s_codec = ghb_settings_get_string(asettings, "AudioEncoder");
+                       s_br = ghb_settings_get_string(asettings, "AudioBitrate");
+                       s_sr = ghb_settings_get_string(asettings, "AudioSamplerate");
+                       s_mix = ghb_settings_get_string(asettings, "AudioMixdown");
+                       s_drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
 
                        gtk_list_store_set(GTK_LIST_STORE(store), &iter, 
                                // These are displayed in list
@@ -539,7 +535,7 @@ validate_settings(signal_user_data_t *ud)
                        size = g_file_info_get_attribute_uint64(info, 
                                                                        G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
                        
-                       gint64 fsize = estimate_file_size(ud);
+                       gint64 fsize = (guint64)10 * 1024 * 1024 * 1024;
                        if (size < fsize)
                        {
                                message = g_strdup_printf(
@@ -592,11 +588,6 @@ validate_settings(signal_user_data_t *ud)
        {
                return FALSE;
        }
-       // Validate container settings
-       if (!ghb_validate_container(ud))
-       {
-               return FALSE;
-       }
        // Validate filter settings
        if (!ghb_validate_filters(ud))
        {
@@ -1009,6 +1000,14 @@ ghb_reload_queue(signal_user_data_t *ud)
        gchar *message;
 
        g_debug("ghb_reload_queue");
+
+       // I really shouldn't have to do this, but at startup the
+       // initial window size is larger than it should be.  This
+       // make it adjust to the proper size.
+       GtkWindow *hb_window;
+       hb_window = GTK_WINDOW(GHB_WIDGET (ud->builder, "hb_window"));
+       gtk_window_resize(hb_window, 16, 16);
+
        queue = ghb_load_queue();
        // Look for unfinished entries
        count = ghb_array_len(queue);