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

📄 omxipcs_bgr888toycbcr420ls_mcu_u8_s16_c3p3.c

📁 The OpenMAX DL (Development Layer) APIs contain a comprehensive set of audio, video, signal processi
💻 C
字号:
/**** * File Name:  omxIPCS_BGR888ToYCbCr420LS_MCU_U8_S16_C3P3.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 BGR888 to YUV420 in floating point.*                Source is in three channel, pixel domain and the destination would be in*                three-channel planar format. Output is a JPEG MCU.**/#include "omxtypes.h"#include "armCOMM.h"#include "armOMX.h"#include "omxIP.h"#include "armIP.h"/*** Function:  omxIPCS_BGR888ToYCbCr420LS_MCU_U8_S16_C3P3   (4.4.3.7.3)** Description:* These functions convert an input BGR888 MCU to one of the following * sub-sampled color spaces with level-shift:  YCbCr4:4:4, YCbCr4:2:2, and * YCbCr4:2:0.  The parameter pDstMCU[0] must point to the start of a buffer * with sufficient free space to contain the particular number of contiguously * stored 8x8 Y blocks that constitute a complete MCU given the output chroma * sub-sampling scheme, i.e., 1, 2, or 4 of 8x8 Y blocks for YCbCr 4:4:4, 4:2:2, * or 4:2:0 output, respectively. ** Input Arguments:*   *   pSrc - pointer to the source image data buffer.  The source image data *            are stored in interleaved order as BGRBGRBGR  The image data *            buffer pSrc can support bottom-up storage formats.  For *            bottom-up images, srcStep can be less than 0. *   srcStep - distance in bytes between the starts of consecutive lines in *            the source image;  can be less than 0 to support bottom-up *            storage format. ** Output Arguments:*   *   pDstMCU[3] - output MCU pointers.  The parameter pDstMCU[0] must point *            to the start of a buffer with sufficient free space to contain *            the particular number of contiguously stored 8x8 Y blocks that *            constitute a complete MCU given the output chroma sub-sampling *            scheme, i.e., 1, 2, or 4 8x8 Y blocks for YCbCr 4:4:4, 4:2:2, or *            4:2:0 output, respectively. The parameter pDstMCU[1] points to *            the Cb block, and the parameter pDstMCU[2] points to the Cr *            block.  Output components are expressed using a Q8 *            representation and are bounded on the interval [-128, 127].  The *            buffers referenced by pDstMCU[] support top-down storage format *            only, and all pointers pDstMCU[0..2] must be 8-byte aligned. ** Return Value:*    *    OMX_Sts_NoErr - no error *    OMX_Sts_BadArgErr - one or more of the following bad argument *              conditions was detected: *    -   a pointer was NULL *    -   the absolute value of srcStep was smaller than 24 for YCbCr 444,*        or 48 for YCbCr422/ YCbCr420 *    -   the start address of each pointer in pDstMCU[] was not 8-byte aligned **/OMXResult omxIPCS_BGR888ToYCbCr420LS_MCU_U8_S16_C3P3(    const OMX_U8 *pSrc,    OMX_INT srcStep,    OMX_S16 * pDstMCU[3]    )    {        OMX_S16 *pDstY, *pDstY2, *pDstCb, *pDstCr;        OMX_U8  Rdata, Rdata2, Rdata3, Rdata4;        OMX_U8  Gdata, Gdata2, Gdata3, Gdata4;        OMX_U8  Bdata, Bdata2, Bdata3, Bdata4;        OMX_INT i, j, blk_x, blk_y;        ARM_BLOCK8x8 *y8x8;        OMX_INT blkOffset_Dst, blkOffset_UV;        const OMX_U8 *pRGB, *pRGB2;        armRetArgErrIf(!pSrc, OMX_Sts_BadArgErr);        armRetArgErrIf(!pDstMCU, OMX_Sts_BadArgErr);        armRetArgErrIf(!pDstMCU[0], OMX_Sts_BadArgErr);        armRetArgErrIf(!pDstMCU[1], OMX_Sts_BadArgErr);        armRetArgErrIf(!pDstMCU[2], OMX_Sts_BadArgErr);        armRetArgErrIf(!armIs8ByteAligned(pDstMCU[0]), OMX_Sts_BadArgErr);        armRetArgErrIf(!armIs8ByteAligned(pDstMCU[1]), OMX_Sts_BadArgErr);        armRetArgErrIf(!armIs8ByteAligned(pDstMCU[2]), OMX_Sts_BadArgErr);        armRetArgErrIf(((srcStep > (-3 * JPEG_MCU_PIX_WIDTH_420)) && (srcStep < (3 * JPEG_MCU_PIX_WIDTH_420))), OMX_Sts_BadArgErr);        /*        -----------------------------------------------------------------------------        With input data (R, G, B) belonging to [0, 255] and output data (Y,Cb,Cr)         expected in [-128, 127], CC equations in JPEG domain would be -         Y  =  0.29900*R  + 0.58700*G  + 0.11400*B - 128        Cb = -0.16874*R  - 0.33126*G  + 0.50000*B        Cr =  0.50000*R  - 0.41869*G  - 0.08131*B        This routine handles the input data in 2x2 blocks, producing 4Y, 1Cb and 1Cr        pixels according to the interpolation type chosen. The cases of Nearest         Neighbour interpolation and Bilinear interpolation are separately handled.        The armComputeXFromRGB_JPEG() functions apart from doing the colour conversion,         takes care of type-conversion from intermediate float values and clipping to         S16, taking care of rounding errors.        -----------------------------------------------------------------------------        */        y8x8 = (ARM_BLOCK8x8 *)pDstMCU[0];        for(blk_y = 0; blk_y < 2; blk_y++)        {            for(blk_x = 0; blk_x < 2; blk_x++)            {                blkOffset_Dst = blk_y * 8 * srcStep + blk_x * 24;                blkOffset_UV  = blk_y * 8 * 4 + blk_x * 4;                pDstY   = (OMX_S16 *)y8x8++;                pDstY2  = pDstY + 8;                pDstCb  = pDstMCU[1] + blkOffset_UV;                pDstCr  = pDstMCU[2] + blkOffset_UV;                pRGB    = pSrc + blkOffset_Dst;                pRGB2   = pRGB + srcStep;                for(i = 0; i < 4; i++)                {                    for(j = 0; j < 4*6; j+=6)                    {                        Bdata       = pRGB[j];                        Gdata       = pRGB[j+1];                        Rdata       = pRGB[j+2];                        Bdata2      = pRGB[j+3];                        Gdata2      = pRGB[j+4];                        Rdata2      = pRGB[j+5];                        Bdata3      = pRGB2[j];                        Gdata3      = pRGB2[j+1];                        Rdata3      = pRGB2[j+2];                        Bdata4      = pRGB2[j+3];                        Gdata4      = pRGB2[j+4];                        Rdata4      = pRGB2[j+5];                        armIPCS_ComputeYFromRGB_JPEG_F32_S16(Rdata,  Gdata,  Bdata,  pDstY++);                        armIPCS_ComputeYFromRGB_JPEG_F32_S16(Rdata2, Gdata2, Bdata2, pDstY++);                        armIPCS_ComputeYFromRGB_JPEG_F32_S16(Rdata3, Gdata3, Bdata3, pDstY2++);                        armIPCS_ComputeYFromRGB_JPEG_F32_S16(Rdata4, Gdata4, Bdata4, pDstY2++);                        {                            OMX_F32 interpPixR = (Rdata + Rdata2 + Rdata3 + Rdata4) / (OMX_F32)4;                            OMX_F32 interpPixG = (Gdata + Gdata2 + Gdata3 + Gdata4) / (OMX_F32)4;                            OMX_F32 interpPixB = (Bdata + Bdata2 + Bdata3 + Bdata4) / (OMX_F32)4;                            armIPCS_ComputeUFromRGB_JPEG_F32_S16(interpPixR, interpPixG, interpPixB, pDstCb++);                            armIPCS_ComputeVFromRGB_JPEG_F32_S16(interpPixR, interpPixG, interpPixB, pDstCr++);                        }                    }                    pDstY   += 8;                    pDstY2  += 8;                    pDstCb  += 4;                    pDstCr  += 4;                    pRGB    += 2 * srcStep;                    pRGB2   += 2 * srcStep;                }            }        }        return OMX_Sts_NoErr;    }    /* End of file */

⌨️ 快捷键说明

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