Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion ext/vpu/gstimxvpudecbufferpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ static gboolean gst_imx_vpu_dec_buffer_pool_set_config(GstBufferPool *pool, GstS
imx_vpu_dec_buffer_pool->video_info.offset[0] = 0;
imx_vpu_dec_buffer_pool->video_info.offset[1] = fb_metrics->y_size;
imx_vpu_dec_buffer_pool->video_info.offset[2] = fb_metrics->y_size + fb_metrics->uv_size;
imx_vpu_dec_buffer_pool->video_info.size = MAX(stream_info->min_output_framebuffer_size, size);
/* Advertise the minimum required size of DMA buffer memory for the
* frame size. The buffer pool size can be larger to include reserved
* space on some SoCs, but advertising it will confuse downstream
* interpretation of the buffer contents. */
imx_vpu_dec_buffer_pool->video_info.size = stream_info->min_output_framebuffer_size;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give an example for such a confusion?

Copy link
Copy Markdown
Author

@evanedstrom evanedstrom Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are on i.MX6, decoding H.264 at 800x480 NV12, pipeline excerpt: "queue ! imxvpudec_h264 ! qtvideosink"

I will use the actual sizes of our scenario as an example:

  • min_output_framebuffer_size = 645120 (Y + UV)
  • min_fb_pool_framebuffer_size = 860160 (Y + UV + 215040 bytes of MvCol data used by the VPU)

The decoder sets the output buffer's logical size to 645120 here:

gst_buffer_set_size(out_frame->output_buffer, imx_vpu_dec->current_stream_info.min_output_framebuffer_size);

Prior to this change, video_info.size is set to 860160 in the buffer pool, the full allocated buffer size. This is wrong because the video frame is not this size.

When downstream doesn't support GstVideoMeta, the decoder uses gst_imx_vpu_dec_copy_output_frame_if_needed() which pulls video_info from the dma buffer pool here:

memcpy(&vpu_video_info, gst_imx_vpu_dec_buffer_pool_get_video_info(imx_vpu_dec->dma_buffer_pool), sizeof(GstVideoInfo));

The subsequent call to gst_video_frame_map() then fails because the buffer's logical size (645120) is smaller than video_info.size (860160) so it thinks the buffer is too small for the frame:

    /* do some sanity checks */
    if (frame->map[0].size < info->size)
      goto invalid_size;

Resulting error:

ERROR                default video-frame.c:181:gst_video_frame_map_id: invalid buffer size 645120 < 860160
ERROR              imxvpudec gstimxvpudec.c:1709:gst_imx_vpu_dec_copy_output_frame_if_needed:<imxvpudech264-0> could not map VPU output video frame


imx_vpu_dec_buffer_pool->add_videometa = gst_buffer_pool_config_has_option(config, GST_BUFFER_POOL_OPTION_VIDEO_META);

Expand Down