libs: remove surface's parent context

In commit 18031dc6 surface's parent context is not assigned because of
circular references. Since then (2013), there's has no issue with
subpictures attached to a context, the current only users of this API.

This patch cleans up all of related code with the unused surface's
parent context.
This commit is contained in:
Víctor Manuel Jáquez Leal 2019-08-20 16:50:46 +02:00
parent e8b52f59f5
commit dae057588b
6 changed files with 5 additions and 69 deletions

View file

@ -34,7 +34,6 @@
#include "gstvaapidisplay_priv.h"
#include "gstvaapiobject_priv.h"
#include "gstvaapisurface.h"
#include "gstvaapisurface_priv.h"
#include "gstvaapisurfacepool.h"
#include "gstvaapisurfaceproxy.h"
#include "gstvaapivideopool_priv.h"
@ -61,13 +60,6 @@ ensure_attributes (GstVaapiContext * context)
return (context->attribs != NULL);
}
static void
unref_surface_cb (GstVaapiSurface * surface)
{
gst_vaapi_surface_set_parent_context (surface, NULL);
gst_vaapi_object_unref (surface);
}
static inline gboolean
context_get_attribute (GstVaapiContext * context, VAConfigAttribType type,
guint * out_value_ptr)
@ -141,7 +133,6 @@ context_ensure_surfaces (GstVaapiContext * context)
cip->chroma_type, cip->width, cip->height, context->attribs->formats);
if (!surface)
return FALSE;
gst_vaapi_surface_set_parent_context (surface, context);
g_ptr_array_add (context->surfaces, surface);
if (!gst_vaapi_video_pool_add_object (context->surfaces_pool, surface))
return FALSE;
@ -163,7 +154,7 @@ context_create_surfaces (GstVaapiContext * context)
num_surfaces = cip->ref_frames + SCRATCH_SURFACES_COUNT;
if (!context->surfaces) {
context->surfaces = g_ptr_array_new_full (num_surfaces,
(GDestroyNotify) unref_surface_cb);
(GDestroyNotify) gst_vaapi_object_unref);
if (!context->surfaces)
return FALSE;
}

View file

@ -35,7 +35,6 @@
#include "gstvaapicontext.h"
#include "gstvaapiimage.h"
#include "gstvaapiimage_priv.h"
#include "gstvaapicontext_overlay.h"
#include "gstvaapibufferproxy_priv.h"
#define DEBUG 1
@ -78,7 +77,6 @@ gst_vaapi_surface_destroy (GstVaapiSurface * surface)
GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
gst_vaapi_surface_destroy_subpictures (surface);
gst_vaapi_surface_set_parent_context (surface, NULL);
if (surface_id != VA_INVALID_SURFACE) {
GST_VAAPI_DISPLAY_LOCK (display);
@ -619,42 +617,6 @@ gst_vaapi_surface_get_size (GstVaapiSurface * surface,
*height_ptr = GST_VAAPI_SURFACE_HEIGHT (surface);
}
/**
* gst_vaapi_surface_set_parent_context:
* @surface: a #GstVaapiSurface
* @context: a #GstVaapiContext
*
* Sets new parent context, or clears any parent context if @context
* is %NULL. This function owns an extra reference to the context,
* which will be released when the surface is destroyed.
*/
void
gst_vaapi_surface_set_parent_context (GstVaapiSurface * surface,
GstVaapiContext * context)
{
g_return_if_fail (surface != NULL);
surface->parent_context = NULL;
}
/**
* gst_vaapi_surface_get_parent_context:
* @surface: a #GstVaapiSurface
*
* Retrieves the parent #GstVaapiContext, or %NULL if there is
* none. The surface shall still own a reference to the context.
* i.e. the caller shall not unreference the returned context object.
*
* Return value: the parent context, if any.
*/
GstVaapiContext *
gst_vaapi_surface_get_parent_context (GstVaapiSurface * surface)
{
g_return_val_if_fail (surface != NULL, NULL);
return surface->parent_context;
}
/**
* gst_vaapi_surface_derive_image:
* @surface: a #GstVaapiSurface
@ -1026,8 +988,6 @@ gst_vaapi_surface_query_status (GstVaapiSurface * surface,
* gst_vaapi_surface_set_subpictures_from_composition:
* @surface: a #GstVaapiSurface
* @compostion: a #GstVideoOverlayCompositon
* @propagate_context: a flag specifying whether to apply composition
* to the parent context, if any
*
* Helper to update the subpictures from #GstVideoOverlayCompositon. Sending
* a NULL composition will clear all the current subpictures. Note that this
@ -1037,17 +997,13 @@ gst_vaapi_surface_query_status (GstVaapiSurface * surface,
*/
gboolean
gst_vaapi_surface_set_subpictures_from_composition (GstVaapiSurface * surface,
GstVideoOverlayComposition * composition, gboolean propagate_context)
GstVideoOverlayComposition * composition)
{
GstVaapiDisplay *display;
guint n, nb_rectangles;
g_return_val_if_fail (surface != NULL, FALSE);
if (propagate_context && surface->parent_context)
return gst_vaapi_context_apply_composition (surface->parent_context,
composition);
display = GST_VAAPI_OBJECT_DISPLAY (surface);
if (!display)
return FALSE;

View file

@ -247,7 +247,7 @@ gst_vaapi_surface_query_status (GstVaapiSurface * surface,
gboolean
gst_vaapi_surface_set_subpictures_from_composition (GstVaapiSurface * surface,
GstVideoOverlayComposition * composition, gboolean propagate_context);
GstVideoOverlayComposition * composition);
void
gst_vaapi_surface_set_buffer_proxy (GstVaapiSurface * surface,

View file

@ -47,7 +47,6 @@ struct _GstVaapiSurface
guint height;
GstVaapiChromaType chroma_type;
GPtrArray *subpictures;
GstVaapiContext *parent_context;
};
/**
@ -109,15 +108,6 @@ struct _GstVaapiSurfaceClass
#define GST_VAAPI_SURFACE_HEIGHT(surface) \
(GST_VAAPI_SURFACE (surface)->height)
G_GNUC_INTERNAL
void
gst_vaapi_surface_set_parent_context (GstVaapiSurface * surface,
GstVaapiContext * context);
G_GNUC_INTERNAL
GstVaapiContext *
gst_vaapi_surface_get_parent_context (GstVaapiSurface * surface);
G_END_DECLS
#endif /* GST_VAAPI_SURFACE_PRIV_H */

View file

@ -482,7 +482,7 @@ gst_vaapi_apply_composition (GstVaapiSurface * surface, GstBuffer * buffer)
if (cmeta)
composition = cmeta->overlay;
return gst_vaapi_surface_set_subpictures_from_composition (surface,
composition, TRUE);
composition);
}
gboolean

View file

@ -149,8 +149,7 @@ main (int argc, char *argv[])
g_error ("could not create video overlay composition");
gst_video_overlay_rectangle_unref (overlay);
if (!gst_vaapi_surface_set_subpictures_from_composition (surface, compo,
FALSE))
if (!gst_vaapi_surface_set_subpictures_from_composition (surface, compo))
g_error ("could not create subpictures from video overlay compoition");
gst_vaapi_window_show (window);