mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 06:26:23 +00:00
xvimagesink: get rid of unnecessary private struct for pool
This commit is contained in:
parent
fb8f53efb7
commit
39c6b41864
2 changed files with 48 additions and 63 deletions
|
@ -37,28 +37,9 @@
|
||||||
GST_DEBUG_CATEGORY_EXTERN (gst_debug_xvimagepool);
|
GST_DEBUG_CATEGORY_EXTERN (gst_debug_xvimagepool);
|
||||||
#define GST_CAT_DEFAULT gst_debug_xvimagepool
|
#define GST_CAT_DEFAULT gst_debug_xvimagepool
|
||||||
|
|
||||||
|
|
||||||
struct _GstXvImageBufferPoolPrivate
|
|
||||||
{
|
|
||||||
GstXvImageAllocator *allocator;
|
|
||||||
|
|
||||||
GstCaps *caps;
|
|
||||||
gint im_format;
|
|
||||||
GstVideoRectangle crop;
|
|
||||||
GstVideoInfo info;
|
|
||||||
GstVideoAlignment align;
|
|
||||||
guint padded_width;
|
|
||||||
guint padded_height;
|
|
||||||
gboolean add_metavideo;
|
|
||||||
gboolean need_alignment;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* bufferpool */
|
/* bufferpool */
|
||||||
static void gst_xvimage_buffer_pool_finalize (GObject * object);
|
static void gst_xvimage_buffer_pool_finalize (GObject * object);
|
||||||
|
|
||||||
#define GST_XVIMAGE_BUFFER_POOL_GET_PRIVATE(obj) \
|
|
||||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_XVIMAGE_BUFFER_POOL, GstXvImageBufferPoolPrivate))
|
|
||||||
|
|
||||||
#define gst_xvimage_buffer_pool_parent_class parent_class
|
#define gst_xvimage_buffer_pool_parent_class parent_class
|
||||||
G_DEFINE_TYPE (GstXvImageBufferPool, gst_xvimage_buffer_pool,
|
G_DEFINE_TYPE (GstXvImageBufferPool, gst_xvimage_buffer_pool,
|
||||||
GST_TYPE_BUFFER_POOL);
|
GST_TYPE_BUFFER_POOL);
|
||||||
|
@ -77,7 +58,6 @@ static gboolean
|
||||||
xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
{
|
{
|
||||||
GstXvImageBufferPool *xvpool = GST_XVIMAGE_BUFFER_POOL_CAST (pool);
|
GstXvImageBufferPool *xvpool = GST_XVIMAGE_BUFFER_POOL_CAST (pool);
|
||||||
GstXvImageBufferPoolPrivate *priv = xvpool->priv;
|
|
||||||
GstVideoInfo info;
|
GstVideoInfo info;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstXvContext *context;
|
GstXvContext *context;
|
||||||
|
@ -95,54 +75,54 @@ xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, info.width, info.height,
|
GST_LOG_OBJECT (pool, "%dx%d, caps %" GST_PTR_FORMAT, info.width, info.height,
|
||||||
caps);
|
caps);
|
||||||
|
|
||||||
context = gst_xvimage_allocator_peek_context (priv->allocator);
|
context = gst_xvimage_allocator_peek_context (xvpool->allocator);
|
||||||
|
|
||||||
priv->im_format = gst_xvcontext_get_format_from_info (context, &info);
|
xvpool->im_format = gst_xvcontext_get_format_from_info (context, &info);
|
||||||
if (priv->im_format == -1)
|
if (xvpool->im_format == -1)
|
||||||
goto unknown_format;
|
goto unknown_format;
|
||||||
|
|
||||||
if (priv->caps)
|
if (xvpool->caps)
|
||||||
gst_caps_unref (priv->caps);
|
gst_caps_unref (xvpool->caps);
|
||||||
priv->caps = gst_caps_ref (caps);
|
xvpool->caps = gst_caps_ref (caps);
|
||||||
|
|
||||||
/* enable metadata based on config of the pool */
|
/* enable metadata based on config of the pool */
|
||||||
priv->add_metavideo =
|
xvpool->add_metavideo =
|
||||||
gst_buffer_pool_config_has_option (config,
|
gst_buffer_pool_config_has_option (config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||||
|
|
||||||
/* parse extra alignment info */
|
/* parse extra alignment info */
|
||||||
priv->need_alignment = gst_buffer_pool_config_has_option (config,
|
xvpool->need_alignment = gst_buffer_pool_config_has_option (config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||||
|
|
||||||
if (priv->need_alignment) {
|
if (xvpool->need_alignment) {
|
||||||
gst_buffer_pool_config_get_video_alignment (config, &priv->align);
|
gst_buffer_pool_config_get_video_alignment (config, &xvpool->align);
|
||||||
|
|
||||||
GST_LOG_OBJECT (pool, "padding %u-%ux%u-%u", priv->align.padding_top,
|
GST_LOG_OBJECT (pool, "padding %u-%ux%u-%u", xvpool->align.padding_top,
|
||||||
priv->align.padding_left, priv->align.padding_left,
|
xvpool->align.padding_left, xvpool->align.padding_left,
|
||||||
priv->align.padding_bottom);
|
xvpool->align.padding_bottom);
|
||||||
|
|
||||||
/* do padding and alignment */
|
/* do padding and alignment */
|
||||||
gst_video_info_align (&info, &priv->align);
|
gst_video_info_align (&info, &xvpool->align);
|
||||||
|
|
||||||
/* we need the video metadata too now */
|
/* we need the video metadata too now */
|
||||||
priv->add_metavideo = TRUE;
|
xvpool->add_metavideo = TRUE;
|
||||||
} else {
|
} else {
|
||||||
gst_video_alignment_reset (&priv->align);
|
gst_video_alignment_reset (&xvpool->align);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the padding */
|
/* add the padding */
|
||||||
priv->padded_width =
|
xvpool->padded_width =
|
||||||
GST_VIDEO_INFO_WIDTH (&info) + priv->align.padding_left +
|
GST_VIDEO_INFO_WIDTH (&info) + xvpool->align.padding_left +
|
||||||
priv->align.padding_right;
|
xvpool->align.padding_right;
|
||||||
priv->padded_height =
|
xvpool->padded_height =
|
||||||
GST_VIDEO_INFO_HEIGHT (&info) + priv->align.padding_top +
|
GST_VIDEO_INFO_HEIGHT (&info) + xvpool->align.padding_top +
|
||||||
priv->align.padding_bottom;
|
xvpool->align.padding_bottom;
|
||||||
|
|
||||||
priv->info = info;
|
xvpool->info = info;
|
||||||
priv->crop.x = priv->align.padding_left;
|
xvpool->crop.x = xvpool->align.padding_left;
|
||||||
priv->crop.y = priv->align.padding_top;
|
xvpool->crop.y = xvpool->align.padding_top;
|
||||||
priv->crop.w = priv->info.width;
|
xvpool->crop.w = xvpool->info.width;
|
||||||
priv->crop.h = priv->info.height;
|
xvpool->crop.h = xvpool->info.height;
|
||||||
|
|
||||||
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config);
|
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (pool, config);
|
||||||
|
|
||||||
|
@ -177,17 +157,16 @@ xvimage_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
GstBufferPoolAcquireParams * params)
|
GstBufferPoolAcquireParams * params)
|
||||||
{
|
{
|
||||||
GstXvImageBufferPool *xvpool = GST_XVIMAGE_BUFFER_POOL_CAST (pool);
|
GstXvImageBufferPool *xvpool = GST_XVIMAGE_BUFFER_POOL_CAST (pool);
|
||||||
GstXvImageBufferPoolPrivate *priv = xvpool->priv;
|
|
||||||
GstVideoInfo *info;
|
GstVideoInfo *info;
|
||||||
GstBuffer *xvimage;
|
GstBuffer *xvimage;
|
||||||
GstMemory *mem;
|
GstMemory *mem;
|
||||||
|
|
||||||
info = &priv->info;
|
info = &xvpool->info;
|
||||||
|
|
||||||
xvimage = gst_buffer_new ();
|
xvimage = gst_buffer_new ();
|
||||||
|
|
||||||
mem = gst_xvimage_allocator_alloc (priv->allocator, priv->im_format,
|
mem = gst_xvimage_allocator_alloc (xvpool->allocator, xvpool->im_format,
|
||||||
priv->padded_width, priv->padded_height, &priv->crop, NULL);
|
xvpool->padded_width, xvpool->padded_height, &xvpool->crop, NULL);
|
||||||
|
|
||||||
if (mem == NULL) {
|
if (mem == NULL) {
|
||||||
gst_buffer_unref (xvimage);
|
gst_buffer_unref (xvimage);
|
||||||
|
@ -195,7 +174,7 @@ xvimage_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
}
|
}
|
||||||
gst_buffer_append_memory (xvimage, mem);
|
gst_buffer_append_memory (xvimage, mem);
|
||||||
|
|
||||||
if (priv->add_metavideo) {
|
if (xvpool->add_metavideo) {
|
||||||
GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
|
GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
|
||||||
gst_buffer_add_video_meta_full (xvimage, GST_VIDEO_FRAME_FLAG_NONE,
|
gst_buffer_add_video_meta_full (xvimage, GST_VIDEO_FRAME_FLAG_NONE,
|
||||||
GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
|
GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
|
||||||
|
@ -221,7 +200,7 @@ gst_xvimage_buffer_pool_new (GstXvImageAllocator * allocator)
|
||||||
GstXvImageBufferPool *pool;
|
GstXvImageBufferPool *pool;
|
||||||
|
|
||||||
pool = g_object_new (GST_TYPE_XVIMAGE_BUFFER_POOL, NULL);
|
pool = g_object_new (GST_TYPE_XVIMAGE_BUFFER_POOL, NULL);
|
||||||
pool->priv->allocator = gst_object_ref (allocator);
|
pool->allocator = gst_object_ref (allocator);
|
||||||
|
|
||||||
GST_LOG_OBJECT (pool, "new XvImage buffer pool %p", pool);
|
GST_LOG_OBJECT (pool, "new XvImage buffer pool %p", pool);
|
||||||
|
|
||||||
|
@ -234,8 +213,6 @@ gst_xvimage_buffer_pool_class_init (GstXvImageBufferPoolClass * klass)
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||||
GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
|
GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GstXvImageBufferPoolPrivate));
|
|
||||||
|
|
||||||
gobject_class->finalize = gst_xvimage_buffer_pool_finalize;
|
gobject_class->finalize = gst_xvimage_buffer_pool_finalize;
|
||||||
|
|
||||||
gstbufferpool_class->get_options = xvimage_buffer_pool_get_options;
|
gstbufferpool_class->get_options = xvimage_buffer_pool_get_options;
|
||||||
|
@ -246,21 +223,20 @@ gst_xvimage_buffer_pool_class_init (GstXvImageBufferPoolClass * klass)
|
||||||
static void
|
static void
|
||||||
gst_xvimage_buffer_pool_init (GstXvImageBufferPool * pool)
|
gst_xvimage_buffer_pool_init (GstXvImageBufferPool * pool)
|
||||||
{
|
{
|
||||||
pool->priv = GST_XVIMAGE_BUFFER_POOL_GET_PRIVATE (pool);
|
/* nothing to do here */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_xvimage_buffer_pool_finalize (GObject * object)
|
gst_xvimage_buffer_pool_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstXvImageBufferPool *pool = GST_XVIMAGE_BUFFER_POOL_CAST (object);
|
GstXvImageBufferPool *pool = GST_XVIMAGE_BUFFER_POOL_CAST (object);
|
||||||
GstXvImageBufferPoolPrivate *priv = pool->priv;
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (pool, "finalize XvImage buffer pool %p", pool);
|
GST_LOG_OBJECT (pool, "finalize XvImage buffer pool %p", pool);
|
||||||
|
|
||||||
if (priv->caps)
|
if (pool->caps)
|
||||||
gst_caps_unref (priv->caps);
|
gst_caps_unref (pool->caps);
|
||||||
if (priv->allocator)
|
if (pool->allocator)
|
||||||
gst_object_unref (priv->allocator);
|
gst_object_unref (pool->allocator);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_xvimage_buffer_pool_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gst_xvimage_buffer_pool_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstXvImageBufferPool GstXvImageBufferPool;
|
typedef struct _GstXvImageBufferPool GstXvImageBufferPool;
|
||||||
typedef struct _GstXvImageBufferPoolClass GstXvImageBufferPoolClass;
|
typedef struct _GstXvImageBufferPoolClass GstXvImageBufferPoolClass;
|
||||||
typedef struct _GstXvImageBufferPoolPrivate GstXvImageBufferPoolPrivate;
|
|
||||||
|
|
||||||
/* buffer pool functions */
|
/* buffer pool functions */
|
||||||
#define GST_TYPE_XVIMAGE_BUFFER_POOL (gst_xvimage_buffer_pool_get_type())
|
#define GST_TYPE_XVIMAGE_BUFFER_POOL (gst_xvimage_buffer_pool_get_type())
|
||||||
|
@ -40,7 +39,17 @@ struct _GstXvImageBufferPool
|
||||||
{
|
{
|
||||||
GstBufferPool bufferpool;
|
GstBufferPool bufferpool;
|
||||||
|
|
||||||
GstXvImageBufferPoolPrivate *priv;
|
GstXvImageAllocator *allocator;
|
||||||
|
|
||||||
|
GstCaps *caps;
|
||||||
|
gint im_format;
|
||||||
|
GstVideoRectangle crop;
|
||||||
|
GstVideoInfo info;
|
||||||
|
GstVideoAlignment align;
|
||||||
|
guint padded_width;
|
||||||
|
guint padded_height;
|
||||||
|
gboolean add_metavideo;
|
||||||
|
gboolean need_alignment;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstXvImageBufferPoolClass
|
struct _GstXvImageBufferPoolClass
|
||||||
|
|
Loading…
Reference in a new issue