Commit graph

52482 commits

Author SHA1 Message Date
Dale Curtis
2ddc3cbd98
avcodec/flacdsp: Fix integer-overflow in flac_lpc_33_c
This fix copies a couple of casts from surrounding functions.
See https://crbug.com/432528781 for stack trace details.

Signed-off-by: Dale Curtis <dalecurtis@chromium.org>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-31 20:25:15 +02:00
Dariusz Frankiewicz
9d8469e431
avcodec/apv: align APV color format support with latest liboapv version
Signed-off-by: Dariusz Frankiewicz <d.frankiewic@samsung.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-31 20:24:40 +02:00
Michael Niedermayer
f09c834a7d
avcodec/cbs_apv_syntax_template: Check tile_data_size
Fixes: heap-buffer-overflow
Fixes: 418421333/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-6592025183191040
Fixes: 418804929/clusterfuzz-testcase-minimized-ffmpeg_BSF_APV_METADATA_fuzzer-5773904646045696
Fixes: 420737045/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-5535272169439232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-30 01:18:03 +02:00
Michael Niedermayer
3ccd7d8c8e
avcodec/sanm: Check decoded_size for old_codec48
Fixes: writing over the end of the array
Fixes: BIGSLEEP-434637586/payload

Regression since: b22ce90d42

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-30 01:18:02 +02:00
Araz Iusubov
5f24c50890 amfenc: Fix for full PA queue
Fixes AMF_INPUT_FULL errors with pre-analysis (PA) enabled.
Added wait and poll encoder output to free up internal buffers
before submitting new frames.
Improves stability and performance by accounting for encoder and
analysis stage queue limits (incl. lookahead buffering).

Reproduce:
ffmpeg.exe -y -r 60 -f lavfi -i testsrc=rate=60:size=3840x2160
-t 10 -pix_fmt yuv420p -an -c:v av1_amf -preset:v high_quality
-profile:v main -quality:v high_quality -usage:v high_quality
2025-07-29 23:38:16 +02:00
Frank Plowman
7c5319e692
lavc/vvc: Add max parameter to kth_order_egk_decode
Prior to this patch, kth_order_egk_decode could read arbitrarily
large values which then overflowed and caused various issues.
Patch fixes this by making kth_order_egk_decode falliable,
requiring the caller to specify an upper bound and returning an
error if the read value would exceed that bound.

This patch resolves the same issue as
eb52251c0a, but I think this is the proper
fix as it also addresses issues with syntax elements besides
ff_vvc_num_signalled_palette_entries.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-07-28 20:46:10 +01:00
Frank Plowman
ce172bc362
lavc/vvc: Don't discard palette_subblock_data return code
Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-07-28 20:45:45 +01:00
Michael Niedermayer
3afae0f440
avcodec/sanm: Check w, h for subversion < 2
Fixes: 410609432/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-4935159201988608
Fixes: out of array access

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 19:28:13 +02:00
Michael Niedermayer
a45755e302
avcodec/dxvenc: Clear width to linesize not linesize to linesize
Fixes: use of uninitialized memory
Fixes: 422217206/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_fuzzer-4786889444098048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:38 +02:00
Michael Niedermayer
909229b880
avcodec/shorten: Clear the additionally allocated space on realloc
Fixes: use of uninitialized memory
Fixes: 421954767/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SHORTEN_fuzzer-515682786246656

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:38 +02:00
Michael Niedermayer
7a21c37f75
avcodec/hevc/hevcdec: Clean sao_pixel_buffer_v on allocation
Fixes: use of uninitialized memory
Fixes: 378102648/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5896308499480576

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:41:36 +02:00
Michael Niedermayer
0887d2e291
avcodec/alsdec: Allow the user to set a maximum prediction order
The only offical profile i could find (ALS simple profile) has a max of 15 while the bitstream allows 1023
which is very slow.

We do have a fate sample with 1023

Fixes: Timeout
Fixes: 429645375/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5377900448907264

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-28 17:27:52 +02:00
Kacper Michajłow
e74dbb02eb avcodec/dovi_rpudec: skip unknown ext blocks instead of erroring out
Should allow for forward compatibility with newer versions.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-27 12:16:00 +00:00
Kacper Michajłow
ef167512ab avcodec/dovi_rpudec: parse RPU forward, don't try to find end
Instead of scanning backwards for the end of RPU payload, parse it and
report if we didn't land at the terminator byte.

Current expectation was that we can have additional zero bytes after RPU
payload, which were skipped to find playload end. That's not always the
case. So loosen this requirement.

This fixes files where there is additional non-zeroed padding after the
end of the RPU in NALU.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-27 14:09:46 +02:00
Kacper Michajłow
bf640b53db avcodec/hevc/hevcdec: handle rpu_buf allocation failure correctly
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-27 14:09:46 +02:00
Timo Rothenpieler
dc0ac81bbe avcodec/cuviddec: fix wrong 10bit 420 format in cuvid_handle_video_sequence 2025-07-26 14:42:33 +02:00
Timo Rothenpieler
a56da996ce avcodec/cuviddec: also reflect new pix_fmts in cuvid_handle_video_sequence 2025-07-26 14:42:05 +02:00
Kacper Michajłow
40b56c6536 avcodec/x86/vc1: guard usage of undefined functions with preprocessor
The asumption is that DCE will remove references to those functions.
However some compilers with certain instrumentation enabled doesn't DCE
those at all, resulting in linking failure. Tested with cl.exe -RTCu -RTCs.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
9658d4425e avcodec/x86/fdct: guard usage of undefined functions with preprocessor
The asumption is that DCE will remove references to those functions.
However some compilers with certain instrumentation enabled doesn't DCE
those at all, resulting in linking failure. Tested with cl.exe -RTCu -RTCs.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
6bc23ab352 avcodec/d3d12va_encode_hevc: remove unused variable
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
62e2af358d avcodec/d3d12va_encode: don't return uninitialized value on error
When CreateEvent fails, err was not initialized.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
7d9b21601c avcodec/d3d12va_encode: don't write garbage when there is no header
When codec->write_sequence_header is not defined, bit_len was undefined,
and while data bufer was zeroed we could just overread it. Do nothing
when we don't have anything to write.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
a1588c875a avcodec/d3d12va_encode: use correct none flag
NFC, it's still 0, but correct enum type so compilers won't complain.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
c1ccd4bb22 avcodec/d3d12va_decode: remove unused variable
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:16 +02:00
Kacper Michajłow
d6b72d1d26 avformat/options_table: supress implicit conversion warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-25 21:10:13 +02:00
Leo Izen
829680f96a
avcodec/jpegxl_parser: add sanity check for frame size
If a frame size is absolutely massive, this can spin the parser as it
attempts to decode a permuted TOC. We add a sanity check here for eight
times the size of the image for an internal frame to prevent malicious
bitstreams from slowing the parser down to a crawl.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-23 06:22:16 -04:00
James Almer
3f2b452a22 avcodec/opus/silk: don't assume stereo when calling silk_decode_frame()
Fixes use-of-uninitialized-value under MSAN.

Reviewed-by: Kacper Michajlow <kasper93@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 22:16:25 -03:00
James Almer
86670fec9c avcodec/ffv1dec: don't check chroma_planes for f->colorspace > 0
It's RGB, so check instead if it's packed or planar.

Fixes: libavcodec/ffv1dec.c:461:43: runtime error: applying zero offset to null pointer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 12:37:31 -03:00
James Almer
cb9742af76 avcodec: use the getters for xGA font data arrays
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
James Almer
e835738b70 avcodec/cbs_apv: add missing READ/WRITE preprocessor checks
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:18 -03:00
James Almer
48ef4caac2 avcodec/ffv1dec: don't add offsets to more NULL pointers
Fixes: libavcodec/ffv1dec.c:453:43: runtime error: applying zero offset to null pointer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-22 09:47:17 -03:00
Bernat Arlandis
3cd4fa9b89
libtheoraenc: Add encoding speed level option
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-22 01:35:01 +02:00
Michael Niedermayer
749aaf2744
avcodec/smacker: cleanup on bet buffer failure
Fixes: memleak (of vlc)
Fixes: 430343927/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMACKAUD_fuzzer-5265858979233792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-20 01:05:24 +02:00
Michael Niedermayer
051e0d7744
avcodec/ffv1dec: Check k in get_vlc_symbol()
The true problem happens in several previous get_vlc_symbol()
but checking that is more expensive (involving FFABS())
here its just a simple check between 2 variables we have.

Fixes: Assertion log >= k failed at libavcodec/golomb.h:406
Fixes: 429296194/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_DEC_fuzzer-4691594622337024

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-20 01:05:23 +02:00
Michael Niedermayer
c0f1c3e185
avcodec/ivi: Check luma/chroma mb_size
Fixes: shift exponent -1 is negative
Fixes: 429011224/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO5_fuzzer-5031059358285824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-20 01:05:23 +02:00
Michael Niedermayer
2d72bf6fe0
avcodec/cfhd: Check idwt_buf size before allocation
Fixes: OOM
Fixes: 428760799/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_DEC_fuzzer-5685176435015680

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-20 01:05:23 +02:00
Kacper Michajłow
806186e9ad avcodec/sonic: move code closer to use to avoid unused warnings
Put decoding and encoding code into thier respective #if blocks.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-19 00:36:25 +02:00
Kacper Michajłow
39e11fa700 avcodec/sonic: remove dead code
This was in else branch of `#if 1` since ever. No need to keep dead code
like that, if anyone needs it they can get it from git history.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-19 00:36:25 +02:00
Dawid Kozinski
8baa691e5f avformat/mov_muxer: Extended MOV muxer to handle APV video content
- Changes in mov_write_video_tag function to handle APV elementary stream
- Provided structure APVDecoderConfigurationRecord that specifies the decoder configuration information for APV video content

Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Dawid Kozinski <d.kozinski@samsung.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 14:54:36 -03:00
James Almer
585a8d5357 avcodec/motion_est: don't add offsets to NULL pointers
Fixes: libavcodec/motion_est.c:94:31: runtime error: applying zero offset to null pointer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 14:23:10 -03:00
Zhao Zhili
fa0080bf2e avcodec/ohenc: Add h264/hevc OpenHarmony encoders 2025-07-18 14:45:13 +08:00
Zhao Zhili
e7f44f8cd8 avcodec/ohdec: Add h264/hevc OpenHarmony decoders 2025-07-18 14:45:13 +08:00
James Almer
9c55f22ef2 avcodec/ffv1dec: don't add offsets to NULL pointers
Fixes: libavcodec/ffv1dec.c:452:43: runtime error: applying zero offset to null pointer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-15 10:24:09 -03:00
Lynne
bedfb6eca4
aacenc_tns: clamp filter direction energy measurement
The issue is that:

float en[2];
...
tns->n_filt[w] = is8 ? 1 : order != TNS_MAX_ORDER ? 2 : 3;
for (g = 0; g < tns->n_filt[w]; g++) {
    tns->direction[w][g] = slant != 2 ? slant : en[g] < en[!g];

When using the AAC Main profile, n_filt = 3, and slant is by
default 2 (normal long frames), g can go above 1.

en is the evolution of energy in the frequency domain for every
band at the given window. E.g. whether the energy is concentrated
at the top of each band, or the bottom.

For 2-pole filters, its straightforward.
For 3-pole filters, we need more than 2 measurements.

This commit properly implements support for 3-pole filters, by measuring
the band energy across three areas.

Do note that even xHE-AAC caps n_filt to 2, and only AAC Main allows
n_filt == 3.

Fixes https://trac.ffmpeg.org/ticket/11418
2025-07-15 16:27:31 +09:00
Jiasheng Jiang
35a6de137a
libavcodec/alsdec.c: Add check for av_malloc_array() and av_calloc()
Add check for the return value of av_malloc_array() and av_calloc()
to avoid potential NULL pointer dereference.

Fixes: dcfd24b10c ("avcodec/alsdec: Implement floating point sample data decoding")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-07-12 20:35:18 +02:00
Timo Rothenpieler
3ce348063c avcodec/nvdec: switch to proper pixfmts on next major bump 2025-07-11 17:49:58 +02:00
Timo Rothenpieler
8304a1abc7 avcodec/nvenc: add support for new 10 bit MSB pixel formats 2025-07-11 17:49:58 +02:00
Andreas Rheinhardt
fadadb56e6 avcodec/mpegvideo_dec: Avoid implicit NULL + offset
Happens since 4fc874ef08
when this code is called via error resilience.
Also do the same for wmv2dec.c.
Fixes the vsynth_{1,2,3,_lena}-mpeg4-error and wmv2-drm-dec FATE-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-11 15:14:36 +02:00
Andreas Rheinhardt
9139edfdd3 avcodec/opus/dec: Simplify resetting AVAudioFifo
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-11 15:14:27 +02:00
Andreas Rheinhardt
66f29ae9b6 avcodec/opus/dec: Don't call function multiple times in FFMAX
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-11 15:14:21 +02:00