diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c index 6baec64a4e..d6d8f4985a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.c @@ -26,6 +26,10 @@ #include "gstvavideoformat.h" #include +/* XXX: find a better log category */ +#define GST_CAT_DEFAULT gst_va_display_debug +GST_DEBUG_CATEGORY_EXTERN (gst_va_display_debug); + gboolean va_destroy_surfaces (GstVaDisplay * display, VASurfaceID * surfaces, gint num_surfaces) @@ -42,7 +46,6 @@ va_destroy_surfaces (GstVaDisplay * display, VASurfaceID * surfaces, } return TRUE; - } gboolean diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h index 4a68ac1c3e..18f88f757a 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/vasurfaceimage.h @@ -20,7 +20,7 @@ #pragma once -#include +#include #include #include #include @@ -42,10 +42,14 @@ gboolean va_export_surface_to_dmabuf (GstVaDisplay * displa VASurfaceID surface, guint32 flags, VADRMPRIMESurfaceDescriptor * desc); + +GST_VA_API gboolean va_sync_surface (GstVaDisplay * display, VASurfaceID surface); +GST_VA_API gboolean va_check_surface (GstVaDisplay * display, VASurfaceID surface); + gboolean va_copy_surface (GstVaDisplay * display, VASurfaceID dst, VASurfaceID src); @@ -73,9 +77,11 @@ gboolean va_ensure_image (GstVaDisplay * displa gboolean derived); /* mapping */ +GST_VA_API gboolean va_map_buffer (GstVaDisplay * display, VABufferID buffer, gpointer * data); +GST_VA_API gboolean va_unmap_buffer (GstVaDisplay * display, VABufferID buffer); diff --git a/subprojects/gst-plugins-bad/sys/va/gstvafilter.c b/subprojects/gst-plugins-bad/sys/va/gstvafilter.c index 41eb229b69..b536b6e9ac 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvafilter.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvafilter.c @@ -24,6 +24,7 @@ #include "gstvafilter.h" +#include #include #include @@ -1517,23 +1518,6 @@ gst_va_filter_drop_filter_buffers (GstVaFilter * self) return ret; } -static gboolean -_check_surface (GstVaDisplay * display, VASurfaceID surface) -{ - VADisplay dpy = gst_va_display_get_va_dpy (display); - VAStatus status; - VASurfaceStatus state; - - status = vaQuerySurfaceStatus (dpy, surface, &state); - - if (status != VA_STATUS_SUCCESS) - GST_ERROR ("vaQuerySurfaceStatus: %s", vaErrorStr (status)); - - GST_LOG ("surface %#x status %d", surface, state); - - return (status == VA_STATUS_SUCCESS); -} - static gboolean _fill_va_sample (GstVaFilter * self, GstVaSample * sample, GstPadDirection direction) @@ -1548,7 +1532,7 @@ _fill_va_sample (GstVaFilter * self, GstVaSample * sample, /* @FIXME: in gallium vaQuerySurfaceStatus only seems to work with * encoder's surfaces */ if (!GST_VA_DISPLAY_IS_IMPLEMENTATION (self->display, MESA_GALLIUM)) { - if (!_check_surface (self->display, sample->surface)) + if (!va_check_surface (self->display, sample->surface)) return FALSE; } diff --git a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c index 8c4e8647d1..c0b61c8c26 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvah264enc.c @@ -55,6 +55,7 @@ #include #include +#include #include #include @@ -3199,30 +3200,20 @@ _push_buffer_to_downstream (GstVaH264Enc * self, GstVideoCodecFrame * frame) guint coded_size; goffset offset; GstBuffer *buf; - VADisplay dpy; VASurfaceID surface; - VAStatus status; VACodedBufferSegment *seg, *seg_list; - dpy = gst_va_display_get_va_dpy (self->display); - frame_enc = _enc_frame (frame); /* Wait for encoding to finish */ surface = gst_va_encode_picture_get_raw_surface (frame_enc->picture); - status = vaSyncSurface (dpy, surface); - if (status != VA_STATUS_SUCCESS) { - GST_WARNING_OBJECT (self, "vaSyncSurface: %s", vaErrorStr (status)); + if (!va_sync_surface (self->display, surface)) goto error; - } seg_list = NULL; - status = vaMapBuffer (dpy, frame_enc->picture->coded_buffer, - (gpointer *) & seg_list); - if (status != VA_STATUS_SUCCESS) { - GST_WARNING_OBJECT (self, "vaMapBuffer: %s", vaErrorStr (status)); + if (!va_map_buffer (self->display, frame_enc->picture->coded_buffer, + (gpointer *) & seg_list)) goto error; - } if (!seg_list) { GST_WARNING_OBJECT (self, "coded buffer has no segment list"); @@ -3254,9 +3245,7 @@ _push_buffer_to_downstream (GstVaH264Enc * self, GstVideoCodecFrame * frame) offset += seg->size; } - status = vaUnmapBuffer (dpy, frame_enc->picture->coded_buffer); - if (status != VA_STATUS_SUCCESS) - GST_WARNING ("vaUnmapBuffer: %s", vaErrorStr (status)); + va_unmap_buffer (self->display, frame_enc->picture->coded_buffer); frame->pts = self->start_pts + self->frame_duration * frame_enc->total_frame_count;