changeset 576:9aa5f0d0124e libavcodec

YUV410P to YUV420P patch by Franois Revol <revol at free dot fr>
author michaelni
date Sun, 21 Jul 2002 07:54:53 +0000
parents 23eee7d73c4b
children babaca0899f1
files imgconvert.c
diffstat 1 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/imgconvert.c	Sun Jul 21 01:34:05 2002 +0000
+++ b/imgconvert.c	Sun Jul 21 07:54:53 2002 +0000
@@ -245,6 +245,34 @@
     }
 }
 
+/* 1x1 -> 2x2 */
+static void grow22(UINT8 *dst, int dst_wrap,
+                     UINT8 *src, int src_wrap,
+                     int width, int height)
+{
+    int w;
+    UINT8 *s1, *d;
+
+    for(;height > 0; height--) {
+        s1 = src;
+        d = dst;
+        for(w = width;w >= 4; w-=4) {
+            d[1] = d[0] = s1[0];
+            d[3] = d[2] = s1[1];
+            s1 += 2;
+            d += 4;
+        }
+        for(;w > 0; w--) {
+            d[0] = s1[0];
+            s1 ++;
+            d++;
+        }
+        if (height%2)
+            src += src_wrap;
+        dst += dst_wrap;
+    }
+}
+
 static void img_copy(UINT8 *dst, int dst_wrap, 
                      UINT8 *src, int src_wrap,
                      int width, int height)
@@ -382,6 +410,17 @@
     } else if (dst_pix_fmt == PIX_FMT_YUV420P) {
         
         switch(pix_fmt) {
+        case PIX_FMT_YUV410P:
+            img_copy(dst->data[0], dst->linesize[0],
+                     src->data[0], src->linesize[0],
+                     width, height);
+            grow22(dst->data[1], dst->linesize[1],
+                     src->data[1], src->linesize[1],
+                     width/2, height/2);
+            grow22(dst->data[2], dst->linesize[2],
+                     src->data[2], src->linesize[2],
+                     width/2, height/2);
+            break;
         case PIX_FMT_YUV420P:
             for(i=0;i<3;i++) {
                 img_copy(dst->data[i], dst->linesize[i],