vdpau: add GstVdpOutputBufferPool
GstVdpVideoOutputPool is a subclass of GstVdpBufferPool that caches GstVdpOutputBuffers
This commit is contained in:
parent
d82c4acd8a
commit
2d9132c590
@ -8,6 +8,7 @@ libgstvdp_@GST_MAJORMINOR@_la_SOURCES = \
|
|||||||
gstvdpvideobuffer.c \
|
gstvdpvideobuffer.c \
|
||||||
gstvdpvideobufferpool.c \
|
gstvdpvideobufferpool.c \
|
||||||
gstvdpoutputbuffer.c \
|
gstvdpoutputbuffer.c \
|
||||||
|
gstvdpoutputbufferpool.c \
|
||||||
gstvdpvideosrcpad.c \
|
gstvdpvideosrcpad.c \
|
||||||
gstvdpoutputsrcpad.c \
|
gstvdpoutputsrcpad.c \
|
||||||
gstvdpdecoder.c \
|
gstvdpdecoder.c \
|
||||||
@ -22,6 +23,7 @@ libgstvdp_@GST_MAJORMINOR@include_HEADERS = \
|
|||||||
gstvdpvideobuffer.h \
|
gstvdpvideobuffer.h \
|
||||||
gstvdpvideobufferpool.h \
|
gstvdpvideobufferpool.h \
|
||||||
gstvdpoutputbuffer.h \
|
gstvdpoutputbuffer.h \
|
||||||
|
gstvdpoutputbufferpool.h \
|
||||||
gstvdpvideosrcpad.h \
|
gstvdpvideosrcpad.h \
|
||||||
gstvdpoutputsrcpad.h \
|
gstvdpoutputsrcpad.h \
|
||||||
gstvdpdecoder.h \
|
gstvdpdecoder.h \
|
||||||
|
@ -32,7 +32,7 @@ GST_DEBUG_CATEGORY_INIT (gst_vdp_output_buffer_debug, "vdpoutputbuffer", 0, "VDP
|
|||||||
|
|
||||||
GstVdpOutputBuffer *
|
GstVdpOutputBuffer *
|
||||||
gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format,
|
gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format,
|
||||||
gint width, gint height)
|
gint width, gint height, GError ** error)
|
||||||
{
|
{
|
||||||
GstVdpOutputBuffer *buffer;
|
GstVdpOutputBuffer *buffer;
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
@ -41,12 +41,8 @@ gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format,
|
|||||||
status =
|
status =
|
||||||
device->vdp_output_surface_create (device->device, rgba_format, width,
|
device->vdp_output_surface_create (device->device, rgba_format, width,
|
||||||
height, &surface);
|
height, &surface);
|
||||||
if (status != VDP_STATUS_OK) {
|
if (status != VDP_STATUS_OK)
|
||||||
GST_ERROR ("Couldn't create a VdpOutputSurface, error returned was: %s",
|
goto create_error;
|
||||||
device->vdp_get_error_string (status));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
buffer =
|
buffer =
|
||||||
(GstVdpOutputBuffer *) gst_mini_object_new (GST_TYPE_VDP_OUTPUT_BUFFER);
|
(GstVdpOutputBuffer *) gst_mini_object_new (GST_TYPE_VDP_OUTPUT_BUFFER);
|
||||||
@ -59,6 +55,12 @@ gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format,
|
|||||||
buffer->surface = surface;
|
buffer->surface = surface;
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
||||||
|
create_error:
|
||||||
|
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ,
|
||||||
|
"Couldn't create a VdpOutputSurface, error returned from vdpau was: %s",
|
||||||
|
device->vdp_get_error_string (status));
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GObjectClass *gst_vdp_output_buffer_parent_class;
|
static GObjectClass *gst_vdp_output_buffer_parent_class;
|
||||||
@ -69,6 +71,9 @@ gst_vdp_output_buffer_finalize (GstVdpOutputBuffer * buffer)
|
|||||||
GstVdpDevice *device;
|
GstVdpDevice *device;
|
||||||
VdpStatus status;
|
VdpStatus status;
|
||||||
|
|
||||||
|
if (gst_vdp_buffer_revive (GST_VDP_BUFFER_CAST (buffer)))
|
||||||
|
return;
|
||||||
|
|
||||||
device = buffer->device;
|
device = buffer->device;
|
||||||
|
|
||||||
status = device->vdp_output_surface_destroy (buffer->surface);
|
status = device->vdp_output_surface_destroy (buffer->surface);
|
||||||
@ -120,7 +125,7 @@ gst_vdp_output_buffer_get_type (void)
|
|||||||
(GInstanceInitFunc) gst_vdp_output_buffer_init,
|
(GInstanceInitFunc) gst_vdp_output_buffer_init,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
_gst_vdp_output_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
|
_gst_vdp_output_buffer_type = g_type_register_static (GST_TYPE_VDP_BUFFER,
|
||||||
"GstVdpOutputBuffer", &info, 0);
|
"GstVdpOutputBuffer", &info, 0);
|
||||||
|
|
||||||
DEBUG_INIT ();
|
DEBUG_INIT ();
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "gstvdpbuffer.h"
|
||||||
#include "gstvdpdevice.h"
|
#include "gstvdpdevice.h"
|
||||||
|
|
||||||
typedef struct _GstVdpOutputBuffer GstVdpOutputBuffer;
|
typedef struct _GstVdpOutputBuffer GstVdpOutputBuffer;
|
||||||
@ -32,7 +33,7 @@ typedef struct _GstVdpOutputBuffer GstVdpOutputBuffer;
|
|||||||
#define GST_VDP_OUTPUT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_OUTPUT_BUFFER, GstVdpOutputBuffer))
|
#define GST_VDP_OUTPUT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_OUTPUT_BUFFER, GstVdpOutputBuffer))
|
||||||
|
|
||||||
struct _GstVdpOutputBuffer {
|
struct _GstVdpOutputBuffer {
|
||||||
GstBuffer buffer;
|
GstVdpBuffer vdp_buffer;
|
||||||
|
|
||||||
GstVdpDevice *device;
|
GstVdpDevice *device;
|
||||||
VdpRGBAFormat rgba_format;
|
VdpRGBAFormat rgba_format;
|
||||||
@ -43,7 +44,7 @@ struct _GstVdpOutputBuffer {
|
|||||||
|
|
||||||
GType gst_vdp_output_buffer_get_type (void);
|
GType gst_vdp_output_buffer_get_type (void);
|
||||||
|
|
||||||
GstVdpOutputBuffer* gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format, gint width, gint height);
|
GstVdpOutputBuffer* gst_vdp_output_buffer_new (GstVdpDevice * device, VdpRGBAFormat rgba_format, gint width, gint height, GError **error);
|
||||||
|
|
||||||
GstCaps *gst_vdp_output_buffer_get_template_caps (void);
|
GstCaps *gst_vdp_output_buffer_get_template_caps (void);
|
||||||
GstCaps *gst_vdp_output_buffer_get_allowed_caps (GstVdpDevice *device);
|
GstCaps *gst_vdp_output_buffer_get_allowed_caps (GstVdpDevice *device);
|
||||||
|
146
sys/vdpau/gstvdp/gstvdpoutputbufferpool.c
Normal file
146
sys/vdpau/gstvdp/gstvdpoutputbufferpool.c
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* gst-plugins-bad
|
||||||
|
* Copyright (C) Carl-Anton Ingmarsson 2010 <ca.ingmarsson@gmail.com>
|
||||||
|
*
|
||||||
|
* gst-plugins-bad is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gst-plugins-bad 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gstvdpdevice.h"
|
||||||
|
#include "gstvdpoutputbuffer.h"
|
||||||
|
|
||||||
|
#include "gstvdpoutputbufferpool.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct _GstVdpOutputBufferPool
|
||||||
|
{
|
||||||
|
GstVdpBufferPool buffer_pool;
|
||||||
|
|
||||||
|
VdpRGBAFormat rgba_format;
|
||||||
|
guint width, height;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GstVdpOutputBufferPool, gst_vdp_output_buffer_pool,
|
||||||
|
GST_TYPE_VDP_BUFFER_POOL);
|
||||||
|
|
||||||
|
GstVdpBufferPool *
|
||||||
|
gst_vdp_output_buffer_pool_new (GstVdpDevice * device)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GST_IS_VDP_DEVICE (device), NULL);
|
||||||
|
|
||||||
|
return g_object_new (GST_TYPE_VDP_OUTPUT_BUFFER_POOL, "device", device, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
parse_caps (const GstCaps * caps, VdpChromaType * rgba_format, gint * width,
|
||||||
|
gint * height)
|
||||||
|
{
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
|
||||||
|
if (!gst_structure_get_int (structure, "rgba-format", (gint *) rgba_format))
|
||||||
|
return FALSE;
|
||||||
|
if (!gst_structure_get_int (structure, "width", width))
|
||||||
|
return FALSE;
|
||||||
|
if (!gst_structure_get_int (structure, "height", height))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_vdp_output_buffer_pool_check_caps (GstVdpBufferPool * bpool,
|
||||||
|
const GstCaps * caps)
|
||||||
|
{
|
||||||
|
GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool);
|
||||||
|
|
||||||
|
VdpChromaType rgba_format;
|
||||||
|
gint width, height;
|
||||||
|
|
||||||
|
if (!parse_caps (caps, &rgba_format, &width, &height))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (rgba_format != opool->rgba_format || width != opool->width ||
|
||||||
|
height != opool->height)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_vdp_output_buffer_pool_set_caps (GstVdpBufferPool * bpool,
|
||||||
|
const GstCaps * caps, gboolean * clear_bufs)
|
||||||
|
{
|
||||||
|
GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool);
|
||||||
|
|
||||||
|
VdpChromaType rgba_format;
|
||||||
|
gint width, height;
|
||||||
|
|
||||||
|
if (!parse_caps (caps, &rgba_format, &width, &height))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (rgba_format != opool->rgba_format || width != opool->width ||
|
||||||
|
height != opool->height)
|
||||||
|
*clear_bufs = TRUE;
|
||||||
|
else
|
||||||
|
*clear_bufs = FALSE;
|
||||||
|
|
||||||
|
opool->rgba_format = rgba_format;
|
||||||
|
opool->width = width;
|
||||||
|
opool->height = height;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstVdpBuffer *
|
||||||
|
gst_vdp_output_buffer_pool_alloc_buffer (GstVdpBufferPool * bpool,
|
||||||
|
GError ** error)
|
||||||
|
{
|
||||||
|
GstVdpOutputBufferPool *opool = GST_VDP_OUTPUT_BUFFER_POOL (bpool);
|
||||||
|
GstVdpDevice *device;
|
||||||
|
|
||||||
|
device = gst_vdp_buffer_pool_get_device (bpool);
|
||||||
|
return GST_VDP_BUFFER_CAST (gst_vdp_output_buffer_new (device,
|
||||||
|
opool->rgba_format, opool->width, opool->height, error));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vdp_output_buffer_pool_finalize (GObject * object)
|
||||||
|
{
|
||||||
|
/* TODO: Add deinitalization code here */
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (gst_vdp_output_buffer_pool_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vdp_output_buffer_pool_init (GstVdpOutputBufferPool * opool)
|
||||||
|
{
|
||||||
|
opool->rgba_format = -1;
|
||||||
|
opool->width = 0;
|
||||||
|
opool->height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_vdp_output_buffer_pool_class_init (GstVdpOutputBufferPoolClass * klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
GstVdpBufferPoolClass *buffer_pool_class = GST_VDP_BUFFER_POOL_CLASS (klass);
|
||||||
|
|
||||||
|
buffer_pool_class->alloc_buffer = gst_vdp_output_buffer_pool_alloc_buffer;
|
||||||
|
buffer_pool_class->set_caps = gst_vdp_output_buffer_pool_set_caps;
|
||||||
|
buffer_pool_class->check_caps = gst_vdp_output_buffer_pool_check_caps;
|
||||||
|
|
||||||
|
object_class->finalize = gst_vdp_output_buffer_pool_finalize;
|
||||||
|
}
|
50
sys/vdpau/gstvdp/gstvdpoutputbufferpool.h
Normal file
50
sys/vdpau/gstvdp/gstvdpoutputbufferpool.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* gst-plugins-bad
|
||||||
|
* Copyright (C) Carl-Anton Ingmarsson 2010 <ca.ingmarsson@gmail.com>
|
||||||
|
*
|
||||||
|
* gst-plugins-bad is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* gst-plugins-bad 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GST_VDP_OUTPUT_BUFFER_POOL_H_
|
||||||
|
#define _GST_VDP_OUTPUT_BUFFER_POOL_H_
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
|
|
||||||
|
#include "gstvdpbufferpool.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define GST_TYPE_VDP_OUTPUT_BUFFER_POOL (gst_vdp_output_buffer_pool_get_type ())
|
||||||
|
#define GST_VDP_OUTPUT_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPool))
|
||||||
|
#define GST_VDP_OUTPUT_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPoolClass))
|
||||||
|
#define GST_IS_VDP_OUTPUT_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL))
|
||||||
|
#define GST_IS_VDP_OUTPUT_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VDP_OUTPUT_BUFFER_POOL))
|
||||||
|
#define GST_VDP_OUTPUT_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VDP_OUTPUT_BUFFER_POOL, GstVdpOutputBufferPoolClass))
|
||||||
|
|
||||||
|
typedef struct _GstVdpOutputBufferPool GstVdpOutputBufferPool;
|
||||||
|
typedef struct _GstVdpOutputBufferPoolClass GstVdpOutputBufferPoolClass;
|
||||||
|
|
||||||
|
struct _GstVdpOutputBufferPoolClass
|
||||||
|
{
|
||||||
|
GstVdpBufferPoolClass buffer_pool_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
GstVdpBufferPool *gst_vdp_output_buffer_pool_new (GstVdpDevice *device);
|
||||||
|
|
||||||
|
GType gst_vdp_output_buffer_pool_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* _GST_VDP_OUTPUT_BUFFER_POOL_H_ */
|
@ -156,7 +156,7 @@ gst_vdp_output_src_pad_create_buffer (GstVdpOutputSrcPad * vdp_pad,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*output_buf = gst_vdp_output_buffer_new (vdp_pad->device,
|
*output_buf = gst_vdp_output_buffer_new (vdp_pad->device,
|
||||||
vdp_pad->rgba_format, vdp_pad->width, vdp_pad->height);
|
vdp_pad->rgba_format, vdp_pad->width, vdp_pad->height, NULL);
|
||||||
if (!*output_buf)
|
if (!*output_buf)
|
||||||
goto output_buf_error;
|
goto output_buf_error;
|
||||||
|
|
||||||
|
@ -912,7 +912,7 @@ gst_vdp_sink_get_output_buffer (VdpSink * vdp_sink, GstCaps * caps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*buf = GST_BUFFER (gst_vdp_output_buffer_new (vdp_sink->device,
|
*buf = GST_BUFFER (gst_vdp_output_buffer_new (vdp_sink->device,
|
||||||
rgba_format, width, height));
|
rgba_format, width, height, NULL));
|
||||||
if (*buf == NULL) {
|
if (*buf == NULL) {
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user