1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-03-03 14:32:16 +02:00

48860 Commits

Author SHA1 Message Date
Paul B Mahol
f7dc5d76e0 avcodec/lagarith: use VLC for prob code length 2023-09-17 11:17:20 +02:00
Paul B Mahol
1ac2769009 avcodec/adx_parser: make packet split work if nb_channels is set 2023-09-17 11:11:24 +02:00
Andreas Rheinhardt
b5c07a368b avcodec/vp3: Don't truncate ptrdiff_t
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-16 14:55:25 +02:00
Andreas Rheinhardt
11a9aab6c1 avcodec/vp3: Use range-based loop variables
Motivated by:
    #if CONFIG_VP4_DECODER
        int j;
    #endif

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-16 14:54:58 +02:00
Andreas Rheinhardt
5022be4e75 avcodec/vp3: Add const where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-16 14:54:58 +02:00
Andreas Rheinhardt
9c9458115e avcodec/vp3: Move work after ff_thread_finish_setup
all_fragments is not synced between threads; resetting it can wait.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-16 14:54:58 +02:00
Andreas Rheinhardt
4dae62f708 avcodec/dnxhddec: Use VLC symbol table to avoid lookup
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-16 14:54:17 +02:00
James Almer
156f53e987 avcodec/evc_ps: make the sps parameter in ref_pic_list_struct const
It's not changed.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-09-15 16:33:13 -03:00
Lynne
9310ffc809
vulkan_decode: don't call get_proc_addr on every frame's destruction
The issue is that we cannot rely on any context existing when we free
frames. The Vulkan functions are loaded in each context separately,
so until now, we've just been loading them on every frame's destruction.

Rather than do this, just save the function pointers we need in each
frame. The function pointers are guaranteed to not change and exist.
2023-09-15 17:35:22 +02:00
Lynne
552a5fa496
vulkan_hevc: switch from a buffer pool to a malloc and simplify
Simpler and more robust now that contexts are not shared between threads.
2023-09-15 17:35:19 +02:00
Michael Niedermayer
4565747056
avcodec/evc_ps: Check ref_pic_num and sps_max_dec_pic_buffering_minus1
Fixes: out of array write

Found-by: dongsookim@korea.ac.kr
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-15 17:13:54 +02:00
Jun Zhao
5c635b7d8c lavc/videotoolboxenc: Get the encoder supported properties
Get the encoder supported properties list, it will be used for
feature support checks.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2023-09-15 21:08:21 +08:00
Jun Zhao
213cba9696 lavc/videotoolboxenc: Dump the encoder
Dump the encoder, it's will help debug some case

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2023-09-15 21:07:46 +08:00
Andreas Rheinhardt
27562bf022 avcodec/x86/mpegvideoenc_template: Disable dead code
Since bfb28b5ce89f3e950214b67ea95b45e3355c2caf the permutation
type FF_IDCT_PERM_SIMPLE is ARCH_X86_32-only. So use this
knowledge to disable code for it when not on ARCH_X86_32.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-15 13:08:55 +02:00
Andreas Rheinhardt
fa77cb258b avcodec/h264dec: Fix data race when updating decode_error_flags
When using multi-threaded decoding, every decoding thread
has its own DBP consisting of H264Pictures and each of these
points to its own AVFrames. They are synced during
update_thread_context via av_frame_ref() and therefore
the threads actually decoding (as well as all the others)
must not modify any field that is copied by av_frame_ref()
after ff_thread_finish_setup().

Yet this is exactly what happens when an error occurs
during decoding and the AVFrame's decode_error_flags are updated.
Given that these errors only become apparent during decoding,
this can't be set before ff_thread_finish_setup() without
defeating the point of frame-threading; in practice,
this meant that the decoder did not set these flags correctly
in case frame-threading was in use. (This means that e.g.
the ffmpeg cli tool fails to output its "corrupt decoded frame"
message in a nondeterministic fashion.)

This commit fixes this by adding a new H264Picture field
that is actually propagated across threads; the field
is an AVBufferRef* whose data is an atomic_int; it is
atomic in order to allow multiple threads to update it
concurrently and not to provide synchronization
between the threads setting the field and the thread
ultimately returning the AVFrame.

This unfortunately has the overhead of one allocation
per H264Picture (both the original one as well as
creating a reference to an existing one), even in case
of no errors. In order to mitigate this, an AVBufferPool
has been used and only if frame-threading is actually
in use. This expense will be removed as soon as
a proper API for refcounted objects (not based upon
AVBuffer) is in place.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-15 13:08:37 +02:00
Andreas Rheinhardt
d2bc039501 avcodec/error_resilience: Make applying decode_error_flags optional
Add a pointer parameter that if supplied will be used to return
the updated decode_error_flags. This will allow to fix several
races when using frame-threading; these resulted from AVFrame
that the earlier code updated concurrently being used as source
in an av_frame_ref() call in the decoder's update_thread_context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-15 13:08:37 +02:00
Andreas Rheinhardt
c1b6235d41 avcodec/vulkan_decode: Factor creating session params out, fix leak
All Vulkan HWAccels share the same boilerplate code for creating
session params and this includes a common bug: In case actually
creating the video session parameters fails, the buffer destined
to hold them leaks; in case of HEVC this is also true if
get_data_set_buf() fails.

This commit factors this code out and fixes the leak.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-15 02:38:22 +02:00
Michael Niedermayer
2b25a5168e
avcodec/bonk: Fix integer overflow in predictor_calc_error()
Fixes: signed integer overflow: -2147483300 - 12285 cannot be represented in type 'int'
Fixes: 59462/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BONK_fuzzer-5714298807386112

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-14 22:00:17 +02:00
Michael Niedermayer
c012d1f2bb
avcodec/jpeg2000dec: jpeg2000 has its own lowres option
jpeg2000 overrides the global lowres variable with a lowres field called reduction_factor
ffmpeg -lowres X causes the reduction_factor to be set
ffplay -lowres X causes both lowres and the reduction_factor to be set
ossfuss sets only lowres

only the ffmpeg variant works. This patch tries to make the other 2 work.

Alternative we could just error out if things are inconsistent.
More complex restructuring should be limited to the master branch
to keep this reasonably easy to backport

Fixes: out of array access
Fixes: 59672/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-14 22:00:17 +02:00
Michael Niedermayer
90647a9249
avcodec/huffyuvdec: avoid undefined behavior with get_vlc2() failure
Fixes: left shift of negative value -1
Fixes: 59889/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HUFFYUV_fuzzer-5472742275940352

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-14 22:00:17 +02:00
Michael Niedermayer
ca09d8a0dc
avcodec/jpegxl_parser: Check for ctx->skip overflow
Fixes: out of array access
Fixes: 62113/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5025082076168192

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-14 22:00:17 +02:00
Paul B Mahol
00a837c70c avcodec/vmixdec: add support for custom first byte 2023-09-14 14:54:40 +02:00
Andreas Rheinhardt
038b992256 avcodec/libaribb24: Use FF_CODEC_CAP_INIT_CLEANUP
libaribb24_close() does the same as the fail path in
libaribb24_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-14 12:32:02 +02:00
Andreas Rheinhardt
c1714a483f avcodec/libaribb24,ttmlenc, avutil/tx: Remove redundant init of AVBPrint
An AVBPrint is initialized via av_bprint_init() (or
av_bprint_init_for_buffer()) which expects uninitialized
AVBPrints; it is therefore not necessary to zero them before
the actual initialization.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-14 12:32:02 +02:00
Andreas Rheinhardt
6434e44003 avcodec/thread: Remove ff_thread_get_format define
Unnecessary since FF_API_THREAD_SAFE_CALLBACKS is no more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-13 22:04:22 +02:00
Andreas Rheinhardt
0058f6013f avcodec/av1dec: Don't rely on AV_PIX_FMT_NONE == -1
Since fb548fba04193a418f118d21b261ba05db4f480b,
this return -1 is in a function returning enum AVPixelFormat
whose caller checks for AV_PIX_FMT_NONE for failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-13 22:04:22 +02:00
Andreas Rheinhardt
c38693b4b0 avcodec/av1dec: Pass AVCodecContext* as logctx in get_sw_pixel_format()
It indicates to the reader that said function does not modify
any state.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-13 22:04:11 +02:00
Andreas Rheinhardt
423b6a7e49 avutil/imgutils: Add wrapper for av_image_copy() to avoid casts
av_image_copy() accepts const uint8_t* const * as source;
lots of user have uint8_t* const * and therefore either
cast (the majority) or copy the array of pointers.

This commit changes this by adding a static inline wrapper
for av_image_copy() that casts between the two types
so that we do not need to add casts everywhere else.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-12 09:42:27 +02:00
Paul B Mahol
8cd2e0c075 avcodec/fraps: remove extra new lines and not needed cast 2023-09-11 22:04:28 +02:00
Paul B Mahol
1735ca3c41 avcodec/8bps: always decode to planar formats directly 2023-09-11 22:04:26 +02:00
Paul B Mahol
1ce1970417 avcodec/8bps: use uint8/uint16 where possible 2023-09-11 22:04:25 +02:00
Andreas Rheinhardt
740ce93fae avcodec/flicvideo: Remove unnecessary cast
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 20:27:26 +02:00
Andreas Rheinhardt
eb9bfe30a2 avcodec/imc: Fix leak on init error
Since e6afa61be97674312e36c9b6f8bb5fba009232e7 an AVFloatDSPContext
would leak on av_tx_init() failure.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 20:27:06 +02:00
Paul B Mahol
86bd0f08d3 avcodec/vmixdec: fix inputs with more than 255 slices 2023-09-11 01:14:50 +02:00
Paul B Mahol
64f538c356 avcodec/shorten: use uint16_t for wave_format 2023-09-11 01:14:49 +02:00
Andreas Rheinhardt
e9bbb39e94 avcodec/truemotion2: Don't check before freeing VLC
ff_vlc_free() is of course compatible with freeing
a blank VLC.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 00:28:04 +02:00
Andreas Rheinhardt
9cdf82c2c2 avcodec/vlc: Use proper namespace
Therefore use a proper prefix for this API, e.g.
ff_init_vlc_sparse -> ff_vlc_init_sparse
ff_free_vlc        -> ff_vlc_free
INIT_VLC_LE        -> VLC_INIT_LE
INIT_VLC_USE_NEW_STATIC -> VLC_INIT_USE_STATIC
(The ancient INIT_VLC_USE_STATIC has been removed
in 595324e143b57a52e2329eb47b84395c70f93087, so that
the NEW has been dropped.)
Finally, reorder the flags and change their values
accordingly.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 00:27:45 +02:00
Andreas Rheinhardt
7b98a1875d avcodec/vlc: Add documentation for ff_init_vlc_sparse()
Mostly taken from the documentation for ff_init_vlc_from_lengths();
also remove the documentation in vlc.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 00:26:34 +02:00
Andreas Rheinhardt
a84fe06112 avcodec/idctdsp: Avoid inclusion of avcodec.h
Not every user of idctdsp.h wants to initialize an IDCTDSPContext;
e.g. the proresdsp only uses ff_init_scantable_permutation()
and the IDCT permutation enum; similarly for cavsdsp and wmv2dsp.
Using a forward declaration here avoids an avcodec.h dependency
in the relevant files.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 00:26:34 +02:00
Andreas Rheinhardt
7b0b9a25ed avcodec/proresdsp: Pass necessary parameter directly
Only avctx->bits_per_raw_sample is used.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 00:26:34 +02:00
Andreas Rheinhardt
489d96ca02 avcodec/proresdec: Include required headers directly
Do not rely on an indirect inclusion of avcodec.h in proresdsp.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-11 00:26:34 +02:00
Andreas Rheinhardt
b0fb8e82dd avcodec/get_bits: Avoid reading multiple times in get_bits_long
Due to non-byte-alignment a read of 32 bits guarantees only
25 usable bits; therefore get_bits_long() (which is used to
potentially read more than 25 bits) performs two reads in case
it needs to read more than 25 bits and combines the result.

Yet this is not necessary: One can just read 64 bits at a time
to get 32 usable bits (57 would be possible). This commit does so.

This reduced the size of .text by 30144B for GCC 11.4 and 5648B
for Clang 14 (both with -O3).

(get_bits_long() is a building block of show_bits_long()
and get_ue_golomb_long(), so this patch affects these, too.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-10 23:21:05 +02:00
Paul B Mahol
e26506cb3b avcodec/exr: use uint16/uint8 where possible 2023-09-10 22:44:39 +02:00
Andreas Rheinhardt
cfa47fd331 all: Use av_frame_replace() where appropriate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-10 21:22:30 +02:00
llyyr
ded4478b8b hevc_ps: fix fixed_rate check
Fixes: fc429d785e9e24c5520ce716d4bc3b5547e581eb

Since fc429d785e9e24c5520ce716d4bc3b5547e581eb splits the fixed_rate
flag into general and within_cvs, check for both.
2023-09-10 20:05:07 +01:00
llyyr
06241c3154 hevc_ps: fix cpb_cnt_minus1 initialization
Fixes: fc429d785e9e24c5520ce716d4bc3b5547e581eb

cpb_cnt used to be initialized to 1 before
fc429d785e9e24c5520ce716d4bc3b5547e581eb so cpb_cnt_minus1 should be
initialized to 0.

Also add +1 to the decode_sublayer_hrd call to account for the change to
the offset
2023-09-10 20:04:56 +01:00
Paul B Mahol
1a87a9d82a avcodec/magicyuvenc: add support for encoding raw slice
Switched to raw slice encoding only if huffman encoding size of slice
is bigger than raw one.
2023-09-10 17:56:04 +02:00
Michael Niedermayer
ab7d38f970
avcodec/cscd: Fix "CamStudio Lossless Codec 1.0" gzip files
Fixes: tickets/10241/cscd_1_0_306_306_gzip.avi

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-10 16:40:49 +02:00
Michael Niedermayer
d2a0464fc2
avcodec/cscd: Check for CamStudio Lossless Codec 1.0 behavior in end check of LZO files
Alternatively the check could be simply made more tolerant
Fixes: Ticket10227

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2023-09-10 16:40:49 +02:00
Paul B Mahol
c6f0fd2dcd avcodec/magicyuvenc: use last slice height when correlating 2023-09-10 13:53:04 +02:00