video-converter: only make a scaler when we are scaling
authorWim Taymans <wtaymans@redhat.com>
Wed, 25 Feb 2015 15:50:02 +0000 (16:50 +0100)
committerWim Taymans <wtaymans@redhat.com>
Wed, 25 Feb 2015 15:50:02 +0000 (16:50 +0100)
Only make a scaler when we are actually doing any scaling. Without
scalers, the scale function will simply do a copy.

gst-libs/gst/video/video-converter.c

index 2c9d126..08b8298 100644 (file)
@@ -3918,9 +3918,12 @@ setup_scale (GstVideoConverter * convert)
       gst_video_scaler_free (y_scaler);
       gst_video_scaler_free (uv_scaler);
     } else {
-      convert->fh_scaler[0] =
-          gst_video_scaler_new (method, GST_VIDEO_SCALER_FLAG_NONE, taps,
-          in_width, out_width, convert->config);
+      if (in_width != out_width)
+        convert->fh_scaler[0] =
+            gst_video_scaler_new (method, GST_VIDEO_SCALER_FLAG_NONE, taps,
+            in_width, out_width, convert->config);
+      else
+        convert->fh_scaler[0] = NULL;
 
       pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (out_finfo, GST_VIDEO_COMP_R);
       convert->fin_x[0] = convert->in_x * pstride;
@@ -3929,11 +3932,15 @@ setup_scale (GstVideoConverter * convert)
     stride = MAX (stride, GST_VIDEO_INFO_PLANE_STRIDE (in_info, 0));
     stride = MAX (stride, GST_VIDEO_INFO_PLANE_STRIDE (out_info, 0));
 
-    convert->fv_scaler[0] =
-        gst_video_scaler_new (method, GST_VIDEO_SCALER_FLAG_NONE, taps,
-        in_height, out_height, convert->config);
+    if (in_height != out_height) {
+      convert->fv_scaler[0] =
+          gst_video_scaler_new (method, GST_VIDEO_SCALER_FLAG_NONE, taps,
+          in_height, out_height, convert->config);
+      gst_video_scaler_get_coeff (convert->fv_scaler[0], 0, NULL, &max_taps);
+    } else {
+      convert->fv_scaler[0] = NULL;
+    }
 
-    gst_video_scaler_get_coeff (convert->fv_scaler[0], 0, NULL, &max_taps);
 
     convert->fin_y[0] = convert->in_y;
     convert->fout_y[0] = convert->out_y;