summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2019-06-10 20:46:30 -0700
committerTim-Philipp Müller <tim@centricular.com>2020-01-08 18:10:21 +0000
commita9578a47e1ecfa75c8760f3cb603706ebe212251 (patch)
tree2e555fca7e508bd9947f41e0314ef6af1c8b95c1
parent043309e90081f2dbf910f14ee13999cde27472bd (diff)
downloadgstreamer-vaapi-a9578a47e1ecfa75c8760f3cb603706ebe212251.tar.gz
plugins: remove last negotiated video info if caps are same
If the allocation caps and negotiated caps are the same, then ensure any previously negotiated video info is also removed. This can occur when multi-resolution video decoding returns to it's original resolution. Fixes #170
-rw-r--r--gst/vaapi/gstvaapipluginbase.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c
index c7c929e3..1753ad09 100644
--- a/gst/vaapi/gstvaapipluginbase.c
+++ b/gst/vaapi/gstvaapipluginbase.c
@@ -532,7 +532,6 @@ static gboolean
ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo,
GstCaps * caps)
{
- gboolean different_caps;
const GstVideoInfo *image_info;
if (!reset_allocator (plugin->srcpad_allocator, vinfo))
@@ -576,30 +575,37 @@ valid_allocator:
/* update the size with the one generated by the allocator */
GST_VIDEO_INFO_SIZE (vinfo) = GST_VIDEO_INFO_SIZE (image_info);
- /* the received caps are the "allocation caps" which may be
- * different from the "negotiation caps". In this case, we should
- * indicate the allocator to store the negotiation caps since they
- * are the one should be used for frame mapping with GstVideoMeta */
- different_caps = GST_IS_VIDEO_DECODER (plugin) && plugin->srcpad_caps &&
- !gst_caps_is_strictly_equal (plugin->srcpad_caps, caps);
-
- if (different_caps) {
- guint i;
- GstVideoInfo vi = plugin->srcpad_info;
-
- /* update the planes and the size with the allocator image/surface
- * info, but not the resolution */
- for (i = 0; i < GST_VIDEO_INFO_N_PLANES (image_info); i++) {
- GST_VIDEO_INFO_PLANE_OFFSET (&vi, i) =
- GST_VIDEO_INFO_PLANE_OFFSET (image_info, i);
- GST_VIDEO_INFO_PLANE_STRIDE (&vi, i) =
- GST_VIDEO_INFO_PLANE_STRIDE (image_info, i);
+ if (GST_IS_VIDEO_DECODER (plugin)) {
+ /* the received caps are the "allocation caps" which may be
+ * different from the "negotiation caps". In this case, we should
+ * indicate the allocator to store the negotiation caps since they
+ * are the one should be used for frame mapping with GstVideoMeta */
+ gboolean different_caps = plugin->srcpad_caps &&
+ !gst_caps_is_strictly_equal (plugin->srcpad_caps, caps);
+ const GstVideoInfo *previous_negotiated =
+ gst_allocator_get_vaapi_negotiated_video_info
+ (plugin->srcpad_allocator);
+
+ if (different_caps) {
+ guint i;
+ GstVideoInfo vi = plugin->srcpad_info;
+
+ /* update the planes and the size with the allocator image/surface
+ * info, but not the resolution */
+ for (i = 0; i < GST_VIDEO_INFO_N_PLANES (image_info); i++) {
+ GST_VIDEO_INFO_PLANE_OFFSET (&vi, i) =
+ GST_VIDEO_INFO_PLANE_OFFSET (image_info, i);
+ GST_VIDEO_INFO_PLANE_STRIDE (&vi, i) =
+ GST_VIDEO_INFO_PLANE_STRIDE (image_info, i);
+ }
+ GST_VIDEO_INFO_SIZE (&vi) = GST_VIDEO_INFO_SIZE (image_info);
+ gst_allocator_set_vaapi_negotiated_video_info (plugin->srcpad_allocator,
+ &vi);
+ } else if (previous_negotiated) {
+ gst_allocator_set_vaapi_negotiated_video_info (plugin->srcpad_allocator,
+ NULL);
}
- GST_VIDEO_INFO_SIZE (&vi) = GST_VIDEO_INFO_SIZE (image_info);
- gst_allocator_set_vaapi_negotiated_video_info (plugin->srcpad_allocator,
- &vi);
}
-
return TRUE;
/* ERRORS */