mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +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);
|
||||
#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 */
|
||||
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
|
||||
G_DEFINE_TYPE (GstXvImageBufferPool, gst_xvimage_buffer_pool,
|
||||
GST_TYPE_BUFFER_POOL);
|
||||
|
@ -77,7 +58,6 @@ static gboolean
|
|||
xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||
{
|
||||
GstXvImageBufferPool *xvpool = GST_XVIMAGE_BUFFER_POOL_CAST (pool);
|
||||
GstXvImageBufferPoolPrivate *priv = xvpool->priv;
|
||||
GstVideoInfo info;
|
||||
GstCaps *caps;
|
||||
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,
|
||||
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);
|
||||
if (priv->im_format == -1)
|
||||
xvpool->im_format = gst_xvcontext_get_format_from_info (context, &info);
|
||||
if (xvpool->im_format == -1)
|
||||
goto unknown_format;
|
||||
|
||||
if (priv->caps)
|
||||
gst_caps_unref (priv->caps);
|
||||
priv->caps = gst_caps_ref (caps);
|
||||
if (xvpool->caps)
|
||||
gst_caps_unref (xvpool->caps);
|
||||
xvpool->caps = gst_caps_ref (caps);
|
||||
|
||||
/* enable metadata based on config of the pool */
|
||||
priv->add_metavideo =
|
||||
xvpool->add_metavideo =
|
||||
gst_buffer_pool_config_has_option (config,
|
||||
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||
|
||||
/* 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);
|
||||
|
||||
if (priv->need_alignment) {
|
||||
gst_buffer_pool_config_get_video_alignment (config, &priv->align);
|
||||
if (xvpool->need_alignment) {
|
||||
gst_buffer_pool_config_get_video_alignment (config, &xvpool->align);
|
||||
|
||||
GST_LOG_OBJECT (pool, "padding %u-%ux%u-%u", priv->align.padding_top,
|
||||
priv->align.padding_left, priv->align.padding_left,
|
||||
priv->align.padding_bottom);
|
||||
GST_LOG_OBJECT (pool, "padding %u-%ux%u-%u", xvpool->align.padding_top,
|
||||
xvpool->align.padding_left, xvpool->align.padding_left,
|
||||
xvpool->align.padding_bottom);
|
||||
|
||||
/* 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 */
|
||||
priv->add_metavideo = TRUE;
|
||||
xvpool->add_metavideo = TRUE;
|
||||
} else {
|
||||
gst_video_alignment_reset (&priv->align);
|
||||
gst_video_alignment_reset (&xvpool->align);
|
||||
}
|
||||
|
||||
/* add the padding */
|
||||
priv->padded_width =
|
||||
GST_VIDEO_INFO_WIDTH (&info) + priv->align.padding_left +
|
||||
priv->align.padding_right;
|
||||
priv->padded_height =
|
||||
GST_VIDEO_INFO_HEIGHT (&info) + priv->align.padding_top +
|
||||
priv->align.padding_bottom;
|
||||
xvpool->padded_width =
|
||||
GST_VIDEO_INFO_WIDTH (&info) + xvpool->align.padding_left +
|
||||
xvpool->align.padding_right;
|
||||
xvpool->padded_height =
|
||||
GST_VIDEO_INFO_HEIGHT (&info) + xvpool->align.padding_top +
|
||||
xvpool->align.padding_bottom;
|
||||
|
||||
priv->info = info;
|
||||
priv->crop.x = priv->align.padding_left;
|
||||
priv->crop.y = priv->align.padding_top;
|
||||
priv->crop.w = priv->info.width;
|
||||
priv->crop.h = priv->info.height;
|
||||
xvpool->info = info;
|
||||
xvpool->crop.x = xvpool->align.padding_left;
|
||||
xvpool->crop.y = xvpool->align.padding_top;
|
||||
xvpool->crop.w = xvpool->info.width;
|
||||
xvpool->crop.h = xvpool->info.height;
|
||||
|
||||
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)
|
||||
{
|
||||
GstXvImageBufferPool *xvpool = GST_XVIMAGE_BUFFER_POOL_CAST (pool);
|
||||
GstXvImageBufferPoolPrivate *priv = xvpool->priv;
|
||||
GstVideoInfo *info;
|
||||
GstBuffer *xvimage;
|
||||
GstMemory *mem;
|
||||
|
||||
info = &priv->info;
|
||||
info = &xvpool->info;
|
||||
|
||||
xvimage = gst_buffer_new ();
|
||||
|
||||
mem = gst_xvimage_allocator_alloc (priv->allocator, priv->im_format,
|
||||
priv->padded_width, priv->padded_height, &priv->crop, NULL);
|
||||
mem = gst_xvimage_allocator_alloc (xvpool->allocator, xvpool->im_format,
|
||||
xvpool->padded_width, xvpool->padded_height, &xvpool->crop, NULL);
|
||||
|
||||
if (mem == NULL) {
|
||||
gst_buffer_unref (xvimage);
|
||||
|
@ -195,7 +174,7 @@ xvimage_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
|||
}
|
||||
gst_buffer_append_memory (xvimage, mem);
|
||||
|
||||
if (priv->add_metavideo) {
|
||||
if (xvpool->add_metavideo) {
|
||||
GST_DEBUG_OBJECT (pool, "adding GstVideoMeta");
|
||||
gst_buffer_add_video_meta_full (xvimage, GST_VIDEO_FRAME_FLAG_NONE,
|
||||
GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
|
||||
|
@ -221,7 +200,7 @@ gst_xvimage_buffer_pool_new (GstXvImageAllocator * allocator)
|
|||
GstXvImageBufferPool *pool;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -234,8 +213,6 @@ gst_xvimage_buffer_pool_class_init (GstXvImageBufferPoolClass * klass)
|
|||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||
GstBufferPoolClass *gstbufferpool_class = (GstBufferPoolClass *) klass;
|
||||
|
||||
g_type_class_add_private (klass, sizeof (GstXvImageBufferPoolPrivate));
|
||||
|
||||
gobject_class->finalize = gst_xvimage_buffer_pool_finalize;
|
||||
|
||||
gstbufferpool_class->get_options = xvimage_buffer_pool_get_options;
|
||||
|
@ -246,21 +223,20 @@ gst_xvimage_buffer_pool_class_init (GstXvImageBufferPoolClass * klass)
|
|||
static void
|
||||
gst_xvimage_buffer_pool_init (GstXvImageBufferPool * pool)
|
||||
{
|
||||
pool->priv = GST_XVIMAGE_BUFFER_POOL_GET_PRIVATE (pool);
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
static void
|
||||
gst_xvimage_buffer_pool_finalize (GObject * object)
|
||||
{
|
||||
GstXvImageBufferPool *pool = GST_XVIMAGE_BUFFER_POOL_CAST (object);
|
||||
GstXvImageBufferPoolPrivate *priv = pool->priv;
|
||||
|
||||
GST_LOG_OBJECT (pool, "finalize XvImage buffer pool %p", pool);
|
||||
|
||||
if (priv->caps)
|
||||
gst_caps_unref (priv->caps);
|
||||
if (priv->allocator)
|
||||
gst_object_unref (priv->allocator);
|
||||
if (pool->caps)
|
||||
gst_caps_unref (pool->caps);
|
||||
if (pool->allocator)
|
||||
gst_object_unref (pool->allocator);
|
||||
|
||||
G_OBJECT_CLASS (gst_xvimage_buffer_pool_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ G_BEGIN_DECLS
|
|||
|
||||
typedef struct _GstXvImageBufferPool GstXvImageBufferPool;
|
||||
typedef struct _GstXvImageBufferPoolClass GstXvImageBufferPoolClass;
|
||||
typedef struct _GstXvImageBufferPoolPrivate GstXvImageBufferPoolPrivate;
|
||||
|
||||
/* buffer pool functions */
|
||||
#define GST_TYPE_XVIMAGE_BUFFER_POOL (gst_xvimage_buffer_pool_get_type())
|
||||
|
@ -40,7 +39,17 @@ struct _GstXvImageBufferPool
|
|||
{
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue