bayer: fix stride inconsistencies for odd widths
authorTim-Philipp Müller <tim@centricular.com>
Fri, 8 Jan 2016 21:41:56 +0000 (21:41 +0000)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 1 Nov 2016 17:35:47 +0000 (19:35 +0200)
Consistently use GST_ROUND_UP_4(width) as stride for
bayer buffers. Bayer data will usually come in widths
that are multiples of 4 anyway, so hopefully this
should not have any adverse impact on anyone in
practice.

Before, bayer2rgb required input buffers to are sized
accordingly, but then didn't actually round up when
calculating row offsets. rgb2bayer didn't use a rounded
stride nor buffer size.

https://bugzilla.gnome.org/show_bug.cgi?id=752014

gst/bayer/gstbayer2rgb.c
gst/bayer/gstrgb2bayer.c

index bf723b1..de356ed 100644 (file)
@@ -470,7 +470,7 @@ gst_bayer2rgb_transform (GstBaseTransform * base, GstBuffer * inbuf,
 
   output = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0);
   gst_bayer2rgb_process (filter, output, frame.info.stride[0],
-      map.data, filter->width);
+      map.data, GST_ROUND_UP_4 (filter->width));
 
   gst_video_frame_unmap (&frame);
   gst_buffer_unmap (inbuf, &map);
index 21e7811..787fe99 100644 (file)
@@ -173,7 +173,7 @@ gst_rgb2bayer_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
     name = gst_structure_get_name (structure);
     /* Our name must be either video/x-bayer video/x-raw */
     if (g_str_equal (name, "video/x-bayer")) {
-      *size = width * height;
+      *size = GST_ROUND_UP_4 (width) * height;
       return TRUE;
     } else {
       /* For output, calculate according to format */
@@ -249,7 +249,7 @@ gst_rgb2bayer_transform (GstBaseTransform * trans, GstBuffer * inbuf,
   src = GST_VIDEO_FRAME_PLANE_DATA (&frame, 0);
 
   for (j = 0; j < height; j++) {
-    guint8 *dest_line = dest + width * j;
+    guint8 *dest_line = dest + GST_ROUND_UP_4 (width) * j;
     guint8 *src_line = src + frame.info.stride[0] * j;
 
     for (i = 0; i < width; i++) {