VDEC Functions and Restrictions

Function Description

VDEC decodes videos.

Resolution Restrictions

Input Resolution Range

Model

Resolution Range

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas inference products

128 × 128 to 4096 × 4096

Atlas 200I/500 A2 inference products

H.264 input streams: 128 × 128 to 8192 × 8192

H.265 input streams: 128 × 128 to 5400 × 8192

Output Resolution Range

Model

Resolution Range

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas inference products

10 × 6 to 4096 × 4096

Atlas 200I/500 A2 inference products

The maximum resolution of the output image is 8192 x 8192. When the width of the input stream is less than or equal to 4096, the minimum resolution of the output image is 10 × 6. Otherwise, the minimum resolution of the output image is 128 × 128.

APIs for Buffer Allocation and Freeing

When using VDEC, call hi_mpi_dvpp_malloc to allocate the input and output buffers on the device, and hi_mpi_dvpp_free to free the input and output buffers. The buffer lifetime is managed by the user. The size of the input buffer refers to the actual size occupied by the input stream. For details about the size of the output buffer, see the formula in Restrictions on Stream/Image Formats, Width and Height Alignment, and Buffers.

For the following product models, you can also call aclrtMalloc and aclrtFree to allocate and free the input and output buffers on the device. The buffer lifetime is managed by the user.

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

hi_mpi_dvpp_malloc allocates a dedicated buffer for processing media data. However, the address space of the dedicated buffer is limited. If buffer planning is considered or buffer resources are limited, you are advised to allocate a buffer by calling aclrtMalloc. When calling aclrtMalloc to allocate a buffer, you are advised to allocate the buffer of the ACL_MEM_MALLOC_HUGE_FIRST type. Huge page buffers are preferred because they have better performance.

Restrictions on Stream/Image Formats, Width and Height Alignment, and Buffers

  • Input stream formats:
    • H.264 BP/MP/HP level 5.1 YUV420 streams (Annex-B raw video streams only)
    • H.265 8-/10-bit level 5.1 YUV420 streams (Annex-B raw video streams only)
  • Output image requirements:

    For details about the definition of the output image format, see hi_pixel_format. For details about the concepts such as width stride and height stride, see Basic Concepts.

    Table 1 Restrictions on the stream/image format, width and height alignment, and buffer size ( Atlas A3 training products / Atlas A3 inference products and Atlas A2 training products / Atlas A2 inference products )

    Output Image Format

    Output Width and Height

    Output Width Stride, Height Stride, and Buffer Size

    YUV420SP NV12 8-bit

    Width: a multiple of 2

    Height: a multiple of 2

    Width stride: No alignment requirements. The value is the same as the width and ranges from 10 to 24576.

    Height stride: No alignment requirements. The value is the same as the height and ranges from 6 to 24576.

    The start address of the buffer must be 16-byte aligned.

    Buffer size (in bytes) ≥ Width stride × Height stride × 3/2

    YUV420SP NV21 8-bit

    Width: a multiple of 2

    Height: a multiple of 2

    YUV420SP NV12 10bit

    YUV420SP NV21 10bit

    Width: a multiple of 2

    Height: a multiple of 2

    Width stride: Round up the width to the nearest multiple of 2 and then multiply the result by 2. The value ranges from 256 to 24576.

    Height stride: Round up the height to the nearest multiple of 2. The value ranges from 128 to 24576.

    The start address of the buffer must be 16-byte aligned.

    Buffer size (in bytes) ≥ Width stride × Height stride × 3/2

    RGB888

    BGR888

    No alignment requirements.

    Width stride = Width x 3. The value ranges from 30 to 24576.

    Height stride: No alignment requirements. The value is the same as the height and ranges from 6 to 24576.

    The start address of the buffer must be 16-byte aligned.

    Buffer size (in bytes) ≥ Width stride × Height stride

    RGB888 Planar

    BGR888 Planar

    No alignment requirements.

    Width stride: No alignment requirements. The value is the same as the width and ranges from 10 to 24576.

    Height stride: No alignment requirements. The value is the same as the height and ranges from 6 to 24576.

    The start address of the buffer must be 16-byte aligned.

    Buffer size (in bytes) ≥ Width stride × Height stride

    Table 2 Restrictions on stream/image formats, width and height alignment, and buffers for Atlas 200I/500 A2 inference products

    Output Image Format

    Output Width and Height

    Output Width Stride, Height Stride, and Buffer Size

    YUV420SP NV12 8-bit

    YUV420SP NV21 8-bit

    Width: a multiple of 2

    Height: a multiple of 2

    Width stride: No alignment requirements. The value is the same as the width and ranges from 10 to 24576.

    Height stride: No alignment requirements. The value is the same as the height and ranges from 6 to 24576.

    The start address of the buffer must be 16-byte aligned.

    Buffer size (in bytes) ≥ Width stride × Height stride × 3/2

    RGB888

    BGR888

    No alignment requirements.

    Width stride = Width x 3. The value ranges from 30 to 24576.

    Height stride: No alignment requirements. The value is the same as the height and ranges from 6 to 24576.

    The start address of the buffer must be 16-byte aligned.

    Buffer size (in bytes) ≥ Width stride × Height stride

    Table 3 Restrictions on stream/image formats, width and height alignment, and buffers for Atlas inference products

    Output Image Format

    Output Width and Height

    Output Width Stride, Height Stride, and Buffer Size

    YUV420SP NV12 8-bit

    YUV420SP NV21 8-bit

    Width: a multiple of 2

    Height: a multiple of 2

    Width stride: Round up the width to the nearest multiple of 16. The value ranges from 32 to 16384.

    Height stride: Round up the height to the nearest multiple of 2. The value ranges from 6 to 16384.

    The start address of the buffer must be 16-byte aligned.

    Buffer size (in bytes) ≥ Width stride × Height stride × 3/2

    RGB888

    BGR888

    No alignment requirements.

    Width stride: Round up the width to the nearest multiple of 16 and then multiply the result by 3. The value ranges from 48 to 16384.

    Height stride: No alignment requirements. The value ranges from 6 to 16384.

    The start address of the buffer must be 16-byte aligned.

    Buffer size (in bytes) ≥ Width stride × Height stride

Other Restrictions

  • If the output image format is YUV420SP NV12 10-bit or YUV420SP NV21 10-bit, image resizing and CSC are not supported when VDEC is used.

    This restriction applies to the following product models:

    Atlas A3 training products / Atlas A3 inference products

    Atlas A2 training products / Atlas A2 inference products

  • VDEC decodes input streams by frame.
  • If there are bad frames or frame loss in the stream, VDEC will mark the frames as a decoding failure and report an exception.
  • VDEC decodes only H.264 8-bit streams encoded in interlaced mode.
  • The combined use of stream feeding in frame mode and output in the decoding sequence enables both fast decoding and output. However, this is not applicable to streams containing B-frames.