📄 omxipcs_ycbcr420rszcscrotbgr_u8_p3c3r.c
字号:
/** * * * File Name: omxIPCS_YCbCr420RszCscRotBGR_U8_P3C3R.c * OpenMAX DL: v1.0.2 * Revision: 10586 * Date: Wednesday, March 5, 2008 * * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. * * * * Description : Integrated Resize, Colour Conversion and Rotate Routine - Fractional version * 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_YCbCr420RszCscRotBGR_U8_P3C3R (4.4.3.5.2) * * Description: * This function combines several atomic image processing kernels into a * single function. In particular, the following sequence of operations is * applied to the input YCbCr image: * * 1. Resize. The input image of dimension srcSize is rescaled according * to the Q16 reciprocal ratio scaling control parameters rcpRatiox and * rcpRatioy using the interpolation/decimation methodology specified by * the control parameter interpolation. Nearest neighbor and bilinear * interpolation schemes are supported. The rescaled image is clipped to * dstSize using a clipping rectangle, the origin of which coincides with * the top, left corner of the input image, i.e., pixels are discarded * along the right and bottom edges. * * 2. Color space conversion. Following scaling, color space conversion * from either YCbCr420 or YCbCr422 to BGR is applied according to the * control parameter colorConversion. The following target BGR color * spaces are supported: BGR565, BGR888, BGR555, or BGR444. * * 3. Rotation. After color space conversion, the output image is rotated * with respect to the input image according to the control parameter * rotation. * * The input data should be in YCbCr420 planar format for the * function <omxIPCS_YCbCr420RszCscRotBGR_U8_P3CR> or YCbCr422 planar format * for the function <omxIPCS_YCbCr422RszCscRotBGR_U8_P3CR>. * The starting address of pDst must be aligned at 8-byte boundary; and * dstStep must be multiple of 8 when output format is BGR444/555/565, * and dstStep must be multiple of 2 when output format is BGR888. * The starting address of pSrc[0] must be aligned at a 4-byte boundary, * pSrc[1] must be aligned at a 2-byte boundary and pSrc[2] must be aligned * at a 2-byte boundary; and srcStep[0] must be multiple of 4, srcStep[1] * must be multiple of 2 and srcStep[2] must be multiple of 2. * * The parameter dstSize specifies the size of the image after the * resizing operation, but prior to the rotation operation. * * Input Arguments: * * pSrc - a 3-element vector containing pointers to the start of each of * the YCbCr420 or YCbCr422 input planes * srcStep - a 3-element vector containing the distance, in bytes, between * the start of lines in each of the input image planes * dstStep - distance, in bytes, between the start of lines in the * destination image * srcSize - dimensions, in pixels, of the source image * dstSize - dimensions, in pixels, of the destination image (before * applying rotation to the resizing image) * interpolation - interpolation methodology control parameter; must take * one of the following values: OMX_IP_NEAREST, or OMX_IP_BILINEAR * for nearest neighbor or bilinear interpolation, respectively. * colorConversion - color conversion control parameter; must be set to one * of the following pre defined values: OMX_IP_BGR565, * OMX_IP_BGR555, OMX_IP_BGR444, or OMX_IP_BGR888. * rotation - rotation control parameter; must be set to one of the * following pre-defined values: OMX_IP_DISABLE OMX_IP_ROTATE90L * OMX_IP_ROTATE90R OMX_IP_ROTATE180 OMX_IP_FLIP_HORIZONTAL * OMX_IP_FLIP_VERTICAL Counter-clockwise rotation is denoted by * the L postfix, and clockwise rotation is denoted by the R * postfix. A horizontal flip creates a mirror image with respect * to the vertical image axis, i.e., * "bow" -> horizontal flip -> "wod" * and a vertical flip creates a mirror image with respect to the * horizontal image axis, i.e., * "bow" -> vertical flip -> "pom" * rcpRatiox - x direction scaling control parameter, specified in terms of * a reciprocal resize ratio using a Q16 representation. Valid in * the range [1, xrr_max], where xrr_max = (OMX_INT) ((( (OMX_F32) * ((srcSize.width&~1)-1) / ((dstSize.width&~1)-1)) * (1<<16) * +0.5). Setting rcpRatiox = xrr_max guarantees that the output * image size will be exactly dstSize; otherwise for values less * than xrr_max the right hand side of the image will be clipped * since the output image will extend beyond dstSize. Expansion in * the x direction occurs for values of rcpRatiox < 65536; * contraction in the x direction occurs for values > 65536. To * avoid clipping, use the value xrr_max, which will ensure that * the output image width == dstSize.width. Values larger than * xrr_max are invalid, i.e., output images smaller than dstSize * are not allowed. * rcpRatioy - y direction scaling control parameter, specified in terms of * a reciprocal resize ratio using a Q16 representation. Valid in * the range [1, yrr_max], where yrr_max = (OMX_INT) ((( (OMX_F32) * (srcSize.height&~1)-1) / ((dstSize.height&~1)-1)) * (1<< 16) * +0.5). Setting rcpRatioy = yrr_max guarantees that the output * image size will be exactly dstSize; otherwise for values less * than yrr_max the bottom of the output image will be clipped * since the output image will be larger than dstSize. Expansion * in the y direction occurs for values of rcpRatioy < 65536; * contraction in the y direction occurs for values > 65536. To * avoid clipping, use the value yrr_max, which will ensure that * the output image height == dstSize.height. Values larger than * yrr_max are invalid, i.e., output images smaller than dstSize * are not allowed. * * Output Arguments: * * pDst - pointer to the start of the buffer containing the resized, * color-converted, and rotated output image. * * Return Value: * If the function runs without error, it returns OMX_Sts_NoErr. * If one of the following cases occurs, the function returns * OMX_Sts_BadArgErr: * - any pointer is NULL * - rcpRatioy is outside of the range [1, yrr_max], where yrr_max = * (OMX_INT) ((( (OMX_F32) (srcSize.height&~1)-1) / * ((dstSize.height&~1)-1)) * (1<< 16) + 0.5). * - rcpRatiox is outside of the range [1, xrr_max], where xrr_max = * (OMX_INT) ((( (OMX_F32) ((srcSize.width&~1)-1) / * ((dstSize.width&~1)-1)) * (1<<16) + 0.5). * - srcSize.width or srcSize.height <=0 * - dstSize.width or dstSize.height <=0 * - pDst is not aligned at 8 bytes boundary, * - pSrc[0] is not aligned at 4 bytes boundary, * - pSrc[1] is not aligned at 2 bytes boundary, or * - pSrc[2] is not aligned at 2 bytes boundary. * - srcStep[0], srcStep[1], srcStep[2] or dstStep is less than 1. * - srcStep[0] is not a multiple of 4, * - srcStep[1] is not multiple of 2, or * - srcStep[2] is not multiple of 2. * - dstStep is not a multiple of 8 when colorConversion is OMX_IP_BGR565, * OMX_IP_BGR555, or OMX_IP_BGR444; * - dstStep is not multiple of 2 when colorConversion is OMX_IP_BGR888. * - srcSize.width is larger than srcStep[0]; * - srcSize.width>>1 is larger than half of srcStep[1] or srcStep[2]. * - interpolation contains an invalid value * - colorConversion contains an invalid value * - rotation contains an invalid value * - dstSize.height * bytes/pixel of output image is larger than dstStep * when rotation is OMX_IP_ROTATE90L or OMX_IP_ROTATE90R; * - dstSize.width * bytes/pixel of output image is larger than * dstStep when other valid rotation options. * */ OMXResult omxIPCS_YCbCr420RszCscRotBGR_U8_P3C3R( const OMX_U8 *pSrc[3], OMX_INT srcStep[3], OMXSize srcSize, void *pDst, OMX_INT dstStep, OMXSize dstSize, OMXIPColorSpace colorConversion, OMXIPInterpolation interpolation, OMXIPRotation rotation, OMX_INT rcpRatiox, OMX_INT rcpRatioy ){ const OMX_U8 *pSrcY, *pSrcU, *pSrcV; OMX_U8 *pDstRGB1, *pDstRGB2, *pDstRGBRef1, *pDstRGBRef2; OMX_U8 Y00data, Y01data, Y10data, Y11data, Udata, Vdata; OMX_INT srcStepY, srcStepU, srcStepV, dstPixStep, dstRowStep, i, j; OMX_INT bytesPerOutPix = (colorConversion == OMX_IP_BGR888) ? 3 : 2; OMX_INT outBufWidth, outBufHeight; OMX_INT lumaPix, chromaPix; OMX_INT xPosLuma1, xPosLuma2, xPosChroma, xPos; OMX_INT yPosLuma1, yPosLuma2, yPosChroma; OMX_F32 xOff, yOffLuma1, yOffLuma2, yOffChroma; OMX_F32 gridRatioH = ((OMX_F32)rcpRatiox) / (1 << 16); OMX_F32 gridRatioV = ((OMX_F32)rcpRatioy) / (1 << 16); OMX_F32 rcpRatioXmax = (((srcSize.width & ~1) -1) << 16) / (OMX_F32)((dstSize.width & ~1) -1); OMX_F32 rcpRatioYmax = (((srcSize.height & ~1) -1) << 16) / (OMX_F32)((dstSize.height & ~1) -1); armRetArgErrIf(!pSrc, OMX_Sts_BadArgErr); armRetArgErrIf(!pSrc[0], OMX_Sts_BadArgErr); armRetArgErrIf(!pSrc[1], OMX_Sts_BadArgErr); armRetArgErrIf(!pSrc[2], OMX_Sts_BadArgErr); armRetArgErrIf(!srcStep, OMX_Sts_BadArgErr); armRetArgErrIf(!pDst, OMX_Sts_BadArgErr); armRetArgErrIf(srcSize.width <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(srcSize.height <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(dstSize.width <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(dstSize.height <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(armNot4ByteAligned(pSrc[0]), OMX_Sts_BadArgErr); armRetArgErrIf(armNot2ByteAligned(pSrc[1]), OMX_Sts_BadArgErr); armRetArgErrIf(armNot2ByteAligned(pSrc[2]), OMX_Sts_BadArgErr); armRetArgErrIf(armNot8ByteAligned(pDst), OMX_Sts_BadArgErr); armRetArgErrIf(armNot4ByteAligned(srcStep[0]), OMX_Sts_BadArgErr); armRetArgErrIf(armNot2ByteAligned(srcStep[1]), OMX_Sts_BadArgErr); armRetArgErrIf(armNot2ByteAligned(srcStep[2]), OMX_Sts_BadArgErr); armRetArgErrIf(rcpRatiox <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(rcpRatioy <= 0, OMX_Sts_BadArgErr); armRetArgErrIf(rcpRatiox > rcpRatioXmax, OMX_Sts_BadArgErr); armRetArgErrIf(rcpRatioy > rcpRatioYmax, OMX_Sts_BadArgErr);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -