Commit Graph

122302 Commits

Author SHA1 Message Date
James Almer
d7ee7ac20f avutil/iamf: remove default value from demixing_matrix_def
It's not required sice the previous commit, and fixes memleaks introduced by
a6e5fa3fbb.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-30 20:15:32 -03:00
James Almer
c6e7243f11 avutil/opt: fix av_opt_is_set_to_default() for array options with no default value
If AVOptionArrayDef.def is NULL, av_opt_is_set_to_default() should return true
when the field in the object is NULL.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-30 20:14:56 -03:00
Benjamin Cheng
2298978b47 hwcontext_vulkan: Remove unnecessary validation filters
With the latest changes, I can no longer get these to show up.
2025-12-30 14:39:19 -05:00
Benjamin Cheng
531e184944 lavc/vulkan_video: Drop sampler
With the limiting of video usages on the image views, we no longer need
a yuv sampler, since no multi-plane image will be created with the
SAMPLED usage bit.
2025-12-30 14:39:08 -05:00
Benjamin Cheng
b8de254e8c lavc/vulkan_video: Restrict usages for image views
These image views are used only internally for video coding, so they do
not need all the usages of the image it's created from.
2025-12-30 14:38:37 -05:00
Benjamin Cheng
24db09a881 lavc/vulkan_video: Restrict usages for image views
These image views are used only internally for video coding, so they do
not need all the usages of the image it's created from.
2025-12-30 14:15:46 -05:00
Benjamin Cheng
e41e21a1ec avutil/hwcontext_vulkan: Limit usages for lone DPBs
Lone DPBs will only be requested when the implementation requires
a separate DPB. These images are never given out, and are never used for
anything other than a DPB. Also most implementations requiring these
won't support any other usages on DPBs, so limiting the usages would fix
some validation errors.
2025-12-30 14:15:43 -05:00
Ramiro Polla
aa80a7880b avcodec/jpegls: rename SOF48 to SOF55
SOF48 (0xf0) was used in a public draft of the standard (FCD 14495).
In the final specification it is called SOF55 (0xf7).
2025-12-30 17:30:45 +00:00
Frank Plowman
72a38c12e5 lavc/vvc: Prevent OOB write to slice_top_left_ctu_x in PPS CBS
Prior to the fix, in the case of a tile containing multiple slices
(pps_num_exp_slices_in_tile != 0) the number of slices was temporarily
allowed to exceed pps_num_slices_in_pic_minus1+1 and therefore
VVC_MAX_SLICES.  The number of slices was later verified, but while the
current slice index was higher than expected it was used to write to a
array of size VVC_MAX_SLICES, leading to an OOB write.

To rectify this, the patch adds some checks at an earlier stage, to
ensure that the slice index i + j at no point exceeds
pps_num_slices_in_pic_minus1.

Fixes #YWH-PGM40646-30
2025-12-30 13:39:40 +00:00
Zhao Zhili
ee2eb6ced8 fftools/ffmpeg_filter: fix access private API of libavcodec
Firstly, mathops.h is a private header of libavcodec and should not be used
in fftools. It may reference libavcodec internal symbols, causing link
error with dynamic library, e.g.,

fftools/ffmpeg_filter.c:2687: undefined reference to `ff_rv_zbb_supported'

Secondly, mid_pred operates on int types, while current use case is
int64_t.
2025-12-30 07:40:15 +00:00
caifan3
82144fea48 libavformat/file: apply pkt_size option to read mode
Previously, the pkt_size option only affected write buffering in the file
protocol. This change extends its effect to read mode as well.

On embedded systems with limited RAM, users can now reduce I/O buffer
memory by setting a smaller pkt_size.

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-12-30 00:49:13 +00:00
Ramiro Polla
7dda7f3b99 avcodec/mjpegdec: speed up find_marker()
Minimize number of reads and simplify conditionals.

Also use memchr(), as suggested by Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-29 21:44:07 +00:00
Ramiro Polla
254124f869 avcodec/mjpegdec: fix some error return codes 2025-12-29 17:22:34 +01:00
James Almer
6223b7fa0b tests/fate/iamf: add tests for Projection mode ambisonic Audio Elements
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:53 -03:00
James Almer
9c5a37388b fftools/ffprobe: print demixing_matrix in Projection mode ambisonic IAMF Audio Element groups
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:40 -03:00
James Almer
129744ac72 avformat/iamf_writer: reindent after the previous change
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:10 -03:00
James Almer
8cd4d4cb0b avformat/iamf_writer: add support for Projection mode ambisonic Audio elements
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:02 -03:00
James Almer
a0fc454871 avformat/iamf_writer: check that stream count is consistent for ambisonic Audio Elements
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer
21ff60d2cf avformat/iamf_writer: fix writting some ambisonics fields in Audio Elements
The fields are defined as 8 bit long unsigned ints. Fortunately, writing most sane values
as leb is equivalent, which is why no tests are affected.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer
e3498c8051 avformat/iamf_parse: set AVIAMFLayer.nb_demixing_matrix
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer
03a981445e avformat/iamf_parse: fix setting denominator in AVIAMFLayer.demixing_matrix
The format of demixing_matrix is Q15 fixed point values.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:00:01 -03:00
James Almer
a6e5fa3fbb avutil/iamf: add an AVOption for AVIAMFLayer.demixing_matrix
Plus a length field, to fulfill the requirements of AV_OPT_TYPE_FLAG_ARRAY options.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 11:59:36 -03:00
tangsha
d28250eada avcodec/adpcm: Fix step_index decoding by skipping padding byte
The bug was caused by incorrect reading of the step_index field: the original
code read a 16-bit value (including a padding byte) instead of the correct
8-bit step_index as defined by the ADPCM format. This led to distorted audio
or incorrect step calculations when decoding specific ADPCM-encoded files.

Fix by:
1. Reading step_index as an 8-bit unsigned byte via bytestream2_get_byteu()
2. Skipping the subsequent 8-bit padding byte with bytestream2_skip()
2025-12-29 14:18:35 +00:00
Michael Niedermayer
ecd2919174 avcodec/mjpegdec: only test the size bound in sequential mjpeg
The original fix was intended only for sequential mjpeg, but it was also used for progressive
which broke. This commit fixes this regression

Fixes: issue21225

The testcase 6381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEGLS_fuzzer-5665032743419904 still exits within 240ms

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-29 13:57:33 +00:00
Martin Storsjö
78bfcf003b libavformat: Fix the docs for av_mime_codec_str and ff_make_codec_str
The doxygen comments were missed as these functions were updated
during review; they don't take separate pointer/length parameters
but use an AVBPrint struct now instead.

Also clarify that ff_make_codec_str doesn't log if the logctx
parameter is NULL.
2025-12-29 12:05:14 +00:00
Michael Niedermayer
9ab2a437a1 .forgejo/CODEOWNERS: maintain tools/target_dec_fuzzer.c
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-28 21:58:02 +00:00
James Almer
fc5f45bd42 avcodec/libdav1d: only consider colorspace when choosing between YUV and GBR
Several files use values for primaries and transfer characteristics other than
BT709 and IEC_61966 respectively, while still being GBR.
Also always set color_range while at it. It's always coded in the bistream.

Fixes part of #21304.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 15:32:57 -03:00
James Almer
a8f1c2366e avcodec/libaomdec: don't overwrite color information from the container if unset in the bitstream
Fixes part of #21304.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 15:31:13 -03:00
James Almer
afeff1c729 avcodec/interplayacm: add a flush callback function
Should prevent potential buffer overflows if passing new packets after seeking.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-28 12:55:59 -03:00
Michael Niedermayer
224b3ff82a avcodec/jpeg2000htdec: Check pLSB
Fixes: negative shift and other undefined shifts
Fixes: 462335934/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-4538493775970304

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-27 21:42:20 +00:00
nikitalita
0629780cf6 avfilter/vf_libplacebo: replace preproc directive in function-like macros
MSVC build was failing due to preprocessor directives being used within function-like macro argument lists, which is undefined behavior according to the C11 spec. Fixed by replacing the directive blocks with macro definitions outside of the macro invocations.
2025-12-27 18:13:13 +00:00
James Almer
f8e6f8f0a2 avformat/iamf_parse: check layer channel count and stream count for consistency
A layer could define a loudspeaker_layout that corresponds to a certain channel layout,
but then report an amount of substream_count and coupled_substream_count that might not
match the expected channel count.

Fixes: Invalid write of size 4
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6687125346254848

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-27 15:16:49 +00:00
Frank Plowman
90f1f797aa lavc/vvc: Error on inter slice with no reference pics
The semantics of sh_num_ref_idx_active_minus1[ i ] state that

When the current slice is a P slice, the value of NumRefIdxActive[ 0 ] shall be greater than 0.
When the current slice is a B slice, both NumRefIdxActive[ 0 ] and NumRefIdxActive[ 1 ] shall be greater than 0.

Fixes: use of uninitialized memory
Fixes: 449549597/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-5600497089445888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reported-by: Michael Niedermayer michael@niedermayer.cc
2025-12-27 15:14:16 +00:00
Ramiro Polla
0dfaed77a6 swscale/tests/sws_ops: add optional -src and -dst parameters 2025-12-26 13:14:28 +00:00
Niklas Haas
abb1524138 Revert "swscale/ops: clarify SwsOpList.src/dst semantics"
This reverts commit c94e8afe5d.

These are now actually purely informational.
2025-12-24 16:37:22 +00:00
Niklas Haas
c0f49db53d swscale/ops: remove broken value range assumption hack
This information is now pre-filled automatically for SWS_OP_READ when
relevant.

yuv444p10msbbe -> rgb24:
   [u16 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) planar >> 0
   [u16 ...X -> +++X] SWS_OP_SWAP_BYTES
   [u16 ...X -> +++X] SWS_OP_RSHIFT       : >> 6
   [u16 ...X -> +++X] SWS_OP_CONVERT      : u16 -> f32
   [f32 ...X -> ...X] SWS_OP_LINEAR       : matrix3+off3 [...]
   [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
   [f32 ...X -> ...X] SWS_OP_MAX          : {0 0 0 0} <= x
+  [f32 ...X -> ...X] SWS_OP_MIN          : x <= {255 255 255 _}
   [f32 ...X -> +++X] SWS_OP_CONVERT      : f32 -> u8
   [ u8 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) packed >> 0
    (X = unused, + = exact, 0 = zero)

(This clamp is needed and was incorrectly optimized away before, because the
`SWS_OP_RSHIFT` incorrectly distorted the value range assertion)
2025-12-24 16:37:22 +00:00
Niklas Haas
ede8318e9f swscale/ops: explicitly reset value range after SWS_OP_UNPACK
The current logic implicitly pulled the new value range out of SwsComps using
ff_sws_apply_op_q(), but this was quite ill-formed and not very robust. In
particular, it only worked because of the implicit assumption that the value
range was always set to 0b1111...111.

This actually poses a serious problem for 32-bit packed formats, whose
value range actually does not fit into AVRational. In the past, it only
worked because the value would implicitly overflow to -1, which SWS_OP_UNPACK
would then correctly extract the bits out from again.

In general, it's cleaner (and sufficient) to just explicitly reset the value
range on SWS_OP_UNPACK again.
2025-12-24 16:37:22 +00:00
Niklas Haas
a0032fb40f swscale/ops: use switch/case for updating SwsComps ranges
A bit more readable and makes it clear what the special cases are.
2025-12-24 16:37:22 +00:00
Niklas Haas
5f1be98f62 swscale/ops: add SWS_COMP_SWAPPED
This flag keeps track of whether a pixel is currently byte-swapped or
not. Not needed by current backends, but informative and useful for
catching potential endianness errors.

Updates a lot of FATE tests with a cosmetic diff like this:

 rgb24 -> gray16be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> .++X] SWS_OP_LINEAR       : dot3 [...]
   [f32 .XXX -> +++X] SWS_OP_CONVERT      : f32 -> u16
-  [u16 .XXX -> +++X] SWS_OP_SWAP_BYTES
-  [u16 .XXX -> +++X] SWS_OP_WRITE        : 1 elem(s) planar >> 0
-    (X = unused, + = exact, 0 = zero)
+  [u16 .XXX -> zzzX] SWS_OP_SWAP_BYTES
+  [u16 .XXX -> zzzX] SWS_OP_WRITE        : 1 elem(s) planar >> 0
+    (X = unused, z = byteswapped, + = exact, 0 = zero)

(The choice of `z` to represent swapped integers is arbitrary, but I think
it's visually evocative and distinct from the other symbols)
2025-12-24 16:37:22 +00:00
Niklas Haas
5a6602e959 swscale/format: add pixel range metadata to SWS_OP_READ 2025-12-24 16:37:22 +00:00
Niklas Haas
9586b81373 swscale/ops: don't strip SwsComps from SWS_OP_READ
The current behavior of assuming the value range implicitly on SWS_OP_READ
has a number of serious drawbacks and shortcomings:

- It ignored the effects of SWS_OP_RSHIFT, such as for p010 and related
  MSB-aligned formats. (This is actually a bug)

- It adds a needless dependency on the "purely informative" src/dst fields
  inside SwsOpList.

- It is difficult to reason about when acted upon by SWS_OP_SWAP_BYTES, and
  the existing hack of simply ignoring SWAP_BYTES on the value range is not
  a very good solution here.

Instead, we need a more principled way for the op list generating code
to communicate extra metadata about the operations read to the optimizer.

I think the simplest way of doing this is to allow the SwsComps field attached
to SWS_OP_READ to carry additional, user-provided information about the values
read.

This requires changing ff_sws_op_list_update_comps() slightly to not completely
overwrite SwsComps on SWS_OP_READ, but instead merge the implicit information
with the explictly provided one.
2025-12-24 16:37:22 +00:00
Niklas Haas
61eca588dc swscale/ops: move ff_sws_op_list_update_comps() to ops.c
I think this is ultimately a better home, since the semantics of this are
not really tied to optimization itself; and because I want to make it an
explicitly suported part of the user-facing API (rather than just an
internal-use field).

The secondary motivating reason here is that I intend to use internal
helpers of `ops.c` inside the next commit. (Though this is a weak reason
on its own, and not sufficient to justify this move by itself.)
2025-12-24 16:37:22 +00:00
James Almer
fe1dae1e18 avcodec/lcevcdec: free pictures on error
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:23:37 -03:00
James Almer
4f86ebfe94 avcodec/lcevcdec: fix input dimensions for the base picture
Fixes crashes with some samples.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:23:37 -03:00
James Almer
b392d75cf7 avcodec/lcevcdec: avoid copying the input frame
Based on the lcevc filter implementation.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:23:37 -03:00
James Almer
3e91d82292 avcodec/cbs_apv: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
James Almer
64be23153e fftools/ffmpeg_sched: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
James Almer
2678482c10 fftools/ffmpeg_enc: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
Michael Niedermayer
9e974b2c45 avformat/hls: fix double space
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 14:14:45 +01:00
Michael Niedermayer
548b28d5b1 avformat/hls: Fix arguments of handle_rendition_args()
Fixes: call to function handle_rendition_args through pointer to incorrect function type 'void (*)(void *, const char *, int, char **, int *)'
Fixes: 464965411/clusterfuzz-testcase-minimized-ffmpeg_dem_HLS_fuzzer-4790164406992896

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-24 12:04:07 +00:00