summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/vdpau/gstvdp/Makefile.am2
-rw-r--r--sys/vdpau/gstvdp/gstvdpvideobuffer.c23
-rw-r--r--sys/vdpau/gstvdp/gstvdpvideobuffer.h8
-rw-r--r--sys/vdpau/gstvdp/gstvdpvideobufferpool.c146
-rw-r--r--sys/vdpau/gstvdp/gstvdpvideobufferpool.h50
-rw-r--r--sys/vdpau/gstvdp/gstvdpvideosrcpad.c2
-rw-r--r--sys/vdpau/gstvdpvideopostprocess.c4
7 files changed, 220 insertions, 15 deletions
diff --git a/sys/vdpau/gstvdp/Makefile.am b/sys/vdpau/gstvdp/Makefile.am
index 44a0b9e95..c79ca55c0 100644
--- a/sys/vdpau/gstvdp/Makefile.am
+++ b/sys/vdpau/gstvdp/Makefile.am
@@ -6,6 +6,7 @@ libgstvdp_@GST_MAJORMINOR@_la_SOURCES = \
6 gstvdpbuffer.c \ 6 gstvdpbuffer.c \
7 gstvdpbufferpool.c \ 7 gstvdpbufferpool.c \
8 gstvdpvideobuffer.c \ 8 gstvdpvideobuffer.c \
9 gstvdpvideobufferpool.c \
9 gstvdpoutputbuffer.c \ 10 gstvdpoutputbuffer.c \
10 gstvdpvideosrcpad.c \ 11 gstvdpvideosrcpad.c \
11 gstvdpoutputsrcpad.c \ 12 gstvdpoutputsrcpad.c \
@@ -19,6 +20,7 @@ libgstvdp_@GST_MAJORMINOR@include_HEADERS = \
19 gstvdpbuffer.h \ 20 gstvdpbuffer.h \
20 gstvdpbufferpool.h \ 21 gstvdpbufferpool.h \
21 gstvdpvideobuffer.h \ 22 gstvdpvideobuffer.h \
23 gstvdpvideobufferpool.h \
22 gstvdpoutputbuffer.h \ 24 gstvdpoutputbuffer.h \
23 gstvdpvideosrcpad.h \ 25 gstvdpvideosrcpad.h \
24 gstvdpoutputsrcpad.h \ 26 gstvdpoutputsrcpad.h \
diff --git a/sys/vdpau/gstvdp/gstvdpvideobuffer.c b/sys/vdpau/gstvdp/gstvdpvideobuffer.c
index ff7fc5b94..1d1883cae 100644
--- a/sys/vdpau/gstvdp/gstvdpvideobuffer.c
+++ b/sys/vdpau/gstvdp/gstvdpvideobuffer.c
@@ -32,19 +32,19 @@ GST_DEBUG_CATEGORY_INIT (gst_vdp_video_buffer_debug, "vdpvideobuffer", 0, "VDPAU
32 32
33GstVdpVideoBuffer * 33GstVdpVideoBuffer *
34gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaType chroma_type, 34gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaType chroma_type,
35 gint width, gint height) 35 gint width, gint height, GError ** error)
36{ 36{
37 GstVdpVideoBuffer *buffer; 37 GstVdpVideoBuffer *buffer;
38 VdpStatus status; 38 VdpStatus status;
39 VdpVideoSurface surface; 39 VdpVideoSurface surface;
40 40
41 g_return_val_if_fail (GST_IS_VDP_DEVICE (device), NULL);
42
43
41 status = device->vdp_video_surface_create (device->device, chroma_type, width, 44 status = device->vdp_video_surface_create (device->device, chroma_type, width,
42 height, &surface); 45 height, &surface);
43 if (status != VDP_STATUS_OK) { 46 if (status != VDP_STATUS_OK)
44 GST_ERROR ("Couldn't create a VdpVideoSurface, error returned was: %s", 47 goto create_error;
45 device->vdp_get_error_string (status));
46 return NULL;
47 }
48 48
49 buffer = 49 buffer =
50 (GstVdpVideoBuffer *) gst_mini_object_new (GST_TYPE_VDP_VIDEO_BUFFER); 50 (GstVdpVideoBuffer *) gst_mini_object_new (GST_TYPE_VDP_VIDEO_BUFFER);
@@ -53,6 +53,12 @@ gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaType chroma_type,
53 buffer->surface = surface; 53 buffer->surface = surface;
54 54
55 return buffer; 55 return buffer;
56
57create_error:
58 g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ,
59 "Couldn't create a VdpVideoSurface, error returned from vdpau was: %s",
60 device->vdp_get_error_string (status));
61 return NULL;
56} 62}
57 63
58static GObjectClass *gst_vdp_video_buffer_parent_class; 64static GObjectClass *gst_vdp_video_buffer_parent_class;
@@ -63,6 +69,9 @@ gst_vdp_video_buffer_finalize (GstVdpVideoBuffer * buffer)
63 GstVdpDevice *device; 69 GstVdpDevice *device;
64 VdpStatus status; 70 VdpStatus status;
65 71
72 if (gst_vdp_buffer_revive (GST_VDP_BUFFER_CAST (buffer)))
73 return;
74
66 device = buffer->device; 75 device = buffer->device;
67 76
68 status = device->vdp_video_surface_destroy (buffer->surface); 77 status = device->vdp_video_surface_destroy (buffer->surface);
@@ -114,7 +123,7 @@ gst_vdp_video_buffer_get_type (void)
114 (GInstanceInitFunc) gst_vdp_video_buffer_init, 123 (GInstanceInitFunc) gst_vdp_video_buffer_init,
115 NULL 124 NULL
116 }; 125 };
117 _gst_vdp_video_buffer_type = g_type_register_static (GST_TYPE_BUFFER, 126 _gst_vdp_video_buffer_type = g_type_register_static (GST_TYPE_VDP_BUFFER,
118 "GstVdpVideoBuffer", &info, 0); 127 "GstVdpVideoBuffer", &info, 0);
119 } 128 }
120 return _gst_vdp_video_buffer_type; 129 return _gst_vdp_video_buffer_type;
diff --git a/sys/vdpau/gstvdp/gstvdpvideobuffer.h b/sys/vdpau/gstvdp/gstvdpvideobuffer.h
index 4d14d8c53..0699e73c9 100644
--- a/sys/vdpau/gstvdp/gstvdpvideobuffer.h
+++ b/sys/vdpau/gstvdp/gstvdpvideobuffer.h
@@ -24,10 +24,9 @@
24#include <gst/gst.h> 24#include <gst/gst.h>
25#include <gst/video/video.h> 25#include <gst/video/video.h>
26 26
27#include "gstvdpbuffer.h"
27#include "gstvdpdevice.h" 28#include "gstvdpdevice.h"
28 29
29#include "gstvdpvideobuffer.h"
30
31typedef struct _GstVdpVideoBuffer GstVdpVideoBuffer; 30typedef struct _GstVdpVideoBuffer GstVdpVideoBuffer;
32 31
33#define GST_TYPE_VDP_VIDEO_BUFFER (gst_vdp_video_buffer_get_type()) 32#define GST_TYPE_VDP_VIDEO_BUFFER (gst_vdp_video_buffer_get_type())
@@ -36,7 +35,7 @@ typedef struct _GstVdpVideoBuffer GstVdpVideoBuffer;
36#define GST_VDP_VIDEO_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_VIDEO_BUFFER, GstVdpVideoBuffer)) 35#define GST_VDP_VIDEO_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_VIDEO_BUFFER, GstVdpVideoBuffer))
37 36
38struct _GstVdpVideoBuffer { 37struct _GstVdpVideoBuffer {
39 GstBuffer buffer; 38 GstVdpBuffer vdp_buffer;
40 39
41 GstVdpDevice *device; 40 GstVdpDevice *device;
42 VdpVideoSurface surface; 41 VdpVideoSurface surface;
@@ -92,8 +91,7 @@ static const GstVdpVideoBufferFormats formats[] = {
92 91
93GType gst_vdp_video_buffer_get_type (void); 92GType gst_vdp_video_buffer_get_type (void);
94 93
95GstVdpVideoBuffer* gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaType chroma_type, gint width, gint height); 94GstVdpVideoBuffer *gst_vdp_video_buffer_new (GstVdpDevice * device, VdpChromaType chroma_type, gint width, gint height, GError **error);
96void gst_vdp_video_buffer_add_reference (GstVdpVideoBuffer *buffer, GstVdpVideoBuffer *buf);
97 95
98GstCaps *gst_vdp_video_buffer_get_caps (gboolean filter, VdpChromaType chroma_type); 96GstCaps *gst_vdp_video_buffer_get_caps (gboolean filter, VdpChromaType chroma_type);
99GstCaps *gst_vdp_video_buffer_get_allowed_caps (GstVdpDevice * device); 97GstCaps *gst_vdp_video_buffer_get_allowed_caps (GstVdpDevice * device);
diff --git a/sys/vdpau/gstvdp/gstvdpvideobufferpool.c b/sys/vdpau/gstvdp/gstvdpvideobufferpool.c
new file mode 100644
index 000000000..889367d98
--- /dev/null
+++ b/sys/vdpau/gstvdp/gstvdpvideobufferpool.c
@@ -0,0 +1,146 @@
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2/*
3 * gst-plugins-bad
4 * Copyright (C) Carl-Anton Ingmarsson 2010 <ca.ingmarsson@gmail.com>
5 *
6 * gst-plugins-bad is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * gst-plugins-bad is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "gstvdpdevice.h"
21#include "gstvdpvideobuffer.h"
22
23#include "gstvdpvideobufferpool.h"
24
25
26struct _GstVdpVideoBufferPool
27{
28 GstVdpBufferPool buffer_pool;
29
30 VdpChromaType chroma_type;
31 guint width, height;
32};
33
34G_DEFINE_TYPE (GstVdpVideoBufferPool, gst_vdp_video_buffer_pool,
35 GST_TYPE_VDP_BUFFER_POOL);
36
37GstVdpBufferPool *
38gst_vdp_video_buffer_pool_new (GstVdpDevice * device)
39{
40 g_return_val_if_fail (GST_IS_VDP_DEVICE (device), NULL);
41
42 return g_object_new (GST_TYPE_VDP_VIDEO_BUFFER_POOL, "device", device, NULL);
43}
44
45static gboolean
46parse_caps (const GstCaps * caps, VdpChromaType * chroma_type, gint * width,
47 gint * height)
48{
49 GstStructure *structure;
50
51 structure = gst_caps_get_structure (caps, 0);
52
53 if (!gst_structure_get_int (structure, "chroma-type", (gint *) chroma_type))
54 return FALSE;
55 if (!gst_structure_get_int (structure, "width", width))
56 return FALSE;
57 if (!gst_structure_get_int (structure, "height", height))
58 return FALSE;
59
60 return TRUE;
61}
62
63static gboolean
64gst_vdp_video_buffer_pool_check_caps (GstVdpBufferPool * bpool,
65 const GstCaps * caps)
66{
67 GstVdpVideoBufferPool *vpool = GST_VDP_VIDEO_BUFFER_POOL (bpool);
68
69 VdpChromaType chroma_type;
70 gint width, height;
71
72 if (!parse_caps (caps, &chroma_type, &width, &height))
73 return FALSE;
74
75 if (chroma_type != vpool->chroma_type || width != vpool->width ||
76 height != vpool->height)
77 return FALSE;
78
79 return TRUE;
80}
81
82static gboolean
83gst_vdp_video_buffer_pool_set_caps (GstVdpBufferPool * bpool,
84 const GstCaps * caps, gboolean * clear_bufs)
85{
86 GstVdpVideoBufferPool *vpool = GST_VDP_VIDEO_BUFFER_POOL (bpool);
87
88 VdpChromaType chroma_type;
89 gint width, height;
90
91 if (!parse_caps (caps, &chroma_type, &width, &height))
92 return FALSE;
93
94 if (chroma_type != vpool->chroma_type || width != vpool->width ||
95 height != vpool->height)
96 *clear_bufs = TRUE;
97 else
98 *clear_bufs = FALSE;
99
100 vpool->chroma_type = chroma_type;
101 vpool->width = width;
102 vpool->height = height;
103
104 return TRUE;
105}
106
107static GstVdpBuffer *
108gst_vdp_video_buffer_pool_alloc_buffer (GstVdpBufferPool * bpool,
109 GError ** error)
110{
111 GstVdpVideoBufferPool *vpool = GST_VDP_VIDEO_BUFFER_POOL (bpool);
112 GstVdpDevice *device;
113
114 device = gst_vdp_buffer_pool_get_device (bpool);
115 return GST_VDP_BUFFER_CAST (gst_vdp_video_buffer_new (device,
116 vpool->chroma_type, vpool->width, vpool->height, error));
117}
118
119static void
120gst_vdp_video_buffer_pool_finalize (GObject * object)
121{
122 /* TODO: Add deinitalization code here */
123
124 G_OBJECT_CLASS (gst_vdp_video_buffer_pool_parent_class)->finalize (object);
125}
126
127static void
128gst_vdp_video_buffer_pool_init (GstVdpVideoBufferPool * vpool)
129{
130 vpool->chroma_type = -1;
131 vpool->width = 0;
132 vpool->height = 0;
133}
134
135static void
136gst_vdp_video_buffer_pool_class_init (GstVdpVideoBufferPoolClass * klass)
137{
138 GObjectClass *object_class = G_OBJECT_CLASS (klass);
139 GstVdpBufferPoolClass *buffer_pool_class = GST_VDP_BUFFER_POOL_CLASS (klass);
140
141 buffer_pool_class->alloc_buffer = gst_vdp_video_buffer_pool_alloc_buffer;
142 buffer_pool_class->set_caps = gst_vdp_video_buffer_pool_set_caps;
143 buffer_pool_class->check_caps = gst_vdp_video_buffer_pool_check_caps;
144
145 object_class->finalize = gst_vdp_video_buffer_pool_finalize;
146}
diff --git a/sys/vdpau/gstvdp/gstvdpvideobufferpool.h b/sys/vdpau/gstvdp/gstvdpvideobufferpool.h
new file mode 100644
index 000000000..e22e9b939
--- /dev/null
+++ b/sys/vdpau/gstvdp/gstvdpvideobufferpool.h
@@ -0,0 +1,50 @@
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2/*
3 * gst-plugins-bad
4 * Copyright (C) Carl-Anton Ingmarsson 2010 <ca.ingmarsson@gmail.com>
5 *
6 * gst-plugins-bad is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * gst-plugins-bad is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef _GST_VDP_VIDEO_BUFFERPOOL_H_
21#define _GST_VDP_VIDEO_BUFFERPOOL_H_
22
23#include <gst/gst.h>
24
25#include "gstvdpbufferpool.h"
26
27G_BEGIN_DECLS
28
29#define GST_TYPE_VDP_VIDEO_BUFFER_POOL (gst_vdp_video_buffer_pool_get_type ())
30#define GST_VDP_VIDEO_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VDP_VIDEO_BUFFER_POOL, GstVdpVideoBufferPool))
31#define GST_VDP_VIDEO_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VDP_VIDEO_BUFFER_POOL, GstVdpVideoBufferPoolClass))
32#define GST_IS_VDP_VIDEO_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VDP_VIDEO_BUFFER_POOL))
33#define GST_IS_VDP_VIDEO_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_VDP_VIDEO_BUFFER_POOL))
34#define GST_VDP_VIDEO_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_VDP_VIDEO_BUFFER_POOL, GstVdpVideoBufferPoolClass))
35
36typedef struct _GstVdpVideoBufferPool GstVdpVideoBufferPool;
37typedef struct _GstVdpVideoBufferPoolClass GstVdpVideoBufferPoolClass;
38
39struct _GstVdpVideoBufferPoolClass
40{
41 GstVdpBufferPoolClass buffer_pool_class;
42};
43
44GstVdpBufferPool *gst_vdp_video_buffer_pool_new (GstVdpDevice *device);
45
46GType gst_vdp_video_buffer_pool_get_type (void) G_GNUC_CONST;
47
48G_END_DECLS
49
50#endif /* _GST_VDP_VIDEO_BUFFER_POOL_H_ */
diff --git a/sys/vdpau/gstvdp/gstvdpvideosrcpad.c b/sys/vdpau/gstvdp/gstvdpvideosrcpad.c
index db2f7d9f7..7c8444b8d 100644
--- a/sys/vdpau/gstvdp/gstvdpvideosrcpad.c
+++ b/sys/vdpau/gstvdp/gstvdpvideosrcpad.c
@@ -182,7 +182,7 @@ gst_vdp_video_src_pad_alloc_buffer (GstVdpVideoSrcPad * vdp_pad,
182 GstVdpDevice *device = vdp_pad->device; 182 GstVdpDevice *device = vdp_pad->device;
183 183
184 *video_buf = gst_vdp_video_buffer_new (device, VDP_CHROMA_TYPE_420, 184 *video_buf = gst_vdp_video_buffer_new (device, VDP_CHROMA_TYPE_420,
185 vdp_pad->width, vdp_pad->height); 185 vdp_pad->width, vdp_pad->height, NULL);
186 if (!*video_buf) 186 if (!*video_buf)
187 goto video_buf_error; 187 goto video_buf_error;
188 188
diff --git a/sys/vdpau/gstvdpvideopostprocess.c b/sys/vdpau/gstvdpvideopostprocess.c
index 0b739b3a3..e77b41dd6 100644
--- a/sys/vdpau/gstvdpvideopostprocess.c
+++ b/sys/vdpau/gstvdpvideopostprocess.c
@@ -791,7 +791,7 @@ no_qos:
791 GstVdpVideoBuffer *video_buf; 791 GstVdpVideoBuffer *video_buf;
792 792
793 video_buf = gst_vdp_video_buffer_new (vpp->device, vpp->chroma_type, 793 video_buf = gst_vdp_video_buffer_new (vpp->device, vpp->chroma_type,
794 vpp->width, vpp->height); 794 vpp->width, vpp->height, NULL);
795 if (G_UNLIKELY (!video_buf)) 795 if (G_UNLIKELY (!video_buf))
796 goto video_buf_error; 796 goto video_buf_error;
797 797
@@ -884,7 +884,7 @@ gst_vdp_vpp_sink_bufferalloc (GstPad * pad, guint64 offset, guint size,
884 884
885 *buf = 885 *buf =
886 GST_BUFFER (gst_vdp_video_buffer_new (vpp->device, chroma_type, width, 886 GST_BUFFER (gst_vdp_video_buffer_new (vpp->device, chroma_type, width,
887 height)); 887 height, NULL));
888 888
889 if (*buf == NULL) 889 if (*buf == NULL)
890 goto video_buffer_error; 890 goto video_buffer_error;