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

📄 omxipcs_ycbcr422rszcscrotbgr_u8_p3c3r.c

📁 The OpenMAX DL (Development Layer) APIs contain a comprehensive set of audio, video, signal processi
💻 C
📖 第 1 页 / 共 2 页
字号:
    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);    armRetArgErrIf((colorConversion == OMX_IP_BGR888) && armNot2ByteAligned(dstStep), OMX_Sts_BadArgErr);    armRetArgErrIf((colorConversion != OMX_IP_BGR888) && armNot8ByteAligned(dstStep), OMX_Sts_BadArgErr);    armRetArgErrIf(srcStep[0] < 1, OMX_Sts_BadArgErr);    armRetArgErrIf(srcStep[1] < 1, OMX_Sts_BadArgErr);    armRetArgErrIf(srcStep[2] < 1, OMX_Sts_BadArgErr);    armRetArgErrIf(dstStep    < 1, OMX_Sts_BadArgErr);    armRetArgErrIf(srcSize.width > srcStep[0],        OMX_Sts_BadArgErr);    armRetArgErrIf((srcSize.width >> 1) > srcStep[1], OMX_Sts_BadArgErr);    armRetArgErrIf((srcSize.width >> 1) > srcStep[2], OMX_Sts_BadArgErr);    armRetArgErrIf((interpolation != OMX_IP_NEAREST) &&                    (interpolation != OMX_IP_BILINEAR), 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);    armRetArgErrIf((colorConversion != OMX_IP_BGR555) &&                    (colorConversion != OMX_IP_BGR565) &&                   (colorConversion != OMX_IP_BGR444) &&                    (colorConversion != OMX_IP_BGR888), OMX_Sts_BadArgErr);    if((rotation == OMX_IP_ROTATE90L) || (rotation == OMX_IP_ROTATE90R))    {        armRetArgErrIf((dstSize.height * bytesPerOutPix) > dstStep, OMX_Sts_BadArgErr);    }    else    {        armRetArgErrIf((dstSize.width * bytesPerOutPix) > dstStep, OMX_Sts_BadArgErr);    }    /*    ----------------------------------------------------------------------------------    In this reference implementation, resize 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 resized and colour converted     input) - the image is flipped along the major diagonal, after resizing & colour     conversion, and before writing to the output buffer.        Resize:    Resizing is easier, if we have a have a unified grid containing both input and    rescaled images. The pixel (0,0) of the input image co-incides with the pixel     (0,0) of the output image.  We can compute the relative position of rescaled     pixels on the original image grid using the formula -    PIXnew(x,y) = PIXold(x*gridRatioH, y*gridRatioV),    where gridRatioH = SourceWidth/DestWidth and gridRatioV = SourceHeight/DestHeight    Then we apply either the Nearest Neighbour or Bilinear interpolation accordingly.        It is important to note that if DstWidth and DstHeight are not big enough to hold     the interpolated data, the interpolated image gets clipped such that we get the     top-left portion of the interpolated image in the output buffer.        After interpolation, the YUV422 data is converted from planar domain, to a pixel    domain in the from of |Y|U|Y|V|.        Colour Space Conversion:    CSC is clubbed with scale reduction and hence doesn't have to be done in-place.    A function armIPCS_RGBConvertAndPack() is called, after reading the scaled     input pixels. This function calls the relevant macros to perform YUV422->RGB    conversion and then pixel packing (BGR565 or BGR555).    ----------------------------------------------------------------------------------    */        pSrcY       = pSrc[0];    pSrcU       = pSrc[1];    pSrcV       = pSrc[2];    srcStepY    = srcStep[0];    srcStepU    = srcStep[1];    srcStepV    = srcStep[2];        if((rotation == OMX_IP_ROTATE90L) || (rotation == OMX_IP_ROTATE90R))    {        dstPixSkip  = dstStep;        dstRowSkip  = bytesPerOutPix;    }    else    {        dstPixSkip  = bytesPerOutPix;        dstRowSkip  = dstStep;    }    if(interpolation == OMX_IP_NEAREST)    {        for(i = 0; i < dstSize.height; i++)        {            yPos    = armRoundFloatToS32(i * gridRatioV);            lumaPix = chromaPix = 0;            pDstRGB = (OMX_U8 *)pDst + (dstRowSkip * i);                        for(j = 0; j < dstSize.width; j += 2)            {                xPosLuma1   = armRoundFloatToS32(lumaPix++ * gridRatioH);                xPosLuma2   = armRoundFloatToS32(lumaPix++ * gridRatioH);                xPosChroma  = armRoundFloatToS32(chromaPix++ * gridRatioH);                Y0data      = pSrcY[xPosLuma1  + (yPos * srcStepY)];                Udata       = pSrcU[xPosChroma + (yPos * srcStepU)];                Y1data      = pSrcY[xPosLuma2  + (yPos * srcStepY)];                Vdata       = pSrcV[xPosChroma + (yPos * srcStepV)];                                armIPCS_BGRConvertAndPack(Y0data, Udata, Vdata, colorConversion, (void *)pDstRGB);                pDstRGB += dstPixSkip;                armIPCS_BGRConvertAndPack(Y1data, Udata, Vdata, colorConversion, (void *)pDstRGB);                pDstRGB += dstPixSkip;            }        }    }        else if(interpolation == OMX_IP_BILINEAR)    {        for(i = 0; i < dstSize.height; i++)        {            yPos    = (OMX_INT)(i * gridRatioV);            yOff    = (i * gridRatioV) - yPos;            lumaPix = chromaPix = 0;            pDstRGB = (OMX_U8 *)pDst + (dstRowSkip * i);                        for(j = 0; j < dstSize.width; j += 2)            {                xPos    = (OMX_INT)(lumaPix * gridRatioH);                xOff    = (lumaPix * gridRatioH) - xPos;                armIPCS_InterpPixel_Bilinear(pSrcY, srcStepY, xPos, yPos, xOff, yOff, &Y0data);                lumaPix++;                                xPos    = (OMX_INT)(lumaPix * gridRatioH);                xOff    = (lumaPix * gridRatioH) - xPos;                armIPCS_InterpPixel_Bilinear(pSrcY, srcStepY, xPos, yPos, xOff, yOff, &Y1data);                lumaPix++;                                xPos    = (OMX_INT)(chromaPix * gridRatioH);                xOff    = (chromaPix * gridRatioH) - xPos;                armIPCS_InterpPixel_Bilinear(pSrcU, srcStepU, xPos, yPos, xOff, yOff, &Udata);                armIPCS_InterpPixel_Bilinear(pSrcV, srcStepV, xPos, yPos, xOff, yOff, &Vdata);                chromaPix++;                                armIPCS_BGRConvertAndPack(Y0data, Udata, Vdata, colorConversion, (void *)pDstRGB);                pDstRGB += dstPixSkip;                armIPCS_BGRConvertAndPack(Y1data, Udata, Vdata, colorConversion, (void *)pDstRGB);                pDstRGB += dstPixSkip;            }        }    }        /*    ---------------------------------------------------------------------------------    Rotation:    The Rotation operation follows the Resize-CSC and is to be done in-place.    The formulae for different flavours of rotation -    H flip: OutPix(x,y) = InPix(width-x,y),    V flip: OutPix(x,y) = InPix(x,height-y),    180 is: OutPix(x,y) = InPix(width-x,height-y),    90L is: OutPix(y,x) = InPix(x,height-y),    90R is: OutPix(y,x) = InPix(width-x,y),        The formulae for rotation by 90R and 90L listed above can't be implemented     in-place elegantly, in single looping through the image, and hence it is done    in two iterations (both of which can be done in-place, easily):    [1] The input is transformed according to the formulae OutPix(y,x) = InPix(x,y).        This is equivalent to flipping the image along the major diagonal and is         already performed during the Resize-Csc phase.    [2] Then we flip it along HORIZ axis (for 90L) and VERT axis (for 90R).    ---------------------------------------------------------------------------------    */        outBufWidth   = dstSize.width;    outBufHeight  = dstSize.height;        switch(rotation)    {        case OMX_IP_FLIP_HORIZONTAL : armIPCS_FlipLeftRight_I(pDst, bytesPerOutPix, dstStep, outBufWidth, outBufHeight);                                      break;        case OMX_IP_FLIP_VERTICAL   : armIPCS_FlipTopBottom_I(pDst, bytesPerOutPix, dstStep, outBufWidth, outBufHeight);                                      break;        case OMX_IP_ROTATE180       : armIPCS_Rotate180_I(pDst, bytesPerOutPix, dstStep, outBufWidth, outBufHeight);                                      break;        case OMX_IP_ROTATE90L       : armIPCS_FlipTopBottom_I(pDst, bytesPerOutPix, dstStep, outBufHeight, outBufWidth);                                      break;        case OMX_IP_ROTATE90R       : armIPCS_FlipLeftRight_I(pDst, bytesPerOutPix, dstStep, outBufHeight, outBufWidth);                                      break;        default                     : break;    }    return OMX_Sts_NoErr;}/* End of file */

⌨️ 快捷键说明

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