Optimized general_YUV444ToRGB_8u_P3AC4R for BGRX
authorArmin Novak <armin.novak@thincast.com>
Mon, 16 Jan 2017 09:54:01 +0000 (10:54 +0100)
committerArmin Novak <armin.novak@thincast.com>
Wed, 18 Jan 2017 14:28:53 +0000 (15:28 +0100)
libfreerdp/primitives/prim_YUV.c

index 5e8883f..5549533 100644 (file)
@@ -316,7 +316,7 @@ static INLINE BYTE YUV2B(INT32 Y, INT32 U, INT32 V)
        return CLIP(b8);
 }
 
-static pstatus_t general_YUV444ToRGB_8u_P3AC4R(
+static pstatus_t general_YUV444ToRGB_8u_P3AC4R_general(
     const BYTE* pSrc[3], const UINT32 srcStep[3],
     BYTE* pDst, UINT32 dstStep, UINT32 DstFormat,
     const prim_size_t* roi)
@@ -350,6 +350,54 @@ static pstatus_t general_YUV444ToRGB_8u_P3AC4R(
        return PRIMITIVES_SUCCESS;
 }
 
+static pstatus_t general_YUV444ToRGB_8u_P3AC4R_BGRX(
+    const BYTE* pSrc[3], const UINT32 srcStep[3],
+    BYTE* pDst, UINT32 dstStep, UINT32 DstFormat,
+    const prim_size_t* roi)
+{
+       UINT32 x, y;
+       UINT32 nWidth, nHeight;
+       const DWORD formatSize = GetBytesPerPixel(DstFormat);
+       nWidth = roi->width;
+       nHeight = roi->height;
+
+       for (y = 0; y < nHeight; y++)
+       {
+               const BYTE* pY = pSrc[0] + y * srcStep[0];
+               const BYTE* pU = pSrc[1] + y * srcStep[1];
+               const BYTE* pV = pSrc[2] + y * srcStep[2];
+               BYTE* pRGB = pDst + y * dstStep;
+
+               for (x = 0; x < nWidth; x++)
+               {
+                       const BYTE Y = pY[x];
+                       const INT32 U = pU[x];
+                       const INT32 V = pV[x];
+                       const BYTE r = YUV2R(Y, U, V);
+                       const BYTE g = YUV2G(Y, U, V);
+                       const BYTE b = YUV2B(Y, U, V);
+                       pRGB = writePixelBGRX(pRGB, formatSize, DstFormat, r, g, b, 0xFF);
+               }
+       }
+
+       return PRIMITIVES_SUCCESS;
+}
+
+static pstatus_t general_YUV444ToRGB_8u_P3AC4R(
+    const BYTE* pSrc[3], const UINT32 srcStep[3],
+    BYTE* pDst, UINT32 dstStep, UINT32 DstFormat,
+    const prim_size_t* roi)
+{
+       switch (DstFormat)
+       {
+               case PIXEL_FORMAT_BGRA32:
+               case PIXEL_FORMAT_BGRX32:
+                       return general_YUV444ToRGB_8u_P3AC4R_BGRX(pSrc, srcStep, pDst, dstStep, DstFormat, roi);
+
+               default:
+                       return general_YUV444ToRGB_8u_P3AC4R_general(pSrc, srcStep, pDst, dstStep, DstFormat, roi);
+       }
+}
 /**
  * | R |    ( | 256     0    403 | |    Y    | )
  * | G | = (  | 256   -48   -120 | | U - 128 |  ) >> 8