⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 omxipcs_ycbcr420tobgr565ls_mcu_s16_u16_p3c3.c

📁 The OpenMAX DL (Development Layer) APIs contain a comprehensive set of audio, video, signal processi
💻 C
字号:
/**** * File Name:  omxIPCS_YCbCr420ToBGR565LS_MCU_S16_U16_P3C3.c* OpenMAX DL: v1.0.2* Revision:   10586* Date:       Wednesday, March 5, 2008* * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved.* * ** Description  : Colour Conversion Routine - Converts YUV420 to BGR565 in floating point.*                Source data is stored as a JPEG MCU in three channel, planar domain and *                the destination would be in three-channel pixel format.**/#include "omxtypes.h"#include "armCOMM.h"#include "armOMX.h"#include "omxIP.h"#include "armIP.h"/** * Function:  omxIPCS_YCbCr420ToBGR565LS_MCU_S16_U16_P3C3   (4.4.3.8.6) * * Description: * These functions convert sub-sampled YCbCr data to BGR565 data with  * level-shift.  The parameter pSrcMCU[0] must point to the start of a  * sufficient number of contiguously stored 8x8 Y blocks to constitute a  * complete MCU given the source chroma sub-sampling scheme, i.e., 1, 2, or 4  * blocks for YCbCr 4:4:4, 4:2:2, or YCbCr 4:2:0, respectively.  * * Input Arguments: *    *   pSrcMCU - buffer containing input MCU pointers: pSrcMCU[0] points to the  *            first Y block, pSrcMCU[1] points to Cb the block, and pSrcMCU[2]  *            points to the Cr block; all three must be aligned on 8-byte  *            boundaries.  The parameter pSrcMCU[0] must point to the start of  *            a sufficient number of contiguously stored 8x8 Y blocks to  *            constitute a complete MCU given the source chroma sub-sampling  *            scheme, i.e., 1, 2, or 4 blocks for YCbCr 4:4:4, 4:2:2, or YCbCr  *            4:2:0, respectively. Only top-down storage format is supported.   *            Input components are represented using Q8 and are bounded on the  *            interval [-128, 127].  *   dstStep - distance in bytes between the starts of consecutive lines in  *            the destination image; can take negative values to support  *            bottom-up storage format.  * * Output Arguments: *    *   pDst - output image buffer pointer; data are interleaved as follows:   *            [B G R B G R  ], where G is represented using 6 bits, and B and R  *            are represented using 5 bits.  Output components are saturated.  *            The parameter dstStep can take negative values to support  *            bottom-up storage.  * * Return Value: *     *    OMX_Sts_NoErr - no error  *    OMX_Sts_BadArgErr - bad arguments - returned if one or more of the  *              following is true:  *    -   a pointer was NULL  *    -   the absolute value of dstStep was smaller than 16 (for YCbCr444)  *        or 32 (for YCbCr422/YCbCr420)  *    -   a pointer in pSrcMCU[] was not 8-byte aligned  * */OMXResult omxIPCS_YCbCr420ToBGR565LS_MCU_S16_U16_P3C3(    const OMX_S16 *pSrcMCU[3],    OMX_U16 *pDstRGB,    OMX_INT dstStep    ){    const OMX_S16 *pSrcY, *pSrcY2, *pSrcCb, *pSrcCr;    OMX_S16 Ydata, Ydata2, Ydata3, Ydata4, Udata, Vdata;    OMX_F32 Rdata, Rdata2, Rdata3, Rdata4;    OMX_F32 Gdata, Gdata2, Gdata3, Gdata4;    OMX_F32 Bdata, Bdata2, Bdata3, Bdata4;    OMX_INT i, j, blk_x, blk_y;    OMX_INT blkOffset_Dst, blkOffset_UV;    OMX_U16  *pRGB, *pRGB2;    ARM_BLOCK8x8 *y8x8;    armRetArgErrIf(!pSrcMCU, OMX_Sts_BadArgErr);    armRetArgErrIf(!pDstRGB, OMX_Sts_BadArgErr);    armRetArgErrIf(!pSrcMCU[0], OMX_Sts_BadArgErr);    armRetArgErrIf(!pSrcMCU[1], OMX_Sts_BadArgErr);    armRetArgErrIf(!pSrcMCU[2], OMX_Sts_BadArgErr);    armRetArgErrIf(!armIs8ByteAligned(pSrcMCU[0]), OMX_Sts_BadArgErr);    armRetArgErrIf(!armIs8ByteAligned(pSrcMCU[1]), OMX_Sts_BadArgErr);    armRetArgErrIf(!armIs8ByteAligned(pSrcMCU[2]), OMX_Sts_BadArgErr);    armRetArgErrIf(((dstStep > (-2 * JPEG_MCU_PIX_WIDTH_420)) && (dstStep < (2 * JPEG_MCU_PIX_WIDTH_420))), OMX_Sts_BadArgErr);    /*    ---------------------------------------------------------------------------------    (Y, Cb, Cr) belongs to [-128, 127] and output data (R, G, B) belongs to [0, 255]    The armComputeXFromYUV_JPEG() functions apart from doing the colour conversion,     takes care of type-conversion from intermediate float values and clipping to U8,    taking care of rounding errors.  This is followed armIPCS_PackToRGB565() that packs    the R, G, B data in 565 format.    ---------------------------------------------------------------------------------    */    y8x8 = (ARM_BLOCK8x8 *)pSrcMCU[0];    for(blk_y = 0; blk_y < 2; blk_y++)    {        for(blk_x = 0; blk_x < 2; blk_x++)        {            blkOffset_Dst = blk_y * 8 * (dstStep >> 1) + blk_x * 8;            blkOffset_UV  = blk_y * 8 * 4 + blk_x * 4;            pSrcY   = (OMX_S16 *)y8x8++;            pSrcY2  = pSrcY + 8;            pSrcCb  = pSrcMCU[1] + blkOffset_UV;            pSrcCr  = pSrcMCU[2] + blkOffset_UV;            pRGB    = pDstRGB + blkOffset_Dst;            pRGB2   = pRGB + (dstStep >> 1);            for(i = 0; i < 4; i++)            {                for(j = 0; j < 4*2; j+=2)                {                    Ydata       = *pSrcY++;                    Ydata2      = *pSrcY++;                    Ydata3      = *pSrcY2++;                    Ydata4      = *pSrcY2++;                    Udata       = *pSrcCb++;                    Vdata       = *pSrcCr++;                    armIPCS_ComputeRGBFromYUV_JPEG_F32(Ydata, Udata, Vdata, &Rdata, &Gdata, &Bdata);                    armIPCS_ComputeRGBFromYUV_JPEG_F32(Ydata2, Udata, Vdata, &Rdata2, &Gdata2, &Bdata2);                    armIPCS_ComputeRGBFromYUV_JPEG_F32(Ydata3, Udata, Vdata, &Rdata3, &Gdata3, &Bdata3);                    armIPCS_ComputeRGBFromYUV_JPEG_F32(Ydata4, Udata, Vdata, &Rdata4, &Gdata4, &Bdata4);                    pRGB[j]      = armIPCS_PackToBGR565_F32(Bdata,  Gdata,  Rdata);                    pRGB[j+1]    = armIPCS_PackToBGR565_F32(Bdata2, Gdata2, Rdata2);                    pRGB2[j]     = armIPCS_PackToBGR565_F32(Bdata3, Gdata3, Rdata3);                    pRGB2[j+1]   = armIPCS_PackToBGR565_F32(Bdata4, Gdata4, Rdata4);                }                pSrcY   += 8;                pSrcY2  += 8;                pSrcCb  += 4;                pSrcCr  += 4;                pRGB    += dstStep;                pRGB2   += dstStep;            }        }    }    return OMX_Sts_NoErr;}/* End of file */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -