changeset 29299:24954ec81529

Partial (low bits ignored, no direct transcoding into other RGB formats) support for inputting RGB48BE/LE.
author kostya
date Tue, 02 Jun 2009 12:28:49 +0000
parents fb99e3db8f8b
children 321437b5bde2
files libswscale/swscale.c libswscale/swscale_internal.h libswscale/swscale_template.c
diffstat 3 files changed, 61 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libswscale/swscale.c	Mon Jun 01 22:25:10 2009 +0000
+++ b/libswscale/swscale.c	Tue Jun 02 12:28:49 2009 +0000
@@ -108,6 +108,8 @@
         || (x)==PIX_FMT_YUVA420P    \
         || (x)==PIX_FMT_YUYV422     \
         || (x)==PIX_FMT_UYVY422     \
+        || (x)==PIX_FMT_RGB48BE     \
+        || (x)==PIX_FMT_RGB48LE     \
         || (x)==PIX_FMT_RGB32       \
         || (x)==PIX_FMT_RGB32_1     \
         || (x)==PIX_FMT_BGR24       \
@@ -1122,6 +1124,48 @@
     }
 }
 
+static inline void rgb48ToY(uint8_t *dst, const uint8_t *src, int width)
+{
+    int i;
+    for (i = 0; i < width; i++) {
+        int r = src[i*6+0];
+        int g = src[i*6+2];
+        int b = src[i*6+4];
+
+        dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
+    }
+}
+
+static inline void rgb48ToUV(uint8_t *dstU, uint8_t *dstV,
+                             uint8_t *src1, uint8_t *src2, int width)
+{
+    int i;
+    assert(src1==src2);
+    for (i = 0; i < width; i++) {
+        int r = src1[6*i + 0];
+        int g = src1[6*i + 2];
+        int b = src1[6*i + 4];
+
+        dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
+        dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
+    }
+}
+
+static inline void rgb48ToUV_half(uint8_t *dstU, uint8_t *dstV,
+                                  uint8_t *src1, uint8_t *src2, int width)
+{
+    int i;
+    assert(src1==src2);
+    for (i = 0; i < width; i++) {
+        int r= src1[12*i + 0] + src1[12*i + 6];
+        int g= src1[12*i + 2] + src1[12*i + 8];
+        int b= src1[12*i + 4] + src1[12*i + 10];
+
+        dstU[i]= (RU*r + GU*g + BU*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1);
+        dstV[i]= (RV*r + GV*g + BV*b + (257<<RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT+1);
+    }
+}
+
 #define BGR2Y(type, name, shr, shg, shb, maskr, maskg, maskb, RY, GY, BY, S)\
 static inline void name(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused)\
 {\
--- a/libswscale/swscale_internal.h	Mon Jun 01 22:25:10 2009 +0000
+++ b/libswscale/swscale_internal.h	Tue Jun 02 12:28:49 2009 +0000
@@ -344,7 +344,9 @@
         || (x)==PIX_FMT_GRAY16LE    \
     )
 #define isRGB(x)        (           \
-           (x)==PIX_FMT_RGB32       \
+           (x)==PIX_FMT_RGB48BE     \
+        || (x)==PIX_FMT_RGB48LE     \
+        || (x)==PIX_FMT_RGB32       \
         || (x)==PIX_FMT_RGB32_1     \
         || (x)==PIX_FMT_RGB24       \
         || (x)==PIX_FMT_RGB565      \
--- a/libswscale/swscale_template.c	Mon Jun 01 22:25:10 2009 +0000
+++ b/libswscale/swscale_template.c	Tue Jun 02 12:28:49 2009 +0000
@@ -2235,6 +2235,9 @@
             src += ALT32_CORR;
     }
 
+    if (srcFormat == PIX_FMT_RGB48LE)
+        src++;
+
     if (internal_func) {
         internal_func(formatConvBuffer, src, srcW, pal);
         src= formatConvBuffer;
@@ -2424,6 +2427,11 @@
         src2 += ALT32_CORR;
     }
 
+    if (srcFormat==PIX_FMT_RGB48LE) {
+        src1++;
+        src2++;
+    }
+
     if (c->hcscale_internal) {
         c->hcscale_internal(formatConvBuffer, formatConvBuffer+VOFW, src1, src2, srcW, pal);
         src1= formatConvBuffer;
@@ -3047,6 +3055,8 @@
     }
     if (c->chrSrcHSubSample) {
         switch(srcFormat) {
+        case PIX_FMT_RGB48BE:
+        case PIX_FMT_RGB48LE: c->hcscale_internal = rgb48ToUV_half; break;
         case PIX_FMT_RGB32  :
         case PIX_FMT_RGB32_1: c->hcscale_internal = bgr32ToUV_half; break;
         case PIX_FMT_BGR24  : c->hcscale_internal = RENAME(bgr24ToUV_half); break;
@@ -3060,6 +3070,8 @@
         }
     } else {
         switch(srcFormat) {
+        case PIX_FMT_RGB48BE:
+        case PIX_FMT_RGB48LE: c->hcscale_internal = rgb48ToUV; break;
         case PIX_FMT_RGB32  :
         case PIX_FMT_RGB32_1: c->hcscale_internal = bgr32ToUV; break;
         case PIX_FMT_BGR24  : c->hcscale_internal = RENAME(bgr24ToUV); break;
@@ -3103,6 +3115,8 @@
     case PIX_FMT_RGB32_1: c->hyscale_internal = bgr32ToY; break;
     case PIX_FMT_BGR32  :
     case PIX_FMT_BGR32_1: c->hyscale_internal = rgb32ToY; break;
+    case PIX_FMT_RGB48BE:
+    case PIX_FMT_RGB48LE: c->hyscale_internal = rgb48ToY; break;
     }
     if (c->alpPixBuf) {
         switch (srcFormat) {