Skip to main content

Video Decoding

The Video Decoding section allows developers to enhance the TouchGFX HAL with either hardware or software video decoding capabilities.

TouchGFX Generator Video Decoding settings

Further reading
See the MJPEG Video article for in-depth information on how MJPEG Video Decoding is done in TouchGFX.

Video software decoding allows the use of a different Decoding Format, than the one used for the application framebuffer. Video hardware decoding only supports video RGB buffer(s) with the same pixel format as the application framebuffer.

Note
Not all MCUs support hardware video decoding.
Audio is not supported.

Type

By default the "Type" of Video Decoding is disabled. If the required peripherals are not enabled in STM32CubeMX, both "Software" and "Hardware" will be greyed out. Hover the mouse over the greyed-out options the see which peripherals are required.

Info box showing Video Type dependencies for "Hardware"

  • Software - If LIBJPEG is enabled under the Middleware and Software Packs section in STM32CubeMX, the "Software" option can be selected and the software decoder will be generated. This means that TouchGFX Generator will generate a software MJPEG decoder.

LIBJPEG enabled in STM32CubeMX project

  • Hardware - If JPEG IP is enabled under the Multimedia section and a CMSIS compliant RTOS is selected in the TouchGFX Generator the "Hardware" option can be selected.

JPEG IP enabled in STM32CubeMX project

Further reading
See section Scenarios for concrete examples of code for different video decoding scenarios.

Concurrent videos

The "Concurrent Videos" option is the largest amount of videos being decoded simultaneously on the same screen in the GUI at any given time. If you only wish to decode one video on a screen, the "Number of Videos" can be set to 1.

A maximum of 4 videos can be decoded simultaneously.

Strategy

The developer has three options when it comes to the video decoding strategy.

  • Direct to Framebuffer - The video is decoded in the UI thread. It can be slower than the other strategies, but saves RAM by not having a buffer for the video frames.
  • Single Buffer - Video is decoded in a separate task in a dedicated buffer. This buffer is allocated in internal memory.
  • Double Buffer - Video is decoded in a separate task in two dedicated buffers for better performances at the cost of memory.

When working with the single or double framebuffer strategy it is necessary to enable a CMSIS compliant OS.

Info box about CMSIS RTOS requirement

Note
Pay attention to the memory consumption when working with the double buffer strategy.
Further reading
See section Scenarios for a concrete example of configuring FreeRTOS for video decoding.

Decode Format

For Software decoding, developers can choose the pixel format of the RGB buffer regardless of the pixel format of the framebuffer. TouchGFX Generator generates code that allows DMA2D (ChromART) to do pixel-format-conversion between the formats if they're different.

  • RGB565 - Video RGB buffer is 16-bit.
  • RGB888 - Video RGB buffer is 24-bit.
  • ARGB8888 - Video RGB buffer is 32-bit. Alpha value is 255.
Tip
Having the video decoding buffer in RGB565 (16-bit) in a RGB888 (24-bit) application allows developers to have a smaller memory footprint.

Buffer size

The buffer width and height settings must be larger than or equal to the largest video dimensions in the application. The width must be divisible by 32.