libfreerdp-codec: fix and improve SRL decoder
This commit is contained in:
parent
6abd9e6be0
commit
f79be532f0
@ -688,8 +688,10 @@ int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive, RFX_PROG
|
||||
|
||||
diff = tile->flags & RFX_TILE_DIFFERENCE;
|
||||
|
||||
#if 0
|
||||
printf("ProgressiveTileFirst: quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d flags: 0x%02X quality: %d yLen: %d cbLen: %d crLen: %d tailLen: %d\n",
|
||||
tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen, tile->cbLen, tile->crLen, tile->tailLen);
|
||||
#endif
|
||||
|
||||
region = &(progressive->region);
|
||||
|
||||
@ -798,7 +800,6 @@ struct _RFX_PROGRESSIVE_UPGRADE_STATE
|
||||
|
||||
/* SRL state */
|
||||
|
||||
int k;
|
||||
int kp;
|
||||
int nz;
|
||||
BOOL mode;
|
||||
@ -807,6 +808,7 @@ typedef struct _RFX_PROGRESSIVE_UPGRADE_STATE RFX_PROGRESSIVE_UPGRADE_STATE;
|
||||
|
||||
INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state, UINT32 numBits)
|
||||
{
|
||||
int k;
|
||||
UINT32 bit;
|
||||
UINT32 max;
|
||||
UINT32 mag;
|
||||
@ -819,6 +821,8 @@ INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state, UINT32 numB
|
||||
return 0;
|
||||
}
|
||||
|
||||
k = state->kp / 8;
|
||||
|
||||
if (!state->mode)
|
||||
{
|
||||
/* zero encoding */
|
||||
@ -830,35 +834,35 @@ INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state, UINT32 numB
|
||||
{
|
||||
/* '0' bit, nz >= (1 << k), nz = (1 << k) */
|
||||
|
||||
state->nz = (1 << state->k);
|
||||
state->nz = (1 << k);
|
||||
|
||||
state->kp += 4;
|
||||
|
||||
if (state->kp > 80)
|
||||
state->kp = 80;
|
||||
|
||||
state->k = state->kp / 8;
|
||||
|
||||
state->nz--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* '1' bit, nz < (1 << k), nz = next k bits */
|
||||
|
||||
state->nz = 0;
|
||||
|
||||
if (state->k)
|
||||
else
|
||||
{
|
||||
bs->mask = ((1 << state->k) - 1);
|
||||
state->nz = ((bs->accumulator >> (32 - state->k)) & bs->mask);
|
||||
BitStream_Shift(bs, state->k);
|
||||
}
|
||||
/* '1' bit, nz < (1 << k), nz = next k bits */
|
||||
|
||||
if (state->nz)
|
||||
{
|
||||
state->nz = 0;
|
||||
state->mode = 1; /* unary encoding is next */
|
||||
state->nz--;
|
||||
return 0;
|
||||
|
||||
if (k)
|
||||
{
|
||||
bs->mask = ((1 << k) - 1);
|
||||
state->nz = ((bs->accumulator >> (32 - k)) & bs->mask);
|
||||
BitStream_Shift(bs, k);
|
||||
}
|
||||
|
||||
if (state->nz)
|
||||
{
|
||||
state->nz--;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,6 +875,11 @@ INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state, UINT32 numB
|
||||
sign = (bs->accumulator & 0x80000000) ? 1 : 0;
|
||||
BitStream_Shift(bs, 1);
|
||||
|
||||
state->kp -= 6;
|
||||
|
||||
if (state->kp < 0)
|
||||
state->kp = 0;
|
||||
|
||||
if (numBits == 1)
|
||||
return sign ? -1 : 1;
|
||||
|
||||
@ -888,18 +897,12 @@ INT16 progressive_rfx_srl_read(RFX_PROGRESSIVE_UPGRADE_STATE* state, UINT32 numB
|
||||
mag++;
|
||||
}
|
||||
|
||||
state->kp -= 6;
|
||||
|
||||
if (state->kp < 0)
|
||||
state->kp = 0;
|
||||
|
||||
state->k = state->kp / 8;
|
||||
|
||||
return sign ? -mag : mag;
|
||||
}
|
||||
|
||||
int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* state, INT16* buffer, INT16* sign, int length, UINT32 bitPos, UINT32 numBits)
|
||||
{
|
||||
int pad;
|
||||
int index;
|
||||
INT16 input;
|
||||
wBitStream* srl;
|
||||
@ -924,6 +927,21 @@ int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* state, INT16* b
|
||||
buffer[index] += (input << bitPos);
|
||||
}
|
||||
|
||||
/* This is the last band, read padding bits from RAW and SRL bit streams */
|
||||
|
||||
pad = (raw->position % 8) ? (8 - (raw->position % 8)) : 0;
|
||||
|
||||
if (pad)
|
||||
BitStream_Shift(raw, pad);
|
||||
|
||||
pad = (srl->position % 8) ? (8 - (srl->position % 8)) : 0;
|
||||
|
||||
if (pad)
|
||||
BitStream_Shift(srl, pad);
|
||||
|
||||
if (BitStream_GetRemainingLength(srl) == 8)
|
||||
BitStream_Shift(srl, 8);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -961,102 +979,6 @@ int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* state, INT16* b
|
||||
return 1;
|
||||
}
|
||||
|
||||
int progressive_rfx_upgrade_block_count_raw(BOOL nonLL, INT16* sign, int length, int numBits)
|
||||
{
|
||||
int index;
|
||||
int count = 0;
|
||||
|
||||
if (numBits < 0)
|
||||
return 0;
|
||||
|
||||
if (!nonLL)
|
||||
{
|
||||
count = length;
|
||||
return (count * numBits);
|
||||
}
|
||||
|
||||
for (index = 0; index < length; index++)
|
||||
{
|
||||
if (sign[index] != 0)
|
||||
count++;
|
||||
}
|
||||
|
||||
return (count * numBits);
|
||||
}
|
||||
|
||||
int progressive_rfx_upgrade_component_count_raw(RFX_COMPONENT_CODEC_QUANT* numBits, INT16* sign, int delta)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[0], 1023, numBits->HL1 + delta); /* HL1 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[1023], 1023, numBits->LH1 + delta); /* LH1 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[2046], 961, numBits->HH1 + delta); /* HH1 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[3007], 272, numBits->HL2 + delta); /* HL2 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[3279], 272, numBits->LH2 + delta); /* LH2 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[3551], 256, numBits->HH2 + delta); /* HH2 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[3807], 72, numBits->HL3 + delta); /* HL3 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[3879], 72, numBits->LH3 + delta); /* LH3 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(TRUE, &sign[3951], 64, numBits->HH3 + delta); /* HH3 */
|
||||
count += progressive_rfx_upgrade_block_count_raw(FALSE, &sign[4015], 81, numBits->LL3 + delta); /* LL3 */
|
||||
|
||||
return (count + 7) / 8;
|
||||
}
|
||||
|
||||
int progressive_rfx_upgrade_component_fix_count(RFX_COMPONENT_CODEC_QUANT* numBits, INT16* sign, int rawLen)
|
||||
{
|
||||
int delta = 0;
|
||||
int count = 0;
|
||||
int p_count = 0;
|
||||
int count_n[3] = { 0 };
|
||||
int p_count_n[3] = { 0 };
|
||||
int count_p[3] = { 0 };
|
||||
int p_count_p[3] = { 0 };
|
||||
|
||||
count_n[0] = progressive_rfx_upgrade_component_count_raw(numBits, sign, -1);
|
||||
count_n[1] = progressive_rfx_upgrade_component_count_raw(numBits, sign, -2);
|
||||
count_n[2] = progressive_rfx_upgrade_component_count_raw(numBits, sign, -3);
|
||||
|
||||
count = progressive_rfx_upgrade_component_count_raw(numBits, sign, 0);
|
||||
|
||||
count_p[0] = progressive_rfx_upgrade_component_count_raw(numBits, sign, 1);
|
||||
count_p[1] = progressive_rfx_upgrade_component_count_raw(numBits, sign, 2);
|
||||
count_p[2] = progressive_rfx_upgrade_component_count_raw(numBits, sign, 3);
|
||||
|
||||
if (rawLen)
|
||||
{
|
||||
p_count_n[0] = (int) ((((float) count_n[0]) / ((float) rawLen)) * 100.0f);
|
||||
p_count_n[1] = (int) ((((float) count_n[1]) / ((float) rawLen)) * 100.0f);
|
||||
p_count_n[2] = (int) ((((float) count_n[2]) / ((float) rawLen)) * 100.0f);
|
||||
|
||||
p_count = (int) ((((float) count) / ((float) rawLen)) * 100.0f);
|
||||
|
||||
p_count_p[0] = (int) ((((float) count_p[0]) / ((float) rawLen)) * 100.0f);
|
||||
p_count_p[1] = (int) ((((float) count_p[1]) / ((float) rawLen)) * 100.0f);
|
||||
p_count_p[2] = (int) ((((float) count_p[2]) / ((float) rawLen)) * 100.0f);
|
||||
}
|
||||
|
||||
if (p_count_n[0] == 100)
|
||||
delta = -1;
|
||||
if (p_count_n[1] == 100)
|
||||
delta = -2;
|
||||
if (p_count_n[2] == 100)
|
||||
delta = -3;
|
||||
|
||||
if (p_count_p[0] == 100)
|
||||
delta = 1;
|
||||
if (p_count_p[1] == 100)
|
||||
delta = 2;
|
||||
if (p_count_p[2] == 100)
|
||||
delta = 3;
|
||||
|
||||
printf("NumBitsFix: -3: %d -2: %d -1: %d 0: %d 1: %d 2: %d 3: %d\n",
|
||||
p_count_n[2], p_count_n[1], p_count_n[0], p_count, p_count_p[0], p_count_p[1], p_count_p[2]);
|
||||
printf("NumBitsFix HL1: %d LH1: %d HH1: %d HL2: %d LH2: %d HH2: %d HL3: %d LH3: %d HH3: %d LL3: %d\n",
|
||||
numBits->HL1, numBits->LH1, numBits->HH1, numBits->HL2, numBits->LH2, numBits->HH2, numBits->HL3, numBits->LH3, numBits->HH3, numBits->LL3);
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
int progressive_rfx_upgrade_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMPONENT_CODEC_QUANT* bitPos,
|
||||
RFX_COMPONENT_CODEC_QUANT* numBits, INT16* buffer, INT16* current, INT16* sign,
|
||||
const BYTE* srlData, int srlLen, const BYTE* rawData, int rawLen)
|
||||
@ -1071,10 +993,8 @@ int progressive_rfx_upgrade_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMP
|
||||
ZeroMemory(&s_raw, sizeof(wBitStream));
|
||||
ZeroMemory(&state, sizeof(RFX_PROGRESSIVE_UPGRADE_STATE));
|
||||
|
||||
progressive_rfx_upgrade_component_fix_count(numBits, sign, rawLen);
|
||||
|
||||
state.kp = 8;
|
||||
state.k = state.kp / 8;
|
||||
state.mode = 0;
|
||||
state.srl = &s_srl;
|
||||
state.raw = &s_raw;
|
||||
|
||||
@ -1114,9 +1034,11 @@ int progressive_rfx_upgrade_component(PROGRESSIVE_CONTEXT* progressive, RFX_COMP
|
||||
if (srlLen)
|
||||
pSrlLen = (int) ((((float) aSrlLen) / ((float) srlLen)) * 100.0f);
|
||||
|
||||
printf("RAW: %d/%d %d%% SRL: %d/%d %d%%\n",
|
||||
aRawLen, rawLen, pRawLen,
|
||||
aSrlLen, srlLen, pSrlLen);
|
||||
printf("RAW: %d/%d %d%% (%d/%d:%d)\tSRL: %d/%d %d%% (%d/%d:%d)\n",
|
||||
aRawLen, rawLen, pRawLen, state.raw->position, rawLen * 8,
|
||||
(rawLen * 8) - state.raw->position,
|
||||
aSrlLen, srlLen, pSrlLen, state.srl->position, srlLen * 8,
|
||||
(srlLen * 8) - state.srl->position);
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -1151,10 +1073,12 @@ int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive, RFX_PR
|
||||
tile->pass++;
|
||||
|
||||
if (tile->pass > 2)
|
||||
return 1; /* skip for now */
|
||||
return -1; /* skip for now */
|
||||
|
||||
#if 0
|
||||
printf("ProgressiveTileUpgrade: pass: %d quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d quality: %d ySrlLen: %d yRawLen: %d cbSrlLen: %d cbRawLen: %d crSrlLen: %d crRawLen: %d\n",
|
||||
tile->pass, tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->quality, tile->ySrlLen, tile->yRawLen, tile->cbSrlLen, tile->cbRawLen, tile->crSrlLen, tile->crRawLen);
|
||||
#endif
|
||||
|
||||
region = &(progressive->region);
|
||||
|
||||
@ -1581,7 +1505,7 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
|
||||
blockLen = *((UINT32*) &block[boffset + 2]); /* blockLen (4 bytes) */
|
||||
boffset += 6;
|
||||
|
||||
printf("%s\n", progressive_get_block_type_string(blockType));
|
||||
//printf("%s\n", progressive_get_block_type_string(blockType));
|
||||
|
||||
if ((blocksLen - offset) < blockLen)
|
||||
return -1003;
|
||||
|
@ -1,10 +1,496 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/path.h>
|
||||
#include <winpr/print.h>
|
||||
|
||||
#include <freerdp/codec/progressive.h>
|
||||
|
||||
int TestFreeRDPCodecProgressive(int argc, char* argv[])
|
||||
/**
|
||||
* Microsoft Progressive Codec Sample Data
|
||||
* (available under NDA only)
|
||||
*
|
||||
* <enc/dec>_<image#>_<quarter#>_<prog%>_<bitmap>.<type>
|
||||
*
|
||||
* readme.pdf
|
||||
*
|
||||
* bitmaps/
|
||||
* 1920by1080-SampleImage1.bmp
|
||||
* 1920by1080-SampleImage2.bmp
|
||||
* 1920by1080-SampleImage3.bmp
|
||||
*
|
||||
* compress/
|
||||
* enc_0_0_025_sampleimage1.bin
|
||||
* enc_0_0_050_sampleimage1.bin
|
||||
* enc_0_0_075_sampleimage1.bin
|
||||
* enc_0_0_100_sampleimage1.bin
|
||||
* enc_0_1_025_sampleimage1.bin
|
||||
* enc_0_1_050_sampleimage1.bin
|
||||
* enc_0_1_075_sampleimage1.bin
|
||||
* enc_0_1_100_sampleimage1.bin
|
||||
* enc_0_2_025_sampleimage1.bin
|
||||
* enc_0_2_050_sampleimage1.bin
|
||||
* enc_0_2_075_sampleimage1.bin
|
||||
* enc_0_2_100_sampleimage1.bin
|
||||
* enc_0_3_025_sampleimage1.bin
|
||||
* enc_0_3_050_sampleimage1.bin
|
||||
* enc_0_3_075_sampleimage1.bin
|
||||
* enc_0_3_100_sampleimage1.bin
|
||||
* enc_1_0_025_sampleimage2.bin
|
||||
* enc_1_0_050_sampleimage2.bin
|
||||
* enc_1_0_075_sampleimage2.bin
|
||||
* enc_1_0_100_sampleimage2.bin
|
||||
* enc_1_1_025_sampleimage2.bin
|
||||
* enc_1_1_050_sampleimage2.bin
|
||||
* enc_1_1_075_sampleimage2.bin
|
||||
* enc_1_1_100_sampleimage2.bin
|
||||
* enc_1_2_025_sampleimage2.bin
|
||||
* enc_1_2_050_sampleimage2.bin
|
||||
* enc_1_2_075_sampleimage2.bin
|
||||
* enc_1_2_100_sampleimage2.bin
|
||||
* enc_1_3_025_sampleimage2.bin
|
||||
* enc_1_3_050_sampleimage2.bin
|
||||
* enc_1_3_075_sampleimage2.bin
|
||||
* enc_1_3_100_sampleimage2.bin
|
||||
* enc_2_0_025_sampleimage3.bin
|
||||
* enc_2_0_050_sampleimage3.bin
|
||||
* enc_2_0_075_sampleimage3.bin
|
||||
* enc_2_0_100_sampleimage3.bin
|
||||
* enc_2_1_025_sampleimage3.bin
|
||||
* enc_2_1_050_sampleimage3.bin
|
||||
* enc_2_1_075_sampleimage3.bin
|
||||
* enc_2_1_100_sampleimage3.bin
|
||||
* enc_2_2_025_sampleimage3.bin
|
||||
* enc_2_2_050_sampleimage3.bin
|
||||
* enc_2_2_075_sampleimage3.bin
|
||||
* enc_2_2_100_sampleimage3.bin
|
||||
* enc_2_3_025_sampleimage3.bin
|
||||
* enc_2_3_050_sampleimage3.bin
|
||||
* enc_2_3_075_sampleimage3.bin
|
||||
* enc_2_3_100_sampleimage3.bin
|
||||
*
|
||||
* decompress/
|
||||
* dec_0_0_025_sampleimage1.bmp
|
||||
* dec_0_0_050_sampleimage1.bmp
|
||||
* dec_0_0_075_sampleimage1.bmp
|
||||
* dec_0_0_100_sampleimage1.bmp
|
||||
* dec_0_1_025_sampleimage1.bmp
|
||||
* dec_0_1_050_sampleimage1.bmp
|
||||
* dec_0_1_075_sampleimage1.bmp
|
||||
* dec_0_1_100_sampleimage1.bmp
|
||||
* dec_0_2_025_sampleimage1.bmp
|
||||
* dec_0_2_050_sampleimage1.bmp
|
||||
* dec_0_2_075_sampleimage1.bmp
|
||||
* dec_0_2_100_sampleimage1.bmp
|
||||
* dec_0_3_025_sampleimage1.bmp
|
||||
* dec_0_3_050_sampleimage1.bmp
|
||||
* dec_0_3_075_sampleimage1.bmp
|
||||
* dec_0_3_100_sampleimage1.bmp
|
||||
* dec_1_0_025_sampleimage2.bmp
|
||||
* dec_1_0_050_sampleimage2.bmp
|
||||
* dec_1_0_075_sampleimage2.bmp
|
||||
* dec_1_0_100_sampleimage2.bmp
|
||||
* dec_1_1_025_sampleimage2.bmp
|
||||
* dec_1_1_050_sampleimage2.bmp
|
||||
* dec_1_1_075_sampleimage2.bmp
|
||||
* dec_1_1_100_sampleimage2.bmp
|
||||
* dec_1_2_025_sampleimage2.bmp
|
||||
* dec_1_2_050_sampleimage2.bmp
|
||||
* dec_1_2_075_sampleimage2.bmp
|
||||
* dec_1_2_100_sampleimage2.bmp
|
||||
* dec_1_3_025_sampleimage2.bmp
|
||||
* dec_1_3_050_sampleimage2.bmp
|
||||
* dec_1_3_075_sampleimage2.bmp
|
||||
* dec_1_3_100_sampleimage2.bmp
|
||||
* dec_2_0_025_sampleimage3.bmp
|
||||
* dec_2_0_050_sampleimage3.bmp
|
||||
* dec_2_0_075_sampleimage3.bmp
|
||||
* dec_2_0_100_sampleimage3.bmp
|
||||
* dec_2_1_025_sampleimage3.bmp
|
||||
* dec_2_1_050_sampleimage3.bmp
|
||||
* dec_2_1_075_sampleimage3.bmp
|
||||
* dec_2_1_100_sampleimage3.bmp
|
||||
* dec_2_2_025_sampleimage3.bmp
|
||||
* dec_2_2_050_sampleimage3.bmp
|
||||
* dec_2_2_075_sampleimage3.bmp
|
||||
* dec_2_2_100_sampleimage3.bmp
|
||||
* dec_2_3_025_sampleimage3.bmp
|
||||
* dec_2_3_050_sampleimage3.bmp
|
||||
* dec_2_3_075_sampleimage3.bmp
|
||||
* dec_2_3_100_sampleimage3.bmp
|
||||
*/
|
||||
|
||||
struct _EGFX_SAMPLE_FILE
|
||||
{
|
||||
BYTE* buffer;
|
||||
UINT32 size;
|
||||
};
|
||||
typedef struct _EGFX_SAMPLE_FILE EGFX_SAMPLE_FILE;
|
||||
|
||||
BYTE* test_progressive_load_file(char* path, char* file, UINT32* size)
|
||||
{
|
||||
FILE* fp;
|
||||
BYTE* buffer;
|
||||
char* filename;
|
||||
|
||||
filename = GetCombinedPath(path, file);
|
||||
|
||||
fp = fopen(filename, "r");
|
||||
|
||||
if (!fp)
|
||||
return NULL;
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
*size = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
buffer = (BYTE*) malloc(*size);
|
||||
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
if (fread(buffer, *size, 1, fp) != 1)
|
||||
return NULL;
|
||||
|
||||
free(filename);
|
||||
fclose(fp);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
int test_progressive_load_files(char* ms_sample_path, EGFX_SAMPLE_FILE files[3][4][4])
|
||||
{
|
||||
int imageNo = 0;
|
||||
int quarterNo = 0;
|
||||
int passNo = 0;
|
||||
|
||||
/* image 1 */
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_0_025_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_0_050_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_0_075_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_0_100_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_1_025_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_1_050_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_1_075_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_1_100_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_2_025_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_2_050_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_2_075_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_2_100_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_3_025_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_3_050_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_3_075_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_0_3_100_sampleimage1.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
imageNo++;
|
||||
|
||||
/* image 2 */
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_0_025_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_0_050_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_0_075_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_0_100_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_1_025_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_1_050_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_1_075_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_1_100_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_2_025_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_2_050_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_2_075_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_2_100_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_3_025_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_3_050_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_3_075_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_1_3_100_sampleimage2.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
imageNo++;
|
||||
|
||||
/* image 3 */
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_0_025_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_0_050_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_0_075_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_0_100_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_1_025_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_1_050_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_1_075_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_1_100_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_2_025_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_2_050_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_2_075_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_2_100_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
quarterNo = (quarterNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_3_025_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_3_050_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_3_075_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
files[imageNo][quarterNo][passNo].buffer = test_progressive_load_file(ms_sample_path,
|
||||
"compress/enc_2_3_100_sampleimage3.bin", &(files[imageNo][quarterNo][passNo].size));
|
||||
passNo = (passNo + 1) % 4;
|
||||
|
||||
/* check if all test data has been loaded */
|
||||
|
||||
for (imageNo = 0; imageNo < 3; imageNo++)
|
||||
{
|
||||
for (quarterNo = 0; quarterNo < 4; quarterNo++)
|
||||
{
|
||||
for (passNo = 0; passNo < 4; passNo++)
|
||||
{
|
||||
if (!files[imageNo][quarterNo][passNo].buffer)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int g_Width = 0;
|
||||
static int g_Height = 0;
|
||||
static int g_DstStep = 0;
|
||||
static BYTE* g_DstData = NULL;
|
||||
|
||||
int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE_FILE files[4], int count)
|
||||
{
|
||||
int pass;
|
||||
int status;
|
||||
|
||||
for (pass = 0; pass < count; pass++)
|
||||
{
|
||||
status = progressive_decompress(progressive, files[pass].buffer, files[pass].size,
|
||||
&g_DstData, PIXEL_FORMAT_XRGB32, g_DstStep, 0, 0, g_Width, g_Height, 0);
|
||||
|
||||
printf("ProgressiveDecompress: status: %d pass: %d\n", status, pass + 1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int test_progressive_ms_sample(char* ms_sample_path)
|
||||
{
|
||||
int count;
|
||||
int status;
|
||||
EGFX_SAMPLE_FILE files[3][4][4];
|
||||
PROGRESSIVE_CONTEXT* progressive;
|
||||
|
||||
g_Width = 1920;
|
||||
g_Height = 1080;
|
||||
g_DstStep = g_Width * 4;
|
||||
|
||||
status = test_progressive_load_files(ms_sample_path, files);
|
||||
|
||||
if (status < 0)
|
||||
return -1;
|
||||
|
||||
count = 2;
|
||||
|
||||
progressive = progressive_context_new(FALSE);
|
||||
|
||||
g_DstData = _aligned_malloc(g_DstStep * g_Height, 16);
|
||||
|
||||
progressive_create_surface_context(progressive, 0, g_Width, g_Height);
|
||||
|
||||
/* image 1 */
|
||||
|
||||
if (1)
|
||||
{
|
||||
test_progressive_decode(progressive, files[0][0], count);
|
||||
test_progressive_decode(progressive, files[0][1], count);
|
||||
test_progressive_decode(progressive, files[0][2], count);
|
||||
test_progressive_decode(progressive, files[0][3], count);
|
||||
}
|
||||
|
||||
/* image 2 */
|
||||
|
||||
if (1)
|
||||
{
|
||||
test_progressive_decode(progressive, files[1][0], count);
|
||||
test_progressive_decode(progressive, files[1][1], count);
|
||||
test_progressive_decode(progressive, files[1][2], count);
|
||||
test_progressive_decode(progressive, files[1][3], count);
|
||||
}
|
||||
|
||||
/* image 3 */
|
||||
|
||||
if (1)
|
||||
{
|
||||
test_progressive_decode(progressive, files[2][0], count);
|
||||
test_progressive_decode(progressive, files[2][1], count);
|
||||
test_progressive_decode(progressive, files[2][2], count);
|
||||
test_progressive_decode(progressive, files[2][3], count);
|
||||
}
|
||||
|
||||
progressive_context_free(progressive);
|
||||
|
||||
_aligned_free(g_DstData);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TestFreeRDPCodecProgressive(int argc, char* argv[])
|
||||
{
|
||||
char* ms_sample_path;
|
||||
|
||||
ms_sample_path = _strdup("/tmp/EGFX_PROGRESSIVE_MS_SAMPLE");
|
||||
|
||||
if (PathFileExistsA(ms_sample_path))
|
||||
return test_progressive_ms_sample(ms_sample_path);
|
||||
|
||||
free(ms_sample_path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user