From e1715f7728da0ea7ccb1cf51adf3cb6ec54f4a54 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 25 Feb 2015 16:50:02 +0100 Subject: [PATCH] video-converter: only make a scaler when we are scaling 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 | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c index 2c9d1266eb..08b8298812 100644 --- a/gst-libs/gst/video/video-converter.c +++ b/gst-libs/gst/video/video-converter.c @@ -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;