1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-24 13:56:33 +02:00

118007 Commits

Author SHA1 Message Date
Niklas Haas
79452d382f swscale/graph: fix memleak of cascaded graphs
Just free them directly and discard the parent context.

Fixes: bf738412e849bcb8c63a330dfb814281b3d97f6b
Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: Sovereign Tech Fund
2024-12-04 11:38:30 +01:00
Zhao Zhili
40302cc35b avcodec/hevc: Add wasm simd128 idct
Benchmark with wasmtime:
wasmtime checkasm --test=hevc_idct --benchmark

hevc_idct_4x4_8_c:                                      20.8 ( 1.00x)
hevc_idct_4x4_8_simd128:                                10.2 ( 2.02x)
hevc_idct_4x4_10_c:                                     21.0 ( 1.00x)
hevc_idct_4x4_10_simd128:                               10.2 ( 2.05x)
hevc_idct_8x8_8_c:                                     198.0 ( 1.00x)
hevc_idct_8x8_8_simd128:                                41.5 ( 4.77x)
hevc_idct_8x8_10_c:                                    197.8 ( 1.00x)
hevc_idct_8x8_10_simd128:                               41.8 ( 4.74x)
hevc_idct_16x16_8_c:                                  1385.2 ( 1.00x)
hevc_idct_16x16_8_simd128:                             291.8 ( 4.75x)
hevc_idct_16x16_10_c:                                 1375.0 ( 1.00x)
hevc_idct_16x16_10_simd128:                            281.2 ( 4.89x)
hevc_idct_32x32_8_c:                                 13479.0 ( 1.00x)
hevc_idct_32x32_8_simd128:                            1541.5 ( 8.74x)
hevc_idct_32x32_10_c:                                13448.0 ( 1.00x)
hevc_idct_32x32_10_simd128:                           1541.5 ( 8.72x)

Decoding test:

1. Without the optimization:
$ wasmtime --wasi threads --dir=/ ./ffmpeg -cpuflags 0 -i 265.mp4 -an -t 120 -f null - -benchmark
frame= 2880 fps= 94 q=-0.0 Lsize=N/A time=00:02:00.00 bitrate=N/A speed=3.92x

2. With the optimization:
$ wasmtime --wasi threads --dir=/ ./ffmpeg -i 265.mp4 -an -t 120 -f null - -benchmark
frame= 2880 fps=110 q=-0.0 Lsize=N/A time=00:02:00.00 bitrate=N/A speed=4.58x

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-12-04 16:43:07 +08:00
Zhao Zhili
ea3d21c349 tests/checkasm: Add partial support for wasm
WASI mssing signal and siglongjmp support. This patch workaround
build error and add simd128 flag. Please note that many tests use
large array on stack, so you need to increase the stack size when
build checkasm, e.g., --extra-ldflags='-Wl,-z,stack-size=10485760'

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-12-04 16:43:07 +08:00
Zhao Zhili
2dc55f5993 configure: Add wasm as a fake arch
And add wasm simd128 flag, so we can add simd128 optimizations.
It can be enabled by put -msimd128 to extra cflags. There is
no runtime detection on simd128 support yet. I think that needs to
be done with JavaScript.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-12-04 16:43:06 +08:00
Michael Niedermayer
7c1e732ad2
avcodec/webp: Check ref_x/y
Fixes: 70991/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WEBP_fuzzer-5544067620995072
Fixes: use of uninintailized value

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-04 04:23:49 +01:00
Michael Niedermayer
4482218440
avcodec/ilbcdec: Initialize tempbuff2
Fixes: Use of uninitialized value
Fixes: 71350/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ILBC_fuzzer-6322020827070464

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-04 04:23:49 +01:00
Michael Niedermayer
61cbcaf93f
avcodec/rv60dec: Check qp for intra
The rv60_qp_to_idx table only supports qp up to 31 on intra

Fixes: global-buffer-overflow
Fixes: 377543818/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5160167345291264

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>
2024-12-04 04:23:49 +01:00
Michael Niedermayer
559d435fa3
avcodec/ffv1enc: Add enum for qtable
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-04 04:23:48 +01:00
Michael Niedermayer
d32dcc07a7
swscale/swscale_unscaled: Fix odd height with nv24_to_yuv420p_chroma()
Fixes: out of array read
Fixes: 71726/clusterfuzz-testcase-ffmpeg_SWS_fuzzer-5876893532880896
Fixes: 377735917/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-6686071112400896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Approved-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-04 04:23:48 +01:00
Scott Theisen
5ba63f0ef1 avformat/mpegts: is_pes_stream() use switch case
also add STREAM_TYPE_PRIVATE_SECTION since a private_section() is not a
PES_packet().

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-12-03 23:09:58 +01:00
Scott Theisen
1259760825 avformat/mpegts*: reduce use of magic numbers
Note ISO/IEC 13818-1 defines an Extension_descriptor with descriptor_tag value
0x3f (63), so I kept the DVB comment.

I don't know what defines stream_type value 0x8a as DTS.

I don't have any Blu-ray standards so I don't know where those stream_type
values are defined.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-12-03 23:09:57 +01:00
Frank Plowman
56419fd096 lavc/vvc: Fix overflow in MVD derivation
H.266 (V3) section 7.4.12.8: "The value of lMvd[ compIdx ] shall be in
the range of −2^{17} to 2^{17} − 1, inclusive."

Signed-off-by: Frank Plowman <post@frankplowman.com>
2024-12-03 10:22:55 +08:00
Frank Plowman
499896ca2f lavc/vvc: Fix derivation of LmcsMaxBinIdx
Per H.266 (V3) section 7.4.3.19, LmcsMaxBinIdx is set equal to
15 - lmcs_delta_max_bin_idx.  The previous code instead had it equal to
15 - lmcs_min_bin_idx.  This could cause decoder mismatches.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2024-12-03 10:22:55 +08:00
Frank Plowman
699322519c lavc/vvc: Store MIP information over entire CU area
Previously, the code only stored the MIP mode and transpose flag in the
relevant tables at the top-left corner of the CU.  This information ends
up being retrieved in ff_vvc_intra_pred_* not based on the CU position
but instead the transform unit position (specifically, using the x0 and
y0 from get_luma_predict_unit).  There might be multiple transform units
in a CU, hence the top-left corner of the transform unit might not
coincide with the top-left corner of the CU.  Consequently, we need to
store the MIP information at all positions in the CU, not only its
top-left corner, as we already do for the MIP flag.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2024-12-03 10:20:51 +08:00
Frank Plowman
7399d9f374 lavc/vvc: Don't check motion estimation region for IBC
The final parameter of check_available determines whether the motion
estimation region constraints imposed in section 8.5.2.3 of H.266 (V3)
on MVP candidates apply to the current candidate or not.  In the case of
IBC spatial merge candidates they do not, as their availability is
dependent only on the criteria described in sections 8.6.2.3 and 6.4.4,
which do not include this constraint on the motion estimation region.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2024-12-03 10:20:51 +08:00
Frank Plowman
9221cb0443 lavc/vvc: Use second definition of MinQtLog2SizeIntraC if relevant
MinQtLog2SizeIntraC is usually (eq. (51) from VVCv3) defined as

sps_log2_diff_min_qt_min_cb_intra_slice_chroma + MinCbLog2SizeY

However, in the case ph_log2_diff_min_qt_min_cb_intra_slice_chroma is
present, it is instead (eq. (83) from VVCv3) defined as

ph_log2_diff_min_qt_min_cb_intra_slice_chroma + MinCbLog2SizeY

When ph_log2_diff_max_bt_min_qt_intra_slice_chroma and
ph_log2_diff_max_tt_min_qt_intra_slice_chroma are present, so is
ph_log2_diff_min_qt_min_cb_intra_slice_chroma, and so we should use the
second definition of MinQtLog2SizeIntraC, rather than the first, when
calculating the bounds for these syntax elements.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2024-12-03 10:20:51 +08:00
Alexander Strasser
a280e2e646 avcodec/cbs_h266: Fix typo
Introduced in commit 98698ed3c24bfd0b1e6e6db943b5f25f6046cee7

Fixes: CID1635788 CID1635789
Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
2024-12-03 10:19:34 +08:00
James Almer
cb27e478f7 doc/codecs: add missing enhancements value for export_side_data
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-02 12:53:54 -03:00
James Almer
d2c90abab7 doc/filters: add an entry for vf_lcevc
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-02 12:53:54 -03:00
Zhao Zhili
6e49b86996 avutil/mem_internal: Don't use alignas for MSVC
MSVC messed up standard C features, again.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: James Almer <jamrial@gmail.com>
2024-12-02 20:37:47 +08:00
Michael Niedermayer
4fc43e45f9
avcodec/hevc/hevcdec: initialize qp_y_tab
This does not replicate on my setup, thus this is a blind fix based on ossfuzz trace

Fixes: use of uninitialized value
Fixes: 71747/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5427736120721408

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:49 +01:00
Michael Niedermayer
f52b9d0583
avformat/qcp: Check for read failure in header
Fixes: Use of uninitialized value
Fixes: 71551/clusterfuzz-testcase-minimized-ffmpeg_dem_QCP_fuzzer-4647386712965120

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:48 +01:00
Michael Niedermayer
4949e34d96
avcodec/eatgq: Check bytestream2_get_buffer() for failure
Fixes: Use of uninitialized memory
Fixes: 71546/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EATGQ_fuzzer-5607656650244096

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:48 +01:00
Michael Niedermayer
cdce6a8b97
avcodec/eatgq: move array to where it is used
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:48 +01:00
Michael Niedermayer
7e020f2141
avformat/dxa: check bpc
Fixes: integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 373971762/clusterfuzz-testcase-minimized-ffmpeg_dem_DXA_fuzzer-4880491112103936

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:47 +01:00
Michael Niedermayer
aeec39f3c1
swscale/slice: clear allocated memory in alloc_lines()
Fixes: use of uninitialized memory in hScale16To15_c()
Fixes: 373924007/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5841199968092160

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:47 +01:00
Michael Niedermayer
b2da4c33e3
avcodec/rangecoder: eliminate main branch from renorm_encoder()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:47 +01:00
Michael Niedermayer
18922f4ae3
avcodec/rangecoder: Remove unneeded outstanding byte mask
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:46 +01:00
Michael Niedermayer
70fa8bd38c
avcodec/rangecoder: Avoid checking for the first byte on every renormalization
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:46 +01:00
Michael Niedermayer
832649986c
avcodec/rangecoder: Move refill check out of refill() function
If the function is not inlined, this is more efficient. Also
it allows calling refill() without the check

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:46 +01:00
Michael Niedermayer
c314a68d04
avcodec/rangecoder: Do not loop renormalization
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:45 +01:00
Michael Niedermayer
360e7cafd0
avcodec/h2645_parse: Ignore NAL with nuh_layer_id == 63
Comply with "For purposes other than determining the amount of data in the decoding units
of the bitstream, decoders shall ignore all data that follow the value 63 for nuh_layer_id in a NAL unit"
Rec. ITU-T H.265 v8 (08/2021)	Page 67

Fixes: index 63 out of bounds for type 'const int8_t[63]' (aka 'const signed char[63]')
Fixes: clusterfuzz-testcase-fuzzer_loadfile-5109286752026624
Reported-by: Kacper Michajlow <kasper93@gmail.com>
Found-by: ossfuzz
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:45 +01:00
Michael Niedermayer
c250a903a7
doc/encoders: very basic FFv1 documentation
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 03:14:44 +01:00
Sean McGovern
b9eaf6e05c
swscale/ppc: disable YUV2RGB AltiVec acceleration
The FATE test 'checkasm-sw_yuv2rgb' currently fails on this platform,
in both little- and big-endian configurations with AltiVec enabled.

Disable it for the time being.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 02:51:39 +01:00
Michael Niedermayer
4cc1495aca
avformat/iamf_parse: reject ambisonics mode > 1
ambisonics mode > 1 does not initialize any layer but layer 0
is unconditionally dereferenced

Fixes: poc-2024-11
Fixes: null pointer dereference
Found-by: 苏童 <220235212@seu.edu.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-02 02:51:38 +01:00
Marth64
1c2c70fe4d doc/demuxers/dvdvideo: seeking is supported, remove outdated statement
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-12-01 13:49:01 -06:00
Marth64
e256761def avformat/dvdvideodec: check return code of ff_dvdclut_yuv_to_rgb()
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-12-01 13:48:51 -06:00
Marth64
a5a899bfcb avformat/dvdvideodec: fix missing last chapter marker due to off-by-one
When using fast chapter marker calculation (default), the last
marker is inadverdently ignored due to an off-by-one.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-12-01 13:48:45 -06:00
Frank Plowman
1e3dc705df lavc/x86/videodsp: Drop MMX usage
Remove the MMX versions of these functions and modify the SSE
implementations to avoid using MMX registers.

Signed-off-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
2024-12-01 13:26:34 +08:00
Nuo Mi
4de67e8746 avcodec/vvcdec: return error if CTU size > 128
The v3 spec reserves CTU size 256. Currently, we use an uint8_t* table to hold cb_width and cb_height.
If a CTU size of 256 is not split, cb_width and cb_height will overflow to 0.
To avoid switching to uint16_t, rejecting CTU size 256 provides a simple solution.
2024-11-30 09:58:59 +08:00
Nuo Mi
eb67e60cb0 avcodec/vvcdec: schedule next stage only if the current stage reports no error
If the current stage reports an error, some variables may not be correctly initialized.
Scheduling the next stage could lead to the use of uninitialized variables.
2024-11-30 09:58:59 +08:00
Nuo Mi
4ec767abcc avcodec/vvcdec: misc, reformat inter_data() 2024-11-30 09:58:59 +08:00
Nuo Mi
ba89c5b989 avcodec/vvcdec: inter_data, check the return value from hls_merge_data
Reported-by: Frank Plowman <post@frankplowman.com>
2024-11-30 09:58:59 +08:00
Nuo Mi
98698ed3c2 avcodec/cbs_h266: stricter validation for subpicture's max width and height
Co-authored-by: Frank Plowman <post@frankplowman.com>
2024-11-30 09:58:59 +08:00
Nuo Mi
e06515b092 avcodec/cbs_h266: improve readability in subpicture parser 2024-11-30 09:58:59 +08:00
Nuo Mi
5c5a08ecb5 avcodec/vvcdec: ensure every CTU belongs to a slice
According to section 6.3.3 "Spatial or component-wise partitionings,"
CTUs should fully cover slices with no overlaps, gaps, or additions.
No overlaps are ensured by task_init_parse.
No gaps and no additions are ensured by this patch.

Co-authored-by: Frank Plowman <post@frankplowman.com>
2024-11-30 09:58:59 +08:00
Nuo Mi
46006529a1 avcodec/cbs_h266: check subpicture slices number
According to section 6.3.3, 'Spatial or component-wise partitionings,'
Subpictures must cover the entire picture.
Therefore, the total number of subpicture slices should equal the number of picture slices

Co-authored-by: Frank Plowman <post@frankplowman.com>
2024-11-30 09:58:59 +08:00
Marton Balint
4100a2da29 tests/fate/filter-audio: add aloop test
Signed-off-by: Marton Balint <cus@passwd.hu>
2024-11-29 21:59:56 +01:00
Marton Balint
f5948543f4 fate: revert previous frequency adjustments of the sine filter
With more precise frequency support in the sine filter, several fate tests will
change.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-11-29 21:16:22 +01:00
Marton Balint
8d6f3bcb96 avfilter/asrc_sine: increase frequency accuracy
Previously the delta phase was fixed point fractional with 2^32 fractions,
which caused inaccuracies in the output frequency, unless the input
frequency*2^32 was divisable by the sample rate.

This patch improves frequency accuracy by tracking subfractions of the delta
phase fractions. For this we are using a denominator which is a multiple of the
sample rate, making sure that integer frequencies are always accurately
represented.

Signed-off-by: Marton Balint <cus@passwd.hu>
2024-11-29 21:16:22 +01:00