mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-24 01:24:20 +00:00
surfaceproxy: allow for NULL cropping rectangle.
Make it possible associate an empty cropping rectangle to the surface proxy, thus resetting any cropping rectangle that was previously set. This allows for returning plain NULL when no cropping rectangle was initially set up to the surface proxy, or if it was reset to defaults.
This commit is contained in:
parent
ad7202bb77
commit
eb00f6d101
2 changed files with 12 additions and 23 deletions
gst-libs/gst/vaapi
|
@ -33,24 +33,6 @@
|
|||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
static inline void
|
||||
set_crop_rect_from_surface(GstVaapiSurfaceProxy *proxy)
|
||||
{
|
||||
proxy->crop_rect.x = 0;
|
||||
proxy->crop_rect.y = 0;
|
||||
proxy->crop_rect.width = GST_VAAPI_SURFACE_WIDTH(proxy->surface);
|
||||
proxy->crop_rect.height = GST_VAAPI_SURFACE_HEIGHT(proxy->surface);
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_crop_rect(GstVaapiSurfaceProxy *proxy, const GstVaapiRectangle *crop_rect)
|
||||
{
|
||||
if (crop_rect)
|
||||
proxy->crop_rect = *crop_rect;
|
||||
else
|
||||
set_crop_rect_from_surface(proxy);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_surface_proxy_finalize(GstVaapiSurfaceProxy *proxy)
|
||||
{
|
||||
|
@ -92,11 +74,10 @@ gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool *pool)
|
|||
proxy->surface = gst_vaapi_video_pool_get_object(proxy->pool);
|
||||
if (!proxy->surface)
|
||||
goto error;
|
||||
set_crop_rect_from_surface(proxy);
|
||||
|
||||
proxy->timestamp = GST_CLOCK_TIME_NONE;
|
||||
proxy->duration = GST_CLOCK_TIME_NONE;
|
||||
proxy->destroy_func = NULL;
|
||||
proxy->has_crop_rect = FALSE;
|
||||
gst_vaapi_object_ref(proxy->surface);
|
||||
return proxy;
|
||||
|
||||
|
@ -267,7 +248,11 @@ gst_vaapi_surface_proxy_set_destroy_notify(GstVaapiSurfaceProxy *proxy,
|
|||
* represents the cropping rectangle for the underlying surface to be
|
||||
* used for rendering.
|
||||
*
|
||||
* Return value: the #GstVaapiRectangle
|
||||
* If no cropping rectangle was associated with the @proxy, then this
|
||||
* function returns %NULL.
|
||||
*
|
||||
* Return value: the #GstVaapiRectangle, or %NULL if none was
|
||||
* associated with the surface proxy
|
||||
*/
|
||||
const GstVaapiRectangle *
|
||||
gst_vaapi_surface_proxy_get_crop_rect(GstVaapiSurfaceProxy *proxy)
|
||||
|
@ -290,5 +275,7 @@ gst_vaapi_surface_proxy_set_crop_rect(GstVaapiSurfaceProxy *proxy,
|
|||
{
|
||||
g_return_if_fail(proxy != NULL);
|
||||
|
||||
set_crop_rect(proxy, crop_rect);
|
||||
proxy->has_crop_rect = crop_rect != NULL;
|
||||
if (proxy->has_crop_rect)
|
||||
proxy->crop_rect = *crop_rect;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ struct _GstVaapiSurfaceProxy {
|
|||
GDestroyNotify destroy_func;
|
||||
gpointer destroy_data;
|
||||
GstVaapiRectangle crop_rect;
|
||||
guint has_crop_rect : 1;
|
||||
};
|
||||
|
||||
#define GST_VAAPI_SURFACE_PROXY_FLAGS GST_VAAPI_MINI_OBJECT_FLAGS
|
||||
|
@ -109,6 +110,7 @@ struct _GstVaapiSurfaceProxy {
|
|||
*/
|
||||
#undef GST_VAAPI_SURFACE_PROXY_CROP_RECT
|
||||
#define GST_VAAPI_SURFACE_PROXY_CROP_RECT(proxy) \
|
||||
&GST_VAAPI_SURFACE_PROXY(proxy)->crop_rect
|
||||
(GST_VAAPI_SURFACE_PROXY(proxy)->has_crop_rect ? \
|
||||
&GST_VAAPI_SURFACE_PROXY(proxy)->crop_rect : NULL)
|
||||
|
||||
#endif /* GST_VAAPI_SURFACE_PROXY_PRIV_H */
|
||||
|
|
Loading…
Reference in a new issue