Commit graph

217 commits

Author SHA1 Message Date
Sebastian Dröge
681d97aed7 video: Handle errors in gst_video_info_set_format() / gst_video_info_align()
https://bugzilla.gnome.org/show_bug.cgi?id=774588
2016-11-24 15:06:39 +02:00
Scott D Phillips
e740103669 videodecoder, audiodecoder: parse format before checking in src_query_default
The logic change in these commits misordered the parsing and checking of
format in position queries:

 2b06e54 videodecoder: Don't answer BYTES queries
 1840b02 audio: Don't answer BYTES queries

https://bugzilla.gnome.org/show_bug.cgi?id=774484
2016-11-16 07:57:31 +11:00
Jan Schmidt
2b06e54651 videodecoder: Don't answer BYTES queries
Refuse to answer BYTES queries ourselves. The only
time they make sense is on raw elementary streams,
in which case upstream would already have answered.

https://bugzilla.gnome.org/show_bug.cgi?id=757631
2016-11-16 00:14:47 +11:00
Julien Isorce
3bf893e12a video: add gst_video_decoder_allocate_output_frame_with_params
It adds a third argument to pass GstBufferPoolAcquireParams
to gst_buffer_pool_acquire_buffer.

If a user subclasses GstBufferPoolAcquireParams, this allows to
pass an updated param to the underlying buffer pool at each
gst_video_decoder_allocate_output_frame_with_params call.

https://bugzilla.gnome.org/show_bug.cgi?id=773165
2016-11-04 16:18:13 +00:00
Sebastian Dröge
e6fd46601c videodecoder: Proxy field order to the output caps
https://bugzilla.gnome.org/show_bug.cgi?id=771376
2016-11-01 20:40:07 +02:00
Stian Selnes
92392a4733 videodecoder: Default caps sets format I420
Also the format must be fixed on the default raw caps. If not
gst_video_info_from_caps() will fail and
gst_video_decoder_negotiate_default_caps() return FALSE.

The test simulates the use case where a gap event is received before
the first buffer causing the decoder to fall back to the default caps.

https://bugzilla.gnome.org/show_bug.cgi?id=773103
2016-10-20 14:11:48 +03:00
Edward Hervey
cfc36ba586 videodecoder: More trickmode fix
We need to take into account the input segment flags to know whether
we should drain the decoder after a new keyframe in trick mode.

Otherwise we would have to wait for the next frame to be outputted (and
the segment to be activated) which ... well ... kind of beats the whole
point of this draining :)
2016-07-07 17:12:31 +02:00
Philippe Normand
6338146c06 videodecoder: Take stream lock one time only on drain
When the drain is triggered from the chain function the lock is already
taken so there is no need to take it one more time.

https://bugzilla.gnome.org/show_bug.cgi?id=767641
2016-07-05 19:38:40 +03:00
Sebastian Dröge
e18a9d9b5f videodecoder: fix criticals fixating a non existent field
https://bugzilla.gnome.org/show_bug.cgi?id=766970
2016-07-04 11:16:55 +02:00
Sebastian Dröge
66342c5c86 videodecoder: Use the object lock to protect bytes/time tracking
And especially don't use the stream lock for that, as otherwise non-serialized
queries (CONVERT) will cause the stream lock to be taken and easily causes the
application to deadlock.

https://bugzilla.gnome.org/show_bug.cgi?id=768361
2016-07-04 10:55:07 +02:00
Sebastian Dröge
d8111778bd videoencoder/decoder: Move conversion utility functions to a common header and use consistently in encoder/decoder 2016-07-04 10:47:36 +02:00
Víctor Manuel Jáquez Leal
8b8708f946 videodecoder: handle buffer's flags at offset
For reverse playback it is important to handle correctly the frame sync
points, which is set when the input buffer doesn't have the DELTA_UNIT flag.

This is handled correctly when decoder is packetized, but when it is not the
frame's sync point is not copied, and the reverse playback never decodes frame
batches.

The current patch adds the buffer's flags to the Timestamp list, where the
timestamp and duration of the input buffers are hold.
2016-06-09 19:13:46 +03:00
Víctor Manuel Jáquez Leal
75906f53d1 videodecoder: squash two message logs into one
There were two consecutive log messages in gst_video_decoder_decode_frame().
Given the information they provide, it is more efficient to squash them into a
single one.
2016-06-09 19:08:08 +03:00
Víctor Manuel Jáquez Leal
779e739142 videodecoder: playback rate is in input_segment
The playback rate is hold in the input_segment member variable, not in the
output_segment, and the parse_gather list was never filled because of that.

This patch changes the comparison with input_segment.
2016-06-09 19:05:41 +03:00
Sebastian Dröge
0bd3f2352c videodecoder: Use input segment rate instead of output segment rate to decide whether the drain on keyframes
The output segment is only set up after data is output, which might be far in
the future for reverse playback. Also we are here interested in the state at
the current *input* frame (which is the keyframe), not any possible output.
2016-06-09 19:02:49 +03:00
Sebastian Dröge
0c7022d681 videodecoder: Only drain in KEY_UNITS trick mode after a keyframe in forwards playback mode
For reverse playback the same behaviour was already implemented in
flush_parse().

For reverse playback, chain_forward() is only used to gather frames and not
for decoding, and it is actually called by the draining logic, causing an
infinite recursion.
2016-06-09 18:57:49 +03:00
Edward Hervey
8bee96c4a2 videodecoder: Don't push late frames
While it's a bit tricky to discard frames *before* decoding (because
we might not be sure which data is needed or not by the decoder), we
can discard them after decoding if they are too late anyway.

Any following basetransform based element or similar would drop the frame too.
2016-06-09 17:21:45 +03:00
Edward Hervey
5bef865f9f videodecoder: Avoid recursive drain/flush calls
_chain_forward() can also be called with reverse playback. Blindly
calling drain_out() on DISCONT buffers would end up in a recursive
call.
2016-06-07 10:31:59 +02:00
Edward Hervey
183e94b2d3 videodecoder: Drain out keyframes in TRICK_MODE_KEY_UNITS
When asked to just decode keyframe, if we got a keyframe drain out
the decoder straight away.
This avoids having to wait for the next frame and reduces delay even
more.

https://bugzilla.gnome.org/show_bug.cgi?id=767232
2016-06-07 09:50:08 +02:00
Edward Hervey
eb1ebf226f videodecoder: Drain decoder on DISCONT buffers
This ensures the decoder is properly drained out when receiving a
DISCONT buffer. The optimal way of doing this would have been to
receive a GAP event before hand but it is not always possible.

Fixes big delays with some decoders (ex gst-libav) that will not
drain out data when only decoding keyframes.

https://bugzilla.gnome.org/show_bug.cgi?id=767232
2016-06-07 09:49:56 +02:00
Edward Hervey
fb21fc3af1 videodecoder: Make sure the DISCONT flag is set on the outgoing buffer
The base class was setting the DISCONT flag before checking whether the buffer
would be in segment or not.

Fix issues with DISCONT flags not being properly propagated downstream when
decoders buffers were out of segment.

https://bugzilla.gnome.org/show_bug.cgi?id=766800
2016-06-02 10:50:58 +03:00
Víctor Manuel Jáquez Leal
b4a695cd11 libs: video: split allocation query caos and pad caps
Since the allocation query caps contains memory size and the pad's caps
contains the display size, a video encoder or decoder might need to allocate
a different frame size than the size negotiated in the caps.

This patch splits this logic distinction for videodecoder and videoencoder.

The user if needs a different allocation caps, should set the allocation_caps
in the GstVideoCodecState before calling negotiate() vmethod. Otherwise the
allocation_caps will be the same as the caps set in the src pad.

https://bugzilla.gnome.org/show_bug.cgi?id=764421
2016-04-05 11:32:50 +02:00
HoonHee Lee
dfa2f49523 audio/videodecoder: Minor cleanup of last commit
https://bugzilla.gnome.org/show_bug.cgi?id=761218
2016-01-28 13:21:49 +01:00
HoonHee Lee
15df3c812b audio/videodecoder: use gst_pad_peer_query_caps to make output caps
gst_pad_get_allowed_caps() will return NULL if the srcpad has no peer.
In that case, use gst_pad_peer_query_caps() with template caps as filter
to have negotiated output caps properly before forwarding GAP event.

https://bugzilla.gnome.org/show_bug.cgi?id=761218
2016-01-28 11:34:22 +01:00
Julien Isorce
4f396ae61c videodecoder: add some debug around pool negotiation
It lets us know easily which pool is activated or
inactivated during the negotiation.

https://bugzilla.gnome.org/show_bug.cgi?id=720597
2015-12-11 14:55:46 +00:00
Edward Hervey
d34aaf9e9b videodecoder: Avoid pushing buffers before segment start
In the case where the stream doesn't have a framerate set and the frames
don't have a duration set, we still want to use the clipping path to
make sure we don't push buffers outside of the segment.

The problem was the previous iteration was setting a duration of 2s, which
meant that any buffer which was less than 2s before the segment start would
end up getting pushed.

Instead, use a saner 40ms (25fps single frame duration) to figure out whether
the frame could be within the segment or not
2015-12-03 16:42:50 +01:00
Luis de Bethencourt
227f1d1e0f videodecoder: Print GstClockTimeDiff as a signed integer in debug logs 2015-11-03 13:44:39 +00:00
Luis de Bethencourt
b81b3f07ec videodecoder: subtract time difference with GST_CLOCK_DIFF
To ensure the subtraction of two GstClockTime values (which are guint64)
can be negative. Use GST_CLOCK_DIFF which returns a gint64.

CID 1338049
2015-11-02 12:09:45 +00:00
Sebastian Dröge
1da79c76a7 videodecoder: Print another time difference as a signed integer instead of a huge unsigned one 2015-10-29 16:52:49 +02:00
Sebastian Dröge
f17758d9e3 videodecoder: Print GstClockTimeDiff as a signed integer in debug logs 2015-10-29 16:01:26 +02:00
Sebastian Dröge
64301f1005 video(en|de)coder: Return TRUE when we consumed a tag event without creating a new event
Fixes spurious flow errors that especially break gst-validate.
2015-08-18 16:28:42 +03:00
Tim-Philipp Müller
30b7cc6670 videodecoder: fix tag handling
Before we just merged everything in pretty much random ways
ad-hoc instead of keeping state properly. In 0.10 that was
how it worked, but in 1.x the tag events sent should always
reflect the latest state and replace any previous tags.

So save the upstream (stream) tags, and save the tags set
by the decoder subclass with merge mode, and then update
the merged tags whenever either of those two changes.

This slightly changes the behaviour of gst_video_decoder_merge_tags()
in case it is called multiple times, since now any call replaces
the previously-set tags. However, it leads to much more predictable
outcomes, and also we are not aware of any subclass which sets this
multiple times and expects all the tags set to be merged.

If more complex tag merging scenarios are required, we'll have
to add a new vfunc for that or the subclass has to intercept
the upstream tags itself and send merged tags itself.

https://bugzilla.gnome.org/show_bug.cgi?id=679768
2015-08-16 18:23:07 +01:00
Thiago Santos
c63db0e104 Revert "videodecoder: expose default query handling function"
Apparently I forgot how gobject works, there is no need to expose
it directly as one can call it from the parent_class pointer

This reverts commit ea9b6a7e3c.
2015-08-15 13:44:35 -03:00
Thiago Santos
4982188cf7 videodecoder: add option to use default pad accept-caps handling
Add gst_video_decoder_set_use_default_pad_acceptcaps() to allow
subclasses to make videodecoder use the default pad acceptcaps
handling instead of resorting to the caps query that is, usually,
less efficient and unecessary

API: gst_video_decoder_set_use_default_pad_acceptcaps
2015-08-15 13:44:34 -03:00
Thiago Santos
ea9b6a7e3c videodecoder: expose default query handling function
Subclasses can use it to select what queries they want to handle
and forward the rest to the default handling function.

API: gst_video_decoder_sink_query_default

https://bugzilla.gnome.org/show_bug.cgi?id=753623
2015-08-14 13:41:58 -03:00
Thiago Santos
a1c3276159 videodecoder: documentation cleanup
Remove some whitespace and break lines longer than 80 columns
2015-08-10 10:40:07 -03:00
Thiago Santos
e59d1308cc videodecoder: push pending events before gap
Push all pending events before pushing the gap. This ensures the
segment is pushed before the gap so it can be properly translated
to the running time

Includes unit test.

https://bugzilla.gnome.org/show_bug.cgi?id=753360
2015-08-10 00:21:37 -03:00
Stian Selnes
008a228865 videodecoder: Fix setting default pixel-aspect-ratio
It's needed to check if pixel-aspect-ratio exists before fixating.
It does not exist if input caps is not set yet and allowed caps
does not contain pixel-aspect-ratio (e.g. when using GST_VIDEO_CAPS_MAKE)

https://bugzilla.gnome.org/show_bug.cgi?id=751932
2015-07-06 11:59:38 +03:00
Sebastian Dröge
f5eebb27a2 {audio,video}{en,de}oder: Also copy POOL metas and make sure to copy over metas when creating subbuffers
POOL meta just means that this specific instance of the meta is related to a
pool, a copy should be made when reasonable and the flag should just not be
set in the copy.
2015-07-01 10:58:07 +02:00
Sebastian Dröge
d2cc76b228 videodecoder: Add transform_meta() vfunc with default implementation
The default implementation copies all metadata without tags, and metadata
with only the video tag. Same behaviour as in GstVideoFilter.

This currently does not work if the ::parse() vfunc is implemented as all
metas are getting lost inside GstAdapter.

https://bugzilla.gnome.org/show_bug.cgi?id=742385
2015-06-30 10:40:09 +02:00
Jan Schmidt
4b373d4c97 videodecoder: Copy multiview-mode, flags and view count from ref info
When copying info from the reference input state, duplicate
all the fields of the video info. The sub-class will have the
chance to override them later.
2015-06-13 01:36:45 +10:00
Sebastian Dröge
f74524b58d videodecoder: Also negotiate with downstream if needed before handling a GAP event 2015-05-08 15:07:56 +02:00
Sebastian Dröge
21b5741251 videodecoder: Try to be smarter when clipping buffers without duration/framerate to the segment
2 second frame duration is rather unlikely... but if we don't clip
away buffers that far before the segment we can cause the pipeline to
lockup. This can happen if audio is properly clipped, and thus the
audio sink does not preroll yet but the video sink prerolls because
we already outputted a buffer here... and then queues run full.

In the worst case we will clip one buffer too many here now if no
framerate is given, no buffer duration is given and the actual
framerate is less than 0.5fps.

Fixes seeking on HLS/DASH streams, when seeking into the middle of
fragments and having no framerate/buffer duration.
2015-05-06 12:42:33 +02:00
Sebastian Dröge
6539d1da29 videodecoder: Break instead of return if default negotiation on GAP events fails
Otherwise we're going to leak the event.
2015-04-11 19:52:50 +02:00
Sebastian Dröge
f268f2be92 videodecoder: Try to invent default caps instead of setting none at all when getting a GAP event before CAPS
Otherwise we would forward the GAP event without ever providing any caps,
which then would make decodebin expose a srcpad without any caps set. That's
confusing for applications and can lead to all kinds of interesting bugs.

Instead do the same as already is done in GstAudioDecoder, and try to invent
caps based on the sinkpad caps and the caps allowed by downstream and the
srcpad template caps.

https://bugzilla.gnome.org/show_bug.cgi?id=747190
2015-04-08 20:49:39 -07:00
Sebastian Dröge
0c72d0acdf {audio,video}decoder: Forward SEGMENT_DONE events immediately and drain decoders
Otherwise we're going to wait with draining until the next data comes, which
is a bit suboptimal and might take a long time... or maybe never happens.
2015-04-06 19:20:51 -07:00
Vincent Penquerc'h
2954813b86 audio,video: use gst_segment_is_equal instead of memcmp
memcmp will blindly compare the reserved fields, as well as any
padding the compiler may choose to sprinkle in GstSegment.

Fixes valgrind complaints in unit tests, as well as some found via
https://bugzilla.gnome.org/show_bug.cgi?id=738216
2015-04-03 12:09:41 +01:00
Mark Nauwelaerts
f134072c66 videodecoder: only return EOS upon clipping if applicable
See also https://bugzilla.gnome.org/show_bug.cgi?id=709224
2015-03-07 20:12:23 +01:00
Jan Schmidt
af26201429 videodecoder: Add drain() vfunc
drain() is a new vfunc which does what finish() does, while
explicitly requiring the decoder be able to continue processing
data afterward.

https://bugzilla.gnome.org/show_bug.cgi?id=734617
2015-02-24 01:36:44 +11:00
Mark Nauwelaerts
ccee86a7dd Revert "videodecoder: drain current segment upon new one to ensure correct flow return"
This reverts commit cc1b4eaf9e.

See https://bugzilla.gnome.org/show_bug.cgi?id=734617
2015-02-22 16:59:08 +01:00