video-scaler: take number of bits into account when copying

Copy twice the amount of pixels for 16 bits formats.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=747225
This commit is contained in:
Wim Taymans 2016-09-22 16:15:54 +02:00
parent 0c151f6bb2
commit 7a02e9676f

View file

@ -1197,21 +1197,20 @@ static gboolean
get_functions (GstVideoScaler * hscale, GstVideoScaler * vscale,
GstVideoFormat format,
GstVideoScalerHFunc * hfunc, GstVideoScalerVFunc * vfunc,
gint * n_elems, guint * width)
gint * n_elems, guint * width, gint * bits)
{
gint bits;
gboolean mono = FALSE;
switch (format) {
case GST_VIDEO_FORMAT_GRAY8:
bits = 8;
*bits = 8;
*n_elems = 1;
mono = TRUE;
break;
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_YVYU:
case GST_VIDEO_FORMAT_UYVY:
bits = 8;
*bits = 8;
*n_elems = 1;
*width = GST_ROUND_UP_4 (*width * 2);
break;
@ -1219,7 +1218,7 @@ get_functions (GstVideoScaler * hscale, GstVideoScaler * vscale,
case GST_VIDEO_FORMAT_BGR:
case GST_VIDEO_FORMAT_v308:
case GST_VIDEO_FORMAT_IYU2:
bits = 8;
*bits = 8;
*n_elems = 3;
break;
case GST_VIDEO_FORMAT_AYUV:
@ -1231,17 +1230,17 @@ get_functions (GstVideoScaler * hscale, GstVideoScaler * vscale,
case GST_VIDEO_FORMAT_BGRA:
case GST_VIDEO_FORMAT_ARGB:
case GST_VIDEO_FORMAT_ABGR:
bits = 8;
*bits = 8;
*n_elems = 4;
break;
case GST_VIDEO_FORMAT_ARGB64:
case GST_VIDEO_FORMAT_AYUV64:
bits = 16;
*bits = 16;
*n_elems = 4;
break;
case GST_VIDEO_FORMAT_GRAY16_LE:
case GST_VIDEO_FORMAT_GRAY16_BE:
bits = 16;
*bits = 16;
*n_elems = 1;
mono = TRUE;
break;
@ -1250,13 +1249,13 @@ get_functions (GstVideoScaler * hscale, GstVideoScaler * vscale,
case GST_VIDEO_FORMAT_NV21:
case GST_VIDEO_FORMAT_NV24:
case GST_VIDEO_FORMAT_NV61:
bits = 8;
*bits = 8;
*n_elems = 2;
break;
default:
return FALSE;
}
if (bits == 8) {
if (*bits == 8) {
switch (hscale ? hscale->resampler.max_taps : 0) {
case 0:
break;
@ -1298,7 +1297,7 @@ get_functions (GstVideoScaler * hscale, GstVideoScaler * vscale,
*vfunc = video_scale_v_ntap_u8;
break;
}
} else if (bits == 16) {
} else if (*bits == 16) {
switch (hscale ? hscale->resampler.max_taps : 0) {
case 0:
break;
@ -1345,7 +1344,7 @@ void
gst_video_scaler_horizontal (GstVideoScaler * scale, GstVideoFormat format,
gpointer src, gpointer dest, guint dest_offset, guint width)
{
gint n_elems;
gint n_elems, bits;
GstVideoScalerHFunc func = NULL;
g_return_if_fail (scale != NULL);
@ -1353,7 +1352,7 @@ gst_video_scaler_horizontal (GstVideoScaler * scale, GstVideoFormat format,
g_return_if_fail (dest != NULL);
g_return_if_fail (dest_offset + width <= scale->resampler.out_size);
if (!get_functions (scale, NULL, format, &func, NULL, &n_elems, &width)
if (!get_functions (scale, NULL, format, &func, NULL, &n_elems, &width, &bits)
|| func == NULL)
goto no_func;
@ -1387,7 +1386,7 @@ void
gst_video_scaler_vertical (GstVideoScaler * scale, GstVideoFormat format,
gpointer src_lines[], gpointer dest, guint dest_offset, guint width)
{
gint n_elems;
gint n_elems, bits;
GstVideoScalerVFunc func = NULL;
g_return_if_fail (scale != NULL);
@ -1395,7 +1394,7 @@ gst_video_scaler_vertical (GstVideoScaler * scale, GstVideoFormat format,
g_return_if_fail (dest != NULL);
g_return_if_fail (dest_offset < scale->resampler.out_size);
if (!get_functions (NULL, scale, format, NULL, &func, &n_elems, &width)
if (!get_functions (NULL, scale, format, NULL, &func, &n_elems, &width, &bits)
|| func == NULL)
goto no_func;
@ -1442,7 +1441,7 @@ gst_video_scaler_2d (GstVideoScaler * hscale, GstVideoScaler * vscale,
gpointer dest, gint dest_stride, guint x, guint y,
guint width, guint height)
{
gint n_elems;
gint n_elems, bits;
GstVideoScalerHFunc hfunc = NULL;
GstVideoScalerVFunc vfunc = NULL;
gint i;
@ -1450,7 +1449,8 @@ gst_video_scaler_2d (GstVideoScaler * hscale, GstVideoScaler * vscale,
g_return_if_fail (src != NULL);
g_return_if_fail (dest != NULL);
if (!get_functions (hscale, vscale, format, &hfunc, &vfunc, &n_elems, &width))
if (!get_functions (hscale, vscale, format, &hfunc, &vfunc, &n_elems, &width,
&bits))
goto no_func;
#define LINE(s,ss,i) ((guint8 *)(s) + ((i) * (ss)))
@ -1462,7 +1462,7 @@ gst_video_scaler_2d (GstVideoScaler * hscale, GstVideoScaler * vscale,
guint8 *s, *d;
xo = x * n_elems;
xw = width * n_elems;
xw = width * n_elems * (bits / 8);
s = LINE (src, src_stride, y) + xo;
d = LINE (dest, dest_stride, y) + xo;