videoconvert: respect the pack_lines when packing
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 28 Mar 2013 17:16:09 +0000 (18:16 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 28 Mar 2013 17:16:09 +0000 (18:16 +0100)
Packing is supposed to happen on the amount of lines specified in the format
info. It's currently all set to 1 but that will change.

gst/videoconvert/videoconvert.c
gst/videoconvert/videoconvert.h

index 847d843..bd5c176 100644 (file)
@@ -49,7 +49,7 @@ VideoConvert *
 videoconvert_convert_new (GstVideoInfo * in_info, GstVideoInfo * out_info)
 {
   VideoConvert *convert;
-  int width;
+  int width, lines;
 
   convert = g_malloc0 (sizeof (VideoConvert));
 
@@ -67,9 +67,12 @@ videoconvert_convert_new (GstVideoInfo * in_info, GstVideoInfo * out_info)
   convert->height = GST_VIDEO_INFO_HEIGHT (in_info);
 
   width = convert->width;
+  lines = out_info->finfo->pack_lines;
 
-  convert->tmpline8 = g_malloc (sizeof (guint8) * (width + 8) * 4);
-  convert->tmpline16 = g_malloc (sizeof (guint16) * (width + 8) * 4);
+  convert->lines = lines;
+
+  convert->tmpline8 = g_malloc (lines * sizeof (guint8) * (width + 8) * 4);
+  convert->tmpline16 = g_malloc (lines * sizeof (guint16) * (width + 8) * 4);
   convert->errline = g_malloc0 (sizeof (guint16) * width * 4);
 
   return convert;
@@ -388,8 +391,8 @@ static void
 videoconvert_convert_generic (VideoConvert * convert, GstVideoFrame * dest,
     const GstVideoFrame * src)
 {
-  int i, j;
-  gint width, height;
+  int i, j, k;
+  gint width, height, lines;
   guint in_bits, out_bits;
   gconstpointer pal;
   gsize palsize;
@@ -402,35 +405,43 @@ videoconvert_convert_generic (VideoConvert * convert, GstVideoFrame * dest,
   in_bits = convert->in_bits;
   out_bits = convert->out_bits;
 
-  tmpline8 = convert->tmpline8;
-  tmpline16 = convert->tmpline16;
+  lines = convert->lines;
 
-  for (j = 0; j < height; j++) {
-    if (in_bits == 16) {
-      UNPACK_FRAME (src, tmpline16, j, width);
-    } else {
-      UNPACK_FRAME (src, tmpline8, j, width);
+  for (j = 0; j < height; j += lines) {
+    tmpline8 = convert->tmpline8;
+    tmpline16 = convert->tmpline16;
 
-      if (out_bits == 16)
-        for (i = 0; i < width * 4; i++)
-          tmpline16[i] = TO_16 (tmpline8[i]);
-    }
+    for (k = 0; k < lines; k++) {
+      if (in_bits == 16) {
+        UNPACK_FRAME (src, tmpline16, j + k, width);
+      } else {
+        UNPACK_FRAME (src, tmpline8, j + k, width);
 
-    if (out_bits == 16 || in_bits == 16) {
-      if (convert->matrix16)
-        convert->matrix16 (convert, tmpline16);
-      if (convert->dither16)
-        convert->dither16 (convert, tmpline16, j);
-    } else {
-      if (convert->matrix)
-        convert->matrix (convert, tmpline8);
+        if (out_bits == 16)
+          for (i = 0; i < width * 4; i++)
+            tmpline16[i] = TO_16 (tmpline8[i]);
+      }
+
+      if (out_bits == 16 || in_bits == 16) {
+        if (convert->matrix16)
+          convert->matrix16 (convert, tmpline16);
+        if (convert->dither16)
+          convert->dither16 (convert, tmpline16, j);
+      } else {
+        if (convert->matrix)
+          convert->matrix (convert, tmpline8);
+      }
+      tmpline8 += width * 4;
+      tmpline16 += width * 8;
     }
+    tmpline8 = convert->tmpline8;
+    tmpline16 = convert->tmpline16;
 
     if (out_bits == 16) {
       PACK_FRAME (dest, tmpline16, j, width);
     } else {
       if (in_bits == 16)
-        for (i = 0; i < width * 4; i++)
+        for (i = 0; i < width * 4 * lines; i++)
           tmpline8[i] = tmpline16[i] >> 8;
 
       PACK_FRAME (dest, tmpline8, j, width);
index 0b2552f..9e9387f 100644 (file)
@@ -46,6 +46,8 @@ struct _VideoConvert {
 
   ColorSpaceDitherMethod dither;
 
+  guint lines;
+
   guint8 *tmpline8;
   guint16 *tmpline16;
   guint16 *errline;