From 328632029777048593c725e53e07575e34113859 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 4 Nov 2014 11:03:50 +0100 Subject: [PATCH] video-scaler: fix temp line allocation We need to allocate the templine with the amount of pixels we are going to handle, which we only know for the vertical resampler when we are asked to resample. --- gst-libs/gst/video/video-scaler.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/gst-libs/gst/video/video-scaler.c b/gst-libs/gst/video/video-scaler.c index bfc4d6c..372e3d8 100644 --- a/gst-libs/gst/video/video-scaler.c +++ b/gst-libs/gst/video/video-scaler.c @@ -62,6 +62,7 @@ struct _GstVideoScaler /* for ORC */ gint inc; + gint tmpwidth; guint32 *tmpline1; guint32 *tmpline2; }; @@ -106,6 +107,16 @@ resampler_zip (GstVideoResampler * resampler, const GstVideoResampler * r1, } } +static void +realloc_tmplines (GstVideoScaler * scale, gint width) +{ + scale->tmpline1 = + g_realloc (scale->tmpline1, + sizeof (gint32) * width * 4 * scale->resampler.max_taps); + scale->tmpline2 = g_realloc (scale->tmpline2, sizeof (gint32) * width * 4); + scale->tmpwidth = width; +} + /** * gst_video_scaler_new: * @method: a #GstVideoResamplerMethod @@ -164,10 +175,6 @@ gst_video_scaler_new (GstVideoResamplerMethod method, GstVideoScalerFlags flags, else scale->inc = ((in_size - 1) << 16) / (out_size - 1) - 1; - scale->tmpline1 = - g_malloc (sizeof (gint32) * out_size * 4 * scale->resampler.max_taps); - scale->tmpline2 = g_malloc (sizeof (gint32) * out_size * 4); - return scale; } @@ -727,6 +734,9 @@ gst_video_scaler_horizontal (GstVideoScaler * scale, GstVideoFormat format, pstride = finfo->pixel_stride[0]; g_return_if_fail (pstride == 4 || pstride == 8); + if (scale->tmpwidth < width) + realloc_tmplines (scale, width); + switch (pstride) { case 4: switch (scale->resampler.max_taps) { @@ -797,6 +807,9 @@ gst_video_scaler_vertical (GstVideoScaler * scale, GstVideoFormat format, pstride = finfo->pixel_stride[0]; g_return_if_fail (pstride == 4 || pstride == 8); + if (scale->tmpwidth < width) + realloc_tmplines (scale, width); + switch (pstride) { case 4: switch (scale->resampler.max_taps) { -- 2.7.4