JPEG Decoding Overview

[中文]

1. Overview

This section mainly describes the overall architecture, supported functions, and usage methods of the JPEG decoder. The system provides two JPEG decoding solutions: hardware decoding and software decoding to meet the needs of different scenarios.

2. Architecture

The JPEG decoder provides two implementation methods:

  1. Hardware Decoder: Uses dedicated hardware to accelerate the JPEG decoding process, featuring high performance and low CPU usage.

  2. Software Decoder: Uses CPU to implement the JPEG decoding process, providing more flexible decoding options and output format support.

The hardware decoder and software decoder share similar interface designs, allowing users to easily switch between the two modes. Both decoders support the same callback mechanism and basic decoding process.

3. Supported Functions

Common features of both JPEG decoders:

  1. Supports standard JPEG format decoding;

  2. Supports obtaining image information (width, height, format, etc.);

  3. Supports callback mechanism to handle decoding completion events;

  4. Supports extended control interface.

Hardware decoder specific features:

  1. High decoding speed;

  2. No CPU resource occupation;

Software decoder specific features:

  1. Supports multiple output formats such as GRAY, RGB565, RGB888, YUYV, VYUY, VUYY;

  2. Supports big-endian and little-endian byte order configuration;

  3. Supports multi-core optimized execution;

  4. Provides rich image rotation and format conversion options;

  5. Supports JPEG image decoding of multiple formats: YUV444, YUV422, YUV420.

4. Document Structure

This JPEG decoding documentation set includes the following parts:

  1. JPEG Decoding Overview (current page): Provides an overview of the overall architecture and functions of JPEG decoding.

  2. JPEG Hardware Decoding: Details the usage methods, APIs, and data structures of the hardware decoder.

  3. JPEG Software Decoding: Details the usage methods, APIs, and data structures of the software decoder.

6. Usage Flow Comparison

The basic usage flows of hardware decoders and software decoders are similar, but there are differences in specific implementations and configuration options. Here is a comparison of the main usage flows for both decoders:

Hardware Decoder Usage Flow:

  1. Create hardware decoder instance (bk_hardware_jpeg_decode_new)

  2. Open hardware decoder (bk_jpeg_decode_hw_open)

  3. Get image information (bk_jpeg_decode_hw_get_img_info)

  4. Configure hardware decoder (optional, bk_jpeg_decode_hw_set_config)

  5. Wait for decoding to complete

  6. Close hardware decoder (bk_jpeg_decode_hw_close)

  7. Delete hardware decoder instance (bk_jpeg_decode_hw_delete)

Software Decoder Usage Flow:

  1. Create software decoder instance (bk_software_jpeg_decode_new or bk_software_jpeg_decode_on_multi_core_new)

  2. Open software decoder (bk_jpeg_decode_sw_open)

  3. Get image information (bk_jpeg_decode_sw_get_img_info)

  4. Set output frame configuration (bk_jpeg_decode_sw_set_config, optional, called when changing the configuration passed during instance creation)

  5. Execute decoding (synchronous or asynchronous)

  6. Wait for decoding to complete

  7. Close software decoder (bk_jpeg_decode_sw_close)

  8. Delete software decoder instance (bk_jpeg_decode_sw_delete)

7. JPEG Decoder Selection Guide

How to choose the appropriate JPEG decoder? Here are some selection guidelines:

Choose Hardware Decoder When:

  • High performance requirements, need to quickly decode a large number of JPEG images

  • Moderate decoding resolution and not complex output format requirements

  • Other CPU-intensive tasks need to run

Choose Software Decoder When:

  • Need to support multiple output formats and special image processing

  • Have special requirements for decoding quality

  • Need to process some non-standard or special JPEG formats

  • Sufficient system resources and not strict power consumption requirements

  • Low decoding resolution and small number of images

  • Need to optimize performance on multi-core processors

In some application scenarios, a combination of both decoders can also be considered. For example, when processing JPEG images of different resolutions or formats, the most suitable decoder can be selected based on specific needs.

8. JPEG Decoding Reference Project

The complete JPEG decoding example project is located at:

./projects/jpeg_decode_example

This example provides detailed usage cases, including complete implementations of hardware decoding and software decoding, as well as demonstrations of error handling, callback mechanisms, and other functions. The example code shows how to use the JPEG decoder for image decoding in practical applications.

9. More Information

  • For detailed information about JPEG hardware decoding, please refer to: jpeg_decoding_hw

  • For detailed information about JPEG software decoding, please refer to: jpeg_decoding_sw