From dbb58f4152ca64da16eb5d23b4cbdac4828b06c3 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Fri, 15 Feb 2013 18:24:24 +0200 Subject: [PATCH] plugins: add helper functions to set the render rectangle. Some video clips may have a clipping region that needs to propogate to the renderer. These helper functions make it possible to attach that clipping region, as a GstVaapiRectangle, the the video meta associated with the buffer. Signed-off-by: Sreerenj Balachandran signed-off-by: Gwenole Beauchesne --- gst/vaapi/gstvaapivideometa.c | 43 +++++++++++++++++++++++++++++++++++ gst/vaapi/gstvaapivideometa.h | 9 ++++++++ 2 files changed, 52 insertions(+) diff --git a/gst/vaapi/gstvaapivideometa.c b/gst/vaapi/gstvaapivideometa.c index 77b8af4c41..e05466419a 100644 --- a/gst/vaapi/gstvaapivideometa.c +++ b/gst/vaapi/gstvaapivideometa.c @@ -46,6 +46,8 @@ struct _GstVaapiVideoMeta { GstVaapiSurfaceProxy *proxy; GFunc converter; guint render_flags; + GstVaapiRectangle render_rect; + guint has_render_rect : 1; }; static inline void @@ -158,6 +160,7 @@ gst_vaapi_video_meta_init(GstVaapiVideoMeta *meta) meta->proxy = NULL; meta->converter = NULL; meta->render_flags = 0; + meta->has_render_rect = FALSE; } static inline GstVaapiVideoMeta * @@ -229,6 +232,10 @@ gst_vaapi_video_meta_copy(GstVaapiVideoMeta *meta) gst_vaapi_surface_proxy_ref(meta->proxy) : NULL; copy->converter = meta->converter; copy->render_flags = meta->render_flags; + + copy->has_render_rect = meta->has_render_rect; + if (copy->has_render_rect) + copy->render_rect = meta->render_rect; return copy; } @@ -708,6 +715,42 @@ gst_vaapi_video_meta_set_render_flags(GstVaapiVideoMeta *meta, guint flags) meta->render_flags = flags; } +/** + * gst_vaapi_video_meta_get_render_rect: + * @meta: a #GstVaapiVideoMeta + * + * Retrieves the render rectangle bound to the @meta + * + * Return value: render rectangle associated with the video meta. + */ +const GstVaapiRectangle * +gst_vaapi_video_meta_get_render_rect(GstVaapiVideoMeta *meta) +{ + g_return_val_if_fail(GST_VAAPI_IS_VIDEO_META(meta), NULL); + + if (!meta->has_render_rect) + return NULL; + return &meta->render_rect; +} + +/** + * gst_vaapi_video_meta_set_render_rect: + * @meta: a #GstVaapiVideoMeta + * @rect: a #GstVaapiRectangle + * + * Sets the render rectangle @rect to the @meta. + */ +void +gst_vaapi_video_meta_set_render_rect(GstVaapiVideoMeta *meta, + const GstVaapiRectangle *rect) +{ + g_return_if_fail(GST_VAAPI_IS_VIDEO_META(meta)); + + meta->has_render_rect = rect != NULL; + if (meta->has_render_rect) + meta->render_rect = *rect; +} + #if GST_CHECK_VERSION(1,0,0) #define GST_VAAPI_VIDEO_META_HOLDER(meta) \ diff --git a/gst/vaapi/gstvaapivideometa.h b/gst/vaapi/gstvaapivideometa.h index 93b40ed68a..cb1dc2b61b 100644 --- a/gst/vaapi/gstvaapivideometa.h +++ b/gst/vaapi/gstvaapivideometa.h @@ -135,6 +135,15 @@ G_GNUC_INTERNAL void gst_vaapi_video_meta_set_render_flags(GstVaapiVideoMeta *meta, guint flags); +G_GNUC_INTERNAL +const GstVaapiRectangle * +gst_vaapi_video_meta_get_render_rect(GstVaapiVideoMeta *meta); + +G_GNUC_INTERNAL +void +gst_vaapi_video_meta_set_render_rect(GstVaapiVideoMeta *meta, + const GstVaapiRectangle *rect); + G_GNUC_INTERNAL GstVaapiVideoMeta * gst_buffer_get_vaapi_video_meta(GstBuffer *buffer);