Decompress

This sample demonstrates the decompress function of the IMDC peripheral.

Requirements

The sample supports the following development kits:

Development Kit

Hardware Platforms

Board Name

RTL87x2G HDK

RTL87x2G EVB

For more requirements, please refer to Quick Start.

Wiring

None

Building and Downloading

This sample can be found in the SDK folder:

Project file: samples\peripheral\imdc\decompress\proj\rtl87x2g\mdk

Project file: samples\peripheral\imdc\decompress\proj\rtl87x2g\gcc

To build and run the sample, follow the steps listed below:

  1. Open Sample Project File.

  2. To build the target, follow the steps listed in the Generating App Image in Quick Start.

  3. After a successful compilation, the app bin app_MP_xxx.bin will be generated in the directory mdk\bin.

  4. To download app bin into the EVB board, follow the steps listed in the MP Tool Download in Quick Start.

  5. Press the reset button on the EVB board and it will start running.

Experimental Verification

  1. After the sample is executed, observing the following log in the DebugAnalyzer window indicates successful decompression:

decompress procedure succeeded

Code Overview

This chapter will be introduced according to the following several parts:

  1. Source Code Directory.

  2. Peripheral initialization will be introduced in chapter Initialization.

  3. Functional implementation after initialization will be introduced in chapter Functional Implementation.

Source Code Directory

  1. Project Directory: sdk\samples\peripheral\imdc\decompress\proj

  2. Source Code Directory: sdk\samples\peripheral\imdc\decompress\src

Source files are currently categorized into several groups as below.

└── Project: decompress
    └── imdc
        ├── config                   includes project construct configuration
        ├── display                  includes the peripheral drivers related with display
        └── Device                   includes startup code
            ├── startup_rtl.c
            └── system_rtl.c
        ├── CMSIS                    includes CMSIS header files
        ├── CMSE Library             non-secure callable lib
        ├── Lib                      includes all binary symbol files that user application is built on
            └── rtl87x2g_io.lib
        ├── Peripheral               includes all peripheral drivers and module code used by the application
            ├── rtl_rcc.c
            ├── rtl_pinmux.c
        └── APP                      source code of IMDC sample
            ├── main_ns.c
            └── imdc_test.c

Initialization

The initialization process is included in IMDC_test().

  1. Decode information of the compressed image.

Tip

For the selection of image format, refer to Troubleshooting.

  1. Determine the range of the image to be decompressed.

IMDC_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;
  1. Assign DMA channels and the address to store decompressed data.

IMDC_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 IMDC_Decode(), decompressed data will be compared with golden data. If any error occurs, false data will be displayed in DebugAnalyzer Tool.

Troubleshooting

Select Compressed Picture

Find desired format in imdc_test_source.h and change the MACRO definition at the start of the corresponding line to 1. Meanwhile, ensure all other MACROs in this file are defined as 0.