Commit graph

277 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
9e3d24c669 plugins: add support for GstContext API.
Add support for the new GstContext API from GStreamer 1.2.x.
- implement the GstElement::set_context() hook ;
- reply to the `context' query from downstream elements.

https://bugzilla.gnome.org/show_bug.cgi?id=703235

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:17:07 +02:00
Víctor Manuel Jáquez Leal
c67b783275 plugins: add compat layer for GstVideoContext.
Add thin compatibility layer for the deprecated GstVideoContext API.
For GStreamer API >= 1.2, this involves the following two functions:
- gst_vaapi_video_context_prepare(): queries if a context is already
  set in the pipeline ;
- gst_vaapi_video_context_propagate(): propagates the newly-created
  context to the rest of the pipeline.

https://bugzilla.gnome.org/show_bug.cgi?id=703235

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:16:52 +02:00
Víctor Manuel Jáquez Leal
f75762d910 plugins: initial port to GStreamer 1.2.
Port vaapidecode and vaapisink plugins to GStreamer API >= 1.2. This
is rather minimalistic so that to test the basic functionality.

Disable vaapipostproc plugin for now as further polishing is needed.
Also disable GstVideoContext interface support since this API is now
gone in 1.2.x. This is preparatory work for GstContext support.

https://bugzilla.gnome.org/show_bug.cgi?id=703235

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:15:51 +02:00
Zhao Halley
45b4ba7df7 vaapisink: ensure the uploader is setup for upstream allocated buffers.
In GStreamer 0.10 builds, make sure that the GstVaapiUploader helper
is setup in case upstream elements allocate buffers themselves without
honouring our GstVaapiSink::bufer_alloc() hook.

In particular, this fixes support for OGG video streams with WebKit.

https://bugzilla.gnome.org/show_bug.cgi?id=703934

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-08-29 19:36:06 +02:00
Gwenole Beauchesne
6d7b5eef7d vaapisink: simplify get_render_buffer() for GStreamer 0.10 builds.
Implement and use gst_vaapisink_get_render_buffer() for GStreamer 0.10
builds as well.
2013-08-29 19:36:06 +02:00
Gwenole Beauchesne
d2648afa32 vaapisink: handle raw buffers not created from VA video buffer pool.
Handle raw video buffers that were not created from a VA video buffer
pool. Use the generic GstVideo API to copy buffers in GStreamer 1.0.x
builds instead of the GstVaapiUploader.

https://bugs.freedesktop.org/show_bug.cgi?id=55818
2013-08-29 19:36:06 +02:00
Gwenole Beauchesne
1be80e791c vaapidecode: remove extraneous size information from allowed caps.
Fix _getcaps() implementation to not report codecs with size information
filled in the returned caps. That's totally useless nowadays. Ideally,
this is a hint to insert a video parser element, thus allowing future
optimizations, but this is not a strict requirement for gstreamer-vaapi,
which is able to parse the elementary bitstreams itself.

https://bugzilla.gnome.org/show_bug.cgi?id=704734
2013-08-29 19:36:06 +02:00
Guangxin.Xu
111d7d4fa4 vaapidecode: submit the last frame from output adapter to decoder.
If there is no frame delimiter at the end of the stream, e.g. no
end-of-stream or end-of-sequence marker, and that the current frame
was fully parsed correctly, then assume that last frame is complete
and submit it to the decoder.

https://bugzilla.gnome.org/show_bug.cgi?id=705123

Signed-off-by: Guangxin.Xu <Guangxin.Xu@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-08-29 14:47:40 +02:00
Gwenole Beauchesne
91736b3a60 vaapidecode: push all decoded frames from within the task.
Make sure to push all decoded frames from the task so that the unlying
VA surfaces could all be rendered from the same thread.
2013-08-29 11:55:05 +02:00
Gwenole Beauchesne
771071a4e5 decode: fix creation of GLX video buffers for GStreamer 0.10.
Fix creation of GstVaapiVideoBuffer objects (i) to have that type for real;
and (ii) to correctly extract the GstSurfaceConverter from the video buffer
object meta.

This fixes support for cluttersink with GStreamer 0.10 builds.
2013-08-26 17:14:33 +02:00
Simon Farnsworth
0ef5979d77 vaapisink: allow scaling to ignore aspect ratio.
Other GStreamer sinks, like xvimagesink, have a force-aspect-ratio property,
which allows you to say that you don't want the sink to respect aspect
ratio. Add the same property to vaapisink.

http://lists.freedesktop.org/archives/libva/2012-September/001298.html

Signed-off-by: Simon Farnsworth <simon.farnsworth at onelan.co.uk>
2013-08-26 13:10:33 +02:00
Wind Yuan
e5a50af2ae vaapisink: fix memory leak of GstVaapiUploader instance.
Make sure gst_vaapisink_ensure_uploader() checks for the existence
of a former GstVaapiUploader instance prior to forcibly creating a
new one.

https://bugzilla.gnome.org/show_bug.cgi?id=703980
2013-08-26 13:01:26 +02:00
Guangxin.Xu
92a124f306 vaapisink: fix get_caps() implementation for GStreamer 1.0.
Fix GstBaseSink::get_caps() implementation for GStreamer 1.0.X builds
by honouring the filter caps argument. More precisely, this fixes the
following pipeline: gst-launch-1.0 videotestsrc ! vaapisink

https://bugzilla.gnome.org/show_bug.cgi?id=705192

Signed-off-by: Guangxin.Xu <Guangxin.Xu@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-08-26 12:56:06 +02:00
Zhao Halley
944a7bd077 filter: add initial support for deinterlacing.
Add basic deinterlacing support, i.e. bob-deinterlacing whereby only
the selected field from the input surface is kept for the target surface.
Setting gst_vaapi_filter_set_deinterlacing() method argument to
GST_VAAPI_DEINTERLACE_METHOD_NONE means to disable deinterlacing.

Also move GstVaapiDeinterlaceMethod definition from vaapipostproc plug-in
to libgstvaapi core library.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-08-23 19:00:38 +02:00
Gwenole Beauchesne
0b1a97cbf9 plugins: handle video cropping in X11 pixmap converter.
Use GstVideoCropMeta in GStreamer 1.0 or any other render rectangle
we could decode from the stream.
2013-07-22 15:45:10 +02:00
Gwenole Beauchesne
6f04a52905 plugins: add support for "x11-pixmap" video converter type.
Install a new video converter that supports X11 pixmap targets for X11
backends only, or make the GLX converter creation function chain up to
the X11 converter whenever requested.
2013-07-22 15:45:10 +02:00
Emilio López
b868c6d888 plugins: fix display type comparison in gst_vaapi_create_display().
After the code got moved to create the gst_vaapi_create_display() helper,
this comparison was not updated to dereference the newly-created
pointer, so the code was comparing the pointer itself to the type, and
therefore failing to retrieve the VA display.

This fixes the following error (and gets gst-vaapi decoding again):

    ERROR vaapidecode gstvaapidecode.c:807:gst_vaapidecode_ensure_allowed_caps: failed to retrieve VA display

https://bugzilla.gnome.org/show_bug.cgi?id=704410

Signed-off-by: Emilio López <emilio@elopez.com.ar>
2013-07-18 08:41:28 +02:00
Gwenole Beauchesne
7fa4973f8a Fix new video format API.
Fix new internal video format API, based on GstVideoFormat, to not
clobber with system symbols. So replace the gst_video_format_* prefix
with gst_vaapi_video_format_ prefix, even if the format type remains
GstVideoFormat.
2013-07-15 14:42:33 +02:00
Gwenole Beauchesne
cee9101dd8 plugins: simlpify gst_vaapi_create_display() helper.
Simplify gst_vaapi_create_display() helper as gst_vaapi_display_XXX_new()
performs the necessary validation checks for the underlying VA display
prior to returning to the caller. So, if an error occurred, then NULL is
really returned in that case.
2013-07-15 11:58:31 +02:00
Víctor Manuel Jáquez Leal
3d290a162c plugins: add gst_vaapi_create_display() helper.
https://bugzilla.gnome.org/show_bug.cgi?id=703235

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-07-15 11:54:44 +02:00
Gwenole Beauchesne
5e18a5b1bd plugins: don't reallocate pool allocator for the same caps.
If the video buffer pool config doesn't have new caps, then it's not
necessary to reinstantiate the allocator. That could be a costly
operation as we could do some extra heavy checking in there.
2013-07-12 17:55:37 +02:00
Gwenole Beauchesne
c82a1bc0ff plugins: fix ref counting of GstVaapiVideoMemory allocator.
Fix reference counting issue whereby gst_memory_init() does not hold
an extra reference to the GstAllocator. So, there could be situations
where the last instance of GstVaapiVideoAllocator gets released before
a dangling GstVaapiVideoMemory object, thus possibly leading to a crash.
2013-07-12 17:14:49 +02:00
Gwenole Beauchesne
d79d561819 vaapiupload: use implicit color conversion to NV12.
Always perform conversion of sources buffers to NV12 since this is
the way we tested for this capability in ensure_allowed_caps(). This
also saves memory bandwidth for further rendering. However, this may
not preserve quality since the YUV buffers are down-sampled to 4:2:0.
2013-07-12 15:15:07 +02:00
Wind Yuan
9b3ad4daad vaapidownload: fix src caps format error.
This fixes direct linking of vaapidownload element to xvimagesink with
VA drivers supporting vaGetImage() from the native VA surface format to
a different VA image format. i.e. color conversion during download.

http://bugzilla.gnome.org/show_bug.cgi?id=703937

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-07-11 19:09:53 +02:00
Gwenole Beauchesne
4668e59bf6 vaapidownload: fix debug string for image formats.
The image is now expressed as a standard GstVideoFormat, which is not
a FOURCC but rather a regular enum value.

This is a regression introduced in commit 09397fa.
2013-07-11 19:09:53 +02:00
Gwenole Beauchesne
ed1bec1e43 plugins: clean-up video uploader helper.
Fix gst_vaapi_uploader_get_buffer() to not assign caps since they
were already negotiated beforehand, and they are not used from the
buffer in upstream elements.

Clean-up gst_vaapi_uploader_ensure_caps() to use the new image caps
represented as a GstVideoInfo.
2013-07-10 17:03:47 +02:00
Gwenole Beauchesne
419af50009 plugins: use GstVideoInfo in video uploader helper. 2013-07-10 17:03:47 +02:00
Gwenole Beauchesne
1cfe03ee52 plugins: allow creation of VA surfaces with explicit pixel format.
Adapt GstVaapiVideoMemory allocator to support creation of VA surfaces
with an explicit pixel format. This allows for direct rendering to
VA surface memory from a software decoder.
2013-07-10 17:03:47 +02:00
Gwenole Beauchesne
4ca7922f4b Use GstVideoInfo for video pools.
Get rid of GstCaps to create surface/image pool, and use GstVideoInfo
structures instead. Those are smaller, and allows for streamlining
libgstvaapi more.
2013-07-10 17:03:47 +02:00
Gwenole Beauchesne
09397fa0d8 plugins: port to new video format API. 2013-07-09 17:16:35 +02:00
Gwenole Beauchesne
40b6832b82 vaapisink: fix creation of GLX texture.
Fix creation of GLX texture, to not depend on the GstCaps video size that
could be wrong, especially in presence of frame cropping. So, use the size
from the source VA surfaces.

An optimization could be to reduce the texture size to the actual visible
size on screen. i.e. scale down the texture size to match the screen dimensions,
while preserving the VA surface aspect ratio. However, some VA drivers don't
honour that.
2013-07-08 18:54:15 +02:00
Gwenole Beauchesne
5bbab30859 plugins: add support for video cropping.
Add support for GstVideoCropMeta in GStreamer >= 1.0.x builds and gst-vaapi
specific meta information to hold video cropping details. Make the sink
support video cropping in X11 and GLX modes.
2013-07-08 18:52:56 +02:00
Sreerenj Balachandran
dbb58f4152 plugins: add helper functions to set the render rectangle.
Some video clips may have a clipping region that needs to propogate to
the renderer. These helper functions make it possible to attach that
clipping region, as a GstVaapiRectangle, the the video meta associated
with the buffer.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-07-08 18:52:56 +02:00
Sreerenj Balachandran
769f33cab2 vaapisink: expose the raw video formats in static caps template.
Expose all raw video formats in the static caps template since the
vaapisink is supporting raw data. We will get the exact set of formats
supported by the driver dynamically through the _get_caps() routine.

This also fixes an inconsistency wrt. GStreamer 0.10 builds.

https://bugzilla.gnome.org/show_bug.cgi?id=702178

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-06-27 14:01:26 +02:00
Gwenole Beauchesne
ece5cb2d83 vaapisink: add "use-glx" property for OpenGL rendering.
Now that VA/GLX capable buffers are generated by default on X11, thus
depending on a VA/GLX display, we stil want to use vaPutSurface() for
rendering since it is faster.

Anyway, OpenGL rendering in vaapisink was only meant for testing and
enabling "fancy" effects to play with. This has no real value. So,
disable OpenGL rendering by default.
2013-06-27 13:53:46 +02:00
Víctor Manuel Jáquez Leal
2fafbd7b64 plugins: try to allocate a GLX display first over an X11 one.
If the gstreamer-vaapi plug-in elements are built with GLX support, then
try to allocate a GstVaapiDisplayGLX first before resorting to a VA/X11
display next.

https://bugzilla.gnome.org/show_bug.cgi?id=701742
2013-06-27 10:19:37 +02:00
Zhao Halley
bbd7a130e2 vaapisink: fix build without VA/GLX support. 2013-06-05 11:09:37 +02:00
Gwenole Beauchesne
e712abba11 plugins: allow buffer mappings to GstVaapiSurfaceProxy.
Allow plain gst_buffer_map() interface to work with gstreamer-vaapi
video buffers, i.e. expose the underlying GstVaapiSurfaceProxy to the
caller. This is the only sensible enough thing to do in this mode as
the underlying surface pixels need to be extracted through an explicit
call to the gst_video_frame_map() function instead.

A possible use-case of this is to implement a "handoff" signal handler
to fakesink or identity element for further processing.
2013-06-05 11:09:37 +02:00
Gwenole Beauchesne
eb9dd361f8 plugins: silence check for direct-rendering mode in video memory.
Fix gst_vaapi_video_allocator_new() to silently check for direct-rendering
mode support, and not trigger fatal-criticals if either test surface or
image could not be created. Typical case: pixel format mismatch, e.g. NV12
supported by most hardware vs. I420 supported by most software decoders.
2013-06-05 11:09:37 +02:00
Gwenole Beauchesne
33f6415696 plugins: improve video memory flags safety checks.
On map, ensure we have GST_MAP_WRITE flags since this is only what we
support for now. Likewise, on unmap, make sure that the VA image is
unmapped for either read or write, while still committing it to the
VA surface if write was requested.
2013-06-05 11:09:37 +02:00
Gwenole Beauchesne
c12dc19b8b vaapisink: fix one-time initialization when display property is set.
Fix gst_vaapisink_ensure_display() to perform one-time initialization
tasks even if the `display' property was explicitly set.
2013-05-27 17:21:11 +02:00
Zhao Halley
dadf0ef978 uploader: fix memory leak in GStreamer 0.10 builds.
In GStreamer 0.10 builds, gst_vaapi_uploader_get_buffer() was used
but it exhibited a memory leak because the surface generated for the
GstVaapiVideoMeta totally lost its parent video pool. So, it was not
possible to release that surface back to the parent pool when the meta
gets released, and the memory consumption kept growing.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-05-23 19:22:48 +02:00
Gwenole Beauchesne
35eaa9e763 plugins: fix gst_vaapi_video_meta_new_from_pool().
Since GST_VAAPI_IS_xxx_VIDEO_POOL() was only testing for NULL and not
the underlying object type, the gst_vaapi_video_meta_new_from_pool()
was hereby totally broken. Fixed this regression by using the newly
provided gst_vaapi_video_pool_get_object_type() function.
2013-05-23 19:01:34 +02:00
Gwenole Beauchesne
e52ea35b11 plugins: cope with GST_VAAPI_IS_xxx() macros removal. 2013-05-23 19:01:34 +02:00
Gwenole Beauchesne
9535bb9950 plugins: cope with new GstVaapiMiniObject objects. 2013-05-07 18:19:03 +02:00
Gwenole Beauchesne
c43a2d497a decoder: add gst_vaapi_decoder_get_frame_with_timeout().
Add gst_vaapi_decoder_get_frame_with_timeout() helper function that will
wait for a frame to be decoded, until the specified timeout in microseconds,
prior to returning to the caller.

This is a fix to performance regression from 851cc0, whereby the vaapidecode
loop executed on the srcpad task was called to often, thus starving all CPU
resources.
2013-04-25 14:18:00 +02:00
Gwenole Beauchesne
d2bf4ffd97 vaapidecode: rework heuristics to detect decode timeout.
Rework heuristics to detect when downstream element ran into errors,
and thus failing to release any VA surface in due time for the current
frame to get decoded. In particular, recalibrate the render time base
when the first frame gets submitted downstream, or when there is no
timestamp that could be inferred.
2013-04-18 18:54:40 +02:00
Gwenole Beauchesne
851cc000c2 vaapidecode: rework GstVideoDecoder::handle_frame() with a task.
Rework GstVideoDecoder::handle_frame() to decode the current frame,
while possibly waiting for a free surface, and separately submit all
decoded frames from a task. This makes it possible to pop and render
decoded frames as soon as possible.
2013-04-18 18:46:01 +02:00
Gwenole Beauchesne
9d8bac313f plugins: use gst_object_unref() wherever applicable.
Use gst_object_unref() wherever applicable, e.g. objects derived from
GstElement, GstVideoPool, etc.
2013-04-18 17:16:43 +02:00
Gwenole Beauchesne
a0e587667a vaapipostproc: minor clean-ups.
Use g_clear_object() wherever appropriate and remove dead-code.
2013-04-17 10:58:04 +02:00