📄 omxipcs_colortwistq14_u8_c3r.c
字号:
/** * * * File Name: omxIPCS_ColorTwistQ14_U8_C3R.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 - Colour Twist in fixed point. * The source is in three-channel format and pixel domain, and * the destination in three-channel format and pixel domain. * */#include "omxtypes.h"#include "armCOMM.h"#include "armOMX.h"#include "omxIP.h"/** * Function: omxIPCS_ColorTwistQ14_U8_C3R (4.4.3.2.1) * * Description: * Applies a Q17.14 color twist matrix to the ROI of the source image pointed * to by pSrc. Places the results into the ROI of the destination image * pointed to by pDst. The Q14 modifier with a parameter of type OMX_S32 is * used to indicate the fact that the matrix entries are obtained by * multiplying the entries of the equivalent floating-point color twist matrix * with (1<<14). * * Input Arguments: * * pSrc - pointer to the source ROI; should contain three interleaved * ( C3 ) channels of 8-bit image data. * srcStep - distance in bytes between the starts of consecutive lines in * the source image * dstStep - distance in bytes between the starts of consecutive lines in * the destination image * roiSize - size of the source and destination ROI in pixels * twistQ14 - twist matrix * * Output Arguments: * * pDst - pointer to the destination ROI; contains transformed version of * the input ROI. * * Return Value: * * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments detected; at least one of the * following is true: * - pSrc or pDst is NULL * - srcStep or dstStep is less than or equal to zero * - srcStep/3 < roiSize.width * - dstStep/3 < roiSize.width * - roiSize has a field with zero or negative value * */ OMXResult omxIPCS_ColorTwistQ14_U8_C3R( const OMX_U8* pSrc, OMX_INT srcStep, OMX_U8* pDst, OMX_INT dstStep, OMXSize roiSize, const OMX_S32 twistQ14[3][4] ){ OMX_INT convWidth = 3 * roiSize.width; /* convWidth is the bytes to read */ OMX_INT convHeight = roiSize.height; OMX_U8 pix0, pix1, pix2; OMX_U16 round = 1 << 13; OMX_INT i, j; OMX_S32 Ct00 = twistQ14[0][0]; OMX_S32 Ct01 = twistQ14[0][1]; OMX_S32 Ct02 = twistQ14[0][2]; OMX_S32 Ct03 = twistQ14[0][3]; OMX_S32 Ct10 = twistQ14[1][0]; OMX_S32 Ct11 = twistQ14[1][1]; OMX_S32 Ct12 = twistQ14[1][2]; OMX_S32 Ct13 = twistQ14[1][3]; OMX_S32 Ct20 = twistQ14[2][0]; OMX_S32 Ct21 = twistQ14[2][1]; OMX_S32 Ct22 = twistQ14[2][2]; OMX_S32 Ct23 = twistQ14[2][3]; armRetArgErrIf(!pSrc, OMX_Sts_BadArgErr); armRetArgErrIf(!pDst, OMX_Sts_BadArgErr); armRetArgErrIf(srcStep <= 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(srcStep/3 < roiSize.width, OMX_Sts_BadArgErr); armRetArgErrIf(dstStep/3 < roiSize.width, OMX_Sts_BadArgErr); /* ------------------------------------------------------------------------------------------------- Colour Twist Matrix (in Q1.14 format) and Equations Q17.14 Format: -bit[31]*pow(2,17) + Summation from 0 to 16 of {bit[14+i]*pow(2,i)} + Summation from 1 to 14 of {bit[14-i]*pow(2,-i)} This has one sign bit, 17 integer bits and 14 binary point bits ==> Totally 32 bits. |Ct00 Ct01 Ct02 Ct03| TwistQ14 = |Ct10 Ct11 Ct12 Ct13| |Ct20 Ct21 Ct22 Ct23| newPix0 = (Ct00*pix0 + Ct01*pix1 + Ct02*pix2 + Ct03 + Rounding) / (1<<14) newPix1 = (Ct10*pix0 + Ct11*pix1 + Ct12*pix2 + Ct13 + Rounding) / (1<<14) newPix2 = (Ct20*pix0 + Ct21*pix1 + Ct22*pix2 + Ct23 + Rounding) / (1<<14) Since the newPix values have to be eventually saturated between OMX_MIN_U8 and OMX_MAX_U8, the division by (1<<14) could as well be replaced with a right-shift by 14. ------------------------------------------------------------------------------------------------- */ for(i=0; i<convHeight; i++, pSrc+=srcStep, pDst+=dstStep) { for(j=0; j<convWidth; j+=3) { pix0 = pSrc[j]; pix1 = pSrc[j+1]; pix2 = pSrc[j+2]; pDst[j] = (OMX_U8)armClip(OMX_MIN_U8, OMX_MAX_U8, (pix0*Ct00 + pix1*Ct01 + pix2*Ct02 + Ct03 + round) >> 14); pDst[j+1] = (OMX_U8)armClip(OMX_MIN_U8, OMX_MAX_U8, (pix0*Ct10 + pix1*Ct11 + pix2*Ct12 + Ct13 + round) >> 14); pDst[j+2] = (OMX_U8)armClip(OMX_MIN_U8, OMX_MAX_U8, (pix0*Ct20 + pix1*Ct21 + pix2*Ct22 + Ct23 + round) >> 14); } } return OMX_Sts_NoErr;}/* End of file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -