Commit graph

118431 commits

Author SHA1 Message Date
2f72dc33ff avformat/flvdec: add enhanced audio codecs 2024-12-27 20:24:22 +01:00
70067c829b avformat/flvenc: remove !size check for audio packets
At least flac finishes every stream with an empty side-data only packet,
that would trigger an assertion/error were these checks still in place.
2024-12-27 20:24:22 +01:00
Dennis Sädtler
466a400b94 avformat/flvdec: add support for demuxing multi-track FLV
Based on enhanced-rtmp v2 spec published by Veovera:
https://veovera.github.io/enhanced-rtmp/docs/enhanced/enhanced-rtmp-v2

Signed-off-by: Dennis Sädtler <dennis@obsproject.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2024-12-27 20:24:09 +01:00
Dennis Sädtler
d8d0175d3a avformat/flvenc: implement support for multi-track video
Based on enhanced-rtmp v2 spec published by Veovera:
https://veovera.github.io/enhanced-rtmp/docs/enhanced/enhanced-rtmp-v2

This implementation maintains some backwards compatibility by only
writing the track information for track indices > 0. This means that
older FFmpeg versions - and possibly other software - can still read the
first video track properly and skip over unsupported packets.

Signed-off-by: Dennis Sädtler <dennis@obsproject.com>
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2024-12-27 20:22:19 +01:00
James Almer
cedd9151f8 avformat/iamf_writer: ensure the stream groups are not empty
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-27 16:17:51 -03:00
Niklas Haas
59258fb90e swscale/utils: lazily allocate XYZ tables on CONFIG_SMALL
This has the downside of requiring these tables to be recomputed on every
init, but saves ~270 kB of static data.

Signed-off-by: Niklas Haas <git@haasn.dev>
2024-12-26 20:31:36 +01:00
Niklas Haas
60bfafcd8a swscale/utils: add return code to fill_xyztables()
Needed for lazy allocation of XYZ tables.

Signed-off-by: Niklas Haas <git@haasn.dev>
2024-12-26 20:31:36 +01:00
Niklas Haas
af6d52eec6 swscale: use 16-bit intermediate precision for RGB/XYZ conversion
The current logic uses 12-bit linear light math, which is woefully insufficient
and leads to nasty postarization artifacts. This patch simply switches the
internal logic to 16-bit precision.

This raises the memory requirement of these tables from 32 kB to 272 kB.

All relevant FATE tests updated for improved accuracy.

Fixes: #4829
Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: Sovereign Tech Fund
2024-12-26 20:31:36 +01:00
James Almer
3e6d89cd97 avcodec/cbs_h2645: revert accidental change
This was erroneously included in 7e778586e7.

Reported-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-26 15:46:44 -03:00
Niklas Haas
8cf2d97280 swscale/unscaled: add pal8 -> gbr(a)p special converter
Fixes: #9520
Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: Sovereign Tech Fund
2024-12-26 19:29:18 +01:00
James Almer
7e778586e7 avcodec/libx265: ignore user set alpha x265-param
It makes no difference when the input has an alpha plane, and may end up in
crashes or undefined behavior if it doesn't.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-26 13:41:28 -03:00
James Almer
6ffbc22b53 doc/ffmpeg.texi: replace use of uncommon unicode characters
Addresses ticket #11372

Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-26 13:41:28 -03:00
Gyan Doshi
fe04b93afa ffmpeg_sched: return better error code
The existing code of 'No space left on device' leaves end users confused
since the issue isn't of disk space.
2024-12-26 15:45:00 +05:30
Pradeep Kumar Goudagunta
aa20294b31 fftools/ffmpeg_opt: Fix precedence issue in abs_start_seek calculation
This patch corrects a C operator precedence issue in fftools/ffmpeg_opt.c
where the abs_start_seek calculation did not yield the expected result
due to incorrect placement of parentheses.
2024-12-26 15:44:18 +05:30
3778b1f6f1 avformat/dashdec: reformat and lowercase get_Fragment()
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-12-24 16:36:05 -06:00
Eugene Zemtsov
7c9bde1d0d avformat/mov: fix crash when trying to get a fragment time for a non-existing fragment
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Marth64 <marth64@proxyid.net>
2024-12-24 15:36:30 -06:00
8e8260aabf avcodec/cbs_av1: fix variable shadowing in cbs_av1_split_fragment()
header is previously declared as an int argument then
shadowed in the scope of the loop as a AV1RawOBUHeader.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-12-24 15:36:17 -06:00
954d55c2a4
avformat/mov: dereference pointer after null check
Fixes: null pointer dereference
Fixes: 383397479/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4776829338058752

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-24 02:55:52 +01:00
9327093079
avcodec/utils: Fix block align overflow for ADPCM_IMA_WAV
Fixes: signed integer overflow: 529008646 * 8 cannot be represented in type 'int'
Fixes: 383379145/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6674045107503104

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-24 02:55:52 +01:00
361d24e6d9
avformat/matroskadec: Check pre_ns for overflow
Fixes: signed integer overflow: -3483479120376300096 - 7442323944145700864 cannot be represented in type 'long'
Fixes: 383187489/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-4561470580391936

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-24 02:55:51 +01:00
8f4eb0fe03
tools/target_dec_fuzzer: Adjust threshold for EACMV
Fixes: Timeout
Fixes: 382988735/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EACMV_fuzzer-5278721465974784

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-24 02:55:51 +01:00
fe1aeb499b
tools/target_dec_fuzzer: Adjust threshold for SGA
Fixes: Timeout
Fixes: 382804863/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SGA_fuzzer-5652795669151744

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-24 02:55:51 +01:00
e7230bc503
tools/target_dec_fuzzer: Adjust threshold for MVC1
Fixes: Timeout
Fixes: 378231213/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MVC1_fuzzer-6640960500465664

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-24 02:55:50 +01:00
e8c94e31da
avformat/mov: free stream_info when the surrounding array is freed
Fixes: memleak
Fixes: 378408474/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5699368121860096

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-24 02:55:50 +01:00
61ff3047c5
avcodec/rv60dec: Check NEXT/LAST availability
Fixes: NULL ptr use
Fixes: 378634700/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5008344043028480

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-24 02:55:50 +01:00
2336fc44ac
avcodec/rv60dec: Use get_bits_long()
Fixes: 378634700/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5008344043028480
Fixes: assertion failure

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-24 02:55:18 +01:00
34c06f5284
avcodec/escape130: move get_buffer down
This way the (slow) allocation of an image is done after various additional checks

Fixes: Timeout
Fixes: 379418967/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ESCAPE130_fuzzer-6507383574036480

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-24 02:46:47 +01:00
89efc6c97c
tools/target_dec_fuzzer: Adjust Threshold for indeo5
Fixes: 379768251/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INDEO5_fuzzer-5981329084186624
Fixes: Timeout

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-24 02:46:47 +01:00
6ba33b50f5
avutil/timecode: Avoid fps overflow in av_timecode_get_smpte_from_framenum()
Fix from c94875471e

Found-by: Youngjae Choi <youngjaechoi@korea.ac.kr>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-12-24 02:45:13 +01:00
James Almer
f1ddba24a0 avutil/frame: add missing size dependent prop to LCEVC payload side data
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-23 17:39:57 -03:00
Niklas Haas
d23f443dfc avfilter/vf_lut*: strip color volume metadata
These filters, in general, will apply some arbitrary color volume
transformation. Strip corresponding metadata to be conservative/safe.
2024-12-23 14:23:13 +01:00
Niklas Haas
eecdc25d4b avfilter/vf_colorspace: strip color volume metadata 2024-12-23 14:23:13 +01:00
Niklas Haas
0d468730bc avfilter/vf_libplacebo: update metadata stripping logic
Switches to av_frame_side_data_remove_by_props(), covering a number of
cases that we previously ignored. Additionally, stop stripping metadata
when merely changing colorspace or color range, since these do not
affect the actual color volume of the image data, only the encoding.
2024-12-23 14:23:13 +01:00
Niklas Haas
d1eadc43b9 avfilter/vf_zscale: strip metadata on change
Required for both size changes and color volume changes (as a result of
changing primaries/transfer).
2024-12-23 14:23:13 +01:00
Niklas Haas
f22965b882 avfilter/vf_scale*: strip metadata on size change 2024-12-23 14:23:13 +01:00
Niklas Haas
b88944a8aa avutil/frame: add av_frame_side_data_remove_by_props()
As discussed in the previous commit, we often need a convenient way of
stripping all side data related to a certain aspect of the frame. This helper
accomplishes just that.

I considered also adding a way to match only side data matching *all*
properties, but I think this is sufficiently useless in practise to not warrant
inclusion in the API.
2024-12-23 14:22:56 +01:00
Niklas Haas
3428a8d830 avutil/frame: add AV_SIDE_DATA_PROP_{SIZE,COLOR}_DEPENDENT
Many filters modify certain aspects of frame data, e.g. through resizing
(vf_*scale* family), color volume mapping (vf_lut*, vf_tonemap*), or
possibly others.

When this happens, we should strip all frame side data that will no
longer be correct/relevant after the operation. For example, changing
the image size should invalidate AV_FRAME_DATA_PANSCAN because the crop
window (given in pixels) no longer corresponds to the actual image size.
For another example, tone-mapping filters (e.g. from HDR to SDR) should
strip all of the dynamic HDR related metadata.

Since there are a lot of different side data types that are affected by such
operations, it makes sense to establish this information in a common, easily
accessible way. The existing side data properties enum is a perfect fit for
this.
2024-12-23 13:33:33 +01:00
Niklas Haas
01084f3d16 avutil/frame: add AVSideDataDescriptor for AV_FRAME_DATA_VIDEO_HINT
This entry was seemingly missing.
2024-12-23 13:32:48 +01:00
Niklas Haas
5ca5bbd462 swscale/options: add -sws_dither none alias
While this one was technically supported on account of the generic options
code allowing "none" as a valid alias for 0, not having it listed here meant
it never showed up in e.g. the -h output, and is also inconsistent with other
places in the code that generally add an explicit alias with appropriate
documentation. Reduces user confusion at negligible cost.

Fixes: #9192
Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: Sovereign Tech Fund
2024-12-23 12:47:10 +01:00
Niklas Haas
253b8977c0 swscale: remove primaries/trc change warning
This is now supported when using the new API.
2024-12-23 12:33:43 +01:00
Niklas Haas
6da940e118 swscale/graph: allow dynamically updating HDR metadata
Without triggering a full graph reinit.
2024-12-23 12:33:43 +01:00
Niklas Haas
efff80c8f6 swscale/graph: add color mapping pass
This leverages the previously introduced color management subsystem in order
to adapt between transfer functions and color spaces, as well as for HDR tone
mapping.

Take special care to handle grayscale formats without a colorspace
gracefully.
2024-12-23 12:33:43 +01:00
Niklas Haas
a57fe519b6 swscale/lut3d: add 3DLUT dispatch system
This is a lightweight wrapper around the underlying color management system,
whose job it is merely to manage the 3DLUT state and apply them to the frame
data. This is where we might add platform-specific optimizations in the future.

I also plan on adding support for more pixel formats in the future. In
particular, we could support YUV or XYZ input formats directly using only
negligible additional code in the 3DLUT setup functions. This would eliminate
the major source of slowdown, which is currently the roundtrip to RGBA64.
2024-12-23 12:33:43 +01:00
Niklas Haas
dddf536d3d swscale/cms: add color management subsystem
The underlying color mapping logic was ported as straightforwardly as possible
from libplacebo, although the API and glue code has been very heavily
refactored / rewritten. In particular, the generalization of gamut mapping
methods is replaced by a single ICC intent selection, and constants have been
hard-coded.

To minimize the amount of overall operations, this gamut mapping LUT now embeds
a direct end-to-end transformation to the output color space; something that
libplacebo does in shaders, but which is prohibitively expensive in software.

In order to preserve compatibility with dynamic tone mapping without severely
regressing performance, we add the ability to generate a pair of "split" LUTS,
one for encoding the input and output to the perceptual color space, and a
third to embed the tone mapping operation. Additionally, this intermediate
space could be used for additional subjective effect (e.g. changing
saturation or brightness).

The big downside of the new approach is that generating a static color mapping
LUT is now fairly slow, as the chromaticity lobe peaks have to be recomputed
for every single RGB value, since correlated RGB colors are not necessarily
aligned in ICh space. Generating a split 3DLUT significantly alleviates this
problem because the expensive step is done as part of the IPT input LUT, which
can share the same hue peak calculation at least for all input intensities.
2024-12-23 12:33:43 +01:00
Niklas Haas
2e674780b7 swscale/csputils: add internal colorspace math helpers
Logic is, for the most part, a straight port of similar logic in
liplacebo's colorspace.c, with some general edits and refactors.
2024-12-23 12:33:43 +01:00
Niklas Haas
01ce9d7963 avfilter/vf_scale: strip metadata when changing colorspace
This is no longer relevant after a change in color space.
2024-12-23 12:33:43 +01:00
Niklas Haas
4315cc943a avfilter/vf_scale: make options alignment consistent (cosmetic) 2024-12-23 12:33:43 +01:00
Niklas Haas
b7a2333357 avfilter/vf_scale: add colorspace and transfer property options
In the long run, it would be ideal if we could add these to the avfilter
negotiation as well, but for now, this is a good start.
2024-12-23 12:33:43 +01:00
Niklas Haas
45f0a7ad33 swscale: add ICC intent enum and option
This setting can be used to infuence the type of tone and gamut mapping used
internally when color space conversions are required. As discussed at VDD'24,
the default was set to relative colorimetric clipping, which is approximately
associative, surjective and idempotent. As such, it roundtrips well, although
it is strictly speaking not associative on out-of-gamut colors.
2024-12-23 12:33:43 +01:00
Niklas Haas
7b7c32322d swscale/utils: fix XYZ primaries tagging
Swscale currently handles XYZ by embedding a forced conversion to
BT.709 RGB with a hardcoded matrix. This is not ideal, but to preserve the
status quo and avoid any unexpected changes in behavior, this patch merely
fixes the inferred primaries tag to match the reality.

In the future, I would like to handle XYZ properly, via direct conversion
to the target colorspace (or possibly simply by using a more fitting
RGB intermediate like SMPTE428), but for now just keep the status quo.
2024-12-23 12:33:43 +01:00