]> granicus.if.org Git - handbrake/commitdiff
cropscale: prevent crash when scale dimensions too small
authorjstebbins <jstebbins.hb@gmail.com>
Mon, 24 Aug 2015 15:40:24 +0000 (15:40 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Mon, 24 Aug 2015 15:40:24 +0000 (15:40 +0000)
This will result in no video in the output file, but in such cases, this
might actually be desirable.  Scaling to such small dimensions is often
used simply to re-encode audio.

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

libhb/cropscale.c
libhb/hb.c

index 548bdcc2e193fc0edb4ffe808f2e0686f3d038fa..a8a995a6c66dfdb53a875f55a7656f7da0e1b84d 100644 (file)
@@ -202,6 +202,12 @@ static hb_buffer_t* crop_scale( hb_filter_private_t * pv, hb_buffer_t * in )
             pv->pix_fmt   = in->f.fmt;
         }
         
+        if (pv->context == NULL)
+        {
+            hb_buffer_close(&out);
+            return NULL;
+        }
+
         // Scale pic_crop into pic_render according to the
         // context set up above
         sws_scale(pv->context,
index ab61ff74e105296deaa5ddd5ae56eef80950dd9e..e8418e7413bc455fa259ae78d0633775e8e09d8c 100644 (file)
@@ -240,7 +240,7 @@ hb_sws_get_context(int srcW, int srcH, enum AVPixelFormat srcFormat,
                       1 << 16 ); // saturation
 
         if (sws_init_context(ctx, NULL, NULL) < 0) {
-            fprintf(stderr, "Cannot initialize resampling context\n");
+            hb_error("Cannot initialize resampling context");
             sws_freeContext(ctx);
             ctx = NULL;
         }