📄 omxsp_filtermedian_s32.c
字号:
/** * * File Name: omxSP_FilterMedian_S32.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 median filtering * */#include "omxtypes.h"#include "armOMX.h"#include "omxSP.h"#include "armCOMM.h"/** * Function: omxSP_FilterMedian_S32 (2.2.3.4.1) * * Description: * This function computes the median over the region specified by the median * mask for the every element of the input array. The median outputs are * stored in the corresponding elements of the output vector. * * Input Arguments: * * pSrc - pointer to the input vector * len - number of elements contained in the input and output vectors (0 < * len < 65536) * maskSize - median mask size; if an even value is specified, the function * subtracts 1 and uses the odd value of the filter mask for median * filtering (0 < maskSize < 256) * * Output Arguments: * * pDst - pointer to the median-filtered output vector * * Return Value: * * OMX_Sts_NoErr - no error * OMX_Sts_BadArgErr - bad arguments; returned if one or more of the * following is true: * - one or more of the following pointers is NULL: pSrc, pDst. * - len < 0 * - maskSize < 1 or maskSize> 255 * OMX_StsSP_EvenMedianMaskSizeErr - even mask size replaced by odd mask * size * */OMXResult omxSP_FilterMedian_S32( const OMX_S32 *pSrc, OMX_S32 *pDst, OMX_INT len, OMX_INT maskSize ){ OMX_S32 sortedData[256]; OMX_S32 *pSort; const OMX_S32 *pTempSrc; OMX_S32 firstElement,lastElement,temp; OMX_INT maskByTwo,i,j,count; /* Argument Check */ armRetArgErrIf( pSrc == NULL , OMX_Sts_BadArgErr); armRetArgErrIf( pDst == NULL , OMX_Sts_BadArgErr); armRetArgErrIf( len <= 0 , OMX_Sts_BadArgErr); armRetArgErrIf( len >= 65536 , OMX_Sts_BadArgErr); armRetArgErrIf( maskSize <= 0 , OMX_Sts_BadArgErr); armRetArgErrIf( maskSize >= 256 , OMX_Sts_BadArgErr); armRetArgErrIf( maskSize > len , OMX_Sts_BadArgErr); /* Processing */ if(!(maskSize & 1)) { maskSize--; } maskByTwo = ((maskSize - 1)>>1); firstElement = pSrc[0]; lastElement = pSrc[len - 1]; for(count = 0 ; count < len ; count ++) { pSort = sortedData; pTempSrc = pSrc; /* Initialize the array */ if ( count < maskByTwo ) { for(i = 0 ; i < (maskByTwo - count) ; i++) { *pSort++ = firstElement; } for(i = 0; i <= count; i++) { *pSort++ = *pTempSrc++; } } else { for(i = 0; i <= maskByTwo; i++) { *pSort++ = *pTempSrc++; } pSrc++; } if ( (len - count - 1) < maskByTwo ) { for(i = 0; i < (len - count - 1); i++) { *pSort++ = *pTempSrc++; } for(i = 0; i < ( maskByTwo - (len - count - 1) ); i++) { *pSort++ = lastElement; } } else { for(i = 0; i < maskByTwo; i++) { *pSort++ = *pTempSrc++; } } /*Sort the Data - Bubble sort implementation*/ for(i = 0 ; i <= maskByTwo ; i++) { for(j = 0; j < (maskSize - 1 - i); j++ ) { if(sortedData[j+1] < sortedData[j]) { temp = sortedData[j]; sortedData[j] = sortedData[j+1]; sortedData[j+1] = temp; } } } *pDst = sortedData[maskByTwo]; pDst++; } return OMX_Sts_NoErr;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -