Commit graph

270 commits

Author SHA1 Message Date
Nicolas Dufresne be6793d0d1 videodecoder: Call drain() rather then finish() on segment-done
The finish() virtual function documentation state that "Sub-classes can refuse
to decode new data after." Though, it is very common to issue a non-flushing
seek after that event in gapless playback uses case. This fixes potential
stalls with code using segment seeks, by using drain() virtual funciton
instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1206>
2021-06-23 20:31:06 +00:00
Stéphane Cerveau ada8b07be2 videodecoder: use DTS if PTS unknown
The buffer should be set according to DTS if exists
when we are guessin the PTS instead of segment start.
The decoder can receive buffers which are before the segment
in case of seek for example.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1111>
2021-04-19 13:28:39 +02:00
Matthew Waters 98249a57db gst: don't use volatile to mean atomic
volatile is not sufficient to provide atomic guarantees and real atomics
should be used instead.  GCC 11 has started warning about using volatile
with atomic operations.

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Discovered in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/868

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1073>
2021-03-19 04:20:19 +00:00
Alicia Boya García 29aeba639a videodecoder: Fix racy critical when pool negotiation occurs during flush
I found a rather reproducible race in a WebKit LayoutTest when a player
was intantiated and a VP8/9 video was loaded, then torn down after
getting the video dimensions from the caps.

The crash occurs during the handling of the first frame by gstvpxdec.
The following actions happen sequentially leading to a crash.

(MT=Main Thread, ST=Streaming Thread)

MT: Sets pipeline state to NULL, which deactivates vpxdec's srcpad,
    which in turn sets its FLUSHING flag.

ST: gst_vpx_dec_handle_frame() -- which is still running -- calls
    gst_video_decoder_allocate_output_frame(); this in turn calls
    gst_video_decoder_negotiate_unlocked() which fails because the
    srcpad is FLUSHING. As a direct consequence of the negotiation
    failure, a pool is NOT set.

    gst_video_decoder_negotiate_unlocked() still assumes there is a
    pool, crashing in a critical in gst_buffer_pool_acquire_buffer()
    a couple statements later.

This patch fixes the bug by returning != GST_FLOW_OK when the
negotiation fails. If the srcpad is FLUSHING, GST_FLOW_FLUSHING is
returned, otherwise GST_FLOW_ERROR is used.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1031>
2021-02-16 16:57:54 +00:00
Stéphane Cerveau 9b852181d8 videodecoder: Forward hdr-format info downstream
By default the hdr-format detected by a parser should
be passed to the downstream element.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/650>
2020-12-15 16:37:46 +00:00
Seungha Yang 660b5e4a98 videodecoder: Don't assume GstVideoChromaSite and GstVideoColorimetry
Even if given GstVideoChromaSite and/or GstVideoColorimetry has unknown
value(s), assumption for an unknown value should be done by subclass or
downstream element, not a role of video decoder. And subclass might
want to output unknown value as is.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/910>
2020-11-02 14:11:52 +00:00
Seungha Yang 37255eb7dc videodecoder: Remove trailing whitespace
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/910>
2020-11-02 14:11:52 +00:00
Sebastian Dröge 6af87dee17 audio/videodecoder: Initialize max_errors in instance_init()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/882>
2020-10-20 12:46:07 +03:00
Sebastian Dröge ed62e78c6e audio/videodecoder: Don't reset max-errors in reset()
Otherwise setting the property on the elements has no effect at all
because it's immediately reset during startup.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/881>
2020-10-20 11:52:07 +03:00
Guillaume Desmottes a3a2992bc8 videodecoder: fix output state interlace-mode
When user is passing the actual interlace-mode when calling
gst_video_decoder_set_interlaced_output_state() it should not be
overidden by the input interlace-mode.

Needed to fix #825 as we want to keep interlace-mode=interleaved from
parsers and have the OMX decoder producing interlace-mode=alternate.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/852>
2020-10-09 11:04:30 +02:00
Guillaume Desmottes a19a27a4ca videodecoder: add interlace-mode to debug output when setting output state
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/852>
2020-10-09 11:04:30 +02:00
Stian Selnes eaedb5c2de videodecoder: Bump log level of marking a sync point
Sync points are often important when debugging and deserves DEBUG
level.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/730>
2020-09-10 20:31:10 +02:00
Sebastian Dröge d26eede464 videodecoder: Add API for subclasses to request a new sync point
This allows subclasses that notice missing reference frames to request a
new sync point to allow seamless decoding again. While doing so the
subclass can also signal whether it wants a) all following input frames
until the sync point to be discarded or b) all output frames until the
sync point to be marked as corrupt.

Sending of force-keyunit events for this can be throttled by the
application via the "min-force-keyunit-interval" property.

This replaces custom behaviour for the same in various decoders, for
example openh264dec.

Based on patches by Haakon Sporsheim <haakon@pexip.com> and
Stian Selnes <stian@pexip.com>.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/730>
2020-09-10 20:31:10 +02:00
Sebastian Dröge fdf79a786c videodecoder: Add API for subclasses to signal that they need the stream to start with a sync point
If the first frame(s) at the very beginning or after a flush are not a
sync point then the base class would discard them before passing them to
the subclass.

This also fixes the previously broken distance_from_sync handling: it
was never reset at sync points.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/730>
2020-09-10 17:22:14 +00:00
Sebastian Dröge 1afb145dc5 videodecoder: Add "discard-corrupted-frames" property
This can be used by applications to configure decoders so that corrupted
frames are directly discarded instead of being forwarded inside the
pipeline. It is a replacement for the "output-corrupt" property of the
ffmpeg decoders.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/730>
2020-09-10 17:22:14 +00:00
Sebastian Dröge 06bcf95ebf videodecoder: Add API for marking output frames as corrupted
This can be used by subclasses to mark output frames as known to be
corrupted, for example if reference frames were missing. ffmpeg's
decoders can signal this.

In addition this flag is propagated downstream if the input frame had it
set.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/730>
2020-09-10 17:22:14 +00:00
Sebastian Dröge 74889206eb videodecoder: Remove unused reorder_depth variable
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/730>
2020-09-10 17:22:14 +00:00
Sebastian Dröge 391d09dc24 audio/video: Copy more metas by default in the codec base classes
For audio we copy metas that have no tags at all, or that only have the
"audio" and/or "audio-channels" tag. Audio codecs don't change the
audio aspect of the stream and in almost all cases don't change the
number of channels. They might however change the sample rate (e.g.
Opus). Subclasses that change the number of channels will have to
override ::transform_meta() accordingly.

For video we copy metas that have no tags at all, or that only have the
"video" and/or "video-size" and/or "video-orientation" tag. Video codecs
don't change the "video" aspect of the stream and in almost all cases
don't change the resolution or orientation. Subclasses that rescale or
change the orientation will have to override ::transform_meta()
accordingly.

See https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/576#note_610581

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/801>
2020-08-30 22:12:22 +00:00
Havard Graff 0826fb95b7 audio: video: Optimize by using cached quark for meta tag
Avoid taking the global quark lock for every single buffer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/295>
2020-06-27 09:23:10 +00:00
Haakon Sporsheim 226a371e3f videodecoder: Add max-errors property
The number of consecutive decode errors that should be tolerated before
returning flow error should be up to the application, not the element.

Hence max-error should be exposed as a property.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/720>
2020-06-23 07:17:00 +00:00
Sebastian Dröge caaa5ac864 video: Use GQueue instead of plain GList in a few places
Also not optimal but at least simplifies the code a bit and doesn't
require g_list_length() and g_list_append() in a few places.

For 2.0 there are some more candidates to change but unfortunately
they're currently part of the API.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/683>
2020-06-03 16:21:41 +03:00
Jan Schmidt 8cb14728a7 videodecoder: Handle instant-rate-change event
When receiving an instant-rate-change event, store the updated
seek flags and replace the flags in any input segments with them
to allow for instant switching between trickmodes and not.
2020-04-01 21:01:38 +00:00
Víctor Manuel Jáquez Leal 8211370281 videodecoder: fix documentation
Fix list indentation, othewise it is interpreted as verbatim.
2020-03-21 14:15:51 +01:00
Nicolas Dufresne 1174e37b80 videodecoder: Add a property to disable dropping on QoS 2019-11-02 14:36:01 +00:00
Nicolas Dufresne 1570314609 videodecoder: Post QoS when we drop because of QoS
At the moment, we only posted QoS messages when frame_drop() was
called, but not in finish_frame() when QoS triggered a late push.
This should fix applications that tries to account the dropped
frames. We also emit a warning on drops so it's more clear what is
happening.
2019-11-02 14:36:01 +00:00
Thibault Saunier 909baa2360 Pass the code through codespell 2019-08-30 13:05:36 +00:00
Wonchul Lee afcfb22f83 videodecoder: Fix typo in documentation 2019-06-15 10:44:48 +09:00
Thibault Saunier 287897e465 doc: Fix some gtk-doc comments 2019-05-13 11:34:08 -04:00
Seungha Yang 3e460766e8 videodecoder: Forward upstream HDR information to downstream
The HDR related information is not part of GstVideoInfo but should be passed
to downstream.
2019-04-30 15:45:44 +00:00
Guillaume Desmottes f5a1164590 videodecoder: remove useless code in negotiate_default_caps()
gst_video_decoder_negotiate_default_caps() is meant to pick a default output
format when we need one earlier because of an incoming GAP.
It tries to use the input caps as a base if available and fallback to a default
format (I420 1280x720@30) for the missing fields.

But the framerate and pixel-aspect were not explicitly passed to
gst_video_decoder_set_output_state() which is solely relying on the input format
as reference to get the framerate anx pixel-aspect-ratio.
So there is no need to manually handling those two fields as
gst_video_decoder_set_output_state() will already use the ones from
upstream if available, and they will be ignored anyway if there are not.

This also prevent confusing debugging output where we claim to use a
specific framerate while actually none was set.
2019-02-04 11:53:03 +01:00
Edward Hervey 3519b39131 videodecoder: Remove dead assignment
structure is never used afterwards
2018-12-17 12:21:01 +01:00
Nicolas Dufresne 8ffd15ab28 videodecoder: Delete the link before pushing
The gst_video_decoder_clip_and_push_buf() now drops the internal stream
lock while pushing. This means, the output_queued list could be modififed
during that time. To make the code safe again, we delete the link before
pushing the data. The walk pointer will later be updated with the list
head, which makes it safe in case the list was modififed.

https://bugzilla.gnome.org/show_bug.cgi?id=715192
2018-09-10 17:08:25 -04:00
Alexey Chernov fb49674a39 videodecoder: Release STREAM_LOCK during gst_pad_push()
Release STREAM_LOCK before calling gst_pad_push() and take it
back afterward so that upstream isn't blocked while output
buffer is being pushed downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=715192
2018-08-31 16:10:57 -04:00
Zeeshan Ali be6c8400b0 video: Add gst_video_decoder_set_interlaced_output_state()
Add a variant of gst_video_decoder_set_output_state() that allows the user
to pass an interlacing mode as well. This is needed to ensure that
gst_video_info_set_interlaced_format() is used instead so that
GstVideoInfo.size is correctly initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=796106
2018-08-29 12:14:38 -04:00
Nicolas Dufresne 62cb08404b videodecoder: Don't always drain on gaps/discont
V4L2 and OMX decoder don't support draining and keeping reference
frames. As a side effect, these decoder just stops working on
gaps/discont. When this drain was introduced, the commit stated that
this was for TRICKMODE_KEY_UNITS, so only drain if running in this mode.

https://bugzilla.gnome.org/show_bug.cgi?id=796771
2018-07-12 15:25:51 -04:00
Tim-Philipp Müller 18c457dfb4 video: Update for g_type_class_add_private() deprecation in recent GLib
https://gitlab.gnome.org/GNOME/glib/merge_requests/7
2018-06-23 21:59:13 +02:00
Matthias Fend 41c6efb9ff videodecoder: keep event order
Since events are pushed out in reverse order, newer events need to
be added at the front of event lists

https://bugzilla.gnome.org/show_bug.cgi?id=794192
2018-04-26 17:05:04 -04:00
Edward Hervey 22c9e5f7c1 libs: Documentation cleanup
* Fix wrong naming, wrong types and typos
* Add missing sections
* Add missing documentation for entries
* Explicitely mark private structure entries
* Remove items that never existed
2018-04-02 08:53:28 +02:00
Nicolas Dufresne 604c1bfb4e videodecoder: Reset QoS time after pushing segment
This fixes playbin gapless playback. An ancient QoS time was used and
would lead to all frames being dropped.

https://bugzilla.gnome.org/show_bug.cgi?id=668995
2018-03-01 11:19:31 -05:00
Matthew Waters a81b5a95ba Revert "videodecoder: flush decoder in transition PAUSED->READY"
This reverts commit 6e9edc3031.
2017-10-22 01:00:08 +11:00
Nicola Murino 6e9edc3031 videodecoder: flush decoder in transition PAUSED->READY
https://bugzilla.gnome.org/show_bug.cgi?id=787311
2017-10-20 01:55:07 +11:00
Reynaldo H. Verdejo Pinochet e81c334ca9 Use proper GtkDoc notation for NULL/FALSE/TRUE 2017-10-03 14:31:18 -07:00
Sebastian Dröge ae8d0cf3ac videodecoder: Make sure we have an actually writable buffer when modifying metadata
avviddec keeps references to the buffers internally for example, in
which case we need to do a shallow copy of the buffer.
2017-07-24 16:48:17 +03:00
Edward Hervey dfa548dc5b videodecoder: Don't queue frames in TRICKMODE_KEY_UNITS
When the input is TRICKMODE_KEY_UNITS, we expect to only receive keyframes
which we want to decode/push immediately. Therefore don't queue them.

If upstream didn't send just keyframes (which is the ideal situation), two
different things can happen:
1) Either the subclass checks the segment flags and properly configures
 the decoder implementation to only decode/output keyframes,
2) Or the subclass really decodes and outputs everything, in which case
 the reverse frames will end up arriving "late" downstream (and will
 be dropped). If upstream did properly send GOP in reverse order, we
 still end up just showing keyframes (but at the overhead of decoding
 everything).

https://bugzilla.gnome.org/show_bug.cgi?id=777094
2017-05-20 17:37:27 +02:00
Jan Schmidt 2980e96a50 videodecoder: Output mono multiview caps if none specified
Always put multiview-caps onto the output caps, assuming
mono if we've got no other information. It's still easy for
downstream elements to override using a capssetter or event
probe if desired.

https://bugzilla.gnome.org/show_bug.cgi?id=776172
2017-05-19 18:02:36 +02:00
Sebastian Dröge a3656ba29b libs: Check if meta transform_func is NULL before using it
https://bugzilla.gnome.org/show_bug.cgi?id=782050
2017-05-02 14:31:14 +03:00
Jan Schmidt 2d3e69dca3 videodecoder: Add debug output tracking decode-after-flush
Track how long it takes to generate the first buffer after a flush
as a simple measure of how efficient the decoder is at skipping /
rushing to get to the first decode.
2017-03-18 02:03:47 +11:00
Thibault Saunier 099ac9faf2 docs: Convert gtkdoc comments to markdown
Modernizing the documentation, making it simpler to read an
modify and allowing us to possibly switch to hotdoc in the
future.
2017-03-10 18:19:17 -03:00
Matthew Waters d15b0f4844 videodecoder: fix build error on i386
Use G_GUINT64_FORMAT for guint64 values.

Introduced by fcb63e77a9

Found by Alexander Larsson

gstvideodecoder.c: In function 'gst_video_decoder_have_frame':
gstvideodecoder.c:3312:51: error: format '%u' expects argument of type 'unsigned int', but argument 8 has type 'guint64 {aka long long unsigned int}' [-Werror=format=]
2017-03-10 18:23:48 +11:00
Jan Schmidt 052d34478f videodecoder: Fix a leak introduced in fcb63e
CID: 1402055
2017-03-06 19:14:48 +11:00