📄 omxipcs_bgr565toycbcr420ls_mcu_u16_s16_c3p3.c
字号:
/**** * File Name: omxIPCS_BGR565ToYCbCr420LS_MCU_U16_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 BGR565 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_BGR565ToYCbCr420LS_MCU_U16_S16_C3P3 (4.4.3.7.6)** Description:* This function converts packed BGR565 image data to the following * sub-sampled color spaces: 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 - references the source image data buffer. Pixel intensities are * interleaved as shown in Table 4 1, and G, B, and R are * represented using, respectively, 6, 5, and 5 bits. The image * data buffer pSrcsupports bottom-up storage format, for which * 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 of 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 - bad arguments. Returned for any of the following * conditions: * - a pointer was NULL * - srcStep was an odd number or its absolute value was less * than 16 for YCbCr444 or 32 for YCbCr422/YCbCr420. * - a pointer in pDstMCU[] was not 8-byte aligned **/OMXResult omxIPCS_BGR565ToYCbCr420LS_MCU_U16_S16_C3P3( const OMX_U16 *pSrc, OMX_INT srcStep, OMX_S16 *pDstMCU[3] ) { const OMX_U16 *pSrc2 = pSrc + (srcStep >> 1); 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_U16 *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 > (-2 * JPEG_MCU_PIX_WIDTH_420)) && (srcStep < (2 * JPEG_MCU_PIX_WIDTH_420))), OMX_Sts_BadArgErr); armRetArgErrIf((srcStep % 2), OMX_Sts_BadArgErr); /* -------------------------------------------------------------------------- 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, take 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 * 8; 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*2; j+=2) { armIPCS_UnpackBGR565(pSrc[j], &Bdata, &Gdata, &Rdata); armIPCS_UnpackBGR565(pSrc[j+1], &Bdata2, &Gdata2, &Rdata2); armIPCS_UnpackBGR565(pSrc2[j], &Bdata3, &Gdata3, &Rdata3); armIPCS_UnpackBGR565(pSrc2[j+1], &Bdata4, &Gdata4, &Rdata4); 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 + -