📄 omxipcs_ycbcr420tobgr565_u8_u16_p3c3r.c
字号:
/** * * * File Name: omxIPCS_YCbCr420ToBGR565_U8_U16_P3C3R.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 - YUV420 to BGR565 in floating point. * The source is in three-channel format and planar domain, and * the destination in three-channel format and pixel domain. * */#include "omxtypes.h"#include "armCOMM.h"#include "armOMX.h"#include "omxIP.h"#include "armIP.h"/** * Function: omxIPCS_YCbCr420ToBGR565_U8_U16_P3C3R (4.4.3.1.4) * * Description: * This function converts a planar YCbCr420 input image to a pixel-oriented * BGR565 output image. The memory organization for a planar YCbCr420 image * is specified in Table 4-2. The memory organization for a pixel-oriented * BGR565 image is specified in Table 4-1. * * Input Arguments: * * pSrc - an array of pointers to the YCbCr420 source planes * srcStep - an array of three step values; which represent for each image * plane, respectively, the distance in bytes between the starts of * consecutive lines in the source image. The following must be * true: srcStep[0] >= roiSize.width, srcStep[1]*2 >= * roiSize.width, and srcStep[2]*2 >= roiSize.width. * dstStep - distance in bytes between the starts of consecutive lines in * the destination image, must be an even number, and the following * condition must be true: dstStep/2 >= roiSize.width. * roiSize - size of the source and destination ROI in pixels * * Output Arguments: * * pDst - pointer to the destination buffer; BGR565 is represented using * 16-bit words that are orgranized as specified in Table 4-1. * * Return Value: * * OMX_Sts_NoErr - No error. Any other value indicates an error or a * warning * OMX_Sts_BadArgErr - bad arguments detected; at least one of the * following is true: * - pSrc or pDst is NULL * - dstStep has a non-even value * - at least one of the values srcStep[0..2] or dstStep[0..2] is negative * - srcStep[0] < roiSize.width * - srcStep[1]*2 < roiSize.width * - srcStep[2]*2 < roiSize.width * - dstStep/2 < roiSize.width * */ OMXResult omxIPCS_YCbCr420ToBGR565_U8_U16_P3C3R( const OMX_U8 *pSrc[3], OMX_INT srcStep[3], OMX_U16 *pDst, OMX_INT dstStep, OMXSize roiSize ){ OMX_INT convWidth = roiSize.width; /* convWidth is the bytes to read */ OMX_INT convHeight = roiSize.height; const OMX_U8 *Yptr, *Uptr, *Vptr; OMX_U8 Ydata, Udata, Vdata; OMX_F32 Rdata, Gdata, Bdata; OMX_U16 *BGRptr; OMX_INT i, j; armRetArgErrIf(!pSrc, OMX_Sts_BadArgErr); armRetArgErrIf(!pDst, OMX_Sts_BadArgErr); armRetArgErrIf(!pSrc[0], OMX_Sts_BadArgErr); armRetArgErrIf(!pSrc[1], OMX_Sts_BadArgErr); armRetArgErrIf(!pSrc[2], OMX_Sts_BadArgErr); armRetArgErrIf(srcStep[0] <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(srcStep[1] <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(srcStep[2] <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(dstStep <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(roiSize.width <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(roiSize.height <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(dstStep % 2, OMX_Sts_BadArgErr); armRetArgErrIf(srcStep[0] < roiSize.width, OMX_Sts_BadArgErr); armRetArgErrIf(srcStep[1]*2 < roiSize.width, OMX_Sts_BadArgErr); armRetArgErrIf(srcStep[2]*2 < roiSize.width, OMX_Sts_BadArgErr); dstStep >>= 1; /* dstStep is converted to half-word size length */ Yptr = pSrc[0]; Uptr = pSrc[1]; Vptr = pSrc[2]; for(i = 0; i < convHeight; i++, Yptr += srcStep[0], pDst += dstStep) { BGRptr = pDst; for(j = 0; j < convWidth; j++) { Ydata = Yptr[j]; Udata = Uptr[(OMX_INT)(j/2)]; Vdata = Vptr[(OMX_INT)(j/2)]; armIPCS_ComputeRGBFromYUV_F32(Ydata, Udata, Vdata, &Rdata, &Gdata, &Bdata); *BGRptr++ = armIPCS_PackToBGR565_F32(Bdata, Gdata, Rdata); } Uptr += (i%2) ? srcStep[1] : 0; Vptr += (i%2) ? srcStep[2] : 0; } return OMX_Sts_NoErr;}/* End of file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -