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


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

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


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

示例1: Compress_SuperFast

CodecError CCodec_DXT5::Compress(CCodecBuffer& bufferIn, CCodecBuffer& bufferOut, Codec_Feedback_Proc pFeedbackProc, CMP_DWORD_PTR pUser1, CMP_DWORD_PTR pUser2)
{
#ifndef _WIN64  //todo: add sse2 feature for win64
    if(m_nCompressionSpeed == CMP_Speed_SuperFast && m_bUseSSE2)
        return Compress_SuperFast(bufferIn, bufferOut, pFeedbackProc, pUser1, pUser2);
    else if((m_nCompressionSpeed == CMP_Speed_Fast || m_nCompressionSpeed == CMP_Speed_SuperFast) && m_bUseSSE)
        return Compress_Fast(bufferIn, bufferOut, pFeedbackProc, pUser1, pUser2);
#endif
    assert(bufferIn.GetWidth() == bufferOut.GetWidth());
    assert(bufferIn.GetHeight() == bufferOut.GetHeight());

    if(bufferIn.GetWidth() != bufferOut.GetWidth() || bufferIn.GetHeight() != bufferOut.GetHeight())
        return CE_Unknown;


    #ifdef DXT5_COMPDEBUGGER
    CompViewerClient    g_CompClient;
    if (g_CompClient.connect())
    {
        DbgTrace(("-------> Remote Server Connected"));
    }
    #endif
    
    const CMP_DWORD dwBlocksX = ((bufferIn.GetWidth() + 3) >> 2);
    const CMP_DWORD dwBlocksY = ((bufferIn.GetHeight() + 3) >> 2);


    #ifdef DXT5_COMPDEBUGGER
    DbgTrace(("IN : BufferType %d ChannelCount %d ChannelDepth %d",bufferIn.GetBufferType(),bufferIn.GetChannelCount(),bufferIn.GetChannelDepth()));
    DbgTrace(("   : Height %d Width %d Pitch %d isFloat %d",bufferIn.GetHeight(),bufferIn.GetWidth(),bufferIn.GetWidth(),bufferIn.IsFloat()));

    DbgTrace(("OUT: BufferType %d ChannelCount %d ChannelDepth %d",bufferOut.GetBufferType(),bufferOut.GetChannelCount(),bufferOut.GetChannelDepth()));
    DbgTrace(("   : Height %d Width %d Pitch %d isFloat %d",bufferOut.GetHeight(),bufferOut.GetWidth(),bufferOut.GetWidth(),bufferOut.IsFloat()));
    #endif;


    bool bUseFixed = (!bufferIn.IsFloat() && bufferIn.GetChannelDepth() == 8 && !m_bUseFloat);

    for(CMP_DWORD j = 0; j < dwBlocksY; j++)
    {
        for(CMP_DWORD i = 0; i < dwBlocksX; i++)
        {
            CMP_DWORD compressedBlock[4];
            memset(compressedBlock,0,sizeof(compressedBlock));
            if(bUseFixed)
            {
                CMP_BYTE srcBlock[BLOCK_SIZE_4X4X4];
                memset(srcBlock,0,sizeof(srcBlock));
                bufferIn.ReadBlockRGBA(i*4, j*4, 4, 4, srcBlock);

                #ifdef DXT5_COMPDEBUGGER
                g_CompClient.SendData(1,sizeof(srcBlock),srcBlock);
                #endif

                CompressRGBABlock(srcBlock, compressedBlock, CalculateColourWeightings(srcBlock));
            }
            else
            {
                float srcBlock[BLOCK_SIZE_4X4X4];
                bufferIn.ReadBlockRGBA(i*4, j*4, 4, 4, srcBlock);
                CompressRGBABlock(srcBlock, compressedBlock, CalculateColourWeightings(srcBlock));
            }

            bufferOut.WriteBlock(i*4, j*4, compressedBlock, 4);
    
            #ifdef DXT5_COMPDEBUGGER 
                //g_CompClient.SendData(2,sizeof(compressedBlock),(byte *)&compressedBlock[0]);
            #endif

            #ifdef DXT5_COMPDEBUGGER // Checks decompression it should match or be close to source
                CMP_BYTE destBlock[BLOCK_SIZE_4X4X4];
                DecompressRGBABlock(destBlock, compressedBlock);
                g_CompClient.SendData(3,sizeof(destBlock),destBlock);
            #endif

        }
        if(pFeedbackProc)
        {
            float fProgress = 100.f * (j * dwBlocksX) / (dwBlocksX * dwBlocksY);
            if(pFeedbackProc(fProgress, pUser1, pUser2))
            {
                #ifdef DXT5_COMPDEBUGGER
                    g_CompClient.disconnect();
                #endif
                return CE_Aborted;
            }
        }
    }

    #ifdef DXT5_COMPDEBUGGER
        g_CompClient.disconnect();
    #endif
    return CE_OK;
}
开发者ID:GPUOpen-Tools,项目名称:Compressonator,代码行数:94,代码来源:Codec_DXT5.cpp

示例2: Compress

CodecError CCodec_ASTC::Compress(CCodecBuffer& bufferIn, CCodecBuffer& bufferOut, Codec_Feedback_Proc pFeedbackProc, CMP_DWORD_PTR pUser1, CMP_DWORD_PTR pUser2)
{
    m_AbortRequested = false;

    int xsize = bufferIn.GetWidth();
    int ysize = bufferIn.GetHeight();
    int zsize = 1; //todo: add depth to support 3d textures
    m_xdim = bufferOut.GetBlockWidth();
    m_ydim = bufferOut.GetBlockHeight();
    m_zdim = 1;

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

#ifdef ASTC_COMPDEBUGGER
    CompViewerClient    g_CompClient;
    if (g_CompClient.connect())
    {
        #ifdef USE_DBGTRACE
            DbgTrace(("-------> Remote Server Connected"));
        #endif
    }
#endif


#ifdef USE_DBGTRACE
    DbgTrace(("IN : BufferType %d ChannelCount %d ChannelDepth %d", bufferIn.GetBufferType(), bufferIn.GetChannelCount(), bufferIn.GetChannelDepth()));
    DbgTrace(("   : Height %d Width %d Pitch %d isFloat %d", bufferIn.GetHeight(), bufferIn.GetWidth(), bufferIn.GetWidth(), bufferIn.IsFloat()));

    DbgTrace(("OUT: BufferType %d ChannelCount %d ChannelDepth %d", bufferOut.GetBufferType(), bufferOut.GetChannelCount(), bufferOut.GetChannelDepth()));
    DbgTrace(("   : Height %d Width %d Pitch %d isFloat %d", bufferOut.GetHeight(), bufferOut.GetWidth(), bufferOut.GetWidth(), bufferOut.IsFloat()));
#endif;


    int bitness = 0; //todo: replace astc_codec_image with bufferIn and rewrite fetch_imageblock()
    switch (bufferIn.GetBufferType())
    {
    case CBT_RGBA8888:
    case CBT_BGRA8888:
    case CBT_ARGB8888:
    case CBT_RGB888:
    case CBT_RG8:
    case CBT_R8:
        bitness = 8;
        break;
    case CBT_RGBA2101010:
        break;
    case CBT_RGBA16:
    case CBT_RG16:
    case CBT_R16:
        break;
    case CBT_RGBA32:
    case CBT_RG32:
    case CBT_R32:
        break;
    case CBT_RGBA16F:
    case CBT_RG16F:
    case CBT_R16F:
        break;
    case CBT_RGBA32F:
    case CBT_RG32F:
    case CBT_R32F:
        break;
    default:
        break;
    }

    if (bitness != 8)
        assert("Unsupported type of input buffer");

    astc_codec_image_cpu *input_image = allocate_image_cpu(bitness, xsize, ysize, zsize, 0);

    if (!input_image)
        assert("Unable to allocate image buffer");

    // Loop through the original input image and setup compression threads for each 
    // block to encode  we will load the buffer to pass to ASTC code as 8 bit 4x4 blocks
    // the fill in source image. ASTC code will then use the adaptive sizes for process on the input
    BYTE *pData = bufferIn.GetData();
    int ii = 0;
    for (int y = 0; y < ysize; y++) {
        for (int x = 0; x < xsize; x++) {
            input_image->imagedata8[0][y][4*x      ] = pData[ii];      // Red
            ii++;
            input_image->imagedata8[0][y][4 * x + 1] = pData[ii];      // Green
            ii++;
            input_image->imagedata8[0][y][4 * x + 2] = pData[ii];      // Blue
            ii++;
            input_image->imagedata8[0][y][4 * x + 3] = pData[ii];      // Alpha
            ii++;
        }
    }

    m_NumEncodingThreads = min(m_NumThreads, (decltype(m_NumThreads))MAX_ASTC_THREADS);
    if (m_NumEncodingThreads == 0) m_NumEncodingThreads = 1;

// Common ARM and AMD Code
    CodecError result = CE_OK;
    int xdim = m_xdim;
    int ydim = m_ydim;
//.........这里部分代码省略.........
开发者ID:GPUOpen-Tools,项目名称:Compressonator,代码行数:101,代码来源:Codec_ASTC.cpp

示例3: Compress

CodecError CCodec_GT::Compress(CCodecBuffer& bufferIn, CCodecBuffer& bufferOut, Codec_Feedback_Proc pFeedbackProc, DWORD_PTR pUser1, DWORD_PTR pUser2)
{
    assert(bufferIn.GetWidth()    == bufferOut.GetWidth());
    assert(bufferIn.GetHeight() == bufferOut.GetHeight());

    if(bufferIn.GetWidth() != bufferOut.GetWidth() || bufferIn.GetHeight() != bufferOut.GetHeight())
        return CE_Unknown;

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

#ifdef GT_COMPDEBUGGER
    CompViewerClient    g_CompClient;
    if (g_CompClient.connect())
    {
        #ifdef USE_DBGTRACE
        DbgTrace(("-------> Remote Server Connected"));
        #endif
    }
#endif

    const CMP_DWORD dwBlocksX = ((bufferIn.GetWidth() + 3) >> 2);
    const CMP_DWORD dwBlocksY = ((bufferIn.GetHeight() + 3) >> 2);
    const CMP_DWORD dwBlocksXY = dwBlocksX*dwBlocksY;


    #ifdef USE_DBGTRACE
    DbgTrace(("IN : BufferType %d ChannelCount %d ChannelDepth %d",bufferIn.GetBufferType(),bufferIn.GetChannelCount(),bufferIn.GetChannelDepth()));
    DbgTrace(("   : Height %d Width %d Pitch %d isFloat %d",bufferIn.GetHeight(),bufferIn.GetWidth(),bufferIn.GetWidth(),bufferIn.IsFloat()));

    DbgTrace(("OUT: BufferType %d ChannelCount %d ChannelDepth %d",bufferOut.GetBufferType(),bufferOut.GetChannelCount(),bufferOut.GetChannelDepth()));
    DbgTrace(("   : Height %d Width %d Pitch %d isFloat %d",bufferOut.GetHeight(),bufferOut.GetWidth(),bufferOut.GetWidth(),bufferOut.IsFloat()));
    #endif;

    char            row,col,srcIndex;

    CMP_BYTE    *pOutBuffer;
    pOutBuffer    = bufferOut.GetData();

    CMP_BYTE*    pInBuffer;
    pInBuffer    =  bufferIn.GetData();

    DWORD block = 0;

    for(CMP_DWORD j = 0; j < dwBlocksY; j++)
    {

        for(CMP_DWORD i = 0; i < dwBlocksX; i++)
        {
            BYTE blockToEncode[BLOCK_SIZE_4X4][CHANNEL_SIZE_ARGB];
            CMP_BYTE srcBlock[BLOCK_SIZE_4X4X4];

            memset(srcBlock,0,sizeof(srcBlock));
            bufferIn.ReadBlockRGBA(i*4, j*4, 4, 4, srcBlock);

            #ifdef GT_COMPDEBUGGER
            g_CompClient.SendData(1,sizeof(srcBlock),srcBlock);
            #endif

            // Create the block for encoding
            srcIndex = 0;
            for(row=0; row < BLOCK_SIZE_4; row++)
            {
                for(col=0; col < BLOCK_SIZE_4; col++)
                {
                    blockToEncode[row*BLOCK_SIZE_4+col][BC_COMP_RED]        = srcBlock[srcIndex];
                    blockToEncode[row*BLOCK_SIZE_4+col][BC_COMP_GREEN]      = srcBlock[srcIndex+1];
                    blockToEncode[row*BLOCK_SIZE_4+col][BC_COMP_BLUE]       = srcBlock[srcIndex+2];
                    blockToEncode[row*BLOCK_SIZE_4+col][BC_COMP_ALPHA]      = srcBlock[srcIndex+3];
                    srcIndex+=4;
                }
            }

            EncodeGTBlock(blockToEncode,pOutBuffer+block);
            block += 16;

            #ifdef GT_COMPDEBUGGER // Checks decompression it should match or be close to source
            union BBLOCKS
            {
                CMP_DWORD    compressedBlock[4];
                BYTE            out[16];
                BYTE            in[16];
            } data;
            
            memset(data.in,0,sizeof(data));
            
            union DBLOCKS
            {
                double            blockToSave[16][4];
                double            block[64];
            } savedata;
        
            CMP_BYTE destBlock[BLOCK_SIZE_4X4X4];
            memset(savedata.block,0,sizeof(savedata));
            m_decoder->DecompressBlock(savedata.blockToSave,data.in);

            for (row=0; row<64; row++)
            {
                destBlock[row] = (BYTE)savedata.block[row];
            }
//.........这里部分代码省略.........
开发者ID:NoSuchProcess,项目名称:Compressonator,代码行数:101,代码来源:Codec_GT.cpp

示例4: assert

CodecError CCodec_BC6H::Compress(CCodecBuffer& bufferIn, CCodecBuffer& bufferOut, Codec_Feedback_Proc pFeedbackProc, DWORD_PTR pUser1, DWORD_PTR pUser2)
{
    assert(bufferIn.GetWidth()    == bufferOut.GetWidth());
    assert(bufferIn.GetHeight() == bufferOut.GetHeight());

    if(bufferIn.GetWidth() != bufferOut.GetWidth() || bufferIn.GetHeight() != bufferOut.GetHeight())
        return CE_Unknown;

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

#ifdef BC6H_COMPDEBUGGER
    CompViewerClient    g_CompClient;
    if (g_CompClient.connect())
    {
    #ifdef USE_DBGTRACE
        DbgTrace(("-------> Remote Server Connected"));
    #endif
    }
#endif

#ifdef BC6H_DEBUG_TO_RESULTS_TXT
    g_fp = fopen("AMD_Results.txt","w");
    g_block = 0;
#endif

    const CMP_DWORD dwBlocksX = ((bufferIn.GetWidth() + 3) >> 2);
    const CMP_DWORD dwBlocksY = ((bufferIn.GetHeight() + 3) >> 2);


#ifdef _REMOTE_DEBUG
    DbgTrace(("IN : BufferType %d ChannelCount %d ChannelDepth %d",bufferIn.GetBufferType(),bufferIn.GetChannelCount(),bufferIn.GetChannelDepth()));
    DbgTrace(("   : Height %d Width %d Pitch %d isFloat %d",bufferIn.GetHeight(),bufferIn.GetWidth(),bufferIn.GetWidth(),bufferIn.IsFloat()));

    DbgTrace(("OUT: BufferType %d ChannelCount %d ChannelDepth %d",bufferOut.GetBufferType(),bufferOut.GetChannelCount(),bufferOut.GetChannelDepth()));
    DbgTrace(("   : Height %d Width %d Pitch %d isFloat %d",bufferOut.GetHeight(),bufferOut.GetWidth(),bufferOut.GetWidth(),bufferOut.IsFloat()));
#endif;

    char            row,col,srcIndex;

    CMP_BYTE    *pOutBuffer;
    pOutBuffer    = bufferOut.GetData();

    CMP_BYTE*    pInBuffer;
    pInBuffer    =  bufferIn.GetData();

    DWORD block = 0;

#ifdef _SAVE_AS_BC6
    FILE *bc6file = fopen("Test.bc6", "wb");
#endif

    for(CMP_DWORD j = 0; j < dwBlocksY; j++)
    {

        for(CMP_DWORD i = 0; i < dwBlocksX; i++)
        {
            float blockToEncode[BLOCK_SIZE_4X4][CHANNEL_SIZE_ARGB];
            CMP_FLOAT srcBlock[BLOCK_SIZE_4X4X4];

            memset(srcBlock,0,sizeof(srcBlock));
            bufferIn.ReadBlockRGBA(i*4, j*4, 4, 4, srcBlock);

            #ifdef _BC6H_COMPDEBUGGER
            g_CompClient.SendData(1,sizeof(srcBlock),srcBlock);
            #endif

            // Create the block for encoding
            srcIndex = 0;
            for(row=0; row < BLOCK_SIZE_4; row++)
            {
                for(col=0; col < BLOCK_SIZE_4; col++)
                {
                    blockToEncode[row*BLOCK_SIZE_4+col][BC6H_COMP_RED]        = (float)srcBlock[srcIndex];
                    blockToEncode[row*BLOCK_SIZE_4+col][BC6H_COMP_GREEN]    = (float)srcBlock[srcIndex+1];
                    blockToEncode[row*BLOCK_SIZE_4+col][BC6H_COMP_BLUE]        = (float)srcBlock[srcIndex+2];
                    blockToEncode[row*BLOCK_SIZE_4+col][BC6H_COMP_ALPHA]    = (float)srcBlock[srcIndex+3];
                    srcIndex+=4;
                }
            }

            union BBLOCKS
            {
                CMP_DWORD    compressedBlock[4];
                BYTE            out[16];
                BYTE            in[16];
            } data;

            memset(data.in,0,sizeof(data));
            CEncodeBC6HBlock(blockToEncode,pOutBuffer+block);
            
#ifdef _SAVE_AS_BC6
            if (fwrite(pOutBuffer+block, sizeof(char), 16, bc6file) != 16)
                throw "File error on write";
#endif

            block += 16;


//.........这里部分代码省略.........
开发者ID:NoSuchProcess,项目名称:Compressonator,代码行数:101,代码来源:Codec_BC6H.cpp


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