2 * gstvaapiupload.c - VA-API video uploader
4 * Copyright (C) 2010-2011 Splitted-Desktop Systems
5 * Copyright (C) 2011-2012 Intel Corporation
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.
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.
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
24 * SECTION:gstvaapiupload
25 * @short_description: A video to VA flow filter
27 * vaapiupload uploads from raw YUV pixels to VA surfaces suitable
28 * for the vaapisink element, for example.
34 #include <gst/video/video.h>
35 #include <gst/video/videocontext.h>
36 #include <gst/vaapi/gstvaapivideobuffer.h>
37 #include <gst/vaapi/gstvaapidebug.h>
39 #include "gstvaapiupload.h"
40 #include "gstvaapipluginutil.h"
41 #include "gstvaapipluginbuffer.h"
43 #define GST_PLUGIN_NAME "vaapiupload"
44 #define GST_PLUGIN_DESC "A video to VA flow filter"
46 GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapiupload);
47 #define GST_CAT_DEFAULT gst_debug_vaapiupload
49 /* ElementFactory information */
50 static const GstElementDetails gst_vaapiupload_details =
52 "VA-API colorspace uploader",
53 "Filter/Converter/Video",
55 "Gwenole Beauchesne <gwenole.beauchesne@intel.com>");
57 /* Default templates */
58 static const char gst_vaapiupload_yuv_caps_str[] =
60 "width = (int) [ 1, MAX ], "
61 "height = (int) [ 1, MAX ]; ";
63 static const char gst_vaapiupload_vaapi_caps_str[] =
64 GST_VAAPI_SURFACE_CAPS;
66 static GstStaticPadTemplate gst_vaapiupload_sink_factory =
67 GST_STATIC_PAD_TEMPLATE(
71 GST_STATIC_CAPS(gst_vaapiupload_yuv_caps_str));
73 static GstStaticPadTemplate gst_vaapiupload_src_factory =
74 GST_STATIC_PAD_TEMPLATE(
78 GST_STATIC_CAPS(gst_vaapiupload_vaapi_caps_str));
81 gst_vaapiupload_implements_iface_init(GstImplementsInterfaceClass *iface);
84 gst_video_context_interface_init(GstVideoContextInterface *iface);
86 #define GstVideoContextClass GstVideoContextInterface
87 G_DEFINE_TYPE_WITH_CODE(
90 GST_TYPE_BASE_TRANSFORM,
91 G_IMPLEMENT_INTERFACE(GST_TYPE_IMPLEMENTS_INTERFACE,
92 gst_vaapiupload_implements_iface_init);
93 G_IMPLEMENT_INTERFACE(GST_TYPE_VIDEO_CONTEXT,
94 gst_video_context_interface_init));
97 * Direct rendering levels (direct-rendering)
98 * 0: upstream allocated YUV pixels
99 * 1: vaapiupload allocated YUV pixels (mapped from VA image)
100 * 2: vaapiupload allocated YUV pixels (mapped from VA surface)
102 #define DIRECT_RENDERING_DEFAULT 2
107 PROP_DIRECT_RENDERING,
111 gst_vaapiupload_start(GstBaseTransform *trans);
114 gst_vaapiupload_stop(GstBaseTransform *trans);
117 gst_vaapiupload_transform(
118 GstBaseTransform *trans,
124 gst_vaapiupload_transform_caps(
125 GstBaseTransform *trans,
126 GstPadDirection direction,
131 gst_vaapiupload_set_caps(
132 GstBaseTransform *trans,
138 gst_vaapiupload_get_unit_size(
139 GstBaseTransform *trans,
145 gst_vaapiupload_sinkpad_buffer_alloc(
154 gst_vaapiupload_prepare_output_buffer(
155 GstBaseTransform *trans,
163 gst_vaapiupload_query(
168 /* GstImplementsInterface interface */
171 gst_vaapiupload_implements_interface_supported(
172 GstImplementsInterface *iface,
176 return (type == GST_TYPE_VIDEO_CONTEXT);
180 gst_vaapiupload_implements_iface_init(GstImplementsInterfaceClass *iface)
182 iface->supported = gst_vaapiupload_implements_interface_supported;
185 /* GstVideoContext interface */
188 gst_vaapiupload_set_video_context(GstVideoContext *context, const gchar *type,
191 GstVaapiUpload *upload = GST_VAAPIUPLOAD (context);
192 gst_vaapi_set_display (type, value, &upload->display);
196 gst_video_context_interface_init(GstVideoContextInterface *iface)
198 iface->set_context = gst_vaapiupload_set_video_context;
202 gst_vaapiupload_destroy(GstVaapiUpload *upload)
204 g_clear_object(&upload->images);
205 g_clear_object(&upload->surfaces);
206 g_clear_object(&upload->display);
210 gst_vaapiupload_finalize(GObject *object)
212 gst_vaapiupload_destroy(GST_VAAPIUPLOAD(object));
214 G_OBJECT_CLASS(gst_vaapiupload_parent_class)->finalize(object);
219 gst_vaapiupload_set_property(
226 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(object);
229 case PROP_DIRECT_RENDERING:
230 GST_OBJECT_LOCK(upload);
231 upload->direct_rendering = g_value_get_uint(value);
232 GST_OBJECT_UNLOCK(upload);
235 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
241 gst_vaapiupload_get_property(
248 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(object);
251 case PROP_DIRECT_RENDERING:
252 g_value_set_uint(value, upload->direct_rendering);
255 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
261 gst_vaapiupload_class_init(GstVaapiUploadClass *klass)
263 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
264 GstElementClass * const element_class = GST_ELEMENT_CLASS(klass);
265 GstBaseTransformClass * const trans_class = GST_BASE_TRANSFORM_CLASS(klass);
266 GstPadTemplate *pad_template;
268 GST_DEBUG_CATEGORY_INIT(gst_debug_vaapiupload,
269 GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC);
271 object_class->finalize = gst_vaapiupload_finalize;
272 object_class->set_property = gst_vaapiupload_set_property;
273 object_class->get_property = gst_vaapiupload_get_property;
275 trans_class->start = gst_vaapiupload_start;
276 trans_class->stop = gst_vaapiupload_stop;
277 trans_class->transform = gst_vaapiupload_transform;
278 trans_class->transform_caps = gst_vaapiupload_transform_caps;
279 trans_class->set_caps = gst_vaapiupload_set_caps;
280 trans_class->get_unit_size = gst_vaapiupload_get_unit_size;
281 trans_class->prepare_output_buffer = gst_vaapiupload_prepare_output_buffer;
283 gst_element_class_set_details_simple(
285 gst_vaapiupload_details.longname,
286 gst_vaapiupload_details.klass,
287 gst_vaapiupload_details.description,
288 gst_vaapiupload_details.author
292 pad_template = gst_static_pad_template_get(&gst_vaapiupload_sink_factory);
293 gst_element_class_add_pad_template(element_class, pad_template);
294 gst_object_unref(pad_template);
297 pad_template = gst_static_pad_template_get(&gst_vaapiupload_src_factory);
298 gst_element_class_add_pad_template(element_class, pad_template);
299 gst_object_unref(pad_template);
302 * GstVaapiUpload:direct-rendering:
304 * Selects the direct rendering level.
306 * <listitem override="0">
307 * Disables direct rendering.
310 * Enables direct rendering to the output buffer. i.e. this
311 * tries to use a single buffer for both sink and src pads.
314 * Enables direct rendering to the underlying surface. i.e. with
315 * drivers supporting vaDeriveImage(), the output surface pixels
316 * will be modified directly.
320 g_object_class_install_property
322 PROP_DIRECT_RENDERING,
323 g_param_spec_uint("direct-rendering",
325 "Direct rendering level",
327 DIRECT_RENDERING_DEFAULT,
332 gst_vaapiupload_init(GstVaapiUpload *upload)
334 GstPad *sinkpad, *srcpad;
336 upload->display = NULL;
337 upload->images = NULL;
338 upload->images_reset = FALSE;
339 upload->image_width = 0;
340 upload->image_height = 0;
341 upload->surfaces = NULL;
342 upload->surfaces_reset = FALSE;
343 upload->surface_width = 0;
344 upload->surface_height = 0;
345 upload->direct_rendering_caps = 0;
346 upload->direct_rendering = G_MAXUINT32;
347 upload->need_manual_upload = FALSE;
349 /* Override buffer allocator on sink pad */
350 sinkpad = gst_element_get_static_pad(GST_ELEMENT(upload), "sink");
351 gst_pad_set_bufferalloc_function(
353 gst_vaapiupload_sinkpad_buffer_alloc
355 gst_pad_set_query_function(sinkpad, gst_vaapiupload_query);
356 g_object_unref(sinkpad);
358 /* Override query on src pad */
359 srcpad = gst_element_get_static_pad(GST_ELEMENT(upload), "src");
360 gst_pad_set_query_function(srcpad, gst_vaapiupload_query);
361 g_object_unref(srcpad);
364 static inline gboolean
365 gst_vaapiupload_ensure_display(GstVaapiUpload *upload)
367 return gst_vaapi_ensure_display(upload, GST_VAAPI_DISPLAY_TYPE_ANY,
372 gst_vaapiupload_start(GstBaseTransform *trans)
374 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
376 if (!gst_vaapiupload_ensure_display(upload))
382 gst_vaapiupload_stop(GstBaseTransform *trans)
384 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
386 g_clear_object(&upload->display);
392 gst_vaapiupload_transform(
393 GstBaseTransform *trans,
398 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
399 GstVaapiVideoBuffer *vbuffer;
400 GstVaapiSurface *surface;
401 GstVaapiImage *image;
404 vbuffer = GST_VAAPI_VIDEO_BUFFER(outbuf);
405 surface = gst_vaapi_video_buffer_get_surface(vbuffer);
407 return GST_FLOW_UNEXPECTED;
409 if (upload->direct_rendering) {
410 if (!GST_VAAPI_IS_VIDEO_BUFFER(inbuf)) {
411 GST_DEBUG("GstVaapiVideoBuffer was expected");
412 return GST_FLOW_UNEXPECTED;
415 vbuffer = GST_VAAPI_VIDEO_BUFFER(inbuf);
416 image = gst_vaapi_video_buffer_get_image(vbuffer);
418 return GST_FLOW_UNEXPECTED;
419 if (!gst_vaapi_image_unmap(image))
420 return GST_FLOW_UNEXPECTED;
422 if (upload->direct_rendering < 2) {
423 if (!gst_vaapi_surface_put_image(surface, image))
424 goto error_put_image;
429 /* PVR need directly copy image to surface */
430 image = gst_vaapi_surface_derive_image(surface);
431 //image = gst_vaapi_video_pool_get_object(upload->images);
433 goto error_put_image;
435 if (!upload->need_manual_upload) {
436 success = gst_vaapi_image_update_from_buffer(image, inbuf, NULL);
437 } else { /* manually copy data to image*/
438 success = gst_vaapi_convert_buffer_to_image(image, inbuf);
441 goto error_put_image;
443 //success = gst_vaapi_surface_put_image(surface, image);
444 //gst_vaapi_video_pool_put_object(upload->images, image);
446 // goto error_put_image;
447 g_object_unref(image);
450 FPS_CALCULATION(vaapiupload);
455 GST_WARNING("failed to upload %" GST_FOURCC_FORMAT " image "
457 GST_FOURCC_ARGS(gst_vaapi_image_get_format(image)),
458 gst_vaapi_surface_get_id(surface));
459 if (!upload->direct_rendering && image)
460 g_object_unref(image);
466 gst_vaapi_get_other_support_caps(GstVaapiUpload *upload)
469 caps = gst_caps_from_string(GST_VIDEO_CAPS_YUV("YUY2"));
474 gst_vaapiupload_transform_caps(
475 GstBaseTransform *trans,
476 GstPadDirection direction,
480 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
481 GstCaps *out_caps = NULL;
482 GstStructure *structure;
484 g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
486 structure = gst_caps_get_structure(caps, 0);
488 if (direction == GST_PAD_SINK) {
489 if (!gst_structure_has_name(structure, "video/x-raw-yuv"))
491 out_caps = gst_caps_from_string(gst_vaapiupload_vaapi_caps_str);
493 structure = gst_caps_get_structure(out_caps, 0);
496 "type", G_TYPE_STRING, "vaapi",
497 "opengl", G_TYPE_BOOLEAN, USE_GLX,
502 if (!gst_structure_has_name(structure, GST_VAAPI_SURFACE_CAPS_NAME))
504 out_caps = gst_caps_from_string(gst_vaapiupload_yuv_caps_str);
505 if (upload->display) {
506 GstCaps *allowed_caps, *inter_caps, *other_caps;
507 allowed_caps = gst_vaapi_display_get_image_caps(upload->display);
510 /* can direct copy other YUV to va surface */
511 other_caps = gst_vaapi_get_other_support_caps(upload);
512 gst_caps_merge(allowed_caps, other_caps);
514 inter_caps = gst_caps_intersect(out_caps, allowed_caps);
515 gst_caps_unref(allowed_caps);
516 gst_caps_unref(out_caps);
517 out_caps = inter_caps;
521 if (!gst_vaapi_append_surface_caps(out_caps, caps)) {
522 gst_caps_unref(out_caps);
529 gst_vaapiupload_ensure_image_pool(GstVaapiUpload *upload, GstCaps *caps)
531 GstStructure * const structure = gst_caps_get_structure(caps, 0);
534 gst_structure_get_int(structure, "width", &width);
535 gst_structure_get_int(structure, "height", &height);
537 if (width != upload->image_width || height != upload->image_height) {
538 upload->image_width = width;
539 upload->image_height = height;
540 g_clear_object(&upload->images);
541 upload->images = gst_vaapi_image_pool_new(upload->display, caps);
544 upload->images_reset = TRUE;
550 gst_vaapiupload_ensure_surface_pool(GstVaapiUpload *upload, GstCaps *caps)
552 GstStructure * const structure = gst_caps_get_structure(caps, 0);
555 gst_structure_get_int(structure, "width", &width);
556 gst_structure_get_int(structure, "height", &height);
558 if (width != upload->surface_width || height != upload->surface_height) {
559 upload->surface_width = width;
560 upload->surface_height = height;
561 g_clear_object(&upload->surfaces);
562 upload->surfaces = gst_vaapi_surface_pool_new(upload->display, caps);
563 if (!upload->surfaces)
565 upload->surfaces_reset = TRUE;
571 gst_vaapiupload_ensure_direct_rendering_caps(
572 GstVaapiUpload *upload,
576 GstVaapiSurface *surface;
577 GstVaapiImage *image;
578 GstVaapiImageFormat vaformat;
579 GstVideoFormat vformat;
580 GstStructure *structure;
583 if (!upload->images_reset && !upload->surfaces_reset)
586 upload->images_reset = FALSE;
587 upload->surfaces_reset = FALSE;
588 upload->direct_rendering_caps = 0;
590 structure = gst_caps_get_structure(caps, 0);
593 gst_structure_get_int(structure, "width", &width);
594 gst_structure_get_int(structure, "height", &height);
596 /* Translate from Gst video format to VA image format */
597 if (!gst_video_format_parse_caps(caps, &vformat, NULL, NULL))
599 if (!gst_video_format_is_yuv(vformat))
601 vaformat = gst_vaapi_image_format_from_video(vformat);
605 /* Check if we can alias sink & output buffers (same data_size) */
606 image = gst_vaapi_video_pool_get_object(upload->images);
608 if (upload->direct_rendering_caps == 0 &&
609 (gst_vaapi_image_get_format(image) == vaformat &&
610 gst_vaapi_image_is_linear(image) &&
611 (gst_vaapi_image_get_data_size(image) ==
612 gst_video_format_get_size(vformat, width, height))))
613 upload->direct_rendering_caps = 1;
614 gst_vaapi_video_pool_put_object(upload->images, image);
617 /* Check if we can access to the surface pixels directly */
618 surface = gst_vaapi_video_pool_get_object(upload->surfaces);
620 image = gst_vaapi_surface_derive_image(surface);
622 if (gst_vaapi_image_map(image)) {
623 if (upload->direct_rendering_caps == 1 &&
624 (gst_vaapi_image_get_format(image) == vaformat &&
625 gst_vaapi_image_is_linear(image) &&
626 (gst_vaapi_image_get_data_size(image) ==
627 gst_video_format_get_size(vformat, width, height))))
628 upload->direct_rendering_caps = 2;
629 gst_vaapi_image_unmap(image);
631 g_object_unref(image);
633 gst_vaapi_video_pool_put_object(upload->surfaces, surface);
637 typedef enum YUV_TYPE {
645 _image_format_to_yuv_type(guint32 fourcc)
648 case GST_MAKE_FOURCC('N','V','1','2'):
649 case GST_MAKE_FOURCC('Y','V','1','2'):
650 case GST_MAKE_FOURCC('I','4','2','0'):
651 case GST_MAKE_FOURCC('N','V','2','1'):
654 case GST_MAKE_FOURCC('Y','U','Y','2'):
655 case GST_MAKE_FOURCC('Y','V','Y','U'):
658 case GST_MAKE_FOURCC('A','Y','U','V'):
667 _get_nearest_caps(GstCaps *caps_list, GstCaps *src_caps)
670 GstStructure *cur_struct, *tmp_struct;
671 guint32 cur_format, dest_format, tmp_format;
672 YUV_TYPE cur_type, tmp_type;
673 const GValue*tmp_val;
676 guint min_diff, tmp_diff;
678 cur_struct = gst_caps_get_structure(src_caps, 0);
679 tmp_val = gst_structure_get_value (cur_struct, "format");
683 cur_format = gst_value_get_fourcc(tmp_val);
684 if((cur_type = _image_format_to_yuv_type(cur_format)) == YUV_UNKOWN)
687 n_caps = gst_caps_get_size(caps_list);
690 for (i = 0; i < n_caps; ++i) {
691 tmp_struct = gst_caps_get_structure(caps_list, i);
692 tmp_val = gst_structure_get_value (tmp_struct, "format");
695 tmp_format = gst_value_get_fourcc(tmp_val);
696 if ((tmp_type = _image_format_to_yuv_type(tmp_format)) == YUV_UNKOWN)
698 tmp_diff = abs(tmp_type - cur_type);
699 if (tmp_diff < min_diff) {
701 dest_format = tmp_format;
705 if (dest_format == 0)
708 ret = gst_caps_copy(src_caps);
709 tmp_struct = gst_caps_get_structure(ret, 0);
710 gst_structure_set(tmp_struct, "format", GST_TYPE_FOURCC, dest_format, NULL);
715 gst_vaapiupload_negotiate_buffers(
716 GstVaapiUpload *upload,
723 GstCaps *image_allowed_caps = NULL;
724 GstCaps *image_caps = NULL;
726 image_allowed_caps = gst_vaapi_display_get_image_caps(upload->display);
727 if (gst_caps_can_intersect(incaps, image_allowed_caps)) {
728 image_caps = gst_caps_ref(incaps);
729 upload->need_manual_upload = FALSE;
731 image_caps = _get_nearest_caps(image_allowed_caps, incaps);
732 upload->need_manual_upload = TRUE;
735 if (!gst_vaapiupload_ensure_image_pool(upload, image_caps))
738 if (!gst_vaapiupload_ensure_surface_pool(upload, outcaps))
741 gst_vaapi_video_pool_set_capacity(upload->surfaces, 6);
742 gst_vaapi_video_pool_reserve(upload->surfaces, 4);
744 if (upload->direct_rendering && !upload->need_manual_upload)
745 gst_vaapiupload_ensure_direct_rendering_caps(upload, incaps);
746 dr = MIN(upload->direct_rendering, upload->direct_rendering_caps);
747 if (upload->direct_rendering != dr) {
748 upload->direct_rendering = dr;
749 GST_DEBUG("direct-rendering level: %d", dr);
758 gst_caps_unref(image_caps);
759 gst_caps_unref(image_allowed_caps);
764 gst_vaapiupload_set_caps(
765 GstBaseTransform *trans,
770 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
772 if (!gst_vaapiupload_negotiate_buffers(upload, incaps, outcaps))
775 GST_INFO("set caps\nIN caps:\n%" GST_PTR_FORMAT "\nOUT caps:\n%" GST_PTR_FORMAT,
781 gst_vaapiupload_get_unit_size(
782 GstBaseTransform *trans,
787 GstStructure * const structure = gst_caps_get_structure(caps, 0);
788 GstVideoFormat format;
791 if (gst_structure_has_name(structure, GST_VAAPI_SURFACE_CAPS_NAME))
794 if (!gst_video_format_parse_caps(caps, &format, &width, &height))
796 *size = gst_video_format_get_size(format, width, height);
802 gst_vaapiupload_buffer_alloc(
803 GstBaseTransform *trans,
809 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
810 GstBuffer *buffer = NULL;
811 GstVaapiImage *image = NULL;
812 GstVaapiSurface *surface = NULL;
813 GstVaapiVideoBuffer *vbuffer;
815 /* already checked */
816 if (!upload->direct_rendering)
819 /* Check if we can use direct-rendering */
820 if (!gst_vaapiupload_negotiate_buffers(upload, caps, caps))
822 if (!upload->direct_rendering)
825 switch (upload->direct_rendering) {
827 buffer = gst_vaapi_video_buffer_new_from_pool(upload->surfaces);
830 vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
832 surface = gst_vaapi_video_buffer_get_surface(vbuffer);
833 image = gst_vaapi_surface_derive_image(surface);
834 if (image && gst_vaapi_image_get_data_size(image) == size) {
835 gst_vaapi_video_buffer_set_image(vbuffer, image);
836 g_object_unref(image); /* video buffer owns an extra reference */
840 /* We can't use the derive-image optimization. Disable it. */
841 upload->direct_rendering = 1;
842 gst_buffer_unref(buffer);
846 buffer = gst_vaapi_video_buffer_new_from_pool(upload->images);
849 vbuffer = GST_VAAPI_VIDEO_BUFFER(buffer);
851 image = gst_vaapi_video_buffer_get_image(vbuffer);
856 if (!gst_vaapi_image_map(image))
859 GST_BUFFER_DATA(buffer) = gst_vaapi_image_get_plane(image, 0);
860 GST_BUFFER_SIZE(buffer) = gst_vaapi_image_get_data_size(image);
862 gst_buffer_set_caps(buffer, caps);
867 /* We can't use the inout-buffers optimization. Disable it. */
868 GST_DEBUG("disable in/out buffer optimization");
870 gst_buffer_unref(buffer);
871 upload->direct_rendering = 0;
876 gst_vaapiupload_sinkpad_buffer_alloc(
884 GstBaseTransform *trans;
887 trans = GST_BASE_TRANSFORM(gst_pad_get_parent_element(pad));
889 return GST_FLOW_UNEXPECTED;
891 ret = gst_vaapiupload_buffer_alloc(trans, size, caps, pbuf);
892 g_object_unref(trans);
897 gst_vaapiupload_prepare_output_buffer(
898 GstBaseTransform *trans,
905 GstVaapiUpload * const upload = GST_VAAPIUPLOAD(trans);
906 GstBuffer *buffer = NULL;
908 if (upload->direct_rendering == 2) {
909 if (GST_VAAPI_IS_VIDEO_BUFFER(inbuf)) {
910 buffer = gst_vaapi_video_buffer_new_from_buffer(inbuf);
911 GST_BUFFER_SIZE(buffer) = size;
914 GST_DEBUG("upstream element destroyed our in/out buffer");
915 upload->direct_rendering = 1;
920 buffer = gst_vaapi_video_buffer_new_from_pool(upload->surfaces);
922 return GST_FLOW_UNEXPECTED;
923 gst_buffer_set_caps(buffer, caps);
931 gst_vaapiupload_query(GstPad *pad, GstQuery *query)
933 GstVaapiUpload *upload = GST_VAAPIUPLOAD (gst_pad_get_parent_element (pad));
936 GST_DEBUG ("sharing display %p", upload->display);
938 if (gst_vaapi_reply_to_query (query, upload->display))
941 res = gst_pad_query_default (pad, query);
943 g_object_unref (upload);