diff imgconvert.c @ 736:918756bffda2 libavcodec

minimum support for YUV411P (new combined scaler/converter will handle that better...)
author bellard
date Tue, 08 Oct 2002 17:42:33 +0000
parents d6955d0d7d27
children f720b01c0fd5
line wrap: on
line diff
--- a/imgconvert.c	Tue Oct 08 12:09:23 2002 +0000
+++ b/imgconvert.c	Tue Oct 08 17:42:33 2002 +0000
@@ -399,6 +399,31 @@
     }
 }
 
+/* 1x2 -> 2x1. width and height are given for the source picture */
+static void conv411(UINT8 *dst, int dst_wrap, 
+                    UINT8 *src, int src_wrap,
+                    int width, int height)
+{
+    int w, c;
+    UINT8 *s1, *s2, *d;
+
+    for(;height > 0; height -= 2) {
+        s1 = src;
+        s2 = src + src_wrap;
+        d = dst;
+        for(w = width;w > 0; w--) {
+            c = (s1[0] + s2[0]) >> 1;
+            d[0] = c;
+            d[1] = c;
+            s1++;
+            s2++;
+            d += 2;
+        }
+        src += src_wrap * 2;
+        dst += dst_wrap;
+    }
+}
+
 static void img_copy(UINT8 *dst, int dst_wrap, 
                      UINT8 *src, int src_wrap,
                      int width, int height)
@@ -628,6 +653,17 @@
     } else if (dst_pix_fmt == PIX_FMT_YUV420P) {
         
         switch(pix_fmt) {
+        case PIX_FMT_YUV411P:
+            img_copy(dst->data[0], dst->linesize[0],
+                     src->data[0], src->linesize[0],
+                     width, height);
+            conv411(dst->data[1], dst->linesize[1],
+                    src->data[1], src->linesize[1],
+                    width / 4, height);
+            conv411(dst->data[2], dst->linesize[2],
+                    src->data[2], src->linesize[2],
+                    width / 4, height);
+            break;
         case PIX_FMT_YUV410P:
             img_copy(dst->data[0], dst->linesize[0],
                      src->data[0], src->linesize[0],