Commit Graph

117244 Commits

Author SHA1 Message Date
Michael Niedermayer
ad35eaf848
avcodec/osq: Treat sum = 0 as k = 0
We have no valid sample that triggers this so we do not know if this would decode
correctly, but -inf is not the correct k value

Fixes: Assertion n>=0 && n<=32 failed at libavcodec/get_bits.h:423
Fixes: -inf is outside the range of representable values of type 'int'
Fixes: 70709/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6223623839350784

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2024-09-24 15:37:15 +02:00
Michael Niedermayer
f2aba7bd9f
MAINTAINERS: Fix typo in web repository
Found-by: Martin Schitter

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-09-24 15:37:14 +02:00
Martin Storsjö
b4d9fa6cb9 compat: Fix the fallback definition of stdc_trailing_zeros
While shifting "value" to left, we would iterate through all bits
of an unsigned long long, while we only expect to count through
"size * CHAR_BIT" bits; instead shift bits to the right and just
count the trailing zeros.

This fixes fate with MSVC.

Signed-off-by: Martin Storsjö <martin@martin.st>
2024-09-24 14:00:27 +03:00
Zhao Zhili
e18b46d95f swscale/aarch64: Fix rgb24toyv12 only works with aligned width
Since c0666d8b, rgb24toyv12 is broken for width non-aligned to 16.
Add a simple wrapper to handle the non-aligned part.

Co-authored-by: johzzy <hellojinqiang@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-09-24 10:24:14 +08:00
James Almer
0dd6f1d5bf avformat/mov: fix setting index of LCEVC enhancement stream
Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 23:11:12 -03:00
James Almer
cc73bf02ba doc/general_contents: add missing reference to LCEVC
Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 13:42:19 -03:00
Anton Khirnov
ce5f571e96 tests/fate/hevc: add a test for selecting view by position
Using a real-world iPhone-recorded file.
2024-09-23 17:15:02 +02:00
Anton Khirnov
eca95dc38f tests/fate/hevc: add a test for switching between single and multi-view 2024-09-23 17:15:02 +02:00
Anton Khirnov
b15af98f6e tests/fate/hevc: add a test for nontrivial values of nuh_layer_id
Typical files use 0 for the base layer and 1 for the secondary one, but
any value for the secondary layer should be supported.
2024-09-23 17:15:02 +02:00
Anton Khirnov
7d4c15cafb tests/fate/hevc: add MV-HEVC conformance sample tests
Only those that can be decoded with our implementation, so excluding
* C and D - independent layers
* G, H, I - more than 2 layers

Frame hashes verified against the reference implementation from
https://hevc.hhi.fraunhofer.de/svn/svn_3DVCSoftware/
2024-09-23 17:15:02 +02:00
Anton Khirnov
da420ac6e1 fftools/ffmpeg: add support for multiview video
This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
2024-09-23 17:15:02 +02:00
Anton Khirnov
68c198fae2 fftools/ffmpeg_sched: allow decoders to have multiple outputs
Will be useful for multilayer video.
2024-09-23 17:15:02 +02:00
James Almer
aef221b22a avcodec/hevc/refs: export Stereo 3D side data
Use the 3D Reference Displays Info SEI message to link a view_id with
an eye.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 17:15:02 +02:00
Anton Khirnov
14746871e1 lavc/hevcdec: implement decoding MV-HEVC
At most two layers are supported.

Aspects of this work were sponsored by Vimeo and Meta.
2024-09-23 17:15:02 +02:00
Anton Khirnov
0fde9c609f lavc/decode: merge stereo3d information from decoder with packet side data
The HEVC decoder will start setting stereoscopic view position (left or
right) based on 3D Reference Displays Info SEI message in future
commits. This information should be merged with container-derived
stereo3D side data.
2024-09-23 17:12:17 +02:00
Anton Khirnov
327080c088 lavc/decode: make sure side data mapping does not produce duplicates
Also, deduplicate the code performing the mapping.
2024-09-23 17:12:15 +02:00
Anton Khirnov
bcbe999077 lavc/decode: clear side data in reget_buffer()
Otherwise it may accumulate when e.g. global side data is repeatedly
copied to the frame with in each subsequent reget_buffer() call.
2024-09-23 17:11:40 +02:00
Anton Khirnov
e19551d165 lavc/decode: do not clear the frame discard flag in ff_decode_frame_props_from_pkt()
Only do it in reget_buffer().

The purpose of this clearing this flag is to prevent it for
unintentionally persisting across multiple invocations of this function
on one frame, however that is only a problem if the frame is not
unreffed between uses, which is only the case with reget_buffer().

In other cases the caller may legitimately want to set the discard flag
and should have the option of doing so.
2024-09-23 17:11:40 +02:00
Anton Khirnov
75914b5822 lavc/hevc/hevcdec: implement MV-HEVC inter-layer prediction
The per-frame reference picture set contains two more lists -
INTER_LAYER[01]. Assuming at most two layers, INTER_LAYER1 is always
empty, but is added anyway for completeness.

When inter-layer prediction is enabled, INTER_LAYER0 for the
second-layer frame will contain the base-layer frame from the same
access unit, if it exists.

The new lists are then used in per-slice reference picture set
construction as per F.8.3.4 "Decoding process for reference picture
lists construction".
2024-09-23 17:11:40 +02:00
Anton Khirnov
02a9435cb0 lavc/hevcdec: implement slice header parsing for nuh_layer_id>0
Cf. F.7.3.6.1 "General slice segment header syntax"
2024-09-23 17:11:40 +02:00
Anton Khirnov
a811ab74f0 lavc/hevc/parser: only split packets on NALUs with nuh_layer_id=0
A packet should contain a full access unit, which for multilayer video
should contain all the layers.
2024-09-23 17:11:40 +02:00
Anton Khirnov
52ce2d2a04 lavc/hevcdec/parse: process NALUs with nuh_layer_id>0
Otherwise parameter sets from extradata with nuh_layer_id>0 would be
ignored. Needed for upcoming MV-HEVC support.
2024-09-23 17:11:40 +02:00
Anton Khirnov
81e9afa6c2 lavc/hevc/ps: reindent 2024-09-23 17:11:40 +02:00
Anton Khirnov
7d245866b8 lavc/hevc/ps: implement SPS parsing for nuh_layer_id>0
Cf. F.7.3.2.2 "Sequence parameter set RBSP syntax", which extends normal
SPS parsing with special clauses depending on MultiLayerExtSpsFlag.
2024-09-23 17:11:40 +02:00
Anton Khirnov
4359467ad6 lavc/hevc/ps: drop a warning for sps_multilayer_extension_flag
SPS multilayer extension contains a single flag that we are free to
ignore, no reason to print a warning.
2024-09-23 17:11:40 +02:00
Niklas Haas
7351e067bc lavc/hevc_ps: parse VPS extension
Only implementing what's needed for MV-HEVC with two views.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-23 17:11:40 +02:00
James Almer
efa9d3deca avcodec/hevc/sei: add support for 3D Reference Displays Information SEI
Signed-off-by: James Almer <jamrial@gmail.com>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-23 17:11:40 +02:00
Anton Khirnov
299d9115d4 lavfi/f_select: allow selection based on view ID
Can be used together with the split filter to decompose multiview video
into individual views.
2024-09-23 17:11:40 +02:00
Anton Khirnov
6940a6de2f lavu/frame: add side data storing view ID for multi-view video 2024-09-23 17:11:38 +02:00
Rémi Denis-Courmont
a7505ec562 compat: add a fallback implementation of C23 stdbit.h
Header contents taken from VLC commit 7a970a33329c9836d169727ddbaf49a33240d587.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-23 17:08:46 +02:00
Anton Khirnov
8c185ef4e7 compat: drop gcc, suncc, and pthreads stdatomic emulation
Since we now require a C11-compliant compiler, there should be no
supported configurations where any of these is used.
2024-09-23 17:08:46 +02:00
Jonathan Baudanza
6b3f9c2e92 avformat/rtpdec: fix integer overflow in start_time_realtime calculation
I encountered this problem with NTP timestamps that are extremely old,
like from January, 1990.

Although RFC3550 suggests that the timestamps in the RTCP packets use
the actual wallclock, some implementations use other clocks, such as
the CLOCK_MONOTONIC on linux.

I'm my case, I'm dealing with packets from mediasoup.

Without this patch, start_time_realtime shows up in the distance future
instead of around Jan 1900.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2024-09-23 17:08:33 +02:00
James Almer
660e7e6a0e avcodec: add LCEVC decoding support via LCEVCdec
Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 10:20:47 -03:00
James Almer
6147385393 avcodec: add an export_side_data flag to export picture enhancement layers
Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 10:07:37 -03:00
James Almer
d250cc02e2 avcodec/hevc/refs: ensure LCEVC SEI payloads are exported as frame side data before get_buffer() calls
Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 10:05:34 -03:00
James Almer
dbbf9a5ff7 avcodec/decode: split ProgressFrame allocator into two functions
Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 10:05:34 -03:00
James Almer
a48eba0021 fftools/ffmpeg_filter: ensure that the inserted filters exist
If not, report it as a bug. avfilter_graph_create_filter() will return ENOMEM if the
passed filter argument is NULL, which is misleading.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 09:02:23 -03:00
James Almer
aeb64d6fa5 configure: add missing filter dependencies to ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 09:02:23 -03:00
Víctor Manuel Jáquez Leal
2bcc124e1a
vulkan_encode: set the quality level in session parameters
While running this command

./ffmpeg_g -loglevel debug -hwaccel vulkan -init_hw_device vulkan=vk:0,debug=1 -hwaccel_output_format vulkan -i input.y4m -vf 'format=nv12,hwupload' -c:v h264_vulkan -quality 2 output.mp4 -y

It hit this validation error:

Validation Error: [ VUID-vkCmdEncodeVideoKHR-None-08318 ] Object 0: handle =
0x8f000000008f, type = VK_OBJECT_TYPE_VIDEO_SESSION_KHR; Object 1: handle =
0xfd00000000fd, type = VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR;
| MessageID = 0x5dc3dd39
| vkCmdEncodeVideoKHR(): The currently configured encode quality level (2) for
VkVideoSessionKHR 0x8f000000008f[] does not match the encode quality level (0)
VkVideoSessionParametersKHR 0xfd00000000fd[] was created with. The Vulkan spec
states: The bound video session parameters object must have been created with
the currently set video encode quality level for the bound video session at the
time the command is executed on the
device (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkCmdEncodeVideoKHR-None-08318)

This patch adds a new function helper for creating session parameters, which
also sets the quality level and it's called by the H.264 and H.265 Vulkan
encoders.
2024-09-23 13:42:34 +02:00
Lynne
39c640e1d6
nlmeans_vulkan: split up descriptor sets, rename buffer offset vars 2024-09-23 13:42:34 +02:00
Lynne
bc36fe6f1f
vulkan: use push descriptors where possible
Push descriptors are in theory slightly faster, but come with
limitations for which we have to check.

Either way, they're not difficult to implement, so even though
no one should be using peasant-tier descriptors, do it anyway.
2024-09-23 13:41:07 +02:00
Lynne
8a7af4aa49
vulkan: add support for regular descriptor pools
This permits:
 - The use of Vulkan filtering on many more devices
 - Better debugging due to lack of descriptor buffer support in layers

Much of the changes here are due to a requirement that updates to
descriptors must happen between the command buffer being waited on,
and the pipeline not being bound.

We routinely did it the other way around, by updating only after
we bind the pipeline.
2024-09-23 13:40:38 +02:00
Lynne
3d75ba7495
vulkan: separate out descriptor layouts from sets
Just avoids a single temporary allocation.
2024-09-23 13:40:38 +02:00
Lynne
2942ca802a
hwcontext_vulkan: forward debug_mode to check_extensions() for devices
This allows disabling of certain extensions when debug mode is turned on.
2024-09-23 13:40:37 +02:00
Lynne
b5184c5d45
hwcontext_vulkan: add the PROFILE_INDEPENDENT only when needed 2024-09-23 13:40:36 +02:00
Lynne
a577d313b2
hwcontext_vulkan: add support for implicit DRM synchronization
More recent kernel versions allow for users to extract a sync_file
handle from a DMA-BUF, which can then be imported into Vulkan as a
binary semaphore.

This finally allows for synchronization between Vulkan and DMA-BUF
images, such as those from screen capture software, or VAAPI,
avoiding any corruption artifacts.

This is done fully asynchronously, where we use the kernel's
given binary semaphores as a dependency to increment the image's
usual VkSemaphores we allocate. The old imported binary semaphores
are cleaned up after execution as usual.

In the future, hwcontext_drm should receive support for explicitly
synchronized images as well, which would make the synchronization
more robust and portable.
2024-09-22 02:11:08 +02:00
Lynne
2395444c80
vulkan: add ff_vk_exec_add_dep_bool_sem
This function simply takes in a binary semaphore as a dependency
to an execution.
2024-09-22 02:11:08 +02:00
Lynne
c4048013e5
vulkan: flexibly allocate temporary imageviews
No reason to allocate 16 when 3 will do.
2024-09-22 02:11:07 +02:00
Lynne
1445102e68
hwcontext_vulkan: fix VUID-VkPhysicalDeviceImageFormatInfo2-usage-requiredbitmask
fmt_props.usage was initialized to 0 as create_info.usage was set later.
2024-09-22 02:11:04 +02:00
Brad Smith
2bf588f273 libavutil/ppc: Make use of getauxval() and elf_aux_info() on ppc
Modern Linux has getauxval() and FreeBSD/OpenBSD ppc have elf_aux_info().

Signed-off-by: Brad Smith <brad@comstyle.com>
2024-09-21 03:11:22 -04:00