1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-10 06:10:52 +02:00
Commit Graph

120311 Commits

Author SHA1 Message Date
James Almer
e32264a1e1 avformat/mov: don't assume iloc and iinf entries for each item_id will be in the same order
Nothing forbids them to be in any order the muxer desires.

Fixes demuxing heif samples generated by S1II.

Tested-by: Lynne <dev@lynne.ee>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 14:57:09 -03:00
James Almer
3cd5672bfe fate/lavf-container: add test for APV in MP4
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 14:55:34 -03: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
James Almer
af9b43455a swscale/swscale_unscaled: don't add offsets to NULL pointers
Fixes: libswscale/swscale_unscaled.c:916:20: runtime error: applying zero offset to null pointer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 14:23:10 -03:00
James Almer
ee4ff3f706 avfilter/x86/vf_blackdetect_init: don't enable the ASM functions on targets where it's known they will be slower
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 13:05:44 -03:00
James Almer
f263192f0e avfilter/x86/vf_blackdetect: don't use rax to return a 32bit integer
Fixes compilation on x86_32.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-18 13:05:44 -03:00
Zhao Zhili
a218cafe4d avfilter/vf_blackdetect: Fix header guard
Fix fate-source failure.
2025-07-18 13:44:51 +02:00
Niklas Haas
bfab026298 tests/checkasm: add test for vf_blackdetect 2025-07-18 10:47:31 +02:00
Niklas Haas
75cd42c48a avfilter/vf_blackdetect: add AVX2 SIMD version
Requested by a user. Even with autovectorization enabled, the compiler
performs a quite poor job of optimizing this function, due to not being
able to take advantage of the pmaxub + pcmpeqb trick for counting the number
of pixels less than or equal-to a threshold.

blackdetect8_c:                                       4625.0 ( 1.00x)
blackdetect8_avx2:                                     155.1 (29.83x)
blackdetect16_c:                                      2529.4 ( 1.00x)
blackdetect16_avx2:                                    163.6 (15.46x)
2025-07-18 10:47:31 +02: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
Zhao Zhili
fbda5ffb95 avutil/hwcontext: Add ohcodec device and pixel format
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-07-18 14:44:39 +08:00
wangbin
7b13d17b6d avdevice/android_camera: Set image linesize aligment to 1
Can't read alignment from packet, codecpar or decoded frame linesizes, so don't
set it. My test device redmi k60 produces images in 4624x3472, not 32 aligned

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-07-18 10:37:53 +08:00
Eric Joyner
291ec0faf3 avformat/mov: Enable jpeg streams in HEIF MOVContext
Nikon HEIFs from a camera or NX studio include a small jpeg thumbnail in addition to
the expected HEVC thumbnails; allowing jpegs allows all thumbnails to
have an associated stream for Nikon HEIF files.

With this, Nikon HEIFs can finally be decoded without failing and the
thumbnails can be extracted into their own files.

Signed-off-by: Eric Joyner <erj@erj.cc>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-17 21:54:03 -03:00
Eric Joyner
fb163eb28b avformat/mov: Support multiple thumbnails in HEIF
Prevents ffmpeg/ffprobe from erroring out when reading an HEIF that
contains multiple hvcC thumbnails (e.g. from a Nikon Z6III camera).

Before, move_read_iref_thmb() would always override the stored
thmb_item_id in the MOVContext with each new read thumbnail, causing a
stream and item_id mismatch later in mov_parse_heif_items(), resulting
in the "HEIF thumbnail doesn't reference a stream" error message.

To solve this,

- Turn thmb_item_id into an array of IDs because multiple thumbnails can
  exist
- Change check in mov_parse_heif_items() to compare against all stored
  thumbnail IDs to see if any item missing a stream is in the list of
  thumbnail IDs.

Signed-off-by: Eric Joyner <erj@erj.cc>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-17 21:54:03 -03:00
Jack Lau
25e710c61e avformat/whip: force NONBLOCK for rtp
We need to ensure rtp sets NONBLOCK since the dtls
handshake has potentially overriden the sockets mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 14:33:47 +02:00
Timo Rothenpieler
e6d2c67cd0 avformat/tls_openssl: avoid unusual inline-if style 2025-07-17 14:06:07 +02:00
Jack Lau
abb274b154 avformat/tls_openssl: make tls and dtls use one close function
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 14:04:32 +02:00
Niklas Haas
bc8d06d541 avfilter/vf_thumbnail: unroll and use multiple histograms
This naive hist[p[x]]++ loop suffers badly when there are large regions of
identical values in the image, because of store-to-load forwarding delay.

Splitting up the histogram into four "parallel" histograms and processing
them one at a time speeds things up significantly, about 40% on my end.
2025-07-17 12:33:59 +02:00
Niklas Haas
e44a1aaeec avfilter/x86/scene_sad: add high bit depth AVX2/AVX512 version
Since psadbw only exists for 8-bits, we have to emulate it for 16-bit
inputs. The simplest sequence is to use a normal subtraction, which is safe
as long as the inputs do not exceed 32767 - so limit this implementation
to 15-bit inputs and below.

For 16-bit inputs, we could in theory instead use a pminw / pmaxw to ensure
the resulting difference does not overflow, but this is slower, and also
breaks the subsequent use of pmaddwd, so I opted to skip 16-bit SIMD for
now.

scene_sad10_c:                                      114175.6 ( 1.00x)
scene_sad10_avx2:                                     9617.7 (11.87x)
scene_sad10_avx512:                                   5208.8 (21.92x)
scene_sad12_c:                                      114537.8 ( 1.00x)
scene_sad12_avx2:                                     9614.0 (11.91x)
scene_sad12_avx512:                                   5186.3 (22.08x)
scene_sad14_c:                                      114113.9 ( 1.00x)
scene_sad14_avx2:                                     9612.9 (11.87x)
scene_sad14_avx512:                                   5186.0 (22.00x)
scene_sad15_c:                                      114108.9 ( 1.00x)
scene_sad15_avx2:                                     9612.3 (11.87x)
scene_sad15_avx512:                                   5186.4 (22.00x)
scene_sad16_c:                                      114136.0 ( 1.00x)
2025-07-17 12:26:06 +02:00
Niklas Haas
91f2d146d4 avfilter/x86/scene_sad: add AVX512 implementation
Trivial to add, but a lot faster (on my machine).

scene_sad8_c:                                       114476.4 ( 1.00x)
scene_sad8_sse2:                                      8644.3 (13.24x)
scene_sad8_avx2:                                      4520.1 (25.33x)
scene_sad8_avx512:                                    3153.0 (36.31x)
2025-07-17 12:26:06 +02:00
Niklas Haas
9251af058a tests/checkasm: add scene_sad checkasm test 2025-07-17 12:26:05 +02:00
Niklas Haas
dc61b74c1d avfilter/scene_sad: pass true depth to ff_scene_sad_get_fn()
I need to be able to distinguish between 10/12/14 and 16 bit depths, for
overflow reasons.
2025-07-17 12:26:05 +02:00
Jack Lau
e6af82c498 avformat/tls_openssl: remove all redundant "TLS: " in log with AVClass
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:35:11 +02:00
Jack Lau
dda91b87e8 avformat/tls_openssl: replace 1 with TLS_ST_OK to be more clear
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:35:07 +02:00
Jack Lau
7bd3bdbd62 avformat/whip: free udp socket after dtls free
the SSL_shutdown in tls_close need call the url_bio_bwrite
so we should keep udp still alive

Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:35:01 +02:00
Timo Rothenpieler
95eae5dd50 avformat/tls_openssl: unset nonblock flag on correct URLContext during dtls handshake
The internal BIO functions do not in fact look at this flag, only the outer
tls_read and tls_write functions do.
2025-07-17 02:20:34 +02:00
Jack Lau
7afe1167e5 avformat/tls_openssl: set tlsext host name after init ssl
Signed-off-by: Jack Lau <jacklau1222@qq.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-17 02:04:38 +02:00
Kacper Michajłow
2869cce163 configure: add -Wl when linker is called indirectly
It's possible to call linker indirectly through driver like Clang. In
which cases linker args has to be prefixed with -Wl.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-17 00:28:21 +02:00
Kacper Michajłow
ec51162bb6 checkasm/swscale: fix function prototypes
This aligns declared function types in checkasm with real definition.

Fixes FATE: checkasm-{sw_rgb,sw_scale,sw_yuv2rgb,sw_yuv2yuv}

Fixes: runtime error: call to function <func> through pointer to incorrect function type
Fixes: c1a0e65763

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-07-17 00:28:21 +02:00
Timo Rothenpieler
9015d595a1 avformat/flvdec: don't skip backwards or over EOF
Skipping backwards (and even forwards) resets the EOF flag, and can thus
lead to infinite looping if the conditions are just right.

Fixes: Infinite loop
Fixes: 427538726/clusterfuzz-testcase-minimized-ffmpeg_dem_FLV_fuzzer-6582567304495104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-16 19:05:51 +02:00
Timo Rothenpieler
483e509169 avformat/tls_openssl: automatically generate self-signed certificate when none is provided in listen mode 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
454f161b4b avformat/tls_openssl: make generating fingerprints optional 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
40ce64eae7 avformat/tls_openssl: don't expose deprecated EC_KEY outside of its function 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
5339db2cf4 avformat/tls_openssl: properly free generated/read keys and certificates 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
49badc8689 avformat/tls_openssl: don't enable read_ahead in dtls mode
OpenSSL docs say:
These functions have no impact when used with DTLS.
2025-07-16 18:46:55 +02:00
Timo Rothenpieler
31abcc1505 avformar/tls_openssl: use correct info callback in DTLS mode 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
5edbfc4bae avformat/tls_openssl: clean up peer verify logic in dtls mode 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
95fd0840fe avformat/tls_openssl: don't hardcode ciphers and curves for dtls 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
f3355a1fff avformat/tls_openssl: properly limit written size to data mtu 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
576f44016a avformat/tls_openssl: set default MTU if none is set 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
b6e808d28b avformat/tls_openssl: initialize DTLS context with correct method 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
db0adbbd3f avformat/tls_openssl: don't abort if dtls has no key/cert set 2025-07-16 18:46:55 +02:00
Timo Rothenpieler
951013e603 avformat/tls_openssl: force dtls handshake to be blocking
There is no sensible way to handle this otherwise anyway, one just has
to loop over this function until it succeeds.
2025-07-16 18:46:55 +02:00
Timo Rothenpieler
87b09f3931 avformat/tls_openssl: set dtls remote addr in listen mode
Taken from the first received packet, which will signify the now
permanent peer of this DTLS "connection".
2025-07-16 18:46:55 +02: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
James Almer
307983b292 avformat/tls_schannel: add check for Windows 10 only types and defines
Old Mingw-w64 releases provided by some distros seemingly don't have them, so
check for them and disable the dtls protocol if unavailable.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-15 10:24:08 -03:00
Niklas Haas
053a113ad8 avutil/hwcontext_vulkan: don't over-map buffers with prior padding
If the image data is not at the start of the buffer allocation, such as
when the buffer has padding before the image data, this function maps too
much memory, since src_data + src_buf->size exceeds the buffer size.

Fix this by subtracting the difference between the buffer start and the
provided image data pointer from the size of the memory range to map.

An easy way to reproduce this issue is using the vf_pad filter, which
allocates image data buffers with a nonzero offset whenever padding is
requested before the start of the image data.
2025-07-15 12:46:11 +02: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