Apply Faisal's second patch from Bug 2354, plus a missing "break" statement NewGraphicsArchitecture
authorWilliam Roberts <williamr@symbian.org>
Tue, 20 Apr 2010 16:38:10 +0100
branchNewGraphicsArchitecture
changeset 35 3aa07f06a4b7
parent 34 76efc8f9f7b4
child 37 31d52bbe209c
Apply Faisal's second patch from Bug 2354, plus a missing "break" statement - Add YUV support
graphicscomposition/openwfcompositionengine/adaptation/src/Platform/Graphics/symbian/owfnativestreamstub.cpp
graphicscomposition/openwfcompositionengine/common/include/owfimage.h
graphicscomposition/openwfcompositionengine/common/include/owftypes.h
graphicscomposition/openwfcompositionengine/common/src/owfimage.c
graphicscomposition/openwfcompositionengine/group/openwfc.mmp
--- a/graphicscomposition/openwfcompositionengine/adaptation/src/Platform/Graphics/symbian/owfnativestreamstub.cpp	Tue Apr 20 16:24:43 2010 +0100
+++ b/graphicscomposition/openwfcompositionengine/adaptation/src/Platform/Graphics/symbian/owfnativestreamstub.cpp	Tue Apr 20 16:38:10 2010 +0100
@@ -94,6 +94,11 @@
                 bytesPerPixel = -8;
                 b.iAlignment = max(4,format->rowPadding);
                 break;
+            case OWF_IMAGE_UYVY:
+                b.iPixelFormat = EUidPixelFormatYUV_422Interleaved;
+                bytesPerPixel = 1;
+                b.iAlignment = max(4,format->rowPadding);
+                break;
             default:
                 return surface;
             }   
@@ -291,6 +296,13 @@
                 aFormat.rowPadding = 4;
                 aFormat.pixelFormat = OWF_IMAGE_L1;          
                 break;
+
+            case EUidPixelFormatYUV_422Interleaved :
+                aFormat.linear = OWF_FALSE;
+                aFormat.premultiplied = OWF_FALSE;
+                aFormat.rowPadding = 1;
+                aFormat.pixelFormat = OWF_IMAGE_UYVY;          
+                break;
             default:
                 aFormat.linear = OWF_FALSE;
                 aFormat.premultiplied = OWF_FALSE;
--- a/graphicscomposition/openwfcompositionengine/common/include/owfimage.h	Tue Apr 20 16:24:43 2010 +0100
+++ b/graphicscomposition/openwfcompositionengine/common/include/owfimage.h	Tue Apr 20 16:38:10 2010 +0100
@@ -31,6 +31,7 @@
 
 typedef void*   OWF_DISPCTX;
 
+#define CLIP(a) if (a < 0) a = 0; else if (a > 255) a = 255;
 
 #undef USE_FLOAT_PIXEL
 
@@ -201,6 +202,7 @@
     OWFpixel*               tsColor;
 } OWF_BLEND_INFO;
 
+#define CLIP(a) if (a < 0) a = 0; else if (a > 255) a = 255;
 
 /*!---------------------------------------------------------------------------
  *  \brief Initialize image object
--- a/graphicscomposition/openwfcompositionengine/common/include/owftypes.h	Tue Apr 20 16:24:43 2010 +0100
+++ b/graphicscomposition/openwfcompositionengine/common/include/owftypes.h	Tue Apr 20 16:38:10 2010 +0100
@@ -73,6 +73,7 @@
     OWF_IMAGE_L16           = 0xA16,
     OWF_IMAGE_L8            = 0xA8,
     OWF_IMAGE_L1            = 0xA1,
+    OWF_IMAGE_UYVY          = 0x422, /* EUidPixelFormatYUV_422Interleaved */
     OWF_IMAGE_ARGB_INTERNAL = 0x666 /* OWFpixel rep */
 } OWF_PIXEL_FORMAT;
 
--- a/graphicscomposition/openwfcompositionengine/common/src/owfimage.c	Tue Apr 20 16:24:43 2010 +0100
+++ b/graphicscomposition/openwfcompositionengine/common/src/owfimage.c	Tue Apr 20 16:38:10 2010 +0100
@@ -370,7 +370,49 @@
                 }
                 break;
             }
-    
+            case OWF_IMAGE_UYVY:
+            {
+                OWFuint8* srcPtr = (OWFuint8*) srcLinePtr;
+                OWFint y,u,v,r,g,b,x;
+                for (x = 0; x < count; x++)
+                {
+                    u = srcPtr[0] - 128;
+                    v = srcPtr[2] - 128;
+                    y = srcPtr[3] - 16;
+                    
+                    r = ((298 * y + 409 * u) / 256);
+                    g = ((298 * y - 100 * v - 208 * u) / 256);
+                    b = ((298 * y + 516 * v) / 256);
+                    
+                    CLIP(r);
+                    CLIP(g);
+                    CLIP(b);
+                    
+                    dstPtr->color.alpha = 255;
+                    dstPtr->color.red = r;
+                    dstPtr->color.green = g;
+                    dstPtr->color.blue = b;
+                    dstPtr++;
+                    
+                    y = srcPtr[1] - 16;
+                    r = ((298 * y + 409 * u) / 256);
+                    g = ((298 * y - 100 * v - 208 * u) / 256);
+                    b = ((298 * y + 516 * v) / 256);
+                    
+                    CLIP(r);
+                    CLIP(g);
+                    CLIP(b);
+                    
+                    dstPtr->color.alpha = 255;
+                    dstPtr->color.red = r;
+                    dstPtr->color.green = g;
+                    dstPtr->color.blue = b;
+                    dstPtr++;                  
+                    srcPtr += 4;                                      
+                }
+                break;
+            }
+                
             default:
             {
                 return OWF_FALSE; /* source format not supported */
@@ -547,7 +589,49 @@
 #endif
                 break;
             }
-    
+            case OWF_IMAGE_UYVY:
+            {
+                OWFuint8* srcPtr = (OWFuint8*) srcLinePtr;
+                OWFint y,u,v,r,g,b,x;
+                for (x = 0; x < count; x++)
+                {
+                    u = srcPtr[0] - 128;
+                    v = srcPtr[2] - 128;
+                    y = srcPtr[3] - 16;
+                    
+                    r = ((298 * y + 409 * u) / 256);
+                    g = ((298 * y - 100 * v - 208 * u) / 256);
+                    b = ((298 * y + 516 * v) / 256);
+                    
+                    CLIP(r);
+                    CLIP(g);
+                    CLIP(b);
+                    
+                    dstPtr->color.alpha = 255;
+                    dstPtr->color.red = r;
+                    dstPtr->color.green = g;
+                    dstPtr->color.blue = b;
+                    dstPtr++;
+                    
+                    y = srcPtr[1] - 16;
+                    r = ((298 * y + 409 * u) / 256);
+                    g = ((298 * y - 100 * v - 208 * u) / 256);
+                    b = ((298 * y + 516 * v) / 256);
+                    
+                    CLIP(r);
+                    CLIP(g);
+                    CLIP(b);
+                    
+                    dstPtr->color.alpha = 255;
+                    dstPtr->color.red = r;
+                    dstPtr->color.green = g;
+                    dstPtr->color.blue = b;
+                    dstPtr++;                  
+                    srcPtr += 4;                                      
+                }
+                break;
+            }
+                
             default:
             {
                 return OWF_FALSE; /* destination format not supported */
@@ -1797,6 +1881,7 @@
         }
 
         case OWF_IMAGE_L8:
+        case OWF_IMAGE_UYVY:
         {
             return 1;
         }
@@ -1852,6 +1937,7 @@
         }
 
         case OWF_IMAGE_L8:
+        case OWF_IMAGE_UYVY:
         {
             padding = 1;
             break;
--- a/graphicscomposition/openwfcompositionengine/group/openwfc.mmp	Tue Apr 20 16:24:43 2010 +0100
+++ b/graphicscomposition/openwfcompositionengine/group/openwfc.mmp	Tue Apr 20 16:38:10 2010 +0100
@@ -42,7 +42,7 @@
 OPTION ARMCC    -O3 -Otime --cpu 6
 ALWAYS_BUILD_AS_ARM
 
-OS_LAYER_SYSTEMINCLUDE_SYMBIAN
+OS_LAYER_SYSTEMINCLUDE
 OS_LAYER_LIBC_SYSTEMINCLUDE
 MACRO		HG_NO_ALLOCA_H
 MACRO		EGL_DLL