本文整理汇总了C++中CCodecBuffer::WriteBlock方法的典型用法代码示例。如果您正苦于以下问题:C++ CCodecBuffer::WriteBlock方法的具体用法?C++ CCodecBuffer::WriteBlock怎么用?C++ CCodecBuffer::WriteBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCodecBuffer
的用法示例。
在下文中一共展示了CCodecBuffer::WriteBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
CodecError CCodec_DXT5::Compress_SuperFast(CCodecBuffer& bufferIn, CCodecBuffer& bufferOut, Codec_Feedback_Proc pFeedbackProc, CMP_DWORD_PTR pUser1, CMP_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;
const CMP_DWORD dwBlocksX = ((bufferIn.GetWidth() + 3) >> 2);
const CMP_DWORD dwBlocksY = ((bufferIn.GetHeight() + 3) >> 2);
CMP_DWORD compressedBlock[4];
CMP_BYTE srcBlock[BLOCK_SIZE_4X4X4];
for(CMP_DWORD j = 0; j < dwBlocksY; j++)
{
for(CMP_DWORD i = 0; i < dwBlocksX; i++)
{
bufferIn.ReadBlockRGBA(i*4, j*4, 4, 4, srcBlock);
CompressRGBABlock_SuperFast(srcBlock, compressedBlock);
bufferOut.WriteBlock(i*4, j*4, compressedBlock, 4);
}
if(pFeedbackProc)
{
float fProgress = 100.f * (j * dwBlocksX) / (dwBlocksX * dwBlocksY);
if(pFeedbackProc(fProgress, pUser1, pUser2))
return CE_Aborted;
}
}
return CE_OK;
}
示例2: 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;
}