📄 armipcs_flip.c
字号:
/** * * * File Name: armIPCS_Flip.c * OpenMAX DL: v1.0.2 * Revision: 10586 * Date: Wednesday, March 5, 2008 * * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. * * * * Description : Contains functions that do basic flipping and rotation of input images. * */#include "omxtypes.h"#include "armIP.h"/** * Functions: armIPCS_FlipTopBottom_I * * Description: * This function flips the image w.r.t X axis and does it in-place. * The formula being used is OutPix(x,y) = InPix(x,height-y). * No assumption is being made on the buffer alignment. * * Return Value: * OMXResult -- Error status from the function */ OMXResult armIPCS_FlipTopBottom_I( void *pBuf, /* Pointer to the Image Buffer */ OMX_INT bufElemSize, /* Number of bytes in one element */ OMX_INT bufStep, /* Offset in bytes between two rows */ OMX_INT bufWidth, /* Number of elements in one row */ OMX_INT bufHeight /* Number of rows in the image */ ){ OMX_U8 *pBufTop = (OMX_U8*)pBuf; OMX_U8 *pBufBot = (OMX_U8*)pBuf + (bufHeight - 1) * bufStep; OMX_INT i, j; armRetArgErrIf(!pBuf, OMX_Sts_BadArgErr); for(i = 0; i < bufHeight/2; i++) { for(j = 0; j < bufWidth; j++) { armSwapElem((pBufTop + j *bufElemSize), (pBufBot + j * bufElemSize), bufElemSize); } pBufTop += bufStep; pBufBot -= bufStep; } return OMX_Sts_NoErr;}/** * Functions: armIPCS_FlipLeftRight_I * * Description: * This function flips the image w.r.t Y axis and does it in-place. * The formula being used is OutPix(x,y) = InPix(width-x,y). * The size of each element of the image is specified in <bufElemSize> * and no assumption is being made on the buffer alignment. * * Return Value: * OMXResult -- Error status from the function */ OMXResult armIPCS_FlipLeftRight_I( void *pBuf, /* Pointer to the Image Buffer */ OMX_INT bufElemSize, /* Number of bytes in one element */ OMX_INT bufStep, /* Offset in bytes between two rows */ OMX_INT bufWidth, /* Number of elements in one row */ OMX_INT bufHeight /* Number of rows in the image */ ){ OMX_U8 *pBufLeft = (OMX_U8*)pBuf; OMX_U8 *pBufRight = (OMX_U8*)pBuf + (bufWidth - 1) * bufElemSize; OMX_INT i, j; armRetArgErrIf(!pBuf, OMX_Sts_BadArgErr); for(i = 0; i < bufHeight; i++) { for(j = 0; j < bufWidth/2; j++) { armSwapElem((pBufLeft + j * bufElemSize), (pBufRight - j * bufElemSize), bufElemSize); } pBufLeft += bufStep; pBufRight += bufStep; } return OMX_Sts_NoErr;}/** * Functions: armIPCS_FlipMajorDiagonal_I * * Description: * This function flips the image w.r.t major diagonal and does it in-place. * The formula being used is OutPix(y,x) = InPix(x,y). * The size of each element of the image is specified in <bufElemSize> * and no assumption is being made on the buffer alignment. * * Return Value: * OMXResult -- Error status from the function */ OMXResult armIPCS_FlipMajorDiagonal_I( void *pBuf, /* Pointer to the Image Buffer */ OMX_INT bufElemSize, /* Number of bytes in one element */ OMX_INT bufStep, /* Offset in bytes between two rows */ OMX_INT bufWidth, /* Number of elements in one row */ OMX_INT bufHeight /* Number of rows in the image */ ){ OMX_U8 *pBufRight = (OMX_U8*)pBuf; OMX_U8 *pBufDown = (OMX_U8*)pBuf; OMX_INT loopCnt = (bufWidth > bufHeight) ? bufWidth : bufHeight; OMX_INT i, j; armRetArgErrIf(!pBuf, OMX_Sts_BadArgErr); for(i = 0; i < loopCnt; i++) { for(j = 0; j < i; j++) { armSwapElem((pBufRight + j * bufStep), (pBufDown + j * bufElemSize), bufElemSize); } pBufRight += bufElemSize; pBufDown += bufStep; } return OMX_Sts_NoErr;}/** * Functions: armIPCS_Rotate180_I * * Description: * The function rotates the buffer by 180 degree and does it in-place. * The formula being used is OutPix(x,y) = InPix(width-x,height-y). * The size of each element of the image is specified in <bufElemSize> * and no assumption is being made on the buffer alignment. * * Return Value: * OMXResult -- Error status from the function */ OMXResult armIPCS_Rotate180_I( void *pBuf, /* Pointer to the Image Buffer */ OMX_INT bufElemSize, /* Number of bytes in one element */ OMX_INT bufStep, /* Offset in bytes between two rows */ OMX_INT bufWidth, /* Number of elements in one row */ OMX_INT bufHeight /* Number of rows in the image */ ){ OMX_U8 *pBufLeft, *pBufRight; OMX_U8 *pBufTop = (OMX_U8*)pBuf; OMX_U8 *pBufBot = (OMX_U8*)pBuf + (bufWidth - 1) * bufElemSize + (bufHeight - 1) * bufStep; OMX_INT i, j; armRetArgErrIf(!pBuf, OMX_Sts_BadArgErr); /* ------------------------------------------------------------------- The function rotates the buffer by 180 degree and does it in-place. The formulae for this is OutPix(x,y) = InPix(width-x,height-y) ------------------------------------------------------------------- */ for(i = 0; i < bufHeight/2; i++) { for(j = 0; j < bufWidth; j++) { armSwapElem((pBufTop + j * bufElemSize), (pBufBot - j * bufElemSize), bufElemSize); } pBufTop += bufStep; pBufBot -= bufStep; } /* ---------------------------------------------------------------------------- This part of the code handles cases, where the <bufHeight> is an odd number. ---------------------------------------------------------------------------- */ if(bufHeight % 2) { pBufLeft = (OMX_U8*)pBuf + ((OMX_INT)(bufHeight/2)) * bufStep; pBufRight = (OMX_U8*)pBuf + ((OMX_INT)(bufHeight/2)) * bufStep + (bufWidth - 1) * bufElemSize; for(i = 0; i < bufWidth/2; i++) { armSwapElem((pBufLeft + i), (pBufRight - i), bufElemSize); } } return OMX_Sts_NoErr;}/* End of file */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -