va: Expose a couple va surface/buffer methods.

And use them in va plugin.

Also, set as default logging category the vadisplay one.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2077>
This commit is contained in:
Víctor Manuel Jáquez Leal 2022-03-30 18:09:36 +02:00 committed by GStreamer Marge Bot
parent 02115a5efc
commit e207ff905b
4 changed files with 18 additions and 36 deletions

View file

@ -26,6 +26,10 @@
#include "gstvavideoformat.h"
#include <va/va.h>
/* 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

View file

@ -20,7 +20,7 @@
#pragma once
#include <gst/va/va_fwd.h>
#include <gst/va/gstva.h>
#include <gst/video/video.h>
#include <va/va.h>
#include <va/va_drmcommon.h>
@ -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);

View file

@ -24,6 +24,7 @@
#include "gstvafilter.h"
#include <gst/va/vasurfaceimage.h>
#include <gst/video/video.h>
#include <va/va_drmcommon.h>
@ -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;
}

View file

@ -55,6 +55,7 @@
#include <gst/codecparsers/gsth264bitwriter.h>
#include <gst/va/gstva.h>
#include <gst/va/vasurfaceimage.h>
#include <gst/video/video.h>
#include <va/va_drmcommon.h>
@ -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;