Commit graph

140 commits

Author SHA1 Message Date
Alicia Boya García
b7d450b118 gstavviddec: Limit default number of decoder threads
When the `max-threads` property is not specified, GStreamer defaults to
the amount of CPU threads in the system.

The number of threads used in avdec has a direct impact on the latency
of the decoder, which is of as many frames as threads. Therefore, big
numbers of threads can make latency levels that can be problematic in
some applications.

For this reason, ffmpeg emits a warning when more than 16 threads are
requested.

This patch limits the default number of threads to 16. This affects only
computers with more than 16 CPU threads when using avviddec without
setting `max-threads`.
2019-12-19 21:59:44 +00:00
Seungha Yang
07f33470b3 avviddec: Fix huge leak caused by circular reference
AVBufferRef -> GstFFMpegVideoDecVideoFrame -> GstVideoCodecFrame -> AVBufferRef

Instead of holding additional ref there, set read-only which would not be
reused by ff_reget_buffer()

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-libav/issues/63
2019-10-29 16:29:46 +09:00
Seungha Yang
30d0674e7d avvideenc,avvidedec: Filtering hardware en/decoder by flag
... instead of filtering them by hardcoded string compare.
2019-10-25 19:48:15 +09:00
Seungha Yang
80c8c05457 avviddec: Enforce allocate new AVFrame per input frame
... if ffmpeg would reuse the allocated AVBuffer. Reused AVFrame by
the ffmpeg seems to break our decoding flow since the reused AVFrame
holds the initial opaque data (GstVideoCodecFrame in this case), so
we couldn't trace the our in/out frames.
To enforce get_buffer() call per output frame, hold another reference
to the AVBuffer in order to mark the AVBuffer as not writable.

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-libav/issues/62
2019-10-24 00:25:28 +09:00
Seungha Yang
40f5953828 avviddec,avcodemap: Use new helper function for map color space information
... between GStreamer and FFmpeg. Note that FFmpeg follows ISO/IEC 23001-8
defined color{matrix,transfer,primaries} values.
2019-09-24 23:52:11 +09:00
Mathieu Duponchelle
1e8e040fbc avviddec: improve latency calculation
When thread_type is set to FF_THREAD_FRAME, per the documentation
a latency of one frame per thread is introduced:

<https://ffmpeg.org/ffmpeg-codecs.html>, search for thread_type.

Additionally, we need in that case to calculate the automatic
number of threads ourselves, so as to accurately calculate the
latency.
2019-07-18 00:26:50 +02:00
Seungha Yang
e8f21b510a avviddec: Add thread-type property
The thread-type property allows specifying preferred
multithreading methods by user. Note that FF_THREAD_FRAME
may introduce additional latency especially on non-filesrc usecase,
since it introduces a decoding delay of (number of threads) frames.

https://bugzilla.gnome.org/show_bug.cgi?id=797254
2019-07-18 00:05:21 +02:00
Guillaume Desmottes
2e59973cca avviddec: remove cdgraphics element
It was never usable as we don't have a parser and we now have 'cdgdec'
in gst-plugins-rs.
2019-05-29 11:49:38 +05:30
Seungha Yang
2b50a0ce93 avcodecmap,avviddec: Map bt2020-10, PQ and HLG transfer functions
Map more transfer functions between Gstreamer and ffmpeg
2019-05-24 20:44:12 +09:00
Seungha Yang
8d9b30695b avviddec: Extract HDR information if any
Convert mastering display information (a.k.a HDR static metadata) and
content light level information provided by FFMPEG to Gstreamer.
2019-05-01 23:24:56 +09:00
Yeongjin Jeong
93e2466115 avviddec: Ensure drain even if codec has not delay capabilities
There are decoders that need to be drained if they work on multi-threads,
even if AV_CODEC_CAP_DELAY is not set.
2019-04-29 15:38:42 +09:00
Aaron Boxer
b2cc8a57d4 avviddec: do not add 708 caption meta if already exists
(this is only used for CEA 708 raw data). another element
such as mpegvideoparse may have already added the meta.
2019-04-01 17:11:36 -04:00
Edward Hervey
46cc79c43a avviddec: Remove unneeded check
frame is always valid in this function (but wasn't before the
refactoring from a few months ago).

CID #1439540
2018-09-21 16:01:53 +02:00
Mathieu Duponchelle
ff3a8f6627 decoders: fix draining
https://bugzilla.gnome.org/show_bug.cgi?id=796900
2018-07-31 19:13:25 +02:00
Seungha Yang
db82350245 libav: Fix symbol redefine build error
https://bugzilla.gnome.org/show_bug.cgi?id=796827
2018-07-19 12:21:01 +01:00
Mathieu Duponchelle
dd37a553ac av*dec: Ignore decoding errors
We were ignoring these before the port to 4.0, interpreting them
as GST_FLOW_ERROR / GST_ELEMENT_ERROR causes check failures.

We should start using GST_*_DECODER_ERROR in latter commits,
for now simply restore the previous behaviour.
2018-07-13 17:24:07 +02:00
Mathieu Duponchelle
be9b6969cb avviddec: fix invalid alignment calculations.
avcodec_align_dimensions2 uses context->pix_fmt to make its
calculations, we thus need to make sure it is adequately set
when calling it.

Fixes:

gst-launch-1.0 videotestsrc ! video/x-raw, width=1920, height=1080 \
! avenc_mpeg4 ! avdec_mpeg4 ! xvimagesink

This showed invalid writes under valgrind, then segfault.

https://bugzilla.gnome.org/show_bug.cgi?id=792900
2018-07-13 00:53:27 +02:00
Mathieu Duponchelle
965cd81603 avviddec: fix signed/unsigned comparisons
https://bugzilla.gnome.org/show_bug.cgi?id=792900
2018-07-13 00:53:27 +02:00
Mathieu Duponchelle
d191fb2e50 avvidec: port to new decoding API
https://bugzilla.gnome.org/show_bug.cgi?id=792900
2018-07-13 00:53:27 +02:00
Mathieu Duponchelle
e4bf6147a0 av_codec_next (deprecated) -> av_codec_iterate
https://bugzilla.gnome.org/show_bug.cgi?id=792900
2018-07-13 00:53:27 +02:00
Nicolas Dufresne
d8dfa4657b avviddec: Stop using deperated EDGE API
https://bugzilla.gnome.org/show_bug.cgi?id=792900
2018-07-13 00:53:26 +02:00
Nicolas Dufresne
aa724e2f14 Use AV_ namespace for all CODEC_ macro
The remaining use of CODEC_ are codec flags that has been moved into the
new codec private properties or have been deperated. Will be fixed in
later patches.

https://bugzilla.gnome.org/show_bug.cgi?id=792900
2018-07-13 00:53:26 +02:00
Nicolas Dufresne
7b3e41e20b Use AV_ namespace for INPUT_BUFFER_PADDING_SIZE
https://bugzilla.gnome.org/show_bug.cgi?id=792900
2018-07-13 00:53:26 +02:00
Edward Hervey
04b3867cb8 libav: Switch to common include 2018-05-11 14:24:03 +02:00
Edward Hervey
b894bedeb3 avvidec: Expose Closed Caption as GstVideoCaptionMeta 2018-05-07 17:12:07 +02:00
Mathieu Duponchelle
d5b0305241 Enable gif format, and make it so avdemux_gif and avdec_gif can autoplug
https://bugzilla.gnome.org/show_bug.cgi?id=784684
2018-02-12 08:27:53 +01:00
Edward Hervey
79bc255fa2 avvid*: Don't expose V4L2 mem-to-mem decoder and encoders
It's not going to work without special handling. Mask for now.
2018-02-10 15:18:11 +01:00
Sebastian Dröge
5b22802b35 Revert "avviddec: Remove usage of deprecated EDGE APIs"
This reverts commit 4284d791bc.

It causes crashes on various h264 and DNXHD/VC3 streams, where the
decoders write to arbitrary memory far after what we've allocated.
2017-08-10 18:55:29 +03:00
Nicolas Dufresne
4284d791bc avviddec: Remove usage of deprecated EDGE APIs
As a side effect, left/right green bars goes away when using
xvimagesink. I just think that xv cropping is broken, so this is
probably just hiding a bug.
2017-07-11 09:37:03 -04:00
Sebastian Dröge
15a17f3f8d avviddec: Don't expose NVIDIA CUVID decoder
It's not working without further changes on our side, like all hardware
decoders in ffmpeg.
2017-05-16 18:55:36 +03:00
Jan Schmidt
8e6fbe7f63 avviddec: Map any stereo3D info to multiview modes
Map any libav Stereo3D side data to GStreamer multiview
mode / flags for playback.

https://bugzilla.gnome.org/show_bug.cgi?id=767938
2017-03-16 15:23:01 +11:00
Garima Gaur
14dc964f0e Fix some caps leaks when creating pad templates
https://bugzilla.gnome.org/show_bug.cgi?id=776700
2017-01-02 12:41:20 +00:00
leigh123linux@googlemail.com
3c3be3125f avvidenc/dec: Disable more hardware encoder/decoders
Important when using a system ffmpeg/libav.

https://bugzilla.gnome.org/show_bug.cgi?id=774278
2016-11-12 10:33:51 +02:00
Sebastian Dröge
88da0fb956 avviddec: Fix comment to say interlace-mode instead of interlaced-mode 2016-11-04 16:27:59 +02:00
Sebastian Dröge
5e61a8999f avviddec: Use interlaced-mode=interleaved and set field-order if possible
https://bugzilla.gnome.org/show_bug.cgi?id=771376
2016-11-01 20:42:52 +02:00
Sebastian Dröge
5b40fb965b avviddec: Set colorimetry information from the context if known
But only if upstream did not provide that information.

https://bugzilla.gnome.org/show_bug.cgi?id=750882
2016-11-01 20:42:52 +02:00
Sebastian Dröge
e3558d4d07 avviddec: Use enum instead of magic numbers for the chroma siting values 2016-09-29 12:01:59 +03:00
Iain Lane
f5f32986b6 Only use AV_CODEC_ID_WRAPPED_AVFRAME on new enough libavcodecs
https://bugzilla.gnome.org/show_bug.cgi?id=770753
2016-09-03 14:20:26 +03:00
Edward Hervey
8b374b3f82 avvidec: Ensure skipping strategy gets properly reset
When switching playback modes, like from TRICKMODE or TRICKMODE_KEY_UNITS
back to regular playback, we need to make sure we set the skip mode
back to the default setting.

While this field would be properly reset when we *have* feedback from
downstream (i.e. diff != G_MAXINT64), it would not be reset during
the initial phase (i.e. when the decoder hasn't pushed a buffer yet,
and therefore the sink hasn't sent back QoS information).

This avoids dropping plenty of frames when going back to regular playback
2016-08-04 10:45:14 +02:00
Sebastian Dröge
3e93ad1bcd libav: Ignore more quasi-codecs 2016-07-22 14:54:21 +03:00
Sebastian Dröge
5f4bd291c1 libav: Ignore VAAPI decoders and VAAPI/nvenc encoders
These can show up when having a build against a system version of ffmpeg.
2016-07-22 14:42:59 +03:00
Edward Hervey
e36fa30c15 avvidec: Don't set bogus latency
We might have cases where the framerate is not known (0/1).
2016-05-14 12:09:06 +02:00
Edward Hervey
878d32ad38 avvidec: Report the latency once we're fully configured
Several decoders will only be able to report a real latency (has_b_frames)
once they're actually initialized (i.e. when they return their first frame).

Doing it earlier (in set_format) doesn't guarantee that the AVCodecContext
has_b_frames has been properly initialized.

https://bugzilla.gnome.org/show_bug.cgi?id=766362
2016-05-13 09:52:29 +02:00
Tim-Philipp Müller
9e00a37d0e Don't use exported but undeclared core debug category symbols
It's not right and won't work on Windows with MSVC.
2016-02-20 12:59:38 +00:00
Edward Hervey
da335a0ea3 avvidec: Bring mpeg video decoders up to PRIMARY rank
We should have done that ages ago ...

https://bugzilla.gnome.org/show_bug.cgi?id=574461
2016-01-21 17:35:51 +01:00
Sebastian Dröge
6e18a221a0 avviddec: Use AVFrame API instead of deprecated AVPicture API 2016-01-20 10:31:40 +02:00
Andreas Cadhalpun
6235a04ef3 libav: Remove usage of deprecated API
https://bugzilla.gnome.org/show_bug.cgi?id=757498
2016-01-16 16:47:40 +02:00
Vineeth TM
ae27b9c503 avviddec: remove realvideo slice_offset handling
Handling slice_offset in avviddec is resulting in invalid memory read.
Since rv decoders anyways handle slice_offset, removing the same to fix
memory mishandlings

https://bugzilla.gnome.org/show_bug.cgi?id=758726
2015-12-23 13:17:08 +01:00
Sebastian Dröge
5df8cc5e38 avviddec: Make sure to use a buffer pool with the correct width/height configured on it for pushing buffers downstream
If downstream does not provide a (usable) pool, we would use our internal
pool. But the internal pool might be configured with a different width/height
because of padding, which then will cause problems if we push buffers from it
directly downstream.
Instead create a new pool if the width/height is different.

This prevents crashes with vaapisink and d3dvideosink for example.

Based on the debugging results and discussions with
Nicolas Dufresne <nicolas.dufresne@collabora.com>

https://bugzilla.gnome.org/show_bug.cgi?id=758344
2015-12-01 12:34:27 +02:00
Vineeth T M
839a72f92c avviddec: Fix structure memory leak
gst_structure_copy already takes a reference for config_copy.
No need to take another reference while setting it to buffer pool

https://bugzilla.gnome.org/show_bug.cgi?id=758512
2015-11-23 12:05:26 -03:00