Commit graph

459 commits

Author SHA1 Message Date
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
Gwenole Beauchesne
3a762284a2 vaapivideomemory: use an image pool to cache objects.
Use an image pool to hold VA images to be used for downloads/uploads
of contents for the associated surface.

This is an optmization for size. So, instead of creating as many VA
images as there are buffers (then VA surfaces) allocated, we only
maintain a minimal set of live VA images, thus preserving memory
resources.
2014-07-24 06:55:26 +02:00
Gwenole Beauchesne
c3643b42a4 vaapivideomemory: forbid R/W mappings if non direct-rendering mode.
Disable read-write mappings if "direct-rendering" is not supported.
Since the ordering of read and write operations is not specified,
this would require to always download the VA surface on _map(), then
commit the temporary VA image back to the VA surface on _unmap().

Some SW decoding plug-in elements still use R/W mappings though.

https://bugzilla.gnome.org/show_bug.cgi?id=733242
2014-07-24 00:14:09 +02:00
Gwenole Beauchesne
f2ce28e4b7 vaapivideomemory: minor code clean-ups.
Fix error messages introduced in the previous commit for the _map()
imaplementation. Also use the new get_image_data() helper function
to determine the base pixels data buffer from a GstVaapiImage when
updating the video info structure from it.
2014-07-23 23:53:15 +02:00
Gwenole Beauchesne
9cad85a936 vaapivideomemory: add support for raw pixels mappings.
Allow raw pixels of the whole frame to be mapped read-only. i.e. in
cases where the buffer pool is allocated without VideoMeta API, thus
individual planes cannot be mapped.

This is initial support for Firefox >= 30.

https://bugzilla.gnome.org/show_bug.cgi?id=731886
2014-07-23 19:14:47 +02:00
Sreerenj Balachandran
9cb3acc813 vaapivideomemory: fix determination of the surface pool format.
While creating the vaapi video allocator, make sure the associated
surface pool has correct format instead of defaulting to NV12 video
format even though there is no direct rendering support.

https://bugzilla.gnome.org/show_bug.cgi?id=732691
2014-07-23 18:48:32 +02:00
Gwenole Beauchesne
b07de8a7f9 vaapivideomemory: fix association of surface to proxy.
Make sure to always update the VA surface pointer whenever the proxy
changes. This used to only work when the VA surface is written to, in
interop with SW element ("upload" feature), and this now fixes cases
when the VA surface is needed for reading, in interop with SW element
("download" feature).
2014-07-23 18:01:21 +02:00
Gwenole Beauchesne
dac20cecb4 plugins: expose I420 format for interop with SW elements.
Always expose I420 format by default when the VA surface could be
mapped for interoperability with non harware accelerated elements.
However, the default behaviour remains the auto-plugging of vaapi
elements, down to the sink.

Side effect: "direct-rendering" mode is also disabled most of the
times as plain memcpy() from uncached speculative write combining
memory is not going to be efficient enough.
2014-07-23 16:25:08 +02:00
Gwenole Beauchesne
dc6d529830 plugins: allow download capability to vaapidecode element.
Fix support for VA surface download capability in vaapidecode element
for GStreamer >= 1.2. This is a fix to supporting libva-vdpau-driver,
but also the libva-intel-driver while performing hardware accelerated
conversions from the native VA surface format (NV12) to the desired
output VA image format.

For instance, this fixes pipelines involving vaapidecode ! xvimagesink.

https://bugzilla.gnome.org/show_bug.cgi?id=733243
2014-07-22 19:06:52 +02:00
Lionel Landwerlin
334a0ca8bd vaapidecode: make decoder work with playbin
When playbin/decodebin builds the pipeline, it puts decoders and sinks
into different bins and forwards the queries from bins to bins. So in
the initials steps the pipeline is built iteratively by playbin and
looks like this :

[filesrc]

[filesrc] -> [typefind]

[filesrc] -> [typefind] -> [demuxer]

[filesrc] -> [typefind] -> [demuxer] -> [decoder]

At this point the decoder is asked for its SRC caps and it will make a
choice based on what gst_pad_peer_query_caps() returns. The problem is
that the caps returns at that point includes caps features like ANY,
essentially because playbin can plug in additional elements like
videoscale, videoconv or deinterlace.

This patch adds a another call to
gst_vaapi_find_preferred_caps_feature() when the decoder decides its
allocation, to make sure we asks the downstream elements when the
entire pipeline has been built.

https://bugzilla.gnome.org/show_bug.cgi?id=731645
2014-07-03 23:07:51 +02:00
Simon Farnsworth
4d2de696a9 vaapipostproc: don't let tmp_rect go out of scope.
A compiler change showed me that tmp_rect went out of scope before
it was used. Move it to the beginning of the function instead.

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

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
[added guards for GStreamer 0.10 builds]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-07-03 22:59:36 +02:00
Gwenole Beauchesne
700fd242cc build: fix for GStreamer 0.10. 2014-07-03 19:43:04 +02:00
Sreerenj Balachandran
cb9f98f0d5 decoder: h264: add support for NALU "alignment" optimization.
We can avoid scanning for start codes again if the bitstream is fed
in NALU chunks. Currently, we always scan for start codes, and keep
track of remaining bits in a GstAdapter, even if, in practice, we
are likely receiving one GstBuffer per NAL unit. i.e. h264parse with
"nal" alignment.

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

[use gst_adapter_available_fast() to determine the top buffer size]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-19 15:29:12 +02:00