1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-07 11:13:41 +02:00
Commit Graph

100067 Commits

Author SHA1 Message Date
Anton Khirnov
dc1099442e 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.
2020-10-28 13:53:23 +01:00
Anton Khirnov
944ba30db0 put_bits: make avpriv_put_string() lavc-local
It has not been used outside of libavcodec since
20f325f320
2020-10-28 13:53:23 +01:00
Anton Khirnov
717503f716 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.
2020-10-28 13:53:23 +01:00
Anton Khirnov
886c601a70 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.
2020-10-28 13:53:23 +01:00
Anton Khirnov
2068ad5914 lavf/latmenc: fix units mismatch
avpriv_copy_bits() takes the size in bits, not bytes. According to
a736eb4a60, nobody is quite sure whether
this code produces working files.
2020-10-28 13:53:23 +01:00
Yigit Uyan
c1efb1decb rtsp: increase the control uri size
Current browsers support up to 2k characters.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2020-10-28 13:53:20 +01:00
Andreas Rheinhardt
81d4b8fb3c 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>
2020-10-28 11:28:24 +01:00
Andreas Rheinhardt
e75b6ec43b avcodec/bitstream: Check code length before truncating to uint8_t
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-28 11:23:33 +01:00
Xu Guangxin
e5be4c5a88 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>
2020-10-28 11:29:09 +08:00
Paul B Mahol
c7ece8e26f avfilter/vf_normalize: fix regression with white/black point calculation 2020-10-27 19:45:51 +01:00
Andreas Rheinhardt
8b1bb4f38e avcodec/webp: Replace never-true check by assert
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-27 11:51:01 +01:00
Andreas Rheinhardt
548f1a3fa4 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>
2020-10-27 11:51:01 +01:00
Andreas Rheinhardt
d4cce1514e 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>
2020-10-27 11:51:01 +01:00
Limin Wang
6f36eb0da7 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>
2020-10-27 18:18:24 +08:00
Limin Wang
f3568a33c9 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>
2020-10-27 18:18:24 +08:00
Andreas Rheinhardt
df6ec7f83b 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>
2020-10-27 10:34:23 +01:00
Andreas Rheinhardt
0da310d7be avcodec/mpeg4videodec: Don't check for errors for complete VLCs
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-27 10:33:11 +01:00
Andreas Rheinhardt
5f8de7b741 avcodec/atrac3plus: Perform reusing of VLCs during init
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-27 10:32:16 +01:00
Andreas Rheinhardt
38afc6858c avcodec/atrac3: Use least max_depth for get_vlc2()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-27 10:31:16 +01:00
Andreas Rheinhardt
2d4f878626 avcodec/atrac3: Inline constants
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-27 10:30:28 +01:00
Andreas Rheinhardt
e4eeb851fd 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>
2020-10-27 10:19:38 +01:00
Michael Niedermayer
718e862da3 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>
2020-10-26 19:27:53 +01:00
Michael Niedermayer
343c3149ab 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>
2020-10-26 09:10:49 +01:00
Andreas Rheinhardt
307a1b8e54 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>
2020-10-26 07:56:51 +01:00
Andreas Rheinhardt
77e8c959aa avcodec/mobiclip: Use static VLC tables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2020-10-26 07:48:19 +01:00
Andreas Rheinhardt
924bc6d860 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>
2020-10-26 07:46:05 +01:00
Andreas Rheinhardt
10106b5d54 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>
2020-10-26 07:43:32 +01:00
Andreas Rheinhardt
c4229ad074 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>
2020-10-26 07:25:09 +01:00
Andreas Rheinhardt
3a836f38f6 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>
2020-10-26 07:16:10 +01:00
Andreas Rheinhardt
f033e6d2e6 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>
2020-10-26 07:16:10 +01:00
Andreas Rheinhardt
c69392a54c 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>
2020-10-26 07:15:37 +01:00
Steven Liu
bc90145fa3 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>
2020-10-26 11:20:17 +08:00
Zane van Iperen
7fc97fb7f4
avcodec/adpcm_ima_cunning: document origin of tables
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2020-10-26 12:25:28 +10:00
Carl Eugen Hoyos
7b0d179195 lavfi/Makefile: Remove opencl object files when calling make clean. 2020-10-25 21:18:34 +01:00
Zane van Iperen
86267fccc6
fate: add adpcm_ima_alp encoding test 2020-10-25 23:44:27 +10:00
Zane van Iperen
7a11cc29d6
avformat: add alp muxer 2020-10-25 23:44:26 +10:00
Zane van Iperen
40a8d43885
avcodec: add adpcm_ima_alp encoder 2020-10-25 23:44:26 +10:00
Zane van Iperen
5df7fd1cbe
avformat/alp: fix handling of TUN files
Sample rate is always 22050. Verified by trying various files in the game.
2020-10-25 23:44:25 +10:00
Paul B Mahol
d6e903b09b avfilter/vf_v360: make commands always do relative rotation 2020-10-25 12:49:25 +01:00
Michael Niedermayer
0d395767ec 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>
2020-10-25 09:49:56 +01:00
Michael Niedermayer
728330462c 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>
2020-10-25 09:49:40 +01:00
Michael Niedermayer
b23a619c13 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>
2020-10-25 09:49:31 +01:00
Michael Niedermayer
80bc2ac3c0 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>
2020-10-25 09:49:26 +01:00
Michael Niedermayer
ac8cebd48e 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>
2020-10-25 09:49:21 +01:00
Michael Niedermayer
6939174bfc tests/fate/hevc: Add test for 3fbf873792
Tested-on: x86-32/64/ARM/MIPS Linux, Mingw/WINE 32/64
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-25 09:48:29 +01:00
Michael Niedermayer
389b9e9b4f 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>
2020-10-25 09:47:37 +01:00
Michael Niedermayer
857aba7c45 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>
2020-10-25 09:05:01 +01:00
Michael Niedermayer
6e64d89410 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>
2020-10-24 22:38:55 +02:00
Michael Niedermayer
b990148d1e avformat/ifv: Check that total frames do not overflow
Fixes: Infinite loop
Fixes: 26392/clusterfuzz-testcase-minimized-ffmpeg_dem_GIF_fuzzer-5713658237419520
Fixes: 26435/clusterfuzz-testcase-minimized-ffmpeg_dem_SUBVIEWER_fuzzer-6548251853193216

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-24 19:11:12 +02:00
Michael Niedermayer
4e9514e99b avutil/common: Implement av_sat_add64_c() with fewer branches
No benchmark because this is not used in any speed relevant pathes nor is it
used where __builtin_add_overflow is available.
So I do not know how to realistically benchmark it.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2020-10-24 19:11:12 +02:00