Commit graph

414 commits

Author SHA1 Message Date
Sreerenj Balachandran
7f3795c9fb encode: Attach the codec-data to out caps only based on negotiated caps
Attach the codec_data to out_caps only if downstream needed.
For eg: h264 encoder doesn't need to stuff codec_data to the
src caps if the negotiated caps has a stream format of byte-stream.

https://bugzilla.gnome.org/show_bug.cgi?id=734902
2014-10-29 15:46:12 +02:00
Gwenole Beauchesne
0b6d6d956e vaapisink: clean-ups (indentation, drop unused variables). 2014-09-24 13:49:32 +02:00
Gwenole Beauchesne
48e5bcbe7b vaapisink: fix GstNavigation "key-press" / "key-release" events.
Fix arguments to XkbKeycodeToKeysym() for converting an X11 keycode
to a KeySym. In particular, there is no such Window argument. Also
make sure to check for, and use, the correct <X11/XKBlib.h> header
where that new function is defined. Otherwise, default to the older
XKeycodeToKeysym() function.
2014-09-24 13:49:06 +02:00
Gwenole Beauchesne
039244bf77 vaapisink: fix GstNavigation "mouse-move" event.
Really use the motion event coordinates to propagate the "mouse-move"
event to upper layer, instead of those from a button event. Those are
technically the same though.
2014-09-24 13:48:27 +02:00
Sreerenj Balachandran
33212d9634 vaapisink: implement the GstNavigation interface
This is useful for things like DVD menus, where key/mouse events
would need to be forwarded from the upstream sink element.

https://bugzilla.gnome.org/show_bug.cgi?id=711479
2014-09-16 14:25:40 +03:00
Simon Farnsworth
406aa37373 vaapipostproc: fix deinterlacing from non VA memory buffers.
When we copy a buffer because we're moving it into VA-API memory, we
need to copy flags. Otherwise, interlaced YUV buffers from a capture
source (e.g. V4L2) don't get flagged as interlaced.

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

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
[reversed order of gst_buffer_copy_into() flags to match <1.0 code]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-08-25 10:07:54 +02:00
Gwenole Beauchesne
b61d993e7d vaapipostproc: add support for GLTextureUploadMeta output.
This allows for vaapipostproc to be chained to the glimagesink element
for instance.

https://bugzilla.gnome.org/show_bug.cgi?id=735231
2014-08-22 18:52:23 +02:00
Gwenole Beauchesne
493337c4b1 vaapipostproc: add support for "download" capability.
Allow implicit conversions to raw video formats, while still keeping
VA surfaces underneath. This allows for chaining the vaapipostproc
element to a software-only element that takes care of maps/unmaps.
e.g. xvimagesink.

https://bugzilla.gnome.org/show_bug.cgi?id=720174
2014-08-22 18:20:46 +02:00
Gwenole Beauchesne
9ee46ab32e vaapipostproc: use pooled vaapi video meta.
Use pooled GstVaapiVideoMeta information, i.e. always allocate that on
video buffer allocation. Also optimize copy of additional metadata info
into the resulting video buffer: only copy the video cropping info and
the source surface proxy.

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

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
[fixed proxy leak, fixed double free on error, optimized meta copy]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-08-22 18:15:31 +02:00
Gwenole Beauchesne
92fcb38ba6 vaapipostproc: fix passthrough mode.
If no explicit output surface format is supplied try to keep the one
supplied through the sink pad caps. This avoids a useless copy, even
if things are kept in GPU memory.

This is a performance regression from git commit dfa70b9.
2014-08-22 15:54:32 +02:00
Sreerenj Balachandran
db111fe72a vaapipostproc: fix output buffer to have a GstVaapiVideoMemory.
https://bugzilla.gnome.org/show_bug.cgi?id=720311

[used new infrastructure through base decide_allocation() impl]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-08-22 15:54:32 +02:00
Gwenole Beauchesne
bc8e7a6734 vaapipostproc: enable advanced deinterlacing with same format.
If only advanced deinterlacing is requested, i.e. deinterlacing is
the only active algorithm to apply with source and output surface
formats being the same, then make sure to enable VPP processing.

Otherwise, allow fallback to bob-deinterlacing with simple rendering
flags alteration.
2014-08-22 15:54:32 +02:00
Sreerenj Balachandran
aa4d1f5a1e vaapivideomemory: avoid NULL pointer unref if GstVaapiImage creation failed.
https://bugzilla.gnome.org/show_bug.cgi?id=735156
2014-08-22 15:54:32 +02:00
Gwenole Beauchesne
c257c3232a plugins: fix memory leaks. 2014-08-22 15:54:32 +02:00
Gwenole Beauchesne
d0a9575fc2 plugins: factor out decide_allocation() hook.
Add a default decide_allocation() hook to GstVaapiPluginBase. The caps
feature argument can be used to force a bufferpool with a specific kind
of memory.
2014-08-22 15:54:32 +02:00
Gwenole Beauchesne
1ef5a3a200 plugins: allow bufferpool to not allocate vaapi video meta.
Add GST_VAAPI_VIDEO_BUFFER_POOL_ACQUIRE_FLAG_NO_ALLOC params flag that
can be used to disable early allocations of vaapi video metas on buffers,
thus delagating that to the bufferpool user.
2014-08-22 15:54:32 +02:00
Gwenole Beauchesne
038d56bdca plugins: re-indent all GstVaapiVideo* related source code. 2014-08-22 15:54:32 +02:00
Gwenole Beauchesne
dfa70b9e85 vaapipostproc: fix detection of output surface format changes.
Default to I420 format for output surfaces so that to match the usual
GStreamer pipelines. Though, internally, we could still opt for NV12
surface formats, i.e. default format=ENCODED is a hint for that, thus
delegating the decision to the VA driver.
2014-08-21 09:40:06 +02:00
Gwenole Beauchesne
913f2ef68c vaapipostproc: fix construction of allowed sink pad caps.
Fix construction of the set of caps allowed on the sink pad to filter
out unsupported raw video caps with GStreamer >= 1.2.
2014-08-21 09:39:40 +02:00
Gwenole Beauchesne
d82e6a8866 vaapipostproc: improve heuristics for detecting native VA surfaces.
Use the new gst_caps_has_vaapi_surface() helper function to detect
whether the sink pad caps contain native VA surfaces, or not, i.e.
no raw video caps.

Also rename is_raw_yuv to get_va_surfaces to make the variable more
explicit as we just want a way to differentiate raw video caps from
VA surfaces actually.
2014-08-21 09:39:09 +02:00
Gwenole Beauchesne
6d8c5221b2 vaapipostproc: disable discontinuity detection code.
The "discontinuity" tracking code, whereby lost frames are tentatively
detected, is inoperant if the sink pad buffer timestamps are not right
to begin with.

This is a temporary workaround until the following bug is fixed:
https://bugzilla.gnome.org/show_bug.cgi?id=734386
2014-08-21 09:38:53 +02:00
Gwenole Beauchesne
197001768b vaapipostproc: fix heuristic for detecting discontinuity.
In order to make the discontinuity detection code useful, we need to
detect the lost frames in the history as early as the previous frame.
This is because some VA implementations only support one reference
frame for advanced deinterlacing.

In practice, turn the condition for detecting new frame that is beyond
the previous frame from field_duration*2 to field_duration*3, i.e.
nothing received for the past frame and a half because of possible
rounding errors when calculating the field-duration either in this
element (vaapipostproc), or from the upstream element (parser element).

This is a regression introduced with commit faefd62.

https://bugzilla.gnome.org/show_bug.cgi?id=734135
2014-08-21 09:38:18 +02:00
Gwenole Beauchesne
7e9ac1cb98 plugins: fix detection of raw video caps.
Use the new gst_caps_has_vaapi_surface() helper function to better
detect raw video caps, and in particular those from RGB colorspace.

https://bugzilla.gnome.org/show_bug.cgi?id=734665
2014-08-21 09:36:39 +02:00
Gwenole Beauchesne
95d1826dca plugins: add helper for detecting VA surfaces in caps.
Introduce new gst_caps_has_vaapi_surface() helper function to detect
whether the supplied caps has VA surfaces. With GStreamer >= 1.2, this
implies a check for memory:VASurface caps features, and format=ENCODED
for earlier versions of GStreamer.
2014-08-21 09:36:36 +02:00
Sebastian Dröge
3b2e06be6c vaapidecode: start the decoder task again after finishing
This allows the element to accept data again after draining without
a hard reset or caps change happening in between.

https://bugzilla.gnome.org/show_bug.cgi?id=734616
2014-08-20 17:25:07 +02:00
Sebastian Dröge
2af44842c6 vaapidecode: unlock condition variables before shutting down the element
Otherwise threads might wait for them, causing the shutdown of the element
to deadlock on the streaming thread.

https://bugzilla.gnome.org/show_bug.cgi?id=734616
2014-08-20 17:25:07 +02:00
Sebastian Dröge
c551cc7cc3 vaapidecode: reset decoder_finish variable after stopping the decoder thread
Otherwise the element is not usable again after draining/EOS.

https://bugzilla.gnome.org/show_bug.cgi?id=734616
2014-08-20 17:25:04 +02:00
Sebastian Dröge
4ff4563a47 vaapidecode: don't try flushing the decoder instance if we didn't create one yet
This otherwise results in unnecessary error messages.

https://bugzilla.gnome.org/show_bug.cgi?id=734616
2014-08-20 17:24:59 +02:00
Gwenole Beauchesne
7ac501d026 build: fix with --no-undefined linker flags.
https://bugzilla.gnome.org/show_bug.cgi?id=729352
2014-08-01 11:05:01 +02:00
Changzhi Wei
c201f738fe vaapisink: add support for GstColorBalance interface.
https://bugzilla.gnome.org/show_bug.cgi?id=722390

[fixed channel names, simplified range factor, fixed memory leak]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-07-31 18:49:55 +02:00
Changzhi Wei
5a95cd5645 vaapisink: add support for colorbalance adjustment.
https://bugzilla.gnome.org/show_bug.cgi?id=722390

[fixed and simplified tracking of colorbalance value changes]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-07-31 18:48:46 +02:00
Gwenole Beauchesne
6e92a82138 vaapisink: improve installation of properties.
Simplify the creation and installation process of properties, by first
accumulating them into a g_properties[] array, and next calling into
g_object_class_install_properties().

Also add missing docs and flags to some properties.
2014-07-31 18:48:46 +02:00
Gwenole Beauchesne
d1f83b4570 vaapisink: code clean-ups.
Move code around in a more logical way. Introduce GST_VAAPISINK_CAST()
helper macro and use it wherever we know the object is a GstBaseSink or
any base class. Drop explicit initializers for values that have defaults
set to zero.
2014-07-31 18:48:46 +02:00
Gwenole Beauchesne
1824a80957 vaapisink: re-indent all GstVaapiSink related source code. 2014-07-31 18:48:46 +02:00
Gwenole Beauchesne
30c59af0a0 vaapisink: introduce separate backends.
Introduce new backends vtable so that to have clean separation between
display dependent code and common base code. That's a "soft" separation,
we don't really need dedicated objects.

https://bugzilla.gnome.org/show_bug.cgi?id=722248
2014-07-30 18:38:03 +02:00
Gwenole Beauchesne
24673dc3a4 vaapisink: drop unused "synchronous" mode.
Support for X11 "synchronous" mode was never implemented, and was only
to be useful for debugging. Drop that altogether, that's not going to
be useful in practice.

https://bugzilla.gnome.org/show_bug.cgi?id=733985
2014-07-30 18:35:31 +02:00
Gwenole Beauchesne
81b5ad85b5 vaapisink: drop unused variables.
Drop obsolete, and now unused, video_buffer_pool and video_buffer_size
variables. They got merged into the GstVaapiPluginBase object.
2014-07-30 18:35:31 +02:00
Gwenole Beauchesne
8298d64aad vaapisink: drop GLX rendering and fancy effects.
Rendering with GLX in vaapisink is kind of useless nowadays, including
OpenGL related fancy effects. Plain VA/GLX interfaces are also getting
deprecated in favor of EGL, or more direct buffer sharing with actual
GL textures.

Should testing of interop with GLX be needed, one could still be using
the modern cluttersink or glimagesink elements.

https://bugzilla.gnome.org/show_bug.cgi?id=733984
2014-07-30 18:35:31 +02:00
Holger Kaelberer
4b61cc3cd7 vaapisink: listen to window size changes on X11.
Allow dynamic changes to the window, e.g. performed by the user, and
make sure to refresh its contents, while preserving aspect ratio.

In practice, Expose and ConfigureNotify events are tracked in X11
display mode by default. This occurs in a separte event thread, and
this is similar to what xvimagesink does. Any of those events will
trigger a reconfiguration of the window "soft" size, subsequently
the render-rect when necessary, and finally _expose() the result.

The default of handle_events=true can be changed programatically via
gst_x_overlay_handle_events().

Thanks to Fabrice Bellet for rebasing the patch.

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

[dropped XInitThreads(), cleaned up the code a little]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-07-30 15:46:14 +02:00
Gwenole Beauchesne
528f486513 vaapidecode: decode and output all pending frames on normal EOS.
The gst_vaapidecode_decode_loop() function is called within a separate
task to fetch and output all frames that were decoded so far. So, if
the decoder_loop_status is forcibly set to EOS when _finish() is called,
then we are bound to exist the task without submitting the pending
frames.

If the downstream element error'ed out, then the gst_pad_push() would
propagate up an error and so we will get it right for cutting off
_finish() early in that case.

This is a regression from 6003596.

https://bugzilla.gnome.org/show_bug.cgi?id=733897
2014-07-29 15:47:46 +02:00
Matthew Waters
6003596e82 vaapidecode: properly return from decode loop on downstream errors.
Fixes a hang/race on shutdown where _decode_loop() had already completed
its execution and _finish() was waiting on a GCond for decode_loop()
to complete.  Also fixes the possible race where _finish() is called
but _decode_loop() endlessly returns before signalling completion
iff the decoder instance returns GST_FLOW_OK.

Found with: ... ! vaapidecode ! {glimagesink,cluttersink}

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

[factored out GST_VIDEO_DECODER_STREAM_UNLOCK() call]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-07-29 10:21:02 +02:00
Gwenole Beauchesne
b8601cf4c5 vaapisink: fix GstVideoOverlay::expose() implementation.
Now that we always track the currently active video buffer, it is
not necessary to automatically increase its reference since this is
implicitly performed in ::show_frame() through the get_input_buffer()
helper from GstVaapiPluginBase class.

This is a regression from a26df80.
2014-07-28 18:34:13 +02:00
Gwenole Beauchesne
0607898019 vaapidecode: simplify bufferpool configuration.
Rework the logics behind the configuration of an adequate bufferpool,
especially when OpenGL meta or additional capsfeatures are needed.

Besides, for GStreamer >= 1.4, the first capsfeatures that gets matched,
and that is not system memory, is now selected by default.
2014-07-28 18:34:13 +02:00
Gwenole Beauchesne
c5102c72af vaapidecode: fix auto-plugging of vaapisink element.
Make sure to propagate memory:VASurface capsfeature to srcpad caps
only for GStreamer >= 1.5 as the plug-in elements in GStreamer 1.4
core currently miss additional patches available in 1.5-git (1.6).

This is a temporary workaround.
2014-07-28 18:34:13 +02:00
Gwenole Beauchesne
aa2fab43bd vaapisink: allow a specific view component to be displayed.
If a multiview stream is decoded, multiple view components are submitted
as is downstream. It is the responsibility of the sink element to display
the required view components. By default, always select the frame buffer
that matches the view-id of the very first frame to be displayed.

However, introduce a "view-id" property to allow the selection of a
specific view component of interest to display.
2014-07-28 10:29:57 +02:00
Gwenole Beauchesne
a26df804a6 vaapisink: always keep the last displayed buffer around.
Always record the VA surface that is currently being rendered, no matter
the fact we are using texturedblit or overlay. That's because in some
occasions, we need to refresh or resize the displayed contents based on
new events. e.g. user-resized window.

Besides, it's simpler to track the last video buffer in GstVaapiSink than
through the base sink "last-sample".
2014-07-28 10:12:49 +02:00
Gwenole Beauchesne
5ffa82b64c vaapisink: add support for "display-name" property.
Add a "display-name" property to vaapisink so that the end user could
select the desired output. Keep "display-name" in-line with the existing
"display" (GstVaapiDisplayXXX type).

So, for X11 or GLX, the "display-name" is the usual display name as we
know for XOpenDisplay(); for Wayland, the "display-name" is the name used
for wl_display_connect(); and for DRM, the "display-name" is actually the
DRI device name.

https://bugzilla.gnome.org/show_bug.cgi?id=722247
2014-07-25 17:36:12 +02:00
Gwenole Beauchesne
cafb25c4d1 vaapidecode: add support for VideoAlignment bufferpool option.
Always add VideoAlignment bufferpool option if the downstream element
expects its own pool to be used but does not offer it through a proper
propose_allocation() implementation for instance, and that the ALLOCATION
query does not expose the availability of the Video Meta API.

This fixes propagation of video buffer stride information to Firefox.
2014-07-25 15:52:06 +02:00
Gwenole Beauchesne
1d1be0ae76 vaapivideomemory: always prefer native VA surface formats.
Make sure to always prefer native internal formats for the VA surfaces
that get allocated. Also disable "direct-rendering" mode in this case.

This is needed so that to make sure that anything that gets out of the
decoder, or anything that gets into the encoder, is in native format
for the hardware, and thus the driver doesn't need to perform implicit
conversions in there. Interop with SW elements is still available with
fast implementations of VA imaging APIs.
2014-07-25 15:44:58 +02:00
Gwenole Beauchesne
e0e869f536 vaapivideomemory: disallow memory shares across buffers, use a copy.
Forbid shares of GstMemory instances, and rather make copy of it. This
effectively copies the GstMemory structure and enclosed metadata, but
this does not copy the VA surface contents itself. It should though.

This fixes preroll and makes sure to not download garbage for the first
frame when a SW rendering sink is used.
2014-07-24 11:58:29 +02:00