From 3cd2eb5847a08451bf011e3a6b338f8f975b8b51 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 11 Mar 2015 09:48:20 +0100 Subject: [PATCH] video-converter: fix border handling of YUY2 and friends Don't draw the border in groups of 4 pixels for YUY2 but instead in groups of 2 with alternating U and V. This avoids a crash on odd width borders. --- gst-libs/gst/video/video-converter.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/gst-libs/gst/video/video-converter.c b/gst-libs/gst/video/video-converter.c index b3165b2..9f12306 100644 --- a/gst-libs/gst/video/video-converter.c +++ b/gst-libs/gst/video/video-converter.c @@ -3574,6 +3574,22 @@ memset_u24 (guint8 * data, guint8 col[3], unsigned int n) } } +static void +memset_u32_16 (guint8 * data, guint8 col[4], unsigned int n) +{ + unsigned int i; + + for (i = 0; i < n; i += 2) { + data[0] = col[0]; + data[1] = col[1]; + if (i + 1 < n) { + data[2] = col[2]; + data[3] = col[3]; + } + data += 4; + } +} + #define MAKE_BORDER_FUNC(func) \ for (i = 0; i < out_y; i++) \ func (FRAME_GET_PLANE_LINE (dest, k, i), col, out_maxwidth); \ @@ -3632,11 +3648,7 @@ convert_fill_border (GstVideoConverter * convert, GstVideoFrame * dest) case GST_VIDEO_FORMAT_YUY2: case GST_VIDEO_FORMAT_YVYU: case GST_VIDEO_FORMAT_UYVY: - pgroup = 4; - rb_width /= 2; - lb_width /= 2; - out_maxwidth /= 2; - out_x /= 2; + pgroup = 42; break; default: pgroup = pstride; @@ -3677,6 +3689,16 @@ convert_fill_border (GstVideoConverter * convert, GstVideoFrame * dest) MAKE_BORDER_FUNC (video_orc_splat_u64); break; } + case 42: + { + guint8 col[4]; + col[0] = ((guint8 *) borders)[0]; + col[2] = ((guint8 *) borders)[2]; + col[1] = ((guint8 *) borders)[r_border & 1 ? 3 : 1]; + col[3] = ((guint8 *) borders)[r_border & 1 ? 1 : 3]; + MAKE_BORDER_FUNC (memset_u32_16); + break; + } default: break; } -- 2.7.4