~ubuntu-branches/ubuntu/quantal/gstreamer-vaapi/quantal

« back to all changes in this revision

Viewing changes to gst-libs/gst/vaapi/gstvaapivideobuffer.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-02-10 14:35:09 UTC
  • Revision ID: package-import@ubuntu.com-20120210143509-wq9j8uqb5leu1iik
Tags: upstream-0.3.4
ImportĀ upstreamĀ versionĀ 0.3.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  gstvaapivideobuffer.c - Gst VA video buffer
 
3
 *
 
4
 *  Copyright (C) 2010-2011 Splitted-Desktop Systems
 
5
 *  Copyright (C) 2011 Intel Corporation
 
6
 *
 
7
 *  This library is free software; you can redistribute it and/or
 
8
 *  modify it under the terms of the GNU Lesser General Public License
 
9
 *  as published by the Free Software Foundation; either version 2.1
 
10
 *  of the License, or (at your option) any later version.
 
11
 *
 
12
 *  This library is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 *  Lesser General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU Lesser General Public
 
18
 *  License along with this library; if not, write to the Free
 
19
 *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
20
 *  Boston, MA 02110-1301 USA
 
21
 */
 
22
 
 
23
/**
 
24
 * SECTION:gstvaapivideobuffer
 
25
 * @short_description: VA video buffer for GStreamer
 
26
 */
 
27
 
 
28
#include "sysdeps.h"
 
29
#include "gstvaapivideobuffer.h"
 
30
#include "gstvaapivideobuffer_priv.h"
 
31
#include "gstvaapiimagepool.h"
 
32
#include "gstvaapisurfacepool.h"
 
33
#include "gstvaapiobject_priv.h"
 
34
 
 
35
#define DEBUG 1
 
36
#include "gstvaapidebug.h"
 
37
 
 
38
G_DEFINE_TYPE(GstVaapiVideoBuffer, gst_vaapi_video_buffer, GST_TYPE_SURFACE_BUFFER);
 
39
 
 
40
#define GST_VAAPI_VIDEO_BUFFER_GET_PRIVATE(obj)                 \
 
41
    (G_TYPE_INSTANCE_GET_PRIVATE((obj),                         \
 
42
                                 GST_VAAPI_TYPE_VIDEO_BUFFER,   \
 
43
                                 GstVaapiVideoBufferPrivate))
 
44
 
 
45
struct _GstVaapiVideoBufferPrivate {
 
46
    GstVaapiDisplay            *display;
 
47
    GstVaapiVideoPool          *image_pool;
 
48
    GstVaapiImage              *image;
 
49
    GstVaapiVideoPool          *surface_pool;
 
50
    GstVaapiSurface            *surface;
 
51
    GstVaapiSurfaceProxy       *proxy;
 
52
    GstBuffer                  *buffer;
 
53
};
 
54
 
 
55
static void
 
56
set_display(GstVaapiVideoBuffer *buffer, GstVaapiDisplay *display)
 
57
{
 
58
    GstVaapiVideoBufferPrivate * const priv = buffer->priv;
 
59
 
 
60
    if (priv->display) {
 
61
        g_object_unref(priv->display);
 
62
        priv->display = NULL;
 
63
    }
 
64
 
 
65
    if (display)
 
66
        priv->display = g_object_ref(display);
 
67
}
 
68
 
 
69
static inline void
 
70
set_image(GstVaapiVideoBuffer *buffer, GstVaapiImage *image)
 
71
{
 
72
    buffer->priv->image = g_object_ref(image);
 
73
    set_display(buffer, GST_VAAPI_OBJECT_DISPLAY(image));
 
74
}
 
75
 
 
76
static inline void
 
77
set_surface(GstVaapiVideoBuffer *buffer, GstVaapiSurface *surface)
 
78
{
 
79
    buffer->priv->surface = g_object_ref(surface);
 
80
    set_display(buffer, GST_VAAPI_OBJECT_DISPLAY(surface));
 
81
}
 
82
 
 
83
static void
 
84
gst_vaapi_video_buffer_destroy_image(GstVaapiVideoBuffer *buffer)
 
85
{
 
86
    GstVaapiVideoBufferPrivate * const priv = buffer->priv;
 
87
 
 
88
    if (priv->image) {
 
89
        if (priv->image_pool)
 
90
            gst_vaapi_video_pool_put_object(priv->image_pool, priv->image);
 
91
        else
 
92
            g_object_unref(priv->image);
 
93
        priv->image = NULL;
 
94
    }
 
95
 
 
96
    if (priv->image_pool) {
 
97
        g_object_unref(priv->image_pool);
 
98
        priv->image_pool = NULL;
 
99
    }
 
100
}
 
101
 
 
102
static void
 
103
gst_vaapi_video_buffer_destroy_surface(GstVaapiVideoBuffer *buffer)
 
104
{
 
105
    GstVaapiVideoBufferPrivate * const priv = buffer->priv;
 
106
 
 
107
    if (priv->proxy) {
 
108
        g_object_unref(priv->proxy);
 
109
        priv->proxy = NULL;
 
110
    }
 
111
 
 
112
    if (priv->surface) {
 
113
        if (priv->surface_pool)
 
114
            gst_vaapi_video_pool_put_object(priv->surface_pool, priv->surface);
 
115
        else
 
116
            g_object_unref(priv->surface);
 
117
        priv->surface = NULL;
 
118
    }
 
119
 
 
120
    if (priv->surface_pool) {
 
121
        g_object_unref(priv->surface_pool);
 
122
        priv->surface_pool = NULL;
 
123
    }
 
124
 
 
125
    if (priv->buffer) {
 
126
        gst_buffer_unref(priv->buffer);
 
127
        priv->buffer = NULL;
 
128
    }
 
129
}
 
130
 
 
131
static void
 
132
gst_vaapi_video_buffer_finalize(GstMiniObject *object)
 
133
{
 
134
    GstVaapiVideoBuffer * const buffer = GST_VAAPI_VIDEO_BUFFER(object);
 
135
    GstMiniObjectClass *parent_class;
 
136
 
 
137
    gst_vaapi_video_buffer_destroy_image(buffer);
 
138
    gst_vaapi_video_buffer_destroy_surface(buffer);
 
139
 
 
140
    set_display(buffer, NULL);
 
141
 
 
142
    parent_class = GST_MINI_OBJECT_CLASS(gst_vaapi_video_buffer_parent_class);
 
143
    if (parent_class->finalize)
 
144
        parent_class->finalize(object);
 
145
}
 
146
 
 
147
static void
 
148
gst_vaapi_video_buffer_class_init(GstVaapiVideoBufferClass *klass)
 
149
{
 
150
    GstMiniObjectClass * const object_class = GST_MINI_OBJECT_CLASS(klass);
 
151
 
 
152
    g_type_class_add_private(klass, sizeof(GstVaapiVideoBufferPrivate));
 
153
 
 
154
    object_class->finalize = gst_vaapi_video_buffer_finalize;
 
155
}
 
156
 
 
157
static void
 
158
gst_vaapi_video_buffer_init(GstVaapiVideoBuffer *buffer)
 
159
{
 
160
    GstVaapiVideoBufferPrivate *priv;
 
161
 
 
162
    priv                = GST_VAAPI_VIDEO_BUFFER_GET_PRIVATE(buffer);
 
163
    buffer->priv        = priv;
 
164
    priv->display       = NULL;
 
165
    priv->image_pool    = NULL;
 
166
    priv->image         = NULL;
 
167
    priv->surface_pool  = NULL;
 
168
    priv->surface       = NULL;
 
169
    priv->proxy         = NULL;
 
170
    priv->buffer        = NULL;
 
171
}
 
172
 
 
173
/**
 
174
 * gst_vaapi_video_buffer_new:
 
175
 * @display: a #GstVaapiDisplay
 
176
 *
 
177
 * Creates an empty #GstBuffer. The caller is responsible for completing
 
178
 * the initialization of the buffer with the gst_vaapi_video_buffer_set_*()
 
179
 * functions.
 
180
 *
 
181
 * Return value: the newly allocated #GstBuffer, or %NULL or error
 
182
 */
 
183
static inline gpointer
 
184
_gst_vaapi_video_buffer_new(void)
 
185
{
 
186
    return gst_mini_object_new(GST_VAAPI_TYPE_VIDEO_BUFFER);
 
187
}
 
188
 
 
189
GstBuffer *
 
190
gst_vaapi_video_buffer_new(GstVaapiDisplay *display)
 
191
{
 
192
    GstBuffer *buffer;
 
193
 
 
194
    g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
 
195
 
 
196
    buffer = _gst_vaapi_video_buffer_new();
 
197
    if (!buffer)
 
198
        return NULL;
 
199
 
 
200
    set_display(GST_VAAPI_VIDEO_BUFFER(buffer), display);
 
201
    return buffer;
 
202
}
 
203
 
 
204
/**
 
205
 * gst_vaapi_video_buffer_new_from_pool:
 
206
 * @pool: a #GstVaapiVideoPool
 
207
 *
 
208
 * Creates a #GstBuffer with a video object allocated from a @pool.
 
209
 * Only #GstVaapiSurfacePool and #GstVaapiImagePool pools are supported.
 
210
 *
 
211
 * The buffer is destroyed through the last call to gst_buffer_unref()
 
212
 * and the video objects are pushed back to their respective pools.
 
213
 *
 
214
 * Return value: the newly allocated #GstBuffer, or %NULL on error
 
215
 */
 
216
GstBuffer *
 
217
gst_vaapi_video_buffer_new_from_pool(GstVaapiVideoPool *pool)
 
218
{
 
219
    GstVaapiVideoBuffer *buffer;
 
220
    gboolean is_image_pool, is_surface_pool;
 
221
 
 
222
    g_return_val_if_fail(GST_VAAPI_IS_VIDEO_POOL(pool), NULL);
 
223
 
 
224
    is_image_pool   = GST_VAAPI_IS_IMAGE_POOL(pool);
 
225
    is_surface_pool = GST_VAAPI_IS_SURFACE_POOL(pool);
 
226
 
 
227
    if (!is_image_pool && !is_surface_pool)
 
228
        return NULL;
 
229
 
 
230
    buffer = _gst_vaapi_video_buffer_new();
 
231
    if (buffer &&
 
232
        ((is_image_pool &&
 
233
          gst_vaapi_video_buffer_set_image_from_pool(buffer, pool)) ||
 
234
         (is_surface_pool &&
 
235
          gst_vaapi_video_buffer_set_surface_from_pool(buffer, pool)))) {
 
236
        set_display(buffer, gst_vaapi_video_pool_get_display(pool));
 
237
        return GST_BUFFER(buffer);
 
238
    }
 
239
 
 
240
    gst_mini_object_unref(GST_MINI_OBJECT(buffer));
 
241
    return NULL;
 
242
}
 
243
 
 
244
/**
 
245
 * gst_vaapi_video_buffer_new_from_buffer:
 
246
 * @buffer: a #GstBuffer
 
247
 *
 
248
 * Creates a #GstBuffer with video objects bound to @buffer video
 
249
 * objects, if any.
 
250
 *
 
251
 * Return value: the newly allocated #GstBuffer, or %NULL on error
 
252
 */
 
253
GstBuffer *
 
254
gst_vaapi_video_buffer_new_from_buffer(GstBuffer *buffer)
 
255
{
 
256
    GstVaapiVideoBuffer *inbuf, *outbuf;
 
257
 
 
258
    if (!GST_VAAPI_IS_VIDEO_BUFFER(buffer)) {
 
259
        if (!buffer->parent || !GST_VAAPI_IS_VIDEO_BUFFER(buffer->parent))
 
260
            return NULL;
 
261
        buffer = buffer->parent;
 
262
    }
 
263
    inbuf = GST_VAAPI_VIDEO_BUFFER(buffer);
 
264
 
 
265
    outbuf = _gst_vaapi_video_buffer_new();
 
266
    if (!outbuf)
 
267
        return NULL;
 
268
 
 
269
    if (inbuf->priv->image)
 
270
        gst_vaapi_video_buffer_set_image(outbuf, inbuf->priv->image);
 
271
    if (inbuf->priv->surface)
 
272
        gst_vaapi_video_buffer_set_surface(outbuf, inbuf->priv->surface);
 
273
    if (inbuf->priv->proxy)
 
274
        gst_vaapi_video_buffer_set_surface_proxy(outbuf, inbuf->priv->proxy);
 
275
 
 
276
    outbuf->priv->buffer = gst_buffer_ref(buffer);
 
277
    return GST_BUFFER(outbuf);
 
278
}
 
279
 
 
280
/**
 
281
 * gst_vaapi_video_buffer_new_with_image:
 
282
 * @image: a #GstVaapiImage
 
283
 *
 
284
 * Creates a #GstBuffer with the specified @image. The resulting
 
285
 * buffer holds an additional reference to the @image.
 
286
 *
 
287
 * Return value: the newly allocated #GstBuffer, or %NULL on error
 
288
 */
 
289
GstBuffer *
 
290
gst_vaapi_video_buffer_new_with_image(GstVaapiImage *image)
 
291
{
 
292
    GstVaapiVideoBuffer *buffer;
 
293
 
 
294
    g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), NULL);
 
295
 
 
296
    buffer = _gst_vaapi_video_buffer_new();
 
297
    if (buffer)
 
298
        gst_vaapi_video_buffer_set_image(buffer, image);
 
299
    return GST_BUFFER(buffer);
 
300
}
 
301
 
 
302
/**
 
303
 * gst_vaapi_video_buffer_new_with_surface:
 
304
 * @surface: a #GstVaapiSurface
 
305
 *
 
306
 * Creates a #GstBuffer with the specified @surface. The resulting
 
307
 * buffer holds an additional reference to the @surface.
 
308
 *
 
309
 * Return value: the newly allocated #GstBuffer, or %NULL on error
 
310
 */
 
311
GstBuffer *
 
312
gst_vaapi_video_buffer_new_with_surface(GstVaapiSurface *surface)
 
313
{
 
314
    GstVaapiVideoBuffer *buffer;
 
315
 
 
316
    g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), NULL);
 
317
 
 
318
    buffer = _gst_vaapi_video_buffer_new();
 
319
    if (buffer)
 
320
        gst_vaapi_video_buffer_set_surface(buffer, surface);
 
321
    return GST_BUFFER(buffer);
 
322
}
 
323
 
 
324
/**
 
325
 * gst_vaapi_video_buffer_new_with_surface_proxy:
 
326
 * @proxy: a #GstVaapiSurfaceProxy
 
327
 *
 
328
 * Creates a #GstBuffer with the specified surface @proxy. The
 
329
 * resulting buffer holds an additional reference to the @proxy.
 
330
 *
 
331
 * Return value: the newly allocated #GstBuffer, or %NULL on error
 
332
 */
 
333
GstBuffer *
 
334
gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy)
 
335
{
 
336
    GstVaapiVideoBuffer *buffer;
 
337
 
 
338
    g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
 
339
 
 
340
    buffer = _gst_vaapi_video_buffer_new();
 
341
    if (buffer)
 
342
        gst_vaapi_video_buffer_set_surface_proxy(buffer, proxy);
 
343
    return GST_BUFFER(buffer);
 
344
}
 
345
 
 
346
/**
 
347
 * gst_vaapi_video_buffer_get_display:
 
348
 * @buffer: a #GstVaapiVideoBuffer
 
349
 *
 
350
 * Retrieves the #GstVaapiDisplay the @buffer is bound to. The @buffer
 
351
 * owns the returned #GstVaapiDisplay object so the caller is
 
352
 * responsible for calling g_object_ref() when needed.
 
353
 *
 
354
 * Return value: the #GstVaapiDisplay the @buffer is bound to
 
355
 */
 
356
GstVaapiDisplay *
 
357
gst_vaapi_video_buffer_get_display(GstVaapiVideoBuffer *buffer)
 
358
{
 
359
    g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL);
 
360
 
 
361
    return buffer->priv->display;
 
362
}
 
363
 
 
364
/**
 
365
 * gst_vaapi_video_buffer_get_image:
 
366
 * @buffer: a #GstVaapiVideoBuffer
 
367
 *
 
368
 * Retrieves the #GstVaapiImage bound to the @buffer. The @buffer owns
 
369
 * the #GstVaapiImage so the caller is responsible for calling
 
370
 * g_object_ref() when needed.
 
371
 *
 
372
 * Return value: the #GstVaapiImage bound to the @buffer, or %NULL if
 
373
 *   there is none
 
374
 */
 
375
GstVaapiImage *
 
376
gst_vaapi_video_buffer_get_image(GstVaapiVideoBuffer *buffer)
 
377
{
 
378
    g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL);
 
379
 
 
380
    return buffer->priv->image;
 
381
}
 
382
 
 
383
/**
 
384
 * gst_vaapi_video_buffer_set_image:
 
385
 * @buffer: a #GstVaapiVideoBuffer
 
386
 * @image: a #GstVaapiImage
 
387
 *
 
388
 * Binds @image to the @buffer. If the @buffer contains another image
 
389
 * previously allocated from a pool, it's pushed back to its parent
 
390
 * pool and the pool is also released.
 
391
 */
 
392
void
 
393
gst_vaapi_video_buffer_set_image(
 
394
    GstVaapiVideoBuffer *buffer,
 
395
    GstVaapiImage       *image
 
396
)
 
397
{
 
398
    g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer));
 
399
    g_return_if_fail(GST_VAAPI_IS_IMAGE(image));
 
400
 
 
401
    gst_vaapi_video_buffer_destroy_image(buffer);
 
402
 
 
403
    if (image)
 
404
        set_image(buffer, image);
 
405
}
 
406
 
 
407
/**
 
408
 * gst_vaapi_video_buffer_set_image_from_pool
 
409
 * @buffer: a #GstVaapiVideoBuffer
 
410
 * @pool: a #GstVaapiVideoPool
 
411
 *
 
412
 * Binds a newly allocated video object from the @pool. The @pool
 
413
 * shall be of type #GstVaapiImagePool. Previously allocated objects
 
414
 * are released and returned to their parent pools, if any.
 
415
 *
 
416
 * Return value: %TRUE on success
 
417
 */
 
418
gboolean
 
419
gst_vaapi_video_buffer_set_image_from_pool(
 
420
    GstVaapiVideoBuffer *buffer,
 
421
    GstVaapiVideoPool   *pool
 
422
)
 
423
{
 
424
    GstVaapiImage *image;
 
425
 
 
426
    g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), FALSE);
 
427
    g_return_val_if_fail(GST_VAAPI_IS_IMAGE_POOL(pool), FALSE);
 
428
 
 
429
    gst_vaapi_video_buffer_destroy_image(buffer);
 
430
 
 
431
    if (pool) {
 
432
        image = gst_vaapi_video_pool_get_object(pool);
 
433
        if (!image)
 
434
            return FALSE;
 
435
        set_image(buffer, image);
 
436
        buffer->priv->image_pool = g_object_ref(pool);
 
437
    }
 
438
    return TRUE;
 
439
}
 
440
 
 
441
/**
 
442
 * gst_vaapi_video_buffer_get_surface:
 
443
 * @buffer: a #GstVaapiVideoBuffer
 
444
 *
 
445
 * Retrieves the #GstVaapiSurface bound to the @buffer. The @buffer
 
446
 * owns the #GstVaapiSurface so the caller is responsible for calling
 
447
 * g_object_ref() when needed.
 
448
 *
 
449
 * Return value: the #GstVaapiSurface bound to the @buffer, or %NULL if
 
450
 *   there is none
 
451
 */
 
452
GstVaapiSurface *
 
453
gst_vaapi_video_buffer_get_surface(GstVaapiVideoBuffer *buffer)
 
454
{
 
455
    g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL);
 
456
 
 
457
    return buffer->priv->surface;
 
458
}
 
459
 
 
460
/**
 
461
 * gst_vaapi_video_buffer_set_surface:
 
462
 * @buffer: a #GstVaapiVideoBuffer
 
463
 * @surface: a #GstVaapiSurface
 
464
 *
 
465
 * Binds @surface to the @buffer. If the @buffer contains another
 
466
 * surface previously allocated from a pool, it's pushed back to its
 
467
 * parent pool and the pool is also released.
 
468
 */
 
469
void
 
470
gst_vaapi_video_buffer_set_surface(
 
471
    GstVaapiVideoBuffer *buffer,
 
472
    GstVaapiSurface     *surface
 
473
)
 
474
{
 
475
    g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer));
 
476
    g_return_if_fail(GST_VAAPI_IS_SURFACE(surface));
 
477
 
 
478
    gst_vaapi_video_buffer_destroy_surface(buffer);
 
479
 
 
480
    if (surface)
 
481
        set_surface(buffer, surface);
 
482
}
 
483
 
 
484
/**
 
485
 * gst_vaapi_video_buffer_set_surface_from_pool
 
486
 * @buffer: a #GstVaapiVideoBuffer
 
487
 * @pool: a #GstVaapiVideoPool
 
488
 *
 
489
 * Binds a newly allocated video object from the @pool. The @pool
 
490
 * shall be of type #GstVaapiSurfacePool. Previously allocated objects
 
491
 * are released and returned to their parent pools, if any.
 
492
 *
 
493
 * Return value: %TRUE on success
 
494
 */
 
495
gboolean
 
496
gst_vaapi_video_buffer_set_surface_from_pool(
 
497
    GstVaapiVideoBuffer *buffer,
 
498
    GstVaapiVideoPool   *pool
 
499
)
 
500
{
 
501
    GstVaapiSurface *surface;
 
502
 
 
503
    g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), FALSE);
 
504
    g_return_val_if_fail(GST_VAAPI_IS_SURFACE_POOL(pool), FALSE);
 
505
 
 
506
    gst_vaapi_video_buffer_destroy_surface(buffer);
 
507
 
 
508
    if (pool) {
 
509
        surface = gst_vaapi_video_pool_get_object(pool);
 
510
        if (!surface)
 
511
            return FALSE;
 
512
        set_surface(buffer, surface);
 
513
        buffer->priv->surface_pool = g_object_ref(pool);
 
514
    }
 
515
    return TRUE;
 
516
}
 
517
 
 
518
/**
 
519
 * gst_vaapi_video_buffer_get_surface_proxy:
 
520
 * @buffer: a #GstVaapiVideoBuffer
 
521
 *
 
522
 * Retrieves the #GstVaapiSurfaceProxy bound to the @buffer. The @buffer
 
523
 * owns the #GstVaapiSurfaceProxy so the caller is responsible for calling
 
524
 * g_object_ref() when needed.
 
525
 *
 
526
 * Return value: the #GstVaapiSurfaceProxy bound to the @buffer, or
 
527
 *   %NULL if there is none
 
528
 */
 
529
GstVaapiSurfaceProxy *
 
530
gst_vaapi_video_buffer_get_surface_proxy(GstVaapiVideoBuffer *buffer)
 
531
{
 
532
    g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL);
 
533
 
 
534
    return buffer->priv->proxy;
 
535
}
 
536
 
 
537
/**
 
538
 * gst_vaapi_video_buffer_set_surface_proxy:
 
539
 * @buffer: a #GstVaapiVideoBuffer
 
540
 * @proxy: a #GstVaapiSurfaceProxy
 
541
 *
 
542
 * Binds surface @proxy to the @buffer. If the @buffer contains another
 
543
 * surface previously allocated from a pool, it's pushed back to its
 
544
 * parent pool and the pool is also released.
 
545
 */
 
546
void
 
547
gst_vaapi_video_buffer_set_surface_proxy(
 
548
    GstVaapiVideoBuffer  *buffer,
 
549
    GstVaapiSurfaceProxy *proxy
 
550
)
 
551
{
 
552
    GstVaapiSurface *surface;
 
553
 
 
554
    g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer));
 
555
    g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
 
556
 
 
557
    gst_vaapi_video_buffer_destroy_surface(buffer);
 
558
 
 
559
    if (proxy) {
 
560
        surface = GST_VAAPI_SURFACE_PROXY_SURFACE(proxy);
 
561
        if (!surface)
 
562
            return;
 
563
        set_surface(buffer, surface);
 
564
        buffer->priv->proxy = g_object_ref(proxy);
 
565
    }
 
566
}
 
567
 
 
568
/**
 
569
 * gst_vaapi_video_buffer_set_display:
 
570
 * @buffer: a #GstVaapiVideoBuffer
 
571
 * @display a #GstVaapiDisplay
 
572
 *
 
573
 * For subclass only, don't use.
 
574
 */
 
575
void
 
576
gst_vaapi_video_buffer_set_display(
 
577
    GstVaapiVideoBuffer *buffer,
 
578
    GstVaapiDisplay     *display
 
579
)
 
580
{
 
581
  set_display(buffer, display);
 
582
}
 
583
 
 
584
/**
 
585
 * gst_vaapi_video_buffer_set_display:
 
586
 * @buffer: a #GstVaapiVideoBuffer
 
587
 * @other_buffer: a #GstBuffer
 
588
 *
 
589
 * For subclass only, don't use.
 
590
 */
 
591
void
 
592
gst_vaapi_video_buffer_set_buffer(
 
593
    GstVaapiVideoBuffer *buffer,
 
594
    GstBuffer           *other_buffer
 
595
)
 
596
{
 
597
  g_return_if_fail (buffer->priv->buffer == NULL);
 
598
  buffer->priv->buffer = gst_buffer_ref (other_buffer);
 
599
}