mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 21:18:52 +00:00
libs: context, filter: use new surface attributes API
This commit is contained in:
parent
4ba7c9cae0
commit
6376e7e2bd
3 changed files with 38 additions and 31 deletions
|
@ -39,7 +39,6 @@
|
|||
#include "gstvaapisurfaceproxy.h"
|
||||
#include "gstvaapivideopool_priv.h"
|
||||
#include "gstvaapiutils.h"
|
||||
#include "gstvaapiutils_core.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
@ -51,15 +50,15 @@
|
|||
#define SCRATCH_SURFACES_COUNT (4)
|
||||
|
||||
static gboolean
|
||||
ensure_formats (GstVaapiContext * context)
|
||||
ensure_attributes (GstVaapiContext * context)
|
||||
{
|
||||
if (G_LIKELY (context->formats))
|
||||
if (G_LIKELY (context->attribs))
|
||||
return TRUE;
|
||||
|
||||
context->formats =
|
||||
gst_vaapi_get_surface_formats (GST_VAAPI_OBJECT_DISPLAY (context),
|
||||
context->va_config);
|
||||
return (context->formats != NULL);
|
||||
context->attribs =
|
||||
gst_vaapi_config_surface_attributes_get (GST_VAAPI_OBJECT_DISPLAY
|
||||
(context), context->va_config);
|
||||
return (context->attribs != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -119,9 +118,9 @@ context_destroy (GstVaapiContext * context)
|
|||
context->va_config = VA_INVALID_ID;
|
||||
}
|
||||
|
||||
if (context->formats) {
|
||||
g_array_unref (context->formats);
|
||||
context->formats = NULL;
|
||||
if (context->attribs) {
|
||||
gst_vaapi_config_surface_attributes_free (context->attribs);
|
||||
context->attribs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,13 +132,13 @@ context_ensure_surfaces (GstVaapiContext * context)
|
|||
GstVaapiSurface *surface;
|
||||
guint i;
|
||||
|
||||
if (!ensure_formats (context))
|
||||
if (!ensure_attributes (context))
|
||||
return FALSE;
|
||||
|
||||
for (i = context->surfaces->len; i < num_surfaces; i++) {
|
||||
surface =
|
||||
gst_vaapi_surface_new_from_formats (GST_VAAPI_OBJECT_DISPLAY (context),
|
||||
cip->chroma_type, cip->width, cip->height, context->formats);
|
||||
cip->chroma_type, cip->width, cip->height, context->attribs->formats);
|
||||
if (!surface)
|
||||
return FALSE;
|
||||
gst_vaapi_surface_set_parent_context (surface, context);
|
||||
|
@ -407,7 +406,7 @@ gst_vaapi_context_init (GstVaapiContext * context,
|
|||
context->reset_on_resize = TRUE;
|
||||
gst_vaapi_context_overlay_init (context);
|
||||
|
||||
context->formats = NULL;
|
||||
context->attribs = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -633,7 +632,10 @@ gst_vaapi_context_get_surface_formats (GstVaapiContext * context)
|
|||
{
|
||||
g_return_val_if_fail (context, NULL);
|
||||
|
||||
if (!ensure_formats (context))
|
||||
if (!ensure_attributes (context))
|
||||
return NULL;
|
||||
return g_array_ref (context->formats);
|
||||
|
||||
if (context->attribs->formats)
|
||||
return g_array_ref (context->attribs->formats);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "gstvaapiprofile.h"
|
||||
#include "gstvaapidisplay.h"
|
||||
#include "gstvaapisurface.h"
|
||||
#include "gstvaapiutils_core.h"
|
||||
#include "gstvaapivideopool.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -115,7 +116,7 @@ struct _GstVaapiContext
|
|||
GPtrArray *overlays[2];
|
||||
guint overlay_id;
|
||||
gboolean reset_on_resize;
|
||||
GArray *formats;
|
||||
GstVaapiConfigSurfaceAttributes *attribs;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -62,7 +62,7 @@ struct _GstVaapiFilter
|
|||
GstVideoFormat format;
|
||||
GstVaapiScaleMethod scale_method;
|
||||
GstVideoOrientationMethod video_direction;
|
||||
GArray *formats;
|
||||
GstVaapiConfigSurfaceAttributes *attribs;
|
||||
GArray *forward_references;
|
||||
GArray *backward_references;
|
||||
GstVaapiRectangle crop_rect;
|
||||
|
@ -1086,18 +1086,18 @@ deint_refs_clear_all (GstVaapiFilter * filter)
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* --- Surface Formats --- */
|
||||
/* --- Surface Attribs --- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static gboolean
|
||||
ensure_formats (GstVaapiFilter * filter)
|
||||
ensure_attributes (GstVaapiFilter * filter)
|
||||
{
|
||||
if (G_LIKELY (filter->formats))
|
||||
if (G_LIKELY (filter->attribs))
|
||||
return TRUE;
|
||||
|
||||
filter->formats = gst_vaapi_get_surface_formats (filter->display,
|
||||
filter->attribs = gst_vaapi_config_surface_attributes_get (filter->display,
|
||||
filter->va_config);
|
||||
return (filter->formats != NULL);
|
||||
return (filter->attribs != NULL);
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
|
@ -1111,12 +1111,14 @@ static gboolean
|
|||
find_format (GstVaapiFilter * filter, GstVideoFormat format)
|
||||
{
|
||||
guint i;
|
||||
GArray *formats;
|
||||
|
||||
if (is_special_format (format) || !filter->formats)
|
||||
formats = filter->attribs->formats;
|
||||
if (is_special_format (format) || !formats)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < filter->formats->len; i++) {
|
||||
if (g_array_index (filter->formats, GstVideoFormat, i) == format)
|
||||
for (i = 0; i < formats->len; i++) {
|
||||
if (g_array_index (formats, GstVideoFormat, i) == format)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
@ -1199,9 +1201,9 @@ gst_vaapi_filter_finalize (GObject * object)
|
|||
filter->backward_references = NULL;
|
||||
}
|
||||
|
||||
if (filter->formats) {
|
||||
g_array_unref (filter->formats);
|
||||
filter->formats = NULL;
|
||||
if (filter->attribs) {
|
||||
gst_vaapi_config_surface_attributes_free (filter->attribs);
|
||||
filter->attribs = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gst_vaapi_filter_parent_class)->finalize (object);
|
||||
|
@ -1657,9 +1659,11 @@ gst_vaapi_filter_get_formats (GstVaapiFilter * filter)
|
|||
{
|
||||
g_return_val_if_fail (filter != NULL, NULL);
|
||||
|
||||
if (!ensure_formats (filter))
|
||||
if (!ensure_attributes (filter))
|
||||
return NULL;
|
||||
return g_array_ref (filter->formats);
|
||||
if (filter->attribs->formats)
|
||||
return g_array_ref (filter->attribs->formats);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1685,7 +1689,7 @@ gst_vaapi_filter_set_format (GstVaapiFilter * filter, GstVideoFormat format)
|
|||
{
|
||||
g_return_val_if_fail (filter != NULL, FALSE);
|
||||
|
||||
if (!ensure_formats (filter))
|
||||
if (!ensure_attributes (filter))
|
||||
return FALSE;
|
||||
|
||||
if (!is_special_format (format) && !find_format (filter, format))
|
||||
|
|
Loading…
Reference in a new issue