/src/FreeRDP/libfreerdp/codec/rfx_decode.c
Line | Count | Source (jump to first uncovered line) |
1 | | /** |
2 | | * FreeRDP: A Remote Desktop Protocol Implementation |
3 | | * RemoteFX Codec Library - Decode |
4 | | * |
5 | | * Copyright 2011 Vic Lee |
6 | | * Copyright 2011 Norbert Federa <norbert.federa@thincast.com> |
7 | | * |
8 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
9 | | * you may not use this file except in compliance with the License. |
10 | | * You may obtain a copy of the License at |
11 | | * |
12 | | * http://www.apache.org/licenses/LICENSE-2.0 |
13 | | * |
14 | | * Unless required by applicable law or agreed to in writing, software |
15 | | * distributed under the License is distributed on an "AS IS" BASIS, |
16 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
17 | | * See the License for the specific language governing permissions and |
18 | | * limitations under the License. |
19 | | */ |
20 | | |
21 | | #include <freerdp/config.h> |
22 | | |
23 | | #include <stdio.h> |
24 | | #include <stdlib.h> |
25 | | #include <string.h> |
26 | | |
27 | | #include <winpr/stream.h> |
28 | | #include <freerdp/primitives.h> |
29 | | |
30 | | #include "rfx_types.h" |
31 | | #include "rfx_rlgr.h" |
32 | | #include "rfx_differential.h" |
33 | | #include "rfx_quantization.h" |
34 | | #include "rfx_dwt.h" |
35 | | |
36 | | #include "rfx_decode.h" |
37 | | |
38 | | 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) |
42 | 0 | { |
43 | 0 | INT16* dwt_buffer = NULL; |
44 | 0 | dwt_buffer = BufferPool_Take(context->priv->BufferPool, -1); /* dwt_buffer */ |
45 | 0 | PROFILER_ENTER(context->priv->prof_rfx_decode_component) |
46 | 0 | PROFILER_ENTER(context->priv->prof_rfx_rlgr_decode) |
47 | 0 | context->rlgr_decode(context->mode, data, size, buffer, 4096); |
48 | 0 | PROFILER_EXIT(context->priv->prof_rfx_rlgr_decode) |
49 | 0 | PROFILER_ENTER(context->priv->prof_rfx_differential_decode) |
50 | 0 | rfx_differential_decode(buffer + 4032, 64); |
51 | 0 | PROFILER_EXIT(context->priv->prof_rfx_differential_decode) |
52 | 0 | PROFILER_ENTER(context->priv->prof_rfx_quantization_decode) |
53 | 0 | context->quantization_decode(buffer, quantization_values); |
54 | 0 | PROFILER_EXIT(context->priv->prof_rfx_quantization_decode) |
55 | 0 | PROFILER_ENTER(context->priv->prof_rfx_dwt_2d_decode) |
56 | 0 | context->dwt_2d_decode(buffer, dwt_buffer); |
57 | 0 | PROFILER_EXIT(context->priv->prof_rfx_dwt_2d_decode) |
58 | 0 | PROFILER_EXIT(context->priv->prof_rfx_decode_component) |
59 | 0 | BufferPool_Return(context->priv->BufferPool, dwt_buffer); |
60 | 0 | } |
61 | | |
62 | | /* rfx_decode_ycbcr_to_rgb code now resides in the primitives library. */ |
63 | | |
64 | | /* stride is bytes between rows in the output buffer. */ |
65 | | BOOL rfx_decode_rgb(RFX_CONTEXT* context, const RFX_TILE* tile, BYTE* rgb_buffer, UINT32 stride) |
66 | 0 | { |
67 | 0 | union |
68 | 0 | { |
69 | 0 | const INT16** cpv; |
70 | 0 | INT16** pv; |
71 | 0 | } cnv; |
72 | 0 | BOOL rc = TRUE; |
73 | 0 | BYTE* pBuffer = NULL; |
74 | 0 | INT16* pSrcDst[3]; |
75 | 0 | UINT32* y_quants = NULL; |
76 | 0 | UINT32* cb_quants = NULL; |
77 | 0 | UINT32* cr_quants = NULL; |
78 | 0 | static const prim_size_t roi_64x64 = { 64, 64 }; |
79 | 0 | const primitives_t* prims = primitives_get(); |
80 | 0 | PROFILER_ENTER(context->priv->prof_rfx_decode_rgb) |
81 | 0 | y_quants = context->quants + (tile->quantIdxY * 10); |
82 | 0 | cb_quants = context->quants + (tile->quantIdxCb * 10); |
83 | 0 | cr_quants = context->quants + (tile->quantIdxCr * 10); |
84 | 0 | pBuffer = (BYTE*)BufferPool_Take(context->priv->BufferPool, -1); |
85 | 0 | pSrcDst[0] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 0) + 16])); /* y_r_buffer */ |
86 | 0 | pSrcDst[1] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 1) + 16])); /* cb_g_buffer */ |
87 | 0 | pSrcDst[2] = (INT16*)((BYTE*)(&pBuffer[((8192 + 32) * 2) + 16])); /* cr_b_buffer */ |
88 | 0 | rfx_decode_component(context, y_quants, tile->YData, tile->YLen, pSrcDst[0]); /* YData */ |
89 | 0 | rfx_decode_component(context, cb_quants, tile->CbData, tile->CbLen, pSrcDst[1]); /* CbData */ |
90 | 0 | rfx_decode_component(context, cr_quants, tile->CrData, tile->CrLen, pSrcDst[2]); /* CrData */ |
91 | 0 | PROFILER_ENTER(context->priv->prof_rfx_ycbcr_to_rgb) |
92 | |
|
93 | 0 | cnv.pv = pSrcDst; |
94 | 0 | if (prims->yCbCrToRGB_16s8u_P3AC4R(cnv.cpv, 64 * sizeof(INT16), rgb_buffer, stride, |
95 | 0 | context->pixel_format, &roi_64x64) != PRIMITIVES_SUCCESS) |
96 | 0 | rc = FALSE; |
97 | |
|
98 | 0 | PROFILER_EXIT(context->priv->prof_rfx_ycbcr_to_rgb) |
99 | 0 | PROFILER_EXIT(context->priv->prof_rfx_decode_rgb) |
100 | 0 | BufferPool_Return(context->priv->BufferPool, pBuffer); |
101 | 0 | return rc; |
102 | 0 | } |