21#include <freerdp/config.h>
27#include <winpr/stream.h>
28#include <freerdp/primitives.h>
32#include "rfx_differential.h"
33#include "rfx_quantization.h"
36#include "rfx_decode.h"
38static inline void rfx_decode_component(RFX_CONTEXT* WINPR_RESTRICT context,
39 const UINT32* WINPR_RESTRICT quantization_values,
40 const BYTE* WINPR_RESTRICT data,
size_t size,
41 INT16* WINPR_RESTRICT buffer)
43 INT16* dwt_buffer = BufferPool_Take(context->priv->BufferPool, -1);
44 WINPR_ASSERT(dwt_buffer);
46 PROFILER_ENTER(context->priv->prof_rfx_decode_component)
47 PROFILER_ENTER(context->priv->prof_rfx_rlgr_decode)
48 WINPR_ASSERT(size <= UINT32_MAX);
51 const int rc = context->rlgr_decode(context->mode, data, (UINT32)size, buffer, 4096);
53 WLog_Print(context->priv->log, WLOG_ERROR,
"context->rlgr_decode failed: %d", rc);
56 PROFILER_EXIT(context->priv->prof_rfx_rlgr_decode)
57 PROFILER_ENTER(context->priv->prof_rfx_differential_decode)
58 rfx_differential_decode(buffer + 4032, 64);
59 PROFILER_EXIT(context->priv->prof_rfx_differential_decode)
60 PROFILER_ENTER(context->priv->prof_rfx_quantization_decode)
61 context->quantization_decode(buffer, quantization_values);
62 PROFILER_EXIT(context->priv->prof_rfx_quantization_decode)
63 PROFILER_ENTER(context->priv->prof_rfx_dwt_2d_decode)
64 context->dwt_2d_decode(buffer, dwt_buffer);
65 PROFILER_EXIT(context->priv->prof_rfx_dwt_2d_decode)
66 PROFILER_EXIT(context->priv->prof_rfx_decode_component)
67 BufferPool_Return(context->priv->BufferPool, dwt_buffer);
73BOOL rfx_decode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, const
RFX_TILE* WINPR_RESTRICT tile,
74 BYTE* WINPR_RESTRICT rgb_buffer, UINT32 stride)
82 BYTE* pBuffer =
nullptr;
84 UINT32* y_quants =
nullptr;
85 UINT32* cb_quants =
nullptr;
86 UINT32* cr_quants =
nullptr;
89 PROFILER_ENTER(context->priv->prof_rfx_decode_rgb)
90 y_quants = context->quants + (10ULL * tile->quantIdxY);
91 cb_quants = context->quants + (10ULL * tile->quantIdxCb);
92 cr_quants = context->quants + (10ULL * tile->quantIdxCr);
93 pBuffer = (BYTE*)BufferPool_Take(context->priv->BufferPool, -1);
94 pSrcDst[0] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 0ULL) + 16ULL]));
95 pSrcDst[1] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 1ULL) + 16ULL]));
96 pSrcDst[2] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 2ULL) + 16ULL]));
97 rfx_decode_component(context, y_quants, tile->YData, tile->YLen, pSrcDst[0]);
98 rfx_decode_component(context, cb_quants, tile->CbData, tile->CbLen, pSrcDst[1]);
99 rfx_decode_component(context, cr_quants, tile->CrData, tile->CrLen, pSrcDst[2]);
100 PROFILER_ENTER(context->priv->prof_rfx_ycbcr_to_rgb)
103 if (prims->yCbCrToRGB_16s8u_P3AC4R(cnv.cpv, 64 * sizeof(INT16), rgb_buffer, stride,
104 context->pixel_format, &roi_64x64) != PRIMITIVES_SUCCESS)
107 PROFILER_EXIT(context->priv->prof_rfx_ycbcr_to_rgb)
108 PROFILER_EXIT(context->priv->prof_rfx_decode_rgb)
109 BufferPool_Return(context->priv->BufferPool, pBuffer);