]> git.sesse.net Git - ffmpeg/log
ffmpeg
3 years agoswscale/x86/yuv2rgb: fix crashes when loading alpha from unaligned buffers
Marton Balint [Wed, 28 Oct 2020 22:11:37 +0000 (23:11 +0100)]
swscale/x86/yuv2rgb: fix crashes when loading alpha from unaligned buffers

Regression since fc6a5883d6af8cae0e96af84dda0ad74b360a084 on SSSE3 enabled
CPUs.

Fixes ticket #8955.

Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agofate: Add test for Musepack SV8 decoding
Andreas Rheinhardt [Fri, 30 Oct 2020 11:48:17 +0000 (12:48 +0100)]
fate: Add test for Musepack SV8 decoding

While the FATE suite contains a sample file for Musepack 8, it did not
use it to test the decoder; it is only used in the mpc8-demux test that
tests the demuxer via streamcopy. Therefore this commit adds an actual
encoder test.

The test uses the framecrc output, because Musepack SV8 is an encoder
that returns multiple frames for a single packet, so that timing
information in the test output is valueable. Output seeking has been
used in order to limit the size of the ref file as well as to test this
codepath for the first time.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agofftools/ffmpeg: fix the wrong bitrate and speed stats
Limin Wang [Tue, 20 Oct 2020 14:51:08 +0000 (22:51 +0800)]
fftools/ffmpeg: fix the wrong bitrate and speed stats

The bitrate and speed stats are wrong if the copyts is enabled.
Please test with below command:
wget http://samples.mplayerhq.hu/MPEG2/foxksaz.ts
./ffmpeg -y -copyts -i ./foxksaz.ts -c:v libx264 -x264opts \
    nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize \
    1000k  -c:a mp2 -muxrate 4500k  -vframes 1000 test.ts

before:
frame= 1000 fps=112 q=-1.0 Lsize=    9063kB time=09:10:12.41 bitrate=   2.2kbits/s speed=3.7e+03x
after:
frame= 1000 fps=112 q=-1.0 Lsize=    9062kB time=00:00:15.78 bitrate=4703.4kbits/s speed=1.77x

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavcodec/nvenc: fix build with older SDKs
Timo Rothenpieler [Fri, 30 Oct 2020 19:43:38 +0000 (20:43 +0100)]
avcodec/nvenc: fix build with older SDKs

3 years agoavformat/wavdec: Refuse to read chunks bigger than the filesize in w64_read_header()
Michael Niedermayer [Sat, 17 Oct 2020 21:50:57 +0000 (23:50 +0200)]
avformat/wavdec: Refuse to read chunks bigger than the filesize in w64_read_header()

Fixes: OOM
Fixes: 26414/clusterfuzz-testcase-minimized-ffmpeg_dem_FWSE_fuzzer-5070632544632832
Fixes: 26475/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5770207722995712
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/rsd: Check size and start before computing duration
Michael Niedermayer [Wed, 21 Oct 2020 16:15:53 +0000 (18:15 +0200)]
avformat/rsd: Check size and start before computing duration

Fixes: signed integer overflow: 100794754 * 28 cannot be represented in type 'int'
Fixes: 26474/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-5181797606096896
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/vividas: better check of current_sb_entry
Michael Niedermayer [Wed, 21 Oct 2020 21:05:41 +0000 (23:05 +0200)]
avformat/vividas: better check of current_sb_entry

This is the simplest fix for the problem, it is possible to instead check
this when the variables are set and propagate errors and then fail earlier

Fixes: out of array access
Fixes: 26490/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5723367078100992
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/iff: More completely check body_size
Michael Niedermayer [Wed, 21 Oct 2020 20:56:17 +0000 (22:56 +0200)]
avformat/iff: More completely check body_size

Fixes: infinite loop
Fixes: 26485/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5126561373880320
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/vividas use avpriv_set_pts_info()
Michael Niedermayer [Wed, 21 Oct 2020 20:16:37 +0000 (22:16 +0200)]
avformat/vividas use avpriv_set_pts_info()

Fixes: assertion failure
Fixes: 26482/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-4905102324006912
Fixes: 26491/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6002953141616640
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/xwma: Check for EOF in dpds_table read code
Michael Niedermayer [Wed, 21 Oct 2020 17:37:45 +0000 (19:37 +0200)]
avformat/xwma: Check for EOF in dpds_table read code

Fixes: Timeout (>30 -> 140ms)
Fixes: 26478/clusterfuzz-testcase-minimized-ffmpeg_dem_XWMA_fuzzer-5918147066200064
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/nvenc: only enforce explicitly set twopass mode
Timo Rothenpieler [Fri, 30 Oct 2020 16:26:32 +0000 (17:26 +0100)]
avcodec/nvenc: only enforce explicitly set twopass mode

3 years agoavcodec/nvenc: only auto-pick vbr rc in cq mode
Timo Rothenpieler [Fri, 30 Oct 2020 16:21:13 +0000 (17:21 +0100)]
avcodec/nvenc: only auto-pick vbr rc in cq mode

3 years agoavformat/mpegtsenc: check that not only first pts but also first dts is valid
Limin Wang [Thu, 29 Oct 2020 01:24:29 +0000 (09:24 +0800)]
avformat/mpegtsenc: check that not only first pts but also first dts is valid

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavformat/mpegtsenc: first_pts_check -> first_pts_checked
Limin Wang [Tue, 27 Oct 2020 14:26:22 +0000 (22:26 +0800)]
avformat/mpegtsenc: first_pts_check -> first_pts_checked

change to first_pts_checked and reverse the logic.

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavformat/jacosubdec: Fix unintended fallthrough
Andreas Rheinhardt [Thu, 29 Oct 2020 12:36:22 +0000 (13:36 +0100)]
avformat/jacosubdec: Fix unintended fallthrough

Regression since 715ff75e5dbbbefff7337351db596a9b7a5d4379.

Fixes Coverity issues #1468654 and #1468656.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/nvenc: all presets are SDK10 presets now
Timo Rothenpieler [Thu, 29 Oct 2020 20:59:37 +0000 (21:59 +0100)]
avcodec/nvenc: all presets are SDK10 presets now

3 years agoavcodec/utils: Check sample rate before use for AV_CODEC_ID_BINKAUDIO_DCT in get_audi...
Michael Niedermayer [Tue, 27 Oct 2020 16:21:19 +0000 (17:21 +0100)]
avcodec/utils: Check sample rate before use for AV_CODEC_ID_BINKAUDIO_DCT in get_audio_frame_duration()

Fixes: shift exponent 95 is too large for 32-bit type 'int'
Fixes: 26590/clusterfuzz-testcase-minimized-ffmpeg_dem_SMACKER_fuzzer-5120609937522688
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoffmpeg: move field order decision making to encoder initialization
Jan Ekström [Sun, 20 Sep 2020 18:00:52 +0000 (21:00 +0300)]
ffmpeg: move field order decision making to encoder initialization

We now have the possibility of getting AVFrames here, and we should
not touch the muxer's codecpar after writing the header.

Results of FATE tests change as the MXF and Matroska muxers actually
write down the field/frame coding type of a stream in their
respective headers. Before this change, these values in codecpar
would only be set after the muxer was initialized. Now, the
information is also available for encoder and muxer initialization.

3 years agoffmpeg: pass decoded or filtered AVFrame to output stream initialization
Jan Ekström [Thu, 10 Sep 2020 21:36:23 +0000 (00:36 +0300)]
ffmpeg: pass decoded or filtered AVFrame to output stream initialization

Additionally, reap the first rewards by being able to set the
color related encoding values based on the passed AVFrame.

The only tests that seem to have changed their results with this
change seem to be the MXF tests. There, the muxer writes the
limited/full range flag to the output container if the encoder
is not set to "unspecified".

3 years agoffmpeg: move A/V non-streamcopy initialization to a later point
Jan Ekström [Thu, 10 Sep 2020 21:25:21 +0000 (00:25 +0300)]
ffmpeg: move A/V non-streamcopy initialization to a later point

- For video, this means a single initialization point in do_video_out.
- For audio we unfortunately need to do it in two places just
  before the buffer sink is utilized (if av_buffersink_get_samples
  would still work according to its specification after a call to
  avfilter_graph_request_oldest was made, we could at least remove
  the one in transcode_step).

Other adjustments to make things work:
- As the AVFrame PTS adjustment to encoder time base needs the encoder
  to be initialized, so it is now moved to do_{video,audio}_out,
  right after the encoder has been initialized. Due to this,
  the additional parameter in do_video_out is removed as it is no
  longer necessary.

3 years agoffmpeg: move AVFrame time base adjustment into a function
Jan Ekström [Sun, 13 Sep 2020 08:41:41 +0000 (11:41 +0300)]
ffmpeg: move AVFrame time base adjustment into a function

This will have to be called later for video down the line.

3 years agoffmpeg: add a data size threshold for muxing queue size
Jan Ekström [Thu, 15 Oct 2020 18:21:05 +0000 (21:21 +0300)]
ffmpeg: add a data size threshold for muxing queue size

This way the old max queue size limit based behavior for streams
where each individual packet is large is kept, while for smaller
streams more packets can be buffered (current default is at 50
megabytes per stream).

For some explanation, by default ffmpeg copies packets from before
the appointed seek point/start time and puts them into the local
muxing queue. Before, it getting utilized was much less likely
since as soon as the filter chain was initialized, the encoder
(and thus output stream) was also initialized.

Now, since we will be pushing the encoder initialization to when the
first AVFrame is decoded and filtered - which only happens after
the exact seek point is hit as packets are ignored until then -
this queue will be seeing much more usage.

In more layman's terms, this attempts to fix cases such as where:
- seek point ends up being 5 seconds before requested time.
- audio is set to copy, and thus immediately begins filling the
  muxing queue.
- video is being encoded, and thus all received packets are skipped
  until the requested time is hit.

3 years agoavcodec/vp3: Don't check for errors for complete VLC
Andreas Rheinhardt [Mon, 26 Oct 2020 08:46:25 +0000 (09:46 +0100)]
avcodec/vp3: Don't check for errors for complete VLC

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/cllc: Don't unnecessarily free VLC
Andreas Rheinhardt [Sat, 24 Oct 2020 16:05:34 +0000 (18:05 +0200)]
avcodec/cllc: Don't unnecessarily free VLC

The Canopus Lossless decoder uses several VLCs and if initializing the
ith VLC fails, all the VLCs 0..i have been freed; the ith VLC's table is
initialized to NULL for this purpose. Yet it is totally unnecessary to
free the ith VLC table at all: ff_init_vlc_sparse() cleans up after
itself on error and if an error happens before ff_init_vlc_sparse(),
the ith VLC hasn't been touched yet and doesn't need freeing.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/clearvideo: Don't check for errors for complete VLC
Andreas Rheinhardt [Sat, 24 Oct 2020 13:26:55 +0000 (15:26 +0200)]
avcodec/clearvideo: Don't check for errors for complete VLC

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agolavf/url: fix relative url parsing when the query string or fragment has a colon
ruiquan.crq [Sat, 17 Oct 2020 15:17:14 +0000 (23:17 +0800)]
lavf/url: fix relative url parsing when the query string or fragment has a colon

This disallows the usage of ? and # in libavformat specific scheme options
(e.g. subfile,,start,32815239,end,0,,:video.ts) but this change was considered
acceptable.

Signed-off-by: ruiquan.crq <caihaoning83@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
3 years agoavcodec/codec2utils: move the remaining avpriv functions to lavf
James Almer [Mon, 26 Oct 2020 14:18:03 +0000 (11:18 -0300)]
avcodec/codec2utils: move the remaining avpriv functions to lavf

They are only used by the codec2 demuxers.

The symbols are kept around until the next major bump.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agolibavcodec/codec2utils: remove codec2_version_from_extradata()
James Almer [Wed, 28 Oct 2020 14:59:16 +0000 (11:59 -0300)]
libavcodec/codec2utils: remove codec2_version_from_extradata()

It's only used in the codec2 demuxers, and can be simplified with an AV_RB16()
call instead.

Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/codec2utils: remove avpriv prefix from inline functions
James Almer [Mon, 26 Oct 2020 13:58:51 +0000 (10:58 -0300)]
avcodec/codec2utils: remove avpriv prefix from inline functions

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1dec: fix loading PrevGmParams for frames with primary_ref_frame none
James Almer [Wed, 28 Oct 2020 14:23:44 +0000 (11:23 -0300)]
avcodec/av1dec: fix loading PrevGmParams for frames with primary_ref_frame none

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/av1dec: don't derive loop filter delta parameters
James Almer [Tue, 20 Oct 2020 22:37:28 +0000 (19:37 -0300)]
avcodec/av1dec: don't derive loop filter delta parameters

This is now handled by CBS.

Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs_av1: infer segmentation parameters from reference frames
James Almer [Tue, 20 Oct 2020 21:20:24 +0000 (18:20 -0300)]
avcodec/cbs_av1: infer segmentation parameters from reference frames

Partially implements setup_past_independence() and load_previous().
These ensures they are always set, even if the values were not coded
in the input bitstream and will not be coded in the output bitstream.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agoavcodec/cbs_av1: infer loop filter delta parameters from reference frames
James Almer [Tue, 20 Oct 2020 20:48:31 +0000 (17:48 -0300)]
avcodec/cbs_av1: infer loop filter delta parameters from reference frames

Partially implements setup_past_independence() and load_previous().
These ensures they are always set, even if the values were not coded
in the input bitstream and will not be coded in the output bitstream.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
3 years agolavf: move AVStream.last_in_packet_buffer to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.last_in_packet_buffer to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.probe_data to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.probe_data to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.pts_buffer to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.pts_buffer to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.*index_entries* to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.*index_entries* to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header. Since there are some (semi-)public fields located after these,
even though this section is supposed to be private, keep some dummy
padding there until the next major bump to preserve ABI compatibility.

3 years agolavf: move AVStream.interleaver_chunk_* to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.interleaver_chunk_* to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.{request_probe,skip_to_keyframe} to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.{request_probe,skip_to_keyframe} to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.{nb_decoded_frames,mux_ts_offset} to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.{nb_decoded_frames,mux_ts_offset} to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.{pts_wrap_*,update_initial_durations_done} to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.{pts_wrap_*,update_initial_durations_done} to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.pts_reorder_error[_count] to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.pts_reorder_error[_count] to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.{last_dts_for_order_check,dts_[mis]ordered} to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.{last_dts_for_order_check,dts_[mis]ordered} to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.{inject_global_side_data,display_aspect_ratio} to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 07:22:36 +0000 (09:22 +0200)]
lavf: move AVStream.{inject_global_side_data,display_aspect_ratio} to AVStreamInternal

Those are private fields, no reason to have them exposed in a public
header.

3 years agolavf: move AVStream.info to AVStreamInternal
Anton Khirnov [Fri, 9 Oct 2020 06:15:27 +0000 (08:15 +0200)]
lavf: move AVStream.info to AVStreamInternal

This struct is for internal use of avformat_find_stream_info(), so it
should not be exposed in public headers. Keep a stub pointer in its
place to avoid changing AVStream layout, since e.g. ffmpeg.c accesses
some fields located after it (even though they are marked as private).

3 years agoffmpeg.c: stop accessing private AVStream.codec_info_nb_frames
Anton Khirnov [Sun, 25 Oct 2020 14:50:55 +0000 (15:50 +0100)]
ffmpeg.c: stop accessing private AVStream.codec_info_nb_frames

Use AVSTREAM_EVENT_FLAG_NEW_PACKETS instead, which should provide the
same information in this case.

3 years agoavformat: add a stream event flag for new packets
Anton Khirnov [Sun, 25 Oct 2020 14:50:30 +0000 (15:50 +0100)]
avformat: add a stream event flag for new packets

3 years agoffmpeg.c: rename 'area' to 'score'
Anton Khirnov [Tue, 13 Oct 2020 11:45:05 +0000 (13:45 +0200)]
ffmpeg.c: rename 'area' to 'score'

Other factors besides area are used to pick the best video stream, so
the name 'area' is misleading.

3 years agoavformat: extend documentation of event_flags
Anton Khirnov [Sun, 25 Oct 2020 14:22:44 +0000 (15:22 +0100)]
avformat: extend documentation of event_flags

Document how it is to be used for muxing (currently supported by
flvenc).

3 years agoavformat: fix typo in doxy
Anton Khirnov [Sun, 25 Oct 2020 14:13:47 +0000 (15:13 +0100)]
avformat: fix typo in doxy

av_read_frame() reads new packets, av_read_packet() does not exist.

3 years agolavc: un-avpriv avpriv_bprint_to_extradata()
Anton Khirnov [Mon, 26 Oct 2020 13:10:55 +0000 (14:10 +0100)]
lavc: un-avpriv avpriv_bprint_to_extradata()

It has not been used outside of lavc since 6f69f7a8bf6.

Also, move it to the only place where it is used.

3 years agoput_bits: make avpriv_copy_bits() lavc-local
Anton Khirnov [Mon, 26 Oct 2020 12:41:39 +0000 (13:41 +0100)]
put_bits: make avpriv_copy_bits() lavc-local

It is not used outside of lavc anymore. Keep the avpriv exported symbol
around until the next bump to preserve ABI compatibility.

3 years agoput_bits: make avpriv_put_string() lavc-local
Anton Khirnov [Mon, 26 Oct 2020 12:41:39 +0000 (13:41 +0100)]
put_bits: make avpriv_put_string() lavc-local

It has not been used outside of libavcodec since
20f325f320c6e18ee88983870d2a1fee94257293

3 years agoput_bits: make avpriv_align_put_bits() inline
Anton Khirnov [Mon, 26 Oct 2020 12:36:06 +0000 (13:36 +0100)]
put_bits: make avpriv_align_put_bits() inline

This function is so extremely simple that it is preferable to make it
inline rather than deal with all the complications arising from it being
an exported symbol.

Keep avpriv_align_put_bits() around until the next major bump to
preserve ABI compatibility.

3 years agolavf/latmenc: use a local simplified copy of avpriv_copy_bits()
Anton Khirnov [Mon, 26 Oct 2020 12:16:38 +0000 (13:16 +0100)]
lavf/latmenc: use a local simplified copy of avpriv_copy_bits()

This is the only place in lavf where avpriv_copy_bits() is used, so this
allows us to make avpriv_copy_bits() lavc-local.

3 years agolavf/latmenc: fix units mismatch
Anton Khirnov [Mon, 26 Oct 2020 12:04:33 +0000 (13:04 +0100)]
lavf/latmenc: fix units mismatch

avpriv_copy_bits() takes the size in bits, not bytes. According to
a736eb4a605f46d5ff96c7b32e55710ecd9cce89, nobody is quite sure whether
this code produces working files.

3 years agortsp: increase the control uri size
Yigit Uyan [Tue, 13 Oct 2020 08:17:12 +0000 (01:17 -0700)]
rtsp: increase the control uri size

Current browsers support up to 2k characters.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
3 years agoavcodec/bitstream: Stop allocating one VLCcode more than needed
Andreas Rheinhardt [Sat, 24 Oct 2020 12:23:38 +0000 (14:23 +0200)]
avcodec/bitstream: Stop allocating one VLCcode more than needed

Allocating one temporary entry more than needed was made necessary by
the COPY loop below writing an element before having checked that it
should be written at all. But given that this behaviour changed, the
need for overallocating is gone.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/bitstream: Check code length before truncating to uint8_t
Andreas Rheinhardt [Sat, 24 Oct 2020 12:11:14 +0000 (14:11 +0200)]
avcodec/bitstream: Check code length before truncating to uint8_t

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/hevcdec: constrained intra predict, do not check top left IS_INTRA if it...
Xu Guangxin [Fri, 16 Oct 2020 13:57:34 +0000 (21:57 +0800)]
avcodec/hevcdec: constrained intra predict, do not check top left IS_INTRA if it's not available

fix ticket: 8932

For poc 2, we have tile boundary at x = 640.
When we predict cu(640,912),the top left pixel is not avaliable to the cu.
So, we can not check it's intra or not. We need set top[-1] = top[0] directly.
see 8.4.4.2.1 for details

Signed-off-by: Xu Guangxin <oddstone@gmail.com>
Signed-off-by: Linjie Fu <linjie.justin.fu@gmail.com>
3 years agoavfilter/vf_normalize: fix regression with white/black point calculation
Paul B Mahol [Tue, 27 Oct 2020 18:43:54 +0000 (19:43 +0100)]
avfilter/vf_normalize: fix regression with white/black point calculation

3 years agoavcodec/webp: Replace never-true check by assert
Andreas Rheinhardt [Thu, 22 Oct 2020 14:08:40 +0000 (16:08 +0200)]
avcodec/webp: Replace never-true check by assert

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/webp: Return directly when creating Huff table fails
Andreas Rheinhardt [Thu, 22 Oct 2020 14:03:41 +0000 (16:03 +0200)]
avcodec/webp: Return directly when creating Huff table fails

Neither the auxiliary VLC table nor the code_lengths array need to be
freed if creating the auxiliary VLC table fails.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/webp: Use uint8_t for code lengths
Andreas Rheinhardt [Thu, 22 Oct 2020 13:54:08 +0000 (15:54 +0200)]
avcodec/webp: Use uint8_t for code lengths

They are always in the range 0..15, so using an int is not necessary.
Furthermore, using an int would not work if sizeof(int) != 4 as
ff_init_vlc_sparse() can only handle uint8_t, uint16_t and uint32_t
lengths.

Reviewed-by: zhilizhao(赵志立) <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavformat/mpegtsenc: make first_pcr sync with the first valid dts
Limin Wang [Mon, 26 Oct 2020 10:31:07 +0000 (18:31 +0800)]
avformat/mpegtsenc: make first_pcr sync with the first valid dts

now first_pts assume dts will start from zero, if it's not true(copyts is enable),
too many null packet will be inserted for cbr output.

Please test with below command, you'll get huge test.ts without the patch:
./ffmpeg -y -copyts -i ../fate-suite/mpegts/loewe.ts  -c:v libx264 -x264opts \
   nal-hrd=cbr:force-cfr=1 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize \
   1000k  -c:a mp2 -muxrate 4500k  -vframes 1000 test.ts

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavformat/mpegtsenc: use total_size instead of avio_tell()
Limin Wang [Thu, 22 Oct 2020 01:47:52 +0000 (09:47 +0800)]
avformat/mpegtsenc: use total_size instead of avio_tell()

avio_tell() fails to get the amount of data written so far when the
underlying IO context is flushed to segments.

Please test with below command:
$ ./ffmpeg  -f lavfi -i testsrc=duration=100:size=vga -c:v libx264 -x264opts \
  nal-hrd=cbr:force-cfr=1 -b:v 500k -minrate 500k -maxrate 500k -bufsize 500k \
  -f hls -hls_time 10  -hls_ts_options "muxrate=2000000" test%d.ts

$ du -h test*.ts
Before:
2.4M    test00.ts
4.8M    test11.ts
7.2M    test22.ts
9.6M    test33.ts
12M     test44.ts
...

After apply the patch:
 2.4M   test00.ts
 2.4M   test11.ts
 2.4M   test22.ts
 2.4M   test33.ts
 2.4M   test44.ts
...

Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
3 years agoavcodec/bitstream: Consistently treat symbol as VLC_TYPE
Andreas Rheinhardt [Sun, 25 Oct 2020 23:05:26 +0000 (00:05 +0100)]
avcodec/bitstream: Consistently treat symbol as VLC_TYPE

If a static VLC table gets initialized a second time (or concurrently by
two threads) and if said VLC table uses symbols that have the sign bit
of VLC_TYPE (a typedef for int16_t) set, initializing the VLC fails. The
reason is that the type of the symbol in the temporary array is an
uint16_t and so comparing it to the symbol read from the VLC table will
fail, because only the lower 16bits coincide. Said failure triggers an
assert.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mpeg4videodec: Don't check for errors for complete VLCs
Andreas Rheinhardt [Fri, 23 Oct 2020 18:22:31 +0000 (20:22 +0200)]
avcodec/mpeg4videodec: Don't check for errors for complete VLCs

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3plus: Perform reusing of VLCs during init
Andreas Rheinhardt [Fri, 23 Oct 2020 11:06:36 +0000 (13:06 +0200)]
avcodec/atrac3plus: Perform reusing of VLCs during init

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3: Use least max_depth for get_vlc2()
Andreas Rheinhardt [Fri, 23 Oct 2020 09:45:15 +0000 (11:45 +0200)]
avcodec/atrac3: Use least max_depth for get_vlc2()

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3: Inline constants
Andreas Rheinhardt [Fri, 23 Oct 2020 09:42:15 +0000 (11:42 +0200)]
avcodec/atrac3: Inline constants

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/atrac3: Don't use too big VLC tables
Andreas Rheinhardt [Fri, 23 Oct 2020 09:33:34 +0000 (11:33 +0200)]
avcodec/atrac3: Don't use too big VLC tables

The longest code of any of the VLC tables used is eight bits long, so
using nine bits long VLC tables is wasteful. Furthermore, there are only
seven VLC tables used, yet the code up until now made it look like there
should be eight. This has been corrected, too.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/av1dec: Check for unset obu instead of crashing
Michael Niedermayer [Sun, 25 Oct 2020 23:00:56 +0000 (00:00 +0100)]
avcodec/av1dec: Check for unset obu instead of crashing

Fixes: NULL pointer dereference
Fixes: 26550/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AV1_fuzzer-5417762807349248
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/dirac_parser: do not offset AV_NOPTS_OFFSET
Michael Niedermayer [Fri, 23 Oct 2020 18:29:50 +0000 (20:29 +0200)]
avcodec/dirac_parser: do not offset AV_NOPTS_OFFSET

Fixes: signed integer overflow: -9223372036854775807 - 48000 cannot be represented in type 'long long'
Fixes: 26521/clusterfuzz-testcase-minimized-ffmpeg_dem_DIRAC_fuzzer-5635536506847232
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/mobiclip: Use smaller type for codes
Andreas Rheinhardt [Sat, 24 Oct 2020 11:01:07 +0000 (13:01 +0200)]
avcodec/mobiclip: Use smaller type for codes

Even though the length of these codes is > 8, only the lowest seven bits
are ever set (because the long codes are on the left of the tree), so
one can use an uint8_t for them, saving space.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mobiclip: Use static VLC tables
Andreas Rheinhardt [Sat, 24 Oct 2020 10:50:17 +0000 (12:50 +0200)]
avcodec/mobiclip: Use static VLC tables

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mobiclip: Don't use too big max_depth, inline constants
Andreas Rheinhardt [Sat, 24 Oct 2020 10:26:51 +0000 (12:26 +0200)]
avcodec/mobiclip: Don't use too big max_depth, inline constants

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mobiclip: Don't check for errors for complete VLCs
Andreas Rheinhardt [Sat, 24 Oct 2020 10:15:58 +0000 (12:15 +0200)]
avcodec/mobiclip: Don't check for errors for complete VLCs

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/mobiclip: Reduce size of VLCs, inline constants
Andreas Rheinhardt [Sat, 24 Oct 2020 09:41:37 +0000 (11:41 +0200)]
avcodec/mobiclip: Reduce size of VLCs, inline constants

The longest motion vector VLC for mobiclip is six bits long, so using
eight bits for the VLC table is wasteful. Furthermore, the length can be
inlined.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv34: Simplify getting right VLC
Andreas Rheinhardt [Thu, 22 Oct 2020 10:02:11 +0000 (12:02 +0200)]
avcodec/rv34: Simplify getting right VLC

For both RealVideo 3.0 as well as RealVideo 4.0 the VLC table to use
depends upon the slice's quantization parameter; these are coded on five
bits in the bitstream and are therefore in the range of 0..31; yet the
last element here is not valid and therefore the quantizer is clipped to
the range 0..30 to get the index. But this is unnecessary: One can just
add one element more to the relevant array to avoid the clipping.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/rv34: Don't needlessly copy VLC length and symbol arrays
Andreas Rheinhardt [Thu, 22 Oct 2020 08:57:40 +0000 (10:57 +0200)]
avcodec/rv34: Don't needlessly copy VLC length and symbol arrays

Most of the VLCs used by RealVideo 3 and 4 obey three simple rules:
Shorter codes are on the left of the tree, for each length, the symbols
are ascending from left to right and the symbols either form a
permutation of 1..size or 0..(size - 1). For the latter case, one just
needs to store the length of each symbol and create the codes according
to the other rules; no explicit code or symbol array must be stored.
The former case is also treated in much the same way by artificially
assigning a length of zero to the symbol 0; when a length of zero was
encountered, the element was ignored except that the symbol counter was
still incremented. If the length was nonzero, the symbol would be
assigned via the symbol counter and the length copied over into a new
array.

Yet this is unnecessary, as ff_init_vlc_sparse() follows exactly the
same pattern: If a length of zero is encountered, the element is ignored
and only the symbol counter incremented. So one can directly forward the
length array and also need not create a symbol table oneself, because
ff_init_vlc_sparse() will infer the same symbol table in this case.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agoavcodec/vp3: Make parsing Theora Huffman tables more spec-compliant
Andreas Rheinhardt [Tue, 20 Oct 2020 06:31:17 +0000 (08:31 +0200)]
avcodec/vp3: Make parsing Theora Huffman tables more spec-compliant

Theora allows to use custom Huffman tables which are coded in the
bitstream as a tree: Whether the next node is a leaf or not is coded
in a bit; each node itself contains a five bit token. Each tree can
contain at most 32 leafs; typically they contain exactly 32 with the 32
symbols forming a permutation of 0..31. Yet the standard does not impose
either of these requirements. It explicitly allows less than 32 leafs
and multiple codes with the same token.

But our decoder used an algorithm that required the codes->token mapping
to be injective and that also presumed that there be at least two leafs:
Instead of using an array for codes, tokens and code lengths, the
decoder only had arrays for codes and code lengths. The code and length
for a given token were stored in entry[token]. As no symbols table was
used when initializing the VLC, the default one applied and therefore
the entry[token] got the symbol token (if the length of said entry is >0).
Yet if multiple codes had the same token, the codes and lengths from the
later token would overwrite the earlier codes and lengths.

Furthermore, less than 32 leafs could also lead to problems: Namely if
this was not the first time Huffman tables have been parsed in which
case the array is not zeroed initially so that old entries could make
the new table invalid.

libtheora seems to always use 32 leafs and no duplicate tokens; I am not
aware of any existing valid files that do not.

This is fixed by using a codes, symbols and lengths array when
initializing the VLC. In order to reduce the amount of stuff kept in the
context only the symbols and lengths (which both fit into an uint8_t)
are kept in the context; the codes are derived from the lengths
immediately before creating the tables.

There is now only one thing left which is not spec-compliant: Trees with
only one node (which has length zero) are not supported by
ff_init_vlc_sparse() yet.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
3 years agotests/audiomatch: removes a warning when compiling tests/audiomatch
Steven Liu [Mon, 19 Oct 2020 06:05:36 +0000 (14:05 +0800)]
tests/audiomatch: removes a warning when compiling tests/audiomatch

the warning message:
warning: using floating point absolute value function
'fabs' when argument is of integer type
use FFABS to set the absolute value.

Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
3 years agoavcodec/adpcm_ima_cunning: document origin of tables
Zane van Iperen [Sat, 24 Oct 2020 05:47:55 +0000 (15:47 +1000)]
avcodec/adpcm_ima_cunning: document origin of tables

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
3 years agolavfi/Makefile: Remove opencl object files when calling make clean.
Carl Eugen Hoyos [Sun, 25 Oct 2020 20:18:34 +0000 (21:18 +0100)]
lavfi/Makefile: Remove opencl object files when calling make clean.

3 years agofate: add adpcm_ima_alp encoding test
Zane van Iperen [Fri, 23 Oct 2020 08:23:12 +0000 (18:23 +1000)]
fate: add adpcm_ima_alp encoding test

3 years agoavformat: add alp muxer
Zane van Iperen [Wed, 21 Oct 2020 13:20:20 +0000 (23:20 +1000)]
avformat: add alp muxer

3 years agoavcodec: add adpcm_ima_alp encoder
Zane van Iperen [Fri, 23 Oct 2020 08:14:59 +0000 (18:14 +1000)]
avcodec: add adpcm_ima_alp encoder

3 years agoavformat/alp: fix handling of TUN files
Zane van Iperen [Fri, 23 Oct 2020 11:35:53 +0000 (21:35 +1000)]
avformat/alp: fix handling of TUN files

Sample rate is always 22050. Verified by trying various files in the game.

3 years agoavfilter/vf_v360: make commands always do relative rotation
Paul B Mahol [Sun, 25 Oct 2020 11:46:29 +0000 (12:46 +0100)]
avfilter/vf_v360: make commands always do relative rotation

3 years agotools/target_dec_fuzzer: adjust threshold for wmalossless
Michael Niedermayer [Tue, 20 Oct 2020 16:48:08 +0000 (18:48 +0200)]
tools/target_dec_fuzzer: adjust threshold for wmalossless

Fixes: Timeout (>30sec -> 0.5sec)
Fixes: 26351/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMALOSSLESS_fuzzer-5191487740182528
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/rmdec: Make expected_len 64bit
Michael Niedermayer [Tue, 20 Oct 2020 19:32:59 +0000 (21:32 +0200)]
avformat/rmdec: Make expected_len 64bit

Fixes: signed integer overflow: 1347551268 * 14 cannot be represented in type 'int'
Fixes: 26458/clusterfuzz-testcase-minimized-ffmpeg_dem_RM_fuzzer-5655364324032512
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/pcm: Check block_align
Michael Niedermayer [Tue, 20 Oct 2020 19:44:32 +0000 (21:44 +0200)]
avformat/pcm: Check block_align

Fixes: signed integer overflow: 321 * 8746632 cannot be represented in type 'int'
Fixes: 26461/clusterfuzz-testcase-minimized-ffmpeg_dem_PVF_fuzzer-6326427831762944
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/lrcdec: Clip timestamps
Michael Niedermayer [Tue, 20 Oct 2020 19:55:13 +0000 (21:55 +0200)]
avformat/lrcdec: Clip timestamps

Fixes: signed integer overflow: 7111111111111531010 - -7335632962598013506 cannot be represented in type 'long'
Fixes: 26463/clusterfuzz-testcase-minimized-ffmpeg_dem_LRC_fuzzer-6015558333759488
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavutil/mathematics: Use av_sat_add64() for the last addition in av_add_stable()
Michael Niedermayer [Tue, 20 Oct 2020 20:10:39 +0000 (22:10 +0200)]
avutil/mathematics: Use av_sat_add64() for the last addition in av_add_stable()

Fixes: signed integer overflow: 9223372036854770375 + 5450 cannot be represented in type 'long'
Fixes: 26471/clusterfuzz-testcase-minimized-ffmpeg_dem_MXG_fuzzer-6229617557635072
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotests/fate/hevc: Add test for 3fbf8737923ac49754946a2505367630544b87f1
Michael Niedermayer [Thu, 22 Oct 2020 09:20:36 +0000 (11:20 +0200)]
tests/fate/hevc: Add test for 3fbf8737923ac49754946a2505367630544b87f1

Tested-on: x86-32/64/ARM/MIPS Linux, Mingw/WINE 32/64
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavcodec/pgxdec: Check depth more completely
Michael Niedermayer [Thu, 8 Oct 2020 19:19:14 +0000 (21:19 +0200)]
avcodec/pgxdec: Check depth more completely

Fixes: shift exponent -1 is negative
Fixes: 26107/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGX_fuzzer-5378790047612928
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agoavformat/electronicarts: Check for EOF in each iteration of the loop in ea_read_packet()
Michael Niedermayer [Sat, 24 Oct 2020 17:24:30 +0000 (19:24 +0200)]
avformat/electronicarts: Check for EOF in each iteration of the loop in ea_read_packet()

Fixes: timeout(>20sec -> 1ms)
Fixes: 26526/clusterfuzz-testcase-minimized-ffmpeg_dem_EA_fuzzer-5672328069120000
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
3 years agotools/target_dem_fuzzer: Limit max blocks
Michael Niedermayer [Fri, 23 Oct 2020 16:54:51 +0000 (18:54 +0200)]
tools/target_dem_fuzzer: Limit max blocks

With a IO block size of 1 byte potentially megabytes are quite slow to read, thus
limit the number

Fixes: 26511/clusterfuzz-testcase-minimized-ffmpeg_dem_NUV_fuzzer-5679249073373184
Fixes: 26517/clusterfuzz-testcase-minimized-ffmpeg_dem_XMV_fuzzer-6316634501021696
Fixes: 26518/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-485568285324083
Fixes: 26525/clusterfuzz-testcase-minimized-ffmpeg_dem_MSNWC_TCP_fuzzer-5121987011411968
Fixes: 26538/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-5441800598454272
Fixes: OOM
Fixes: Timeout
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>