Commit Graph

47784 Commits

Author SHA1 Message Date
Anton Khirnov
f566032bfd lavc/decode: validate frames output by decoders
Make sure no frames with invalid parameters will be seen by the caller.
2023-01-10 11:47:29 +01:00
Anton Khirnov
a1eec66867 lavc/decode: deduplicate cleanup in ff_decode_receive_frame() 2023-01-10 11:47:29 +01:00
Anton Khirnov
5bf8f29135 lavc/qsvdec: check ff_decode_frame_props() return value 2023-01-10 11:47:29 +01:00
Anton Khirnov
3dc7a9f623 lavc/ac3dec: fail when the sample rate is unset 2023-01-10 11:47:29 +01:00
Wenbin Chen
13d04e30d7 libavcodec/qsvenc_av1: Add max_frame_size support to av1_qsv encoder
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
2023-01-09 13:56:03 +08:00
Wenbin Chen
c8e73558fe libavcodec/qsvenc_av1: Add low_delay_brc support to av1_qsv encoder
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
2023-01-09 13:56:03 +08:00
Zhao Zhili
a598be44df avcodec/mediacodecenc: enable B frames only with -strict experimental
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-09 19:21:57 +08:00
Anton Khirnov
fcd557a2c2 lavc/get_bits: add a compat wrapper for the cached bitstream reader
Use that instead of the merged version.
2023-01-06 11:04:10 +01:00
Anton Khirnov
b6742259bf lavc/tests: add a cached bitstream reader test 2023-01-06 11:01:00 +01:00
Anton Khirnov
9177970bca lavc/bitstream: templatize for BE/LE
Allows using both BE and LE bitstream readers in the same file.
2023-01-06 10:49:42 +01:00
Alexandra Hájková
8fe551eca0 lavc: add standalone cached bitstream reader
The cached bitstream reader was originally written by Alexandra Hájková
for Libav, with significant input from Kostya Shishkov and Luca Barbato.
It was then committed to FFmpeg in ca079b0954, by merging it with the
implementation of the current bitstream reader.

This merge makes the code of get_bits.h significantly harder to read,
since it now contains two different bitstream readers interleaved with
 #ifdefs. Additionally, the code was committed without proper authorship
attribution.

This commit re-adds the cached bitstream reader as a standalone header,
as it was originally developed. It will be made useful in following
commits.

Integration by Anton Khirnov.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-01-06 10:48:56 +01:00
Aman Karmani
4b2b9a6604 avcodec/mpeg12dec: flush a53 data
Signed-off-by: Aman Karmani <aman@tmm1.net>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-01-06 10:47:53 +01:00
James Almer
4a80db5fc2 avcodec/mpeg12dec: use init_get_bits8 and check the return value in all remaining cases
Signed-off-by: James Almer <jamrial@gmail.com>
2023-01-04 20:48:06 -03:00
Thierry Foucu
efbe84eb1b avcodec/mpeg12dec: use init_get_bits8 and check the return value
Signed-off-by: James Almer <jamrial@gmail.com>
2023-01-04 16:18:21 -03:00
Anton Khirnov
a0b5aaceca lavc/libx265: restructure handling reordered_opaque
Current code stores a pointer to allocated data in libx265 and frees it
when the encoded packet is retrieved. This will leak if the packet is
never retrieved, e.g. if the encoder is closed without being flushed.

Restructure the code such that only indices to an array stored in our
private data are given to libx265. This ensures no allocated memory can
be lost.
2023-01-04 11:48:17 +01:00
Anton Khirnov
7399e5305c lavc/libx264: do not leave an invalid array size on alloc error 2023-01-04 11:48:17 +01:00
Anton Khirnov
a4a81be1a8 lavc/libx264: zero reordered opaque on alloc
This is safer.
2023-01-04 11:48:17 +01:00
Anton Khirnov
141303f323 lavc/libx264: print an error on invalid opaque pointer 2023-01-04 11:48:17 +01:00
Anton Khirnov
89761c2122 lavc/libx264: use a local variable to shorten code 2023-01-04 11:48:17 +01:00
Anton Khirnov
4469ce10a6 lavc/libx264: reindent after previous commit 2023-01-04 11:48:17 +01:00
Anton Khirnov
9ed5b0ac3b lavc/libx264: reorder control flow in setup_roi() to reduce nesting depth 2023-01-04 11:48:17 +01:00
Anton Khirnov
ce5b2d34b4 lavc/libx264: reindent after previous commit 2023-01-04 11:48:17 +01:00
Anton Khirnov
e17b609fc6 lavc/libx264: do not ignore memory allocation errors 2023-01-04 11:48:17 +01:00
Anton Khirnov
cccd2c2179 lavc/libx264: unify cleanup in setup_frame() 2023-01-04 11:48:17 +01:00
Anton Khirnov
87eb362693 lavc/libx264: reindent after previous commit 2023-01-04 11:48:17 +01:00
Anton Khirnov
b1a184283b lavc/libx264: factor out setting up ROI 2023-01-04 11:48:17 +01:00
Anton Khirnov
c7a8a6939b lavc/libx264: use a local variable for input frame in setup_frame() 2023-01-04 11:48:17 +01:00
Anton Khirnov
9f8f980165 lavc/libx264: reindent after previous commit 2023-01-04 11:48:17 +01:00
Anton Khirnov
33cbba165c lavc/libx264: factor out setting up the input frame
X264_frame() is currently too large and complex.
2023-01-04 11:48:17 +01:00
Zhao Zhili
f0d2ed135c avcodec/mediacodecdec: add AV1 decoding support
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2023-01-03 19:23:03 +08:00
Paul B Mahol
5852682dbd avcodec/bonk: increase level limit as joint encodings needs more 2023-01-02 18:42:35 +01:00
Michael Niedermayer
aee0f320ac avcodec/dts2pts_bsf: Avoid poc overflows in cmp_find()
Fixes: signed integer overflow: -2147483648 - 5 cannot be represented in type 'int'
Fixes: 54242/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-472928339243827

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-28 00:25:35 +01:00
Michael Niedermayer
902a49c4cd avcodec/hdrdec: Check for end of input in decompress()
Fixes: Timeout
Fixes: 54386/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HDR_fuzzer-5053598268784640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-28 00:25:34 +01:00
James Almer
7fab58647c avcodec/proresdec2: set color information on frames instead of the decoder context
Similar to how the encoder looks at frame color information to write the frame
header bitstream.

Should workaround ticket #10091, where container level color parameters passed
to the decoder context were being overwritten.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-27 11:03:22 -03:00
Leo Izen
cd9dd03006 avcodec/pnm: avoid mirroring PFM images vertically
PFM (aka Portable FloatMap) encodes its scanlines from bottom-to-top,
not from top-to-bottom, unlike other NetPBM formats. Without this
patch, FFmpeg ignores this exception and decodes/encodes PFM images
mirrored vertically from their proper orientation.

For reference, see the NetPBM tool pfmtopam, which encodes a .pam
from a .pfm, using the correct orientation (and which FFmpeg reads
correctly). Also compare ffplay to magick display, which shows the
correct orientation as well.

See: http://www.pauldebevec.com/Research/HDR/PFM/ and see:
https://netpbm.sourceforge.net/doc/pfm.html for descriptions of this
image format.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-27 10:41:25 -03:00
James Almer
64007595dc avcodec/mjpegbdec: return the amount of bytes consumed when discarding frames
EAGAIN is not correct in this scenario. FFCodec.cb.decode() callback decoders
always return the amount of bytes consumed from the input packet (if any), and
report if a frame was generated by setting got_frame.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-27 10:40:00 -03:00
Martijn van Beurden
d8f1404c50 libavcodec/flacenc: Implement encoding of 32 bit-per-sample PCM
Add encoding of 32 bit-per-sample PCM to FLAC files to libavcodec.
Coding to this format is at this point considered experimental and
-strict experimental is needed to get ffmpeg to encode such files.
2022-12-26 21:15:36 +01:00
Martijn van Beurden
909cfdc205 libavcodec/flacdec: Implement decoding of 32 bit-per-sample PCM
Add decoding of FLAC files coding for 32 bit-per-sample PCM to libavcodec.
2022-12-26 21:15:36 +01:00
Michael Niedermayer
125e01d6cc avcodec/dts2pts_bsf: Avoid searching for poc == INT_MIN-1
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 53876/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-6569754750222336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-25 19:33:24 +01:00
Michael Niedermayer
f8a2a65078 avcodec/sunrast: Fix maplength check
Fixes: out of bounds read

Found-by: Ibrahim Mohamed <ielsayed@meta.com>
Reviewed-by; Ibrahim Mohamed <ielsayed@meta.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-24 23:43:45 +01:00
Michael Niedermayer
64c6c56890 avcodec/mjpegbdec: Check for AVDISCARD_ALL
Fixes: Assertion failure
Fixes: 51825/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEGB_fuzzer-6393802688692224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-23 00:43:01 +01:00
Michael Niedermayer
b7d063951d avcodec/apac: Sanity check bits_per_coded_sample
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 53931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APAC_fuzzer-6072913738727424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-20 18:35:13 +01:00
Michael Niedermayer
8374a747af avcodec/wavpack: Avoid undefined shift in get_tail()
Fixes: left shift of 1208485947 by 1 places cannot be represented in type 'int'
Fixes: 54058/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WAVPACK_fuzzer-5827521084260352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2022-12-20 18:35:12 +01:00
James Darnley
6af453ca38 avcodec/x86: add avx512icl function for v210dec
Ice Lake (Xeon Silver 4316): 2.01x faster (1147±36.8 vs. 571±38.2 decicycles) compared with avx2
2022-12-20 15:02:45 +01:00
James Darnley
f30b4c2f47 avcodec/x86/v210: add some comments to the improved avx2 function 2022-12-20 15:02:45 +01:00
Zhao Zhili
48d5aecfc4 avcodec/mediacodec_wrapper: include stdbool.h
Since NDK failed to do that:
https://github.com/android/ndk/issues/1281

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-12-19 10:03:54 +08:00
James Almer
7af947c0c0 avcodec/libdav1d: honor the requested skip_frame level
This allows dropping non-reference, non-intra, or non-key frames on supported
libdav1d versions.

Signed-off-by: James Almer <jamrial@gmail.com>
2022-12-17 21:37:23 -03:00
Zhao Zhili
10a56363a7 avcodec/mediacodecenc: add pts_as_dts option
It works since most of Android devices don't output B frames by
default. The behavior is documented by Android now, although there
is some exception in history, which should have been fixed now.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-12-17 04:32:57 +08:00
Zhao Zhili
a86bb1d2ce avcodec/mediacodecenc: add max-bframes support
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-12-17 04:31:04 +08:00
Zhao Zhili
7da1adfc02 avcodec/mediacodecenc: remove the strategy to create DTS
Use input PTS as DTS has multiple problems:
1. If there is no reordering, it's better to just use the output
PTS as DTS, since encoder may change the timestamp value (do it
on purpose or rounding error).

2. If there is reordering, input PTS should be shift a few frames
as DTS to satisfy the requirement of PTS >= DTS. I can't find a
reliable way to determine how many frames to be shift. For example,
we don't known if the encoder use hierarchical B frames. The
max_num_reorder_frames can be get from VUI, but VUI is optional.

3. Encoder dropping frames makes the case worse. Android has an
BITRATE_MODE_CBR_FD option to allow it explicitly.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2022-12-17 04:30:36 +08:00