mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
surface: add simple surface info accessors as helper macros.
Add helper macros to retrieve the VA surface information like size (width, height) or chroma type. This is a micro-optimization to avoid useless function calls and NULL pointer re-checks in internal routines.
This commit is contained in:
parent
e66e72e7e3
commit
99dfd44f33
4 changed files with 76 additions and 45 deletions
|
@ -30,41 +30,12 @@
|
|||
#include "gstvaapiutils.h"
|
||||
#include "gstvaapisurface.h"
|
||||
#include "gstvaapisurface_priv.h"
|
||||
#include "gstvaapiobject_priv.h"
|
||||
#include "gstvaapicontext.h"
|
||||
#include "gstvaapiimage.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
typedef struct _GstVaapiSurfaceClass GstVaapiSurfaceClass;
|
||||
|
||||
/**
|
||||
* GstVaapiSurface:
|
||||
*
|
||||
* A VA surface wrapper.
|
||||
*/
|
||||
struct _GstVaapiSurface {
|
||||
/*< private >*/
|
||||
GstVaapiObject parent_instance;
|
||||
|
||||
guint width;
|
||||
guint height;
|
||||
GstVaapiChromaType chroma_type;
|
||||
GPtrArray *subpictures;
|
||||
GstVaapiContext *parent_context;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstVaapiSurfaceClass:
|
||||
*
|
||||
* A VA surface wrapper class.
|
||||
*/
|
||||
struct _GstVaapiSurfaceClass {
|
||||
/*< private >*/
|
||||
GstVaapiObjectClass parent_class;
|
||||
};
|
||||
|
||||
static gboolean
|
||||
_gst_vaapi_surface_associate_subpicture(
|
||||
GstVaapiSurface *surface,
|
||||
|
@ -236,7 +207,7 @@ gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface)
|
|||
{
|
||||
g_return_val_if_fail(surface != NULL, 0);
|
||||
|
||||
return surface->chroma_type;
|
||||
return GST_VAAPI_SURFACE_CHROMA_TYPE(surface);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,7 +223,7 @@ gst_vaapi_surface_get_width(GstVaapiSurface *surface)
|
|||
{
|
||||
g_return_val_if_fail(surface != NULL, 0);
|
||||
|
||||
return surface->width;
|
||||
return GST_VAAPI_SURFACE_WIDTH(surface);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,7 +239,7 @@ gst_vaapi_surface_get_height(GstVaapiSurface *surface)
|
|||
{
|
||||
g_return_val_if_fail(surface != NULL, 0);
|
||||
|
||||
return surface->height;
|
||||
return GST_VAAPI_SURFACE_HEIGHT(surface);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -289,10 +260,10 @@ gst_vaapi_surface_get_size(
|
|||
g_return_if_fail(surface != NULL);
|
||||
|
||||
if (pwidth)
|
||||
*pwidth = gst_vaapi_surface_get_width(surface);
|
||||
*pwidth = GST_VAAPI_SURFACE_WIDTH(surface);
|
||||
|
||||
if (pheight)
|
||||
*pheight = gst_vaapi_surface_get_height(surface);
|
||||
*pheight = GST_VAAPI_SURFACE_HEIGHT(surface);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,6 +24,71 @@
|
|||
|
||||
#include <gst/vaapi/gstvaapicontext.h>
|
||||
#include <gst/vaapi/gstvaapisurface.h>
|
||||
#include "gstvaapiobject_priv.h"
|
||||
|
||||
typedef struct _GstVaapiSurfaceClass GstVaapiSurfaceClass;
|
||||
|
||||
/**
|
||||
* GstVaapiSurface:
|
||||
*
|
||||
* A VA surface wrapper.
|
||||
*/
|
||||
struct _GstVaapiSurface {
|
||||
/*< private >*/
|
||||
GstVaapiObject parent_instance;
|
||||
|
||||
guint width;
|
||||
guint height;
|
||||
GstVaapiChromaType chroma_type;
|
||||
GPtrArray *subpictures;
|
||||
GstVaapiContext *parent_context;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstVaapiSurfaceClass:
|
||||
*
|
||||
* A VA surface wrapper class.
|
||||
*/
|
||||
struct _GstVaapiSurfaceClass {
|
||||
/*< private >*/
|
||||
GstVaapiObjectClass parent_class;
|
||||
};
|
||||
|
||||
/**
|
||||
* GST_VAAPI_SURFACE_SURFACE_CHROMA_TYPE:
|
||||
* @surface: a #GstVaapiSurface
|
||||
*
|
||||
* Macro that evaluates to the @surface chroma type.
|
||||
*
|
||||
* This is an internal macro that does not do any run-time type check.
|
||||
*/
|
||||
#undef GST_VAAPI_SURFACE_CHROMA_TYPE
|
||||
#define GST_VAAPI_SURFACE_CHROMA_TYPE(surface) \
|
||||
GST_VAAPI_SURFACE(surface)->chroma_type
|
||||
|
||||
/**
|
||||
* GST_VAAPI_SURFACE_SURFACE_WIDTH:
|
||||
* @surface: a #GstVaapiSurface
|
||||
*
|
||||
* Macro that evaluates to the @surface width in pixels.
|
||||
*
|
||||
* This is an internal macro that does not do any run-time type check.
|
||||
*/
|
||||
#undef GST_VAAPI_SURFACE_WIDTH
|
||||
#define GST_VAAPI_SURFACE_WIDTH(surface) \
|
||||
GST_VAAPI_SURFACE(surface)->width
|
||||
|
||||
/**
|
||||
* GST_VAAPI_SURFACE_SURFACE_HEIGHT:
|
||||
* @surface: a #GstVaapiSurface
|
||||
*
|
||||
* Macro that evaluates to the @surface height in pixels.
|
||||
*
|
||||
* This is an internal macro that does not do any run-time type check.
|
||||
*/
|
||||
#undef GST_VAAPI_SURFACE_HEIGHT
|
||||
#define GST_VAAPI_SURFACE_HEIGHT(surface) \
|
||||
GST_VAAPI_SURFACE(surface)->height
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
|
|
|
@ -33,16 +33,13 @@
|
|||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
||||
static void
|
||||
static inline void
|
||||
set_crop_rect_from_surface(GstVaapiSurfaceProxy *proxy)
|
||||
{
|
||||
guint width, height;
|
||||
|
||||
gst_vaapi_surface_get_size(proxy->surface, &width, &height);
|
||||
proxy->crop_rect.x = 0;
|
||||
proxy->crop_rect.y = 0;
|
||||
proxy->crop_rect.width = width;
|
||||
proxy->crop_rect.height = height;
|
||||
proxy->crop_rect.width = GST_VAAPI_SURFACE_WIDTH(proxy->surface);
|
||||
proxy->crop_rect.height = GST_VAAPI_SURFACE_HEIGHT(proxy->surface);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "sysdeps.h"
|
||||
#include "gstvaapiwindow.h"
|
||||
#include "gstvaapiwindow_priv.h"
|
||||
#include "gstvaapisurface_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
@ -366,13 +367,10 @@ gst_vaapi_window_set_size(GstVaapiWindow *window, guint width, guint height)
|
|||
static inline void
|
||||
get_surface_rect(GstVaapiSurface *surface, GstVaapiRectangle *rect)
|
||||
{
|
||||
guint width, height;
|
||||
|
||||
gst_vaapi_surface_get_size(surface, &width, &height);
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->width = width;
|
||||
rect->height = height;
|
||||
rect->width = GST_VAAPI_SURFACE_WIDTH(surface);
|
||||
rect->height = GST_VAAPI_SURFACE_HEIGHT(surface);
|
||||
}
|
||||
|
||||
static inline void
|
||||
|
|
Loading…
Reference in a new issue