From d634b3e6d9ad947d12e5264a279b4147b343d9f2 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 1 Aug 2011 16:48:46 +0200 Subject: [PATCH] videopool: add implementation Rename very long structure name to GstVideoAlignment Add the implementation of the video alignment config setter and getters. --- gst-libs/gst/video/Makefile.am | 4 +-- gst-libs/gst/video/gstvideopool.c | 74 +++++++++++++++++++++++++++++++++++++++ gst-libs/gst/video/gstvideopool.h | 28 +++++++-------- 3 files changed, 89 insertions(+), 17 deletions(-) create mode 100644 gst-libs/gst/video/gstvideopool.c diff --git a/gst-libs/gst/video/Makefile.am b/gst-libs/gst/video/Makefile.am index 12bfaa5..15b0c60 100644 --- a/gst-libs/gst/video/Makefile.am +++ b/gst-libs/gst/video/Makefile.am @@ -13,12 +13,12 @@ lib_LTLIBRARIES = libgstvideo-@GST_MAJORMINOR@.la CLEANFILES = $(BUILT_SOURCES) libgstvideo_@GST_MAJORMINOR@_la_SOURCES = \ - video.c gstvideosink.c gstvideofilter.c convertframe.c gstmetavideo.c + video.c gstvideosink.c gstvideofilter.c convertframe.c gstmetavideo.c gstvideopool.c nodist_libgstvideo_@GST_MAJORMINOR@_la_SOURCES = $(BUILT_SOURCES) libgstvideo_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/video libgstvideo_@GST_MAJORMINOR@include_HEADERS = \ - video.h gstvideosink.h gstvideofilter.h gstmetavideo.h + video.h gstvideosink.h gstvideofilter.h gstmetavideo.h gstvideopool.h nodist_libgstvideo_@GST_MAJORMINOR@include_HEADERS = $(built_headers) libgstvideo_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) diff --git a/gst-libs/gst/video/gstvideopool.c b/gst-libs/gst/video/gstvideopool.c new file mode 100644 index 0000000..435a327 --- /dev/null +++ b/gst-libs/gst/video/gstvideopool.c @@ -0,0 +1,74 @@ +/* GStreamer + * Copyright (C) <2011> Wim Taymans + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "gst/video/gstvideopool.h" + +/** + * gst_buffer_pool_config_set_video_alignment: + * @config: a #GstStructure + * @align: a #GstVideoAlignment + * + * Set the video alignment in @align to the bufferpool configuration + * @config + */ +void +gst_buffer_pool_config_set_video_alignment (GstStructure * config, + GstVideoAlignment * align) +{ + g_return_if_fail (config != NULL); + g_return_if_fail (align != NULL); + + gst_structure_set (config, + "padding-top", G_TYPE_UINT, align->padding_top, + "padding-bottom", G_TYPE_UINT, align->padding_bottom, + "padding-left", G_TYPE_UINT, align->padding_left, + "padding-right", G_TYPE_UINT, align->padding_right, + "stride-align0", G_TYPE_UINT, align->stride_align[0], + "stride-align1", G_TYPE_UINT, align->stride_align[1], + "stride-align2", G_TYPE_UINT, align->stride_align[2], + "stride-align3", G_TYPE_UINT, align->stride_align[3], NULL); +} + +/** + * gst_buffer_pool_config_get_video_alignment: + * @config: a #GstStructure + * @align: a #GstVideoAlignment + * + * Get the video alignment from the bufferpool configuration @config in + * in @align + * + * Returns: #TRUE if @config could be parsed correctly. + */ +gboolean +gst_buffer_pool_config_get_video_alignment (GstStructure * config, + GstVideoAlignment * align) +{ + g_return_val_if_fail (config != NULL, FALSE); + g_return_val_if_fail (align != NULL, FALSE); + + return gst_structure_get (config, + "padding-top", G_TYPE_UINT, &align->padding_top, + "padding-bottom", G_TYPE_UINT, &align->padding_bottom, + "padding-left", G_TYPE_UINT, &align->padding_left, + "padding-right", G_TYPE_UINT, &align->padding_right, + "stride-align0", G_TYPE_UINT, &align->stride_align[0], + "stride-align1", G_TYPE_UINT, &align->stride_align[1], + "stride-align2", G_TYPE_UINT, &align->stride_align[2], + "stride-align3", G_TYPE_UINT, &align->stride_align[3], NULL); +} diff --git a/gst-libs/gst/video/gstvideopool.h b/gst-libs/gst/video/gstvideopool.h index 059eba9..179c724 100644 --- a/gst-libs/gst/video/gstvideopool.h +++ b/gst-libs/gst/video/gstvideopool.h @@ -38,37 +38,35 @@ G_BEGIN_DECLS * GST_BUFFER_POOL_OPTION_VIDEO_LAYOUT: * * A bufferpool option to enable extra padding. When a bufferpool supports this - * option, gst_buffer_pool_set_video_layout() can be called. + * option, gst_buffer_pool_set_video_alignment() can be called. */ -#define GST_BUFFER_POOL_OPTION_VIDEO_LAYOUT "GstBufferPoolOptionVideoLayout" +#define GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT "GstBufferPoolOptionVideoAlignment" -typedef struct _GstBufferPoolOptionVideoLayout GstBufferPoolOptionVideoLayout; +typedef struct _GstVideoAlignment GstVideoAlignment; /** - * GstBufferPoolOptionVideoLayout: + * GstVideoAlignment: * @padding_left: extra pixels on the left side * @padding_right: extra pixels on the right side * @padding_top: extra pixels on the top * @padding_bottom: extra pixels on the bottom * @stride_align: array with extra alignment requirements for the strides * - * Extra parameters to configure the memory layout for video buffers. This - * structure is used to configure the bufferpool if it supports the - * #GST_BUFFER_POOL_OPTION_VIDEO_LAYOUT. + * Extra alignment paramters for the memory of video buffers. This + * structure is usually used to configure the bufferpool if it supports the + * #GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT. */ -struct _GstBufferPoolOptionVideoLayout +struct _GstVideoAlignment { - guint padding_left; - guint padding_right; guint padding_top; guint padding_bottom; - gint stride_align[GST_VIDEO_MAX_PLANES]; + guint padding_left; + guint padding_right; + guint stride_align[GST_VIDEO_MAX_PLANES]; }; -void gst_buffer_pool_config_set_video_layout (GstStructure *config, - GstBufferPoolOptionVideoLayout *layout); -gboolean gst_buffer_pool_config_get_video_layout (GstStructure *config, - GstBufferPoolOptionVideoLayout *layout); +void gst_buffer_pool_config_set_video_alignment (GstStructure *config, GstVideoAlignment *align); +gboolean gst_buffer_pool_config_get_video_alignment (GstStructure *config, GstVideoAlignment *align); G_END_DECLS -- 2.7.4