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

📄 ycbcr420.c

📁 jpeg图像文件软件解码器的arm版本的源代码程序
💻 C
字号:
///////////////////////////////////////////////////////////////////////////////
//
//  YCbCr420.c
//
//  DESCRIPTION
//       Accepts the MCU blocks available in 4:2:0 format. Convert them to the
//       specified formats:
//           1. RGB32
//         2. RGB24
//         3. RGB565
//         4. RGB555
//
//
///////////////////////////////////////////////////////////////////////////////

#include "YCbCr420.h"

#if SUPPORT_YUV420

#if SUPPORT_RGB32
/////////////////////////////////////////////////////////////////////////////
// NAME  
//            YCbCr420ToRGB32
//
// DESCRIPTION
//            Convert YCbCr420 format to RGB32 format
//
// INPUTS   
//            imageBlocks  - pointer to YUV buffers
//            decodedImage - pointer to output image structure 
// 
// OUTPUTS  
//            decodedImage - store output in output image structure        
//
// RETURN VALUE
//          Always returns JPEG_OK    
//           
/////////////////////////////////////////////////////////////////////////////
int YCbCr420ToRGB32
(
    OP_UINT8        *imageBlocks, 
    JPEGFieldDec    *decodedImage
)
{
    int         i;
    int         j; 
    int         k;
    OP_UINT8    *pY11; 
    OP_UINT8    *pY12; 
    OP_UINT8    *pY21; 
    OP_UINT8    *pY22;
    OP_UINT8    *pCb; 
    OP_UINT8    *pCr;
    OP_UINT8    *destLine;
    OP_UINT8    y11;
    OP_UINT8    y12; 
    OP_UINT8    y21; 
    OP_UINT8    y22;
    OP_UINT8    Cb11; 
    OP_UINT8    Cr11;
    OP_UINT32   *id1;
    OP_UINT32   *id2;
    int         fieldRowDist;

    pY11 = imageBlocks;
    pY21 = pY11 + BLOCK_SIZE;        // next line

    pY12 = pY11 + BLOCK_AREA;
    pY22 = pY12 + BLOCK_SIZE;        // next line

    pCb = pY11 + (BLOCK_AREA << 2);    // after 4 blocks
    pCr = pCb + BLOCK_AREA;

    fieldRowDist = decodedImage->fieldRowDist;
    destLine = decodedImage->mcuBuf;
    k = ((OP_UINT32)(decodedImage->mcuBufRowEnd - decodedImage->mcuBuf)) >> 3;
    if(k > 8) 
    {
        k = 8;
    }
    k = 8 - k;
     
     // 8 rows per block
    for (i = 8; i > 0; i --)
    {
        id1 = (OP_UINT32 *)destLine;
        id2 = (OP_UINT32 *)(destLine + fieldRowDist);        // 8 lines apart

        if (i == 4)
        {
            // switch to another two Y blocks
            pY11 = imageBlocks + (BLOCK_AREA << 1);
            pY21 = pY11 + BLOCK_SIZE;        // next line

            pY12 = pY11 + BLOCK_AREA;
            pY22 = pY12 + BLOCK_SIZE;
        }

        // eight iterations per row
        for (j = 8; j > 0; j --)
        {
            Cb11 = *pCb++;
            Cr11 = *pCr++;
                        
            if (j > 4)
            {
                y11 = *pY11++;
                y12 = *pY11++;
                y21 = *pY21++;
                y22 = *pY21++;
            }
            else
            {
                y11 = *pY12++;
                y12 = *pY12++;
                y21 = *pY22++;
                y22 = *pY22++;
            }

            if(j > k)
            {
                // RGB
                *id1++ = GetR(y11, Cr11, 0) | (GetG(y11, Cr11, Cb11, 0) << 8)
                        |  (GetB(y11, Cb11, 0) << 16) | 0xff000000L;
                // RGB
                *id1++ = GetR(y12, Cr11, 0) | (GetG(y12, Cr11, Cb11, 0) << 8)
                        |  (GetB(y12, Cb11, 0) << 16) | 0xff000000L;
                // RGB
                *id2++ = GetR(y21, Cr11, 0) | (GetG(y21, Cr11, Cb11, 0) << 8)
                        |  (GetB(y21, Cb11, 0) << 16) | 0xff000000L;
                // RGB
                *id2++ = GetR(y22, Cr11, 0) | (GetG(y22, Cr11, Cb11, 0) << 8)
                        |  (GetB(y22, Cb11, 0) << 16) | 0xff000000L;
            } 
         }
              
        pY11 += BLOCK_SIZE;        // skip one line
        pY12 += BLOCK_SIZE;        // skip one line
        pY21 += BLOCK_SIZE;        // skip one line
        pY22 += BLOCK_SIZE;        // skip one line

        destLine += fieldRowDist << 1;
    }

    decodedImage->mcuBuf += 64;

    return JPEG_OK;
}
#endif

#endif

⌨️ 快捷键说明

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