]> git.sesse.net Git - ffmpeg/log
ffmpeg
4 years agoavcodec/pcm_rechunk_bsf: add bitstream filter to rechunk pcm audio
Marton Balint [Tue, 24 Mar 2020 22:24:22 +0000 (23:24 +0100)]
avcodec/pcm_rechunk_bsf: add bitstream filter to rechunk pcm audio

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavformat/mux: add proper support for full N:M bitstream filtering
Marton Balint [Sat, 18 Apr 2020 12:20:51 +0000 (14:20 +0200)]
avformat/mux: add proper support for full N:M bitstream filtering

Previously only 1:1 bitstream filters were supported, the end of the stream was
not signalled to the bitstream filters and time base changes were ignored.

This change also allows muxers to set up bitstream filters regardless of the
autobsf flag during write_header instead of during check_bitstream and those
bitstream filters will always be executed.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavformat/mux: factorize writing a packet
Marton Balint [Fri, 27 Mar 2020 01:22:53 +0000 (02:22 +0100)]
avformat/mux: factorize writing a packet

In preparation for N:M bsf support.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavformat/mux: factorize interleaved write_packet
Marton Balint [Thu, 26 Mar 2020 23:00:53 +0000 (00:00 +0100)]
avformat/mux: factorize interleaved write_packet

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavformat/mux: move interleaved packet functions upwards
Marton Balint [Mon, 27 Apr 2020 19:07:07 +0000 (21:07 +0200)]
avformat/mux: move interleaved packet functions upwards

Will be needed later to avoid a forward declaration.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavformat/hlsenc: Remove redundant setting of output format
Andreas Rheinhardt [Sat, 29 Feb 2020 01:21:34 +0000 (02:21 +0100)]
avformat/hlsenc: Remove redundant setting of output format

avformat_alloc_output_context2() already sets the oformat member, so
that there is no reason to overwrite it again with the value it already
has.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/profiles: remove duplicate FF_PROFILE_RESERVED entry
Limin Wang [Tue, 5 May 2020 14:43:10 +0000 (22:43 +0800)]
avcodec/profiles: remove duplicate FF_PROFILE_RESERVED entry

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/dashdec: compute the segment size use current pos minus offset plus one
Steven Liu [Wed, 6 May 2020 06:51:22 +0000 (14:51 +0800)]
avformat/dashdec: compute the segment size use current pos minus offset plus one

because the offset should use one byte

Reviewed-by: Zhao Jun <barryjzhao@tencent.com>
Reported-by: Zhao Jun <barryjzhao@tencent.com>
Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
4 years agoavformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet
Limin Wang [Tue, 21 Apr 2020 15:35:24 +0000 (23:35 +0800)]
avformat/mux: Set AV_PKT_FLAG_KEY for is_intra_only packet

The patch will make audio and subtitle packets be marked as AV_PKT_FLAG_KEY.

For audio, it'll caused the audio sample to be sync sample.
To verify ref/fate/movenc results:
1. Get the movenc test data
[lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_old && mv *.mp4 audio_old_

After applied the patch:
[lmwang@vpn ffmpeg]$ make fate-movenc SAMPLES=../fate-suite
[lmwang@vpn ffmpeg]$ libavformat/tests/movenc -w && mkdir -p audio_key && mv *.mp4 audio_key

2. Get l-smash and build boxdumper
https://github.com/l-smash/l-smash.git

3. dump the box of crc change mp4 and diff -u
[lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box audio_key/non-empty-moov-no-elst.mp4  > audio_key/non-empty-moov-no-elst.log
[lmwang@vpn ffmpeg]$ ../l-smash/cli/boxdumper --box audio_old/non-empty-moov-no-elst.mp4  > audio_old/non-empty-moov-no-elst.log
[lmwang@vpn ffmpeg]$ diff -u audio_key/non-empty-moov-no-elst.log audio_old/non-empty-moov-no-elst.log
-                default_sample_flags = 0x02000000
-                    independent
-                    sync sample
+                default_sample_flags = 0x01010000
+                    dependent
+                    non-sync sample

4. have checked the change of crc are caused by default_sample_flags
non-empty-moov.mp4, non-empty-moov-elst.mp4,
non-empty-moov-no-elst.mp4, empty-moov.mp4, delay-moov-content.mp4,
empty-moov-second-frag.mp4, empty-moov-second-frag-discont.mp4,
delay-moov-second-frag-discont.mp4, delay-moov-elst-second-frag.mp4
etc

5 For subtitle, it'll effect for tests/ref/fate/binsub-movtextenc and
tests/ref/fate/sub2video, that's expecting result for the subtitle is
marked as keyframe. Below is the checking result of binsub-movtextenc:

[lmwang@vpn ffmpeg]$ ./ffmpeg -i ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 -flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov audio_key/binsub-movtextenc.mp4
[lmwang@vpn ffmpeg]$ ./ffmpeg -i ../fate-suite/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 -flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov audio_old/binsub-movtextenc.mp4
[lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper audio_key/binsub-movtextenc.mp4  > audio_key/binsub-movtextenc.log
[lmwang@vpn ffmpeg]$../l-smash/cli/boxdumper audio_old/binsub-movtextenc.mp4  > audio_old/binsub-movtextenc.log
[lmwang@vpn ffmpeg]$ diff -u audio_key/binsub-movtextenc.log audio_old/binsub-movtextenc.log
.... // the key difference is the flag for sync sample
-                flags = 0x000701
+                flags = 0x000301
                     data-offset-present
                     sample-duration-present
                     sample-size-present
-                    sample-flags-present
                 sample_count = 6
-                data_offset = 188
+                data_offset = 164
                 sample[0]
                     sample_duration = 1570000
                     sample_size = 21
-                    sample_flags = 0x02000000
-                        independent
-                        sync sample
-                        degradation_priority = 0
                 sample[1]
                     sample_duration = 510000
                     sample_size = 2
-                    sample_flags = 0x01010000
-                        dependent
-                        non-sync sample
-                        degradation_priority = 0
                 sample[2]
                     sample_duration = 1690000
                     sample_size = 9
-                    sample_flags = 0x02000000
-                        independent
-                        sync sample
-                        degradation_priority = 0

Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Suggested-by: Nicolas George <george@nsup.org>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoMAINTAINERS: Add myself to libopenh264enc
Linjie Fu [Thu, 30 Apr 2020 01:12:44 +0000 (09:12 +0800)]
MAINTAINERS: Add myself to libopenh264enc

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/utils: move is_intra_only() to header and rename to ff_is_intra_only()
Limin Wang [Tue, 21 Apr 2020 15:35:23 +0000 (23:35 +0800)]
avformat/utils: move is_intra_only() to header and rename to ff_is_intra_only()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/rtmpproto: use av_reallocp_array()
Limin Wang [Sun, 26 Apr 2020 09:49:22 +0000 (17:49 +0800)]
avformat/rtmpproto: use av_reallocp_array()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/smoothstreamingenc: use av_reallocp_array()
Limin Wang [Sun, 26 Apr 2020 09:49:21 +0000 (17:49 +0800)]
avformat/smoothstreamingenc: use av_reallocp_array()

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agofftools/ffmpeg: use local variable with same contents directly
Limin Wang [Sun, 26 Apr 2020 09:49:17 +0000 (17:49 +0800)]
fftools/ffmpeg: use local variable with same contents directly

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/matroskaenc: Check allocations implicit in dynamic buffers
Andreas Rheinhardt [Wed, 29 Apr 2020 18:55:26 +0000 (20:55 +0200)]
avformat/matroskaenc: Check allocations implicit in dynamic buffers

Failures of the allocations that happen under the hood when using dynamic
buffers are usually completely unchecked and the Matroska muxer is no
exception to this.

The API has its part in this, because there is no documented way to
actually check for errors: The return value of both avio_get_dyn_buf()
as well as avio_close_dyn_buf() is only documented as "the length of
the byte buffer", so that using this to return errors would be an API
break.

Therefore this commit uses the only reliable way to check for errors
with avio_get_dyn_buf(): The AVIOContext's error flag. (This is one of
the advantages of avio_get_dyn_buf(): By not destroying the AVIOContext
it is possible to inspect this value.) Checking whether the size or the
pointer vanishes is not enough as it does not check for truncated output
(the dynamic buffer API is int based and so has to truncate the buffer
even when enough memory would be available; it's current actual limit is
even way below INT_MAX).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Simplify writing buffer
Andreas Rheinhardt [Wed, 29 Apr 2020 18:33:06 +0000 (20:33 +0200)]
avformat/matroskaenc: Simplify writing buffer

If one already has the contents of a master elements in a buffer of
known size, then writing a EBML master element is no different from
writing an EBML binary element. It is overtly complicated to use
start/end_ebml_master() as these functions first write an unkown-length
size field of the appropriate length, then write the buffer's contents,
followed by a seek to the length field to overwrite it with the real
size (obtained via avio_tell() although it was already known in
advance), followed by another seek to the previous position. Just use
put_ebml_binary() instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Avoid dynamic buffer when writing Colour
Andreas Rheinhardt [Wed, 29 Apr 2020 18:22:40 +0000 (20:22 +0200)]
avformat/matroskaenc: Avoid dynamic buffer when writing Colour

There is a good upper bound for the maximum length of the Colour master
element; it is therefore unnecessary to use a dynamic buffer for it.
A simple buffer on the stack is enough. This commit implements this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Unify writing level 1 elements preliminarily
Andreas Rheinhardt [Wed, 29 Apr 2020 04:31:07 +0000 (06:31 +0200)]
avformat/matroskaenc: Unify writing level 1 elements preliminarily

The Matroska muxer updates several header elements when the output is
seekable; if unseekable, the buffer containing the contents of the element
is immediately freed after writing. Before this commit, there were three
places doing exactly the same: Checking whether the output is seekable
and calling the function that writes and frees or the function that
just writes the EBML master. This has been unified; adding SeekHead
entries for these elements has been unified, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Move adding SeekEntry into end_ebml_master_crc32()
Andreas Rheinhardt [Mon, 27 Apr 2020 02:34:45 +0000 (04:34 +0200)]
avformat/matroskaenc: Move adding SeekEntry into end_ebml_master_crc32()

Up until now, SeekEntries were already added before
start_ebml_master_crc32() was even called and before we were actually
sure that we really write the element the SeekHead references: After
all, we might also error out later; and given that the allocations
implicit in dynamic buffers should be checked, end_ebml_master_crc32()
will eventually have to return errors itself, so that it is the right
place to add SeekHead entries.

The earlier behaviour is of course a remnant of the time in which
start_ebml_master_crc32() really did output something, so that the
position before start_ebml_master_crc32() needed to be recorded.
Erroring out later is also not as dangerous as it seems because in
this case no SeekHead will be written (if it happened when writing
the header, the whole muxing process would abort; if it happened
when writing the trailer (when writing chapters not available initially),
writing the trailer would be aborted and no SeekHead containing the
bogus chapter entry would be written).

This commit does not change the way the SeekEntries are added for those
elements that are output preliminarily; this is so because the SeekHead
is written before those elements are finally output and doing it
otherwise would increase the amount of seeks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/hlsenc: Improve checks for invalid stream mappings
Andreas Rheinhardt [Mon, 4 May 2020 22:40:44 +0000 (00:40 +0200)]
avformat/hlsenc: Improve checks for invalid stream mappings

The mapping of streams to the various variant streams to be created by
the HLS muxer is roughly as follows: Space and tab separate variant
stream group maps while the entries in each variant stream group map are
separated by ','.

The parsing process of each variant stream group proceeded as follows:
At first the number of occurences of "a:", "v:" and "s:" in each variant
stream group is calculated so that one can can allocate an array of
streams with this number of entries. Then each entry is checked and the
check for stream numbers was deficient: It did check that there is a
number beginning after the ":", but it did not check that the number
extends until the next "," (or until the end).

This means that an invalid variant stream group like v:0_v:1 will not be
rejected; the problem is that the variant stream in this example is
supposed to have two streams associated with it (because it contains two
"v:"), yet only one stream is actually associated with it (because there
is no ',' to start a second stream specifier). This discrepancy led to
segfaults (null pointer dereferencing) in the rest of the code (when the
nonexistent second stream associated to the variant stream was inspected).

Furthermore, this commit also removes an instance of using atoi() whose
behaviour on a range error is undefined.

Fixes ticket #8652.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agolavf/dashdec: support larger manifests
rcombs [Sat, 2 May 2020 06:33:13 +0000 (01:33 -0500)]
lavf/dashdec: support larger manifests

4 years agoavformat/url: check url root node when rel include double dot and trim double dot
Steven Liu [Wed, 29 Apr 2020 04:50:57 +0000 (12:50 +0800)]
avformat/url: check url root node when rel include double dot and trim double dot

fix ticket: 8625
and add testcase into url for double dot corner case

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
4 years agoavformat/hlsenc: resend full url of the init fragment mp4
Steven Liu [Mon, 4 May 2020 04:00:41 +0000 (12:00 +0800)]
avformat/hlsenc: resend full url of the init fragment mp4

fix ticket: 8651
because the init fragment mp4 file name is without base url name,
so just modify it use the full url which splice after init function.

Tested-by: matclayton
Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
4 years agolibavformat/hlsenc: Allow usage of 'periodic-rekey' with multi-variant streams
Yaroslav Pogrebnyak [Thu, 30 Apr 2020 13:10:53 +0000 (21:10 +0800)]
libavformat/hlsenc: Allow usage of 'periodic-rekey' with multi-variant streams

This patch adds possibility to use 'periodic-rekey' option with
multi-variant streams to hlsenc muxer. All streams variants
use parameters from the same key_info_file.

There are 2 sets of encryption options that kind of overlaps and add
complexity, so I tried to do the thing without changing too much code.

There is a little duplication of the key_file, key_uri, iv_string, etc
in the VariantStream since we copy it from hls to each variant stream,
but generally all the code remains the same to minimise appearing
of unexpected bugs. Refactoring could be done as a separate patch then as needed.

Signed-off-by: Yaroslav Pogrebnyak <yyyaroslav@gmail.com>
4 years agoavformat/hlsenc: compute segment duration use current pts minus last segment end pts
Steven Liu [Wed, 29 Apr 2020 12:39:22 +0000 (20:39 +0800)]
avformat/hlsenc: compute segment duration use current pts minus last segment end pts

segment duration is using vs duration which compute by frame per second,
that can not fix problem of VFR video stream, so compute the duration
when split the segment, set the segment target duration use
current packet pts minus the prev segment end pts..

Reported-by: Zhao Jun <barryjzhao@tencent.com>
Reviewed-by: Zhao Jun <barryjzhao@tencent.com>
Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
4 years agotests/fate/hlsenc: rename fate macro define from FATE_AFILTER to FATE_HLSENC
Steven Liu [Wed, 15 Apr 2020 06:58:15 +0000 (14:58 +0800)]
tests/fate/hlsenc: rename fate macro define from FATE_AFILTER to FATE_HLSENC

and add fate-hlsenc for test all of the testcase
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
4 years agolavc/bsf: add an Opus metadata bitstream filter
Lynne [Sun, 3 May 2020 20:17:33 +0000 (21:17 +0100)]
lavc/bsf: add an Opus metadata bitstream filter

The only adjustable field is the gain. Some ripping/transcoding programs
have started to use it.

4 years agoavcodec/wavpack: Check rate_x and sample rate for overflow
Michael Niedermayer [Sat, 2 May 2020 19:20:45 +0000 (21:20 +0200)]
avcodec/wavpack: Check rate_x and sample rate for overflow

Fixes: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 21647/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVPACK_fuzzer-5686168323883008
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: David Bryant <david@wavpack.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat: add demuxer for Pro Pinball Series' Soundbanks
Zane van Iperen [Mon, 4 May 2020 14:25:56 +0000 (14:25 +0000)]
avformat: add demuxer for Pro Pinball Series' Soundbanks

Adds support for the soundbank files used by the Pro Pinball series of games.

https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2020-May/262094.html

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agolibswscale: add output support for AV_PIX_FMT_GBRAPF32
Mark Reid [Sun, 3 May 2020 23:10:04 +0000 (16:10 -0700)]
libswscale: add output support for AV_PIX_FMT_GBRAPF32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agolibswscale: add input support AV_PIX_FMT_GBRAPF32
Mark Reid [Sun, 3 May 2020 23:10:03 +0000 (16:10 -0700)]
libswscale: add input support AV_PIX_FMT_GBRAPF32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/nutenc: Write size into right dynamic buffer
Andreas Rheinhardt [Mon, 4 May 2020 16:49:22 +0000 (18:49 +0200)]
avformat/nutenc: Write size into right dynamic buffer

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/aviobuf, nutenc: Move ff_puv_v, ff_get_v_length to nutenc.c
Andreas Rheinhardt [Thu, 9 Apr 2020 15:41:50 +0000 (17:41 +0200)]
avformat/aviobuf, nutenc: Move ff_puv_v, ff_get_v_length to nutenc.c

and make it static again.

These functions have been moved from nutenc to aviobuf and internal.h
in f8280ff4c00eeaa245085fa9691035203abd168c in order to use them in a
forthcoming patch in utils.c. Said patch never happened, so this commit
moves them back and makes them static, effectively reverting said
commit as well as f8280ff4c00eeaa245085fa9691035203abd168c (which added
the ff-prefix to these functions).

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/nutenc: Add goto fail in nut_write_headers()
Andreas Rheinhardt [Mon, 4 May 2020 11:06:41 +0000 (13:06 +0200)]
avformat/nutenc: Add goto fail in nut_write_headers()

It allows to combine several ffio_free_dyn_buf().

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/nutenc: Reuse dynamic buffers when possible
Andreas Rheinhardt [Mon, 4 May 2020 10:46:45 +0000 (12:46 +0200)]
avformat/nutenc: Reuse dynamic buffers when possible

NUT uses variable-length integers in order to for length fields.
Therefore the NUT muxer often writes data into a dynamic buffer in order
to get the length of it, then writes the length field using the fewest
amount of bytes needed. To do this, a new dynamic buffer was opened,
used and freed for each element which involves lots of allocations. This
commit changes this: The dynamic buffers are now resetted and reused.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agolibavformat/nutenc: Remove redundant function parameter
Andreas Rheinhardt [Mon, 4 May 2020 09:13:58 +0000 (11:13 +0200)]
libavformat/nutenc: Remove redundant function parameter

calculate_checksum in put_packet() is always 1.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/avpacket: add missing entry for prft to av_packet_side_data_name()
James Almer [Mon, 4 May 2020 15:17:01 +0000 (12:17 -0300)]
avcodec/avpacket: add missing entry for prft to av_packet_side_data_name()

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agolavc/vp9: fix reference frame dimensions check for SINGLE_REFERENCE mode
Linjie Fu [Tue, 17 Mar 2020 14:53:58 +0000 (22:53 +0800)]
lavc/vp9: fix reference frame dimensions check for SINGLE_REFERENCE mode

With the description in frame size with refs semantics (SPEC 7.2.5),
it is a requirement of bitstream conformance that for at least one
reference frame has the valid dimensions.

Modify the check to make sure the decoder works well in SINGLE_REFERENCE
mode that not all reference frames have valid dimensions.

Check and error out if invalid reference frame is used in inter_recon.

One of the failure case is a 480x272 inter frame (SINGLE_REFERENCE mode)
with following reference pool:

0.  960x544    LAST    valid
1. 1920x1088 GOLDEN  invalid, but not used in single reference mode
2. 1920x1088 ALTREF  invalid, but not used in single reference mode
3~7  ...     Unused

Identical logic in libvpx:
<https://github.com/webmproject/libvpx/blob/master/vp9/decoder/vp9_decodeframe.c#L736>

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
4 years agoavcodec/v4l2_m2m_enc: Support changing qmin/qmax
Andriy Gelman [Sun, 19 Jan 2020 06:06:12 +0000 (01:06 -0500)]
avcodec/v4l2_m2m_enc: Support changing qmin/qmax

Hard coded parameters for qmin and qmax are currently used to initialize
v4l2_m2m device. This commit uses values from avctx->{qmin,qmax} if they
are set.

Reviewed-by: Ming Qian <ming.qian@nxp.com>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
4 years agoavcodec/utils: simplify, remove duplicate code
Limin Wang [Thu, 30 Apr 2020 10:29:48 +0000 (18:29 +0800)]
avcodec/utils: simplify, remove duplicate code

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/mxfdec: reindent code
Limin Wang [Mon, 4 May 2020 12:51:24 +0000 (20:51 +0800)]
avformat/mxfdec: reindent code

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavcodec/v4l2_m2m_enc: reindent code
Limin Wang [Wed, 29 Apr 2020 23:23:41 +0000 (07:23 +0800)]
avcodec/v4l2_m2m_enc: reindent code

Reviewed-by: Andriy Gelman <andriy.gelman@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavcodec/prores_metadata_bsf: Use AVCOL_TRC_NB - 1 for the valid max range
Limin Wang [Sun, 3 May 2020 20:58:26 +0000 (04:58 +0800)]
avcodec/prores_metadata_bsf: Use AVCOL_TRC_NB - 1 for the valid max range

Report by Marton after commit.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agolavc/vaapi_encode: add FF_CODEC_CAP_INIT_CLEANUP caps for encoders
Linjie Fu [Tue, 31 Mar 2020 15:34:00 +0000 (23:34 +0800)]
lavc/vaapi_encode: add FF_CODEC_CAP_INIT_CLEANUP caps for encoders

ff_vaapi_encode_close() is not enough to free the resources like cbs
if initialization failure happens after codec->configure (except for
vp8/vp9).

We need to call avctx->codec->close() to deallocate, otherwise memory
leak happens.

Add FF_CODEC_CAP_INIT_CLEANUP for vaapi encoders and deallocate the
resources at free_and_end inside avcodec_open2().

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
4 years agoavformat/matroskadec: Free right buffer on error
Andreas Rheinhardt [Sun, 3 May 2020 06:35:25 +0000 (08:35 +0200)]
avformat/matroskadec: Free right buffer on error

Since commit 979b5b89594c7628bd846c63198cb64ef9d81d16, reverting the
Matroska ContentCompression is no longer done inside
matroska_parse_frame() (the function that creates AVPackets out of the
parsed data (unless we are dealing with certain codecs that need special
handling)), but instead in matroska_parse_block(). As a consequence,
the data that matroska_parse_frame() receives is no longer always owned
by an AVBuffer; it is owned by an AVBuffer iff no ContentCompression needed
to be reversed; otherwise the data is independently allocated and needs
to be freed on error.

Whether the data is owned by an AVBuffer or not is indicated by a variable
buf of type AVBufferRef *: If it is NULL, the data is independently
allocated, if not it is owned by the underlying AVBuffer (and is used to
avoid copying the data when creating the AVPackets).

Because the allocation of the buffer holding the uncompressed data happens
outside of matroska_parse_frame() (if a ContentCompression needs to be
reversed), the data is passed as uint8_t ** in order to not leave any
dangling pointers behind in matroska_parse_block() should the data need to
be freed: In case of errors, said uint8_t ** would be av_freep()'ed in
case buf indicated the data to be independently allocated.

Yet there is a problem with this: Some codecs (namely WavPack and
ProRes) need special handling: Their packets are only stored in
Matroska in a stripped form to save space and the demuxer reconstructs
full packets. This involved allocating a new, enlarged buffer. And if
an error happens when trying to wrap this new buffer into an AVBuffer,
this buffer needs to be freed; yet instead the given uint8_t ** (holding
the uncompressed, yet still stripped form of the data) would be freed
(av_freep()'ed) which certainly leads to a memleak of the new buffer;
even worse, in case the track does not use ContentCompression the given
uint8_t ** must not be freed as the actual data is owned by an AVBuffer
and the data given to matroska_parse_frame() is not the start of the
actual allocated buffer at all.

Both of these issues are fixed by always freeing the current data in
case it is independently allocated. Furthermore, while it would be
possible to track whether the pointer from matroska_parse_block() needs
to be reset or not, there is no gain in doing so, as the pointer is not
used at all afterwards and the sematics are clear: If the data passed
to matroska_parse_frame() is independently allocated, then ownership
of the data passes to matroska_parse_frame(). So don't pass the data
via uint8_t **.

Fixes Coverity ID 1462661 (the issue as described by Coverity is btw
a false positive: It thinks that this error can be triggered by ProRes
with a size of zero after reconstructing the original packets, but the
reconstructed packets can't have a size of zero).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agodoc/muxers: remove hls_fmp4_init_resend parameter
Steven Liu [Mon, 4 May 2020 05:39:44 +0000 (13:39 +0800)]
doc/muxers: remove hls_fmp4_init_resend parameter

the parameter should boolean

4 years agoavcodec/cbs_h265: add missing support for reserved_payload_extension_data SEI bits
James Almer [Fri, 24 Apr 2020 20:41:47 +0000 (17:41 -0300)]
avcodec/cbs_h265: add missing support for reserved_payload_extension_data SEI bits

Fixes ticket #8622

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/cbs_h265: move the payload_extension_present check into its own function
James Almer [Mon, 20 Apr 2020 20:33:55 +0000 (17:33 -0300)]
avcodec/cbs_h265: move the payload_extension_present check into its own function

Will be reused in the following patch.

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/cbs_h265: rename H265RawPSExtensionData to H265RawExtensionData
James Almer [Mon, 20 Apr 2020 18:33:18 +0000 (15:33 -0300)]
avcodec/cbs_h265: rename H265RawPSExtensionData to H265RawExtensionData

So that NAL types other than Parameter Set ones may use it.

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoRevert "avcodec/proresenc_anatoliy: support for more color matrix for proresenc"
Limin Wang [Sun, 3 May 2020 21:22:51 +0000 (05:22 +0800)]
Revert "avcodec/proresenc_anatoliy: support for more color matrix for proresenc"

This reverts commit e0eed1fd523ec5d0cc390a08c468dbc57316378a.

4 years agoavcodec/librav1e: Require a bitrate to be set when using 2-pass mode
Derek Buitenhuis [Sat, 2 May 2020 13:10:48 +0000 (14:10 +0100)]
avcodec/librav1e: Require a bitrate to be set when using 2-pass mode

Not requiring this leads to unexpected result, since Rav1e's current
two pass API has no way to fail in such a case.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
4 years agoffmpeg: Don't require a known device to pass a frames context to an encoder
Mark Thompson [Tue, 28 Apr 2020 22:56:42 +0000 (23:56 +0100)]
ffmpeg: Don't require a known device to pass a frames context to an encoder

The previous code here did not handle passing a frames context when
ffmpeg itself did not know about the device it came from (for example,
because it was created by device derivation inside a filter graph), which
would break encoders requiring that input.  Fix that by checking for HW
frames and device context methods independently, and prefer to use a
frames context method if possible.  At the same time, revert the encoding
additions to the device matching function because the additional
complexity was not relevant to decoding.

Also fixes #8637, which is the same case but with the device creation
hidden in the ad-hoc libmfx setup code.

4 years agoavcodec/h265_metadata: filter parameter sets in packet side data
James Almer [Wed, 22 Apr 2020 15:09:47 +0000 (12:09 -0300)]
avcodec/h265_metadata: filter parameter sets in packet side data

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/h264_metadata: filter parameter sets in packet side data
James Almer [Wed, 22 Apr 2020 15:09:46 +0000 (12:09 -0300)]
avcodec/h264_metadata: filter parameter sets in packet side data

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavcodec/av1_metadata: filter parameter sets in packet side data
James Almer [Wed, 22 Apr 2020 15:09:45 +0000 (12:09 -0300)]
avcodec/av1_metadata: filter parameter sets in packet side data

Extradata included in packet side data is meant to replace the codec context
extradata. So when muxing for example to MP4 without this change and if
extradata is present in a packet side data, the result will be that the
parameter sets present in keyframes will be filtered, but the parameter sets
ultimately included in the av1C box will not.

This is especially important for AV1 as both currently supported encoders don't
export the Sequence Header in the codec context extradata, but as packet side
data instead.

Signed-off-by: James Almer <jamrial@gmail.com>
4 years agoavformat/matroskaenc: Check mimetypes earlier
Andreas Rheinhardt [Sun, 3 Nov 2019 12:25:08 +0000 (13:25 +0100)]
avformat/matroskaenc: Check mimetypes earlier

This avoids errors lateron after the file header has already been
partially written.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Fix memleak upon encountering bogus chapter
Andreas Rheinhardt [Mon, 27 Apr 2020 03:42:09 +0000 (05:42 +0200)]
avformat/matroskaenc: Fix memleak upon encountering bogus chapter

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Make sure UIDs of delayed chapters are != 0
Andreas Rheinhardt [Mon, 27 Apr 2020 01:12:24 +0000 (03:12 +0200)]
avformat/matroskaenc: Make sure UIDs of delayed chapters are != 0

This has previously only been checked if the chapters were initially
available, but not if they were only written in the trailer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/vorbiscomment: Switch to AVIOContext from bytestream API
Andreas Rheinhardt [Tue, 28 Apr 2020 02:54:05 +0000 (04:54 +0200)]
avformat/vorbiscomment: Switch to AVIOContext from bytestream API

Up until now ff_vorbiscomment_write() used the bytestream API to write
VorbisComments. Therefore the caller had to provide a sufficiently large
buffer to write the output.

Yet two of the three callers (namely the FLAC and the Matroska muxer)
actually want the output to be written via an AVIOContext; therefore
they allocated buffers of the right size just for this purpose (i.e.
they get freed immediately afterwards). Only the Ogg muxer actually
wants a buffer. But given that it is easy to wrap a buffer into an
AVIOContext this commit changes ff_vorbiscomment_write() to use an
AVIOContext for its output.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/vorbiscomment: Replace AVDictionary ** by const AVDictionary *
Andreas Rheinhardt [Tue, 28 Apr 2020 01:03:36 +0000 (03:03 +0200)]
avformat/vorbiscomment: Replace AVDictionary ** by const AVDictionary *

ff_vorbiscomment_write() used an AVDictionary ** parameter for a
dictionary whose contents ought to be written; yet this can be replaced
by AVDictionary * since commit 042ca05f0fdc5f4d56a3e9b94bc9cd67bca9a4bc;
and this in turn can be replaced by const AVDictionary * to indicate
that the dictionary isn't modified; the latter also applies to
ff_vorbiscomment_length().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Replace impossible condition with assert
Andreas Rheinhardt [Tue, 28 Apr 2020 00:24:16 +0000 (02:24 +0200)]
avformat/matroskaenc: Replace impossible condition with assert

If a FLAC track uses an unconventional channel layout, the Matroska
muxer adds a WAVEFORMATEXTENSIBLE_CHANNEL_MASK VorbisComment to the
CodecPrivate to preserve this information. And given that FLAC uses
24bit length fields, the muxer checks if the length is more than this
and errors out if it is.

Yet this can never happen, because we create the AVDictionary that is
the source for the VorbisComment. It only contains exactly one entry
that can't grow infinitely large (in fact, the length of the
VorbisComment is <= 4 + 33 + 1 + 18 + strlen(LIBAVFORMAT_IDENT)).
So we can simply assert the size to be < (1 << 24) - 4.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Write SeekHead when livestreaming
Andreas Rheinhardt [Sun, 26 Apr 2020 08:39:27 +0000 (10:39 +0200)]
avformat/matroskaenc: Write SeekHead when livestreaming

Commit 6fd300ac6c2c3871736ce0e6df95603255004dc6 added support for WebM
Chunk livestreaming; in this case, both the header as well as each
Cluster is written to a file of its own, so that even if the AVIOContext
seems seekable, the muxer has to behave as if it were not. Yet one of
the added checks makes no sense: It ensures that no SeekHead is written
preliminarily (and hence no SeekHead is written at all) if the option
for livestreaming is set, although one should write the SeekHead in this
case when writing the Header. E.g. the WebM-DASH specification [1]
never forbids writing a SeekHead and in some instances (that don't apply
here) even requires it (if Cues are written after the Clusters).

[1]: https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskaenc: Only write Cluster if it has in fact been opened
Andreas Rheinhardt [Sat, 2 May 2020 00:18:44 +0000 (02:18 +0200)]
avformat/matroskaenc: Only write Cluster if it has in fact been opened

Since commit 4aa0665f393847c35387a1c673e62346d0acfc95, the dynamic
buffer destined for the contents of the current Cluster is no longer
constantly allocated, reallocated and then freed after writing the
content; instead it is reset and reused when closing a Cluster.

Yet the code in mkv_write_trailer() still checked for whether a Cluster
is open by checking whether the pointer to the dynamic buffer is NULL or
not (instead of checking whether the position of the current Cluster is
-1 or not). If a Cluster was not open, an empty Cluster would be output.

One usually does not run into this issue, because unless there are
errors, there are only three possibilities to not have an opened Cluster
at the end of writing a packet:
The first is if one sent an audio packet to the muxer. It might trigger
closing and outputting the old Cluster, but because the muxer caches
audio packets internally, it would not be output immediately and
therefore no new Cluster would be opened.
The second is an audio packet that does not contain data (such packets
are sometimes sent for side-data only, e.g. by the FLAC encoder). The
only difference to the first scenario is that such packets are not
cached.
The third is if one explicitly flushes the muxer by sending a NULL
packet via av_write_frame().

If one also allows for errors, then there is also another possibility:
Caching the audio packet may fail in the first scenario.

If one calls av_write_trailer() after the first scenario, the cached
audio packet will be output when writing the trailer, for which
a Cluster is opened and everything is fine; because flushing the muxer
does currently not output the cached audio packet (if one is cached),
the issue also does not exist if an audio packet has been cached before
flushing. The issue only exists in one of the other scenarios.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavcodec/proresenc_anatoliy: support for more color matrix for proresenc
Limin Wang [Tue, 5 Nov 2019 02:31:51 +0000 (10:31 +0800)]
avcodec/proresenc_anatoliy: support for more color matrix for proresenc

Please tested with below command:
./ffmpeg -i ../fate-suite/mpeg2/t.mpg  -c:v prores_aw -color_primaries bt2020 -colorspace bt2020_ncl -color_trc smpte2084 -an output.mov

mediainfo outout.mov
...
Color primaries                          : BT.2020
Transfer characteristics                 : PQ
Matrix coefficients                      : BT.2020 non-constant

./ffmpeg -i ../fate-suite/mpeg2/t.mpg  -c:v prores_aw -color_primaries bt2020 -colorspace bt2020_ncl -color_trc arib-std-b67 -an output.mov
mediainfo outout.mov
...
Color primaries                          : BT.2020
Transfer characteristics                 : HLG
Matrix coefficients                      : BT.2020 non-constant

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavcodec/prores_metadata_bsf: add arib-std-b67 format support
Limin Wang [Mon, 4 Nov 2019 11:10:01 +0000 (19:10 +0800)]
avcodec/prores_metadata_bsf: add arib-std-b67 format support

It's based on the following specs:
RDD 45:2017 - SMPTE Registered Disclosure Doc - Interoperable Master Format - Application ProRes

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavcodec/prores_metadata_bsf: add smpte2084 format support
Limin Wang [Mon, 4 Nov 2019 11:10:00 +0000 (19:10 +0800)]
avcodec/prores_metadata_bsf: add smpte2084 format support

It's based on the following specs:
RDD 36:2015 - SMPTE Registered Disclosure Doc - Apple ProRes Bitstream Syntax and Decoding Process

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavcodec/nvenc_hevc: add spatial-aq and temporal-aq option to consistent with nvenc_h264
Limin Wang [Wed, 15 Apr 2020 02:09:01 +0000 (10:09 +0800)]
avcodec/nvenc_hevc: add spatial-aq and temporal-aq option to consistent with nvenc_h264

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavcodec/nvenc_h264: add spatial_aq and temporal_aq option to consistent with nvenc_hevc
Limin Wang [Wed, 15 Apr 2020 02:09:00 +0000 (10:09 +0800)]
avcodec/nvenc_h264: add spatial_aq and temporal_aq option to consistent with nvenc_hevc

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/libsrt: change open_timeout to int64_t to avoid integer overflow
Limin Wang [Tue, 31 Mar 2020 14:08:08 +0000 (22:08 +0800)]
avformat/libsrt: change open_timeout to int64_t to avoid integer overflow

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/libsrt: clarify option description for timeout and latency unit of measurement
Limin Wang [Tue, 31 Mar 2020 14:08:07 +0000 (22:08 +0800)]
avformat/libsrt: clarify option description for timeout and latency unit of measurement

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agodoc/protocols: clarify timeout and latency unit of measurement for SRT
Limin Wang [Tue, 31 Mar 2020 14:08:06 +0000 (22:08 +0800)]
doc/protocols: clarify timeout and latency unit of measurement for SRT

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agofftools/ffmpeg: use a bsf list instead of individual bsfs
Marton Balint [Fri, 17 Apr 2020 21:55:55 +0000 (23:55 +0200)]
fftools/ffmpeg: use a bsf list instead of individual bsfs

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavcodec/bsf: support shorthand options for av_bsf_list_parse_str
Marton Balint [Fri, 17 Apr 2020 22:58:18 +0000 (00:58 +0200)]
avcodec/bsf: support shorthand options for av_bsf_list_parse_str

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavcodec/decode: use a single list bsf for codec decode bsfs
Marton Balint [Sat, 25 Apr 2020 21:48:21 +0000 (23:48 +0200)]
avcodec/decode: use a single list bsf for codec decode bsfs

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agofftools/ffprobe: show closed caption info in the stream dump
vectronic [Wed, 29 Apr 2020 16:14:33 +0000 (17:14 +0100)]
fftools/ffprobe: show closed caption info in the stream dump

Signed-off-by: vectronic <hello.vectronic@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavcodec/vp9dsp_template: Fix integer overflows in idct32_1d()
Michael Niedermayer [Tue, 11 Feb 2020 21:58:08 +0000 (22:58 +0100)]
avcodec/vp9dsp_template: Fix integer overflows in idct32_1d()

Fixes: signed integer overflow: -193177 * 11585 cannot be represented in type 'int'
Fixes: 20557/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-5704852816789504
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/alacdsp: Fix invalid shift in append_extra_bits()
Michael Niedermayer [Sun, 26 Apr 2020 17:29:39 +0000 (19:29 +0200)]
avcodec/alacdsp: Fix invalid shift in append_extra_bits()

Fixes: left shift of negative value -1
Fixes: 21390/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALAC_fuzzer-6242539519868928
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agolibavcodec/wmalosslessdec: prevent sum of positive numbers from becoming negative
Michael Niedermayer [Sun, 9 Feb 2020 17:09:24 +0000 (18:09 +0100)]
libavcodec/wmalosslessdec: prevent sum of positive numbers from becoming negative

Fixes: left shift of negative value -8321365
Fixes: 20506/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-4798062906310656
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/dstdec: Fix integer overflow in read_table()
Michael Niedermayer [Sat, 8 Feb 2020 23:23:14 +0000 (00:23 +0100)]
avcodec/dstdec: Fix integer overflow in read_table()

Fixes: signed integer overflow: -16 * 134217879 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-5639509530378240
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agodoc/mailing-list-faq: Mention current problem with GMX
Michael Niedermayer [Sat, 2 May 2020 09:50:18 +0000 (11:50 +0200)]
doc/mailing-list-faq: Mention current problem with GMX

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agolavc/opus: Reset alloc_trim when doing decoder bit-allocation.
Carl Eugen Hoyos [Sat, 2 May 2020 08:09:01 +0000 (10:09 +0200)]
lavc/opus: Reset alloc_trim when doing decoder bit-allocation.

Fixes ticket #8649.
Reported-by: irc user Xogium
4 years agos->target_i and global are in dB but s->target_tp and true_peak are
Sebastian Dröge [Sat, 2 May 2020 03:52:00 +0000 (20:52 -0700)]
s->target_i and global are in dB but s->target_tp and true_peak are
linear. Instead of mixing these in the calculations, convert the former
first to have all following calculations in the same unit.

Signed-off-by: Kyle Swanson <k@ylo.ph>
4 years agoavcodec/nvenc: refactor dts calculation logic
Timo Rothenpieler [Fri, 1 May 2020 21:42:56 +0000 (23:42 +0200)]
avcodec/nvenc: refactor dts calculation logic

The old approach used some highly complex delta computation math and
output-delaying.
I do not remember what the initial reasoning behind that was, but given
that we can just offset the dts by the amount of bframes, it seems wholy
unnecessary.

This leaves open an issue with VFR content, for which some more complex
logic might be needed.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
4 years agoac3enc: fix AC3 downmix metadata issue
Piotr Oleszczyk [Thu, 30 Apr 2020 16:17:36 +0000 (18:17 +0200)]
ac3enc: fix AC3 downmix metadata issue

Due to a typo, it was impossible to write 0.595 / -4.5 dB
of ltrt_cmixlev, ltrt_surmixlev, loro_cmixlev, loro_surmixlev.
Without any error 0.841 / -1.5 dB was written to file.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/oggdec: Reallocate buffer before writing into it
Michael Niedermayer [Fri, 1 May 2020 12:34:18 +0000 (14:34 +0200)]
avformat/oggdec: Reallocate buffer before writing into it

Fixes: out of array write
Fixes: Regression since f619e1ec66b89215582eff4404b681b760540b4f
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavformat/oggdec: Factor buffer reallocation out
Michael Niedermayer [Fri, 1 May 2020 12:33:46 +0000 (14:33 +0200)]
avformat/oggdec: Factor buffer reallocation out

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
4 years agoavcodec/librav1e: Use the framerate when available for ratecontrol
Derek Buitenhuis [Thu, 30 Apr 2020 19:06:43 +0000 (20:06 +0100)]
avcodec/librav1e: Use the framerate when available for ratecontrol

Rav1e currently uses the time base given to it only for ratecontrol... where
the inverse is taken and used as a framerate. So, do what we do in other wrappers
and use the framerate if we can.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
4 years agoavcodec/nvenc: offset dts to account for b-frame reordering
Timo Rothenpieler [Fri, 1 May 2020 18:51:26 +0000 (20:51 +0200)]
avcodec/nvenc: offset dts to account for b-frame reordering

Fixes ticket #7303

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
4 years agoavformat/hlsenc: add support for microseconds since epoch based sequence number
Marton Balint [Sat, 18 Apr 2020 20:15:39 +0000 (22:15 +0200)]
avformat/hlsenc: add support for microseconds since epoch based sequence number

Sequence numbers of segments should be unique, if an encoder is using shorter
than 1 second segments and it is restarted, then future segments will be using
already used sequence numbers if initial sequence number is based on the number
of seconds since epoch and not microseconds.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agoavutil/opt: only skip evaluation for rational options
Marton Balint [Sat, 18 Apr 2020 19:37:45 +0000 (21:37 +0200)]
avutil/opt: only skip evaluation for rational options

Fixes problems when non-rational options were set using rational expressions,
causing rounding errors and the option range limits not to be enforced
properly.

ffmpeg -f lavfi -i "sine=r=96000/2"

This caused an assertion failure with assert level 2.

Signed-off-by: Marton Balint <cus@passwd.hu>
4 years agodoc/utils: add more examples for valid time duration
Limin Wang [Wed, 8 Apr 2020 02:10:44 +0000 (10:10 +0800)]
doc/utils: add more examples for valid time duration

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/concat: priv_data should be freed internally
Limin Wang [Fri, 3 Apr 2020 13:03:06 +0000 (21:03 +0800)]
avformat/concat: priv_data should be freed internally

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/dashenc: remove the arbitrary restrictions for filename
Limin Wang [Wed, 8 Apr 2020 01:34:28 +0000 (09:34 +0800)]
avformat/dashenc: remove the arbitrary restrictions for filename

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavcodec/mpeg12enc: Use FF_PROFILE_MPEG2_xxx macros
Limin Wang [Fri, 3 Apr 2020 13:04:53 +0000 (21:04 +0800)]
avcodec/mpeg12enc: Use FF_PROFILE_MPEG2_xxx macros

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
4 years agoavformat/matroskadec: Cosmetics
Andreas Rheinhardt [Fri, 6 Dec 2019 23:11:01 +0000 (00:11 +0100)]
avformat/matroskadec: Cosmetics

Reindentation as well as marking several variables used for demuxing
RealAudio as const to clearly see that they don't change during
demuxing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskadec: Support ContentCompression for all codecs
Andreas Rheinhardt [Fri, 6 Dec 2019 08:53:34 +0000 (09:53 +0100)]
avformat/matroskadec: Support ContentCompression for all codecs

The Matroska demuxer has three functions for creating packets out of
the data read: One for certain RealAudio codecs (ATRAC3, cook, sipr,
RealAudio 28.8), one for WebVTT (actually, the WebM flavour of it) and
one for all the others. Only the last function supported Matroska's
ContentCompression (e.g. it reversed zlib compression or added the
removed headers to the packets). But in Matroska, all tracks are allowed
to be compressed. This commit adds support for this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskadec: Cache whether a track needs to be decoded
Andreas Rheinhardt [Wed, 4 Dec 2019 16:54:45 +0000 (17:54 +0100)]
avformat/matroskadec: Cache whether a track needs to be decoded

There is no need to recheck this for every frame.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskadec: Improve forward compability
Andreas Rheinhardt [Wed, 25 Mar 2020 05:52:09 +0000 (06:52 +0100)]
avformat/matroskadec: Improve forward compability

Matroska is built around the principle that a reader does not need to
understand everything in a file in order to be able to make use of it;
it just needs to ignore the data it doesn't know about.

Our demuxer typically follows this principle, but there is one important
instance where it does not: A Block belonging to a TrackEntry with no
associated stream is treated as invalid data (i.e. the demuxer will try
to resync to the next level 1 element because it takes this as a sign
that it has lost sync). Given that we do not create streams if we don't
know or don't support the type of the TrackEntry, this impairs this
demuxer's forward compability.

Furthermore, ignoring Blocks belonging to a TrackEntry without
corresponding stream can (in future commits) also be used to ignore
TrackEntries with obviously bogus entries without affecting the other
TrackEntries (by not creating a stream for said TrackEntry).

Finally, given that matroska_find_track_by_num() already emits its own
error message in case there is no TrackEntry with a given TrackNumber,
the error message (with level AV_LOG_INFO) for this can be removed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskadec: Don't discard valid packets
Andreas Rheinhardt [Wed, 25 Mar 2020 05:00:53 +0000 (06:00 +0100)]
avformat/matroskadec: Don't discard valid packets

A Block (meaning both a Block in a BlockGroup as well as a SimpleBlock)
must have at least three bytes after the field containing the encoded
TrackNumber. So if there are <= 3 bytes, the Matroska demuxer would
skip this block, believing it to be an empty, but valid Block.

This might discard valid nonempty Blocks, namely if the track uses header
stripping. And certain definitely spec-incompliant Blocks don't raise
errors: Those with two or less bytes left after the encoded TrackNumber
and those with three bytes left, but with flags indicating that the Block
uses lacing as then there has to be further data describing the lacing.

Furthermore, zero-sized packets were still possible because only the
size of the last entry of a lace was checked.

This commit fixes this. All spec-compliant Blocks that contain data
(even if side data only) are now returned to the caller; spec-compliant
Blocks that don't contain anything are not returned.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
4 years agoavformat/matroskadec: Simplify checks for cook and ATRAC3
Andreas Rheinhardt [Mon, 20 Apr 2020 06:54:23 +0000 (08:54 +0200)]
avformat/matroskadec: Simplify checks for cook and ATRAC3

Some conditions which don't change and which can therefore be checked
in read_header() were instead rechecked upon parsing each block. This
has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>