Skip to content

va: refine the VIDEO_ALIGNMENT inside va buffer pool.

He Junyan requested to merge He_Junyan/gst-plugins-bad:alignment into master

The current way of VIDEO_ALIGNMENT handling in VA is not precise. First, we still get a lot of warning such as:

0:00:01.402578248 2729491 0x55c9811a6720 WARN               videometa gstvideometa.c:414:gst_video_meta_validate_alignment: Stride of plane 0 defined in meta (1024) is different from the one computed from 
the alignment (1000)

And the alignment of output buffer's video meta is not correct if we have a left or top offset for output display picture.

We now meet a lot of H265 stream with conformance_window_flag=1 and conf_win_left/top_offset>0, which means the output display picture is in the middle of the decoded picture, not in the left-up cornor. We can not handle this now.

In current manner,

  1. We just use the video align to expand the decoded surface resolution, such as:
    base->valign = (GstVideoAlignment) {
      .padding_bottom = self->coded_height - base->height,
      .padding_left = self->coded_width - base->width,
    };

We do not really care about the real position of the output display picture position here, we just assume it in the up-right corner.

  1. In gst_va_pool_set_config, the video_align is just used for calculation the real decoded buffer's width and height. https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/blob/master/sys/va/gstvapool.c#L124 in fact has no effect. The gst_video_info_align just calculate the offset and stride based on the video_align. But all the offsets and strides are overwritten in gst_va_dmabuf_allocator_try or gst_va_allocator_try later. Here, we assume the output display picture is in the left-up corner.

  2. When allocate buffer, https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/blob/master/sys/va/gstvapool.c#L256 assign the wrong video_align. Again we assumes that the output display picture is in the right-up corner.

  3. In real buffer usage, we assume the output display picture is in the left-up corner again, like: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/blob/master/sys/va/gstvafilter.c#L1177

So, the conclusion is, we just use video_align to calculate the real decoded buffer's width and height now and do not care about the real position of output display picture inside the decoded buffer. When the output display picture is not in the left-up corner, we have error.

Edited by He Junyan

Merge request reports