vpu: decoder: Fix video size in buffer pool configuration#331
vpu: decoder: Fix video size in buffer pool configuration#331evanedstrom wants to merge 1 commit into
Conversation
imx_vpu_dec_buffer_pool->video_info.size should be the actual framebuffer size. Including the extra reserved space at the end of the buffer in video_info.size will confuse downstream and make it think this space is part of the frame data.
| * 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; |
There was a problem hiding this comment.
Can you give an example for such a confusion?
There was a problem hiding this comment.
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:
gstreamer-imx/ext/vpu/gstimxvpudec.c
Line 1456 in ce4f86e
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:
gstreamer-imx/ext/vpu/gstimxvpudec.c
Line 1699 in ce4f86e
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
We encountered a visual artifact similar to what is shown in issue #303. I believe the same issue exists in the buffer pool which was fixed in the decoder in 545502e. I implemented this patch for our product, but believe it has upstream utility as others may encounter this same problem.
This sets video_info.size to min_output_framebuffer_size in the buffer pool, matching what 545502e does for individual output buffers.