📄 omxippp_filterfir_u8_c1r.c
字号:
/** * * File Name: omxIPPP_FilterFIR_U8_C1R.c * OpenMAX DL: v1.0.2 * Revision: 10586 * Date: Wednesday, March 5, 2008 * * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. * * * * Description: * This file contains module for 2 dimensional filtering * */#include "omxtypes.h"#include "armOMX.h"#include "omxIP.h"#include "armCOMM.h"static OMX_S32 armIPPP_Mac( OMX_S32 mac, OMX_S32 filtCoeff, OMX_U8 input);/** * Function: omxIPPP_FilterFIR_U8_C1R (4.3.1.1.1) * * Description: * Performs filtering of the ROI of the source image pointed to by pSrc using * a general rectangular (WxH size) convolution kernel. The value of the * output pixel is normalized by the divider and saturated as: * * SAT<U8>(1/divider * PSI<2D>(h,a,x)) * * The result is placed into the ROI of the destination image pointed to by pDst. * * Input Arguments: * * pSrc - pointer to the source ROI * 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 * pKernel - pointer to the 2D FIR filter coefficients * kernelSize - size of the FIR filter kernel. The minimum valid size is * 1x1. There is no limit on the maximum size other than the * practical limitation imposed by the ROI size and location * relative to the image boundaries. The caller should avoid * kernel overlap with invalid buffer locations given ROI size, ROI * placement relative to the image buffer boundaries, and the FIR * operator definition given in Table 4-4. * anchor - anchor cell specifying the alignment of the array of filter * taps with respect to the position of the input pixel * divider - value of the divider used to normalize the result * * Output Arguments: * * pDst - pointer to the destination ROI * * Return Value: * * OMX_Sts_NoErr - no errors detected * 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 * - roiSize has a field with zero or negative value. * - anchor specifies a point outside of the mask divider is out of range * */OMXResult omxIPPP_FilterFIR_U8_C1R( const OMX_U8* pSrc, OMX_INT srcStep, OMX_U8* pDst, OMX_INT dstStep, OMXSize roiSize, const OMX_S32* pKernel, OMXSize kernelSize, OMXPoint anchor, OMX_INT divider ){ OMX_INT width,height; OMX_INT kerWidth,kerHeight; OMX_INT ax,ay; OMX_INT i,j,m,n; OMX_F32 div; OMX_S32 result,mac; const OMX_S32 *pKerTemp; const OMX_U8 *pSrcTemp; /* Argument Check */ armRetArgErrIf(!pDst , OMX_Sts_BadArgErr); armRetArgErrIf(!pSrc , OMX_Sts_BadArgErr); armRetArgErrIf(!pKernel, 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(kernelSize.width <= 0 , OMX_Sts_BadArgErr); armRetArgErrIf(kernelSize.height <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(anchor.x < 0, OMX_Sts_BadArgErr); armRetArgErrIf(anchor.y < 0, OMX_Sts_BadArgErr); armRetArgErrIf(anchor.x >= kernelSize.width , OMX_Sts_BadArgErr); armRetArgErrIf(anchor.y >= kernelSize.height, OMX_Sts_BadArgErr); armRetArgErrIf(divider == 0, OMX_Sts_BadArgErr); /* Processing */ width = roiSize.width; height = roiSize.height; kerWidth = kernelSize.width; kerHeight = kernelSize.height; ax = anchor.x; ay = anchor.y; div = (OMX_F32)divider; for(n = 0 ; n < height ; n++) { for(m = 0 ; m < width ; m++) { pSrcTemp = pSrc + m + ax + ay * srcStep; /*pSrc(m + ax,n + ay)*/ pKerTemp = pKernel; mac = 0; /* Compute the Output */ for( j = 0; j < kerHeight ; j++) { for( i = 0; i < kerWidth ; i++) { mac = armIPPP_Mac(mac,pKerTemp[i],pSrcTemp[-i]); } pSrcTemp -= srcStep; pKerTemp += kerWidth; } /*Store the Output*/ result = armRoundFloatToS32(mac / div); result = armClip (0,255,result); pDst[m] = (OMX_U8)result; } pDst += dstStep; pSrc += srcStep; } return OMX_Sts_NoErr;}static OMX_S32 armIPPP_Mac(OMX_S32 mac, OMX_S32 filtCoeff,OMX_U8 input){ OMX_S16 hi; OMX_U16 lo; OMX_S32 result; /* Multiply Operation */ hi = (OMX_S16)( filtCoeff >> 16); lo = (OMX_U16)( (OMX_U32)(filtCoeff << 16) >> 16 ); result = (hi * input) << 8; result += (lo * input) >> 8; if( result > ( (OMX_S32)OMX_MAX_S32 >> 8) ) { result = OMX_MAX_S32; } else if(result < ( (OMX_S32)OMX_MIN_S32 >> 8) ) { result = OMX_MIN_S32; } else { result = filtCoeff * input; } /* Accumulate Operation */ result = armSatAdd_S32(mac, result); return result;}/* End of File */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -