Commit graph

158 commits

Author SHA1 Message Date
Olivier Crête
17aca8a8c2 avviddec: Enable subframe decoding for H.264
Enable sending NAL units to the decoder without having to first
group them in a frame (an AU).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/66>
2021-07-08 18:39:28 +02:00
Olivier Crête
81cbd0deb6 avviddec: Split allocation tracking from decode-only-ness
When doing subframe decoding, handle_frame will be called multiple
times, so the DECODE_ONLY flag gets re-set when it shouldn't. Instead,
let's create our own flag to track this.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/66>
2021-07-07 18:45:51 +02:00
Doug Nazar
e0be2033a0 avviddec: Fix size of linesize parameter
Although avcodec_align_dimensions2() only copies 4 ints, it expects
a buffer of at least AV_NUM_DATA_POINTERS (8) ints.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/134>
2021-06-03 06:01:30 -04:00
Edward Hervey
75fb364bf4 avviddec: Take into account coded_height for pool
Failure to do this would cause the decoders to constantly request a new
bufferpool thinking the height had changed ... whereas it hadn't.

Fixes #95

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/131>
2021-04-24 10:07:31 +02:00
Tim-Philipp Müller
672f1caf85 avviddec: deprecated debug-mv property to match deprecation in FFmpeg
This has been unimplemented and non-functional for years
and was deprecated with FFmpeg 4.4.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/126>
2021-04-13 22:53:36 +00:00
Matthew Waters
1d33d1c8ea avviddec: take the maximum of the height/coded_height
Otherwise, some h.264 streams (particularly with cropping information)
may cause memory corruption after a renegotiation to a smaller size when
decoded and then ffmpeg writes past the end of the buffer.

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-libav/-/issues/80
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/110>
2021-02-17 03:41:28 +00:00
Matthew Waters
f166c9d234 viddec: don't configure and incorrect buffer pool when receiving a gap event
Scenario is this:
1. libav receives enough data to want a buffer with get_buffer2()
   which wants a buffer pool with a certain format, say Y42B but does
   not negotiate and therefore GstVideoDecoder does not have any output
   state configured
2. A gap event is received which GstVideoDecoder wants to forward.  It
   needs caps to forward the gap event so attempts to negotiate with some
   default information which chooses e.g. I420 and overwrites the
   previously configured bufferpool decided on by get_buffer2()
3. There is a mismatch between what ensure_internal_pool() check for
   consistency and what decide_allocation() sets when overriding the
   internal pool with the downstream pool.
4. FFMpeg then requests a Y42B buffer from an I420 pool and predictably
   crashes writing past the contents of the buffer

This is fixed by keeping track of the internal pool states correctly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/116>
2021-02-17 03:13:21 +00:00
Vivia Nikolaidou
96dd596e54 avviddec: Support for alternate-field interlacing
Not yet supported in FFmpeg, so we temporarily rely on the parser
setting the correct buffer flags for us.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/115>
2021-02-03 15:42:58 +02:00
Sebastian Dröge
1d671c7b89 avauddec/audenc/videnc: Don't return GST_FLOW_EOS when draining
Same behaviour as for avviddec now. FFmpeg will return AVERROR_EOF when it's
completely drained but we should not return that here or otherwise
upstream will receive EOS and not forward us more data.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/97>
2020-09-30 16:31:16 +03:00
Seungha Yang
72933810f5 avviddec: Don't return GST_FLOW_EOS from drain()/finish()
AVERROR_EOF means that it's fully drained, but it doesn't
mean that that end of stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/90>
2020-09-16 03:13:09 +09:00
Sebastian Dröge
90a079cc8d avviddec: Forward flow returns from draining instead of assuming OK
It might be useful for upstream to know that draining/finishing didn't
succeed, and why.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/90>
2020-09-14 14:24:51 +03:00
Sebastian Dröge
6a9b42557e Update for gst_video_transfer_function_*() function renaming
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/89>
2020-09-07 12:15:17 +03:00
Vivia Nikolaidou
88fa030ab1 avviddec: Fix typo that duplicated closed caption meta
We examined the output buffer, instead of the input buffer, for
existence of cc meta.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/83>
2020-07-07 00:33:22 +03:00
Vivia Nikolaidou
83190c4ec0 gstavviddec: Only allow a single closed caption meta
Following discussion in
https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1396#note_556068

While it is technically possible to store multiple closed caption metas
in the same buffer, we don't currently do that anywhere and for
H264/MPEG2 both parts have to be stored in the same packet, and also the
number of CC bytes you can store per frame is rather limited. This
restriction might be relaxed later once we figured out how to do it
without breaking things.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/82>
2020-07-03 07:02:05 +00:00
Mathieu Duponchelle
1c436201ce plugins: uddate gst_type_mark_as_plugin_api() calls 2020-06-06 00:43:02 +02:00
Sebastian Dröge
5738a8c1d6 plugins: Use gst_type_mark_as_plugin_api() for all non-element plugin types 2020-05-31 10:03:17 +03:00
Matej Knopp
b1b49a0913 gstavviddec: only set range when actually reported by avcodec
otherwise we get incomplete colorimetry that video-info complains about

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/70>
2020-05-09 14:56:25 +02:00
Seungha Yang
39e6f846e0 avviddec: Update for video-hdr struct change
See the change of -base https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/594
2020-04-01 14:07:48 +09:00
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