当前位置: 首页>>代码示例>>C++>>正文


C++ CCodecBuffer::GetPitch方法代码示例

本文整理汇总了C++中CCodecBuffer::GetPitch方法的典型用法代码示例。如果您正苦于以下问题:C++ CCodecBuffer::GetPitch方法的具体用法?C++ CCodecBuffer::GetPitch怎么用?C++ CCodecBuffer::GetPitch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCodecBuffer的用法示例。


在下文中一共展示了CCodecBuffer::GetPitch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Decompress

// notes:
// Slow CPU based decompression : Should look into also using HW based decompression with this interface
//
CodecError CCodec_ASTC::Decompress(CCodecBuffer& bufferIn, CCodecBuffer& bufferOut, Codec_Feedback_Proc pFeedbackProc, CMP_DWORD_PTR pUser1, CMP_DWORD_PTR pUser2)
{
    m_xdim = bufferIn.GetBlockWidth();
    m_ydim = bufferIn.GetBlockHeight();
    m_zdim = 1;

    CodecError err = InitializeASTCLibrary();
    if (err != CE_OK) return err;

    // Our Compressed data Blocks are always 128 bit long (4x4 blocks)
    const CMP_DWORD imageWidth  = bufferIn.GetWidth();
    const CMP_DWORD imageHeight = bufferIn.GetHeight();
    const CMP_DWORD imageDepth  = 1;
    const BYTE      bitness     = 8;

    const CMP_DWORD CompBlockX  = bufferIn.GetBlockWidth();
    const CMP_DWORD CompBlockY  = bufferIn.GetBlockHeight();
    CMP_BYTE  Block_Width       = bufferIn.GetBlockWidth();
    CMP_BYTE  Block_Height      = bufferIn.GetBlockHeight();

    const CMP_DWORD dwBlocksX = ((bufferIn.GetWidth() + (CompBlockX - 1)) / CompBlockX);
    const CMP_DWORD dwBlocksY = ((bufferIn.GetHeight()+ (CompBlockY - 1)) / CompBlockY);
    const CMP_DWORD dwBlocksZ = 1;
    const CMP_DWORD dwBufferInDepth = 1;

    // Override the current input buffer Pitch size  (Since it will be set according to the Compressed Block Sizes
    // and not to the Compressed Codec data which is for ASTC 16 Bytes per block x Number of blocks per row
    bufferIn.SetPitch(16 * dwBlocksX);

    // Output data size Pitch
    CMP_DWORD  dwPitch = bufferOut.GetPitch();

    // Output Buffer
    BYTE *pDataOut      = bufferOut.GetData();

    const CMP_DWORD dwBlocksXY = dwBlocksX*dwBlocksY;

    for(CMP_DWORD cmpRowY = 0; cmpRowY < dwBlocksY; cmpRowY++)        // Compressed images row = height
    {
        for(CMP_DWORD cmpColX = 0; cmpColX < dwBlocksX; cmpColX++)    // Compressed images Col = width
        {
            union FBLOCKS
            {
                float decodedBlock[144][4];            // max 12x12 block size
                float destBlock[576];                  // max 12x12x4
            } DecData;
    
            union BBLOCKS
            {
                CMP_DWORD       compressedBlock[4];
                BYTE            out[16];
                BYTE            in[16];
            } CompData;

            bufferIn.ReadBlock(cmpColX*4, cmpRowY*4, CompData.compressedBlock, 4);

            // Encode to the appropriate location in the compressed image
            m_decoder->DecompressBlock(Block_Width, Block_Height, bitness, DecData.decodedBlock,CompData.in);
            
            // Now that we have a decoded block lets copy that data over to the target image buffer
            CMP_DWORD outCol = cmpColX*Block_Width;
            CMP_DWORD outRow = cmpRowY*Block_Height;
            CMP_DWORD outImgRow = outRow;
            CMP_DWORD outImgCol = outCol;

            for (int row = 0; row < Block_Height; row++)
            {
                CMP_DWORD  nextRowCol  = (outRow+row)*dwPitch + (outCol * 4);
                CMP_BYTE*  pData       = (CMP_BYTE*)(pDataOut + nextRowCol);
                if ((outImgRow + row) < imageHeight)
                {
                    outImgCol = outCol;
                    for (int col = 0; col < Block_Width; col++)
                    {
                        CMP_DWORD w = outImgCol + col;
                        if (w < imageWidth)
                        {
                            int index = row*Block_Width + col;
                            *pData++ = (CMP_BYTE)DecData.decodedBlock[index][BC_COMP_RED];
                            *pData++ = (CMP_BYTE)DecData.decodedBlock[index][BC_COMP_GREEN];
                            *pData++ = (CMP_BYTE)DecData.decodedBlock[index][BC_COMP_BLUE];
                            *pData++ = (CMP_BYTE)DecData.decodedBlock[index][BC_COMP_ALPHA];
                        }
                        else break;
                    }
                }
            }
        }

        if (pFeedbackProc)
        {
            float fProgress = 100.f * (cmpRowY * dwBlocksX) / dwBlocksXY;
            if (pFeedbackProc(fProgress, pUser1, pUser2))
            {
                return CE_Aborted;
            }
        }
//.........这里部分代码省略.........
开发者ID:GPUOpen-Tools,项目名称:Compressonator,代码行数:101,代码来源:Codec_ASTC.cpp


注:本文中的CCodecBuffer::GetPitch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。