videopool: add implementation

Rename very long structure name to GstVideoAlignment
Add the implementation of the video alignment config setter and getters.
This commit is contained in:
Wim Taymans 2011-08-01 16:48:46 +02:00
parent 5a85e1d75f
commit d634b3e6d9
3 changed files with 89 additions and 17 deletions

View file

@ -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)

View file

@ -0,0 +1,74 @@
/* GStreamer
* Copyright (C) <2011> Wim Taymans <wim.taymans@gmail.com>
*
* 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);
}

View file

@ -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