⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 omxipcs_cbycry422rszcscrotbgr_u8_u16_c2r.c

📁 The OpenMAX DL (Development Layer) APIs contain a comprehensive set of audio, video, signal processi
💻 C
📖 第 1 页 / 共 2 页
字号:
/** * *  * File Name:  omxIPCS_CbYCrY422RszCscRotBGR_U8_U16_C2R.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 - Integral version *                The source is in two-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"#include "armIP.h"static OMXVoid armIPCS_ColourConvertAndPack(OMX_U8 Ydata, OMX_U8 Udata, OMX_U8 Vdata, OMXIPColorSpace colorConversion, OMX_U16 *pDstRGB);/** * Function:  omxIPCS_CbYCrY422RszCscRotBGR_U8_U16_C2R   (4.4.3.3.1) * * Description: * This function synthesizes a low-resolution preview image from the input  * image.  In particular, the following sequence of operations is applied to  * the input image:  * *   1. Scale reduction by an integer scalefactor.  First, the input image *   scale is reduced by an integer scalefactor of either 2, 4, or 8  *   on both axes using the interpolation methodology specified by the   *   control parameter interpolation. The following interpolation schemes  *   are supported: nearest neighbor, bilinear.  * *   2. Color space conversion.  Following scale reduction, color *   space conversion is applied from the CbYCrY422 input color  *   space to a particular BGR target space determined by the control parameter  *   RGBSpec.  * *   3. Rotation. After color space conversion, the preview output  *   image is rotated according to the control parameter rotation.  * * The start address of pSrc, pDst, must be aligned at 8-byte  * boundary; srcStep and dstStep must be multiple of 8. Size of  * * If roiSize.width or roiSize.height cannot be divided by scaleFactor  * exactly, it will be cut to be the multiple of scaleFactor. For example,  * if the rotation control parameter is OMX_IP_DISABLE or OMX_IP_ROTATE180,  * the output image's roiSize.width is equal to: * *     ROUND((input image's roiSize.width)/scaleFactor) * * Input Arguments: *    *   pSrc - pointer to the start of the buffer containing the pixel-oriented  *            input image  *   srcStep - distance, in bytes, between the start of lines in the source  *            image  *   dstStep - distance, in bytes, between the start of lines in the  *            destination image  *   roiSize - dimensions, in pixels, of the source region of interest  *   scaleFactor - reduction scalefactor; values other than 2, 4, or 8 are  *            invalid  *   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  *   RGBSpec - color conversion control parameter; must be set to one of the  *            following pre-defined values: OMX_IP_BGR565 or OMX_IP_BGR555  *   rotation - rotation control parameter; must be set to one of the  *            following pre-defined values: OMX_IP_DISABLE, OMX_IP_ROTATE90L,  *            OMX_IP_ROTATE90R, or OMX_IP_ROTATE180  * * 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 occurs, the function returns OMX_Sts_BadArgErr:  *    -   pSrc or pDst is NULL  *    -   pSrc or pDst is not aligned on an 8-byte boundary  *    -   srcStep or dstStep is less than 1,  *    -   srcStep, or dstStep is not a multiple of 8  *    -   roiSize.width is larger than half of srcStep  *    -   roiSize.width or roiSize.height is less than scaleFactor  *    Invalid values of one or more of the following control parameters:  *    -    scaleFactor, interpolation, colorConversion or rotation  *    -    Half of the dstStep is less than width of downscaled,  *              color-converted and rotated image  * */ OMXResult omxIPCS_CbYCrY422RszCscRotBGR_U8_U16_C2R(        const OMX_U8 *pSrc,        OMX_INT srcStep,        OMX_U16 *pDst,        OMX_INT dstStep,        OMXSize roiSize,        OMX_INT scaleFactor,        OMXIPInterpolation interpolation,        OMXIPColorSpace colorConversion,        OMXIPRotation rotation       ){    OMX_INT outBufWidth, outBufHeight, i, j;    OMX_INT srcRowSkipY = 0, srcRowSkipUV = 0, srcPixSkipY = 0, srcPixSkipUV = 0;    OMX_INT dstPixSkip = 0, dstRowSkip = 0;    OMX_U8  Y0data, Y1data, Udata, Vdata;    OMX_U16 *pDstRGB, tempPix16;    const OMX_U8 *pSrcY, *pSrcU, *pSrcV;    const OMX_U8 *pRefSrcY = NULL, *pRefSrcU = NULL, *pRefSrcV = NULL;        armRetArgErrIf(!pSrc, OMX_Sts_BadArgErr);    armRetArgErrIf(!pDst, OMX_Sts_BadArgErr);    armRetArgErrIf(!armIs8ByteAligned(pSrc), OMX_Sts_BadArgErr);    armRetArgErrIf(!armIs8ByteAligned(pDst), OMX_Sts_BadArgErr);    armRetArgErrIf(!armIs8ByteAligned(srcStep), OMX_Sts_BadArgErr);    armRetArgErrIf(!armIs8ByteAligned(dstStep), OMX_Sts_BadArgErr);    armRetArgErrIf(srcStep < 1, OMX_Sts_BadArgErr);    armRetArgErrIf(dstStep < 1, OMX_Sts_BadArgErr);    armRetArgErrIf(roiSize.width > srcStep/2, OMX_Sts_BadArgErr);    armRetArgErrIf(roiSize.width < scaleFactor, OMX_Sts_BadArgErr);    armRetArgErrIf(roiSize.height < scaleFactor, OMX_Sts_BadArgErr);    armRetArgErrIf((scaleFactor != 2) && (scaleFactor != 4) && (scaleFactor != 8), OMX_Sts_BadArgErr);    armRetArgErrIf((interpolation != OMX_IP_NEAREST) && (interpolation != OMX_IP_BILINEAR), OMX_Sts_BadArgErr);    armRetArgErrIf((colorConversion != OMX_IP_BGR555) && (colorConversion != OMX_IP_BGR565), OMX_Sts_BadArgErr);    armRetArgErrIf((rotation != OMX_IP_ROTATE90L) && (rotation != OMX_IP_ROTATE90R) &&                   (rotation != OMX_IP_ROTATE180) && (rotation != OMX_IP_DISABLE) &&                   (rotation != OMX_IP_FLIP_HORIZONTAL) && (rotation != OMX_IP_FLIP_VERTICAL), OMX_Sts_BadArgErr);    /*    ------------------------------------------------------------------------------    In this reference implementation, scale reduction and colour space conversion    are clubbed together.  In this part of algorithm, ROTATE90 cases are handled    differently (as the output buffer may not be big enough to hold the scaled &    colour converted input) - the image is flipped along the major diagonal, after    scale reduction & colour conversion, and before writing to the output buffer.        Scale Reduction:    Supported interpolation schemes are Nearest Neighbor and Bilinear.    Based on the scaleFactor:    [1] Initialize the Y, U and V pointers in the row to be processed    [2] Set the pixelSkipStep and rowSkipStep for all of Y, U and V pointers    [3] Now each of the interpolation type runs these through a generic loop -         The Nearest Neighbour chooses the pixel data pointed to by Y, U, V         pointers; where as Bilinear, averages the four pixels (for Y) and/or         two pixels (for UV) that surround the interpolated pixel.            For understanding the pointer initialization and arithmetic of the below    loops easily, the interpolation mechanism is represented diagramatically -        Scale Reduction by 2:    --------------------------------    |Y11 U11 Y12 V11|Y13 U12 Y14 V12|...          -------------------------    --------------------------------      ====>>  |Yout1 Uout1|Yout2 Vout1|    |Y21 U21 Y22 V21|Y23 U22 Y24 V22|...          -------------------------    --------------------------------        Yout1 = Interpolate(Y11, Y12, Y21, Y22)    Uout1 = Interpolate(U11, U21)    Yout2 = Interpolate(Y13, Y14, Y23, Y24)    Vout1 = Interpolate(V11, V21)            Scale Reduction by 4:    ----------------------------------------------------------------    |Y11 U11 Y12 V11|Y13 U12 Y14 V12|Y15 U13 Y16 V13|Y17 U14 Y18 V14|...    ----------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -