va: filter, deinterlace, vpp: Add gst_va_buffer_get_surface_flags().

Add a helper function to get, from GstVideoInfo and GstBuffers flags,
the VA interlace surface flags. This is used currently by vainterlace
element, but it will be used in vapostproc too if it can process
interlaced frames.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1109>
This commit is contained in:
Víctor Manuel Jáquez Leal 2021-10-05 17:41:57 +02:00 committed by GStreamer Marge Bot
parent 547570cd79
commit 1642c3fc96
4 changed files with 46 additions and 26 deletions

View file

@ -396,32 +396,7 @@ gst_va_deinterlace_transform (GstBaseTransform * trans, GstBuffer * inbuf,
g_assert (self->curr_field == FIRST_FIELD g_assert (self->curr_field == FIRST_FIELD
|| self->curr_field == SECOND_FIELD); || self->curr_field == SECOND_FIELD);
surface_flags = 0; surface_flags = gst_va_buffer_get_surface_flags (inbuf, info);
if (GST_VIDEO_INFO_INTERLACE_MODE (info) == GST_VIDEO_INTERLACE_MODE_MIXED
|| (GST_VIDEO_INFO_INTERLACE_MODE (info) ==
GST_VIDEO_INTERLACE_MODE_INTERLEAVED
&& GST_VIDEO_INFO_FIELD_ORDER (info) ==
GST_VIDEO_FIELD_ORDER_UNKNOWN)) {
if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_VIDEO_BUFFER_FLAG_INTERLACED)) {
if (GST_BUFFER_FLAG_IS_SET (inbuf, GST_VIDEO_BUFFER_FLAG_TFF)) {
surface_flags = VA_TOP_FIELD_FIRST;
} else {
surface_flags = VA_BOTTOM_FIELD_FIRST;
}
} else {
/* complete frame? do it twice */
surface_flags = VA_FRAME_PICTURE;
}
} else if (GST_VIDEO_INFO_FIELD_ORDER (info) ==
GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST) {
surface_flags = VA_BOTTOM_FIELD_FIRST;
} else if (GST_VIDEO_INFO_FIELD_ORDER (info) ==
GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST) {
surface_flags = VA_TOP_FIELD_FIRST;
} else {
g_assert_not_reached ();
}
if (surface_flags != VA_FRAME_PICTURE) if (surface_flags != VA_FRAME_PICTURE)
_set_field (self, &surface_flags); _set_field (self, &surface_flags);

View file

@ -1695,3 +1695,43 @@ fail_end_pic:
goto bail; goto bail;
} }
} }
/**
* gst_va_buffer_get_surface_flags:
* @buffer: the #GstBuffer to check.
* @info: the #GstVideoInfo with info.
*
* Gets the surface flags, related with interlace given @buffer and
* @info.
*
* Returns: VA surface flags.
*/
guint32
gst_va_buffer_get_surface_flags (GstBuffer * buffer, GstVideoInfo * info)
{
guint32 surface_flags = 0;
if (GST_VIDEO_INFO_INTERLACE_MODE (info) == GST_VIDEO_INTERLACE_MODE_MIXED
|| (GST_VIDEO_INFO_INTERLACE_MODE (info) ==
GST_VIDEO_INTERLACE_MODE_INTERLEAVED
&& GST_VIDEO_INFO_FIELD_ORDER (info) ==
GST_VIDEO_FIELD_ORDER_UNKNOWN)) {
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_INTERLACED)) {
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_VIDEO_BUFFER_FLAG_TFF)) {
surface_flags = VA_TOP_FIELD_FIRST;
} else {
surface_flags = VA_BOTTOM_FIELD_FIRST;
}
} else {
surface_flags = VA_FRAME_PICTURE;
}
} else if (GST_VIDEO_INFO_FIELD_ORDER (info) ==
GST_VIDEO_FIELD_ORDER_BOTTOM_FIELD_FIRST) {
surface_flags = VA_BOTTOM_FIELD_FIRST;
} else if (GST_VIDEO_INFO_FIELD_ORDER (info) ==
GST_VIDEO_FIELD_ORDER_TOP_FIELD_FIRST) {
surface_flags = VA_TOP_FIELD_FIRST;
}
return surface_flags;
}

View file

@ -110,4 +110,7 @@ gboolean gst_va_filter_process (GstVaFilter * self,
GstVaSample * src, GstVaSample * src,
GstVaSample * dest); GstVaSample * dest);
guint32 gst_va_buffer_get_surface_flags (GstBuffer * buffer,
GstVideoInfo * info);
G_END_DECLS G_END_DECLS

View file

@ -651,10 +651,12 @@ gst_va_vpp_transform (GstBaseTransform * trans, GstBuffer * inbuf,
/* *INDENT-OFF* */ /* *INDENT-OFF* */
src = (GstVaSample) { src = (GstVaSample) {
.buffer = buf, .buffer = buf,
.flags = gst_va_buffer_get_surface_flags (buf, &btrans->in_info),
}; };
dst = (GstVaSample) { dst = (GstVaSample) {
.buffer = outbuf, .buffer = outbuf,
.flags = gst_va_buffer_get_surface_flags (outbuf, &btrans->out_info),
}; };
/* *INDENT-ON* */ /* *INDENT-ON* */