[FFmpeg-cvslog] r29341 - in trunk/libswscale: swscale.c swscale_internal.h swscale_template.c

kostya subversion
Tue Jun 2 14:28:49 CEST 2009


Author: kostya
Date: Tue Jun  2 14:28:49 2009
New Revision: 29341

Log:
Partial (low bits ignored, no direct transcoding into other RGB formats) support
for inputting RGB48BE/LE.

Modified:
   trunk/libswscale/swscale.c
   trunk/libswscale/swscale_internal.h
   trunk/libswscale/swscale_template.c

Modified: trunk/libswscale/swscale.c
==============================================================================
--- trunk/libswscale/swscale.c	Tue Jun  2 00:25:10 2009	(r29340)
+++ trunk/libswscale/swscale.c	Tue Jun  2 14:28:49 2009	(r29341)
@@ -108,6 +108,8 @@ unsigned swscale_version(void)
         || (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 void fillPlane(uint8_t* plane, in
     }
 }
 
+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)\
 {\

Modified: trunk/libswscale/swscale_internal.h
==============================================================================
--- trunk/libswscale/swscale_internal.h	Tue Jun  2 00:25:10 2009	(r29340)
+++ trunk/libswscale/swscale_internal.h	Tue Jun  2 14:28:49 2009	(r29341)
@@ -344,7 +344,9 @@ const char *sws_format_name(int format);
         || (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      \

Modified: trunk/libswscale/swscale_template.c
==============================================================================
--- trunk/libswscale/swscale_template.c	Tue Jun  2 00:25:10 2009	(r29340)
+++ trunk/libswscale/swscale_template.c	Tue Jun  2 14:28:49 2009	(r29341)
@@ -2235,6 +2235,9 @@ static inline void RENAME(hyscale)(SwsCo
             src += ALT32_CORR;
     }
 
+    if (srcFormat == PIX_FMT_RGB48LE)
+        src++;
+
     if (internal_func) {
         internal_func(formatConvBuffer, src, srcW, pal);
         src= formatConvBuffer;
@@ -2424,6 +2427,11 @@ inline static void RENAME(hcscale)(SwsCo
         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 @@ static void RENAME(sws_init_swScale)(Sws
     }
     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 @@ static void RENAME(sws_init_swScale)(Sws
         }
     } 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 @@ static void RENAME(sws_init_swScale)(Sws
     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) {



More information about the ffmpeg-cvslog mailing list