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"
39static inline BOOL rfx_decode_component(RFX_CONTEXT* WINPR_RESTRICT context,
40 const UINT32* WINPR_RESTRICT quantization_values,
41 size_t nrQuantValues,
const BYTE* WINPR_RESTRICT data,
42 size_t size, INT16* WINPR_RESTRICT buffer)
45 INT16* dwt_buffer = BufferPool_Take(context->priv->BufferPool, -1);
46 WINPR_ASSERT(dwt_buffer);
48 PROFILER_ENTER(context->priv->prof_rfx_decode_component)
49 PROFILER_ENTER(context->priv->prof_rfx_rlgr_decode)
50 WINPR_ASSERT(size <= UINT32_MAX);
53 const int rc = context->rlgr_decode(context->mode, data, (UINT32)size, buffer, 4096);
56 WLog_Print(context->priv->log, WLOG_ERROR,
"context->rlgr_decode failed: %d", rc);
61 PROFILER_EXIT(context->priv->prof_rfx_rlgr_decode)
62 PROFILER_ENTER(context->priv->prof_rfx_differential_decode)
63 rfx_differential_decode(buffer + 4032, 64);
64 PROFILER_EXIT(context->priv->prof_rfx_differential_decode)
65 PROFILER_ENTER(context->priv->prof_rfx_quantization_decode)
66 if (!context->quantization_decode(buffer, quantization_values, nrQuantValues))
68 PROFILER_EXIT(context->priv->prof_rfx_quantization_decode)
69 PROFILER_ENTER(context->priv->prof_rfx_dwt_2d_decode)
70 context->dwt_2d_decode(buffer, dwt_buffer);
71 PROFILER_EXIT(context->priv->prof_rfx_dwt_2d_decode)
72 PROFILER_EXIT(context->priv->prof_rfx_decode_component)
76 BufferPool_Return(context->priv->BufferPool, dwt_buffer);
83BOOL rfx_decode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, const
RFX_TILE* WINPR_RESTRICT tile,
84 BYTE* WINPR_RESTRICT rgb_buffer, UINT32 stride)
92 BYTE* pBuffer =
nullptr;
94 UINT32* y_quants =
nullptr;
95 UINT32* cb_quants =
nullptr;
96 UINT32* cr_quants =
nullptr;
99 PROFILER_ENTER(context->priv->prof_rfx_decode_rgb)
100 y_quants = context->quants + (NR_QUANT_VALUES * tile->quantIdxY);
101 cb_quants = context->quants + (NR_QUANT_VALUES * tile->quantIdxCb);
102 cr_quants = context->quants + (NR_QUANT_VALUES * tile->quantIdxCr);
103 pBuffer = (BYTE*)BufferPool_Take(context->priv->BufferPool, -1);
104 pSrcDst[0] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 0ULL) + 16ULL]));
105 pSrcDst[1] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 1ULL) + 16ULL]));
106 pSrcDst[2] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 2ULL) + 16ULL]));
107 if (!rfx_decode_component(context, y_quants, NR_QUANT_VALUES, tile->YData, tile->YLen,
110 if (!rfx_decode_component(context, cb_quants, NR_QUANT_VALUES, tile->CbData, tile->CbLen,
113 if (!rfx_decode_component(context, cr_quants, NR_QUANT_VALUES, tile->CrData, tile->CrLen,
116 PROFILER_ENTER(context->priv->prof_rfx_ycbcr_to_rgb)
119 if (prims->yCbCrToRGB_16s8u_P3AC4R(cnv.cpv, 64 * sizeof(INT16), rgb_buffer, stride,
120 context->pixel_format, &roi_64x64) != PRIMITIVES_SUCCESS)
123 PROFILER_EXIT(context->priv->prof_rfx_ycbcr_to_rgb)
124 PROFILER_EXIT(context->priv->prof_rfx_decode_rgb)
128 BufferPool_Return(context->priv->BufferPool, pBuffer);