]> granicus.if.org Git - handbrake/commitdiff
LinGui: add hidden preset option to allow direct QP/CRF entry for ffmpeg and
authorjstebbins <jstebbins.hb@gmail.com>
Tue, 1 Jul 2008 22:56:09 +0000 (22:56 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Tue, 1 Jul 2008 22:56:09 +0000 (22:56 +0000)
x264.  just add "directqp=enable" to a custom preset.  custom preset file
is ~/.config/ghb/custom_presets

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1549 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/callbacks.c
gtk/src/ghb.ui
gtk/src/hb-backend.c
gtk/src/hb-backend.h
gtk/src/internal_defaults
gtk/src/internal_defaults.h

index ce40e299855f056d4d11838954d53164a333cefd..13b23f8ec4483c5c25a218485b82a0097653c98c 100644 (file)
@@ -1211,6 +1211,19 @@ setting_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
        clear_presets_selection(ud);
 }
 
+void
+vcodec_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
+{
+       gint vqmin, vqmax;
+
+       ghb_widget_to_setting(ud->settings, widget);
+       check_depencency(ud, widget);
+       clear_presets_selection(ud);
+       ghb_vquality_range(ud, &vqmin, &vqmax);
+       GtkWidget *qp = GHB_WIDGET(ud->builder, "video_quality");
+       gtk_range_set_range (GTK_RANGE(qp), vqmin, vqmax);
+}
+
 void
 vfr_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
 {
@@ -1949,6 +1962,11 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
                        sensitive = TRUE;
                }
                ud->dont_clear_presets = TRUE;
+               // Temporarily set the video_quality range to (0,100)
+               // This is needed so the video_quality value does not get
+               // truncated when set.  The range will be readjusted below
+               GtkWidget *qp = GHB_WIDGET(ud->builder, "video_quality");
+               gtk_range_set_range (GTK_RANGE(qp), 0, 100);
                ghb_set_preset(ud, preset);
                gint titleindex = ghb_settings_get_int(ud->settings, "title");
                set_pref_audio(titleindex, ud);
@@ -1958,6 +1976,10 @@ presets_list_selection_changed_cb(GtkTreeSelection *selection, signal_user_data_
                        preset_update_title_deps(ud, &tinfo);
                }
                ghb_set_scale (ud, GHB_SCALE_KEEP_NONE);
+
+               gint vqmin, vqmax;
+               ghb_vquality_range(ud, &vqmin, &vqmax);
+               gtk_range_set_range (GTK_RANGE(qp), vqmin, vqmax);
        }
        else
        {
index 64a25f6b4b394e61e47ddf01df70d9e05e20ea79..9314684ea50940a1b4fc0820447a9f8b608a5960 100644 (file)
                                             <child>
                                               <object class="GtkComboBox" id="video_codec">
                                                 <property name="visible">True</property>
-                                                <signal handler="setting_widget_changed_cb" name="changed"/>
+                                                <signal handler="vcodec_changed_cb" name="changed"/>
                                               </object>
                                             </child>
                                           </object>
index c5c9b6285029d30da9bfbc4ece0cadebb9ff6bdb..c36e182ed5f6faa320a3a4feb75cdde86b4a2695 100644 (file)
@@ -439,6 +439,36 @@ ghb_version()
        return HB_VERSION;
 }
 
+void
+ghb_vquality_range(signal_user_data_t *ud, gint *min, gint *max)
+{
+       if (ghb_settings_get_bool(ud->settings, "directqp"))
+       {
+               gint vcodec = ghb_settings_get_int(ud->settings, "video_codec");
+               // Only x264 and ffmpeg currently support direct qp/crf entry
+               if (vcodec == HB_VCODEC_X264)
+               {
+                       *min = 0;
+                       *max = 51;
+               }
+               else if (vcodec == HB_VCODEC_FFMPEG)
+               {
+                       *min = 0;
+                       *max = 31;
+               }
+               else
+               {
+                       *min = 0;
+                       *max = 100;
+               }
+       }
+       else
+       {
+               *min = 0;
+               *max = 100;
+       }
+}
+
 static setting_value_t*
 get_acodec_value(gint val)
 {
@@ -1889,13 +1919,8 @@ ghb_set_scale(signal_user_data_t *ud, gint mode)
        {
                width = crop_width;
                height = crop_height;
-#if defined(ALLOW_UPSCALE)
-               max_width = 0;
-               max_height = 0;
-#else
                max_width = crop_width;
                max_height = crop_height;
-#endif
        }
        else
        {
@@ -1913,19 +1938,7 @@ ghb_set_scale(signal_user_data_t *ud, gint mode)
                }
                if (!max_width)
                {
-#if defined(ALLOW_UPSCALE)
-                       if (anamorphic)
-                       {
-                               max_width = crop_width;
-                       }
-                       else
-                       {
-                               gdouble par = (gdouble)(title->height * aspect_n) / (title->width * aspect_d);
-                               max_width = (crop_width * ((gdouble)max_height/crop_height) * par);
-                       }
-#else
                        max_width = crop_width;
-#endif
                }
                height = MIN(height, max_height);
                width = MIN(width, max_width);
@@ -2311,45 +2324,59 @@ ghb_validate_vquality(GHashTable *settings)
 {
        gint vcodec;
        gchar *message;
+       gint min, max;
 
        if (ghb_settings_get_bool(settings, "nocheckvquality")) return TRUE;
        vcodec = ghb_settings_get_int(settings, "video_codec");
        if (ghb_settings_get_bool(settings, "vquality_type_constant"))
        {
-               gint vquality = ghb_settings_get_dbl(settings, "video_quality");
-               if (vcodec != HB_VCODEC_X264 || ghb_settings_get_bool(settings, "linear_vquality"))
+               if (!ghb_settings_get_bool(settings, "directqp"))
                {
-                       if (vquality < 68 || vquality > 97)
+                       if (vcodec != HB_VCODEC_X264 || 
+                               ghb_settings_get_bool(settings, "linear_vquality"))
                        {
-                               message = g_strdup_printf(
-                                                       "Interesting video quality choise: %d\n\n"
-                                                       "Typical values range from 68 (low) to 97 (high).\n"
-                                                       "Are you sure you wish to use this setting?",
-                                                       vquality);
-                               if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, "Cancel", "Continue"))
-                               {
-                                       g_free(message);
-                                       return FALSE;
-                               }
-                               g_free(message);
+                               min = 68;
+                               max = 97;
+                       }
+                       else if (vcodec == HB_VCODEC_X264)
+                       {
+                               min = 40;
+                               max = 70;
                        }
                }
-               else if (vcodec == HB_VCODEC_X264)
+               else
                {
-                       if (vquality < 40 || vquality > 70)
+                       if (vcodec == HB_VCODEC_X264)
+                       {
+                               min = 16;
+                               max = 30;
+                       }
+                       else if (vcodec == HB_VCODEC_FFMPEG)
+                       {
+                               min = 1;
+                               max = 8;
+                       }
+                       else
+                       {
+                               min = 68;
+                               max = 97;
+                       }
+               }
+               gint vquality = ghb_settings_get_dbl(settings, "video_quality");
+               if (vquality < min || vquality > max)
+               {
+                       message = g_strdup_printf(
+                                               "Interesting video quality choise: %d\n\n"
+                                               "Typical values range from %d to %d.\n"
+                                               "Are you sure you wish to use this setting?",
+                                               vquality, min, max);
+                       if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, 
+                                                                       "Cancel", "Continue"))
                        {
-                               message = g_strdup_printf(
-                                                       "Interesting video quality choise: %d\n\n"
-                                                       "Typical values range from 40 (low) to 70 (high).\n"
-                                                       "Are you sure you wish to use this setting?",
-                                                       vquality);
-                               if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, "Cancel", "Continue"))
-                               {
-                                       g_free(message);
-                                       return FALSE;
-                               }
                                g_free(message);
+                               return FALSE;
                        }
+                       g_free(message);
                }
        }
        return TRUE;
@@ -2504,28 +2531,32 @@ ghb_add_job(job_settings_t *js, gint unique_id)
        }
        if (ghb_settings_get_bool(settings, "vquality_type_constant"))
        {
-               gdouble vquality = ghb_settings_get_dbl(settings, "video_quality") / 100.0;
-               if (ghb_settings_get_bool(settings, "linear_vquality"))
+               gdouble vquality = ghb_settings_get_dbl(settings, "video_quality");
+               if (!ghb_settings_get_bool(settings, "directqp"))
                {
-                       if (job->vcodec == HB_VCODEC_X264)
+                       vquality /= 100.0;
+                       if (ghb_settings_get_bool(settings, "linear_vquality"))
                        {
-                               // Adjust to same range as xvid and ffmpeg
-                               vquality = 31.0 - vquality * 31.0;
-                               if (vquality > 0)
+                               if (job->vcodec == HB_VCODEC_X264)
                                {
-                                       // Convert linear to log curve
-                                       vquality = 12 + 6 * log2(vquality);
-                                       if (vquality > 51) vquality = 51;
-                                       if (vquality < 1) vquality = 1;
+                                       // Adjust to same range as xvid and ffmpeg
+                                       vquality = 31.0 - vquality * 31.0;
+                                       if (vquality > 0)
+                                       {
+                                               // Convert linear to log curve
+                                               vquality = 12 + 6 * log2(vquality);
+                                               if (vquality > 51) vquality = 51;
+                                               if (vquality < 1) vquality = 1;
+                                       }
+                                       else
+                                               vquality = 0;
                                }
-                               else
-                                       vquality = 0;
                        }
-               }
-               else
-               {
-                       if (vquality == 0.0) vquality = 0.01;
-                       if (vquality == 1.0) vquality = 0.0;
+                       else
+                       {
+                               if (vquality == 0.0) vquality = 0.01;
+                               if (vquality == 1.0) vquality = 0.0;
+                       }
                }
                job->vquality =  vquality;
                job->vbitrate = 0;
@@ -2837,20 +2868,6 @@ ghb_get_preview_image(gint titleindex, gint index, GHashTable *settings, gboolea
        if (title->job == NULL) return NULL;
        set_job_picture_settings(title->job, settings);
 
-#if defined(ALLOW_UPSCALE)
-       gdouble scale = 1;
-       if (title->job->width > title->width)
-               scale = (gdouble) title->job->width / title->width;
-       if (title->job->height > title->height)
-       {
-               gdouble tmp;
-               tmp = (gdouble) title->job->height / title->height;
-               if (tmp > scale)
-                       scale = tmp;
-       }
-       title->job->width /= scale;
-       title->job->height /= scale;
-#else
        // hb_get_preview can't handle sizes that are larger than the original title
        // dimensions
        if (title->job->width > title->width)
@@ -2858,7 +2875,6 @@ ghb_get_preview_image(gint titleindex, gint index, GHashTable *settings, gboolea
        
        if (title->job->height > title->height)
                title->job->height = title->height;
-#endif 
        // And also creates artifacts if the width is not a multiple of 8
        //title->job->width = ((title->job->width + 4) >> 3) << 3;
        // And the height must be a multiple of 2
@@ -2967,10 +2983,6 @@ ghb_get_preview_image(gint titleindex, gint index, GHashTable *settings, gboolea
                else
                        dstHeight = dstHeight * par_height / par_width;
        }
-#if defined(ALLOW_UPSCALE)
-       dstWidth = ((gdouble)dstWidth + scale/2) * scale;
-       dstHeight = ((gdouble)dstHeight + scale/2) * scale;
-#endif
        
        g_debug("scaled %d x %d\n", dstWidth, dstHeight);
        GdkPixbuf *scaled_preview;
@@ -2979,6 +2991,31 @@ ghb_get_preview_image(gint titleindex, gint index, GHashTable *settings, gboolea
        return scaled_preview;
 }
 
+static void
+sanitize_volname(gchar *name)
+{
+       gchar *a, *b;
+
+       a = b = name;
+       while (*b)
+       {
+               switch(*b)
+               {
+               case '<':
+                       b++;
+                       break;
+               case '>':
+                       b++;
+                       break;
+               default:
+                       *a = *b;
+                       a++; b++;
+                       break;
+               }
+       }
+       *a = 0;
+}
+
 gchar*
 ghb_dvd_volname(const gchar *device)
 {
@@ -2986,6 +3023,7 @@ ghb_dvd_volname(const gchar *device)
        name = hb_dvd_name((gchar*)device);
        if (name != NULL)
        {
+               sanitize_volname(name);
                return g_strdup(name);
        }
        return name;
index 0c8a021a8e0c46b6137b23e37180416e41c71cc2..9c723b7b68abad642072552e13228e6767e357a3 100644 (file)
@@ -60,6 +60,7 @@ typedef struct
 #define GHB_FRAMERATE 3
 
 const gchar* ghb_version();
+void ghb_vquality_range(signal_user_data_t *ud, gint *min, gint *max);
 //const gchar* ghb_get_rate_string(gint rate, gint type);
 void ghb_backend_init(GtkBuilder *builder, gint debug, gint update);
 void ghb_add_job(job_settings_t *js, gint unique_id);
index ca910ba9c7b98a09fa9ec16e9ec11d9bc1101349..7966959cbaeaa3fa2133eec205b40ac50c226756 100644 (file)
@@ -61,6 +61,7 @@ x264_me=umh
 x264_deblock_alpha=0
 x264_mixed_refs=disable
 x264_trellis=off
+directqp=disable
 
 [Initialization]
 title=none
index ff5b1f8de0e8312a6929f0c5357637c884c8e4d1..4bb097a2211b4e286171fe6dba9e0022942397ce 100644 (file)
@@ -61,6 +61,7 @@
 "x264_deblock_alpha=0\n"
 "x264_mixed_refs=disable\n"
 "x264_trellis=off\n"
+"directqp=disable\n"
 "\n"
 "[Initialization]\n"
 "title=none\n"