changeset 1199:6b566c5d02e4 libavcodec

rgba32 convert
author bellard
date Sat, 19 Apr 2003 16:21:25 +0000
parents cae31b22b14e
children b448d7c17215
files imgconvert.c
diffstat 1 files changed, 32 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/imgconvert.c	Sat Apr 19 13:30:09 2003 +0000
+++ b/imgconvert.c	Sat Apr 19 16:21:25 2003 +0000
@@ -119,7 +119,7 @@
     /* paletted formats */
     [PIX_FMT_PAL8] = {
         .name = "pal8",
-        .nb_components = 1, .is_packed = 1, .is_paletted = 1,
+        .nb_components = 1, .is_packed = 1, .is_alpha = 1, .is_paletted = 1,
     },
 };
 
@@ -989,7 +989,6 @@
 
     d = dst->data[0];
     dst_wrap = dst->linesize[0] - ((width + 7) >> 3);
-    printf("%d %d\n", width, height);
 
     for(y=0;y<height;y++) {
         n = width;
@@ -1085,6 +1084,34 @@
         pal[i++] = 0;
 }
         
+static void rgba32_to_rgb24(AVPicture *dst, AVPicture *src,
+                            int width, int height)
+{
+    const uint8_t *s;
+    uint8_t *d;
+    int src_wrap, dst_wrap, j, y;
+    unsigned int v;
+
+    s = src->data[0];
+    src_wrap = src->linesize[0] - width * 4;
+
+    d = dst->data[0];
+    dst_wrap = dst->linesize[0] - width * 3;
+
+    for(y=0;y<height;y++) {
+        for(j = 0;j < width; j++) {
+            v = *(uint32_t *)s;
+            s += 4;
+            d[0] = v >> 16;
+            d[1] = v >> 8;
+            d[2] = v;
+            d += 3;
+        }
+        s += src_wrap;
+        d += dst_wrap;
+    }
+}
+
 typedef struct ConvertEntry {
     void (*convert)(AVPicture *dst, AVPicture *src, int width, int height);
 } ConvertEntry;
@@ -1158,6 +1185,9 @@
         [PIX_FMT_GRAY8] = { 
             .convert = rgba32_to_gray
         },
+        [PIX_FMT_RGB24] = { 
+            .convert = rgba32_to_rgb24
+        },
     },
     [PIX_FMT_BGR24] = {
         [PIX_FMT_YUV420P] = {