Commit graph

241 commits

Author SHA1 Message Date
Víctor Manuel Jáquez Leal
ee0855dc65 vaapidecode: log flow error name
https://bugzilla.gnome.org/show_bug.cgi?id=744387
2015-02-18 11:21:35 +02:00
Olivier Crete
aaf4165819 vaapidecode: Emit error GstMessage when returning a GST_FLOW_ERROR
This is required in GStreamer, elements should never return
GST_FLOW_ERROR without posting an ERROR message on the bus.

https://bugzilla.gnome.org/show_bug.cgi?id=744620
2015-02-18 11:19:26 +02:00
Olivier Crete
fc7e6b19fd vaapidecode: Check the condition after taking the lock
Otherwise the condition could become true before the lock
is taken and the g_cond_signal() could be called
before the g_cond_wait(), so the g_cond_wait() is never
awoken.

https://bugzilla.gnome.org/show_bug.cgi?id=740645
2015-02-04 18:34:59 +02:00
Michael Olbrich
b7d7a0197d vaapidecode: don't print an error message for GST_FLOW_FLUSHING 2015-01-27 14:50:12 +02:00
Gwenole Beauchesne
b8744f5b9a vaapidecode: commit updated srcpad caps to base plugin.
Make sure that the GstVaapiPluginBase instance receives the new src
pad caps whenever they get updated from within the GstVaapiDecoder
decode routines.

This also ensures that downstream elements receive correctly sized
SW decoded buffers if needed.

https://bugs.tizen.org/jira/browse/TC-114
2015-01-15 17:13:52 +01:00
Gwenole Beauchesne
0777f357aa vaapidecode: always reset decoder on ::set_format().
Split GstVideoDecoder::set_format() handler to first update the sink
pad caps and reset the active VA decoder instance based on those, and
then update the src pad caps whenever possible, e.g. when the caps
specify a valid video resolution.
2015-01-15 17:13:52 +01:00
Gwenole Beauchesne
a4d88db0fd plugins: preserve framerate when updating src caps video format.
In the current implementation, gst_video_info_set_format() would reset
the whole GstVideoInfo structure first, prior to setting video format
and size. So, coleteral information like framerate or pixel-aspect-
ratio are lost.

Provide and use a unique gst_video_info_change_format() for overcome
this issue, i.e. only have it change the format and video size, and
copy over the rest of the fields.

https://bugzilla.gnome.org/show_bug.cgi?id=734665
2014-11-18 18:39:32 +01:00
Gwenole Beauchesne
d1b7dc21f8 vaapidecode: only expose supported profiles when needed.
JPEG and VP8 codecs do not really support the concept of "profile". So,
don't try to expose any set that wouldn't be supported by jpegparse, or
ivfparse for instance.

https://bugzilla.gnome.org/show_bug.cgi?id=739713
https://bugzilla.gnome.org/show_bug.cgi?id=739714
2014-11-14 15:26:07 +01:00
Sreerenj Balachandran
b58bdd1a12 vaapidecode: Expose the supported profiles as caps to upstream
This will allows the playbin to fallback to Software Decoder
if the Hardware Decoder does not support a particular profile.

https://bugzilla.gnome.org/show_bug.cgi?id=730997
2014-10-29 15:46:47 +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
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
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
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
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
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
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
Matthieu Bouron
ead38a4d77 vaapidecode: do not discard video info props when the format changed.
gst_video_info_set_format() does not preserve video info properties. In
order to keep important information in the caps such as interlace mode,
framerate, pixel aspect ratio, ... we need to manually copy back those
properties after setting the new video format.

https://bugzilla.gnome.org/show_bug.cgi?id=722276
2014-06-18 13:59:09 +02:00
Matthew Waters
3fbef25e13 vaapidecode: plug a memory leak.
It can happen that there is a pool provided that does not advertise
the vappivideometa. We should unref that pool before using our own.

Discovered with vaapidecode ! {glimagesink,cluttersink}

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

[fixed compilation by adding the missing semi-colon]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-18 13:58:49 +02:00
Gwenole Beauchesne
abfb5dd06c vaapidecode: parse source data until a frame is obtained.
Parse any pending data until a complete frame is obtained. This is a
memory optimization to avoid expansion of video packets stuffed into
the GstAdapter, and a fix to EOS condition to detect there is actually
pending data that needs to be decoded, and subsequently output.

https://bugzilla.gnome.org/show_bug.cgi?id=731831
2014-06-18 13:47:36 +02:00
Sreerenj Balachandran
ee6d1b7bd1 build: fix conditional compilation of VP8 decoder.
https://bugzilla.gnome.org/show_bug.cgi?id=729170

[added check for VASliceParameterBufferBase fields]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-05-09 14:41:52 +02:00
Zhao, Halley
029bae0b6a Add initial VP8 decoder.
https://bugzilla.gnome.org/show_bug.cgi?id=722761

[complete overhaul, fixed support for resolution changes]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-04-18 20:03:44 +02:00
Gwenole Beauchesne
6bf3c1863c legal: update copyright notice dates. 2014-01-22 19:02:35 +01:00
Matthieu Bouron
a674d9eff2 vaapidecode: query downstream caps features like GLTextureUploadMeta.
Fix vaapidecode to correctly report caps features downstream, when
a custom pipeline is built manually.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-14 19:14:41 +01:00
Matthieu Bouron
cb81acd48c vaapidecode: add system memory caps to template caps.
Since vaapidecode provides buffer that can be mapped as regular memory,
those caps should be added to the template caps. That only applies to
GStreamer >= 1.2.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-14 19:14:41 +01:00
Wind Yuan
d2f6274f31 vaapidecode: fix hang on SIGINT.
vaapidecode hangs when pipeline is stopped without any EOS, e.g. when
<Ctrl>+C is pressed, thus causing the srcpad task to keep running and
locked. This fixes a deadlock on state change from PAUSED to READY.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-01-14 19:14:41 +01:00
Gwenole Beauchesne
c5581298fb display: don't use GstCaps for decode or encode profiles list.
Replace gst_vaapi_display_get_{decode,encode}_caps() APIs with more
more convenient APIs that return an array of GstVaapiProfile instead
of GstCaps: gst_vaapi_display_get_{decode,encode}_profiles().
2013-12-20 17:16:58 +01:00
Gwenole Beauchesne
b324fc6add plugins: factor out pad caps. 2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
01a3fc44c0 plugins: factor out video context sharing code. 2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
e5f066b719 plugins: factor out GstImplementsInterface. 2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
6f2dfb71e6 plugins: factor out display creation process.
Move common VA display creation code to GstVaapiPluginBase, with the
default display type remaining "any". Also add a "display-changed"
hook so that subclasses could perform additional tasks when/if the
VA display changed, due to a new display type request for instance.

All plug-ins are updated to cope with the new internal APIs.
2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
7e58d60854 plugins: add new base object, store display in there.
Introduce a new GstVaapiPluginBase object that will contain all common
data structures and perform all common tasks. First step is to have a
single place to hold VA displays.

While we are at it, also make sure to store and subsequently release
the appropriate debug category for the subclasses.
2013-12-18 16:38:57 +01:00
Gwenole Beauchesne
c2eabc17dd plugins: allow builds without GLX enabled for GStreamer 1.2.
Don't try to build GLTextureUploadMeta related code if GLX is not
enabled during GStreamer >= 1.2 builds.
2013-12-11 15:30:51 +01:00
Matthieu Bouron
6b6c10d94d plugins: request GLTextureUpload meta on buffers in the buffer pool.
Requesting the GLTextureUpload meta on buffers in the bufferpool
prevents such metas from being de-allocated when buffers are released
in the sink.

This is particulary useful in terms of performance when using the
GLTextureUploadMeta API since the GstVaapiTexture associated with
the target texture is stored in the meta.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-12-11 15:30:51 +01:00
Gwenole Beauchesne
7a33165436 plugins: fix reference leaks of VA display objects.
Fix GstElement::set_context() implementation for all plug-in elements
to avoid leaking an extra reference to the VA display, thus preventing
correct cleanup of VA resources in GStreamer 1.2 builds.
2013-11-29 14:02:52 +01:00
Gwenole Beauchesne
15519ebe3d legal: add per-file authorship information.
Credit original authors on a per-file basis as we cannot expect people
to know all country-specific rules, or bother browsing through the git
history.
2013-11-22 06:39:15 +01:00
Gwenole Beauchesne
a6436f27d5 vaapidecode: fix decoder flush.
There are situations where gst_video_decoder_flush() is called, and
this subsequently produces a gst_video_decoder_reset() that kills the
currently active GstVideoCodecFrame. This means that it no longer
exists by the time we reach GstVideoDecoder::finish() callback, thus
possibly resulting in a crash if we assumed spare data was still
available for decode (current_frame_size > 0).

Try to honour GstVideoDecoder::reset() behaviour from GStreamer 1.0
that means a flush, thus performing the actual operations there like
calling gst_video_decoder_have_frame() if pending data is available.
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
af4785b722 vaapidecode: fix dead-locks with decoder task.
Review all interactions between the main video decoder stream thread
and the decode task to derive a correct sequence of operations for
decoding. Also avoid extra atomic operations that become implicit under
the GstVideoDecoder stream lock.
2013-11-21 11:08:23 +01:00
XuGuangxin
6e85f08e33 vaapidecode: fix hard reset for seek cases.
Fix hard reset for seek cases by flushing the GstVaapiDecoder queue
and completely purge any decoded output frame that may come out from
it. At this stage, the GstVaapiDecoder shall be in a complete clean
state to start decoding over new buffers.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-21 11:08:23 +01:00
XuGuangxin
367944ba32 vaapidecode: drop decode timeout, always wait for a free surface.
vaapidecode used to wait up to one second past the expected time of
presentation for the last decoded frame. This is not realistic in
practice when it comes to video pause/resume. Changed behaviour to
unconditionnally wait for a free VA surface prior to continuing the
decoding. The decode task will continue pushing the output frames to
the downstream element while also reporting errors at the same time
to the main thread.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
7e8470e1ec vaapidecode: fix srcpad caps for GStreamer 1.2.
The srcpad caps exposed for GStreamer 1.2 were missing any useful info
like framerate, pixel-aspect-ratio, interlace-mode et al. Not to mention
that it relied on possibly un-initialized data. Fix srcpad caps to be
initialized from a sanitized copy of GstVideoDecoder output state caps.

Note: the correct way to expose the srcpad caps triggers an additional
issue in core GStreamer auto-plugging capabilities as the correct caps
to be exposed should be format=ENCODED with memory:VASurface caps feature
at the minimum. In some situations, we could determine the underlying
VA surface format, but this is not always possible. e.g. cases where it
is not allowed to expose the underlying VA surface data, or when the
VA driver implementation cannot actually provide such information.
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
d556c0a37a plugins: streamline VA formats exposed in caps to a realistic set.
Currently, the decoder only supports YUV 4:2:0 output. So, expose the
output formats for GStreamer 1.2 in caps to a realistic subset. This
means NV12, I420 or YV12 but also ENCODED if we cannot determine the
underlying VA surface format, or if it is actually not allowed to get
access to the surface contents.
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
b4eb1dcd42 plugins: expose the expected format for GstVideoGLTextureUploadMeta.
Fix vaapidecode srcpad caps to only expose RGBA video format for the
meta:GstVideoGLTextureUploadMeta feature. That's only what is supported
so far. Besides, drop this meta from the vaapisink sinkpad caps since
we really don't support that for rendering.

https://bugzilla.gnome.org/show_bug.cgi?id=711828
2013-11-21 11:08:23 +01:00
Gwenole Beauchesne
393e86e3d0 plugins: add helper function to disable deinterlacing in caps.
Add gst_caps_set_interlaced() helper function that would reset the
interlace-mode field to "progressive" for GStreamer >= 1.0, or the
interlaced field to "false" for GStreamer 0.10.
2013-10-04 19:30:36 +02:00
Víctor Manuel Jáquez Leal
395260f24b plugins: hanle the context query in any pad.
Also this patch simplifies the code, since now the query is common for the
decoder and the sink.

https://bugzilla.gnome.org/show_bug.cgi?id=709200
2013-10-01 18:41:16 +02:00
Víctor Manuel Jáquez Leal
41c4da5571 plugins: add support for GstVideoGLTextureUploadMeta.
If the allocation meta GST_VIDEO_GL_TEXTURE_UPLOAD_META_API_TYPE is
requested, and more specifically under a GLX configuration, then add
the GstVideoGLTextureUploadMeta to the output buffer.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:17:20 +02:00
Sreerenj Balachandran
8fe3bb0b14 plugins: add support for GstCaps features.
Move VA video buffer memory from "video/x-surface,type=vaapi" format,
as expressed in caps, to the more standard use of caps features. i.e.
add "memory:VASurface" feature attribute to the associated caps.

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

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:17:16 +02:00
Víctor Manuel Jáquez Leal
21aa850eb4 plugins: improve ::query() debugging messages.
Fix gst_vaapidecode_query() to correctly display the query type name,
instead of randomly displaying that we shared the underlying display.
Also add debug info for the GstVaapiSink::query() handler, i.e. the
supplied query type name actually.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-09-27 14:17:12 +02:00
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
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
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
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
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
945516c9c7 vaapipostproc: port to GStreamer 1.0.
Add support for interlaced streams with GStreamer 1.0 too. Basically,
this enables vaapipostproc, though it is not auto-plugged yet. We also
make sure to reply to CAPS queries, and happily handle CAPS events.
2013-04-17 10:18:45 +02:00
Gwenole Beauchesne
0bd929dfa2 surfaceproxy: drop user-data support from GstVaapiSurfaceProxy.
Drop user-data support from GstVaapiSurfaceProxy. Rather make it explicit
to call some user-provided function when the surface proxy is released.
2013-04-16 18:54:37 +02:00
Gwenole Beauchesne
1790823ed4 decoder: make gst_vaapi_decoder_get_codec_state() return the original state.
Make gst_vaapi_decoder_get_codec_state() return the original codec state,
i.e. make the GstVaapiDecoder object own the return state so that callers
that want an extra reference to it would just gst_video_codec_state_ref()
it before usage. This aligns the behaviour with what we had before with
gst_vaapi_decoder_get_caps().

This is an ABI incompatible change, library major version was bumped from
previous release (0.5.2).
2013-04-15 13:58:58 +02:00
Gwenole Beauchesne
1ed3df201e vaapidecode: submit all decoded frames before decoding a new one.
Make sure to purge all pending frames that were already decoded prior
to decoding a new one. This helps release VA surfaces as early as
possible.
2013-04-10 14:58:17 +02:00
Gwenole Beauchesne
ead7ec2f43 vaapidecode: reply to CAPS queries.
Handle GST_QUERY_CAPS, which is the GStreamer 1.0 mechanism to retrieve
the set of allowed caps, i.e. it works similar to GstPad::get_caps().

This fixes fallback to SW decoding if no HW decoder is available.
2013-04-10 14:58:17 +02:00
Gwenole Beauchesne
1b500dee54 Allow build against either GStreamer API (0.10 or 1.0).
Introduce a new configure option --with-gstreamer-api that determines
the desired GStreamer API to use. By default, GStreamer 1.0 is selected.
Also integrate more compatibility glue into gstcompat.h and plugins.
2013-04-10 14:58:17 +02:00
Sreerenj Balachandran
551ac4c5b3 plugins: use new video buffer pools.
Use new GstVaapiVideoBufferPool to maintain video buffers. Implement
GstBaseSink::propose_allocation() to expose that pool to upstream
elements; and also implement GstVideoDecoder::decide_allocation() to
actually use that pool (from downstream), if any, or create one.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-04-10 14:58:16 +02:00
Sreerenj Balachandran
38d84d968e plugins: initial port to GStreamer 1.0.
Port vaapidecode and vaapisink plugins to GStreamer API >= 1.0. This
is rather minimalistic so that to test the basic functionality.

Disable vaapiupload, vaapidownload and vaapipostproc plugins. The latter
needs polishing wrt. to GStreamer 1.x functionality and the former are
totally phased out in favor of GstVaapiVideoMemory map/unmap facilities,
which are yet to be implemented.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-04-10 14:58:16 +02:00
Gwenole Beauchesne
cadc42eafe vaapidecode: expose the exact set of supported HW decoders.
Don't return static caps that don't mean anything for the underlying codecs
that are actually supported for decoding. i.e. always allocate a VA display
and retrieve the exact set of HW decoders available. That VA display may be
re-used later on during negotiation through GstVideoContext "prepare-context".

This fixes fallback to SW decoding if no HW decoder is available.
2013-04-03 15:10:19 +02:00
Gwenole Beauchesne
140fa66be3 plugins: integrate GstVaapiVideoMeta from libgstvaapi.
Move GstVaapiVideoMeta from core libgstvaapi decoding library to the
actual plugin elements. That's only useful there. Also inline reference
counting code from GstVaapiMiniObject.
2013-03-26 10:33:27 +01:00
Gwenole Beauchesne
63fedf6767 plugins: drop gstvaapipluginbuffer.[ch] helper files.
Move all gst_vaapi_video_buffer_new*() helpers from gstvaapipluginbuffer.[ch]
to gstvaapivideobuffer.[ch], and drop the obsolete files.
2013-03-21 18:16:14 +01:00
Gwenole Beauchesne
2dcc9f19da plugins: use modern GstElement metadata information.
Use gst_element_class_set_static_metadata() from GStreamer 1.0, which
basically is the same as gst_element_class_set_details_simple() in
GStreamer 0.10 context.
2013-03-20 18:43:35 +01:00
Gwenole Beauchesne
7fd648b8b0 plugins: move up interfaces (cosmetics).
Move GstImplementsInterface and GstVideoContext support functions up
so that to keep a clear separation between the plugin element and its
interface hooks.
2013-03-20 18:35:01 +01:00
Gwenole Beauchesne
41dcd82e2f vaapidecode: handle decode-only frames.
Decode-only frames may not have a valid surface proxy. So, simply discard
them gracefully, i.e. don't create meta data information. GstVideoDecoder
base class will properly handle this case and won't try to push any buffer
to downstream elements.
2013-01-30 16:38:48 +01:00
Sreerenj Balachandran
0847b3888d vaapidecode: add support for post-seek semantics reset.
Implement GstVideoDecoder::reset() as a destruction of the VA decoder
and the creation of a new VA decoder.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-01-30 11:00:19 +01:00
Gwenole Beauchesne
0c99f351fc legal: fix year for some copyright notices (2013). 2013-01-29 14:37:02 +01:00
Gwenole Beauchesne
236e8833d1 vaapidecode: handle EOS events.
Flush all decoded frames to downstream when EOS is received. This is
performed by implementing GstVideoDecoder::finish() hook.
2013-01-17 18:40:36 +01:00
Gwenole Beauchesne
cbcdc3bfae vaapidecode: split gvd_handle_frame() into decode/push frames.
Split GstVideoDecoder::handle_frame() implementation into two functions:
(i) one for decoding the provided GstVideoCodecFrame and (ii) another one
for purging all decoded frames and submit them downstream.
2013-01-17 18:39:22 +01:00
Gwenole Beauchesne
a00ae0918a plugins: cope with new GstVaapiVideoMeta API.
Update plugin elements with the new GstVaapiVideoMeta API.

This also fixes support for subpictures/overlay because GstVideoDecoder
generates a sub-buffer from the GstVaapiVideoBuffer. So, that sub-buffer
is marked as read-only. However, when comes in the textoverlay element
for example, it checks whether the input buffer is writable. Since that
buffer read-only, then a new GstBuffer is created. Since gst_buffer_copy()
does not preserve the parent field, the generated buffer in textoverlay
is not exploitable because we lost all VA specific information.

Now, with GstVaapiVideoMeta information attached to a standard GstBuffer,
all information are preserved through gst_buffer_copy() since the latter
does copy metadata (qdata in this case).
2013-01-05 18:02:31 +01:00
Gwenole Beauchesne
5788d8ae45 vaapidecode: fix calculation of the time-out value.
Fix calculation of the time-out value for cases where no VA surface is
available for decoding. In this case, we need to wait until downstream
sink consumed at least one surface. The time-out was miscalculated as
it was always set to <current-time> + one second, which is not suitable
for streams with larger gaps.
2013-01-03 13:10:33 +01:00
Gwenole Beauchesne
3d3f37c558 vaapidecode: use GST_ERROR to print error messages. 2013-01-02 13:13:45 +01:00
Gwenole Beauchesne
0ff8556f65 vaapidecode: avoid double release of frame on error.
Don't call gst_video_decoder_drop_frame() if gst_video_decoder_finish_frame()
was already called before and it returned an error. In that case, we were
releasing the frame again, thus leading to a "double-free" condition.
2013-01-02 13:13:42 +01:00
Gwenole Beauchesne
8c2d9bcd24 decoder: maintain decoded frames as GstVideoCodecFrame objects.
Maintain decoded surfaces as GstVideoCodecFrame objects instead of
GstVaapiSurfaceProxy objects. The latter will tend to be reduced to
the strict minimum: a context and a surface.
2012-12-18 15:31:52 +01:00
Gwenole Beauchesne
039eb3bb6c vaapidecode: output all decoded frames as soon as possible.
Make sure to push all decoded frames downstream as soon as possible.
This makes sure we don't need to wait for a new frame to be ready to
be decoded before receiving new decoded frames.

This also separates the decode process and the output process. The latter
could be moved to a specific GstTask later on.
2012-12-18 15:31:52 +01:00
Sreerenj Balachandran
cb3c0a3e8f vaapidecode: use gst_vaapi_decoder_get_codec_state().
Directly use the GstVideoCodecState associated with the VA decoder
instead of parsing caps again.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
cfdc5c5b43 vaapidecode: use more standard helpers.
Use g_clear_object() [glib >= 2.28] and gst_caps_replace() helper functions
in more places.
2012-12-18 15:31:51 +01:00
Sreerenj Balachandran
9127f17d81 vaapidecode: move to GstVideoDecoder base class.
Make vaapidecode derive from the standard GstVideoDecoder base element
class. This simplifies the code to the strict minimum for the decoder
element and makes it easier to port to GStreamer 1.x API.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
1130a46837 surfaceproxy: port to GstVaapiMiniObject.
GstVaapiSurfaceProxy does not use any particular functionality from
GObject. Actually, it only needs a basic object type with reference
counting.

This is an API and ABI change.
2012-12-18 15:31:50 +01:00
Rob Bradford
4bcfa3fe0a vaapidecode: adopt non-deprecrated glib locking primitive pattern.
The use of heap allocated GMutex/GCond is deprecated. Instead place them
inside the structure they are locking.

These changes switch to use g_mutex_init/g_cond_init rather than the heap
allocation functions.

Because we cannot test for a NULL pointer for the GMutex/GCond we must
initialise inside the GObject _init function and clear inside the _finalize
which is guaranteed to only be called once and after the object is no longer
in use.
2012-10-17 15:21:00 +02:00
Gwenole Beauchesne
7d1b583d91 vaapidecode: fix compiler warnings.
Don't care of the return value for gst_vaapi_decoder_put_buffer()
during destruction of the element. Don't print out (uninitialised)
error code when allocation of video buffer failed.
2012-10-17 14:52:35 +02:00
Wind Yuan
da1e4e3918 vaapidecode: flush buffers when receiving EOS.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-10-09 14:01:15 +02:00
Gwenole Beauchesne
e6047734b3 plugins: include "sysdeps.h" instead of "config.h". 2012-09-12 13:41:47 +02:00
Gwenole Beauchesne
5549dbc3c0 vaapidecode: don't reset decoder if codec type is the same.
Reset, i.e. destroy then create, the decoder in _setcaps() handler only
if the underlying codec type actually changed. This makes it possible
to be more tolerant with certain MPEG-2 streams that get parsed to
form caps that are compatible with the previous state but minor changes
to "codec-data".
2012-09-11 17:08:47 +02:00
Gwenole Beauchesne
2b71db3059 vaapidecode: simplify codec lookup from caps.
Add new gst_vaapi_codec_from_caps() helper to determine codec type from
the specified caps. Don't globally expose this function since this is
really trivial and only used in the vaapidecode element.
2012-09-11 17:08:47 +02:00
Gwenole Beauchesne
9afe700005 vaapidecode: improve "no free surface" conditions.
Previously, vaapidecode would wait up to one second until a free surface
is available, or it aborts decoding. Now, vaapidecode waits until the
last decoded surface was to be presented, plus one second. Besides, end
times are now expressed relative to the monotonic clock.
2012-09-11 17:08:47 +02:00
Gwenole Beauchesne
6c19849cd2 decoder: propagate buffer duration downstream. 2012-09-11 17:08:47 +02:00
Gwenole Beauchesne
a8624d6a79 plugins: fix build in strict ISO C mode. 2012-09-07 16:11:12 +02:00
Philip Lorenz
8bcfeb5a1c vaapidecode: acquire lock only if the mutex exists.
When playback stops the GstVaapiDecode object is reset into a clean
state. However, surfaces may still be referenced by library users and
unreferencing them after the reset triggers an access to an unset mutex.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-09-07 13:54:30 +02:00
Gwenole Beauchesne
4a1127dd7c vaapisink: drop obsolete GstVaapiVideoSink interface.
This interface was deprecated since 0.3.x series when the GstVideoContext
interface was added to the main GStreamer APIs.
2012-08-29 13:20:17 +02:00
Gwenole Beauchesne
cff117b54d plugins: fix display type selection and propagation.
If vaapisink is in the GStreamer pipeline, then we shall allocate a
unique GstVaapiDisplay and propagate it upstream. i.e. subsequent
queries from vaapidecode shall get a valid answer from vaapisink.
2012-07-25 14:52:05 +02:00
Gwenole Beauchesne
8ef490a3de videobuffer: drop deprecated functions.
Move video buffer creation routines to plugin elements. That exclusively
uses *_typed_new*() variants.
2012-07-24 16:13:31 +02:00
Gwenole Beauchesne
753a56e9a1 pluginutils: improve automatic display type selection. 2012-07-24 15:57:57 +02:00
Gwenole Beauchesne
7a0382130f configure: drop check for --enable-vaapi-glx.
This flag is obsolete. It was meant to explicitly enable/disable VA/GLX API
support, or fallback to TFP+FBO if this API is not found. Now, we check for
the VA/GLX API by default if --enable-glx is set. If this API is not found,
we now default to use TFP+FBO.

Note: TFP+FBO, i.e. using vaPutSurface() is now also a deprecated usage and
will be removed in the future. If GLX rendering is requested, then the VA/GLX
API shall be used as it covers most usages. e.g. AMD driver can't render to
an X pixmap yet.
2012-07-24 15:57:57 +02:00
Gwenole Beauchesne
9d440fafb3 Drop all references to USE_CODEC_PARSERS. 2012-07-19 17:30:36 +02:00
Gwenole Beauchesne
7f47ac3bea Drop FFmpeg-based decoders.
GStreamer codecparsers-based decoders are the only supported decoders now.
Though, FFmpeg decoders are still available in gstreamer-vaapi 0.3.x series.
2012-07-19 17:30:36 +02:00
Javier Jardón
5ff0837b32 plugins: use g_clear_object() wherever applicable.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-07-19 15:19:17 +02:00
Gwenole Beauchesne
50e40a4c87 plugins: add support for GstImplementsInterface. 2012-07-19 11:45:19 +02:00
Javier Jardón
2594aadb0e plugins: use G_DEFINE_TYPE_* instead of deprecated GST_BOILERPLATE_*.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-07-19 11:25:15 +02:00
Javier Jardón
90d82ab7e1 plugins: do not use deprecated core GStreamer symbols.
Bump GStreamer required version to 0.10.14, needed for
gst_element_class_set_details_simple().

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-07-19 10:56:56 +02:00
Wind Yuan
75e8a7d6f8 Add initial JPEG decoder.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-04-11 19:38:12 +02:00
Wind Yuan
5d75cc4c6f vaapidecode: fix VA display type.
Fix typo whereby plain VADisplay type was used instead of the GstVaapiDisplay
wrapper.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-04-10 15:19:56 +02:00
Gwenole Beauchesne
68d1b7e525 vaapidecode: fix includes when compiling for a single API. 2012-04-10 15:19:56 +02:00
Gwenole Beauchesne
84b5fc5e58 vaapidecode: report unsupported codec profiles.
Try to gracefully abort when the HW does not support the requested
profile. There is no fallback unless profiles are correctly parsed
and matched through caps beforehand.
2012-04-02 16:11:22 +02:00
Wind Yuan
d43f3dc50a decode: delay NEWSEGMENT event if vaapidecode element was not linked.
Rationale: playbin2 links all elements at run-time. Once vaapidecode
is created and a NEWSEGMENT event arrives, downstream element may not
be ready yet. So, delay this event until next element is chained in,
otherwise basesink could output "Received buffer without a new-segment.
Assuming timestamps start from 0".

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-03-22 14:33:17 +01:00
Holger Kaelberer
0d0cff695f vaapidecode: propagate interlaced and TFF properties downstream.
Propagate "interlaced" caps downstream and set "tff" buffer flag
appropriately to output buffers for interlaced pictures.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-03-19 18:43:06 +01:00
Gwenole Beauchesne
6c8b052bd3 Revert "vaapidecode: fix another pad template ref leak" (Holger Kaelberer)
This reverts commit 2f127d6af4.

For gst_element_class_get_pad_template(), no unreferencing is necessary
according to the GStreamer documentation.
2012-03-02 15:03:57 +01:00
Gwenole Beauchesne
2f127d6af4 vaapidecode: fix another pad template ref leak. 2012-02-06 16:11:38 +01:00
Gwenole Beauchesne
f64bafea59 plugins: fix pad template ref leaks. 2012-02-05 18:24:08 +01:00
Gwenole Beauchesne
c071f80f40 Add initial H.264 decoder. 2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
92f11799d1 legal: fix year for some copyright notices. 2012-01-16 11:40:51 +01:00
Gwenole Beauchesne
14cc1cf061 legal: fix copyright notices to include "Copyright" term. 2012-01-16 11:40:51 +01:00
Zhao Halley
6502783474 Add initial MPEG-4 decoder.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-01-16 11:40:51 +01:00
Gwenole Beauchesne
b865d4a740 Add initial VC-1 decoder. 2012-01-16 11:40:51 +01:00
Gwenole Beauchesne
49b4702fb6 Add initial MPEG-2 decoder. 2012-01-16 11:40:50 +01:00
Gwenole Beauchesne
8f0eda8964 Allow conditional build of GStreamer/FFmpeg bitstream parsers. 2012-01-16 11:40:50 +01:00
Gwenole Beauchesne
48cefaf9ce vaapidecode: fix deinitialization order. 2012-01-05 16:26:49 +01:00
Gwenole Beauchesne
9c8c33857f Fix warnings. 2011-12-13 15:59:02 +01:00
Nicolas Dufresne
cbf81d7d51 Add missing video context queries.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2011-12-12 15:02:15 +01:00
Sreerenj Balachandran
809e087cca vaapidecode: return sink caps template if decoder is in NULL state.
Otherwise, the decoder would always create its own X display instead
of probing it from the downstream element, which is not reliable.
e.g. DISPLAY is not :0 or when running on Wayland.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2011-12-08 15:48:42 +01:00
Gwenole Beauchesne
dc08d1eae0 vaapiplugin: properly set surface type to "vaapi" in caps. 2011-12-08 15:44:09 +01:00
Nicolas Dufresne
36e0f582a8 vaapiplugin: properly set opengl support in caps.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2011-12-08 15:13:42 +01:00
Nicolas Dufresne
bb22317e39 vaapiplugin: allocate GLX buffers when supported.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2011-12-08 15:13:42 +01:00
Nicolas Dufresne
b170d1a982 Don't use downstream buffer allocation.
With the new video/x-surface abstraction, we can't rely on having a VA
specific sink downstream. Also, there was no particular reason to do that.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2011-12-08 14:58:58 +01:00
Nicolas Dufresne
99c5d18f41 Port to GstVideoContext interface.
This new interface allows for upstream and downstream display sharing
that works in both static and dynamic pipelines.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2011-12-08 14:58:58 +01:00
Nicolas Dufresne
48b3d02143 Group all plugins into the same bundle
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2011-12-07 14:33:59 +01:00
Renamed from gst/vaapidecode/gstvaapidecode.c (Browse further)