BYTE* YData;
BYTE* CbData;
BYTE* CrData;
+ BYTE* YCbCrData;
};
typedef struct _RFX_TILE RFX_TILE;
* in order to allow optimized functions (SEE, NEON) to read from positions
* that are actually in front/beyond the buffer. Offset calculations are
* performed at the BufferPool_Take function calls in rfx_encode/decode.c.
+ *
+ * We then multiply by 3 to use a single, partioned buffer for all 3 channels.
*/
- context->priv->BufferPool = BufferPool_New(TRUE, 8192 + 32, 16);
+ context->priv->BufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16);
#ifdef _WIN32
{
{
tile = message->tiles[i];
- if (tile->YData)
- BufferPool_Return(context->priv->BufferPool, tile->YData);
-
- if (tile->CbData)
- BufferPool_Return(context->priv->BufferPool, tile->CbData);
-
- if (tile->CrData)
- BufferPool_Return(context->priv->BufferPool, tile->CrData);
+ if (tile->YCbCrData)
+ {
+ BufferPool_Return(context->priv->BufferPool, tile->YCbCrData);
+ tile->YCbCrData = NULL;
+ }
ObjectPool_Return(context->priv->TilePool, (void*) tile);
}
tile->YLen = 0;
tile->CbLen = 0;
tile->CrLen = 0;
- tile->YData = (BYTE*) BufferPool_Take(context->priv->BufferPool, -1);
- tile->CbData = (BYTE*) BufferPool_Take(context->priv->BufferPool, -1);
- tile->CrData = (BYTE*) BufferPool_Take(context->priv->BufferPool, -1);
+
+ tile->YCbCrData = (BYTE*) BufferPool_Take(context->priv->BufferPool, -1);
+
+ tile->YData = (BYTE*) &(tile->YCbCrData[((8192 + 32) * 0) + 16]);
+ tile->CbData = (BYTE*) &(tile->YCbCrData[((8192 + 32) * 1) + 16]);
+ tile->CrData = (BYTE*) &(tile->YCbCrData[((8192 + 32) * 2) + 16]);
if (context->priv->UseThreads)
{
/* stride is bytes between rows in the output buffer. */
BOOL rfx_decode_rgb(RFX_CONTEXT* context, RFX_TILE* tile, BYTE* rgb_buffer, int stride)
{
+ BYTE* pBuffer;
INT16* pSrcDst[3];
UINT32 *y_quants, *cb_quants, *cr_quants;
static const prim_size_t roi_64x64 = { 64, 64 };
cb_quants = context->quants + (tile->quantIdxCb * 10);
cr_quants = context->quants + (tile->quantIdxCr * 10);
- pSrcDst[0] = (INT16*)((BYTE*)BufferPool_Take(context->priv->BufferPool, -1) + 16); /* y_r_buffer */
- pSrcDst[1] = (INT16*)((BYTE*)BufferPool_Take(context->priv->BufferPool, -1) + 16); /* cb_g_buffer */
- pSrcDst[2] = (INT16*)((BYTE*)BufferPool_Take(context->priv->BufferPool, -1) + 16); /* cr_b_buffer */
+ pBuffer = (BYTE*) BufferPool_Take(context->priv->BufferPool, -1);
+ pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* y_r_buffer */
+ pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* cb_g_buffer */
+ pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* cr_b_buffer */
rfx_decode_component(context, y_quants, tile->YData, tile->YLen, pSrcDst[0]); /* YData */
PROFILER_EXIT(context->priv->prof_rfx_decode_rgb);
- BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[0] - 16);
- BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[1] - 16);
- BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[2] - 16);
+ BufferPool_Return(context->priv->BufferPool, pBuffer);
return TRUE;
}
void rfx_encode_rgb(RFX_CONTEXT* context, RFX_TILE* tile)
{
+ BYTE* pBuffer;
INT16* pSrcDst[3];
int YLen, CbLen, CrLen;
UINT32 *YQuant, *CbQuant, *CrQuant;
CbQuant = context->quants + (tile->quantIdxCb * 10);
CrQuant = context->quants + (tile->quantIdxCr * 10);
- pSrcDst[0] = (INT16*)((BYTE*)BufferPool_Take(context->priv->BufferPool, -1) + 16); /* y_r_buffer */
- pSrcDst[1] = (INT16*)((BYTE*)BufferPool_Take(context->priv->BufferPool, -1) + 16); /* cb_g_buffer */
- pSrcDst[2] = (INT16*)((BYTE*)BufferPool_Take(context->priv->BufferPool, -1) + 16); /* cr_b_buffer */
+ pBuffer = (BYTE*) BufferPool_Take(context->priv->BufferPool, -1);
+ pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* y_r_buffer */
+ pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* cb_g_buffer */
+ pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* cr_b_buffer */
PROFILER_ENTER(context->priv->prof_rfx_encode_rgb);
PROFILER_EXIT(context->priv->prof_rfx_encode_rgb);
- BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[0] - 16);
- BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[1] - 16);
- BufferPool_Return(context->priv->BufferPool, (BYTE*)pSrcDst[2] - 16);
+ BufferPool_Return(context->priv->BufferPool, pBuffer);
}