diff options
author | John Stebbins <[email protected]> | 2015-10-21 09:37:53 -0700 |
---|---|---|
committer | John Stebbins <[email protected]> | 2015-10-26 08:32:38 -0700 |
commit | fc25d9a913d485e6bd3caf1ef1115fc6d24c39e6 (patch) | |
tree | 3ac0509b1158aa5f80c607eb017108c943b15383 /gtk | |
parent | 37dfc5b294c084503dab6102be0542f0eb64f881 (diff) |
LinGui: don't call hb_get_preview2 with outragious dimensions
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/src/hb-backend.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index 0c22c430d..25fb09ba1 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -4517,6 +4517,33 @@ ghb_get_preview_image( uiGeo.geometry.par.num = 1; uiGeo.geometry.par.den = 1; + GdkScreen *ss; + gint s_w, s_h; + + ss = gdk_screen_get_default(); + s_w = gdk_screen_get_width(ss); + s_h = gdk_screen_get_height(ss); + + if (uiGeo.geometry.width > s_w * 2 || + uiGeo.geometry.height > s_h * 2) + { + double factor = 1.; + + // Image is of extreme size > twice the screen dimensions. + // In some extreme cases (very lopsided PAR), this can cause + // hb_get_preview2 to crash or hang. + if (uiGeo.geometry.width > s_w) + { + factor = (double)s_w / uiGeo.geometry.width; + } + if (uiGeo.geometry.height * factor > s_h) + { + factor = (double)s_h / uiGeo.geometry.height; + } + uiGeo.geometry.width *= factor; + uiGeo.geometry.height *= factor; + } + GdkPixbuf *preview; hb_image_t *image; image = hb_get_preview2(h_scan, title->index, index, &uiGeo, deinterlace); @@ -4581,17 +4608,12 @@ ghb_get_preview_image( // If the preview is too large to fit the screen, reduce it's size. if (ghb_dict_get_bool(ud->prefs, "reduce_hd_preview")) { - GdkScreen *ss; - gint s_w, s_h; gint factor = 80; if (ghb_dict_get_bool(ud->prefs, "preview_fullscreen")) { factor = 100; } - ss = gdk_screen_get_default(); - s_w = gdk_screen_get_width(ss); - s_h = gdk_screen_get_height(ss); if (previewWidth > s_w * factor / 100 || previewHeight > s_h * factor / 100) |