From 6744bbe7aee89595cb3e8ce64a07e3de075c5923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 18 Aug 2014 19:12:08 -0400 Subject: [PATCH] libfreerdp-codec: start working on progressive dequantization --- libfreerdp/codec/progressive.c | 39 +++++++++++++++++++++++++++++ libfreerdp/codec/rfx_quantization.c | 23 +++++++++++++++-- libfreerdp/codec/rfx_quantization.h | 2 ++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/libfreerdp/codec/progressive.c b/libfreerdp/codec/progressive.c index 24d9493eb..c9e3adf1d 100644 --- a/libfreerdp/codec/progressive.c +++ b/libfreerdp/codec/progressive.c @@ -25,9 +25,13 @@ #include #include +#include #include #include +#include "rfx_differential.h" +#include "rfx_quantization.h" + const char* progressive_get_block_type_string(UINT16 blockType) { switch (blockType) @@ -72,16 +76,51 @@ const char* progressive_get_block_type_string(UINT16 blockType) return "PROGRESSIVE_WBT_UNKNOWN"; } +/* + * Band Offset Dimensions Size + * + * HL1 0 31x33 1023 + * LH1 1023 33x31 1023 + * HH1 2046 31x31 961 + * + * HL2 3007 16x17 272 + * LH2 3279 17x16 272 + * HH2 3551 16x16 256 + * + * HL3 3807 8x9 72 + * LH3 3879 9x8 72 + * HH3 3951 8x8 64 + * + * LL3 4015 9x9 81 + */ + int progressive_rfx_decode_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMPONENT_CODEC_QUANT* quant, const BYTE* data, int length, INT16* buffer) { int status; + const primitives_t* prims = primitives_get(); status = rfx_rlgr_decode(data, length, buffer, 4096, 1); if (status < 0) return status; + rfx_differential_decode(&buffer[4015], 81); /* LL3 */ + + /* Scale the values so that they are represented as 11.5 fixed-point number */ + rfx_quantization_decode_block(prims, buffer, 4096, 5); + + rfx_quantization_decode_block(prims, &buffer[0], 1023, (quant->HL1 - 6)); /* HL1 */ + rfx_quantization_decode_block(prims, &buffer[1023], 1023, (quant->LH1 - 6)); /* LH1 */ + rfx_quantization_decode_block(prims, &buffer[2046], 961, (quant->HH1 - 6)); /* HH1 */ + rfx_quantization_decode_block(prims, &buffer[3007], 272, (quant->HL2 - 6)); /* HL2 */ + rfx_quantization_decode_block(prims, &buffer[3279], 272, (quant->LH2 - 6)); /* LH2 */ + rfx_quantization_decode_block(prims, &buffer[3551], 256, (quant->HH2 - 6)); /* HH2 */ + rfx_quantization_decode_block(prims, &buffer[3807], 72, (quant->HL3 - 6)); /* HL3 */ + rfx_quantization_decode_block(prims, &buffer[3879], 72, (quant->LH3 - 6)); /* LH3 */ + rfx_quantization_decode_block(prims, &buffer[3951], 64, (quant->HH3 - 6)); /* HH3 */ + rfx_quantization_decode_block(prims, &buffer[4015], 81, (quant->LL3 - 6)); /* LL3 */ + return 1; } diff --git a/libfreerdp/codec/rfx_quantization.c b/libfreerdp/codec/rfx_quantization.c index 2cedfd91d..b5c79e5f2 100644 --- a/libfreerdp/codec/rfx_quantization.c +++ b/libfreerdp/codec/rfx_quantization.c @@ -22,9 +22,28 @@ #endif #include + #include "rfx_quantization.h" -static void rfx_quantization_decode_block(const primitives_t *prims, INT16* buffer, int buffer_size, UINT32 factor) +/* + * Band Offset Size + * + * HL1 0 1024 + * LH1 1024 1024 + * HH1 2048 1024 + * + * HL2 3072 256 + * LH2 3328 256 + * HH2 3584 256 + * + * HL3 3840 64 + * LH3 3904 64 + * HH3 3968 64 + * + * LL3 4032 64 + */ + +void rfx_quantization_decode_block(const primitives_t *prims, INT16* buffer, int buffer_size, UINT32 factor) { if (factor == 0) return; @@ -34,7 +53,7 @@ static void rfx_quantization_decode_block(const primitives_t *prims, INT16* buff void rfx_quantization_decode(INT16* buffer, const UINT32* quantization_values) { - const primitives_t *prims = primitives_get(); + const primitives_t* prims = primitives_get(); /* Scale the values so that they are represented as 11.5 fixed-point number */ rfx_quantization_decode_block(prims, buffer, 4096, 5); diff --git a/libfreerdp/codec/rfx_quantization.h b/libfreerdp/codec/rfx_quantization.h index b10aa729f..e446a098a 100644 --- a/libfreerdp/codec/rfx_quantization.h +++ b/libfreerdp/codec/rfx_quantization.h @@ -25,4 +25,6 @@ void rfx_quantization_decode(INT16* buffer, const UINT32* quantization_values); void rfx_quantization_encode(INT16* buffer, const UINT32* quantization_values); +void rfx_quantization_decode_block(const primitives_t *prims, INT16* buffer, int buffer_size, UINT32 factor); + #endif /* __RFX_QUANTIZATION_H */