summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wtaymans@redhat.com>2015-03-11 08:48:20 (GMT)
committerWim Taymans <wtaymans@redhat.com>2015-03-11 08:48:20 (GMT)
commit3cd2eb5847a08451bf011e3a6b338f8f975b8b51 (patch)
treebca4928a72d1a99f8923f348ea7a4ee7440eb6fe
parent757669481c980c3986b8351be6ef1fc7d16b4608 (diff)
downloadgst-plugins-base-3cd2eb5847a08451bf011e3a6b338f8f975b8b51.tar.gz
gst-plugins-base-3cd2eb5847a08451bf011e3a6b338f8f975b8b51.tar.xz
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.
-rw-r--r--gst-libs/gst/video/video-converter.c32
1 files 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;
}