Commit graph

1499 commits

Author SHA1 Message Date
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
Doug Nazar
a98eafa5a7 avmux: Blacklist ttml subtitles
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/133>
2021-04-29 21:32:18 -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
Tim-Philipp Müller
07b43c727c avdemux: fix build with FFmpeg 4.4
Direct access to avstream->index_entries was removed
in favour of the newly added avformat_index_get_entry()
and friends.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-libav/-/issues/85

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/127>
2021-04-13 01:14:52 +01:00
Nicholas Jackson
ad7f7c87f0 avmux: fix segfault when a plugin's long_name is NULL
Some plugins register an empty long_name field.  Check for this
before calling strcmp to avoid a crash.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/114>
2021-03-16 15:44:23 +00:00
Jade Macho
1b81e05ab9 Hook up audio/x-xma: xmaversion: [1,2] to AV_CODEC_ID_XMA[1,2]
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/124>
2021-03-15 20:35:35 +01:00
Sebastian Dröge
dcea8baa14 avcodecmap: Don't try converting channel layouts with more than 64 channels
We only support up to 64 channels in GStreamer with a specific layout so
it's safe to assume a NONE layout in this case.

Also the arrays of channel positions are allocated everywhere with 64
elements so don't try setting more than 64 to NONE as that will cause
stack corruptions and similar memory safety issues.

Thanks to Natalie Silvanovich for reporting this issue.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-libav/-/issues/92

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/120>
2021-03-15 18:56:06 +02: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
Seungha Yang
8f2cab6c03 avauddec: Drain decoder on decoding failure
... and call finish_frame() so that baseclass can reset internal
status. Otherwise baseclass will keep holding the status for
decoding failed frame which will result in outputting buffer with
wrong timestamp.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/112>
2020-12-29 16:27:30 +00:00
Jan Schmidt
d3c4740fb6 codec map: Add a mapping for the OKI ADPCM variant.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/111>
2020-12-14 11:09:35 +02:00
Arun Raghavan
b6acd99239 avauddec: Check planar-ness of frame rather than context
The check seems to be to present to verify that the decoded frame
matches the format we expect. The actual check for the layout of the
frame was being performed against the context instead.

The check fails at least for avdec_aptx_hd, where the AVCodecContext has
the sample format set to AV_SAMPLE_FMT_NONE.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/107>
2020-10-27 07:08:12 -04:00
Seungha Yang
89bb244ab9 avaudenc/avvidenc: Reopen encoding session if it's required
Since the commit https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/22b25b3ea5c,
ffmpeg will not clear draning flag for encoder by avcodec_flush_buffers() API
by default. Allowed case is only if encoder has AV_CODEC_CAP_ENCODER_FLUSH
capability flag. If it's not supported, we should re-open encoding
session, otherwise ffmpeg encoder will keep returning AVERROR_EOF

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/99>
2020-10-06 19:21:36 +09:00
Sebastian Dröge
e30cef4129 avvidenc: Call avcodec_flush_buffers() after draining to allow accepting new input again
This is already done in all other codec elements.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/97>
2020-10-01 11:18:58 +03: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
Seungha Yang
7388b14423 avauddec: Ensure finish_subframe() and finish_frame() are paired
audiodecoder baseclass implementation is expecting that
finish_subframe() is followed by finish_frame() in order clear
its internal state related to subframe.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/90>
2020-09-15 02:13:34 +09:00
Sebastian Dröge
6ea6f1545b avauddec: 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:30:35 +03: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
Edward Hervey
c6e51f404d avauddec: Avoid dropping non-OK flow return
When sucessfully finishing out frames (or finishing configuration), we must make
sure we don't override any failing GstFlowReturn that might have been detected
previously.

Failure to do this would result in not propagating not-linked, flushing,
etc...

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/90>
2020-09-14 14:22:24 +03:00
Olivier Crête
c77e13b9b3 avcodecmap: Enable 24 bit WMA Lossless decoding
This now works with not so recent ffmpeg.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/88>
2020-09-09 15:25:41 -04: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
Jordan Petridis
8d3c0a1f8a gstavcfg.c: fix max->min typo in limits and implict double conversion
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/86>
2020-08-04 18:56:45 +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
Matej Knopp
d84b922b7f avauddec: fix buffer leak when send packet failed
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/81>
2020-06-30 18:39:59 +02:00
Sebastian Dröge
f7371f8691 avcodecmap: Add support for SpeedHQ video codec
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/79>
2020-06-26 16:11:18 +03:00
Mathieu Duponchelle
e2c4828699 avmux: zero-initialize packets
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/76>
2020-06-20 00:36:48 +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
Sebastian Dröge
74bb89eb89 avcodecmap: Remove unused GstFFMpegCompliance type 2020-05-31 10:03:17 +03:00
Mathieu Duponchelle
a5850215ba avdemux: update the context we use to determine stream's caps
The discovered frame rate is only available on the AVStream
itself. Updating the temporary context framerate before
building caps from it seems like a pretty non-intrusive approach.

Fixes #75

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/74>
2020-05-27 16:34:10 +02:00
Mathieu Duponchelle
797c7e1bdf avcodecmap: use framerate instead of time_base when decoding
Documentation for AVCodecContext::time_base:

> decoding: the use of this field for decoding is deprecated.
> Use framerate instead.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/74>
2020-05-27 16:29:27 +02:00
Matej Knopp
0a985ff677 gstlibav: minor fixes for header files
Move G_BEGIN_DECLS below includes and add missing include

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-libav/-/merge_requests/71>
2020-05-09 19:09:41 +00: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
Haihao Xiang
3c6432698e avmux: avoid to use unintialized variable
Without this fix, running the command below will get an error randomly.

Example:
gst-launch-1.0 videotestsrc ! vp9enc ! avmux_ivf ! fakesink

ERROR: pipeline doesn't want to preroll.
0:00:02.388528491 30148 0x5601b424a370 ERROR                  libav :0::
Tag [1]V[0][0] incompatible with output codec id '167' (VP90)
2020-04-15 15:00:02 +08: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
Julien Isorce
c8b8884791 avvidenc: handle GST_VIDEO_MULTIVIEW_MODE_MONO
Otherwise videotestsrc ! avenc_libx265 ! fakesink
outputs `Unsupported multiview mode - no mapping in libav`
2020-01-27 14:22:13 -08:00
Sebastian Dröge
63555e5cc7 avcodecmap: Add some more comments about the assumptions in the ffmpeg code about H264/H265/AAC 2020-01-24 16:14:28 +02:00
Sebastian Dröge
34b1eb117f avdemux: Only set stream-format for H264/H265/AAC when we have a context
Otherwise we don't know yet whether we'll have extradata/codec_data, so
can't decide on the stream-format yet.
2020-01-24 11:05:53 +00:00
Haihao Xiang
4f51000920 avivf_mux: support VP9 and AV1
Besides vp8, ff_ivf_muxer supports VP9 and AV1
2020-01-24 10:15:44 +00:00
Sebastian Dröge
c057fef347 avcodecmap: Set AAC/H264/H265 stream-format for demuxer/encoder situations if no codec_data is provided
This fixes output of the above formats from demuxers.
2020-01-24 08:50:53 +00:00
Sebastian Dröge
6c3fc7a16d avdemux: Pass the URI from the URI query to avformat_open_input()
Some demuxers make use of it in various ways, for example the HLS
demuxer.
2020-01-23 11:58:29 +02: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
Edward Hervey
5a9f3d4bf1 avvidenc: Fix error propagation
Instead of returning the default return value (GST_FLOW_OK), actually
return an error one (res vs ret).
2019-11-29 11:33:41 +01:00
Kevin JOLY
9e56619b10 avdemux: Fix segmentation fault if long_name is NULL
Some plugins (like libcdio) registers empty long_name field. Calling strncmp on this field leads to a segmentation fault.

Signed-off-by: Kevin Joly <joly.kevin25@gmail.com>
2019-11-04 16:14:05 +01: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