diff --git a/subprojects/gst-plugins-bad/sys/va/gstvafilter.c b/subprojects/gst-plugins-bad/sys/va/gstvafilter.c index 3eed9afe32..58a4b2ff70 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvafilter.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvafilter.c @@ -32,6 +32,7 @@ #include "gstvacaps.h" #include "gstvadisplay_priv.h" #include "gstvavideoformat.h" +#include "vasurfaceimage.h" struct _GstVaFilter { @@ -1508,12 +1509,20 @@ static gboolean _fill_va_sample (GstVaFilter * self, GstVaSample * sample, GstPadDirection direction) { - GstVideoCropMeta *crop; + GstVideoCropMeta *crop = NULL; - sample->surface = gst_va_buffer_get_surface (sample->buffer); + if (sample->buffer) + sample->surface = gst_va_buffer_get_surface (sample->buffer); if (sample->surface == VA_INVALID_ID) return FALSE; + /* @FIXME: in gallium vaQuerySurfaceStatus only seems to work with + * encoder's surfaces */ + if (!GST_VA_DISPLAY_IS_IMPLEMENTATION (self->display, MESA_GALLIUM)) { + if (!va_check_surface (self->display, sample->surface)) + return FALSE; + } + /* XXX: cropping occurs only in input frames */ if (direction == GST_PAD_SRC) { GST_OBJECT_LOCK (self); @@ -1524,7 +1533,8 @@ _fill_va_sample (GstVaFilter * self, GstVaSample * sample, } /* if buffer has crop meta, its real size is in video meta */ - crop = gst_buffer_get_video_crop_meta (sample->buffer); + if (sample->buffer) + crop = gst_buffer_get_video_crop_meta (sample->buffer); GST_OBJECT_LOCK (self); if (crop && self->crop_enabled) { @@ -1612,8 +1622,8 @@ gst_va_filter_process (GstVaFilter * self, GstVaSample * src, GstVaSample * dst) gboolean ret = FALSE; g_return_val_if_fail (GST_IS_VA_FILTER (self), FALSE); - g_return_val_if_fail (src && GST_IS_BUFFER (src->buffer), FALSE); - g_return_val_if_fail (dst && GST_IS_BUFFER (dst->buffer), FALSE); + g_return_val_if_fail (src, FALSE); + g_return_val_if_fail (dst, FALSE); if (!gst_va_filter_is_open (self)) return FALSE; diff --git a/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.c b/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.c index 2f0015d0bd..4b1b0982a4 100644 --- a/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.c +++ b/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.c @@ -21,6 +21,7 @@ #include "vasurfaceimage.h" #include "gstvavideoformat.h" +#include gboolean va_destroy_surfaces (GstVaDisplay * display, VASurfaceID * surfaces, @@ -290,3 +291,22 @@ va_ensure_image (GstVaDisplay * display, VASurfaceID surface, return ret; } + +gboolean +va_check_surface (GstVaDisplay * display, VASurfaceID surface) +{ + VADisplay dpy = gst_va_display_get_va_dpy (display); + VAStatus status; + VASurfaceStatus state; + + gst_va_display_lock (display); + status = vaQuerySurfaceStatus (dpy, surface, &state); + gst_va_display_unlock (display); + + if (status != VA_STATUS_SUCCESS) + GST_ERROR ("vaQuerySurfaceStatus: %s", vaErrorStr (status)); + + GST_LOG ("surface %#x status %d", surface, state); + + return (status == VA_STATUS_SUCCESS); +} diff --git a/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.h b/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.h index 96b85c468a..787d8ca4f7 100644 --- a/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.h +++ b/subprojects/gst-plugins-bad/sys/va/vasurfaceimage.h @@ -44,6 +44,8 @@ gboolean va_export_surface_to_dmabuf (GstVaDisplay * displa VADRMPRIMESurfaceDescriptor * desc); gboolean va_sync_surface (GstVaDisplay * display, VASurfaceID surface); +gboolean va_check_surface (GstVaDisplay * display, + VASurfaceID surface); /* images */ gboolean va_create_image (GstVaDisplay * display,