Decompress
This sample demonstrates using IDU to decompress various combinations of compress algorithms and color formats.
Requirements
For requirements, please refer to the Requirements.
Wiring
No physical connection is required in this sample.
Configurations
The following macros can be configured to select target compress algorithm and color format. Note: Only one of the following these macros can be set to 1.
#if 0 /*< RGB888, RLE stage 1, Run Length in stage1 = 1 */ #if 0 /*< RGBA8888, RLE stage 1, Run Length in stage1 = 1 */ #if 0 /*< RGBA8888, RLE stage 1, Run Length in stage1 = 2 */ #if 0 /*< RGBA8888, RLE stage 2, Run Length in stage1 = 1, Run Length in stage2 = 1 */ #if 0 /*< RGBA8888, RLE stage 2, Run Length in stage1 = 1, Run Length in stage2 = 2 */ #if 0 /*< RGBA8888, RLE stage 2, Run Length in stage1 = 2, Run Length in stage2 = 1 */ #if 0 /*< RGBA8888, RLE stage 2, Run Length in stage1 = 2, Run Length in stage2 = 2 */ #if 0 /*< RGBA8888, FastLZ */ #if 0 /*< RGB888, YUV411 sampling, No bit blur */ #if 0 /*< RGB888, YUV411 sampling, Blur 1 bit */ #if 0 /*< RGB888, YUV411 sampling, Blur 2 bits */ #if 0 /*< RGB888, YUV411 sampling, Blur 4 bits */ #if 0 /*< RGB888, YUV422 sampling, No bit blur */ #if 0 /*< RGB888, YUV422 sampling, Blur 1 bit */ #if 0 /*< RGB888, YUV422 sampling, Blur 2 bits */ #if 0 /*< RGB888, YUV422 sampling, Blur 4 bits */ #if 0 /*< RGB888, YUV444 sampling, No bit blur */ #if 0 /*< RGB888, YUV444 sampling, Blur 1 bit */ #if 0 /*< RGB888, YUV444 sampling, Blur 2 bits */ #if 0 /*< RGB888, YUV444 sampling, Blur 4 bits */ #if 0 /*< RGB888, YUV411 sampling, No bit blur, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV411 sampling, Blur 1 bit, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV411 sampling, Blur 2 bits, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV411 sampling, Blur 4 bits, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV422 sampling, No bit blur, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV422 sampling, Blur 1 bit, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV422 sampling, Blur 2 bits, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV422 sampling, Blur 4 bits, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV444 sampling, No bit blur, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV444 sampling, Blur 1 bit, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV444 sampling, Blur 2 bits, FastLZ applied on sampled data */ #if 0 /*< RGB888, YUV444 sampling, Blur 4 bits, FastLZ applied on sampled data */
Building and Downloading
For building and downloading, please refer to the Building and Downloading.
Experimental Verification
Decompress Successfully
After the sample is executed on EVB, observing the following log in the DebugAnalyzer window indicates successful decompression, which mean data decompressed by IDU all meet golden value.
decompress procedure succeeded
Decompress Failed
After the sample is executed on EVB, observing the following log in the DebugAnalyzer window indicates unsuccessful decompression, which means data decompressed by IDU does not meet golden value.
Both received value and golden value will be displayed, as well as position that error occurs. For example:
Received word is 0xABCDEF00
Golden word is 0x12345678
[ERROR] occurs during decompress procedure at offset 172
Code Overview
This section introduces the code and process description for initialization and corresponding function implementation in the sample.
Source Code Directory
The directories for project file and source code are as follows:
Project directory:
sdk\samples\peripheral\idu\decompress\proj
Source code directory:
sdk\samples\peripheral\idu\decompress\src
Initialization
The initialization procedure is included in IDU_test()
.
Select target compress algorithm and color format according to Configurations.
Read information from header of compressed data. Information of algorithm, pixel size and image size is stored in
IDU_file_header
IDU_file_header *header = (IDU_file_header *)file_data;
Fill the decompress range in structure
IDU_decode_range
.
IDU_decode_range range;
range.start_column = 0;
range.end_column = header->raw_pic_width - 1;
range.start_line = 0;
range.end_line = header->raw_pic_height - 1;
Assign GDMA channels and the address to store decompressed data in
IDU_DMA_config
.
IDU_DMA_config dma_cfg;
dma_cfg.output_buf = (uint32_t *)buf;
dma_cfg.RX_DMA_channel_num = 0;
dma_cfg.TX_DMA_channel_num = 1;
Functional Implementation
After executing IDU_Decode()
, decompressed data will be compared with golden data. If any error occurs, false data will be displayed in DebugAnalyzer Tool as demonstrated in Experimental Verification.