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 if (!rfx_differential_decode(buffer + 4032, 64))
65 PROFILER_EXIT(context->priv->prof_rfx_differential_decode)
66 PROFILER_ENTER(context->priv->prof_rfx_quantization_decode)
67 if (!context->quantization_decode(buffer, quantization_values, nrQuantValues))
69 PROFILER_EXIT(context->priv->prof_rfx_quantization_decode)
70 PROFILER_ENTER(context->priv->prof_rfx_dwt_2d_decode)
71 context->dwt_2d_decode(buffer, dwt_buffer);
72 PROFILER_EXIT(context->priv->prof_rfx_dwt_2d_decode)
73 PROFILER_EXIT(context->priv->prof_rfx_decode_component)
77 BufferPool_Return(context->priv->BufferPool, dwt_buffer);
84BOOL rfx_decode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, const
RFX_TILE* WINPR_RESTRICT tile,
85 BYTE* WINPR_RESTRICT rgb_buffer, UINT32 stride)
93 BYTE* pBuffer =
nullptr;
95 UINT32* y_quants =
nullptr;
96 UINT32* cb_quants =
nullptr;
97 UINT32* cr_quants =
nullptr;
100 PROFILER_ENTER(context->priv->prof_rfx_decode_rgb)
101 y_quants = context->quants + (NR_QUANT_VALUES * tile->quantIdxY);
102 cb_quants = context->quants + (NR_QUANT_VALUES * tile->quantIdxCb);
103 cr_quants = context->quants + (NR_QUANT_VALUES * tile->quantIdxCr);
104 pBuffer = (BYTE*)BufferPool_Take(context->priv->BufferPool, -1);
105 pSrcDst[0] = WINPR_PACKED_ALIGN_CAST(
106 INT16*, ((&pBuffer[((8192ULL + 32ULL) * 0ULL) + 16ULL])));
107 pSrcDst[1] = WINPR_PACKED_ALIGN_CAST(
108 INT16*, ((&pBuffer[((8192ULL + 32ULL) * 1ULL) + 16ULL])));
109 pSrcDst[2] = WINPR_PACKED_ALIGN_CAST(
110 INT16*, ((&pBuffer[((8192ULL + 32ULL) * 2ULL) + 16ULL])));
111 if (!rfx_decode_component(context, y_quants, NR_QUANT_VALUES, tile->YData, tile->YLen,
114 if (!rfx_decode_component(context, cb_quants, NR_QUANT_VALUES, tile->CbData, tile->CbLen,
117 if (!rfx_decode_component(context, cr_quants, NR_QUANT_VALUES, tile->CrData, tile->CrLen,
120 PROFILER_ENTER(context->priv->prof_rfx_ycbcr_to_rgb)
123 if (prims->yCbCrToRGB_16s8u_P3AC4R(cnv.cpv, 64 * sizeof(INT16), rgb_buffer, stride,
124 context->pixel_format, &roi_64x64) != PRIMITIVES_SUCCESS)
127 PROFILER_EXIT(context->priv->prof_rfx_ycbcr_to_rgb)
128 PROFILER_EXIT(context->priv->prof_rfx_decode_rgb)
132 BufferPool_Return(context->priv->BufferPool, pBuffer);