Compare commits

..

2649 Commits

Author SHA1 Message Date
Michael Niedermayer c1263a3dd9 Bump versions for master after release/8.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 02:31:23 +01:00
Michael Niedermayer 67c886222f Bump versions for release/8.1
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 02:29:20 +01:00
Michael Niedermayer 5e933b463b doc/APIchanges: Fill in missing values
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 02:29:20 +01:00
Michael Niedermayer 82c55b7ed7 Changelog: Add Version 8.1 marker
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-08 01:42:57 +01:00
James Almer ebf70aa854 avformat/demux: update Stream Groups in avformat_find_stream_info() from parsed values
Dimensions are not available at the container level for LCEVC in mpegts, so derive them
from the parsed values taken from the enhancement stream.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:22:42 -03:00
James Almer b9cb948ec1 avformat/mpegts: add support for LCEVC streams
As defined in ITU-T H.222.0 v9, LCEVC streams use the "Byte stream format"
defined in Annex B of ISO/IEC 23094-2:2021.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:22:42 -03:00
James Almer 0cd4bb2f96 avcodec: add an LCEVC parser
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:22:40 -03:00
James Almer 58052b484e avcodec/codec_desc: make LCEVC a video media type
Every container signals it as such, and the data media stream type is too
undefined and unsupported across the codebase that even if no standalone
decoder can be present for it, it's preferable to it.

This is technically an API break, but LCEVC support has been minimal until
now so it should be safe.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:22:14 -03:00
James Almer c6057f4d96 fftools/ffmpeg_mux_init: don't autoselect video codecs known to lack decoders
They should not be given priority even in a stream copy scenario.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:21:44 -03:00
James Almer 8add479cd3 avcodec/parser: set avctx->pix_fmt for codecs with the enhancement prop set
There will be no decoder for those, so the parser's derived value may be used.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:21:44 -03:00
James Almer c23d56b173 avcodec/codec_desc: add a codec prop to signal enhancement layers
Some video codecs are not meant to output frames on their own but to be applied
on top of frames generated by other codecs, as is the case of LCEVC, Dolby Vision,
etc. Add a codec prop to signal this kind of codec, so that library users may know
to not expect a standalone decoder for them to be present.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:21:38 -03:00
Andreas Rheinhardt 2f9d3ce5a2 avcodec/h261dec: Don't pretend decoding a skipped macroblock can fail
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt f37cfb370f avcodec/avcodec: Deprecate intra_dc_precision
It is only used by the MPEG-2 encoder, so replace it
by a private option instead. Use a more elaborate term
for it: intra_dc_precision ("dc" could be anything).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt cdc632efb3 avcodec/mpegvideo_enc: Ignore intra_dc_precision for non-MPEG-2
This option is only allowed to be set for MPEG-2, so ignore it
except for MPEG-2 and move handling of it to mpeg12enc.c.
This is in preparation for deprecating the AVCodecContext option.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 76a005dccf avcodec/rv10enc: Set encode_picture_header in rv10_encode_init()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 8a431cd8ba avcodec/rv10enc: Check dimensions once during init
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 27d95c3cf8 avcodec/mpegvideo_enc: Move dimension-alignment check to rv10enc.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 9051caa12c avcodec/mpegvideo_enc: Inline intra_dc_precision when known
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt ee72731722 tests/fate/vcodec: Test intra_dc_precision
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 20:14:36 +01:00
Andreas Rheinhardt 38c578b909 swscale_x86/swscale_template: Remove unused macros
WRITEBGR24MMX is unused after a05f22eaf3.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-07 18:06:43 +01:00
James Almer 6dd446918a swscale/utils: don't abort early in sws_freeContext() for non legacy API
There are some buffers still allocated even with it.
Fixes memleaks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 15:46:23 +00:00
Lynne 5a6eeed9f0 vulkan_ffv1: warn users on low number of slices
Files with a low amount of slices take a considerably longer amount
of time to decode. Experimentally, 16 seems to be a good safe minimum.
2026-03-07 15:14:25 +01:00
Lynne 8f2dea9ae8 Changelog: add entry for the prores Vulkan encoder 2026-03-07 15:14:21 +01:00
Lynne b8a4d8a18d aacdec_usac_mps212: fix CID 1681700
Fixes Coverity issue #1681700
2026-03-07 11:56:47 +00:00
Lynne c40318d663 aacdec_usac_mps212: Fix CID 1681701
Fixes Coverity issue #1681701
2026-03-07 11:56:47 +00:00
Lynne 46cf8f1873 aacdec_usac_mps212: fix CID 1681703
Fixes Coverity issue #1681703
2026-03-07 11:56:47 +00:00
Lynne 558738a6d0 aacdec_usac_mps212: Fix CID 1681704
Fixes Coverity issue #1681704
2026-03-07 11:56:47 +00:00
Lynne e7e001a804 aacdec_usac_mps212: fix CID 1681705
Fixes Coverity issue #1681705
2026-03-07 11:56:47 +00:00
Devraj Ajmera 4a390fcd20 avformat/rtpenc: validate MPEG-TS RTP payload size
Ensure that the RTP payload size is at least one TS packet
(188 bytes) when packetizing MPEG-TS.

Previously, small payload sizes were silently rounded up,
which could lead to incorrect behavior. Return EINVAL
with a clear error message instead.

Signed-off-by: Devraj Ajmera <devrajajmera077@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 12:17:27 +01:00
Michael Niedermayer c2364e9222 avcodec/aac/aacdec_usac_mps212: Fix invalid array index
Without the specification, limiting the index is the best that can be done.

Fixes: out of array access
Fixes: 487591441/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-6205915698364416

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 11:11:52 +00:00
Michael Niedermayer c4ee599760 avcodec/aac/aacdec_usac_mps212: Fix invalid shift
Fixes: left shift of negative value -2
Fixes: 487591441/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-6205915698364416

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 11:11:52 +00:00
Michael Niedermayer 1e7d7c4f52 fftools/ffmpeg_demux: Check metadata provided filename
Fixes: path traversal with  -dump_attachment:t
Fixes: malicious.mkv

Based on code from libavformat/concatdec.c
This will be factored out possibly into libavutil once there is agreement on the API

Found-by: Shangzhi Xu <mxu490469@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 11:51:39 +01:00
stevxiao 20cf8befd5 doc/filters: add entry for deinterlace_d3d12
Add documentation for the filter "deinterlace_d3d12" to the filters documentation.

This is the follow-up for commit https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22386/commits

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-03-07 04:47:16 +00:00
James Almer a1496ced65 avcodec/av1dec: sync frame header and tile group behavior with CBS
A new Sequence Header or a Temporal Delimiter OBU invalidate any previous frame
if not yet complete (As is the case of missing Tile Groups).
Similarly, a new Frame Header invalidates any onging Tile Group parsing.

Fixes: out of array access
Fixes: av1dec_tile_desync.mp4
Fixes: av1dec_tile_desync_bypass.mp4

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-06 23:18:35 -03:00
James Almer 282cf4425d avcodec/cbs_av1: don't try to write a Redundant Frame Header as a normal one
Section 6.8.1 of the AV1 specification states:

"If obu_type is equal to OBU_REDUNDANT_FRAME_HEADER, it is a requirement of
bitstream conformance that SeenFrameHeader is equal to 1."

Leave the existing behavior for reading scenarios as such a file may still
be readable.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-06 23:18:35 -03:00
James Almer 9f0441a774 swscale/x86/input: don't overread input in RGB24_TO_UV_FN
Fixes a 4 byte overread after 846823b174 removed padding

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-06 23:13:45 -03:00
Ramiro Polla 252ab61726 avutil/frame: fix typos 2026-03-07 00:54:49 +00:00
Michael Niedermayer 6023ad715c avformat/mlvdec: avoid uninitialized read in read_string()
Fixes: read of uninitialized memory
Fixes: 488256339/clusterfuzz-testcase-minimized-ffmpeg_dem_MLV_fuzzer-6347338118660096

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:32:22 +01:00
Michael Niedermayer d5e2e678ab avcodec/magicyuv: fix small median images
Fixes: out of array acces
Fixes: 487838419/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_DEC_fuzzer-4683933221715968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:25:29 +01:00
Michael Niedermayer 1e63151355 swscale/output: Fix integer overflow in alpha in yuv2rgba64_1_c_template()
Fixes: signed integer overflow: -1548257 * 2048 cannot be represented in type 'int'
Fixes: #21592

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:44 +01:00
Michael Niedermayer 946ce12e1c swscale/utils: Check *Inc
Fixes: signed integer overflow: -2147483648 - 65536 cannot be represented in type 'int'
Fixes: #21588

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:44 +01:00
Michael Niedermayer 9adced3278 avfilter/vf_scale: Fix integer overflow in config_props()
Fixes: signed integer overflow: 536870944 * 16 cannot be represented in type 'int'
Fixes: #21587

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:44 +01:00
Michael Niedermayer a59180022a swscale/output: Fixes integer overflow in yuv2planeX_8_c
Fixes: integer overflow (does not replicate, but looks like it should overflow with some craftet parameters)
Fixes: #21584

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:26 +01:00
Michael Niedermayer dc9bf66796 swscale/utils: initialize chroma when luma switched to cascade
When luma init switched to cascade the chroma init was skiped

Fixes: NULL pointer dereference
Fixes: #21583

Found-by: HAORAN FANG
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:09:26 +01:00
Michael Niedermayer 6084f07189 avcodec/utils: fix duration computation based on frame_bytes
Fixes: signed integer overflow: 256 * 8396351 cannot be represented in type 'int'
Fixes: 482692578/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-5865521093607424

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 23:08:03 +01:00
Andreas Rheinhardt 0ddece40c5 avcodec/x86/vvc/alf: Simplify vb_pos comparisons
The value of vb_pos at vb_bottom, vb_above is known
at compile-time, so one can avoid the modifications
to vb_pos and just compare against immediates.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 1960320112 avcodec/x86/vvc/alf: Avoid pointless wrappers for alf_filter
They are completely unnecessary for the 8bit case (which only
handles 8bit) and overtly complicated for the 10 and 12bit cases:
All one needs to do is set up the (1<<bpp)-1 vector register
and jmp from (say) the 12bpp function stub inside the 10bpp
function. The way it is done here even allows to share the
prologue between the two functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 467f8d8415 avcodec/x86/vvc/alf: Improve offsetting pointers
It can be combined with an earlier lea for the loop
processing 16 pixels at a time; it is unnecessary
for the tail, because the new values will be overwritten
immediately afterwards anyway.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt cb5f6c055b avcodec/x86/vvc/alf: Don't modify rsp unnecessarily
The vvc_alf_filter functions don't use x86inc's stack managment
feature at all; they merely push and pop some regs themselves.
So don't tell x86inc to provide stack (which in this case
entails aligning the stack).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 38062ebd18 avcodec/x86/vvc/alf: Remove pointless counter, stride
Each luma alf block has 2*12 auxiliary coefficients associated
with it that the alf_filter functions consume; the C version
simply increments the pointers.

The x64 dsp function meanwhile does things differenty:
The vvc_alf_filter functions have three levels of loops.
The middle layer uses two counters, one of which is
just the horizontal offset xd in the current line. It is only
used for addressing these auxiliary coefficients and
yet one needs to perform work translate from it to
the coefficient offset, namely a *3 via lea and a *2 scale.
Furthermore, the base pointers of the coefficients are incremented
in the outer loop; the stride used for this is calculated
in the C wrapper functions. Furthermore, due to GPR pressure xd
is reused as loop counter for the innermost loop; the
xd from the middle loop is pushed to the stack.

Apart from the translation from horizontal offset to coefficient
offset all of the above has been done for chroma, too, although
the coefficient pointers don't get modified for them at all.

This commit changes this to just increment the pointers
after reading the relevant coefficients.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt d2e7fe5b19 avcodec/x86/vvc/alf: Improve deriving ac
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 5da3cab645 avcodec/x86/vvc/alf: Avoid broadcast
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt c9da0193ff avcodec/x86/vvc/alf: Don't use 64bit where unnecessary
Reduces codesize (avoids REX prefixes).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt a489a623fb avcodec/x86/vvc/alf: Use memory sources directly
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt df7885d6c3 avcodec/x86/vvc/alf: Improve writing classify parameters
The permutation that was applied before the write macro
is actually only beneficial when one has 16 entries to write,
so move it into the macro to write 16 entries and optimize
the other macro.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt 1bc91eb552 avcodec/x86/vvc/alf: Avoid checking twice
Also avoids a vpermq in case width is eight.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:42 +01:00
Andreas Rheinhardt e4a9d54e48 avcodec/x86/vvc/alf: Avoid nonvolatile registers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt a2d9cd6dcb avcodec/x86/vvc/alf: Don't calculate twice
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 01a897020e avcodec/x86/vvc/alf: Use xmm registers where sufficient
One always has eight samples when processing the luma remainder,
so xmm registers are sufficient for everything. In fact, this
actually simplifies loading the luma parameters.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 9cb5280c0e avcodec/x86/vvc/alf: Improve storing 8bpp
When width is known to be 8 (i.e. for luma that is not width 16),
the upper lane is unused, so use an xmm-sized packuswb and avoid
the vpermq altogether. For chroma not known to be 16 (i.e. 4,8 or
12) defer extracting from the high lane until it is known to be needed.
Also do so via vextracti128 instead of vpermq (also do this for
bpp>8).
Also use vextracti128 and an xmm-sized packuswb in case of width 16
instead of an ymm-sized packuswb followed by vextracti128.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 56a4c15c23 avcodec/x86/vvc/alf: Avoid checking twice
Also avoid doing unnecessary work in the width==8 case.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 43cc8f05df avcodec/x86/vvc/alf: Don't clip for 8bpp
packuswb does it already.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt a8b3b9c26f avcodec/x86/vvc/alf: Remove unused array
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 94f9ad8061 avcodec/x86/vvc/alf: Use immediate for shift when possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 2159e40ab3 avcodec/x86/vvc/of: Avoid jump
At the end of the height==8 codepath, a jump to RET at the end
of the height==16 codepath is performed. Yet the epilogue
is so cheap on Unix64 that this jump is not worthwhile.
For Win64 meanwhile, one can still avoid jumps, because
for width 16 >8bpp and width 8 8bpp content a jump is performed
to the end of the height==8 position, immediately followed
by a jump to RET. These two jumps can be combined into one.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 2a93d09968 avcodec/x86/vvc/of: Ignore upper lane for width 8
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 9fe9fd95b6 avcodec/x86/vvc/of: Only clip for >8bpp
packuswb does it already for 8bpp.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt 83694749ad avcodec/x86/vvc/of,dsp_init: Avoid unnecessary wrappers
Write them in assembly instead; this exchanges a call+ret
with a jmp and also avoids the stack for (1<<bpp)-1.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt d6ed5d6e3d avcodec/x86/vvc/of: Deduplicate writing, save jump
Both the 8bpp width 16 and >8bpp width 8 cases write
16 contiguous bytes; deduplicate writing them. In fact,
by putting this block of code at the end of the SAVE macro,
one can even save a jmp for the width 16 8bpp case
(without adversely affecting the other cases).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt e7e19fcb1b avcodec/x86/vvc/of: Avoid unnecessary jumps
For 8bpp width 8 content, an unnecessary jump was performed
for every write: First to the end of the SAVE_8BPC macro,
then to the end of the SAVE macro. This commit changes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt dee361a5bf avcodec/x86/vvc/of: Avoid initialization, addition for last block
When processing the last block, we no longer need to preserve
some registers for the next block, allowing simplifications.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt c6205355b4 avcodec/x86/vvc/of: Avoid initialization, addition for first block
Output directly to the desired destination registers instead
of zeroing them, followed by adding the desired values.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Andreas Rheinhardt f177672df2 avcodec/x86/vvc/of: Avoid unnecessary additions
BDOF_PROF_GRAD just adds some values to m12,m13,
so one can avoid two pxor, paddw by deferring
saving these registers prematurely.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 20:02:41 +01:00
Niklas Haas 47f89ea88b swscale: explicitly track if a context is "legacy" or not
The legacy API is defined by sws_init_context(), sws_scale() etc., whereas
the "modern" API is defined by just using sws_scale_frame() without prior
init call.

This int allows us to cleanly distinguish the type of context, paving the
way for some minor refactoring.

As an immediate benefit, we now gain a bunch of explict error checks to
ensure the API is used correctly (i.e. sws_scale() not called before
sws_init_context()).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-06 19:06:33 +01:00
Andreas Rheinhardt 5d3ad4f06e avutil/error: Fix overflow when negating
-INT_MIN is not representable in an int.
Fixes issue #22388.

Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-06 17:28:00 +01:00
Michael Niedermayer 987d13d13c avformat/avformat: Fix warning: assignment discards const qualifier from pointer target type
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 15:59:20 +01:00
Zhao Zhili 6fdbb5a93e avfilter/dnn: fix missing set default value to options
There are two options which use non-zero default value: async and
batch_size of openvino. init_model_ov checks and set batch_size to
one when batch_size is equal to zero, so the only option affected
by missing default value is async. Now async works as expected.
2026-03-06 21:41:11 +08:00
stevxiao ba38fa206e avfilter: update deinterlace_d3d12 filter options name
This commit update deinterlace_d3d12 filter options name.

Currently it follows the options name with "deinterlace_vaapi",
In this commit, it will follow filters such as "yadif" and "w3fdif".

Sample command lines:

1. Software decode with hwupload:

    ffmpeg -init_hw_device d3d12va=d3d12 -i interlaced.ts \
      -vf "format=nv12,hwupload,deinterlace_d3d12=method=default,hwdownload,format=nv12" \
      -c:v libx264 output.mp4

2. Full hardware pipeline:

    ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -i interlaced.ts \
      -vf "deinterlace_d3d12=method=custom:mode=field" \
      -c:v h264_d3d12va output.mp4

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-03-06 01:45:09 -05:00
Michael Niedermayer 20cade1ba3 doc/developer: Favor SI units where applicable
This should make things more consistent over time

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 04:29:52 +00:00
Michael Niedermayer e5c1ca60d8 avcodec/cbs_h266_syntax_template: bound slice width/height by remaining tiles
Fixes: out of array access
Fixes: crash_vvc_heap_oob_read.bin

Found-by: akshay jain <akshaythe@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 04:06:01 +01:00
Michael Niedermayer ea9e85e549 avformat/rtsp: Explicitly check protocol
Fixes: redirect to non rtsp protocol
Fixes: YWH-PGM40646-41

Found-by: BapToutatis

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:37:19 +01:00
Michael Niedermayer 88eb772900 avformat/rtsp: Pass blacklist
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:37:19 +01:00
Michael Niedermayer 2326bc5f69 avformat/rtsp: Use ff_format_check_set_url()
Fixes: redirect to blacklisted protocol
Fixes: YWH-PGM40646-41

Found-by: BapToutatis
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:37:19 +01:00
Michael Niedermayer 394a7ff8ce avformat: Add ff_format_check_set_url()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:37:18 +01:00
Michael Niedermayer e24b9820b4 avfilter/vf_convolution: Handle corner cases with small frames
Fixes: out of array read
Fixes: #YWH-PGM40646-35

Found-by: jpraveenrao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:21:37 +01:00
Michael Niedermayer 8970658472 avfilter/vf_convolution: Use avpriv_mirror
Fixes: out of array read
Fixes: #YWH-PGM40646-35

Found-by: jpraveenrao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 03:21:37 +01:00
Michael Niedermayer d707a4af80 avcodec/pnmdec: Check input size against width*height assuming at least 1bit per pixel
Fixes: Timeout
Fixes: 481427018/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PHM_DEC_fuzzer-6315469467615232
Fixes: 485843949/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PHM_DEC_fuzzer-4753439270961152

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-06 02:33:59 +01:00
Niklas Haas 1c2a300f66 swscale/graph: remove pointless helper
Basically identical to ff_sws_graph_add_pass() after the previous commit.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas d9e594ca96 swscale/graph: have ff_sws_graph_add_pass() return an error code
This allows distinguishing between different types of failure, e.g.
AVERROR(EINVAL) on invalid pass dimensions.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas 4b5122bfb2 swscale/ops_dispatch: move on-stack mutation to ops backends
And move the remainder printing there as well.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas b4bcb00cd3 swscale/ops: add and use ff_sws_op_list_input/output()
Makes various pieces of code that expect to get a SWS_OP_READ more robust,
and also allows us to generalize to introduce more input op types in the
future (in particular, I am looking ahead towards filter ops).

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas cc334a223e swscale/ops_backend: move static table out of function body
Ditto for x86.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas 68f3886460 swscale/ops_dispatch: split off compile/dispatch code from ops.c
This code is self-contained and logically distinct from the ops-related
helpers in ops.c, so it belongs in its own file.

Purely cosmetic; no functional change.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas 4178c4d430 swscale/ops: remove unneeded macro
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Niklas Haas 5384908e56 swscale/ops: move pass compilation logic to helper function
Purely cosmetic.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-05 23:34:56 +00:00
Ramiro Polla 493dfc356f swscale/swscale_internal: fix typos in flag names 2026-03-05 20:38:55 +01:00
Kacper Michajłow 6e322fa582 configure: warn about excessive stack usage
Use a 120 KiB per-function threshold. This roughly matches the default
thread stack size on Musl, which is 128 KiB, leaving some headroom for
caller frames.

This warning draws attention to functions in the codebase that may have
excessively large stack frames. A few functions could benefit from
reducing their frame size.

120 KiB is a reasonable limit. If a function requires more stack, it
likely would benefit from restructuring the code.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-05 16:02:04 +00:00
Alexandru Ardelean 3291afd30f libavutil: hwcontext_amf: remove unreachable statements
Inside the amf_device_derive() function, there seem to be some
unreachable 'break' statements, which can be removed.
And also the final 'return 0' statement will also be unreachable
especially since there is a default case in the switch block.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
2026-03-05 15:42:00 +00:00
IndecisiveTurtle cebe0b577e lavc: implement a Vulkan-based prores encoder
Adds a vulkan implementation of the reference prores kostya encoder. Provides about 3-4x speedup over the CPU code
2026-03-05 14:02:39 +00:00
IndecisiveTurtle 576de002e5 lavc: Split out common components used by vulkan prores encoder 2026-03-05 14:02:39 +00:00
Nicolas Gaullier fe86fd07d3 fftools/ffprobe: do not show refs when not processing frames
refs does not belong to AVCodecParameters, so require a decoder:
it should only be showed when frames are actually processed by ffprobe.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-03-05 13:49:59 +00:00
James Almer 77298c29bc avformat/mov: check return value of mov_read_iref_cdsc()
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-05 09:57:28 -03:00
Martin Storsjö 74cfcd1c69 aarch64/vvc: Fix DCE undefined references with MSVC
This fixes compiling with MSVC for aarch64 after
510999f6b0.

While MSVC does do dead code elimintation for function references
within e.g. "if (0)", it doesn't do that for functions referenced
within a static function, even if that static function itself ends
up not used.

A reproduction example:

    void missing(void);
    void (*func_ptr)(void);

    static void wrapper(void) {
        missing();
    }

    void init(int cpu_flags) {
        if (0) {
            func_ptr = wrapper;
        }
    }

If "wrapper" is entirely unreferenced, then MSVC doesn't produce
any reference to the symbol "missing". Also, if we do
"func_ptr = missing;" then the reference to missing also is
eliminated. But for the case of referencing the function in a
static function, even if the reference to the static function can
be eliminated, then MSVC does keep the reference to the symbol.
2026-03-05 11:57:40 +02:00
James Almer f10c0ae276 avformat/mov: Fix multiple issues related to mov_read_iref_dimg()
forward errors and cleanup in teh failure cases

Fixes: freeing uninitialized pointers
Fixes: 487160965/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6525162874011648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-05 02:43:30 +00:00
Michael Niedermayer cbbe68fb1a avcodec/snowenc: avoid NULL ptr arithmetic
Fixes: applying non-zero offset 16 to null pointer
Fixes: 471614378/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SNOW_fuzzer-5967030642868224

Note: FF_PTR_ADD() does not work as this code has NULL + 123 cases where the pointer is unsused afterwards

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-05 01:23:40 +01:00
Zuoqiang He 1fc7464cf7 libavcodec/huffyuvdsp: Add NEON optimization for the add_int16 function
Benchmark Results (1024 iterations, Raspberry Pi 5 - Cortex-A76):
add_int16_128_c:                                       914.0 ( 1.00x)
add_int16_128_neon:                                    516.9 ( 1.77x)
add_int16_rnd_width_c:                                 914.0 ( 1.00x)
add_int16_rnd_width_neon:                              517.5 ( 1.77x)

Co-Authored-By: Martin Storsjö <martin@martin.st>
2026-03-04 22:31:19 +00:00
Martin Storsjö 8324c8ea89 checkasm: ac3dsp: Increase the float tolerance for sum_square_butterfly_float
Accept up to 15 ULP difference.

This fixes running "checkasm --test=ac3dsp <seed>" for the seeds
2043066705, 24168 and 111972 on ARM, and the seeds 40552 and
209754 on aarch64.

This is the same change as 8e4c904c8e,
increasing the tolerance further.

With this change, checkasm passes for over 500 000 seeds on both
ARM and aarch64.
2026-03-04 22:30:40 +00:00
Georgii Zagoruiko 510999f6b0 aarch64/vvc: sme2 optimisation of alf_filter_luma() 8/10/12 bit
Apple M4:
vvc_alf_filter_luma_8x8_8_c:                           347.3 ( 1.00x)
vvc_alf_filter_luma_8x8_8_neon:                        138.7 ( 2.50x)
vvc_alf_filter_luma_8x8_8_sme2:                        134.5 ( 2.58x)
vvc_alf_filter_luma_8x8_10_c:                          299.8 ( 1.00x)
vvc_alf_filter_luma_8x8_10_neon:                       129.8 ( 2.31x)
vvc_alf_filter_luma_8x8_10_sme2:                       128.6 ( 2.33x)
vvc_alf_filter_luma_8x8_12_c:                          293.0 ( 1.00x)
vvc_alf_filter_luma_8x8_12_neon:                       126.8 ( 2.31x)
vvc_alf_filter_luma_8x8_12_sme2:                       126.3 ( 2.32x)
vvc_alf_filter_luma_16x16_8_c:                        1386.1 ( 1.00x)
vvc_alf_filter_luma_16x16_8_neon:                      560.3 ( 2.47x)
vvc_alf_filter_luma_16x16_8_sme2:                      540.1 ( 2.57x)
vvc_alf_filter_luma_16x16_10_c:                       1200.3 ( 1.00x)
vvc_alf_filter_luma_16x16_10_neon:                     515.6 ( 2.33x)
vvc_alf_filter_luma_16x16_10_sme2:                     531.3 ( 2.26x)
vvc_alf_filter_luma_16x16_12_c:                       1223.8 ( 1.00x)
vvc_alf_filter_luma_16x16_12_neon:                     510.7 ( 2.40x)
vvc_alf_filter_luma_16x16_12_sme2:                     524.9 ( 2.33x)
vvc_alf_filter_luma_32x32_8_c:                        5488.8 ( 1.00x)
vvc_alf_filter_luma_32x32_8_neon:                     2233.4 ( 2.46x)
vvc_alf_filter_luma_32x32_8_sme2:                     1093.6 ( 5.02x)
vvc_alf_filter_luma_32x32_10_c:                       4738.0 ( 1.00x)
vvc_alf_filter_luma_32x32_10_neon:                    2057.5 ( 2.30x)
vvc_alf_filter_luma_32x32_10_sme2:                    1053.6 ( 4.50x)
vvc_alf_filter_luma_32x32_12_c:                       4808.3 ( 1.00x)
vvc_alf_filter_luma_32x32_12_neon:                    1981.2 ( 2.43x)
vvc_alf_filter_luma_32x32_12_sme2:                    1047.7 ( 4.59x)
vvc_alf_filter_luma_64x64_8_c:                       22116.8 ( 1.00x)
vvc_alf_filter_luma_64x64_8_neon:                     8951.0 ( 2.47x)
vvc_alf_filter_luma_64x64_8_sme2:                     4225.2 ( 5.23x)
vvc_alf_filter_luma_64x64_10_c:                      19072.8 ( 1.00x)
vvc_alf_filter_luma_64x64_10_neon:                    8448.1 ( 2.26x)
vvc_alf_filter_luma_64x64_10_sme2:                    4225.8 ( 4.51x)
vvc_alf_filter_luma_64x64_12_c:                      19312.6 ( 1.00x)
vvc_alf_filter_luma_64x64_12_neon:                    8270.9 ( 2.34x)
vvc_alf_filter_luma_64x64_12_sme2:                    4245.4 ( 4.55x)
vvc_alf_filter_luma_128x128_8_c:                     88530.5 ( 1.00x)
vvc_alf_filter_luma_128x128_8_neon:                  35686.3 ( 2.48x)
vvc_alf_filter_luma_128x128_8_sme2:                  16961.2 ( 5.22x)
vvc_alf_filter_luma_128x128_10_c:                    76904.9 ( 1.00x)
vvc_alf_filter_luma_128x128_10_neon:                 32439.5 ( 2.37x)
vvc_alf_filter_luma_128x128_10_sme2:                 16845.6 ( 4.57x)
vvc_alf_filter_luma_128x128_12_c:                    77363.3 ( 1.00x)
vvc_alf_filter_luma_128x128_12_neon:                 32907.5 ( 2.35x)
vvc_alf_filter_luma_128x128_12_sme2:                 17018.1 ( 4.55x)
2026-03-04 23:52:58 +02:00
Georgii Zagoruiko 0edd75e150 aarch64/asm.S: to support SME added macro to save/restore registers d8-d16 2026-03-04 23:52:58 +02:00
Georgii Zagoruiko 905348df9d configure: add detection of SME-I16I64 extension 2026-03-04 23:52:57 +02:00
Georgii Zagoruiko 70691bbb27 configure: add detection of assembler support for SME2 2026-03-04 23:52:36 +02:00
Martin Storsjö a0d23706e8 aarch64: Switch to a more correct Windows flag for detecting I8MM
Newer revisions of WinSDK 10.0.26100.0 have exposed more flags for
IsProcessorFeaturePresent; now there is a separate one for
detecting specifically I8MM and not just SVE-I8MM. Switch to using
this flag instead.
2026-03-04 21:46:18 +00:00
zhanghongyuan e686f53424 fftools/ffplay: improve keyboard shortcut documentation
Clarify the behavior of seek keyboard shortcuts in both the
documentation and command-line help text. Specifically:
- left/right: mention custom interval option support
- page down/up: improve wording for chapter seeking fallback
2026-03-04 21:30:40 +00:00
Tong Wu 5b8a4a0e14 avcodec/d3d12va_encode_h264: simplify deblock default option
The deblocking filter is enabled by default. This behavior is the same
as priv->deblock == 1.

Signed-off-by: Tong Wu <wutong1208@outlook.com>
2026-03-04 14:25:00 +00:00
Georgii Zagoruiko 90431417cb aarch64/vvc: Optimisations of put_luma_hv() functions for 10/12-bit
Apple M2:
put_luma_hv_10_4x4_c:                                   36.3 ( 1.00x)
put_luma_hv_10_8x8_c:                                   82.9 ( 1.00x)
put_luma_hv_10_8x8_neon:                                34.9 ( 2.37x)
put_luma_hv_10_16x16_c:                                239.2 ( 1.00x)
put_luma_hv_10_16x16_neon:                             119.0 ( 2.01x)
put_luma_hv_10_32x32_c:                                900.3 ( 1.00x)
put_luma_hv_10_32x32_neon:                             429.3 ( 2.10x)
put_luma_hv_10_64x64_c:                               2984.7 ( 1.00x)
put_luma_hv_10_64x64_neon:                            1736.2 ( 1.72x)
put_luma_hv_10_128x128_c:                            11194.2 ( 1.00x)
put_luma_hv_10_128x128_neon:                          6357.3 ( 1.76x)
put_luma_hv_12_4x4_c:                                   35.9 ( 1.00x)
put_luma_hv_12_8x8_c:                                   82.6 ( 1.00x)
put_luma_hv_12_8x8_neon:                                34.3 ( 2.41x)
put_luma_hv_12_16x16_c:                                240.2 ( 1.00x)
put_luma_hv_12_16x16_neon:                             115.3 ( 2.08x)
put_luma_hv_12_32x32_c:                                787.7 ( 1.00x)
put_luma_hv_12_32x32_neon:                             414.2 ( 1.90x)
put_luma_hv_12_64x64_c:                               3058.4 ( 1.00x)
put_luma_hv_12_64x64_neon:                            1592.3 ( 1.92x)
put_luma_hv_12_128x128_c:                            11350.8 ( 1.00x)
put_luma_hv_12_128x128_neon:                          6378.3 ( 1.78x)

RPi4:
put_luma_hv_10_4x4_c:                                  637.8 ( 1.00x)
put_luma_hv_10_8x8_c:                                 1044.9 ( 1.00x)
put_luma_hv_10_8x8_neon:                               483.7 ( 2.16x)
put_luma_hv_10_16x16_c:                               3098.0 ( 1.00x)
put_luma_hv_10_16x16_neon:                            1603.1 ( 1.93x)
put_luma_hv_10_32x32_c:                              10054.8 ( 1.00x)
put_luma_hv_10_32x32_neon:                            5843.6 ( 1.72x)
put_luma_hv_10_64x64_c:                              40506.2 ( 1.00x)
put_luma_hv_10_64x64_neon:                           24384.0 ( 1.66x)
put_luma_hv_10_128x128_c:                           130604.2 ( 1.00x)
put_luma_hv_10_128x128_neon:                         99746.6 ( 1.31x)
put_luma_hv_12_4x4_c:                                  638.2 ( 1.00x)
put_luma_hv_12_8x8_c:                                 1074.6 ( 1.00x)
put_luma_hv_12_8x8_neon:                               482.6 ( 2.23x)
put_luma_hv_12_16x16_c:                               3094.0 ( 1.00x)
put_luma_hv_12_16x16_neon:                            1602.5 ( 1.93x)
put_luma_hv_12_32x32_c:                              10034.4 ( 1.00x)
put_luma_hv_12_32x32_neon:                            5843.3 ( 1.72x)
put_luma_hv_12_64x64_c:                              40447.5 ( 1.00x)
put_luma_hv_12_64x64_neon:                           24377.2 ( 1.66x)
put_luma_hv_12_128x128_c:                           130610.4 ( 1.00x)
put_luma_hv_12_128x128_neon:                         99765.8 ( 1.31x)
2026-03-04 12:53:16 +00:00
Niklas Haas cef2fbfd4b swscale/vulkan: fix include order (cosmetic)
Non-local includes before local includes.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-04 12:04:12 +01:00
Niklas Haas 1512e52cb4 swscale: switch to refstruct for hw_priv
This is a bit more forward-facing than a bare allocation, and importantly,
allows the `swscale/utils.c` code to remain agnostic about how to correctly
uninit this struct.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-04 12:04:09 +01:00
Niklas Haas 5b39be1f0a swscale: fix build on --disable-unstable
By excluding the Vulkan makefile entirely when --disable-unstable is passed.
This also correctly avoids compiling e.g. unused GLSL compilers.

Fixes: #22295
See-Also: #22366

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-04 11:53:10 +01:00
zengshuang 9d73d10c50 avformat,avcodec: use PRI format macros for uint32_t in log messages
Use PRIu32/PRIX32 format specifiers instead of %d/%u/%X for uint32_t
variables in av_log calls. On some platforms (e.g. NuttX), uint32_t is
typedef'd as unsigned long rather than unsigned int, which triggers
-Wformat warnings despite both types being 4 bytes. Using PRI macros
is the portable way to match the actual underlying type of uint32_t.

Signed-off-by: zengshuang <zengshuang@xiaomi.com>
2026-03-04 10:40:12 +00:00
David Christle 2c7fe8d8ad swscale/aarch64: add NEON rgb32tobgr24 and rgb24tobgr32 conversions
Add NEON alpha drop/insert using ldp+tbl+stp instead of ld4/st3 and
ld3/st4 structure operations. Both use a 2-register sliding-window
tbl with post-indexed addressing. Instruction scheduling targets
narrow in-order cores (A55) while remaining neutral on wide OoO.

Scalar tails use coalesced loads/stores (ldr+strh+lsr+strb for alpha
drop, ldrh+ldrb+orr+str for alpha insert) to reduce per-pixel
instruction count. Independent instructions placed between loads and
dependent operations to fill load-use latency on in-order cores.

checkasm --bench on Apple M3 Max (decicycles, 1920px):
  rgb32tobgr24_c:    114.4 ( 1.00x)
  rgb32tobgr24_neon:  64.3 ( 1.78x)
  rgb24tobgr32_c:    128.9 ( 1.00x)
  rgb24tobgr32_neon:  80.9 ( 1.59x)

C baseline is clang auto-vectorized; speedup is over compiler NEON.

Signed-off-by: David Christle <dev@christle.is>
2026-03-04 10:30:08 +00:00
David Christle 86a62388cc tests/checkasm: add rgb32tobgr24 and rgb24tobgr32 tests
Add checkasm coverage for rgb32tobgr24 (alpha drop) and rgb24tobgr32
(alpha insert) with test widths exercising all code tiers and
overwrite detection via sentinel bytes.

Signed-off-by: David Christle <dev@christle.is>
2026-03-04 10:30:08 +00:00
David Christle ddd720ae61 swscale/aarch64: add NEON rgb24tobgr24 byte-swap
Add a NEON rgb24tobgr24 using ld3/st3 to swap R and B channels in
packed 24bpp RGB buffers. Handles all input sizes with a 16-pixel
NEON fast path, 8-pixel NEON cleanup, and scalar tail.

checkasm --bench on Apple M3 Max (1920*3 = 5760 bytes):
  rgb24tobgr24_c:    722.0 ( 1.00x)
  rgb24tobgr24_neon:  94.9 ( 7.61x)

Signed-off-by: David Christle <dev@christle.is>
2026-03-04 10:30:08 +00:00
David Christle 78f6cec1b4 tests/checkasm: add rgb24tobgr24 test
Add checkasm coverage for rgb24tobgr24 with test widths exercising
all code tiers (scalar, 8-pixel NEON, 16-pixel NEON).

Signed-off-by: David Christle <dev@christle.is>
2026-03-04 10:30:08 +00:00
Michael Niedermayer 8d3b044f84 avformat/mov: check for duplicate stsd before changing state
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-04 10:17:35 +00:00
Niklas Haas 613925a96e avformat/http: fix Cache-Control header parsing
This was calling atoi() on `p + offset`, which is nonsense (p may point to
the start of the cache-control string, which does not necessarilly coincide
with the location of the max-age value). Based on the code, the intent
was clearly to parse the value *after* the matched substring.
2026-03-04 08:49:53 +00:00
Niklas Haas 7a348f662d avformat/http: close stale connection on wrong seek
If http_seek_internal() gives us an unexpected position, we should
close the connection to avoid leaking reading incorrect bytes on subsequent
reads.
2026-03-04 08:49:53 +00:00
Niklas Haas fcc1a03a0e avformat/http: move retry label (cosmetic)
Move this closer to the corresponding `goto`. From the PoV of the control
flow, these placements are completely identical.
2026-03-04 08:49:53 +00:00
Niklas Haas 142d999fda avformat/http: restore offset on http_open_cnx() failure
The retry path restores this offset, but the failure path does not. This
is especially important for the case of the continuation handler in
http_read_stream(), which may result in subsequent loop iterations (after
repeated failures to read additional data) seeking to the wrong offset.
2026-03-04 08:49:53 +00:00
Niklas Haas f5ddf1c4a8 avformat/http: fix http_connect() offset mismatch error code
This (arbitrarily) returns -1, which happens to be AVERROR(EPERM) on my
machine. Return the more descriptive AVERORR(EIO) instead.

Also add a log message to explain what's going on.
2026-03-04 08:49:53 +00:00
Niklas Haas fb7558dcb0 avformat/http: avoid int overflow
This was meant to accumulate int64_t timestamp values.

Fixes: b8daba42cd
2026-03-04 08:49:53 +00:00
Niklas Haas 0540b42657 swscale/graph: correctly handle single threaded mode
The code was evidently designed at one point in time to support "direct"
execution (not via a thread pool) for num_threads == 1, but this was never
implemented.

As a side benefit, reduces context creation overhead in single threaded
mode (relevant e.g. inside the libswscale self test), due to not needing to
spawn and destroy several thousand worker threads.

Co-authored-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-03 23:13:41 +00:00
Shreesh Adiga 22d484f498 avutil/cpu: add static CPU feature flag for AArch64 CRC32 2026-03-03 21:38:00 +00:00
AnandajithS 04fe98482a libswscale/utils: prevent division by zero for chroma width 8 2026-03-03 17:38:01 +00:00
James Almer 264283bd0a avcodec/av1_parser: also decompose Redundant Frame Headers
Ensures samples where a missing Frame Header is handled by a subsequent
Redundant one are parsed correctly.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-03 13:52:58 -03:00
Andreas Rheinhardt 23a58c6c36 avcodec/h264dec,mpeg_er: Move allocating er buffers to ff_er_init()
(This also stops zero-allocating er_temp_buffer for H.264,
reverting back to the behavior from before commit
0a1dc817237b8546189960efd523257b4f62e1ab.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-03 13:07:46 +01:00
Andreas Rheinhardt 49e57c6c85 avcodec/error_resilience: Initialize error resilience context earlier
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-03 13:07:46 +01:00
James Almer 863c748144 avcodec/bsf/extract_extradata: remove extradata blocks from supported LCEVC NALUs
Given we rewrite these NALUs to remove the encoded data blocks to export as extradata,
we need to do the inverse to remove SC, GC and AI blocks to export as filtered data in
packes.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-03 09:05:45 -03:00
James Almer 3607a10dc3 avcodec/bsf/extract_extradata: simplify a switch statement
And use named defines. Will come in handy the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-03 09:05:45 -03:00
James Almer c893117048 avcodec/bsf/extract_extradata: fix writing filtered LCEVC NALUs when removing extradata
write_lcevc_nalu() is meant only for IDR and NON_IDR NALUs. For everything else, just
copy it unchanged.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-03 09:05:45 -03:00
Jun Zhao 7e7d69632d lavc/hevc: optimize qpel H-pass for width>=16 with byte-domain widening multiply
Rewrite ff_hevc_put_hevc_qpel_h16_8_neon and h32 to use byte-domain
widening multiply (umull/umlal/umlsl via calc_qpelb/calc_qpelb2 macros)
instead of the previous int16-domain approach (uxtl + mul/mla).

The byte-domain approach eliminates the uxtl expansion step and halves
the ext stride (1 byte vs 2 bytes per tap), reducing per-row instruction
count from ~32 to ~23. The functions are also inlined, removing bl/ret
call overhead.

This benefits all HV-path callers (hv/uni_hv/bi_hv/uni_w_hv/bi_w_hv)
at widths 16/32/48/64.

checkasm benchmarks on Apple M4 (5-run average):

  H-pass standalone (NEON):
    h16:  34.0 -> 24.4 cycles (1.39x speedup)
    h32: 132.0 -> 95.0 cycles (1.39x speedup)
    h64: 521.8 -> 373.9 cycles (1.40x speedup)

  HV compound paths geometric mean speedup (NEON, width >= 16):
    qpel_hv:      1.144x (4 functions)
    qpel_bi_hv:   1.158x (4 functions)
    qpel_uni_hv:  1.188x (4 functions)
    qpel_uni_w_hv: 1.158x (3 functions)
    Overall:       1.162x (15 functions)

VVC qpel h16/h32 are separated into self-contained functions retaining
the int16-domain approach, as VVC filters have arbitrary coefficients
incompatible with the hardcoded sign pattern in calc_qpelb.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-03 12:04:14 +00:00
Jun Zhao 23b7005d98 lavc/vvc: remove duplicate 'mov mx, x30' in VVC qpel h16/h32
The VVC qpel h16 and h32 functions had a redundant 'mov mx, x30'
instruction. The first one was placed before vvc_load_filter had
finished using mx (the filter pointer argument), making it a dead
store immediately overwritten by the second 'mov mx, x30'.

Remove the first instance and reorder so that 'sub src, src, #3'
comes before 'mov mx, x30', ensuring the filter pointer in mx is
fully consumed by vvc_load_filter before being overwritten with the
link register.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-03-03 12:04:14 +00:00
Michael Niedermayer e392fb8c9c avformat/mov: use 64bit in CENC subsample bounds checks
Found-by: Quang Luong <oss@engineer.ink>
Found-by: PrymEvol
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 11:49:10 +00:00
Michael Niedermayer 5554d9d555 avutil/eval: Store *prng_state / var only in root AVExpr
AFter this, depth and the root element flag is stored in space
needed for alignment and thus does not increase the AVExpr size

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 03:28:37 +01:00
Michael Niedermayer 1528ccb6a1 avutil/eval: use anonymous union
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 03:28:37 +01:00
Michael Niedermayer ed5040e6f5 avutil/eval: Check depth of AVExpr
we already check the depth of the parser but the AVExpr tree differs

Fixes: stack exhaustion
Fixes: YWH-PGM40646-39

Found-by: jpraveenrao
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 03:28:37 +01:00
Michael Niedermayer 32e4ddeda3 avformat/vividas: Reset n_audio_subpackets on error
Fixes: signed integer overflow: -63 - 2147483594 cannot be represented in type 'int'
Fixes: 486530208/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-4694818252193792

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 03:28:03 +01:00
Michael Niedermayer 87c371e2ff avcodec/vp9: Fix memleak
Fixes: 485523353/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VP9_fuzzer-4582329227214848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 02:13:58 +00:00
Michael Niedermayer a4d40f853a avformat/matroskadec: Check that end_time_ns >= start_time_ns
Fixes: signed integer overflow: -8659510451449931520 - 2205846422852077376 cannot be represented in type 'int64_t' (aka 'long')
Fixes: 486358507/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-4896911086911488

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 02:41:56 +01:00
Michael Niedermayer 228b846407 avcodec/vp3: Sanity check cropping
Fixes: Timeout
Fixes: 476179563/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THEORA_fuzzer-5231013478596608

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 02:41:05 +01:00
Michael Niedermayer 65fd516768 avcodec/adpcm: handle ADPCM_IMA_MAGIX like other similar codecs
Fixes: out of array access
Fixes: 471509958/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_MAGIX_DEC_fuzzer-4847227777646592

We ask for a mono sample because the implementation for mono is incomplete

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 01:10:09 +01:00
Michael Niedermayer 927ae7a0d5 avformat/dhav: Check avio_seek() return
Fixes: infinite loop
Fixes: 472567148/clusterfuzz-testcase-minimized-ffmpeg_dem_DHAV_fuzzer-4520943574908928

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 01:04:37 +01:00
Michael Niedermayer b2f1657087 avformat/segafilm: dont read uninitialized value
scratch[20] doesnt exist in version 0

Fixes: use of uninitialized memory
Fixes: 471664627/clusterfuzz-testcase-minimized-ffmpeg_dem_SEGAFILM_fuzzer-4738726971637760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2026-03-03 00:48:38 +01:00
Michael Niedermayer 8eecba02c7 avcodec/mpegvideo_enc: Restructure ff_h263_encode_gob_header() relation to update_mb_info()
Fixes: out of array access

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 00:47:21 +01:00
Michael Niedermayer c5ccc13fe0 avcodec/exr: check tile_attr.x/ySize
Fixes: division by zero
Fixes: 473579863/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-5105281257504768

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 00:35:35 +01:00
Michael Niedermayer fa2aec73ed avcodec/jpeg2000dec: fix integer overflow in dequantization_int_97()
Fixes: signed integer overflow: 2147483640 + 32 cannot be represented in type 'int'
Fixes: 473569764/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-5377306970619904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-03 00:35:21 +01:00
stevxiao 8429aec5e4 avfilter: add d3d12 deinterlace filter deinterlace_d3d12
This commit introduces a video filter `deinterlace_d3d12` that provides
hardware-accelerated deinterlacing using the D3D12 Video Processor.

The filter supports:
 - bob and custom (motion-adaptive)deinterlace modes
 - frame-rate and field-rate output
 - automatic interlace detection

Sample command lines:

1. Software decode with hwupload:

    ffmpeg -init_hw_device d3d12va=d3d12 -i interlaced.ts \
      -vf "format=nv12,hwupload,deinterlace_d3d12=mode=default,hwdownload,format=nv12" \
      -c:v libx264 output.mp4

2. Full hardware pipeline:

    ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -i interlaced.ts \
      -vf "deinterlace_d3d12=mode=custom:rate=field" \
      -c:v h264_d3d12va output.mp4

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-03-02 16:59:32 -05:00
Andreas Rheinhardt 576d5aaf5d configure: Remove vf_spp->me_cmp dependency
It is not used for anything. In fact, me_cmp is not exported at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 21:53:48 +01:00
Michael Niedermayer 0465a9bb8f avformat/demux: Fix integer overflows in select_from_pts_buffer()
Fixes: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long long'); cast to an unsigned type to negate this value to itself
Fixes: 473334102/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-5109540931829760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 19:04:26 +01:00
Michael Niedermayer 09ab2d18ed avcodec/snowdec: fix mconly
Fixes non repeatable checksums

This also avoids allocating the mc only buffer when its not used

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 19:01:46 +01:00
Michael Niedermayer fb3012269e avcodec/golomb: Fix get_ur_golomb_jpegls() with esclen = 0
If there is no escape case then reaching that branch is an error

Fixes: shift exponent 32 is too large for 32-bit type 'uint32_t' (aka 'unsigned int')
Fixes: 472335543/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DST_fuzzer-6682453243920384

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 18:41:13 +01:00
Michael Niedermayer bdea5aec2d avcodec/jpeg2000dec: Handle M_b = -1
Fixes: runtime error: shift exponent -1 is negative
Fixes: runtime error: shift exponent 32 is too large for 32-bit type 'int'
Fixes: 471846062/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-5835290976780288

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 18:12:40 +01:00
Michael Niedermayer 17cad7ac75 swresample/resample_template: add casts to avoid undefined overflows
resample_linear can produce overflows with craftet input,
The added casts should have no effect on the binary output or the operations they
just change things to a defined regime

Fixes: signed integer overflow: 2069416960 + 78151680 cannot be represented in type 'int'
Fixes: 472047214/clusterfuzz-testcase-minimized-ffmpeg_SWR_fuzzer-6374046976770048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 18:11:58 +01:00
Michael Niedermayer 30a6b78bd4 avcodec/h264_parser: Check pts for overflow
Fixes: signed integer overflow: 9223372036854775807 + 3546086691638400 cannot be represented in type 'int64_t' (aka 'long')
Fixes: 471723681/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-4841032488648704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 17:51:45 +01:00
Michael Niedermayer 0c7e0ed35b avcodec/adpcm: fix integer overflow in N64
Fixes: signed integer overflow: 1077919680 + 1077936128 cannot be represented in type 'int'
Fixes: 471686763/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_N64_DEC_fuzzer-6493712281829376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-02 17:49:23 +01:00
Michael Niedermayer 92f8dd1ea1 tests/fate/mov: add quotes to some map arguments
Fixes failures for the tests/data/mov-mp4-iamf-7_1_4-video-first.mp4 target on some systems.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-02 13:05:18 -03:00
Raja-89 27cdf70086 avfilter/dnn: implement asynchronous execution for LibTorch backend
This patch implements the DNNAsyncExecModule for the LibTorch backend,
enabling non-blocking inference using the common infrastructure instead
of custom threading (th_async_module_submit) to align with the
TensorFlow and OpenVINO backends.

The implementation uses ff_dnn_start_inference_async which provides
unified async logic across all DNN backends, eliminating the need for
backend-specific threading code.

Verified with:
  ffmpeg -f lavfi -i testsrc=duration=5:size=320x240:rate=30 -vf dnn_processing=dnn_backend=torch:model=model.pt -y output.mp4

Signed-off-by: Raja Rathour <imraja729@gmail.com>
2026-03-02 21:35:17 +08:00
David Christle 8f567d5cab tests/checkasm/sw_yuv2rgb: test multi-row conversion with padded strides
Increase test height from 2 to 4 rows and add 32 bytes of source stride
padding. This exercises chroma row sharing across multiple luma row pairs
in YUV420P and the stride increment arithmetic in SIMD implementations,
both of which were previously untested.

Signed-off-by: David Christle <dev@christle.is>
2026-03-02 13:14:07 +00:00
David Christle 7fab0becab swscale/aarch64: add NEON YUV420P/YUV422P/YUVA420P to RGB conversion
Add ARM64 NEON-accelerated unscaled YUV-to-RGB conversion for planar
YUV input formats. This extends the existing NV12/NV21 NEON paths with
YUV420P, YUV422P, and YUVA420P support for all packed RGB output
formats (ARGB, RGBA, ABGR, BGRA, RGB24, BGR24) and planar GBRP.

Register with ff_yuv2rgb_init_aarch64() to also cover the scaled path.

checkasm: all 42 sw_yuv2rgb tests pass.
Speedup vs C at 1920px width (Apple M3 Max, avg of 20 runs):
  yuv420p->rgb24:   4.3x    yuv420p->argb:   3.1x
  yuv422p->rgb24:   5.5x    yuv422p->argb:   4.1x
  yuva420p->argb:   3.5x    yuva420p->rgba:  3.5x

Signed-off-by: David Christle <dev@christle.is>
2026-03-02 13:14:07 +00:00
David Christle 8e591af32b swscale/loongarch: fix LASX YUV2RGB residual for multi-row slices
The res variable (pixel residual count for widths not divisible by 16)
is computed once before the row loop, but DEALYUV2RGBLINERES and
DEALYUV2RGBLINERES32 destructively subtract 8 from it inside the loop
body. When srcSliceH > 2, subsequent row pairs get an incorrect
residual count, producing wrong output for the tail pixels.

Fix by recomputing res from the constant c->opts.dst_w at the top of
each row-pair iteration.

Signed-off-by: David Christle <dev@christle.is>
2026-03-02 13:14:07 +00:00
James Almer 40e60a7db0 tests/fate/mov: add tests to demux specific streams within a IAMF Track
Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-02 09:28:36 -03:00
Andreas Rheinhardt 5315d12139 avcodec/encode: Don't issue emms after encode callback
It is no longer necessary: Most encoders don't use any MMX code
at all any more and the ones that do issue emms on their own.
Instead add an ff_asser1_fpu() to check that it stays that way.

To add some more information, only the halfpel (and fullpel),
qpel and motion estimation APIs use MMX in addition to the
SBC and Snow specific dsp code. halfpel is used by the
mpegvideo encoders, SVQ1 and Snow encoders. The same
encoders in addition to the AC-3 ones and dvvideo use me_cmp.
qpel is only used by the MPEG4 encoder which is part of
mpegvideo. None of these codecs need the generic emms_c (even on
errors):

a) The AC-3 encoders only use a width 16 me_cmp function which
can no longer use MMX since d91b1559e0.
b) dvvideo and SBC emit emms on their own and have no error paths
after the start of the part that can use MMX.
c) SVQ1 calls emms_c() on its own, even on all error paths
that need it.
d) Snow calls emms_c() on its ordinary (success) return path;
it has only one error path in the part of the code that uses MMX,
but even it is fine as ratecontrol_1pass() always calls emms_c()
itself.
e) For mpegvideo, the MMX code is almost confined to the part
of the code reachable from the worker threads (if slice threading
is in use). The exception to this is in skip_check() which always
calls emms_c() itself. Because encode_picture() always calls
emms_c() itself after executing the worker threads and before any
error condition, the floating point state is clean upon exit from
encode_picture().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 12:01:15 +01:00
Andreas Rheinhardt ac46514327 avutil/emms: Add ff_assert[01]_fpu()
These will be used to mark and check parts of the code
where the floating point state is supposed to be not
clobbered. They are an improvement on the (deprecated)
av_assert0_fpu() because of proper file and line number
information; they also reset the floating point state
if the assert is actually triggered.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 11:55:30 +01:00
Andreas Rheinhardt 7763155395 avcodec/snowenc: Add emms_c before allocations
Needed for the allocations in ff_snow_common_init_after_header()
(as well as for calculate_visual_weight() if
spatial_decomposition_count could change).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 11:55:30 +01:00
Andreas Rheinhardt bd481ac6c1 avcodec/mpegvideo_enc: Remove redundant emms_c
It is unnecessary since d91b1559e0
(before that the sad_cmp[0] call in get_intra_count() may
have clobbered the floating point state without cleaning it up
itself).

Also remove some commented out emms_c from places where
the floating point state is guaranteed not to have been clobbered
by us.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-02 11:55:30 +01:00
Andreas Rheinhardt 862338fe31 swscale/rgb2rgb: Remove set-but-unused functions
yuy2toyv12, vu9_to_vu12 and yvu9_to_yuy2 are unused. Removing
them saved 7808B of .text and 102B of .text.unlikely
as well as 24B of .bss here.
Thanks to James Almer for pointing out that yuy2toyv12 is unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 23:45:11 +00:00
Andreas Rheinhardt ecd11abcc9 swscale/rgb2rgb_template: Remove unused uyvytoyv12_c()
Added in 81c0590e6c,
but it seems to have always been unused.
See also 5421dee0e7.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 23:45:11 +00:00
Niklas Haas 5375cfd9c7 swscale/vulkan/ops: fix typo
Checks src.interlaced twice.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-01 21:57:53 +00:00
Niklas Haas b2266d6656 swscale/graph: correctly adjust field height for interlaced frames
This is a pre-existing bug from 67f3627267.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-01 21:57:53 +00:00
Niklas Haas 02e4b45f7f swscale/graph: reintroduce SwsFrame
AVFrame just really doesn't have the semantics we want. However, there a
tangible benefit to having SwsFrame act as a carbon copy of a (subset of)
AVFrame.

This partially reverts commit 67f3627267.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-01 21:57:53 +00:00
Andreas Rheinhardt 561f37c023 avcodec/x86/huffyuvencdsp_init: Remove pointless av_unused
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 12:04:14 +01:00
Andreas Rheinhardt d345e902d2 avcodec/x86/huffyuvencdsp: Remove MMX sub_hfyu_median_pred_int16
Superseded by SSE2 and AVX2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 12:04:14 +01:00
Andreas Rheinhardt 154bcd1054 avcodec/x86/huffyuvencdsp: Add AVX2 sub_hfyu_median_pred_int16
This version can also process 16bpp.

Benchmarks:
sub_hfyu_median_pred_int16_9bpp_c:                   12667.7 ( 1.00x)
sub_hfyu_median_pred_int16_9bpp_mmxext:               1966.5 ( 6.44x)
sub_hfyu_median_pred_int16_9bpp_sse2:                  997.6 (12.70x)
sub_hfyu_median_pred_int16_9bpp_avx2:                  474.8 (26.68x)
sub_hfyu_median_pred_int16_9bpp_aligned_c:           12604.6 ( 1.00x)
sub_hfyu_median_pred_int16_9bpp_aligned_mmxext:       1964.6 ( 6.42x)
sub_hfyu_median_pred_int16_9bpp_aligned_sse2:          981.9 (12.84x)
sub_hfyu_median_pred_int16_9bpp_aligned_avx2:          462.6 (27.25x)
sub_hfyu_median_pred_int16_16bpp_c:                  12592.5 ( 1.00x)
sub_hfyu_median_pred_int16_16bpp_avx2:                 465.6 (27.04x)
sub_hfyu_median_pred_int16_16bpp_aligned_c:          12587.5 ( 1.00x)
sub_hfyu_median_pred_int16_16bpp_aligned_avx2:         462.5 (27.22x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 12:04:14 +01:00
Andreas Rheinhardt e575c2d496 avcodec/x86/huffyuvencdsp: Add SSE2 sub_hfyu_median_pred_int16
Contrary to the MMXEXT version this version does not overread at all
(the MMXEXT version processes the input of 2*w bytes in eight byte
chunks and overreads by a further six bytes, because it loads
the next left and left top values at the end of the loop,
i.e. it reads FFALIGN(2*w,8)+6 bytes instead of 2*w).

Benchmarks:
sub_hfyu_median_pred_int16_9bpp_c:                   12673.6 ( 1.00x)
sub_hfyu_median_pred_int16_9bpp_mmxext:               1947.7 ( 6.51x)
sub_hfyu_median_pred_int16_9bpp_sse2:                  993.9 (12.75x)
sub_hfyu_median_pred_int16_9bpp_aligned_c:           12596.1 ( 1.00x)
sub_hfyu_median_pred_int16_9bpp_aligned_mmxext:       1956.1 ( 6.44x)
sub_hfyu_median_pred_int16_9bpp_aligned_sse2:          989.4 (12.73x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 12:03:55 +01:00
Andreas Rheinhardt 6834762d7b avcodec/huffyuvencdsp: Add width parameter to init
This allows to only use certain functions using wide registers
if there is enough work to do and if one can even read a whole
register wide without overreading.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:58:16 +01:00
Andreas Rheinhardt 2b910f71bb tests/checkasm: Fix huffyuvdsp test criterion
Use CONFIG_HUFFYUVDSP, not CONFIG_HUFFYUV_DECODER
(although they are equivalent).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Andreas Rheinhardt fd44e277c8 tests/checkasm: Add huffyuvencdsp test
Only covers sub_hfyu_median_pred_int16 for now.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Andreas Rheinhardt 2268ba89f0 avcodec/huffyuvencdsp: Pass bpp, not AVPixelFormat for init
Avoids having to get a pixel format descriptor.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Andreas Rheinhardt 5de95f7731 avcodec/huffyuvenc: Mark unreachable code as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Andreas Rheinhardt 1fa48a8b5b avcodec/huffyuvenc: Calculate mask only once
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-03-01 11:56:57 +01:00
Jack Lau 80d5fb2ee9 avformat/whip: use av_dict_set_int() for payload_type and ssrc
Now WHIP can directly pass SSRC as UINT32 instead of
converting it as INT for match wrong rtpenc option
range Since 69568479a9.

And Converting SSRC from UINT32 to INT64 is safe to
pass by av_dict_set_int().

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-03-01 07:02:34 +00:00
Steven Liu 2559f263ea tests/fate/flvenc: add vvc in enhanced flv test case 2026-03-01 04:21:45 +00:00
Steven Liu 93be3e37db avformat/rtmpproto: add vvc1 string into enhanced_codecs list
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2026-03-01 04:21:45 +00:00
Steven Liu 0de45f556c avformat/flvdec: support demux vvc in enhanced flv
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2026-03-01 04:21:45 +00:00
Steven Liu 9ceb932c36 avformat/flvenc: support mux vvc in enhanced flv
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
2026-03-01 04:21:45 +00:00
James Almer e869426a8c avcodec/bsf/extract_extradata: remove dead code
Applied accidentally in 3dba9eb806.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 19:42:06 -03:00
James Almer e245f4d5cf avcodec/bsf: add a LCEVC metadata bitstream filter
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 16:14:40 -03:00
James Almer 0390793dc3 avcodec/cbs: add support for LCEVC bitstreams
As defined in ISO/IEC 23094-2:2021/FDAM 1:2023

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 16:12:33 -03:00
James Almer 2d8c55b057 avcodec/h2645_parse: add support for LCEVC
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 16:12:33 -03:00
James Almer 3dba9eb806 avcodec/bsf/extract_extradata: add support for LCEVC
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-28 16:12:33 -03:00
Kacper Michajłow 4e32fb4c2a fftools/cmdutils: constify string
Fixes:
warning: initializing 'char *' with an expression of type 'const char *'
discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-28 13:42:01 +01:00
Weixie Cui 743df5ded9 avfilter/buffersink: use correct enum for alpha_modes
Signed-off-by: Weixie Cui <cuiweixie@gmail.com>
2026-02-28 12:13:02 +00:00
Andreas Rheinhardt f570fa787a swscale/swscale_internal: Move altivec parts to ppc/
Up until now, several altivec-specific fields are directly
put into SwsInternal #if HAVE_ALTIVEC is true. These fields
are of altivec-specific vector types and therefore
require altivec specific headers to be included.

Unfortunately, said altivec specific headers redefine
bool in a manner that is incompatible with stdbool.
swscale/ops.h uses bool and this led graph.c and ops.c
to disagree about the layout of structures from ops.h,
leading to heap corruption [1], [2] in the sws-unscaled
FATE test.

Fix this by moving the altivec-specific parts out of SwsInternal
and into a structure that extends SwsInternal and is allocated
jointly with it. Said structure is local to yuv2rgb_altivec.c,
because this is the only file accessing said fields. Should
more files need them, an altivec-specific swscale header would
need to be added.

Thanks to jfiusdq <jfiusdq@proton.me> for analyzing the issue.

[1]: https://fate.ffmpeg.org/report.cgi?slot=ppc64-linux-gcc-14.3-asan&time=20260224065643
[2]: https://fate.ffmpeg.org/report.cgi?slot=ppc64-linux-gcc-14.3&time=20260224051615

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-28 09:56:01 +01:00
Andreas Rheinhardt 76cb5691e8 swscale/utils: Move altivec init/free code to yuv2rgb_altivec.c
This is in preparation for removing the util_altivec.h inclusion
in swscale_internal.h, which causes problems (on PPC) because
it redefines bool to something different from stdbool.h.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-28 09:56:01 +01:00
Adrien Guinet da9a6d51f5 avformat/mov: add support for multiple decryption keys
This commit introduces new options to support more than one decryption
keys:
* add a decryption_keys option to MOV, that supports a dictionary of
  KID=>key (in hex), using AV_OPT_TYPE_DICT
* add the corresponding cenc_decryption_keys option to DASH

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-28 04:01:08 +01:00
Neko Asakura 69568479a9 avformat/rtpenc: use unsigned type for ssrc option
The ssrc option used AV_OPT_TYPE_INT with range [INT_MIN, INT_MAX],
but the underlying struct field is uint32_t and RFC 3550 defines SSRC
as a 32-bit identifier covering the full [0, UINT32_MAX] range. This
caused ffmpeg to reject any SSRC value above INT_MAX (~2.1 billion),
which is roughly half of all valid values.

The auto-generated fallback path (av_get_random_seed()) already
returns uint32_t and can produce values above INT_MAX, creating an
inconsistency where the automatic path succeeds but the explicit
-ssrc option rejects the same value.

Change the option to AV_OPT_TYPE_UINT with range [0, UINT32_MAX]
to match the field type and allow the full identifier space.

Fixes ticket #9080.

Signed-off-by: Neko Asakura <neko.asakura@outlook.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-28 01:23:12 +00:00
Andreas Rheinhardt aa483bc422 avcodec/x86/bswapdsp: Avoid aligned vs unaligned codepaths for AVX2
For modern cpus (like those supporting AVX2) loads and stores
using the unaligned versions of instructions are as fast
as aligned ones if the address is aligned, so remove
the aligned AVX2 version (and the alignment check) and just
use the unaligned one.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-27 18:25:43 +01:00
Andreas Rheinhardt 55afe49dd0 avcodec/x86/bswapdsp: combine shifting, avoid check for AVX2
This avoids a check and a shift if >=8 elements are processed;
it adds a check if < 8 elements are processed (which should
be rare).
No change in benchmarks here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-27 18:25:31 +01:00
Andreas Rheinhardt 3e6fa5153e avcodec/x86/bswapdsp: Avoid register copies
No change in benchmarks here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-27 18:25:01 +01:00
Niklas Haas 335ca9c4f4 tests/checkasm: Fix whitespace cosmetics
This line was left misaligned in
b863b81500.
2026-02-27 17:08:46 +00:00
Martin Storsjö 5693b07839 tests/checkasm/sw_ops: Switch to opaques for deciding when to test
This uses the new mechanisms introduced in
cf7e2b6773, as used by the crc test
in 0629ebb5ff.
2026-02-27 17:08:31 +00:00
Ramiro Polla 23bb7c3907 swscale/ops_backend: mark unreachable branch
The pixel format for the process loops have already been checked at
this point to be valid.

The switch added in e4abfb8e51 returns AVERROR(EINVAL) in the default
case without calling ff_sws_op_chain_free(chain), but there's no need
to free it since we mark this branch as unreachable.
2026-02-27 16:44:19 +00:00
Niklas Haas 67f3627267 swscale/graph: nuke SwsImg
This has now become fully redundant with AVFrame, especially since the
existence of SwsPassBuffer. Delete it, simplifying a lot of things and
avoiding reinventing the wheel everywhere.

Also generally reduces overhead, since there is less redundant copying
going on.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 4d7b1c3685 swscale/graph: move frame->field init logic to SwsGraph
And have ff_sws_graph_run() just take a bare AVFrame. This will help with
an upcoming change, aside from being a bit friendlier towards API users
in general.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 846823b174 swscale/graph: don't pointlessly align data buffers
Since d67d81a374, enabling asm explicitly requires aligned malloc,
so this FFALIGN accomplishes nothing.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 5121665463 swscale/graph: use AVFrame to track internal allocation
This commit replaces the AVBufferRef inside SwsPassBuffer by an AVFrame, in
anticipation of the SwsImg removal.

Incidentally, we could also now just use av_frame_get_buffer() here, but
at the cost of breaking the 1:1 relationship between planes and buffers,
which is required for per-plane refcopies.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas e9d1ed3fdc swscale/graph: avoid stack copies of SwsImg
In the process of nuking this abstraction in favor of AVFrame.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas d89765eb28 swscale/graph: simplify output buffer management
This function was originally written to support the use case of e.g.
partially allocated planes that implicitly reference the original input
image, but I've decided that this is stupid and doesn't currently work
anyways.

Plus, I have plans to kill SwsImg, so we need to simplify this mess.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 363779a4bb swscale/ops: don't set src/dst_frame_ptr in op_pass_run()
Already set by setup().

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 62dc591a80 swscale/ops: correctly shift pointers for last row handling
The current logic didn't take into account the possible plane shift. Just
re-compute the correctly shifted pointers using the row position.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas bca806d4f9 swscale/ops: avoid stack copies of SwsImg
Instead, precompute the correctly swizzled data and stride in setup()
and just reference the SwsOpExec fields directly.

To avoid the stack copies in handle_tail() we can introduce a temporary
array to hold just the pointers.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
Niklas Haas 79334c8ca1 swscale/ops: add subsampling shift to SwsOpExec
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 16:18:34 +00:00
James Almer 16ee3d8d99 avformat/mov: fix cases where we discard iamf packets from enabled streams
Given the entire iamf struct is inside a single Track, if the first iamf stream
(which is the one sharing the index and id from the Track) was to be disabled,
then packets from every iamf stream would be discarded.
Fix this by actually going through the entire iamf Sample and discarding those
from the disabled streams only.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-27 11:01:25 -03:00
James Almer 51aef95ba1 avformat/mov: fix setting iamf stream id offsets
If we were to add the highest id of a non iamf stream as offset to iamf stream
ids, and one of the latter was 0, then an id overlap would ocurr.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-27 11:00:58 -03:00
Jack Lau 7505cea0e9 avformat/whip: skip the unmatch nack packet through ssrc
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-27 12:42:05 +00:00
Jack Lau 7e48c0afc9 avformat/whip: add missing ":" in "a=rtcp-fb" when generate sdp
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-27 12:42:05 +00:00
Jack Lau d7820156f9 avformat/whip: add RTX support
See https://datatracker.ietf.org/doc/html/rfc4588

Parse sequence number from NACKs, then create RTX
packet and send it.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>

avformat/whip: set NACK logs as DEBUG

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-27 12:42:05 +00:00
Jack Lau e7757d8f2e avformat/whip: add rtp history store and find method
This patch aims to enable rtp history store for RTX

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-02-27 12:42:05 +00:00
Niklas Haas 2e7078cda6 avformat/http: add -request-size option
It has come to my attention that a way to limit the request range size
would be useful in general, for reasons beyond just speeding up initial
header parsing.

This patch generalizez -initial_request_size to -request_size. I decided
to continue allowing both options to be used simultaneously, so users can
e.g. set -request_size to something large like 10 MiB, but still use a smaller
size for initial header parsing (e.g. 256 KiB).

Fixes: https://github.com/mpv-player/mpv/issues/8655
2026-02-27 09:20:33 +00:00
Niklas Haas 3c03048837 swscale/x86/ops: fix MSVC compiler error
src/libswscale/x86/ops.c(534): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(535): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(536): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(537): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(539): error C2099: initializer is not a constant
src/libswscale/x86/ops.c(540): error C2099: initializer is not a constant

Fixes: ec959e20c5
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-27 09:00:04 +01:00
Jack Lau bc63000741 configure: add pkg-config check for amr related libs
This patch doesn't break previous approach, just add
one possible valid method to find the lib.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-27 01:51:09 +00:00
Nariman-Sayed 477bf79b06 avformat/tls_openssl: use SHA-256 instead of SHA-1 for self-signed cert
SHA-1 is deprecated and considered cryptographically weak.
Replace EVP_sha1() with EVP_sha256() when signing self-generated
certificates to comply with modern security standards.
2026-02-26 22:25:29 +00:00
Ramiro Polla f436d885fc swscale/swscale: fix typos 2026-02-26 18:36:46 +00:00
Niklas Haas ecb707f7e0 swscale/format: add assertion to guard UB
AVRational still can't handle 32-bit values...

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 18:08:49 +00:00
Niklas Haas d4202809da swscale/format: check pixel type in ff_sws_encode/decode_colors()
This would otherwise generate illegal ops and undefined behavior, for
pixel formats without any supported corresponding pixel type.

This didn't cause any issues previously because the following
`ff_sws_encode_pixfmt` would normally fail for such formats, and the UB
was ignored in practice.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 18:08:49 +00:00
Niklas Haas 096e20b4b8 swscale/ops: reorder fields in SwsOpList
For some reason, this avoids triggering a compiler bug in gcc-15 on PowerPC,
that was introduced with commit da47951bd7.
2026-02-26 18:08:49 +00:00
Niklas Haas b7bbcccbfe tests/swscale: disable fate-sws-ops-list on BE platforms
The issue is that every le/be pair ends up with a swapped op list:

 rgb24 -> rgb48be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
+  [u16 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)
 rgb24 -> rgb48le:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) packed >> 0
+  [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
+  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) packed >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

I'm not sure of a good work-around that's not needlessly difficult to
implement, so just disable it on BE platforms for now. The actual underlying
conversions should still be covered by the sws-unscaled test.
2026-02-26 18:08:49 +00:00
Niklas Haas 841ca7a2cb swscale/format: pass SwsFormat by ref instead of by value where possible
The one exception is in adapt_colors(), which mutates these structs on
its own stack anyways.
2026-02-26 18:08:49 +00:00
Niklas Haas 4e36265dea swscale/format: don't mark single byte formats as byte swapped
Fixes a bug where all format lists contained redundant byte swapped
annotations on big-endian platforms, even for single-byte formats.
2026-02-26 18:08:49 +00:00
Michael Niedermayer 86ddc8b438 swscale/output: Fix some integer overflows in yuv2rgba64_full*()
Fixes: integer overflows
Fixes: 471587361/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5015347829997568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-26 17:21:46 +00:00
Lynne 47e87ed722 Changelog: add entry about swscale Vulkan support
The SW in swscale can stand for something else now.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne bd24abfb6c swscale/vulkan: initialize GLSL compilation and shader execution
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne 362414afba swscale: add support for processing hardware frames
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne 1d2e616d5f swscale: add a Vulkan backend for ops.c
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne ad452205b6 swscale/ops: add SwsOpBackend.hw_format
Allows to filter hardware formats.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:22 +01:00
Lynne c911295f09 swscale: forward original frame pointers to ops.c backend
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 00907e1244 swscale/ops: realign after adding slice_align
This is a separate commit since it makes it easier to see the changes.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 9c51aa1824 swscale: add SwsCompiledOp.slice_align
Certain backends may not support (or need) slices, since they
would handle slicing themselves.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 5bc08e259d swscale: add SwsFormat.hw_format and populate it
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne d80d5b4ee7 vulkan_spirv: reduce shader print level from TRACE to DEBUG
The issue was that FFv1 concat'd a lot of separate files, each with
a license header, inflating the total shader size to over 3000 lines.

As all codec shaders were rewritten for compile-time SPIR-V, this became
unnencessarily restrictive.

Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 0c34fcf0a8 vulkan: constify FFVulkanShader arg in ff_vk_exec_bind_shader
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:21 +01:00
Lynne 6c5dc2011b vulkan: reset exec context when uninitializing
Sponsored-by: Sovereign Tech Fund
2026-02-26 14:10:19 +01:00
Niklas Haas 26d6ac56c1 swscale: add sws_test_hw_format()
Allows users to test if a given hardware pixel format is supported by swscale.
This is only a rough heuristic anyways, because the actual support may
depend on the specific *combination* of frame attributes, and ultimately
is better served by the `sws_test_frame` and `sws_frame_setup()` APIs anyways.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 14:09:46 +01:00
Niklas Haas 43f1189af7 swscale/ops_optimizer: eliminate unnecessary dither indices
Generates a lot of incremental diffs due to things like ignored alpha
planes or chroma planes that are not actually modified.

e.g.

 bgr24 -> gbrap10be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> ...X] SWS_OP_SCALE        : * 341/85
-  [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {2 3 0 5}
+  [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {2 3 0 -1}
   [f32 ...X -> ...X] SWS_OP_MIN          : x <= {1023 1023 1023 1023}
   [f32 ...X -> +++X] SWS_OP_CONVERT      : f32 -> u16
   [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
   [u16 ...X -> zzzX] SWS_OP_SWIZZLE      : 1023
   [u16 ...X -> zzz+] SWS_OP_CLEAR        : {_ _ _ 65283}
   [u16 .... -> zzz+] SWS_OP_WRITE        : 4 elem(s) planar >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas ce096aa4ee swscale/x86/ops: add support for optional dither indices
Instead of defining multiple patterns for the dither ops, just define a
single generic function that branches internally. The branch is well-predicted
and ridiculously cheap. At least on my end, within margin of error.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas 48ab318f5c swscale/x86/ops: don't preload dither weights
This doesn't actually gain any performance but makes the code needlessly
complicated. Just directly add the indirect address as needed.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas 1ec8e6e3ce swscale/x86/ops: split off dither0 special case
I want to rewrite the dither kernel a bit, and this special case is a bit
too annoying and gets in the way.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas 8b346363aa swscale/ops_backend: implement support for optional dither indices
If you place the branch inside the loop, gcc at least reverts back to scalar
code, so better to just split up and guard the entire loop.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Niklas Haas ef4a597ad8 swscale/ops: allow excluding components from SWS_OP_DITHER
We often need to dither only a subset of the components. Previously this
was not possible, but we can just use the special value -1 for this.

The main motivating factor is actually the fact that "unnecessary" dither ops
would otherwise frequently prevent plane splitting, since e.g. a copied
alpha plane has to come along for the ride through the whole F32/dither
pipeline.

Additionally, it somewhat simplifies implementations.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 13:09:14 +00:00
Adrien Destugues 5425be53b5 configure: re-enable memalign for Haiku
This had been disabled in 2011:
https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2011-June/038362.html

If there are still problems with it we should rather fix them on Haiku
side.

Signed-off-by: Niklas Haas <git@haasn.dev>
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22233
2026-02-26 10:16:11 +00:00
Niklas Haas d67d81a374 configure: don't support asm without memalign
I tried it, and it broke horribly. We should definitively rule out this.

Unfortunately, it's not as easy as just setting `disable asm` here, because
asm having been enabled will already have affected the build process further
upstream - conversely, we don't know whether or not memalign exists until
fairly late in the build process, and I'm not about to go destroying
the current organization of the file just to work around this.

So an error message it is.
2026-02-26 10:16:11 +00:00
Niklas Haas 5fa2a65c11 swscale/unscaled: fix rgbToRgbWrapper for YUVX
This code calculates the pixel step using c->dstFormatBpp, which is wrong;
should use the pixdesc step instead. (dstFormatBpp is 3 for YUVX, but
the actual pixel step is 4 bytes)

This bug was mostly hidden by the fact that the same bug actually disabled
the fast path for the (common) case of strStride == dstStride. Uncovered while
making changes to the swscale.c allocation code.

Reproduced by modifying libswscale in such a way that the dst buffer stride
happened to be exactly 4/3 larger than the src buffer stride, e.g. by adding
extra padding to each dst buffer line, but reproducible in principle by any
API user.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas a22189101b swscale/unscaled: fix packedCopyWrapper for bitstream formats
The assumption that w < stride is not held for such formats. Rather than
this brittle logic we can just always copy the smaller of the two strides.
This is unlikely to affect anything in practice, since usually AVFrames with
the same size and format have matching linesizes, and so the fast path should
be taken. However, in the unlikely case that they don't agree, this fixes an
assertion failure when copying monow to monow.

Reproduced by modifying libswscale to pick a larger-than-normal dst buffer
alignment (and corresponding linesize), but reproducible in principle by any
API user.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas 5649ac2b4d swscale/ops: avoid UB in handle_tail()
Stupid NULL + 0 rule.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas e4abfb8e51 swscale/ops_backend: avoid UB from incorrect function signature
Annoying C-ism; we can't overload the function type even though they will
always be pointers. We can't even get away with using (void *) in the
function signature, despite casts to void * being technically valid.

Avoid the issue altogether by just moving the process loop into the
type-specific template altogether, and just referring to the correct
compiled process function at runtime. Hopefully, the compiler should be
able to optimize these into a single implementation. GCC, at least, compiles
these down into a single implementation plus three stubs that just jmp
to the correct one.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas ec959e20c5 swscale/x86/ops: add special case for expanding bits to bytes/words
Not super useful but also not expensive to carry.

monob -> gbrp:
 Before: time=84 us, ref=137 us, speedup=1.618x faster
 After:  time=23 us, ref=185 us, speedup=7.773x faster

monob -> gray16le:
 Before: time=75 us, ref=108 us, speedup=1.440x faster
 After:  time=20 us, ref=108 us, speedup=5.192x faster

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas 3a5b1d762f swscale/ops_chain: add ability to match fixed scale factor
This is useful especially for the special case of scaling by common
not-quite-power-of-two constants like 255 or 1023.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas a71c115b77 swscale/x86/ops: allow matching planar rw against 1-element packed fmt
Otherwise, the x86 backend fails to serve e.g. rgb565le.

For -src rgb565le:
 Before: Overall speedup=2.210x faster, min=0.256x max=60.465x
 After:  Overall speedup=4.929x faster, min=0.638x max=181.260x

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Niklas Haas 83af1a2977 swscale/x86/ops: properly mark SWS_OP_SCALE as flexible 2026-02-26 10:15:52 +00:00
Niklas Haas 9adfe25ead swscale/ops_chain: properly mark unreachable branch
By breaking to the `av_unreachable` below. This branch is unreachable because
of the `if (entry->flexible)` branch further above.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-26 10:15:52 +00:00
Lynne 6695528af6 Changelog: add entry for recent Vulkan compute codec optimizations
All the compute codecs were ported to compile-time SPIR-V, thoroughly
debugged, and optimized. They're ready for prime-time.
2026-02-26 10:32:39 +01:00
Jack Lau 8bf74556a1 doc/developer: Add Forgejo as a way to send patches
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-26 04:13:25 +00:00
Zhao Zhili 6b949407cb avfilter: use int instead of enum for AVOption fields
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-26 11:40:16 +08:00
Zhao Zhili fddf881c06 avformat: use int instead of enum for AVOption fields
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-26 11:40:16 +08:00
Zhao Zhili 86d2fae59f avcodec: use int instead of enum for AVOption fields
AVOption with AV_OPT_TYPE_INT assumes the field is int (4 bytes),
but enum size is implementation-defined and may be smaller.
This can cause memory corruption when AVOption writes 4 bytes
to a field that is only 1-2 bytes, potentially overwriting
adjacent struct members.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-26 11:40:09 +08:00
Ling, Edison 00d3417b71 avcodec/d3d12va_encode: Add H264 entropy coder parameter support
Add parameter `coder` for users to select entropy coding in D3D12 H264
encoding.

Named constants `cabac` (1) and `cavlc` (0) are supported.
Default is CABAC (1). If the driver does not support CABAC, a warning is
logged and encoding falls back to CAVLC.

Usage:
  CABAC (default): `-coder cabac`  or  `-coder 1`
  CAVLC:           `-coder cavlc`  or  `-coder 0`

Sample command line:
```
  ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -coder cavlc -y output.mp4
```
2026-02-26 02:19:21 +00:00
Werner Robitza 5ba2525c7a avcodec/libsvtav1: enable 2-pass encoding
This patch enables two-pass encoding for libsvtav1 by implementing
support for AV_CODEC_FLAG_PASS1 and AV_CODEC_FLAG_PASS2.

Previously, users requiring two-pass encoding with SVT-AV1 had to use
the standalone SvtAv1EncApp tool. This patch allows 2-pass encoding
directly through FFmpeg.

Based on patch by Fredrik Lundkvist, with review feedback from James
Almer and Andreas Rheinhardt.
See: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-May/327452.html

Changes:

- Use AV_BASE64_DECODE_SIZE macro for buffer size calculation
- Allocate own buffer for rc_stats_buffer (non-ownership pointer)
- Error handling with buffer cleanup

Signed-off-by: Werner Robitza <werner.robitza@gmail.com>
2026-02-25 16:43:53 +01:00
Andreas Rheinhardt 13e95746ea tests/checkasm/h264chroma: Don't overalign
The input only needs to have natural alignment
(i.e. 1 in the 8bpp case, 2 otherwise), the output
only needs to have 16 (namely in the width 8 >8bpp case).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-25 12:42:22 +01:00
Andreas Rheinhardt e9c2f19e01 tests/checkasm/h264chroma: Add bit depth to error output
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-25 12:42:19 +01:00
Andreas Rheinhardt 34cf7790ef tests/checkasm/h264chroma: Fix initialization, range of values
This commit fixes four related bugs:
1. The >8bpp codepath only initializes half the buffer.
The remaining half used leftover samples from the 8bpp codepath
which initialized the complete buffer.
2. The 8bpp codepath tests only 2 bit inputs (&3). This means
that the second half of the buffer only uses 10 bits (in fact,
only values of the form 000000xx000000xxb) when treated as uint16_t
in the >8bpp test. Due to 1., using more bits in the 8bpp test
would make the >8bpp tests fail (the intermediates would no longer
fit into 16bits).
3. For the >8bpp tests, the first half of the buffer would
only be tested with 8bpp input.
4. The 8bpp codepath initializes the whole buffer, but only
uses half of it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-25 12:41:13 +01:00
Andreas Rheinhardt dc65dcec22 avcodec/vvc/inter: Combine offsets early
For bi-predicted weighted averages, only the sum
of the two offsets is ever used, so add the two early.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-25 12:08:33 +01:00
stevxiao fc7c38f9da avcodec/d3d12va_encode: add detailed ValidationFlags error reporting for video encoders check feature support
Improves error diagnostics for D3D12 video encoders check feature support by adding
detailed ValidationFlags reporting when driver validation fails.

This made it easy for users to identify which specific feature was
unsupported without manually decoding the flags.

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-25 08:47:14 +00:00
Jack Lau 659892cda6 avformat/tls_mbedtls: generate self-signed cert and key when none is provided in listen mode
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-25 03:27:03 +00:00
Jack Lau 55f5cfafeb avformat/tls_mbedtls: set dtls remote addr in listen mode
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-25 03:27:03 +00:00
Jack Lau 35ccd5f3de avformat/tls_mbedtls: add dtls support
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-25 03:27:03 +00:00
Jack Lau dc4c798970 avformat: Use ff_*_muxer directly
These muxers already set hard dependencies in
configure so they cannot be enabled unless the
dependencies are enabled.

So these error handling is unreachable.

Directly Using ff_*_muxer is simpler than calling
av_guess_format()

Refer to 289cb3beff

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-25 02:55:43 +00:00
Ramiro Polla c9977acbc6 swscale/ops: clear range values SWS_OP_{MIN,MAX}
This gives partial range values on conversions with floats, after the
values have been clamped.

 gbrpf32be -> rgb8:
   [f32 XXXX -> zzzX] SWS_OP_READ         : 3 elem(s) planar >> 0
   [f32 ...X -> ...X] SWS_OP_SWAP_BYTES
   [f32 ...X -> ...X] SWS_OP_SWIZZLE      : 2013
   [f32 ...X -> ...X] SWS_OP_LINEAR       : diag3 [[7 0 0 0 0] [0 7 0 0 0] [0 0 3 0 0] [0 0 0 1 0]]
   [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
   [f32 ...X -> ...X] SWS_OP_MAX          : {0 0 0 0} <= x
+    min: {0, 0, 0, _}, max: {nan, nan, nan, _}
   [f32 ...X -> ...X] SWS_OP_MIN          : x <= {7 7 3 _}
+    min: {0, 0, 0, _}, max: {7, 7, 3, _}
   [f32 ...X -> +++X] SWS_OP_CONVERT      : f32 -> u8
+    min: {0, 0, 0, _}, max: {7, 7, 3, _}
   [ u8 ...X -> +XXX] SWS_OP_PACK         : {3 3 2 0}
-    min: {0, _, _, _}, max: {0, _, _, _}
+    min: {0, _, _, _}, max: {255, _, _, _}
   [ u8 .XXX -> +XXX] SWS_OP_WRITE        : 1 elem(s) packed >> 0
-    min: {0, _, _, _}, max: {0, _, _, _}
+    min: {0, _, _, _}, max: {255, _, _, _}
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-02-24 20:25:59 +01:00
Ramiro Polla 9fbb03f428 swscale/tests/sws_ops: don't print unused components in the output
Clean up the output by not printing the flags and range values of
unused components in ff_sws_op_list_print().

 rgb24 -> gray16le:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
-    min: {0, 0, 0, nan}, max: {255, 255, 255, nan}
+    min: {0, 0, 0, _}, max: {255, 255, 255, _}
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
-    min: {0, 0, 0, nan}, max: {255, 255, 255, nan}
-  [f32 ...X -> .++X] SWS_OP_LINEAR       : dot3 [[76.843000 150.859000 29.298000 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0]]
-    min: {0, 0, 0, nan}, max: {65535, 255, 255, nan}
-  [f32 .XXX -> +++X] SWS_OP_CONVERT      : f32 -> u16
-    min: {0, 0, 0, nan}, max: {65535, 255, 255, nan}
-  [u16 .XXX -> +++X] SWS_OP_WRITE        : 1 elem(s) planar >> 0
-    min: {0, 0, 0, nan}, max: {65535, 255, 255, nan}
+    min: {0, 0, 0, _}, max: {255, 255, 255, _}
+  [f32 ...X -> .XXX] SWS_OP_LINEAR       : dot3 [[76.843000 150.859000 29.298000 0 0] [0 1 0 0 0] [0 0 1 0 0] [0 0 0 1 0]]
+    min: {0, _, _, _}, max: {65535, _, _, _}
+  [f32 .XXX -> +XXX] SWS_OP_CONVERT      : f32 -> u16
+    min: {0, _, _, _}, max: {65535, _, _, _}
+  [u16 .XXX -> +XXX] SWS_OP_WRITE        : 1 elem(s) planar >> 0
+    min: {0, _, _, _}, max: {65535, _, _, _}
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-02-24 20:22:12 +01:00
Ramiro Polla c7c8c31302 swscale/tests/sws_ops: print range values in the output
This gives more information about each operation and helps catch issues
earlier on.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
2026-02-24 19:27:51 +01:00
James Almer 145f6e5878 avcodec/cbs_h2645: split into separate files per module
This file is becoming too bloated and hard to read, so split it into separate
files, each having codec specific methods.
This will also speed up compilation when using several concurrent jobs.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-24 10:32:20 -03:00
Michael Niedermayer 989d6ddea0 avformat/wtvdec: Check that language is fully read
Fixes: use-of-uninitialized-value
Fixes: 483856523/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-5221422609006592

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-24 10:22:37 +00:00
Nariman-Sayed 186e388716 avformat/whip: use ffurl_closep instead of ffurl_close for dtls_uc 2026-02-24 02:58:34 +00:00
Michael Niedermayer 7761b8fbac avcodec/imm5: Dont pass EAGAIN on as is
Fixes: Assertion consumed != (-(11)) failed at libavcodec/decode.c:465
Fixes: 471587358/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IMM5_fuzzer-4737412376100864

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:58:11 +01:00
Michael Niedermayer 302f198ba5 avcodec/mjpegdec: Check for multiple exif
Fixes: memleak
Fixes: 477993717/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_DEC_fuzzer-4515108431921152

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:52:37 +01:00
Michael Niedermayer 2ab23ec729 avcodec/interplayacm: Check input for fill_block()
Fixes: Timeout
Fixes: 476763877/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_ACM_fuzzer-4515681843609600

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:50:49 +01:00
Michael Niedermayer 3827b3f1f0 tools/target_dec_fuzzer: Adjust threshold for G2M
Fixes: Timeout
Fixes: 473651750/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_G2M_fuzzer-6214373279596544

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:45:14 +01:00
Michael Niedermayer bebea1e8e3 tools/target_dec_fuzzer: Adjust threshold for XAN_WC3
Fixes: Timeout
Fixes: 472673591/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XAN_WC3_fuzzer-6171459778314240

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:37:09 +01:00
Michael Niedermayer ce05529180 tools/target_dec_fuzzer: Adjust threshold for CPIA
Fixes: Timeout
Fixes: 472564084/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CPIA_fuzzer-5597833073065984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:32:47 +01:00
Michael Niedermayer 9c5e6a319c tools/target_dec_fuzzer: Adjust threshold for QOI
Fixes: Timeout
Fixes: 472177584/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QOI_DEC_fuzzer-5417966922694656

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:32:06 +01:00
Michael Niedermayer 538824fd84 avcodec/hdrdec: Check input size before buffer allocation
Fixes: Timeout
Fixes: 471948155/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HDR_DEC_fuzzer-5679690418552832

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:28:09 +01:00
Michael Niedermayer 55bb6e2646 avcodec/tmv: Move space check before buffer allocation
Fixes: Timeout
Fixes: 471664630/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TMV_fuzzer-5291752530706432

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:26:20 +01:00
Michael Niedermayer f81d6479ec tools/target_dec_fuzzer: Adjust threshold for MPC8
Fixes: Timeout
Fixes: 471587345/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPC8_fuzzer-4824233864921088

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:15:19 +01:00
Michael Niedermayer c8b57f0a1e tools/target_dec_fuzzer: Adjust threshold for BFI
Fixes: timeout
Fixes: 471606773/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BFI_fuzzer-6707440390569984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 23:14:44 +01:00
Michael Niedermayer 4446dfb0e3 avcodec/flashsv: Check for input space before (re)allocating frame
Fixes: Timeout
Fixes: 471605680/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLASHSV2_DEC_fuzzer-6210773459468288
Fixes: 471605920/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FLASHSV_DEC_fuzzer-6230719287590912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 22:59:44 +01:00
Michael Niedermayer 40cafc25cf avcodec/mdec: Check input space vs minimal block size
Fixes: Timeout
Fixes: 481006706/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MDEC_fuzzer-6122832651419648

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 22:54:38 +01:00
Michael Niedermayer 73681f888d avcodec/h264_parser: Check remaining input length in loop in scan_mmco_reset()
Fixes: read of uninitialized memory
Fixes: 476177761/clusterfuzz-testcase-minimized-ffmpeg_dem_H264_fuzzer-6400884824408064

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 22:43:28 +01:00
Niklas Haas b21f1b6482 tests/swscale: don't pass fake object to av_opt_eval_*
This is UB, as the fake object may be used for logging.

Reported-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Fixes: ea791a4ef1
2026-02-23 20:55:27 +00:00
Niklas Haas afdb683a3f swscale: avoid UB on interlaced frames
NULL+0 is UB.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas d918551650 swscale/graph: switch SwsPass.output to refstruct
Allows multiple passes to share a single output buffer reference. We always
allocate an output buffer so that subpasses can share the same output buffer
reference while still allowing that reference to implicitly point to the
final output image.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas cc346b232d swscale/graph: store current pass input instead of global args
The global args to ff_sws_graph_run() really shouldn't matter inside thread
workers. If they ever do, it indicates a leaky abstraction. The only reason
it was needed in the first place was because of the way the input/output
buffers implicitly defaulted to the global args.

However, we can solve this much more elegantly by just calculating it in
ff_sws_graph_run() directly and storing the computed SwsImg inside the
execution state.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas 1e071c8585 swscale/graph: omit memcpy() if src and dst are identical
This allows already referenced planes to be skipped, in the case of e.g.
only some of the output planes being sucessfully referenced. Also avoids
what is technically UB, if the user happens to call ff_sws_graph_run() after
already having ref'd an image.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas b98751b13c swscale/graph: set up palette using current input image
Using the original input image here is completely wrong - the format/palette
could have been set to anything else in the meantime. At best, we would want to
use the original input to add_legacy_sws_pass(), but it's impossible for this
to differ from the per-pass input. The only time legacy subpasses are added
is when using cascaded contexts, but in this case, the only context actually
reading from the palette format would be the first one.

I'm not entirely sure why this code was originally written this way, but
I'm reasonably confident that it's not at all necessary. Tested extensively
on both FATE, the self-test, and real-world files.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas 0b446cdccd swscale/graph: switch to an AVBufferRef per plane
This annoyingly requires recreating some of the logic inside av_img_alloc(),
because there's no good existing current helper accessible from libswscale
that gives per-plane allocations like this.

The new code is based off the calculations inside libavframe/bufferpool.c.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas afa08f4971 swscale/graph: duplicate buffer dimensions in SwsPassBuffer
When multiple passes share a buffer reference, the true buffer dimensions
may be different for each pass, depending on slice alignment. So we can't
rely on the pass dimensions being representative.

Instead, store this information in the SwsPassBuffer itself.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas fe25e54d0f swscale/graph: move output image into separate struct
I want to add more metadata to this and also turn it into a refstruct,
but get the cosmetic diff out of the way first.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas 18060a8820 swscale/graph: simplify ff_sws_graph_run() API
There's little reason not to directly take an SwsImg here; it's already an
internally visible struct.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Niklas Haas e1fd274706 swscale/graph: check output plane pointer instead of pixel format
To see if the output buffers are allocated or not.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-23 19:39:17 +00:00
Marvin Scholz 64fafd63f0 avformat: remove HLS protocol
The use of this protocol was already discouraged and warned about
for years with the recommendation to use the HLS demuxer instead.
2026-02-23 20:20:20 +01:00
Niklas Haas ea791a4ef1 swscale/tests/swscale: parse flags from string
We don't actually have an SwsContext yet at this point, so just use
AV_OPT_SEARCH_FAKE_OBJ. For the actual evaluation, the signature only
requires that we pass a "pointer to a struct that contains an AVClass as
its first member", so passing a double pointer to the class itself is
sufficient.
2026-02-23 19:23:09 +01:00
Marvin Scholz fba9fc0c6b lavc: wmadec: limit variable scopes
Moves the loop variable declarations to the actual loops,
narrowing their scopes.
2026-02-23 15:29:27 +00:00
Marvin Scholz d219be03d6 lavc: wmadec: assert channels count
This should never exceed MAX_CHANNELS, else there will be several
out of bounds writes.
2026-02-23 15:29:27 +00:00
Lynne 7b15039cdb Changelog: add changelog entry for Mps212 2026-02-23 07:57:57 +01:00
Lynne baad75cafa aacdec_usac: add support for parsing Mpsp212 (MPEG surround)
This commit adds the full bitstream parsing for Mps212.
2026-02-23 07:57:57 +01:00
Lynne 86977fdb6b aacdec_tab: add Mps212 tables
To be used in the following commit.
2026-02-23 07:57:57 +01:00
Lynne a4ab4a98c4 aacdec_tab: split up tables init 2026-02-23 07:57:57 +01:00
James Almer 40e0463113 avformat/mov: free item_name on infe entry parsing failure
Fixes regression since 28c330d0f3.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-22 23:16:15 -03:00
Michael Niedermayer 7e10579f49 avcodec/exr: fix AVERROR typo
Fixes: out of array read
Fixes: 485866440/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-4520520419966976

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-23 01:44:49 +00:00
James Almer c3aa28f23d avformat/mov: check for EOF in more loops
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-23 00:43:50 +00:00
James Almer 28c330d0f3 avformat/mov: abort if the queried item doesn't exist instead of overwriting it
The check for item presence was insufficient as it would result in the last
item in the array being overwritten if it existed even if the id didn't match.

Fixes: Assertion ref failed at src/libavformat/mov.c:10649
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5312542695292928
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-23 00:43:50 +00:00
Nariman-Sayed 9bc4109b23 avformat/tls_openssl: fix memory leak in cert_from_pem_string
When PEM_read_bio_X509 fails, BIO was not freed, causing memory leak.
Free BIO before returning NULL to prevent resource leak.
2026-02-22 22:39:43 +00:00
Andreas Rheinhardt 53a9a34e23 avcodec/snow: Reduce sizeof(SnowContext)
Each SubBand currently contains an array of 519 uint8_t[32],
yet most of these are unused: For both the decoder and the
encoder, at most 34 contexts are actually used: The only
variable index is context+2, where context is the result
of av_log2() and therefore in the 0..31 range.

There are also several accesses using compile-time indices,
the highest of which is 30. FATE passes with 31 contexts
and maybe these are enough, but I don't know.

Reducing the number to 34 reduces sizeof(SnowContext)
from 2141664B to 155104B here (on x64).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 22:05:16 +01:00
Andreas Rheinhardt bb92009386 avcodec/snow: Only allocate emu_edge_buffer for encoder
Also allocate it during init and move it to the encoder's context.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 22:05:15 +01:00
Michael Niedermayer c7b5f1537d CONTRIBUTING.md: Add Forgejo
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-22 04:39:22 +00:00
Lynne 13e063ceec vulkan/ffv1: properly initialize the linecache 2026-02-22 03:39:23 +01:00
Michael Niedermayer 99515a3342 avcodec/jpeg2000htdec: Check Lcup and Lref
Fixes: use of uninitialized memory
Fixes: 482494999/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-6467586186608640

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-22 02:31:06 +00:00
Andreas Rheinhardt 6c1c1720cf avcodec/x86/vvc/dsp_init: Mark dsp init function as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:05:12 +01:00
Andreas Rheinhardt af3f8f5bd2 avcodec/x86/vvc/of: Break dependency chain
Don't extract and update one word of one and the same register
at a time; use separate src and dst registers, so that pextrw
and bsr can be done in parallel. Also use movd instead of pinsrw
for the first word.

Old benchmarks:
apply_bdof_8_8x16_c:                                  3275.2 ( 1.00x)
apply_bdof_8_8x16_avx2:                                487.6 ( 6.72x)
apply_bdof_8_16x8_c:                                  3243.1 ( 1.00x)
apply_bdof_8_16x8_avx2:                                284.4 (11.40x)
apply_bdof_8_16x16_c:                                 6501.8 ( 1.00x)
apply_bdof_8_16x16_avx2:                               570.0 (11.41x)
apply_bdof_10_8x16_c:                                 3286.5 ( 1.00x)
apply_bdof_10_8x16_avx2:                               461.7 ( 7.12x)
apply_bdof_10_16x8_c:                                 3274.5 ( 1.00x)
apply_bdof_10_16x8_avx2:                               271.4 (12.06x)
apply_bdof_10_16x16_c:                                6590.0 ( 1.00x)
apply_bdof_10_16x16_avx2:                              543.9 (12.12x)
apply_bdof_12_8x16_c:                                 3307.6 ( 1.00x)
apply_bdof_12_8x16_avx2:                               462.2 ( 7.16x)
apply_bdof_12_16x8_c:                                 3287.4 ( 1.00x)
apply_bdof_12_16x8_avx2:                               271.8 (12.10x)
apply_bdof_12_16x16_c:                                6465.7 ( 1.00x)
apply_bdof_12_16x16_avx2:                              543.8 (11.89x)

New benchmarks:
apply_bdof_8_8x16_c:                                  3255.7 ( 1.00x)
apply_bdof_8_8x16_avx2:                                349.3 ( 9.32x)
apply_bdof_8_16x8_c:                                  3262.5 ( 1.00x)
apply_bdof_8_16x8_avx2:                                214.8 (15.19x)
apply_bdof_8_16x16_c:                                 6471.6 ( 1.00x)
apply_bdof_8_16x16_avx2:                               429.8 (15.06x)
apply_bdof_10_8x16_c:                                 3227.7 ( 1.00x)
apply_bdof_10_8x16_avx2:                               321.6 (10.04x)
apply_bdof_10_16x8_c:                                 3250.2 ( 1.00x)
apply_bdof_10_16x8_avx2:                               201.2 (16.16x)
apply_bdof_10_16x16_c:                                6476.5 ( 1.00x)
apply_bdof_10_16x16_avx2:                              400.9 (16.16x)
apply_bdof_12_8x16_c:                                 3230.7 ( 1.00x)
apply_bdof_12_8x16_avx2:                               321.8 (10.04x)
apply_bdof_12_16x8_c:                                 3210.5 ( 1.00x)
apply_bdof_12_16x8_avx2:                               200.9 (15.98x)
apply_bdof_12_16x16_c:                                6474.5 ( 1.00x)
apply_bdof_12_16x16_avx2:                              400.2 (16.18x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:05:12 +01:00
Andreas Rheinhardt 19dc7b79a4 avcodec/x86/vvc/of: Unify shuffling
One can use the same shuffles for the width 8 and width 16
case if one also changes the permutation in vpermd (that always
follows pshufb for width 16).

This also allows to load it before checking width.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:03:22 +01:00
Andreas Rheinhardt 8e82416434 avcodec/x86/vvc/of: Avoid unused register
Avoids a push+pop.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:02:20 +01:00
Andreas Rheinhardt 81fb70c833 avcodec/x86/vvc/mc,dsp_init: Avoid pointless wrappers for w_avg
They only add overhead (in form of another function call,
sign-extending some parameters to 64bit (although the upper
bits are not used at all) and rederiving the actual number
of bits (from the maximum value (1<<bpp)-1)).

Old benchmarks:
w_avg_8_2x2_c:                                          16.4 ( 1.00x)
w_avg_8_2x2_avx2:                                       12.9 ( 1.27x)
w_avg_8_4x4_c:                                          48.0 ( 1.00x)
w_avg_8_4x4_avx2:                                       14.9 ( 3.23x)
w_avg_8_8x8_c:                                         168.2 ( 1.00x)
w_avg_8_8x8_avx2:                                       22.4 ( 7.49x)
w_avg_8_16x16_c:                                       396.5 ( 1.00x)
w_avg_8_16x16_avx2:                                     47.9 ( 8.28x)
w_avg_8_32x32_c:                                      1466.3 ( 1.00x)
w_avg_8_32x32_avx2:                                    172.8 ( 8.48x)
w_avg_8_64x64_c:                                      5629.3 ( 1.00x)
w_avg_8_64x64_avx2:                                    678.7 ( 8.29x)
w_avg_8_128x128_c:                                   22122.4 ( 1.00x)
w_avg_8_128x128_avx2:                                 2743.5 ( 8.06x)
w_avg_10_2x2_c:                                         18.7 ( 1.00x)
w_avg_10_2x2_avx2:                                      13.1 ( 1.43x)
w_avg_10_4x4_c:                                         50.3 ( 1.00x)
w_avg_10_4x4_avx2:                                      15.9 ( 3.17x)
w_avg_10_8x8_c:                                        109.3 ( 1.00x)
w_avg_10_8x8_avx2:                                      20.6 ( 5.30x)
w_avg_10_16x16_c:                                      395.5 ( 1.00x)
w_avg_10_16x16_avx2:                                    44.8 ( 8.83x)
w_avg_10_32x32_c:                                     1534.2 ( 1.00x)
w_avg_10_32x32_avx2:                                   141.4 (10.85x)
w_avg_10_64x64_c:                                     6003.6 ( 1.00x)
w_avg_10_64x64_avx2:                                   557.4 (10.77x)
w_avg_10_128x128_c:                                  23722.7 ( 1.00x)
w_avg_10_128x128_avx2:                                2205.0 (10.76x)
w_avg_12_2x2_c:                                         18.6 ( 1.00x)
w_avg_12_2x2_avx2:                                      13.1 ( 1.42x)
w_avg_12_4x4_c:                                         52.2 ( 1.00x)
w_avg_12_4x4_avx2:                                      16.1 ( 3.24x)
w_avg_12_8x8_c:                                        109.2 ( 1.00x)
w_avg_12_8x8_avx2:                                      20.6 ( 5.29x)
w_avg_12_16x16_c:                                      396.1 ( 1.00x)
w_avg_12_16x16_avx2:                                    45.0 ( 8.81x)
w_avg_12_32x32_c:                                     1532.6 ( 1.00x)
w_avg_12_32x32_avx2:                                   142.1 (10.79x)
w_avg_12_64x64_c:                                     6002.2 ( 1.00x)
w_avg_12_64x64_avx2:                                   557.3 (10.77x)
w_avg_12_128x128_c:                                  23748.7 ( 1.00x)
w_avg_12_128x128_avx2:                                2206.4 (10.76x)

New benchmarks:
w_avg_8_2x2_c:                                          16.0 ( 1.00x)
w_avg_8_2x2_avx2:                                        9.3 ( 1.71x)
w_avg_8_4x4_c:                                          48.4 ( 1.00x)
w_avg_8_4x4_avx2:                                       12.4 ( 3.91x)
w_avg_8_8x8_c:                                         168.7 ( 1.00x)
w_avg_8_8x8_avx2:                                       21.1 ( 8.00x)
w_avg_8_16x16_c:                                       394.5 ( 1.00x)
w_avg_8_16x16_avx2:                                     46.2 ( 8.54x)
w_avg_8_32x32_c:                                      1456.3 ( 1.00x)
w_avg_8_32x32_avx2:                                    171.8 ( 8.48x)
w_avg_8_64x64_c:                                      5636.2 ( 1.00x)
w_avg_8_64x64_avx2:                                    676.9 ( 8.33x)
w_avg_8_128x128_c:                                   22129.1 ( 1.00x)
w_avg_8_128x128_avx2:                                 2734.3 ( 8.09x)
w_avg_10_2x2_c:                                         18.7 ( 1.00x)
w_avg_10_2x2_avx2:                                      10.3 ( 1.82x)
w_avg_10_4x4_c:                                         50.8 ( 1.00x)
w_avg_10_4x4_avx2:                                      13.4 ( 3.79x)
w_avg_10_8x8_c:                                        109.7 ( 1.00x)
w_avg_10_8x8_avx2:                                      20.4 ( 5.38x)
w_avg_10_16x16_c:                                      395.2 ( 1.00x)
w_avg_10_16x16_avx2:                                    41.7 ( 9.48x)
w_avg_10_32x32_c:                                     1535.6 ( 1.00x)
w_avg_10_32x32_avx2:                                   137.9 (11.13x)
w_avg_10_64x64_c:                                     6002.1 ( 1.00x)
w_avg_10_64x64_avx2:                                   548.5 (10.94x)
w_avg_10_128x128_c:                                  23742.7 ( 1.00x)
w_avg_10_128x128_avx2:                                2179.8 (10.89x)
w_avg_12_2x2_c:                                         18.9 ( 1.00x)
w_avg_12_2x2_avx2:                                      10.3 ( 1.84x)
w_avg_12_4x4_c:                                         52.4 ( 1.00x)
w_avg_12_4x4_avx2:                                      13.4 ( 3.91x)
w_avg_12_8x8_c:                                        109.2 ( 1.00x)
w_avg_12_8x8_avx2:                                      20.3 ( 5.39x)
w_avg_12_16x16_c:                                      396.3 ( 1.00x)
w_avg_12_16x16_avx2:                                    41.7 ( 9.51x)
w_avg_12_32x32_c:                                     1532.6 ( 1.00x)
w_avg_12_32x32_avx2:                                   138.6 (11.06x)
w_avg_12_64x64_c:                                     5996.7 ( 1.00x)
w_avg_12_64x64_avx2:                                   549.6 (10.91x)
w_avg_12_128x128_c:                                  23738.0 ( 1.00x)
w_avg_12_128x128_avx2:                                2177.2 (10.90x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 01:01:27 +01:00
Andreas Rheinhardt ea78402e9c avcodec/x86/vvc/mc,dsp_init: Avoid pointless wrappers for avg
Up until now, there were two averaging assembly functions,
one for eight bit content and one for <=16 bit content;
there are also three C-wrappers around these functions,
for 8, 10 and 12 bpp. These wrappers simply forward the
maximum permissible value (i.e. (1<<bpp)-1) and promote
some integer values to ptrdiff_t.

Yet these wrappers are absolutely useless: The assembly functions
rederive the bpp from the maximum and only the integer part
of the promoted ptrdiff_t values is ever used. Of course,
these wrappers also entail an additional call (not a tail call,
because the additional maximum parameter is passed on the stack).

Remove the wrappers and add per-bpp assembly functions instead.
Given that the only difference between 10 and 12 bits are some
constants in registers, the main part of these functions can be
shared (given that this code uses a jumptable, it can even
be done without adding any additional jump).

Old benchmarks:
avg_8_2x2_c:                                            11.4 ( 1.00x)
avg_8_2x2_avx2:                                          7.9 ( 1.44x)
avg_8_4x4_c:                                            30.7 ( 1.00x)
avg_8_4x4_avx2:                                         10.4 ( 2.95x)
avg_8_8x8_c:                                           134.5 ( 1.00x)
avg_8_8x8_avx2:                                         16.6 ( 8.12x)
avg_8_16x16_c:                                         255.6 ( 1.00x)
avg_8_16x16_avx2:                                       28.2 ( 9.07x)
avg_8_32x32_c:                                         897.7 ( 1.00x)
avg_8_32x32_avx2:                                       83.9 (10.70x)
avg_8_64x64_c:                                        3320.0 ( 1.00x)
avg_8_64x64_avx2:                                      321.1 (10.34x)
avg_8_128x128_c:                                     12981.8 ( 1.00x)
avg_8_128x128_avx2:                                   1480.1 ( 8.77x)
avg_10_2x2_c:                                           12.0 ( 1.00x)
avg_10_2x2_avx2:                                         8.4 ( 1.43x)
avg_10_4x4_c:                                           34.9 ( 1.00x)
avg_10_4x4_avx2:                                         9.8 ( 3.56x)
avg_10_8x8_c:                                           76.8 ( 1.00x)
avg_10_8x8_avx2:                                        15.1 ( 5.08x)
avg_10_16x16_c:                                        256.6 ( 1.00x)
avg_10_16x16_avx2:                                      25.1 (10.20x)
avg_10_32x32_c:                                        932.9 ( 1.00x)
avg_10_32x32_avx2:                                      73.4 (12.72x)
avg_10_64x64_c:                                       3517.9 ( 1.00x)
avg_10_64x64_avx2:                                     414.8 ( 8.48x)
avg_10_128x128_c:                                    13695.3 ( 1.00x)
avg_10_128x128_avx2:                                  1648.1 ( 8.31x)
avg_12_2x2_c:                                           13.1 ( 1.00x)
avg_12_2x2_avx2:                                         8.6 ( 1.53x)
avg_12_4x4_c:                                           35.4 ( 1.00x)
avg_12_4x4_avx2:                                        10.1 ( 3.49x)
avg_12_8x8_c:                                           76.6 ( 1.00x)
avg_12_8x8_avx2:                                        16.7 ( 4.60x)
avg_12_16x16_c:                                        256.6 ( 1.00x)
avg_12_16x16_avx2:                                      25.5 (10.07x)
avg_12_32x32_c:                                        933.2 ( 1.00x)
avg_12_32x32_avx2:                                      75.7 (12.34x)
avg_12_64x64_c:                                       3519.1 ( 1.00x)
avg_12_64x64_avx2:                                     416.8 ( 8.44x)
avg_12_128x128_c:                                    13695.1 ( 1.00x)
avg_12_128x128_avx2:                                  1651.6 ( 8.29x)

New benchmarks:
avg_8_2x2_c:                                            11.5 ( 1.00x)
avg_8_2x2_avx2:                                          6.0 ( 1.91x)
avg_8_4x4_c:                                            29.7 ( 1.00x)
avg_8_4x4_avx2:                                          8.0 ( 3.72x)
avg_8_8x8_c:                                           131.4 ( 1.00x)
avg_8_8x8_avx2:                                         12.2 (10.74x)
avg_8_16x16_c:                                         254.3 ( 1.00x)
avg_8_16x16_avx2:                                       24.8 (10.25x)
avg_8_32x32_c:                                         897.7 ( 1.00x)
avg_8_32x32_avx2:                                       77.8 (11.54x)
avg_8_64x64_c:                                        3321.3 ( 1.00x)
avg_8_64x64_avx2:                                      318.7 (10.42x)
avg_8_128x128_c:                                     12988.4 ( 1.00x)
avg_8_128x128_avx2:                                   1430.1 ( 9.08x)
avg_10_2x2_c:                                           12.1 ( 1.00x)
avg_10_2x2_avx2:                                         5.7 ( 2.13x)
avg_10_4x4_c:                                           35.0 ( 1.00x)
avg_10_4x4_avx2:                                         9.0 ( 3.88x)
avg_10_8x8_c:                                           77.2 ( 1.00x)
avg_10_8x8_avx2:                                        12.4 ( 6.24x)
avg_10_16x16_c:                                        256.2 ( 1.00x)
avg_10_16x16_avx2:                                      24.3 (10.56x)
avg_10_32x32_c:                                        932.9 ( 1.00x)
avg_10_32x32_avx2:                                      71.9 (12.97x)
avg_10_64x64_c:                                       3516.8 ( 1.00x)
avg_10_64x64_avx2:                                     414.7 ( 8.48x)
avg_10_128x128_c:                                    13693.7 ( 1.00x)
avg_10_128x128_avx2:                                  1609.3 ( 8.51x)
avg_12_2x2_c:                                           14.1 ( 1.00x)
avg_12_2x2_avx2:                                         5.7 ( 2.48x)
avg_12_4x4_c:                                           35.8 ( 1.00x)
avg_12_4x4_avx2:                                         9.0 ( 3.96x)
avg_12_8x8_c:                                           76.9 ( 1.00x)
avg_12_8x8_avx2:                                        12.4 ( 6.22x)
avg_12_16x16_c:                                        256.5 ( 1.00x)
avg_12_16x16_avx2:                                      24.4 (10.50x)
avg_12_32x32_c:                                        934.1 ( 1.00x)
avg_12_32x32_avx2:                                      72.0 (12.97x)
avg_12_64x64_c:                                       3518.2 ( 1.00x)
avg_12_64x64_avx2:                                     414.8 ( 8.48x)
avg_12_128x128_c:                                    13689.5 ( 1.00x)
avg_12_128x128_avx2:                                  1611.1 ( 8.50x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:58:33 +01:00
Andreas Rheinhardt 5a60b3f1a6 avcodec/x86/vvc/mc: Remove always-false branches
The C versions of the average and weighted average functions
contains "FFMAX(3, 15 - BIT_DEPTH)" and the code here followed
this; yet it is only instantiated for bit depths 8, 10 and 12,
for which the above is just 15-BIT_DEPTH. So the comparisons
are unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt 59f8ff4c18 avcodec/x86/vvc/mc: Remove unused constants
Also avoid overaligning .rodata.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt eabf52e787 avcodec/x86/vvc/mc: Avoid unused work
The high quadword of these registers is zero for width 2.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt 9317fb2b2e avcodec/x86/vvc/mc: Avoid ymm registers where possible
Widths 2 and 4 fit into xmm registers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt caa0ae0cfb avcodec/x86/vvc/mc: Avoid pextr[dq], v{insert,extract}i128
Use mov[dq], movdqu instead if the least significant parts
are set (i.e. if the immediate value is 0x0).

Old benchmarks:
avg_8_2x2_c:                                            11.3 ( 1.00x)
avg_8_2x2_avx2:                                          7.5 ( 1.50x)
avg_8_4x4_c:                                            31.2 ( 1.00x)
avg_8_4x4_avx2:                                         10.7 ( 2.91x)
avg_8_8x8_c:                                           133.5 ( 1.00x)
avg_8_8x8_avx2:                                         21.2 ( 6.30x)
avg_8_16x16_c:                                         254.7 ( 1.00x)
avg_8_16x16_avx2:                                       30.1 ( 8.46x)
avg_8_32x32_c:                                         896.9 ( 1.00x)
avg_8_32x32_avx2:                                      103.9 ( 8.63x)
avg_8_64x64_c:                                        3320.7 ( 1.00x)
avg_8_64x64_avx2:                                      539.4 ( 6.16x)
avg_8_128x128_c:                                     12991.5 ( 1.00x)
avg_8_128x128_avx2:                                   1661.3 ( 7.82x)
avg_10_2x2_c:                                           21.3 ( 1.00x)
avg_10_2x2_avx2:                                         8.3 ( 2.55x)
avg_10_4x4_c:                                           34.9 ( 1.00x)
avg_10_4x4_avx2:                                        10.6 ( 3.28x)
avg_10_8x8_c:                                           76.3 ( 1.00x)
avg_10_8x8_avx2:                                        20.2 ( 3.77x)
avg_10_16x16_c:                                        255.9 ( 1.00x)
avg_10_16x16_avx2:                                      24.1 (10.60x)
avg_10_32x32_c:                                        932.4 ( 1.00x)
avg_10_32x32_avx2:                                      73.3 (12.72x)
avg_10_64x64_c:                                       3516.4 ( 1.00x)
avg_10_64x64_avx2:                                     601.7 ( 5.84x)
avg_10_128x128_c:                                    13690.6 ( 1.00x)
avg_10_128x128_avx2:                                  1613.2 ( 8.49x)
avg_12_2x2_c:                                           14.0 ( 1.00x)
avg_12_2x2_avx2:                                         8.3 ( 1.67x)
avg_12_4x4_c:                                           35.3 ( 1.00x)
avg_12_4x4_avx2:                                        10.9 ( 3.26x)
avg_12_8x8_c:                                           76.5 ( 1.00x)
avg_12_8x8_avx2:                                        20.3 ( 3.77x)
avg_12_16x16_c:                                        256.7 ( 1.00x)
avg_12_16x16_avx2:                                      24.1 (10.63x)
avg_12_32x32_c:                                        932.5 ( 1.00x)
avg_12_32x32_avx2:                                      73.3 (12.72x)
avg_12_64x64_c:                                       3520.5 ( 1.00x)
avg_12_64x64_avx2:                                     602.6 ( 5.84x)
avg_12_128x128_c:                                    13689.6 ( 1.00x)
avg_12_128x128_avx2:                                  1613.1 ( 8.49x)
w_avg_8_2x2_c:                                          16.7 ( 1.00x)
w_avg_8_2x2_avx2:                                       13.4 ( 1.25x)
w_avg_8_4x4_c:                                          44.5 ( 1.00x)
w_avg_8_4x4_avx2:                                       15.9 ( 2.81x)
w_avg_8_8x8_c:                                         166.1 ( 1.00x)
w_avg_8_8x8_avx2:                                       45.7 ( 3.63x)
w_avg_8_16x16_c:                                       392.9 ( 1.00x)
w_avg_8_16x16_avx2:                                     57.8 ( 6.80x)
w_avg_8_32x32_c:                                      1455.5 ( 1.00x)
w_avg_8_32x32_avx2:                                    215.0 ( 6.77x)
w_avg_8_64x64_c:                                      5621.8 ( 1.00x)
w_avg_8_64x64_avx2:                                    875.2 ( 6.42x)
w_avg_8_128x128_c:                                   22131.3 ( 1.00x)
w_avg_8_128x128_avx2:                                 3390.1 ( 6.53x)
w_avg_10_2x2_c:                                         18.0 ( 1.00x)
w_avg_10_2x2_avx2:                                      14.0 ( 1.28x)
w_avg_10_4x4_c:                                         53.9 ( 1.00x)
w_avg_10_4x4_avx2:                                      15.9 ( 3.40x)
w_avg_10_8x8_c:                                        109.5 ( 1.00x)
w_avg_10_8x8_avx2:                                      40.4 ( 2.71x)
w_avg_10_16x16_c:                                      395.7 ( 1.00x)
w_avg_10_16x16_avx2:                                    44.7 ( 8.86x)
w_avg_10_32x32_c:                                     1532.7 ( 1.00x)
w_avg_10_32x32_avx2:                                   142.4 (10.77x)
w_avg_10_64x64_c:                                     6007.7 ( 1.00x)
w_avg_10_64x64_avx2:                                   745.5 ( 8.06x)
w_avg_10_128x128_c:                                  23719.7 ( 1.00x)
w_avg_10_128x128_avx2:                                2217.7 (10.70x)
w_avg_12_2x2_c:                                         18.9 ( 1.00x)
w_avg_12_2x2_avx2:                                      13.6 ( 1.38x)
w_avg_12_4x4_c:                                         47.5 ( 1.00x)
w_avg_12_4x4_avx2:                                      15.9 ( 2.99x)
w_avg_12_8x8_c:                                        109.3 ( 1.00x)
w_avg_12_8x8_avx2:                                      40.9 ( 2.67x)
w_avg_12_16x16_c:                                      395.6 ( 1.00x)
w_avg_12_16x16_avx2:                                    44.8 ( 8.84x)
w_avg_12_32x32_c:                                     1531.0 ( 1.00x)
w_avg_12_32x32_avx2:                                   141.8 (10.80x)
w_avg_12_64x64_c:                                     6016.7 ( 1.00x)
w_avg_12_64x64_avx2:                                   732.8 ( 8.21x)
w_avg_12_128x128_c:                                  23762.2 ( 1.00x)
w_avg_12_128x128_avx2:                                2223.4 (10.69x)

New benchmarks:
avg_8_2x2_c:                                            11.3 ( 1.00x)
avg_8_2x2_avx2:                                          7.6 ( 1.49x)
avg_8_4x4_c:                                            31.2 ( 1.00x)
avg_8_4x4_avx2:                                         10.8 ( 2.89x)
avg_8_8x8_c:                                           131.6 ( 1.00x)
avg_8_8x8_avx2:                                         15.6 ( 8.42x)
avg_8_16x16_c:                                         255.3 ( 1.00x)
avg_8_16x16_avx2:                                       27.9 ( 9.16x)
avg_8_32x32_c:                                         897.9 ( 1.00x)
avg_8_32x32_avx2:                                       81.2 (11.06x)
avg_8_64x64_c:                                        3320.0 ( 1.00x)
avg_8_64x64_avx2:                                      335.1 ( 9.91x)
avg_8_128x128_c:                                     12999.1 ( 1.00x)
avg_8_128x128_avx2:                                   1456.3 ( 8.93x)
avg_10_2x2_c:                                           12.0 ( 1.00x)
avg_10_2x2_avx2:                                         8.6 ( 1.40x)
avg_10_4x4_c:                                           34.9 ( 1.00x)
avg_10_4x4_avx2:                                         9.7 ( 3.61x)
avg_10_8x8_c:                                           76.7 ( 1.00x)
avg_10_8x8_avx2:                                        16.3 ( 4.69x)
avg_10_16x16_c:                                        256.3 ( 1.00x)
avg_10_16x16_avx2:                                      25.2 (10.18x)
avg_10_32x32_c:                                        932.8 ( 1.00x)
avg_10_32x32_avx2:                                      73.3 (12.72x)
avg_10_64x64_c:                                       3518.8 ( 1.00x)
avg_10_64x64_avx2:                                     416.8 ( 8.44x)
avg_10_128x128_c:                                    13691.6 ( 1.00x)
avg_10_128x128_avx2:                                  1612.9 ( 8.49x)
avg_12_2x2_c:                                           14.1 ( 1.00x)
avg_12_2x2_avx2:                                         8.7 ( 1.62x)
avg_12_4x4_c:                                           35.7 ( 1.00x)
avg_12_4x4_avx2:                                         9.7 ( 3.68x)
avg_12_8x8_c:                                           77.0 ( 1.00x)
avg_12_8x8_avx2:                                        16.9 ( 4.57x)
avg_12_16x16_c:                                        256.2 ( 1.00x)
avg_12_16x16_avx2:                                      25.7 ( 9.96x)
avg_12_32x32_c:                                        933.5 ( 1.00x)
avg_12_32x32_avx2:                                      74.0 (12.62x)
avg_12_64x64_c:                                       3516.4 ( 1.00x)
avg_12_64x64_avx2:                                     408.7 ( 8.60x)
avg_12_128x128_c:                                    13691.6 ( 1.00x)
avg_12_128x128_avx2:                                  1613.8 ( 8.48x)
w_avg_8_2x2_c:                                          16.7 ( 1.00x)
w_avg_8_2x2_avx2:                                       14.0 ( 1.19x)
w_avg_8_4x4_c:                                          48.2 ( 1.00x)
w_avg_8_4x4_avx2:                                       16.1 ( 3.00x)
w_avg_8_8x8_c:                                         168.0 ( 1.00x)
w_avg_8_8x8_avx2:                                       22.5 ( 7.47x)
w_avg_8_16x16_c:                                       392.5 ( 1.00x)
w_avg_8_16x16_avx2:                                     47.9 ( 8.19x)
w_avg_8_32x32_c:                                      1453.7 ( 1.00x)
w_avg_8_32x32_avx2:                                    176.1 ( 8.26x)
w_avg_8_64x64_c:                                      5631.4 ( 1.00x)
w_avg_8_64x64_avx2:                                    690.8 ( 8.15x)
w_avg_8_128x128_c:                                   22139.5 ( 1.00x)
w_avg_8_128x128_avx2:                                 2742.4 ( 8.07x)
w_avg_10_2x2_c:                                         18.1 ( 1.00x)
w_avg_10_2x2_avx2:                                      13.8 ( 1.31x)
w_avg_10_4x4_c:                                         47.0 ( 1.00x)
w_avg_10_4x4_avx2:                                      16.4 ( 2.87x)
w_avg_10_8x8_c:                                        110.0 ( 1.00x)
w_avg_10_8x8_avx2:                                      21.6 ( 5.09x)
w_avg_10_16x16_c:                                      395.2 ( 1.00x)
w_avg_10_16x16_avx2:                                    45.4 ( 8.71x)
w_avg_10_32x32_c:                                     1533.8 ( 1.00x)
w_avg_10_32x32_avx2:                                   142.6 (10.76x)
w_avg_10_64x64_c:                                     6004.4 ( 1.00x)
w_avg_10_64x64_avx2:                                   672.8 ( 8.92x)
w_avg_10_128x128_c:                                  23748.5 ( 1.00x)
w_avg_10_128x128_avx2:                                2198.0 (10.80x)
w_avg_12_2x2_c:                                         17.2 ( 1.00x)
w_avg_12_2x2_avx2:                                      13.9 ( 1.24x)
w_avg_12_4x4_c:                                         51.4 ( 1.00x)
w_avg_12_4x4_avx2:                                      16.5 ( 3.11x)
w_avg_12_8x8_c:                                        109.1 ( 1.00x)
w_avg_12_8x8_avx2:                                      22.0 ( 4.96x)
w_avg_12_16x16_c:                                      395.9 ( 1.00x)
w_avg_12_16x16_avx2:                                    44.9 ( 8.81x)
w_avg_12_32x32_c:                                     1533.5 ( 1.00x)
w_avg_12_32x32_avx2:                                   142.3 (10.78x)
w_avg_12_64x64_c:                                     6002.0 ( 1.00x)
w_avg_12_64x64_avx2:                                   557.5 (10.77x)
w_avg_12_128x128_c:                                  23749.5 ( 1.00x)
w_avg_12_128x128_avx2:                                2202.0 (10.79x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt 7bf9c1e3f6 avcodec/x86/vvc/mc: Avoid redundant clipping for 8bit
It is already done by packuswb.

Old benchmarks:
avg_8_2x2_c:                                            11.1 ( 1.00x)
avg_8_2x2_avx2:                                          8.6 ( 1.28x)
avg_8_4x4_c:                                            30.0 ( 1.00x)
avg_8_4x4_avx2:                                         10.8 ( 2.78x)
avg_8_8x8_c:                                           132.0 ( 1.00x)
avg_8_8x8_avx2:                                         25.7 ( 5.14x)
avg_8_16x16_c:                                         254.6 ( 1.00x)
avg_8_16x16_avx2:                                       33.2 ( 7.67x)
avg_8_32x32_c:                                         897.5 ( 1.00x)
avg_8_32x32_avx2:                                      115.6 ( 7.76x)
avg_8_64x64_c:                                        3316.9 ( 1.00x)
avg_8_64x64_avx2:                                      626.5 ( 5.29x)
avg_8_128x128_c:                                     12973.6 ( 1.00x)
avg_8_128x128_avx2:                                   1914.0 ( 6.78x)
w_avg_8_2x2_c:                                          16.7 ( 1.00x)
w_avg_8_2x2_avx2:                                       14.4 ( 1.16x)
w_avg_8_4x4_c:                                          48.2 ( 1.00x)
w_avg_8_4x4_avx2:                                       16.5 ( 2.92x)
w_avg_8_8x8_c:                                         168.1 ( 1.00x)
w_avg_8_8x8_avx2:                                       49.7 ( 3.38x)
w_avg_8_16x16_c:                                       392.4 ( 1.00x)
w_avg_8_16x16_avx2:                                     61.1 ( 6.43x)
w_avg_8_32x32_c:                                      1455.3 ( 1.00x)
w_avg_8_32x32_avx2:                                    224.6 ( 6.48x)
w_avg_8_64x64_c:                                      5632.1 ( 1.00x)
w_avg_8_64x64_avx2:                                    896.9 ( 6.28x)
w_avg_8_128x128_c:                                   22136.3 ( 1.00x)
w_avg_8_128x128_avx2:                                 3626.7 ( 6.10x)

New benchmarks:
avg_8_2x2_c:                                            12.3 ( 1.00x)
avg_8_2x2_avx2:                                          8.1 ( 1.52x)
avg_8_4x4_c:                                            30.3 ( 1.00x)
avg_8_4x4_avx2:                                         11.3 ( 2.67x)
avg_8_8x8_c:                                           131.8 ( 1.00x)
avg_8_8x8_avx2:                                         21.3 ( 6.20x)
avg_8_16x16_c:                                         255.0 ( 1.00x)
avg_8_16x16_avx2:                                       30.6 ( 8.33x)
avg_8_32x32_c:                                         898.5 ( 1.00x)
avg_8_32x32_avx2:                                      104.9 ( 8.57x)
avg_8_64x64_c:                                        3317.7 ( 1.00x)
avg_8_64x64_avx2:                                      540.9 ( 6.13x)
avg_8_128x128_c:                                     12986.5 ( 1.00x)
avg_8_128x128_avx2:                                   1663.4 ( 7.81x)
w_avg_8_2x2_c:                                          16.8 ( 1.00x)
w_avg_8_2x2_avx2:                                       13.9 ( 1.21x)
w_avg_8_4x4_c:                                          48.2 ( 1.00x)
w_avg_8_4x4_avx2:                                       16.2 ( 2.98x)
w_avg_8_8x8_c:                                         168.6 ( 1.00x)
w_avg_8_8x8_avx2:                                       46.3 ( 3.64x)
w_avg_8_16x16_c:                                       392.4 ( 1.00x)
w_avg_8_16x16_avx2:                                     57.7 ( 6.80x)
w_avg_8_32x32_c:                                      1454.6 ( 1.00x)
w_avg_8_32x32_avx2:                                    214.6 ( 6.78x)
w_avg_8_64x64_c:                                      5638.4 ( 1.00x)
w_avg_8_64x64_avx2:                                    875.6 ( 6.44x)
w_avg_8_128x128_c:                                   22133.5 ( 1.00x)
w_avg_8_128x128_avx2:                                 3334.3 ( 6.64x)

Also saves 550B of .text here. The improvements will likely
be even better on Win64, because it avoids using two nonvolatile
registers in the weighted average case.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:57:56 +01:00
Andreas Rheinhardt b22b65f2f8 avformat/hlsenc: Return error upon error, fix shadowing
Introduced in 65fc0db581.

Reviewed-by: Marvin Scholz <epirat07@gmail.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-22 00:23:00 +01:00
Michael Niedermayer c98346ffaa avcodec/libtheoraenc: make keyframe mask unsigned and handle its larger range
Fixes: left shift of 1 by 31 places cannot be represented in type 'int'
Fixes: 473579864/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBTHEORA_fuzzer-5835688160591872

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-21 22:43:41 +00:00
Marvin Scholz ca011ee754 avformat: Bump version and add APIChanges entry
Needed after the recent addition of the command APIs.
2026-02-21 20:03:52 +01:00
Andreas Rheinhardt 3be4545b67 avcodec/vvc/inter: Deduplicate applying averaging
Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-21 12:48:50 +01:00
Andreas Rheinhardt 324fd0bc46 avcodec/vvc/inter: Remove redundant variable, fix shadowing
Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-21 12:48:50 +01:00
Andreas Rheinhardt 6777d5cd48 avcodec/vvc/inter: Remove always-false/true checks
derive_weight() is only called when pred_flag is PF_BI,
which only happens in B slices.

Reviewed-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-21 12:48:50 +01:00
Niklas Haas cff9f29d5b swscale/ops_optimizer: add sanity checks to scale->expand conversion
This only works for integer types.
2026-02-21 11:47:43 +00:00
Niklas Haas 5c661dec61 swscale/ops: avoid UB in ff_sws_pixel_expand()
Restructure the loop slightly to avoid UB in the first loop iteration if
src is 4 bytes, which otherwise computes (0 << 32) | 1. Instead, make
1 the default base case and only shift+add if src < dst.

Add an explicit check to preserve the behavior of returnin 0 if src > dst.
2026-02-21 11:47:43 +00:00
Andreas Rheinhardt f951aa9ef3 avfilter/af_loudnorm: Avoid unchecked allocation
Also deduplicate printing json and summary output.

Reviewed-by: Kyle Swanson <k@ylo.ph>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 20:35:16 +01:00
Ramiro Polla a0b55a0491 avcodec/mjpegdec: fix indentation and some white spaces 2026-02-20 16:32:10 +01:00
Ramiro Polla 0accfde281 avcodec/jpeglsdec: fix decoding of jpegls files with restart markers 2026-02-20 16:32:10 +01:00
Ramiro Polla 80edf78e58 tests/fate/image: add jpegls tests with restart markers
The samples have been generated with:
jpeg -c -ls 0 -z 1 great_wave_128.ppm jpegls/ilv0_rst.jls
jpeg -c -ls 1 -z 1 great_wave_128.ppm jpegls/ilv1_rst.jls

Note: ilv2 is still unsupported
2026-02-20 16:32:10 +01:00
Ramiro Polla 5672c410a6 avcodec/mjpegdec: unescape data for each restart marker individually
Instead of unescaping the entire image data buffer in advance, and then
having to perform heuristics to skip over where the restart markers
would have been, unescape the image data for each restart marker
individually.
2026-02-20 16:32:10 +01:00
Ramiro Polla 22771117a0 avcodec/mjpegdec: move get_bits_left() checks after handling of restart count
This commit doesn't really change much on its own, but it's helpful in
preparation for the following commit.
2026-02-20 16:32:10 +01:00
Ramiro Polla 3783b8f5e1 avcodec/mjpegdec: move vpred initialization out of loop in ljpeg_decode_rgb_scan()
The initialization code was only being run when mb_y was 0, so it could
just as well be moved out of the loop.

I haven't been able to find a bayer sample that has restart markers to
check whether vpred should be reinitialized at every restart. It would
seem logical that it should, but I have left this out until we find a
sample that does have restart markers.
2026-02-20 16:32:10 +01:00
Ramiro Polla 851cb118da avcodec/jpegls: clear more JLSState fields inside ff_jpegls_init_state() 2026-02-20 16:32:10 +01:00
Ramiro Polla 3f2d4b49e6 avcodec/mjpegdec: split mjpeg_find_raw_scan_data() out of mjpeg_unescape_sos() 2026-02-20 16:32:10 +01:00
Ramiro Polla bb48d2dba2 avcodec/mjpegdec: simplify decode_scan codepaths in ff_mjpeg_decode_sos()
This will be helpful for the next commit.
2026-02-20 16:32:10 +01:00
Ramiro Polla 179db32777 avcodec/mjpegdec: move MxPEG parameters from mjpeg_decode_scan() to MJpegDecodeContext 2026-02-20 16:32:10 +01:00
Ramiro Polla 14602cd999 avcodec/mjpegdec: move SOS header fields to MJpegDecodeContext
Use naming for SOS header fields from ISO/IEC 10918-1's non-lossless
mode of operation in ff_mjpeg_decode_sos() instead of mixing JPEG-LS
and lossless names. Each decode function still keeps its correct name
for each field.
2026-02-20 16:32:10 +01:00
Ramiro Polla c1cd31320d avcodec/mjpegdec: find correct sizes for SOS fields
For hwaccel, find_marker() was being used to skip over the image data,
which could include multiple restart markers.

For MJPEG-B and THP, the field size was already correct since the image
data was already unescaped.

For the rest (mjpeg and jpegls), the buffer was being incremented by
the unescaped_buf_size, which could be smaller than the actual buffer
size.

Now the buffer is correctly incremented in all cases.
2026-02-20 16:32:10 +01:00
Ramiro Polla cad555d0a4 avcodec/mjpegdec: improve unescaping of SOS fields
For non-jpegls:

Changes the behaviour to be more in line with IJG's reference implementation:
- optional 0xFF fill bytes in a stuffed zero byte sequence (which is an
  invalid pattern according to the standard) are now discarded:
    "FF (FF)? 00" => "FF" instead of "FF 00"
- sequences with optional 0xFF fill bytes and a marker are no longer copied:
    "FF (FF)? XX" => "" instead of "FF XX"
- a trailing 0xFF byte is no longer issued when a valid "0xFF 0xXX" marker
  is found:
    "FF XX" => "" instead of "FF"

For jpegls:

Changes the behaviour to be more in line with IJG's (non-jpegls) reference
implementation, similar to the changes above:
- optional 0xFF fill bytes in a stuffed zero bit sequence (which is an
  invalid pattern according to the standard) are now discarded:
  "FF (FF)? 0b0xxxxxxx" => "FF 0bxxxxxxx" instead of "FF 7F XX"
- sequences with optional 0xFF fill bytes and a marker are no longer copied:
  "FF (FF)? 0b1xxxxxxx" => "" instead of "FF 7F"

Unescaping for jpegls is now done in one pass instead of two. The first
pass used to detect the length of the buffer, while the second pass would
copy up to the detected length.

Note that jpegls restart markers are still not supported.

There is also a speed up with the new implementations, mostly due to the
usage of memchr() as suggested by Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 16:32:10 +01:00
Ramiro Polla 8abb40a8d8 avcodec/mjpegdec: simplify away mjpeg_unescape_sos()'s parameters
The input is always obtained from s->gB and the output is always used
to initialize s->gb, so we can move that inside the function itself.
2026-02-20 16:32:10 +01:00
Ramiro Polla 3d90949d1e avcodec/mjpegdec: split mjpeg_unescape_sos() out of ff_mjpeg_find_marker()
Now only the image data is unescaped (and not the SOS header). As a
side-effect, this also provides a proper fix for decoding CJPG files
(issue #133).
2026-02-20 16:32:10 +01:00
Ramiro Polla 0ddb3e6af2 avcodec/mjpegdec: improve ff_mjpeg_find_marker() for non-SOS and for THP
There is no need to unescape the buffer for non-SOS fields and for THP.
2026-02-20 16:32:10 +01:00
Ramiro Polla 2d9023564b avcodec/mjpegdec: move handling of AVRn interlaced picture to mjpeg_decode_scan()
AVRn interlaced files are only present in sequential JPEG.
2026-02-20 16:32:10 +01:00
Ramiro Polla 51caa26a86 avcodec/mjpegdec: move initialization of last_dc field to mjpeg_decode_scan()
The last_dc field is only used in sequential JPEG and the DC coefficients
for progressive JPEG.
2026-02-20 16:32:10 +01:00
Ramiro Polla 44fd92c514 avcodec/mjpegdec: improve debug message in find_marker()
Use pointer arithmetic instead of an extra variable to keep track of
skipped bytes.
2026-02-20 16:32:10 +01:00
Ramiro Polla 8a0f1fd6ab avcodec/mjpegdec: remove commented out code 2026-02-20 16:32:10 +01:00
Ramiro Polla fa4c24a8d9 avcodec/mjpegdec: remove unnecessary else 2026-02-20 16:32:10 +01:00
Andreas Rheinhardt 9a7e0f1052 configure: Enable -Wunterminated-string-initialization warning
When an array of pointers to strings is converted into
an array of constant-length strings, one has to find out
the maximum size of the strings. Currently no warning will
be emitted If one forgets to account for the trailing zero,
making this optimization dangerous (think of the scenario
where the array will be modified without adjusting the maximum
size of the strings).

The -Wunterminated-string-initialization warning catches these cases.
It is supported by GCC 15.1 and Clang 21. It only requires to mark
the few instances of arrays initialized via string literals that
are not supposed to be strings with the nonstring attribute; this
has already been done in the previous commit.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Andreas Rheinhardt 0b77f79191 avutil/attributes_internal: Add attribute_nonstring
This attribute is used to signal to the compiler
that an array object initialized via a string literal
is not a real string and may lack the space for
the trailing zero, as in char fourcc[4]="FOUR".

This is in preparation for enabling
the -Wunterminated-string-initialization warning.

Reviewed-by: J. Dekker <jdek@itanimul.li>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Andreas Rheinhardt acde43703f avutil/error: Remove size from error_stringtable
This stringtable is a concatenation of strings, with their
own trailing \0. Without an explicit size said stringtable
ends with two \0 (one from the last string and one more
because it is initialized via a string literal); the explicit
size exists to discard the last \0.

Yet this makes GCC (but not Clang) think that this is an
unterminated string, leading to warnings when
-Wunterminated-string-initialization is enabled.
So just remove the explicit size to avoid this.

(An alternative would be to mark this as a non-string
for GCC, but not for Clang, but this has been deemed ugly;
another alternative would be to omit the internal \0 from
the stringtable and use length fields instead, but
the necessary copying code more than outweighs the size benefits
of omitting the \0.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Andreas Rheinhardt 005510501e configure: Make check for accepting warnings stricter
Clang by default allows unknown warnings and merely emits
a Wunknown-warning-option warning which is non-fatal by default,
making it appear as if Clang supported any warning. This patch
rewrites the tests to always add the arguments to error out
in case an unrecognized option is encountered.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Andreas Rheinhardt 05098eef42 configure: Use per-language unknown-warnings-flags
E.g. when CC is clang, the unknown warnings flags
are -Werror=unused-command-line-argument and
-Werror=unknown-warning-option. These flags are currently
also used for testing the C++ and ObjC compilers, yet
g++ does not recognize these flags and errors out because
of them, so that the tests fail and the parentheses,
switch etc. warnings are not disabled for C++.

Fix this by using per-language flags.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-20 11:59:37 +01:00
Vignesh Venkat 51349e31fc avformat/whip: Avoid uninitialized pointer read
Do not try to free the io context if it was never allocated.

Fixes coverity #1665383

Signed-off-by: Vignesh Venkatasubramanian <vigneshv@google.com>
2026-02-20 01:12:27 +00:00
Marvin Scholz e8a07be1c2 avformat: rtsp: fix logging of reply sequence number 2026-02-20 01:31:06 +01:00
Marvin Scholz 8d46d88f05 avformat: rtspdec: fix leaks in rtsp_read_command_reply
Reorder to avoid allocation if there is nothing to read and also solve
a memory leak in that case.

Also make sure to free the RTSPMessageHeader, which is not passed
to the caller.
2026-02-20 01:31:06 +01:00
Michael Niedermayer 360a4025fb avcodec/rv60dec: check last_size
Fixes: signed integer overflow: 1878131215 + 2013265920 cannot be represented in type 'int'
Fixes: 472729732/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-4893818005815296

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-19 22:39:35 +00:00
Niklas Haas c9404f5b9c swscale/optimizer: eliminate completely unused operations
e.g. empty read when all components are eventually cleared

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 46d721a69a swscale/optimizer: compress planar reads with unused planes
After plane splitting, we can end up with a situation where a subpass wants
to read only, say, the alpha plane. In this case, we should compress the
planar read by instead swizzling the alpha plane into the correct place
in the src plane order, and then reading only a single plane.

Results in a bunch of benign diffs like:

 yuva444p -> ya8:
-  [ u8 XXXX -> ++++] SWS_OP_READ         : 4 elem(s) planar >> 0
-  [ u8 .XX. -> ++++] SWS_OP_CONVERT      : u8 -> f32
-  [f32 .XX. -> .+++] SWS_OP_LINEAR       : luma [...]
-  [f32 .XX. -> .+++] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
-  [f32 .XX. -> .+++] SWS_OP_MAX          : {0 0 0 0} <= x
-  [f32 .XX. -> .+++] SWS_OP_MIN          : x <= {255 _ _ 255}
-  [f32 .XX. -> ++++] SWS_OP_CONVERT      : f32 -> u8
-  [ u8 .XX. -> ++++] SWS_OP_SWIZZLE      : 0312
-  [ u8 ..XX -> ++++] SWS_OP_WRITE        : 2 elem(s) packed >> 0
+  [ u8 XXXX -> ++XX] SWS_OP_READ         : 2 elem(s) planar >> 0, via {0, 3}
+  [ u8 ..XX -> ++XX] SWS_OP_CONVERT      : u8 -> f32
+  [f32 ..XX -> +XX+] SWS_OP_SWIZZLE      : 0321
+  [f32 .XX. -> .XX+] SWS_OP_LINEAR       : luma [...]
+  [f32 .XX. -> .XX+] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
+  [f32 .XX. -> .XX+] SWS_OP_MAX          : {0 0 0 0} <= x
+  [f32 .XX. -> .XX+] SWS_OP_MIN          : x <= {255 _ _ 255}
+  [f32 .XX. -> +XX+] SWS_OP_CONVERT      : f32 -> u8
+  [ u8 .XX. -> ++XX] SWS_OP_SWIZZLE      : 0312
+  [ u8 ..XX -> ++XX] SWS_OP_WRITE        : 2 elem(s) packed >> 0

This may seem noisy, but really is mostly a result of the fact that the unused
middle components are now marked as garbage instead of as valid data.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas b01236d5fb swscale/optimizer: try pushing all swizzles towards the output
Now that we can directly promote these to plane swizzles, we generally want
to try pushing them in one direction - ideally towards the output, as in the
case of split subpasses, the output is guaranteed to be planar. (And there
may not even be a read)

Results in a lot of diffs, ranging from the benign, e.g.:

 rgb24 -> bgr48be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
   [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
+  [u16 ...X -> zzzX] SWS_OP_SWIZZLE      : 2103
   [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) packed >> 0

 rgb24 -> gbrp9be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> ...X] SWS_OP_SCALE        : * 511/255
   [f32 ...X -> ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
   [f32 ...X -> ...X] SWS_OP_MIN          : x <= {511 511 511 _}
   [f32 ...X -> +++X] SWS_OP_CONVERT      : f32 -> u16
-  [u16 ...X -> +++X] SWS_OP_SWIZZLE      : 1203
   [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0, via {2, 0, 1}

To the clear improvements, e.g.:

 bgr24 -> gbrp16be:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
-  [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> +++X] SWS_OP_SWIZZLE      : 1203
   [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0, via {1, 0, 2}

The only case worth careful consideration is when there are swizzled inputs
that result in unusual plane patterns, e.g.:

 argb -> gbrp9be:
   [ u8 XXXX -> ++++] SWS_OP_READ         : 4 elem(s) packed >> 0
-  [ u8 X... -> ++++] SWS_OP_SWIZZLE      : 1230
-  [ u8 ...X -> ++++] SWS_OP_CONVERT      : u8 -> f32
-  [f32 ...X -> ....] SWS_OP_SCALE        : * 511/255
-  [f32 ...X -> ....] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
-  [f32 ...X -> ....] SWS_OP_MIN          : x <= {511 511 511 _}
-  [f32 ...X -> ++++] SWS_OP_CONVERT      : f32 -> u16
-  [u16 ...X -> ++++] SWS_OP_SWIZZLE      : 1203
-  [u16 ...X -> zzzz] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzz] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [ u8 X... -> ++++] SWS_OP_CONVERT      : u8 -> f32
+  [f32 X... -> ....] SWS_OP_SCALE        : * 511/255
+  [f32 X... -> ....] SWS_OP_DITHER       : 16x16 matrix + {0 0 3 2}
+  [f32 X... -> ....] SWS_OP_MIN          : x <= {511 511 511 511}
+  [f32 X... -> ++++] SWS_OP_CONVERT      : f32 -> u16
+  [u16 X... -> zzzz] SWS_OP_SWAP_BYTES
+  [u16 X... -> zzzz] SWS_OP_SWIZZLE      : 3120
+  [u16 ...X -> zzzz] SWS_OP_WRITE        : 3 elem(s) planar >> 0, via {1, 2, 0}
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Observe the change from ...X to X..., which is a pattern that doesn't
necessarily have a fast path and would usually end up falling back to the
generic 4-component implementations (rather than the 3-component ones).

That said, this is not a big deal, since we can ultimately re-align the
set of implementations with what's actually needed; once we're done with
plane splitting and so forth.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas aaa898a2d1 swscale/optimizer: promote component swizzles to plane swizzles
In some cases, we can just directly swizzle the order of input/output
planes, rather than applying a swizzle operation on the data itself.

This can eliminate some such swizzle operations entirely, for example
yuv444p -> vuya is now just a read, clear and write.

Results in a lot of simplifications like this:

 rgb24 -> gbrp:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
-  [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 1203
-  [ u8 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [ u8 ...X -> +++X] SWS_OP_WRITE        : 3 elem(s) planar >> 0, via {2, 0, 1}

 rgb24 -> gbrap16le:
   [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> u16 (expand)
-  [u16 ...X -> +++X] SWS_OP_SWIZZLE      : 1203
   [u16 ...X -> ++++] SWS_OP_CLEAR        : {_ _ _ 65535}
-  [u16 .... -> ++++] SWS_OP_WRITE        : 4 elem(s) planar >> 0
+  [u16 .... -> ++++] SWS_OP_WRITE        : 4 elem(s) planar >> 0, via {2, 0, 1, 3}

 yuv444p -> vuya:
-  [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) planar >> 0
-  [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
+  [ u8 XXXX -> +++X] SWS_OP_READ         : 3 elem(s) planar >> 0, via {2, 1, 0}
   [ u8 ...X -> ++++] SWS_OP_CLEAR        : {_ _ _ 255}
   [ u8 .... -> ++++] SWS_OP_WRITE        : 4 elem(s) packed >> 0

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas a02860a292 swscale/optimizer: don't assume op lists start with read
This was just a minor/pointless optimization in the first place. We keep
the skip on the last component because we can never commute that past the
end of the list.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 6df8174f77 swscale/optimizer: don't reject op lists without read
When splitting planes, some planes can end up without a read operation
altogether, e.g. when just clearing the alpha plane.

Just return ENOTSUP for such lists instead of EINVAL.

Also fixes the !ops->num_ops check to avoid UB.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas e7965e84c5 swscale/optimizer: fix unswizzle optimization
The way this code was written relied on the implicit assumption that no other
row was reading from the same column, which was true in practice so far but
not necessarily true in general. Fix it by precomputing the nonzero component
mask and then adding an explicit check.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 4b8790f107 swscale/optimizer: allow commuting CLEAR past SWAP_BYTES
This requires a bit of a manual check in the 32-bit integer case to
make sure we don't exceed the value range of AVRational; but it still allows
quite a number of optimizations despite that restriction.

e.g.

rgb24 -> yuva444p9be:
-  [u16 ...X -> ++++] SWS_OP_CLEAR        : {_ _ _ 511}
-  [u16 .... -> zzzz] SWS_OP_SWAP_BYTES
-  [u16 .... -> zzzz] SWS_OP_WRITE        : 4 elem(s) planar >> 0
+  [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
+  [u16 ...X -> zzz+] SWS_OP_CLEAR        : {_ _ _ 65281}
+  [u16 .... -> zzz+] SWS_OP_WRITE        : 4 elem(s) planar >> 0

gray -> yuv444p12be:
-  [u16 .XXX -> +++X] SWS_OP_CLEAR        : {_ 2048 2048 _}
-  [u16 ...X -> zzzX] SWS_OP_SWAP_BYTES
-  [u16 ...X -> zzzX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
+  [u16 .XXX -> zzXX] SWS_OP_SWAP_BYTES
+  [u16 .XXX -> z++X] SWS_OP_CLEAR        : {_ 8 8 _}
+  [u16 ...X -> z++X] SWS_OP_WRITE        : 3 elem(s) planar >> 0

Ultimately, the benefit of this will only become relevant once we start
splitting apart planes, since then we can have planes with only CLEAR
operations.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas e729f49645 swscale/ops_backend: allocate block storage up-front
Instead of in each read() function. Not only is this slightly faster, due
to promoting more tail calls, but it also allows us to have operation chains
that don't start with a read.

Also simplifies the implementations.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 7961e3a48f swscale/ops_backend: add float clear patterns
These have no implementation at all otherwise.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 272e7a047b swscale/ops_backend: add clear pattern for ya8 alpha
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas ef4e16ed50 swscale/x86/ops: make the presence of a read op optional
Allows this backend to process op lists without a read, e.g. for pure clear
operations. I decided to change `write` to a pointer as well for symmetry.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas da47951bd7 swscale/ops: lift read op metadata to SwsOpList
Instead of awkwardly preserving these from the `SwsOp` itself. This
interpretation lessens the risk of bugs as a result of changing the plane
swizzle mask without updating the corresponding components.

After this commit, the plane swizzle mask is automatically taken into
account; i.e. the src_comps mask is always interpreted as if the read op
was in-order (unswizzled).

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 1940662ac6 swscale/ops: take plane order into account during noop() check
This helper function now also takes into account the plane order, and only
returns true if the SwsOpList is a true no-op (i.e. the input image may be
exactly ref'd to the output, with no change in plane order, etc.)

As pointed out in the code, this is unlikely to actually matter, but still
technically correct.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas d0cb74881c swscale/ops: fix PRINTQ snprintf buffer size
There is no reason to subtract 1 here; snprintf guarantees zero-termination.
2026-02-19 19:44:46 +00:00
Niklas Haas 70d30056dc swscale/ops: also print plane order when swizzled
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 998cffb432 swscale/ops: add input/output plane swizzle mask to SwsOpList
This can be used to have the execution code directly swizzle the plane
pointers, instead of swizzling the data via SWS_OP_SWIZZLE. This can be used
to, for example, extract a subset of the input/output planes for partial
processing of split graphs (e.g. subsampled chroma, or independent alpha),
or just to skip an SWS_OP_SWIZZLE operation.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 2dfde1531d swscale/ops: reset comp flags on SWS_OP_CLEAR
Even if we clear to a non-integer value.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas 9662d1fa97 swscale/optimizer: remove read+write optimization
This optimization is lossy, since it removes important information about the
number of planes to be copied. Subsumed by the more correct

Instead, move this code to the new ff_sws_op_list_is_noop().

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas c17a9ba0b8 tests/sws_ops: explicitly skip no-op operation lists
These are not necessarily empty, as a result of the previous changes.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Niklas Haas e96332cb65 swscale/ops: add ff_sws_op_list_is_noop()
And use it in ff_sws_compile_pass() instead of hard-coding the check there.
This check will become more sophisticated in the following commits.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
2026-02-19 19:44:46 +00:00
Lynne c91634dfe6 vulkan/ffv1: add current linecache for encode/decode
This avoids needing expensive roundtrips when reading/writing to images,
mainly in the decoder.
2026-02-19 19:42:35 +01:00
Lynne 3f91ff8aa6 ffv1enc_vulkan: perform non-RGB prediction in 16-bits 2026-02-19 19:42:35 +01:00
Lynne 9d5421ad92 vulkan/ffv1: keep track of RCT Ry/By coeffs using vector suffixes
This makes it far easier to read, particularly because when reading
or writing, their order is swapped.
2026-02-19 19:42:35 +01:00
Lynne b9c19c9073 ffv1enc_vulkan: use direct values rather than reading from struct
This saves indirection and allows compilers to eliminate more
code during compilation.
2026-02-19 19:42:35 +01:00
Lynne b19707103e ffv1enc_vulkan: allocate a device-only output buffer if possible
This avoids needing to map HUGE 4GiB chunks of memory.
2026-02-19 19:42:34 +01:00
Lynne 4b6396a49b ffv1enc_vulkan: allocate all results memory upfront
Suballocation is the Vulkan way.
2026-02-19 19:42:34 +01:00
Lynne f32e70ecc9 vulkan/ffv1: unify all constants buffer into a single buffer
Less allocations is always better.
2026-02-19 19:42:34 +01:00
Lynne fc10cc4a52 vulkan/ffv1: optimize get_isymbol 2026-02-19 19:42:34 +01:00
Lynne f32111f3f7 vulkan/ffv1: improve compiler hints
Don't unroll unless needed, don't use const in function arguments,
don't use expect unless actually needed.
2026-02-19 19:42:34 +01:00
Lynne e9645930dd vulkan/ffv1_dec: synchronize image writes when decoding 2026-02-19 19:42:34 +01:00
Lynne fb7700636c vulkan/ffv1: synchronize before/after RCT transform/preload 2026-02-19 19:42:34 +01:00
Lynne 5ac9376763 vulkan/ffv1_dec_setup: roll a put_rac inside a loop
This saves 16KiB of memory.
Yeah, things go large when all compilers inline everything.
2026-02-19 19:42:33 +01:00
Lynne 33525cb6e7 vulkan/rangecoder: don't store pointers in the context 2026-02-19 19:42:33 +01:00
Lynne 5c1b2947a4 ffv1enc_vulkan: only return the encoded size, not its offset
The encoded offset is just a multiple of the index by the max slice size.
2026-02-19 19:42:33 +01:00
Lynne 2c138e2df5 vulkan/ffv1: use loops to encode planes
Every function in SPIR-V gets inlined, always. So use loops.
2026-02-19 19:42:33 +01:00
Lynne 10a26974cd vulkan/ffv1: finalize and initialize slices only in invocation == 0 2026-02-19 19:42:33 +01:00
Lynne bc968bc8b4 vulkan/ffv1_enc: cache state probabilities
4x speedup on AMD.
2026-02-19 19:42:33 +01:00
Lynne 826b72d12f vulkan/ffv1: mark buffers as uniform/readonly when needed
Should be a speedup in most cases.
2026-02-19 19:42:32 +01:00
Lynne 3d74e0e63a ffv1enc_vulkan: fix Golomb encoding
The issue is that the PB buffer address for Golomb may not be aligned
to mod 4.
2026-02-19 19:42:32 +01:00
Lynne fdd0f21f5d vulkan/ffv1_common: use scalar alignment for the base slice structure
Scalar is the fastest for modern GPUs to use.
2026-02-19 19:42:32 +01:00
Lynne 4b00b26e79 vulkan_ffv1: overhaul the synchronization 2026-02-19 19:42:32 +01:00
Lynne 10407de110 vulkan/rangecoder: clean up unused functions and redundant fields 2026-02-19 19:42:32 +01:00
Lynne c8823ec5b2 vulkan_ffv1: unify slice offsets and status into one buffer
Reduces allocations.
2026-02-19 19:42:32 +01:00
Lynne 128ad49c32 ffv1dec: correctly track configured_width/height
The 2 parameters were not synchronized between decoding threads.
2026-02-19 19:42:31 +01:00
Lynne dbc6fa5248 ffv1enc: use local RangeCoder struct 2026-02-19 19:42:31 +01:00
Lynne b756d83e24 vulkan_ffv1: use local RangeCoder struct, refactor overread checking 2026-02-19 19:42:31 +01:00
Lynne 06eb98bc97 ffv1enc_vulkan: remove dead code 2026-02-19 19:42:31 +01:00
Lynne 6971ba9075 vulkan_ffv1: improve decode report results printout 2026-02-19 19:42:31 +01:00
Lynne 3ba81f2af4 vulkan: drop support for descriptor buffers
Descriptor buffers were a neat attempt at organizing descriptors.
Simple, robust, reliable.

Unfortunately, driver support never caught on, and neither did validation
layer support.

Now they're being replaced by descriptor heaps, which promises to be
the future. We'll see how it goes.
2026-02-19 19:42:31 +01:00
Lynne b230ba4db9 ffv1enc_vulkan: use regular descriptors for slice state 2026-02-19 19:42:30 +01:00
Lynne c0a697a1bc vulkan_ffv1: use regular descriptors for slice state
HUGE speedup on AMD, HUGE speedup everywhere.
2026-02-19 19:42:30 +01:00
Lynne da99d3f209 vulkan_ffv1: implement parallel probability adaptation 2026-02-19 19:42:30 +01:00
Lynne 25e8d3d89c vulkan/rangecoder: clean up the type mess slightly 2026-02-19 19:42:30 +01:00
Lynne a9d9f7e1bb ffv1enc: add descriptor information for GBRP
The C encoder does not support GBRP, this just adds info fields
so the Vulkan encoder can use it.
2026-02-19 19:42:30 +01:00
Lynne b3a388e36e ffv1enc_vulkan: overhaul the synchronization
Allows for the setup and reset shaders to run in parallel.
2026-02-19 19:42:30 +01:00
Lynne 3bc265d484 ffv1enc_vulkan: make reset shader independent from the setup shader
Allows them to run in parallel.
2026-02-19 19:42:29 +01:00
Lynne 7234f1b167 ffv1enc_vulkan: use a loop to write slice header symbols
Same as with the decoder.
2026-02-19 19:42:29 +01:00
Lynne fb5d3cf15e vulkan_ffv1: use a loop to decode slice header symbols
All known drivers and implementations inline every single function.
This ends up being faster.
2026-02-19 19:42:29 +01:00
Lynne eff3dad6b7 avcodec: remove support for runtime SPIR-V compilation
Begone.
2026-02-19 19:42:29 +01:00
Lynne c4879dbbda avcodec/vulkan: standardize on .glsl extension
None of the files are strictly compute now.
2026-02-19 19:42:29 +01:00
Lynne b736d1c73e ffv1enc_vulkan: convert encode shader to compile-time SPIR-V generation 2026-02-19 19:42:29 +01:00
Lynne 4038af3da8 ffv1enc_vulkan: convert setup shader to compile-time SPIR-V generation 2026-02-19 19:42:29 +01:00
Lynne 6f4cef26df ffv1enc_vulkan: convert reset shader to compile-time SPIR-V generation 2026-02-19 19:42:28 +01:00
Lynne fdee87d06d ffv1enc_vulkan: convert RCT search shader to compile-time SPIR-V generation 2026-02-19 19:42:28 +01:00
Lynne a548c2f0a3 vulkan_ffv1: move common spec constant setting to ffv1_vulkan.c
It will be shared between encoder and decoder.
2026-02-19 19:42:28 +01:00
Lynne ab2ba27c18 ffv1enc_vulkan: remove golomb gb context from main slice context 2026-02-19 19:42:28 +01:00
Lynne 6c0b2be235 vulkan_ffv1: remove golomb gb context from main slice context 2026-02-19 19:42:28 +01:00
Lynne ea9ae1166b vulkan_ffv1: precalculate bits and use a specialization constant 2026-02-19 19:42:28 +01:00
Lynne 3dceda7769 vulkan_ffv1: convert to compile-time SPIR-V generation 2026-02-19 19:42:27 +01:00
Lynne 82f0818ff2 vulkan/common: add debug shorthand 2026-02-19 19:42:27 +01:00
Lynne 8b447a670a vulkan/dpx: bounds check with image sizes
Prevents out of bounds accesses.
2026-02-19 19:42:27 +01:00
Lynne 61ca28d6e0 hwcontext_vulkan: correctly set stride for host image uploads
Cursed.
2026-02-19 19:42:27 +01:00
Lynne 6452e0c56e hwcontext_vulkan: drop debug=3 (profile)
The mode is useless with pregenerated SPIR-V.
2026-02-19 19:42:27 +01:00
Lynne 6f749ec0a7 hwcontext_vulkan: zero-pad optional_instance_exts
The layer settings extension was enabled since the list was blank,
and some compilers complained about that, and it should have been
always supported on all platforms everywhere.

Unfortunately, some platforms LIE, claim they support it and yet
they error out that the extension is missing.

Juse zero pad the array.
2026-02-19 19:42:27 +01:00
Lynne ee1d5da27f hwcontext_vulkan: enable VK_KHR_shader_relaxed_extended_instruction by default
We compile our shaders with debug information by default.
2026-02-19 19:42:26 +01:00
Lynne eadfbc109d hwcontext_vulkan: disable shader object when debugging 2026-02-19 19:42:26 +01:00
Lynne 67d5e7e86a vulkan_prores_raw: fix a single statement's indentation
Annoying.
2026-02-19 19:42:26 +01:00
Lynne d616269035 vulkan: don't set FFVulkanDescriptorSetBinding.name when not necessary
It just bloats the code with unused strings.
2026-02-19 19:42:26 +01:00
Lynne ae1a227cf6 Makefile: specify GLSL version via command line arguments
GLSL strictly mandates the version must be the very first non-comment
statement, which results in issues when #including for templating.
2026-02-19 19:42:20 +01:00
nyanmisaka c96b0d94eb scale_vulkan: fix descriptor type for non debayer path
fixup 80229c1

[scale_vulkan @ 0000028b1c2c1300] scale:31: error: 'texture' : no matching overloaded function found
scale:31: error: 'return' : cannot convert return value to function return type

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2026-02-19 18:41:44 +00:00
Marvin Scholz cebdd64981 swscale: gitignore: add sws_ops 2026-02-19 17:25:45 +00:00
Tim Blechmann 2799aaa5af avutil: hwcontext_videotoolbox: support YUYV422 pixel format 2026-02-19 16:52:58 +00:00
Romain Beauxis 0be94a16d6 libavformat/oggdec.c: fix ogg_{save,restore,reset} w.r.t. new_extradata. 2026-02-19 16:45:42 +00:00
Marvin Scholz 8030e3b899 avformat: rtspdec: do not allow SET_PARAMETER command too early 2026-02-19 17:18:12 +01:00
Marvin Scholz da821ec316 avformat: rtspdec: use stored replies for SET_PARAMETER command
Makes the reply reading completely non-blocking and reliably reports
the reply even when interleaved packets are read.
2026-02-19 17:18:12 +01:00
Marvin Scholz b63f69fccf avformat: rtsp: add functions to allow stored replies
This adds the ability to have a stored reply, needed for the
SET_PARAMETERS command feature to reliably report the reply even
while intermediate packets are read.
2026-02-19 17:18:12 +01:00
Marvin Scholz 5daa45fa01 avformat: rtsp: fix log message formatting 2026-02-19 17:18:12 +01:00
Marvin Scholz b59471f8c8 avformat: rtsp: do not skip packets in SET_PARAMETER command handling
Return EAGAIN so the client has a chance to read the pending packets
instead of just silently discarding them internally.
2026-02-19 17:18:12 +01:00
Marvin Scholz 6d8950f046 avformat: rtsp: handle interleaved pending packets
Fixes the behavior when calling ff_rtsp_read_reply again after it
was called at another place with return_on_interleaved_data set to
true. Before, it would result in completely corrupting the internal
state as the $ interleaved packet marker would have already been read
which the next run of ff_rtsp_read_reply would look for but never find
it, trying to read packet data as RTSP message.
2026-02-19 17:18:12 +01:00
Marvin Scholz 44065ea878 avformat/rtspdec: Add SET_PARAMETER command support
Add SET_PARAMETER support, this allows sending SET_PARAMETER requests to
the server using the API.
2026-02-19 17:18:12 +01:00
Marvin Scholz 368ecdd3a4 rtsp: expose rtsp_send_cmd_with_content_async
Add the ff_ prefix and move the declaration to the header, so it can
be used in other places like rtspdec in a future commit.
2026-02-19 17:18:11 +01:00
Marvin Scholz 633dcf71e8 avformat: Add new demuxer command API
This new API adds the ability to send commands to the demuxer and also
receive replies to these commands.

It is useful in cases like the RTSP demuxer, where it might be desirable
for the API user to send commands like SET_PARAMETER or PLAY and PAUSE.

Sending and receiving are decoupled, as to not require waiting for a
reply when sending, as with some demuxers and depending on the command
it could be necessary to process further packets in the meantime
before requesting a reply.
2026-02-19 17:18:11 +01:00
Marvin Scholz cf755be215 lavf: replace read_{play,pause} by a single callback 2026-02-19 17:18:11 +01:00
Andreas Rheinhardt ae60f47a2c tests/fate/{dca,qoa,truehd}: Make fate-audio work
Based on the Makefile variables, "make fate-audio"
is supposed to include the tests for several audio
codecs with their own Makefile. Yet because they are
included after audio.mak*, this doesn't work atm.
Fix this by adding explicit prerequisites.

*: Expansion of variables is not deferred in the context
of prerequisites.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-19 14:35:04 +01:00
Andreas Rheinhardt 166b01aefd tests/fate/dca: Add ffprobe dependency to dca-lossless tests
Forgotten in e1484a30e5.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-19 14:34:45 +01:00
Adam Jensen 059c57a83e avfilter/af_loudnorm: add stats_file option
loudnorm provides stats output that's meant to be used for two-pass
normalization. These stats are often interleaved with ffmpeg's stream
descriptions and other output, making them difficult to parse and pass
to the second pass. The new stats_file option enables writing the stats
to a separate file, or to standard output, for simple parsing and other
programmatic usage.

Signed-off-by: Adam Jensen <adam@acj.sh>
2026-02-19 12:48:58 +00:00
Michael Niedermayer 52b676bb29 avcodec/cfhd: Check transform type before continuing
Fixes: null pointer dereference
Fixes: 471768165/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_DEC_fuzzer-6187504467509248

The first frame allocates buffers with one transform type
the second frame sets up another transform type but the code to reallocate buffers is never triggered

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 23:45:28 +00:00
Michael Niedermayer 2263e05e41 avcodec/cfhd: Add CFHDSegment enum and named identifiers
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 23:45:28 +00:00
Michael Niedermayer d138169966 avcodec/libvorbisdec: output AV_SAMPLE_FMT_FLTP
This removes the internal sample format convert

Fixes: nan is outside the range of representable values of type 'int'
Fixes: 471946097/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBVORBIS_DEC_fuzzer-4843605174059008

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 23:38:16 +00:00
Romain Beauxis 0e89d993c5 libavformat/oggenc.c: re-initialize stream on new metadata. 2026-02-18 16:25:06 +00:00
Michael Niedermayer 5ec37f61b2 avcodec/hevc/ps: Check bit_depth_cm in/out relation
Fixes: Assertion n>0 && n<=25 failed at ./libavcodec/get_bits.h:3
Fixes: 472463689/clusterfuzz-testcase-minimized-ffmpeg_dem_HXVS_fuzzer-6012944883449856

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 13:57:28 +00:00
Niklas Haas 4cefbc54c4 avformat/http: add missing check to connection re-use
Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21685
Fixes: e03b034e45
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21693
2026-02-18 12:57:55 +00:00
lompik 38cd91c99a hwdec/vulkan: fix invalid number of planes usage in map_to_drm
This fixes a SIGSEGV happening (for >1 plane images) in drivers as we
are sending a null semaphore for them to wait on.
2026-02-18 13:48:04 +04:00
Michael Niedermayer 237d03717f avformat/icodec: Check size
Fixes: signed integer overflow: 14 + 2147483647 cannot be represented in type 'int'
Fixes: 471688026/clusterfuzz-testcase-minimized-ffmpeg_dem_ICO_fuzzer-5616495813263360

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 08:20:10 +00:00
Michael Niedermayer a7a009a3eb tools/target_dec_fuzzer: Adjust threshold for JV
Fixes: Timeout
Fixes: 472108726/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JV_fuzzer-5265024680787968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-18 08:18:44 +00:00
James Almer eb36dce742 avfilter/video: reduce potential amount of pool reinitializations
Given we now align both dimensions when allocating buffers, don't reinitialize
the pool when dealing with dimension changes that will not affect the existing
pool size.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:19:01 -03:00
James Almer 14097ee1cd avfilter/framepool: add a few padding lines by aligning height
Fixes segfaults when handling files with odd chroma subsampled dimensions in
some scenarios like using the hstack filter.

./ffmpeg -lavfi testsrc=s=255x31,format=yuv420p -vframes 1 -y in.jpg && \
./ffmpeg -i in.jpg -i in.jpg -i in.jpg -i in.jpg -filter_complex "xstack=inputs=4:grid=2x2" -y out.png

Fixes issue #21739.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:19:01 -03:00
James Almer 7c877b2e80 avcodec/opus/enc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer 0aa3a6fe41 avcodec/libvorbisenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer 84bb5b0748 avcodec/libopusenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer 5863cab885 avcodec/libmp3lame: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer e3061be971 avcodec/libfdk-aacenc: rescale packet duration when calculating discarded samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
James Almer dd9756286d avcodec/encode: add a helper to convert from a duration to samples
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-17 20:17:23 -03:00
Diego de Souza cb0f4de1f5 avcodec/nvenc_av1: fix b_ref_mode "middle" help string for AV1
For AV1, NV_ENC_BFRAME_REF_MODE_MIDDLE does not use a single middle
B-frame. Per the NVENC Programming Guide, it sets every other B-frame
as an Altref2 reference except the last B-frame in the Altref interval.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-02-17 16:36:51 +00:00
Marvin Scholz b98ec6d312 configure: remove require_cpp, check_lib_cpp
Remove the improperly named check functions that were added for the
opencolorio detection in 677cf95ea4.
Those are not needed anymore and there are already require_cxx and
check_lib_cxx for this purpose.
2026-02-17 15:17:37 +00:00
Marvin Scholz 8014cc7620 configure: cleanup libopencolorio check
Do a proper pkg-config check instead of just blindly compiling a test
program even if pkg-config doesn't find anything.
2026-02-17 15:17:37 +00:00
Marvin Scholz 84ffb18f77 configure: do not require default-constructible class
When checking for C++ classes in check_class_headers_cxx, the test code
required the class to be default-constructible, which is not always the
case. For the sake of the test, it is enough to check that referencing
the class succeeds.
2026-02-17 15:17:37 +00:00
Marvin Scholz 305c383d94 configure: add {test,check,require}_pkg_config_cxx
This is necessary to check for C++ only pkg-config dependencies
2026-02-17 15:17:37 +00:00
Sam.Richards@taurich.org a1309700ed configure: remove accidentally added library
This was added by accident in 677cf95ea4
but is not actually used by anything.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>
2026-02-17 15:14:22 +00:00
Jack Lau cbdb325424 avformat/tls_openssl: update the outdated comments
Loading CA certificate is supported.

Remove unrelated comments.

The underlying socket can be tcp or udp.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-17 13:58:14 +00:00
Jack Lau 479c40f595 avformat/tls_openssl: use EINVAL when X509_digest failed
This function just calculate and copy the fingerprint
to the provided buf, will not allocate memory.

It fails when the input (such as cert) is invalid.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-17 13:58:14 +00:00
Michael Niedermayer bce0e22133 avformat/lrcdec: Check ss for finiteness
Fixes: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself
Fixes: 471604230/clusterfuzz-testcase-minimized-ffmpeg_dem_LRC_fuzzer-5474264750030848

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:49:41 +00:00
Michael Niedermayer 82fbb04d07 avformat/http: Also count redirects from the cache
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:43:37 +00:00
Michael Niedermayer ba3639bc90 avformat/http: allow adjusting the redirect limit
Idea from: BapToutatis and also curl and wget have equivalent options

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:43:37 +00:00
Michael Niedermayer 0833dd3665 fftools/ffmpeg_opt: limit recursion of presets
Fixes: stack overflow

This should have limited security impact as it requires access to arbitrary
options.

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:41:37 +00:00
Jack Lau 1fd128ef3a avformat/tls_gnutls: update the comment since the underlying socket can be TCP or UDP
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-17 13:27:09 +00:00
Jack Lau 546d565d07 avformat/tls_gnutls: limit the written size to data MTU
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-17 13:27:09 +00:00
Marton Balint 33b215d155 avcodec/libvpxenc: add experimental support for alpha pixel formats other than YUV 4:2:0.
I could not find any documentation which disallows the use of transparency for
pixel formats other than YUV 4:2:0, so this patch adds support for transparency
using 4:2:2, 4:4:4, RGB, and their high bit depth variants.

It is not quite clear if the alpha channel should be encoded using the
same pixel format as the normal channels, or it should be always YUV 4:2:0. I
sticked to 4:2:0.

Unfortunately the browsers I tested (chrome, firefox) only support 4:2:0
properly, so let's require an experimental flag to generate files with the new,
more exotic pixel formats.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Marton Balint d373dfe157 avcodec/libvpxdec: add support for decoding pixel formats other than YUV420 with alpha
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Marton Balint 693ca902c1 avformat/matroskaenc: write AlphaMode flag for all VP8 and VP9 pixel formats with alpha
Let's check the pixel format descriptor flags instead of hardcoding a specific
pixel format.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Marton Balint 9515cb236b avformat/matroskaenc: only write AlphaMode for VP8 and VP9
AlphaMode should indicate whether the BlockAdditional Element with BlockAddID
of "1" contains Alpha data, as defined by to the Codec Mapping for the `CodecID`.

Only VP8 and VP9 Codec Mappings define this, so writing it for all codecs with
a pixel format of YUVA420P, or for codecs other than VP8/VP9 (if the alpha_mode
metadata entry was set) was wrong.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-15 20:28:31 +01:00
Michael Niedermayer 3ec03b847b swscale/rgb2rgb_template: fix signed shift into sign bit
Fixes: left shift of 255 by 24 places cannot be represented in type 'int'
Fixes: 471591904/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5141341165387776

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 19:26:27 +00:00
Michael Niedermayer 0e3ac1f4f9 swresample: Check ch layouts in swr_alloc_set_opts2()
This way we can error out earlier

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:16:12 +01:00
Michael Niedermayer 906e3edc70 swresample: Check user chlayout in swr_set_matrix()
All callers in FFmpeg check this already, but it is a public
function that can plausibly be given more channels.
In which case out of array writes would occur

This is likely a regression from when channel layouts where extended
to support more than 64 channels

Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:16:11 +01:00
Michael Niedermayer 0d59620bff avcodec/bmp: Move picture allocation after some checks
Fixes: Timeout
Fixes: 479872424/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_BMP_DEC_fuzzer-5311478919135232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:09:54 +01:00
Michael Niedermayer 50adb62670 avcodec/bmp: fix indention
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 20:09:54 +01:00
Michael Niedermayer 33b3dbaf15 avcodec/exr: Handle axmax like bxmin in 04d7a6d3db
Fixes: out of array access
Fixes: 418335931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-6718455383654400
Fixes: 471611870/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_EXR_DEC_fuzzer-6645447302381568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 19:57:42 +01:00
Michael Niedermayer 6ee3e59ce2 avformat/flvdec: Check *size in cts parsing
Fixes: Assertion buf_size >= 0 failed
Fixes: 471553942/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-5982849812725760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-15 06:37:19 +00:00
Andreas Rheinhardt 61b1fb1d00 .forgejo/workflows: Test hardcoded tables
Should detect breakages like the one caused by commit
d8ffec5bf9
(fixed in 1d47ae65bf).

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-14 20:15:13 +01:00
Andreas Rheinhardt 4ef5efc2b6 avcodec/aacps_tablegen_template: Fix hardcoded tables with assert-level 2
In this case an av_assert2 in lavu/softfloat.h pulls in
a dependency on av_log(), which is not available at all,
because the tablegen tools are created for and run on
the host, not the target. This leads to linking failures.

Fix this by undefining ASSERT_LEVEL before the inclusion
of avassert.h.

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-14 20:14:47 +01:00
Michael Niedermayer be1fd6d9d4 avcodec/prores_raw: Tiles of width less than 16 result in undefined behavior
Fixes: passing zero to __builtin_clz(), which is not a valid argument
Fixes: 471569982/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_RAW_DEC_fuzzer-5832576221904896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-14 18:53:08 +00:00
Michael Niedermayer 2ad078b589 avcodec/exif: Check that the values read exist in the input
Fixes: Timeout
Fixes: 471568865/clusterfuzz-testcase-minimized-ffmpeg_dem_AVI_fuzzer-4864048211755008
Fixes: 471951381/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_DEC_fuzzer-5069855998148608
Fixes: 471472005/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AMV_DEC_fuzzer-4660042365468672
Fixes: 471591900/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WEBP_fuzzer-5083936243122176
Fixes: 471593729/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MJPEG_DEC_fuzzer-5401314998943744

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-14 18:52:43 +00:00
Valerii Zapodovnikov 4eca335d94 avcodec/hevc/hevcdec: take into account YUV400 in block length
Also move some definitions around.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
2026-02-14 16:23:16 +00:00
Stéphane Cerveau a2489b3ac6 configure: provide vulkan incflags
This patch allows to use pkgconfig cflags
for vulkan in check_cpp_condition as the vulkan
sdk might be installed in different place than
system wide.

See https://vulkan.lunarg.com/doc/sdk/latest/linux/getting_started.html
2026-02-14 12:24:39 +00:00
Sam.Richards@taurich.org 677cf95ea4 Initial checkin of OCIO filter.
Initial checkin of OCIO filter.

Initial checkin of OCIO filter.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Change for the right C++ library, should work on linux too.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding inverse when using display/view.

Removed comments.

Removed code that was setting the CICP values. Hopefully this can be done through OCIO at some point.

Config cleanup - need a modified require_cpp to handle namespacing.

Switch to using require_cpp so that namespace can be used.

Adding documentation.

Sadly a bit of linting went in here, but more importantly added a threads option to split the image into horizontal tiles, since OCIO was running rather slow.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding context parameters.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Add the OCIO config parameter.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Make the min threads 1 for now, reserve 0 for later if we can automatically pick something.
Also added a few comments.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

This is using ffmpeg-slicing.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding OCIO filetransform.

Making sure everything is using av_log rather than std::cerr.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Updating the tests so they would work without additional files.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding the file-transform documentation.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Adding copyright/license info.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Removing tests, since this is optional code.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Code cleanup.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Typo.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

I went the wrong way, av_log is expecting \n

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Fix indenting to 4 spaces.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Fixing lint issues and a spelling mistake.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Code formatting cleanup to match conventions.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>

Whitespace removal.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>
2026-02-14 12:21:10 +00:00
James Almer a7522f3fef avcodec/libvorbisenc: export padding samples if needed
Based on code from libopus encoder wrapper.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-13 11:50:32 -03:00
James Almer 23dce39d5a avcodec/libvorbisenc: export initial padding during init()
Priming samples don't depend on the contents of the first frame passed to the
encoder but rather on encoder configuration, so use dummy vorbis_dsp_state and
vorbis_block with the main encoder vorbis_info to generate a packet we can then
parse to derive the initial padding.

Muxers will now be aware of the initial padding before receiving packets, which
will allow them to write proper container headers during init without any extra
considerations like having to do a second pass or rewrite during write_trailer.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-13 11:50:32 -03:00
Andreas Rheinhardt 0a629df0a8 avcodec/ratecontrol: Move emms_c() to the only callsite needing it
Namely to one of the three callsites in snowenc.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 059654a73b avcodec/ratecontrol: Remove unnecessary emms_c()
ff_rate_control_init/uninit() are only called during
codec init or close and no DSP calls happen in these,
so there is no need to reset the floating point state.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt fe1742618d avcodec/snowenc: Remove redundant emms_c()
This emms_c() has been superseded by the one added
a few lines above in 2c1d38d1e1.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt c5d9711be4 avcodec/mpegvideoenc: Remove MMX from comment
The MMX code has been removed in 5ef613bcb0
and MMX was not used for most cpus even before then.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt fe0d8cb3e4 avcodec/x86/dirac_dwt: Remove MMX in comment
Forgotten in 5e332fe35c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 2e843c0e9a doc/optimization: Fix incorrect statement
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 509be049b6 swresample/{audioconvert,rematrix}: Don't check for HAVE_MMX
There are no MMX functions left in all of libswresample, so checking
for it makes no sense. Notice that configure currently disables x86asm
if mmx is disabled, so the check is also redundant.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 374b3ab03c swresample/x86/audio_convert: Remove remnants of MMX
Forgotten in 2b94f23b06.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:33 +01:00
Andreas Rheinhardt 66766bb1c7 avutil/avassert: Deprecate av_assert0_fpu()
Said function has presumably been added in order to check
that we have successfully reset the floating point state
after having violated the ABI/calling convention by not
issuing emms in our MMX DSP routines.

Yet the ability to check this should not have been made public,
because there is no external need for it and because the
function does not even always achieve what its documentation
claims to do: It only works when inline assembly is available.
It should have been implemented in emms.h like emms_c()
(which is where a replacement should be put if there is still
ABI-violating MMX code when av_assert0_fpu() is removed).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-13 09:21:02 +01:00
stevxiao 680f32c4c9 avfilter/dnn: add PyTorch version check for XPU initialization in torch backend
Starting with PyTorch 2.6, the hooks API was redesigned so it no longer depends on the device type.

As part of this change, the XPU initialization function was renamed from initXPU() to init().

Add version check to support both old and new LibTorch versions.

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-12 10:48:58 -05:00
stevxiao 57fe259773 avfilter/dnn: add synchronous execution path in torch backend
When using `dnn_processing` filter with torch backend, FFmpeg hangs indefinitely because no inference is actually performed.
Resolve this problem by add "else" branch for synchronous execution path.

Usage:
    ffmpeg -i input.mp4 -vf scale=224:224,format=rgb24,dnn_processing=dnn_backend=torch:model=sr_model_torch.pt:device=cpu output.mp4
2026-02-12 20:30:53 +08:00
James Almer ff98352c3d avcodec: set skip_samples in generic code
Decoders should only worry about exporting AVCodeContext->delay during init.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-12 09:59:54 -03:00
James Almer e1484a30e5 avformat/dtshddec: properly support priming and padding samples
Don't just export initial_padding, but also take it into account for timestamps
by adjusting the stream's start_time. Also, export the padding samples in a way
that's actually supported, as currently trailing_padding is unused so no user
will look at it.

For the sake of not reducing coverage and because the lossy tests have reference
files that contain the priming samples, add the skip_manual flags2 to the tests
so we still output them. A new ffprobe call will ensure the demuxer behavior is
tested too.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-12 09:59:54 -03:00
James Almer 70f0ddd2ca tests/fate/dca: use stream_demux for lossless tests
Unlike md5, the adler32 hash shows the frames with priming samples, which will
be useful in the following commits.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-12 09:59:54 -03:00
Andreas Rheinhardt afb374f109 avcodec/dpcm: Remove unnecessary flush callbacks
{INTERPLAY,ROQ,XAN}_DPCM does not use the stored samples at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 11:06:33 +01:00
Andreas Rheinhardt e3ec6322bb avcodec/dpcm: Avoid trailing '_' in macro parameters
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 11:06:33 +01:00
Andreas Rheinhardt 66c7bf3bf8 avcodec/adpcmenc: Don't advertise ineffective options
ADPCM_ARGO, ADPCM_IMA_QT and ADPCM_SWF don't use
the block_size option at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
Andreas Rheinhardt b764f40eaa avcodec/adpcmenc: Check sample rates, ch layouts generically
This also advertises the supported sample rates/channel layouts.
For ADPCM_IMA_AMV, it actually fixes the advertised channel layouts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
Andreas Rheinhardt 77d7891052 avcodec/adpcmenc: Mark unreachable code as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-12 10:34:19 +01:00
James Almer 10acab8df5 avcodec/hevc/hevcdec: report unparsed unknown NALUs types at verbose level
Reduces spamming at default log level.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-11 21:57:20 -03:00
Kacper Michajłow 3b4281e919 avcodec/hevc/hevcdec: skip logging 'Skipping NAL unit 63'
We know that this is Dolby Vision Enhancement Layer and while it's not
handled, we can just reduce log spam for this, as it's if fact
recognized.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:56:21 +00:00
Kacper Michajłow fa36645f7e avcodec/bsf/dovi_rpu: fix typo
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:56:21 +00:00
Kacper Michajłow 590e2b1894 vf_libplacebo: sync peak detection parameters with upstream
Fixes peak detection for samples like in https://github.com/haasn/libplacebo/issues/358

This might introduce flickering on some other samples, but was agreed
upstream that they are better overall.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-12 00:12:48 +00:00
Rost Kurylo d07d2a4ee1 doc/protocols: Document type option for unix domain sockets
Signed-off-by: Rost Kurylo <rost.kurylo@netint.ca>
2026-02-11 20:41:49 +00:00
Rost Kurylo 95101ecc65 avformat/unix: Fix 'operation unsupported' error when reading from unixgram sockets
Sockets of type SOCK_DGRAM don't support listen(), so it was
impossible to read from "unixgram" sockets in ffmpeg.

Signed-off-by: Rost Kurylo <rost.kurylo@netint.ca>
2026-02-11 20:41:49 +00:00
Nicolas Gaullier f9bf45b8fd avformat/isom_tags: add specific fourccs for in24/in32 LE
Add support for decoding 42ni and 23ni in mov/mp4.

Note that in24/in32 can be either LE or BE thanks to enda atom,
so this patch leaves the muxer unchanged.

Fixes #21445.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-02-11 20:39:31 +00:00
John Chadwick 8b9b71494b tests/fate/image: Add psd-rgbxx
This is an rgb test image with two auxilliary channels and no alpha
channels.
2026-02-11 20:35:20 +00:00
John Chadwick a469598191 avcodec/psd: Support auxiliary channels
Photoshop documents can contain additional "auxiliary" channels that
don't take part in layer compositing, therefore, using the channel count
to determine the presence of an alpha channel in the merged image is
incorrect. Instead, as per the PSD specification, use the sign of the
layer count (present in the layers and masks section) to determine if
there is an alpha channel, then determine the number of primary channels
using both the presence of the alpha channel and the pixel format.
2026-02-11 20:35:20 +00:00
Andreas Rheinhardt 7e3781e3ca avcodec/libcodec2: Remove always-false checks
Already checked via CODEC_SAMPLERATES and CODEC_SAMPLEFMTS.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:38 +01:00
Andreas Rheinhardt 12c2a4e117 avcodec: Don't set AVCodec.sample_fmts,ch_layouts for decoders
It is pointless for them given that these values will
be overridden by the decoder lateron anyway.
The only exceptions to this are scenarios where the decoder
actually checks request_sample_fmt or where there are both
fixed- and floating point decoders.

(IMO something like get_format() for audio would be better for
both cases.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:35 +01:00
Andreas Rheinhardt 028d9d3997 avcodec/sbcdec: Don't set encoder-only fields
ch_layouts, sample_fmts and supported_samplerates
are of no use for a decoder, so don't set them.
In this case this fixes an inconsistency:
ch_layouts contained mono and stereo, yet lateron
the AVCodecContext's ch_layout is always populated
with an AV_CHANNEL_ORDER_UNSPEC layout.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:31 +01:00
Andreas Rheinhardt f648dd0e8a avcodec/adpcm: Don't set AVCodec.sample_fmts
It is unnecessary for a decoder (the sample fmt is
set lateron during init and the user has no choice
over this (even for the decoders where sample_fmts
contains two entries).

(This also fixes the ADPCM_DECODER macro: It's second
and third parameters were called "name" and "sample_fmts",
yet the second argument always contained the sample fmts.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 12:07:07 +01:00
Andreas Rheinhardt 3a7c09eb39 avcodec/x86/mpegvideoencdsp_init: Port draw_edges to SSSE3
Benchmarks:
draw_edges_8_1724_4_c:                                2672.2 ( 1.00x)
draw_edges_8_1724_4_mmx:                              3191.5 ( 0.84x)
draw_edges_8_1724_4_ssse3:                            2179.6 ( 1.23x)
draw_edges_8_1724_8_c:                                2852.3 ( 1.00x)
draw_edges_8_1724_8_mmx:                              3683.0 ( 0.77x)
draw_edges_8_1724_8_ssse3:                            2225.7 ( 1.28x)
draw_edges_8_1724_16_c:                               4169.4 ( 1.00x)
draw_edges_8_1724_16_mmx:                             4665.9 ( 0.89x)
draw_edges_8_1724_16_ssse3:                           2765.8 ( 1.51x)
draw_edges_128_407_4_c:                               1126.6 ( 1.00x)
draw_edges_128_407_4_mmx:                              943.9 ( 1.19x)
draw_edges_128_407_4_ssse3:                            925.7 ( 1.22x)
draw_edges_128_407_8_c:                               1208.8 ( 1.00x)
draw_edges_128_407_8_mmx:                             1119.1 ( 1.08x)
draw_edges_128_407_8_ssse3:                            997.8 ( 1.21x)
draw_edges_128_407_16_c:                              1352.4 ( 1.00x)
draw_edges_128_407_16_mmx:                            1368.7 ( 0.99x)
draw_edges_128_407_16_ssse3:                          1148.3 ( 1.18x)
draw_edges_1080_31_4_c:                                228.5 ( 1.00x)
draw_edges_1080_31_4_mmx:                              240.8 ( 0.95x)
draw_edges_1080_31_4_ssse3:                            226.7 ( 1.01x)
draw_edges_1080_31_8_c:                                411.1 ( 1.00x)
draw_edges_1080_31_8_mmx:                              432.9 ( 0.95x)
draw_edges_1080_31_8_ssse3:                            403.2 ( 1.02x)
draw_edges_1080_31_16_c:                              1121.2 ( 1.00x)
draw_edges_1080_31_16_mmx:                            1124.9 ( 1.00x)
draw_edges_1080_31_16_ssse3:                          1125.4 ( 1.00x)
draw_edges_1920_4_4_c:                                 310.8 ( 1.00x)
draw_edges_1920_4_4_mmx:                               311.6 ( 1.00x)
draw_edges_1920_4_4_ssse3:                             311.6 ( 1.00x)
draw_edges_1920_4_4_negstride_c:                       307.0 ( 1.00x)
draw_edges_1920_4_4_negstride_mmx:                     306.7 ( 1.00x)
draw_edges_1920_4_4_negstride_ssse3:                   306.7 ( 1.00x)
draw_edges_1920_4_8_c:                                 724.2 ( 1.00x)
draw_edges_1920_4_8_mmx:                               724.9 ( 1.00x)
draw_edges_1920_4_8_ssse3:                             717.3 ( 1.01x)
draw_edges_1920_4_8_negstride_c:                       719.2 ( 1.00x)
draw_edges_1920_4_8_negstride_mmx:                     717.1 ( 1.00x)
draw_edges_1920_4_8_negstride_ssse3:                   710.9 ( 1.01x)
draw_edges_1920_4_16_c:                               1752.9 ( 1.00x)
draw_edges_1920_4_16_mmx:                             1754.6 ( 1.00x)
draw_edges_1920_4_16_ssse3:                           1751.1 ( 1.00x)
draw_edges_1920_4_16_negstride_c:                     1783.2 ( 1.00x)
draw_edges_1920_4_16_negstride_mmx:                   1778.2 ( 1.00x)
draw_edges_1920_4_16_negstride_ssse3:                 1768.3 ( 1.01x)

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-11 11:15:06 +01:00
Michael Niedermayer 4f97e52042 avformat/cafdec: Check nb_entries in read_info_chunk()
Fixes: Timeout
Fixes: 477315122/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5274792315125760

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-11 01:17:30 +00:00
Andreas Rheinhardt f6d89a7bed avformat/spdif: Make enum IEC61937DataType at least 16bits
Fixes the spdif-dca-master FATE-test when compiling with
-fshort-enums.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt f0392c908c avcodec/flacenc: Use int for AV_OPT_TYPE_INT
Necessary for -fshort-enums.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt b08e849af8 avfilter/lavfutils: Avoid AVDictionary
Set thread_type directly instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt 373c86bac8 swscale/utils: Improve type-safety
SwsContext.{src,dst}_format is int (but uses enum AVPixelFormat)
values, so the accesses need to be performed using an int
for -fshort-enums support.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt fb8a12db17 avutil/opt: Improve type-safety
In particular, make this code -fshort-enums compatible.
The branch can be optimized away by compilers when
sizeof(enum AVPixelFormat) == sizeof(enum AVSampleFormat).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt 2273902be8 avfilter/lavfutils: Avoid copying frame in ff_load_image()
Return the data in an AVFrame instead. This is what several users
({find,cover}_rect*) want anyway. This also avoids accessing
AVFrame.format (an int) via an enum AVPixelFormat*.

*: This commit actually avoids two frame copies For find_rect:
av_frame_clone() contained an implicit alloc+copy.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt 31173f148c avfilter/vf_removelogo: Properly handle allocation error
Don't rely on av_image_copy_plane() handling a NULL dst
gracefully.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:46 +01:00
Andreas Rheinhardt 0c7424e817 avfilter/filters: Restrict ff_fmt_is_in() to enum AVPixelFormat
Also rename it to ff_pixfmt_is_in(). This is more type-safe;
in particular, it is required to support -fshort-enum.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 19:44:43 +01:00
Andreas Rheinhardt bf44a683eb fftools/ffmpeg_mux_init: Improve type-safety
This makes fftools -fshort-enums compatible.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 16:36:58 +01:00
Andreas Rheinhardt fcfb33922f avformat/cafenc: don't keep track of nb packets ourselves
Just reuse AVStream.nb_frames.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 11:32:56 +01:00
Andreas Rheinhardt 96475bfa21 avformat/cafenc: Simplify writing pakt box
Assemble it already in caf_write_packet(). This has the advantage
of reducing the amount of buffers used; it also allows to avoid
a seek when writing the trailer and avoids function call overhead
(for the avio_w8(); it also reduces codesize).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 11:31:17 +01:00
Michael Niedermayer 38230db7b9 avcodec/vp9: Reallocate on resolution change which does not change tile_cols
Fixes: out of array access on resolution change with slices threads
Fixes: VULN-10/poc.ivf

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 01:30:42 +01:00
Michael Niedermayer 521d18cea3 avformat/img2dec: Check avio_size() for failure
More complete fix for #YWH-PGM40646-32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 01:19:00 +01:00
Michael Niedermayer 19c78cd6d9 avformat/mpegtsenc: Check remaining space in SDT
Fixes: out of array access
Fixes: VULN-8

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 01:07:19 +01:00
Michael Niedermayer ca1c1f29ce avformat/img2enc: Check split planes packet size
Fixes: out of array read
Fixes: VULN-6/poc.raw

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 00:54:41 +01:00
Michael Niedermayer b740b85872 avformat/yuv4mpegen: Sanity check input packet frame dimensions
Fixes: out of array access if a filter-graph is used the injects changing dimensions

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-10 00:40:52 +01:00
Ramiro Polla 9ee6136ece avcodec/mjpegdec: remove start_code field from MJpegDecodeContext
Instead, pass it as a parameter to the only function that uses it.
2026-02-09 17:52:01 +00:00
Andreas Rheinhardt 1218a8a922 avcodec/rangecoder: Fix indentation
Forgotten after 832649986c
and d147b3d7ec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-09 17:36:40 +00:00
James Almer 2e79453549 tests/fate/id3v2: don't use a reference file for fate-id3v2-invalid-tags
This fixes running the test under Valgrind, where more, unrelated lines are
printed, making the comparison fail.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-09 14:04:22 +00:00
Niklas Haas be88553fc8 fftools/ffmpeg_demux: mirror DemuxStream name to AVFormatContext
Results in basically the same name, except less ambiguous because
it includes the input index.
2026-02-09 14:01:14 +00:00
Niklas Haas f2b13f783a avformat: add AVFormatContext.name
Analog to AVFilterContext. May be used to set a custom logging name to
disambiguate multiple AVFormatContext instances in the logs.
2026-02-09 14:01:14 +00:00
Michael Niedermayer 9bfa1635ae avformat/iff: Error out with 0 channel loudspeaker configuration
Fixes: division by 0
Fixes: 478005965/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-5748337088462848
Fixes: 472226169/clusterfuzz-testcase-minimized-ffmpeg_dem_IFF_fuzzer-4528777763028992

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-09 04:25:04 +00:00
Ted Meyer a58cb16e27 Fix overflow in STSD parser
Reset `sc->stsd_count` before parsing entries. This number doesn't get
reset, which means that multiple parse passes can increment it past the
`sc->extradata` array end and cause OOB writes.
2026-02-09 02:38:16 +00:00
James Almer 303fd126a8 avformat/iamf: replace av_assert0(0) with av_unreachable
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-08 21:58:06 -03:00
James Almer 8665748584 avformat/iamf_reader: sanitize block and subblock durations and count
Abort earlier if subblock durations are inconsistent with their containing block,
and ensure each subblock duration is at least 1.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-08 21:58:06 -03:00
James Almer 34ac6f6b07 avformat/iamf_parse: sanitize block and subblock durations and count
Abort earlier if subblock durations are inconsistent with their containing block,
and ensure each subblock duration is at least 1.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-08 21:58:06 -03:00
James Almer 706d4e4736 avutil/iamf: stop setting parameter definition block defaults
It was done for the sake of having subblock_duration not be zero as the spec
forbids that value, but harcoding it to any arbitrary value is no better
considering the user is meant to fill the entire structure.

This helps speeding up the function when trying to allocate a struct with a
huge amount of blocks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-08 21:58:06 -03:00
Hassan Hany 273b161a98 avcodec/exif: skip EXIF entries with invalid TIFF field type 0
EXIF IFD entries with TIFF field type 0 are invalid per the specification.
Without a check, exif_read_values() fails to allocate entry->value,
causing an out of memory error.

This patch skips such entries early during parsing, allowing decoding
to continue normally.

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/21623
2026-02-08 19:56:20 +00:00
Michael Niedermayer 5f84a7263e avcodec/adpcm: Check input buffer size
Larger values will lead to integer overflows in intermediates
No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-08 14:46:56 +00:00
Michael Niedermayer a5007428e8 avformat/scd: Use ffio_read_size()
Fixes: use of uninitialized memory
Fixes: 471771529/clusterfuzz-testcase-minimized-ffmpeg_dem_SCD_fuzzer-5328203515494400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-08 02:25:14 +01:00
Niklas Haas b8daba42cd avformat/http: report connection statistics
Helpful to track the impact of options like -multiple_requests, -probing_size
or -short_seek_size.
2026-02-07 10:02:36 +00:00
Niklas Haas 4f5d91e43f avformat/http: allow limiting initial request size
Sometimes, HTTP sources require a lot of seeking during probing / header
parsing (especially for formats like MXF). Currently, we need to completely
tear down and re-establish the connection most times this happens, which puts
a lot of stress on the network stack and also results in transmission of
possibly many unnecessary bytes.

This patch adds an option to allow FFmpeg to request partial ranges during
the initialization stage. This is done until the initial request size is fully
read, after which we fall back to the normal behavior (i.e. infinite streaming
via an unbounded request).

The usefulness of this is limited without also specifying -multiple_requests 1,
since otherwise there is little point to requesting partial ranges to begin
with. (However, it is semantically independent, so we keep it that way.)
2026-02-07 10:02:36 +00:00
Niklas Haas e03b034e45 avformat/http: re-use keep-alive connection for small seeks
When the previous reply was a partial response (e.g. due to a seek to the
end of the file), and the remaining data from that partial response is
below the short seek size threshold, we can serve this seek by just draining
that data and re-using the existing connection.

This can currently only happen when using keep-alive connections
(-multiple_requests 1) and seeking from the end of the file to somewhere
else, in which case the file's tail can be drained and the connection re-used.

Under other circumstances, however, we still need to force a reconnection,
because we do not yet send partial range requests. (This will be changed in the
following commit)

We need to take special care not to regress the existing fallback logic
for when `http_open_cnx` fails, so here is a quick case analysis:

non-drain path:
- identical to the current

soft drain fails: (ffurl_read error path)
- s->hd = old_hd = NULL
- http_open_cnx() always opens a new connection
- on failure, old buffer is restored and s->hd remains NULL

soft drain succeeds, http_open_cnx() fails:
- s->hd is set to NULL by http_open_cnx() failure path
- old_hd was never set, so remains NULL
- old buffer is restored, s->hd remains NULL

In either case, the outcome that any (previously valid) buffer is left as-is,
the offset is unchanged, and the connection ends up closed (s->hd == NULL).
This is okay to do after the previous change to http_buf_read, which allows
it to internally re-open the connection if needed.
2026-02-07 10:02:36 +00:00
Niklas Haas bf1722a9c6 avformat/http: request more data after partial response
If the Content-Range indicates a smaller range than what we expected,
we should send a new request for the remainder before attempting to read
more.

Again, this commit is theoretically non-functional on its own, since any
conforming HTTP server should give us the entire range we asked for in the
first place, but it is semantically independent from and prepares us for the
following changes.
2026-02-07 10:02:36 +00:00
Niklas Haas 6336fa3335 avformat/http: return EIO if s->hd is NULL
This could conceivably happen currently if the user tries reading more
bytes after the last chunk has already been received. In this case,
we currently segfault - but simply returning AVERROR(EIO) seems more
reasonable and lets the higher end retry the connection in this case.
2026-02-07 10:02:36 +00:00
Niklas Haas ca2c5ff412 avformat/http: parse range size from Content-Range header
In the event that the range returned is smaller than the true filesize, we
should only expect to receive that many bytes - not the entire rest of the
file.

This commit is theoretically non-functional on its own, since any conforming
HTTP server will always return us the full file range, but I wanted to split
it off from the subsequent changes in order to make review easier.
2026-02-07 10:02:36 +00:00
Niklas Haas 19cae9151c avformat/http: print error on HTTP response failure
This currently fails silently with zero indication of what the problem might
be, which tripped me up a bit while debugging.
2026-02-07 10:02:36 +00:00
Niklas Haas 5f95a1e714 avformat/http: fix noop seek check
This fails to consider the case of whence == SEEK_END and the resulting
offset happening to exactly match the current position.

Reorder the check to compute the target position first, then compare.
2026-02-07 10:02:36 +00:00
Brad Smith c352a9ab02 avutil/cpu: add CPU feature detection for AArch64 CRC32 on OpenBSD
Signed-off-by: Brad Smith <brad@comstyle.com>
2026-02-06 14:24:01 -05:00
Andreas Rheinhardt 0fefecd53f Revert "avcodec/opus/parse: export the packet and extradata parsing functions"
This reverts commit aa20d7b3e8.

Adding these avpriv functions is absolutely overblown: Muxers
can get the desired duration in a few lines themselves.
In particular, using the parse functions from this file
necessitated parsing the extradata (and entailed exporting
the parsing function), although it was only used to know
whether the frames are self-delimiting, but everything of
interest to a muxer does not depend on this at all.

The commit to be reverted also made several structures
part of the ABI, which should be avoided in general.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:09:15 +01:00
Andreas Rheinhardt 12747e6296 avformat/matroskaenc: Parse Opus packet durations ourselves
This avoids avpriv functions from lavc/opus/parse.c
(which parse way more than we need, necessitating
parsing the extradata).
It furthermore makes the output of the muxer consistent,
i.e. no longer depending upon whether the Opus parser
or decoder are enabled (the avpriv functions would just
return AVERROR(ENOSYS)).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:05:14 +01:00
Andreas Rheinhardt 853843d86f avcodec/opus/parse: Move frame_duration tab into a file of its own
This is in preparation for duplicating it into libavformat.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-06 14:04:50 +01:00
James Almer 3ab8b976c1 avformat/matroskaenc: parse Opus packets to write proper durations
Before this patch, the last packet in the affected fate test would be written
without a BlockDuration element despite the packet's duration being shorter
than the Opus frame size.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer aa20d7b3e8 avcodec/opus/parse: export the packet and extradata parsing functions
Needed for the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 11e9a325ec tests/fate/matroska: remove copyts from audio tests
It's not needed after the previous commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 0880458e4c avformat/matroskadec: take into account priming samples in audio tracks
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
James Almer 1dd8547193 avformat/demux: don't overwrite already set packet durations with parser ones
Following up on b613eebe78, if a demuxer that exports complete frames sets a
duration, don't overwrite it from the output of the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-05 23:21:49 -03:00
Michael Niedermayer 8f57b04fe5 avcodec/hevc/sei: Use get_bits64() in decode_nal_sei_3d_reference_displays_info()
Fixes: Assertion n>=0 && n<=32 failed at ./libavcodec/get_bits.h:426
Fixes: 468435217/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4644127078940672

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 20:20:08 +00:00
Michael Niedermayer f112ae503e avformat/hls: Check for integer overflow with #EXTINF:
Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:59:29 +00:00
Michael Niedermayer af86f0ffcc avcodec/dca_xll: Clear padding in ff_dca_xll_parse()
Fixes: Use of uninitialized memory
Fixes: 472020020/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_DEC_fuzzer-6433045331902464

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:12:46 +01:00
Michael Niedermayer 00b4d67812 avformat/demux: Allow non opened codec in has_decode_delay_been_guessed()
Fixes: assertion failure
Fixes: 472097507/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6016386662203392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:01:31 +01:00
Michael Niedermayer 5fa7d588f5 avformat/flvdec: Check need_context_update when audio codec changes
We did check video codecs but not audio
Fixes: Assertion failure (on codec_id) in parser.c
Fixes: 472097507/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6016386662203392

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 18:01:31 +01:00
Michael Niedermayer c6c6874c44 avfilter/vf_find_rect: Check x/y min/max
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:08:30 +01:00
Michael Niedermayer 12321e5eba vfilter/vf_find_rect: Clamp x/y min/max to valid values
Fixes: #YWH-PGM40646-15
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 17:08:30 +01:00
Michael Niedermayer ee7a15f0a2 tools/target_dec_fuzzer: adjust threshold for MAGICYUV
Fixes: Timeout
Fixes: 471975516/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_DEC_fuzzer-5987279668838400

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:50:26 +01:00
Michael Niedermayer 189bc0aaf5 avcodec/dxv: Clear tex_data padding on reallocation
dxv assumes that newly reallocated memory in tex_data is not uninitialized
thus we have to do that too in case of reallocation in ff_lzf_uncompress()

Fixes: 475000819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5571269310611456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:29:08 +01:00
Michael Niedermayer 0f35146e27 avcodec/lzf: Remove size messing from ff_lzf_uncompress()
size represents the output size
randomly changing it but not reseting it on errors leaks uninitialized memory.

Fixes: 475000819/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5571269310611456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:29:08 +01:00
Michael Niedermayer 5db50e8775 avcodec/ffv1enc: refine end condition
In the case where the last sorted value was -1u and we where on the first
pass of run1 we failed to fill the last few values of bitmap

No real world testcase is known

Fixes: use of uninitialized memory
Fixes: 460333808/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-6370167888347136

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 16:07:13 +01:00
Michael Niedermayer 11a5afea31 avcodec/dca_xll: Check get_rice_array()
Fixes: use of uninitialized memory
Fixes: 451655450/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DCA_DEC_fuzzer-6527248623796224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-05 14:37:59 +01:00
Zane van Iperen b628cafd48 libavformat/argo_brp: fix incorrect ASF chunk header read
Was inadvertently broken in the switch to ffio_read_size().

Fixes: 6dd83fab44

PR: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21650

Reviewed-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2026-02-05 22:19:48 +10:00
Anthony Bajoua 627da1111c libavformat/movenc: Uses dynamic buffers for fragmented chunks 2026-02-04 18:45:15 -08:00
Jun Zhao 27dd2f1c70 lavc/hevc: fix missing # in ldrsw immediate offset
The ldrsw instruction requires immediate offset with # prefix.
This fixes the syntax error introduced in commit 26752368f0
(aarch64/h26x: Add put_hevc_pel_bi_w_pixels) where the
load_bi_w_pixels_param macro was added.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-05 09:13:22 +08:00
WyattBlue e48eaa8c62 avfilter/af_whisper: Add max_len parameter 2026-02-04 21:26:02 +00:00
Marton Balint 75f5d79f6a fftools/ffprobe: add base64 data dump format
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint ca6f3f3c17 fftools/ffprobe: use an AVTextFormatOptions struct in AVTextFormatContext
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint b1f14cbd0e fftools/ffprobe: fatorize dumping hexdump as data dump
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint 30be62b711 fftools/ffprobe: print AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL id and data
Data is only printed if -show_data is used.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Michael Niedermayer d1a43f1486 avutil/dovi_meta: Document valid range for index of av_dovi_get_ext()
Every use case in libavcodec already checks the index

Found-by: 이동준 <ldj6192@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 15:25:18 +00:00
Andreas Rheinhardt 462fac0e0f tests/checkasm/vc1dsp: Use correct function argument
Fixes a stack-buffer overflow (detected by ASAN) when benching
vc1dsp.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-04 13:28:49 +01:00
Zhao Zhili e250854ecf aarch64/h264pred: disable inefficient functions
These assembly optimizations have been identified as "performance
regressions." Due to advancements in modern CPU micro-architectures
and compiler optimization the C implementations now consistently
outperform these handwritten routines.

Test Name          	 A55-clang       M1             A76-gcc-14      A510-clang      A715-clang      X3-clang
--------------------------------------------------------------------------------------------------------------------
pred8x8_dc_8_neon        55.9 ( 0.79x)!  0.2 ( 0.31x)!  35.7 ( 0.63x)!  98.3 ( 0.37x)!  35.9 ( 0.45x)!  33.6 ( 0.38x)!
pred8x8_dc_10_neon       57.0 ( 1.04x)   0.3 ( 0.36x)!  35.9 ( 0.94x)!  98.2 ( 0.53x)!  35.8 ( 0.58x)!  33.2 ( 0.50x)!
pred8x8_dc_128_8_neon    26.0 ( 0.69x)!  0.1 ( 0.43x)!  15.3 ( 0.73x)!  46.4 ( 0.36x)!  10.6 ( 0.48x)!  10.3 ( 1.09x)
pred8x8_dc_128_10_neon   25.3 ( 0.99x)!  0.1 ( 0.42x)!  19.3 ( 0.48x)!  44.5 ( 0.42x)!  10.0 ( 0.61x)!  11.0 ( 1.00x)
pred8x8_left_dc_8_neon   46.9 ( 0.72x)!  0.2 ( 0.26x)!  30.2 ( 0.49x)!  71.4 ( 0.39x)!  29.8 ( 0.35x)!  26.5 ( 0.44x)!
pred8x8_left_dc_10_neon  45.4 ( 0.82x)!  0.2 ( 0.29x)!  28.1 ( 0.67x)!  70.2 ( 0.47x)!  30.0 ( 0.38x)!  26.5 ( 0.43x)!
pred16x16_dc_8_neon      74.4 ( 1.34x)   0.3 ( 0.62x)!  44.7 ( 0.89x)!  128.0 ( 0.79x)! 48.5 ( 0.67x)!  39.4 ( 0.71x)!
pred16x16_dc_128_8_neon  37.9 ( 0.79x)!  0.1 ( 0.60x)!  20.1 ( 0.80x)!  41.8 ( 0.46x)!  16.2 ( 0.81x)!  12.8 ( 0.95x)!
pred16x16_left_dc_8_neon 69.9 ( 1.19x)   0.3 ( 0.46x)!  49.6 ( 0.54x)!  116.8 ( 0.62x)! 52.8 ( 0.45x)!  44.2 ( 0.51x)!
pred8x8_hori_8_neon      30.6 ( 1.39x)   0.1 ( 0.45x)!  19.4 ( 0.81x)!  71.0 ( 0.50x)!  15.9 ( 0.55x)!  12.2 ( 0.94x)!
pred8x8_hori_10_neon*    29.3 ( 1.82x)   0.1 ( 0.59x)!  18.5 ( 1.56x)   68.9 ( 0.64x)!  15.8 ( 0.62x)!  11.8 ( 0.97x)!
pred8x8_top_dc_8_neon    35.8 ( 0.96x)!  0.1 ( 0.59x)!  16.8 ( 0.81x)!  58.9 ( 0.44x)!  11.3 ( 0.89x)!  11.4 ( 0.99x)!
pred8x8_top_dc_10_neon   37.4 ( 1.24x)   0.1 ( 0.92x)!  20.4 ( 0.81x)!  59.5 ( 0.69x)!  10.5 ( 1.48x)   11.8 ( 1.02x)
pred8x8_vertical_8_neon  18.3 ( 1.08x)   0.1 ( 0.54x)!  12.8 ( 0.89x)!  37.2 ( 0.40x)!   8.3 ( 0.77x)!  11.2 ( 1.00x)
pred8x8_vertical_10_neon 19.0 ( 1.24x)   0.1 ( 0.55x)!  15.3 ( 0.62x)!  39.7 ( 0.50x)!   8.2 ( 0.91x)!  11.1 ( 0.99x)!

- pred8x8_horizontal_10 also underperforms on new architectures, but useful on A55 and A76.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 09:06:37 +00:00
Zhao Zhili f54841d375 avcodec/aarch64: add pngdsp
Test Name                    A55-gcc-11        M1-clang           A76-gcc-12          A510-clang        X3-clang
-------------------------------------------------------------------------------------------------------------------
add_bytes_l2_4096_neon        1807.2 ( 2.01x)    1.6 ( 1.94x)    333.0 ( 6.35x)   1058.2 ( 2.34x)    214.3 ( 1.99x)
add_paeth_prediction_3_neon  33036.1 ( 2.41x)  145.1 ( 1.66x)  20443.3 ( 1.97x)  35225.1 ( 1.23x)  19420.8 ( 1.05x)
add_paeth_prediction_4_neon  24368.6 ( 3.26x)  106.7 ( 2.01x)  15163.8 ( 2.77x)  26454.7 ( 1.62x)  14319.0 ( 1.35x)
add_paeth_prediction_6_neon  17900.6 ( 4.44x)   72.0 ( 2.70x)  10214.3 ( 4.20x)  18296.9 ( 2.27x)   9693.1 ( 1.97x)
add_paeth_prediction_8_neon  12615.4 ( 6.31x)   54.1 ( 2.58x)   7706.0 ( 5.45x)  13733.3 ( 2.94x)   7272.6 ( 2.63x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 12:05:35 +08:00
Zhao Zhili a0d4c07b86 tests/checkasm: add test for png
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-02-04 12:05:35 +08:00
Zhao Zhili 9ebfd68096 swscale/swscale: force SwsDither and SwsAlphaBlend to 32 bits
The 'sws_dither' and 'alphablend' options access 'SwsDither' and
'SwsAlphaBlend' enum fields as integers. This is unsafe when the
code is compiled with -fshort-enums, as the enum size might be
smaller than an int.

Since the 'dither' and 'alpha_blend' struct members are part of the
public API, their types cannot be easily changed.

To ensure safe integer access and maintain ABI compatibility across
different compiler settings, a MAX_ENUM value is added to force the
enums to a 32-bit underlying type.
2026-02-04 04:00:53 +00:00
Jack Lau 36b23092f9 avformat/rtsp: replace the deprecated localport with localrtpport
The `localport` already deprecated in 3a29702cb6

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-04 00:26:26 +00:00
Michael Niedermayer 1fd718c6a9 avformat/mpegts: Check program_info_length
Fixes: overread
No testcase

Found-by: Marton Balint
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 00:04:41 +00:00
Michael Niedermayer 5975149603 avformat/mpegts: Check IOD_DESCRIPTOR len
Fixes: out of array read
Fixes: VULN-7/poc.ts

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-04 00:04:41 +00:00
Jack Lau 5c6c12acb1 avformat/rtpenc: fix memleak when sdp create failed
Fix #20712

When print_sdp() fails during rtp streaming, sch_start()
returns error code without calling wirte_trailer, causing
a memory leak.

The avformat_free_context() will call the mux->deinit, so
we should add a rtp_deinit() to free all internal allocations.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-02-03 23:31:17 +00:00
zhanghongyuan 52f9e8c205 fftools/opt_common: Make -sources/-sinks options work without arguments
The -sources and -sinks options were defined with OPT_FUNC_ARG flag,
which requires an argument. This caused "Missing argument for option
'sources'" error when running ffprobe -sources without arguments.
Removing OPT_FUNC_ARG flag allows these options to work without
arguments, listing all available devices, while still supporting
optional device name argument for filtering specific devices.
2026-02-03 23:22:03 +00:00
WyattBlue 065c2582c0 avfilter/af_whisper: Add newline for txt format 2026-02-03 21:45:43 +00:00
Ruikai Peng 55d5b2b507 avfilter/drawvg: limit VGS parser recursion depth 2026-02-03 21:07:29 +00:00
Oliver Chang a795ca89fa avcodec/qdm2: fix heap-use-after-free in qdm2_decode_frame
The `sub_packet` index in `QDM2Context` was not reset to 0 when
`qdm2_decode_frame` started processing a new packet. If an error
occurred during the decoding of a previous packet, `sub_packet` would
retain a non-zero value.

In subsequent calls to `qdm2_decode_frame` with a new packet, this
non-zero `sub_packet` value caused `qdm2_decode` to skip
`qdm2_decode_super_block`. This function is responsible for initializing
packet lists with pointers to the current packet's data. Skipping it led
to the use of stale pointers from the previous (freed) packet, resulting
in a heap-use-after-free vulnerability.

This patch explicitly resets `s->sub_packet = 0` at the beginning of
`qdm2_decode_frame`, ensuring correct initialization for each new
packet.

Fixes: OSS-Fuzz issue 476179569
(https://issues.oss-fuzz.com/issues/476179569).
2026-02-03 18:17:32 +00:00
Jun Zhao 17d89757cd checkasm/hevc_pel: rename loop variable 'size' to 'idx' to avoid confusion
The variable 'size' is used as a loop index for the 'sizes' array.
This naming similarity is error-prone and recently led to a typo where
'size[sizes]' was written instead of 'sizes[size]'.

Rename the loop index variable from 'size' to 'idx' across all 10 test
functions to make the code more readable and prevent similar typos.

Additionally, replace the hardcoded loop upper bound '10' with
'FF_ARRAY_ELEMS(sizes)' for better maintainability.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-03 14:39:31 +00:00
Jun Zhao 2801d5eafe checkasm/hevc_pel: fix typo size[sizes] -> sizes[size]
Commit 4d4b301e4a introduced a typo where `size[sizes]` was used
instead of `sizes[size]` in 10 places within checkasm_check_pixel_padded
calls.

Since `sizes` is an array and `size` is the loop index, `size[sizes]`
interprets the array pointer as an index, resulting in undefined behavior
and causing AddressSanitizer to detect buffer overflows during testing.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-02-03 14:39:31 +00:00
Michael Niedermayer 2df0ef601a avcodec/jpeg2000dec: allow bpno of -1
Fixes: tickets/4663/levels30.jp2

The file decodes without error messages and no integer overflows
The file before the broader M_b check did decode with error messages and integer overflows but also no visual artifacts

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:32 +01:00
Michael Niedermayer e1472a4e0c avcodec/jpeg2000dec: allow M_b == 31
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:32 +01:00
Michael Niedermayer 8a3c7c9c32 avcodec/jpeg2000dec: Print bpno level when erroring out
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:32 +01:00
Michael Niedermayer 2efffa9ecd avcodec/jpeg2000dec: Print M_b value when asking for a sample
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 12:39:31 +01:00
Michael Niedermayer 65fc0db581 avformat/hlsenc: fix format string vulnerability in parse_playlist
Found-by: Sarthak Munshi <sarthakmunshi@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-03 11:26:23 +00:00
Niklas Haas 8dc025c706 fftools/ffmpeg_sched: drop unneeded atomic
No longer needed now that this code is always locked.
2026-02-03 12:00:31 +01:00
Niklas Haas 41bd67b9fd fftools/ffmpeg_sched: fix race on SchFilterIn.send_finished
This logic was previously added to the scheduler. That commit added locking
(and rescheduling) when updating the corresponding `receive_finished` flag,
but missed doing the same for `send_finished`.

Fixes: fd1fd5850d
2026-02-03 12:00:31 +01:00
Andreas Rheinhardt 836d34e3ba avformat/tests/movenc: Make objects static
(This also fixes a symbol name collision with libssh,
which has a nonstatic function called md5.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-02 23:06:57 +01:00
James Almer b613eebe78 avformat/demux: don't overwrite packet durations with parser ones if unset
Prevents loss of values taken from the demuxer when the underlying parser
doesn't set durations.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer 3fc7e39eb8 avformat/cafenc: disable muxing Opus streams
We're not writing a kuki chunk because its contents for Opus are currently
unknown, so it's best if we don't allow the creation of non spec compliant
files.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer bec16c0bd3 avformat/cafdec: export Opus extradata
Given the contents of the Opus kuki are not fully clear, generate it
using know values from the desc and pakt chunks.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
James Almer d151c904df avformat/cafdec: take into account priming samples in timestamps
Signed-off-by: James Almer <jamrial@gmail.com>
2026-02-02 12:52:02 -03:00
stevxiao 7e9fe341df avfilter: version bump for filter mestimate_d3d12
Bump library version for filter 'mestimate_d3d12'.

This is the follow-up for commit https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21217/commits

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-02 04:16:50 +00:00
stevxiao 8fbd31e715 doc/filters: add entry for mestimate_d3d12
Add documentation for the filter "mestimate_d3d12" to the filters documentation.

This is the follow-up for commit https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21217/commits

Signed-off-by: younengxiao <steven.xiao@amd.com>
2026-02-01 09:53:35 -05:00
Frank Plowman 364d5dda91 lavc/vvc: Fix unchecked error codes from add_reconstructed_area 2026-01-31 13:46:13 +00:00
Frank Plowman f9740eb969 lavc/vvc: Fix unchecked error codes from set_qp_y
Fixes: clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VVC_fuzzer-4957602162475008
2026-01-31 13:46:13 +00:00
Gyan Doshi 50bcc96a75 avformat/cafdec: parse non-intra streams
Needed to set KF flags so that they can be streamcopied using CLI.
2026-01-30 16:59:53 +00:00
Andreas Rheinhardt 39661f9295 fftools/ffmpeg_{filter,mux_init}: Improve type-safety
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 15:20:08 +01:00
Andreas Rheinhardt 67c87cde99 avfilter/formats,vsrc_testsrc: use type-safe formats functions
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 15:20:08 +01:00
Andreas Rheinhardt de3f99d74b avformat/cafenc: Truncate values for avio_w8()
Fixes triggering av_assert2() in avio_w8().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 13:24:06 +01:00
Andreas Rheinhardt 4367c055b6 avformat/cafenc: Fix segfault upon error, avoid indirection
caf_write_deinit() would segfault if the CAFStreamContext
couldn't be allocated. Fix this by moving everything from
CAFStreamContext to the ordinary CAFContext; the separation
doesn't make sense for a format with only one stream anyway
and removing it also avoids an indirection.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 11:30:30 +01:00
Martin Storsjö 7ebb6c54eb tools: Lowercase more patterns in aarch64 assembly
Match more SVE/SME specific details.

Also lowercase all register names. As this matches many cases
of code comments that refer to variables elsewhere, not specific
registers, we only apply this tranformation on the part of lines
before a potential comment.
2026-01-30 05:21:27 +00:00
Martin Storsjö f74c551eaa aarch64: Fix indentation of a few instructions
This file is excempt from the indent checker script, as there
are a few other bits in it that the script wants to reformat
into slightly worse form, or which might not warrant being
reformatted.

But these instructions should indeed be indented this way.
2026-01-30 05:21:27 +00:00
James Almer 277f9cb5d8 avformat/cafenc: add init and deinit callbacks
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:03 -03:00
James Almer 2d5556b082 avformat/cafenc: reindent after the previous changes
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:03 -03:00
James Almer 7581abdcb1 avformat/cafenc: support writing Packet Table Chunk Header if there are priming or remainder frames
If a codec has fixed block_align and frame_size but a given sample has either
priming or remainder frames, a pakt chunk can be written declaring zero packets
and no table, reporting only the samples to be discarded.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer 6ff12c4f6c avformat/cafenc: add support for variable frame size codecs
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer 7600d12383 avformat/cafenc: define a structure to store stream private fields
Will be useful in the following commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer 8d1f247ec1 avformat/cafenc: fix setting frame count fields in Packet Table Description
st->duration is not guaranteed to be set, so store the sum of packet durations instead.
Also, set mPrimingFrames and mRemainderFrames to correct values.

Based on a patch by Jun Zhao.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer f5ea09afe8 avformat/cafdec: export frame size when present
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer c52b287ba9 avformat/cafdec: fix setting stream and packet durations
Take into account priming frames, exported as start time, and remainder frames,
substracted from the stream duration as well as exported as discard padding
side data in the last packet.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer 041d108958 avcodec/opus/enc: don't remove more samples than needed from the last packet
The hardcoded extra 120 samples results in the side data reporting the need to
discard the entire packet rather than the padding samples.
This is in line with the behavior of the libopus encoder.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
James Almer c3aea7628c avcodec/opus/enc: set avctx->frame_size to a better guess based on encoder configuration
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-29 21:09:02 -03:00
Andreas Rheinhardt 5b4ba2e1ac avfilter/vsrc_amf: Remove unused-but-set variable
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 22:33:33 +01:00
Andreas Rheinhardt ca5504fb5c avcodec/liblc3dec: Simplify sample fmt selection
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 14:08:15 +01:00
Andreas Rheinhardt ba1aea762b avcodec/liblc3{dec,enc}: Simplify sample_size, is_planar check
Sample size is always sizeof(float), is planar is a simple if
given that these codecs only support float and planar float.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 14:08:15 +01:00
Jack Lau 3c902f68d7 configure: update whip dependences
The dtls_protocol is ffmpeg component, should
be included by whip_muxer_select

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-29 12:19:17 +00:00
Jack Lau 2a0a32c42b avformat/whip: remove the confused option buffer_size
See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20965#issuecomment-22815

The buffer_size isn't inlcuded in release/8.0,
directly use new option ts_buffer_size to replace
buffer_size shoule be okay.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-29 12:18:22 +00:00
Andreas Rheinhardt fc0e0ef022 tests/checkasm/hevc_dequant: Only init buffer when needed
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 12:25:33 +01:00
Andreas Rheinhardt 436b74b725 avcodec/x86/hevc/dequant: Add SSSE3 dequant ASM function
hevc_dequant_4x4_8_c (GCC):                             20.2 ( 1.00x)
hevc_dequant_4x4_8_c (Clang):                           21.7 ( 1.00x)
hevc_dequant_4x4_8_ssse3:                                5.8 ( 3.51x)
hevc_dequant_8x8_8_c (GCC):                             32.9 ( 1.00x)
hevc_dequant_8x8_8_c (Clang):                           78.7 ( 1.00x)
hevc_dequant_8x8_8_ssse3:                                6.8 ( 4.83x)
hevc_dequant_16x16_8_c (GCC):                          105.1 ( 1.00x)
hevc_dequant_16x16_8_c (Clang):                        151.1 ( 1.00x)
hevc_dequant_16x16_8_ssse3:                             19.3 ( 5.45x)
hevc_dequant_32x32_8_c (GCC):                          415.7 ( 1.00x)
hevc_dequant_32x32_8_c (Clang):                        602.3 ( 1.00x)
hevc_dequant_32x32_8_ssse3:                             78.2 ( 5.32x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 12:25:33 +01:00
Andreas Rheinhardt cf359a7907 avcodec/hevc/dsp: Add alignment for dequant
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 12:25:33 +01:00
Andreas Rheinhardt 0c7f87b136 avcodec/hevc/dsp_template: Optimize impossible branches away
Saves 1856B of .text here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 12:25:33 +01:00
Andreas Rheinhardt 2729c52988 avcodec/x86/hevc/deblock: Reduce usage of GPRs
Don't use two GPRs to store two words from xmm registers;
shuffle these words so that they are fit into one GPR.
This reduces the amount of GPRs used and leads to tiny speedups
here. Also avoid rex prefixes whenever possible (for lines
that needed to be modified anyway).

Old benchmarks:
hevc_h_loop_filter_luma8_skip_c:                        23.8 ( 1.00x)
hevc_h_loop_filter_luma8_skip_sse2:                      8.5 ( 2.80x)
hevc_h_loop_filter_luma8_skip_ssse3:                     7.2 ( 3.29x)
hevc_h_loop_filter_luma8_skip_avx:                       6.4 ( 3.71x)
hevc_h_loop_filter_luma8_strong_c:                     150.4 ( 1.00x)
hevc_h_loop_filter_luma8_strong_sse2:                   34.4 ( 4.37x)
hevc_h_loop_filter_luma8_strong_ssse3:                  34.5 ( 4.36x)
hevc_h_loop_filter_luma8_strong_avx:                    32.3 ( 4.65x)
hevc_h_loop_filter_luma8_weak_c:                       103.2 ( 1.00x)
hevc_h_loop_filter_luma8_weak_sse2:                     34.5 ( 2.99x)
hevc_h_loop_filter_luma8_weak_ssse3:                     7.3 (14.22x)
hevc_h_loop_filter_luma8_weak_avx:                      32.4 ( 3.18x)
hevc_h_loop_filter_luma10_skip_c:                       23.5 ( 1.00x)
hevc_h_loop_filter_luma10_skip_sse2:                     6.6 ( 3.58x)
hevc_h_loop_filter_luma10_skip_ssse3:                    6.1 ( 3.86x)
hevc_h_loop_filter_luma10_skip_avx:                      5.4 ( 4.34x)
hevc_h_loop_filter_luma10_strong_c:                    161.8 ( 1.00x)
hevc_h_loop_filter_luma10_strong_sse2:                  32.2 ( 5.03x)
hevc_h_loop_filter_luma10_strong_ssse3:                 30.4 ( 5.33x)
hevc_h_loop_filter_luma10_strong_avx:                   30.3 ( 5.33x)
hevc_h_loop_filter_luma10_weak_c:                       23.5 ( 1.00x)
hevc_h_loop_filter_luma10_weak_sse2:                     6.6 ( 3.58x)
hevc_h_loop_filter_luma10_weak_ssse3:                    6.1 ( 3.85x)
hevc_h_loop_filter_luma10_weak_avx:                      5.4 ( 4.35x)
hevc_h_loop_filter_luma12_skip_c:                       18.8 ( 1.00x)
hevc_h_loop_filter_luma12_skip_sse2:                     6.6 ( 2.87x)
hevc_h_loop_filter_luma12_skip_ssse3:                    6.1 ( 3.08x)
hevc_h_loop_filter_luma12_skip_avx:                      6.2 ( 3.06x)
hevc_h_loop_filter_luma12_strong_c:                    159.0 ( 1.00x)
hevc_h_loop_filter_luma12_strong_sse2:                  36.3 ( 4.38x)
hevc_h_loop_filter_luma12_strong_ssse3:                 36.1 ( 4.40x)
hevc_h_loop_filter_luma12_strong_avx:                   33.5 ( 4.75x)
hevc_h_loop_filter_luma12_weak_c:                       40.1 ( 1.00x)
hevc_h_loop_filter_luma12_weak_sse2:                    35.5 ( 1.13x)
hevc_h_loop_filter_luma12_weak_ssse3:                   36.1 ( 1.11x)
hevc_h_loop_filter_luma12_weak_avx:                      6.2 ( 6.52x)
hevc_v_loop_filter_luma8_skip_c:                        25.5 ( 1.00x)
hevc_v_loop_filter_luma8_skip_sse2:                     10.6 ( 2.40x)
hevc_v_loop_filter_luma8_skip_ssse3:                    11.4 ( 2.24x)
hevc_v_loop_filter_luma8_skip_avx:                       8.3 ( 3.07x)
hevc_v_loop_filter_luma8_strong_c:                     146.8 ( 1.00x)
hevc_v_loop_filter_luma8_strong_sse2:                   43.9 ( 3.35x)
hevc_v_loop_filter_luma8_strong_ssse3:                  43.7 ( 3.36x)
hevc_v_loop_filter_luma8_strong_avx:                    42.3 ( 3.47x)
hevc_v_loop_filter_luma8_weak_c:                        25.5 ( 1.00x)
hevc_v_loop_filter_luma8_weak_sse2:                     10.6 ( 2.40x)
hevc_v_loop_filter_luma8_weak_ssse3:                    44.0 ( 0.58x)
hevc_v_loop_filter_luma8_weak_avx:                       8.3 ( 3.09x)
hevc_v_loop_filter_luma10_skip_c:                       20.0 ( 1.00x)
hevc_v_loop_filter_luma10_skip_sse2:                    11.3 ( 1.77x)
hevc_v_loop_filter_luma10_skip_ssse3:                   11.0 ( 1.82x)
hevc_v_loop_filter_luma10_skip_avx:                      9.3 ( 2.15x)
hevc_v_loop_filter_luma10_strong_c:                    193.5 ( 1.00x)
hevc_v_loop_filter_luma10_strong_sse2:                  46.1 ( 4.19x)
hevc_v_loop_filter_luma10_strong_ssse3:                 44.2 ( 4.38x)
hevc_v_loop_filter_luma10_strong_avx:                   44.4 ( 4.35x)
hevc_v_loop_filter_luma10_weak_c:                       90.3 ( 1.00x)
hevc_v_loop_filter_luma10_weak_sse2:                    46.3 ( 1.95x)
hevc_v_loop_filter_luma10_weak_ssse3:                   10.8 ( 8.37x)
hevc_v_loop_filter_luma10_weak_avx:                     44.4 ( 2.03x)
hevc_v_loop_filter_luma12_skip_c:                       16.8 ( 1.00x)
hevc_v_loop_filter_luma12_skip_sse2:                    11.8 ( 1.42x)
hevc_v_loop_filter_luma12_skip_ssse3:                   11.7 ( 1.43x)
hevc_v_loop_filter_luma12_skip_avx:                      8.7 ( 1.93x)
hevc_v_loop_filter_luma12_strong_c:                    159.3 ( 1.00x)
hevc_v_loop_filter_luma12_strong_sse2:                  45.3 ( 3.52x)
hevc_v_loop_filter_luma12_strong_ssse3:                 60.3 ( 2.64x)
hevc_v_loop_filter_luma12_strong_avx:                   44.1 ( 3.61x)
hevc_v_loop_filter_luma12_weak_c:                       63.6 ( 1.00x)
hevc_v_loop_filter_luma12_weak_sse2:                    45.3 ( 1.40x)
hevc_v_loop_filter_luma12_weak_ssse3:                   11.7 ( 5.41x)
hevc_v_loop_filter_luma12_weak_avx:                     43.9 ( 1.45x)

New benchmarks:
hevc_h_loop_filter_luma8_skip_c:                        24.2 ( 1.00x)
hevc_h_loop_filter_luma8_skip_sse2:                      8.6 ( 2.82x)
hevc_h_loop_filter_luma8_skip_ssse3:                     7.0 ( 3.46x)
hevc_h_loop_filter_luma8_skip_avx:                       6.8 ( 3.54x)
hevc_h_loop_filter_luma8_strong_c:                     150.4 ( 1.00x)
hevc_h_loop_filter_luma8_strong_sse2:                   33.3 ( 4.52x)
hevc_h_loop_filter_luma8_strong_ssse3:                  32.7 ( 4.61x)
hevc_h_loop_filter_luma8_strong_avx:                    32.7 ( 4.60x)
hevc_h_loop_filter_luma8_weak_c:                       104.0 ( 1.00x)
hevc_h_loop_filter_luma8_weak_sse2:                     33.2 ( 3.13x)
hevc_h_loop_filter_luma8_weak_ssse3:                     7.0 (14.91x)
hevc_h_loop_filter_luma8_weak_avx:                      31.3 ( 3.32x)
hevc_h_loop_filter_luma10_skip_c:                       19.2 ( 1.00x)
hevc_h_loop_filter_luma10_skip_sse2:                     6.2 ( 3.08x)
hevc_h_loop_filter_luma10_skip_ssse3:                    6.2 ( 3.08x)
hevc_h_loop_filter_luma10_skip_avx:                      5.0 ( 3.85x)
hevc_h_loop_filter_luma10_strong_c:                    159.8 ( 1.00x)
hevc_h_loop_filter_luma10_strong_sse2:                  30.0 ( 5.32x)
hevc_h_loop_filter_luma10_strong_ssse3:                 29.2 ( 5.48x)
hevc_h_loop_filter_luma10_strong_avx:                   28.6 ( 5.58x)
hevc_h_loop_filter_luma10_weak_c:                       19.2 ( 1.00x)
hevc_h_loop_filter_luma10_weak_sse2:                     6.2 ( 3.09x)
hevc_h_loop_filter_luma10_weak_ssse3:                    6.2 ( 3.09x)
hevc_h_loop_filter_luma10_weak_avx:                      5.0 ( 3.88x)
hevc_h_loop_filter_luma12_skip_c:                       18.7 ( 1.00x)
hevc_h_loop_filter_luma12_skip_sse2:                     6.2 ( 3.00x)
hevc_h_loop_filter_luma12_skip_ssse3:                    5.7 ( 3.27x)
hevc_h_loop_filter_luma12_skip_avx:                      5.2 ( 3.61x)
hevc_h_loop_filter_luma12_strong_c:                    160.2 ( 1.00x)
hevc_h_loop_filter_luma12_strong_sse2:                  34.2 ( 4.68x)
hevc_h_loop_filter_luma12_strong_ssse3:                 29.3 ( 5.48x)
hevc_h_loop_filter_luma12_strong_avx:                   31.4 ( 5.10x)
hevc_h_loop_filter_luma12_weak_c:                       40.2 ( 1.00x)
hevc_h_loop_filter_luma12_weak_sse2:                    35.2 ( 1.14x)
hevc_h_loop_filter_luma12_weak_ssse3:                   29.3 ( 1.37x)
hevc_h_loop_filter_luma12_weak_avx:                      5.0 ( 8.09x)
hevc_v_loop_filter_luma8_skip_c:                        25.6 ( 1.00x)
hevc_v_loop_filter_luma8_skip_sse2:                     10.2 ( 2.52x)
hevc_v_loop_filter_luma8_skip_ssse3:                    10.5 ( 2.45x)
hevc_v_loop_filter_luma8_skip_avx:                       8.2 ( 3.11x)
hevc_v_loop_filter_luma8_strong_c:                     147.1 ( 1.00x)
hevc_v_loop_filter_luma8_strong_sse2:                   42.6 ( 3.45x)
hevc_v_loop_filter_luma8_strong_ssse3:                  42.4 ( 3.47x)
hevc_v_loop_filter_luma8_strong_avx:                    40.1 ( 3.67x)
hevc_v_loop_filter_luma8_weak_c:                        25.6 ( 1.00x)
hevc_v_loop_filter_luma8_weak_sse2:                     10.6 ( 2.42x)
hevc_v_loop_filter_luma8_weak_ssse3:                    42.7 ( 0.60x)
hevc_v_loop_filter_luma8_weak_avx:                       8.2 ( 3.11x)
hevc_v_loop_filter_luma10_skip_c:                       16.7 ( 1.00x)
hevc_v_loop_filter_luma10_skip_sse2:                    11.0 ( 1.52x)
hevc_v_loop_filter_luma10_skip_ssse3:                   10.5 ( 1.59x)
hevc_v_loop_filter_luma10_skip_avx:                      9.6 ( 1.74x)
hevc_v_loop_filter_luma10_strong_c:                    190.0 ( 1.00x)
hevc_v_loop_filter_luma10_strong_sse2:                  44.8 ( 4.24x)
hevc_v_loop_filter_luma10_strong_ssse3:                 42.3 ( 4.49x)
hevc_v_loop_filter_luma10_strong_avx:                   42.5 ( 4.47x)
hevc_v_loop_filter_luma10_weak_c:                       88.3 ( 1.00x)
hevc_v_loop_filter_luma10_weak_sse2:                    45.7 ( 1.93x)
hevc_v_loop_filter_luma10_weak_ssse3:                   10.5 ( 8.40x)
hevc_v_loop_filter_luma10_weak_avx:                     42.4 ( 2.09x)
hevc_v_loop_filter_luma12_skip_c:                       16.7 ( 1.00x)
hevc_v_loop_filter_luma12_skip_sse2:                    11.7 ( 1.42x)
hevc_v_loop_filter_luma12_skip_ssse3:                   10.5 ( 1.59x)
hevc_v_loop_filter_luma12_skip_avx:                      8.8 ( 1.90x)
hevc_v_loop_filter_luma12_strong_c:                    159.4 ( 1.00x)
hevc_v_loop_filter_luma12_strong_sse2:                  45.2 ( 3.53x)
hevc_v_loop_filter_luma12_strong_ssse3:                 59.3 ( 2.69x)
hevc_v_loop_filter_luma12_strong_avx:                   41.7 ( 3.82x)
hevc_v_loop_filter_luma12_weak_c:                       63.3 ( 1.00x)
hevc_v_loop_filter_luma12_weak_sse2:                    44.9 ( 1.41x)
hevc_v_loop_filter_luma12_weak_ssse3:                   10.5 ( 6.02x)
hevc_v_loop_filter_luma12_weak_avx:                     41.7 ( 1.52x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 11:54:57 +01:00
Andreas Rheinhardt 0843252229 avcodec/x86/hevc/deblock: avoid unused GPR
r12 is unused, so use it instead of r13 to reduce
the amount of push/pops.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 11:54:57 +01:00
Andreas Rheinhardt 0aad8b860a avcodec/x86/hevc/deblock: Avoid vmovdqa
(It would even be possible to avoid a clobbering m10 in
MASKED_COPY and the mask register (%3) in MASKED_COPY2
when VEX encoding is in use.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 11:54:57 +01:00
Andreas Rheinhardt c940128fff avcodec/x86/vp9lpf: Avoid vmovdqa
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 11:54:57 +01:00
Andreas Rheinhardt c898ddb8fe avcodec/x86/cfhddsp: Reduce number of xmm registers used
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:40 +01:00
Andreas Rheinhardt 848c3ca772 avcodec/x86/cfhddsp: Avoid pmaddwd
The result of using pmaddwd with the coefficients 1,-1,...,1,-1
is just the negative of using pmaddwd with the coefficients
-1,1,...,-1,1, so avoid one pmaddwd.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:37 +01:00
Andreas Rheinhardt 6224445753 avcodec/x86/cfhdencdsp: Avoid += x, -= x
Avoid incrementing lowq and highq inside the loop by using
complex addressing modes, avoiding to undo said modification
at the end of the horizontal loop.
For inputq, modify istrideq outside of the loop so that
it is only modified once at the end of the horizontal loop.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:34 +01:00
Andreas Rheinhardt 7dd6487800 avcodec/x86/cfhdencdsp: Don't load twice
Sign extend the integer arguments directly from the stack
instead of loading qwords, followed by sign-extending the
lower half.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:30 +01:00
Andreas Rheinhardt 91c7710412 avcodec/x86/cfhdencdsp: Avoid unnecessary constants
Up until now, cfhdencdsp used constants consisting
of -1, 1, ...,-1,1 words and 1, -1,...,1,-1 words
for use as constants in pmaddwd. But one can use
the same constants if one shuffles the words in
a dword the opposite order. Similarly for some other
constants. This also allowed to avoid a register in
chfdenc_vert_filter.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:33:23 +01:00
Andreas Rheinhardt cd3d8116fb avcodec/x86/cfhdencdsp: Avoid load of -1
It can be easily generated at runtime.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-29 01:32:57 +01:00
Jack Lau 4ad20a2c09 avformat/tls_gnutls: set key and cert when they're PEM string
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau 28fb3f5e9e avformat/tls_gnutls: set srtp profile when it is enabled
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau 8f9825cf41 avformat/tls_gnutls: add check for s->external_sock
When s->external_sock is enabled, the underlying sock
will be set after tls_open(), so it should not open a
sock and handshake.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Jack Lau 7f9d8b0c16 avformat/tls_gnutls: enable dtls build
Implement ff_ssl_*_key_cert()

Generate self-signed cert and key in server
mode if there're no key and cert input.

Implement ff_tls_set_external_socket() and
ff_dtls_export_materials()

Add gnutls as dtls protocol deps.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-28 10:47:07 +00:00
Zhao Zhili f4ca7950d8 avfilter/vf_mestimate_d3d12: remove redundant mb_size constants
A constant named 8 has value 8 is redundant. These constants cannot
prevent user from setting other vaues. Just describe valid values
in the help message.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-27 17:05:27 +00:00
Kasidis Arunruangsirilert e9e8a32b29 avcodec/nvenc: add 4-way multi nvenc split frame encoding support 2026-01-27 12:58:46 +00:00
Diego de Souza 499b5f5f92 avcodec/nvenc: add b_adapt option for HEVC encoder
The b_adapt option allows users to control adaptive B-frame decision
when lookahead is enabled in HEVC encoding. This feature was already
available for H.264 and AV1 encoders, but was missing from HEVC.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-01-27 12:58:08 +00:00
Steven Liu a97632827d avformat/dashdec: check value valid after read value from mpd xml
before this commit ffmpeg get Heap Buffer Overflow in DASH Demuxer
via Negative Start Number.
Check the value from mpd xml, set the value to 0 if get negative value.

Fixes: heap buffer overflow
Found-by: Zhenpeng (Leo) Lin from depthfirst
2026-01-27 08:28:43 +00:00
Andreas Rheinhardt d9e8c85617 swscale/x86/ops_int: Check for cpuflag instead of avx_enabled
This would make this code compatible with forcing VEX encodings
for the SSE4 codepath and is also more correct, because avx_enabled
would be enabled for AVX, although the instructions used in these
codepaths require AVX2.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-26 13:10:15 +01:00
stevxiao 451ff239e6 avfilter: d3d12 motion estimation filter support
This commit introduces a video filter `mestimate_d3d12` that provides hardware-accelerated motion estimation using DirectX 12 Video Encoding APIs. The filter leverages GPU hardware motion estimation capabilities to achieve significant performance improvements over the existing software-based mestimate filter.

Sample Command Line:

1. Basic mestimate_d3d12 functionality
```
	ffmpeg_g.exe -hwaccel d3d12va -i test.mp4 -vf mestimate_d3d12=mb_size=16 -f null -
```
2. Motion vector visualization
```
	ffmpeg -hwaccel d3d12va -i input.mp4 -vf "mestimate_d3d12,hwdownload,format=nv12,codecview=mv=pf" -c:v libx264 output.mp4
```
2026-01-26 11:31:48 +00:00
Dmitrii Ovchinnikov 714152dd9a avutil/hwcontext_d3d11va: added resource and heap flags to DeviceContext 2026-01-26 10:39:10 +00:00
Gyan Doshi fe0813d6e2 ffmpeg_demux: fix readrate to respect initial burst
Fixes #21510
2026-01-26 15:37:22 +05:30
Kacper Michajłow 10db62d205 swscale/utils: zero init filter memory as before
Commit 795bb37a39 removed zeroing of those
buffers, without mention, which introduces corrupted output.

Fixes: 795bb37a39
Fixes: https://github.com/mpv-player/mpv/issues/17317
2026-01-26 09:45:16 +00:00
Andreas Rheinhardt bf4d5037b4 avcodec/h264dsp: Remove redundant h264 from H264DSPCtx member names
These names are a remnant of dsputil when all the DSP functions
from all codecs were part of DSPcontext.

Reviewed-by: Rémi Denis-Courmont <remi@remlab.net>
Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:25 +01:00
Andreas Rheinhardt 489aaf4e1c avcodec/x86/h264_deblock: Don't sign-extend stride
Unnecessary (and wrong) since d5d699ab6e.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt db66e057eb avcodec/x86/h264_deblock: Avoid reload
Old benchmarks:
h264_h_loop_filter_luma_8bpp_c:                         60.0 ( 1.00x)
h264_h_loop_filter_luma_8bpp_sse2:                      65.4 ( 0.92x)
h264_h_loop_filter_luma_8bpp_avx:                       65.3 ( 0.92x)

New benchmarks:
h264_h_loop_filter_luma_8bpp_c:                         60.4 ( 1.00x)
h264_h_loop_filter_luma_8bpp_sse2:                      62.0 ( 0.97x)
h264_h_loop_filter_luma_8bpp_avx:                       61.7 ( 0.98x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 8428a412bc avcodec/x86/h264_deblock: Avoid MMX in deblock_h_luma_8
Old benchmarks:
h264_h_loop_filter_luma_8bpp_c:                         59.9 ( 1.00x)
h264_h_loop_filter_luma_8bpp_sse2:                      67.9 ( 0.88x)
h264_h_loop_filter_luma_8bpp_avx:                       67.4 ( 0.89x)

New benchmarks:
h264_h_loop_filter_luma_8bpp_c:                         60.0 ( 1.00x)
h264_h_loop_filter_luma_8bpp_sse2:                      65.4 ( 0.92x)
h264_h_loop_filter_luma_8bpp_avx:                       65.3 ( 0.92x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 9882973935 avcodec/x86/h264_deblock: Avoid reloading constant
No change in benchmarks.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt eaaf45fd79 avcodec/x86/h264_deblock_10bit: Simplify r0+4*r1
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt aab0946eae avcodec/x86/h264_deblock_10bit: Remove mmxext functions
Now that the SSE2/AVX functions are no longer restricted
to those systems having an aligned stack, the MMXEXT functions
are always overridden (except for ancient systems without
SSE2), so remove them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt dbdf514c17 avcodec/x86/h264_deblock_10bit: Remove custom stack allocation code
Allocate it via cglobal as usual. This makes the SSE2/AVX functions
available when HAVE_ALIGNED_STACK is false; it also avoids
modifying rsp unnecessarily in the deblock_h_luma_intra_10 functions
on Win64.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt b1140d3c98 avcodec/x86/h264_deblock: Remove obsolete macro parameters
They are a remnant of the MMX functions (which processed
only eight pixels at a time, so that it was called twice
via a wrapper; the actual MMX function had "v8" in its name
instead of simply v) which have been removed in commit
4618f36a24.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 899475326b avcodec/x86/h264_deblock: Simplify splatting
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt a22149ab3d avcodec/x86/h264_deblock: Remove always-false branches
These functions are always called with alpha and beta > 0.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt d53ff30215 tests/checkasm/h264dsp: Don't test loop filter strength 0
These functions are not used with these parameters;
see the filter_mb_* functions in h264_loopfilter.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 982244818b avcodec/x86/h264_deblock: Remove unused macros
Forgotten in 4618f36a24.
Also remove a PASS8ROWS wrapper that seems to have been always
unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:53:21 +01:00
Andreas Rheinhardt 6e65d1c945 avcodec/motion_est: Fix left shifts of negative numbers
Fixes ticket #21486.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-25 22:46:39 +01:00
Jun Zhao 8966101fa6 lavc/hevc: add aarch64 neon for 12-bit dequant
Implement NEON optimization for HEVC dequant at 12-bit depth.

For 12-bit: shift = 15 - 12 - log2_size = 3 - log2_size. When shift
is negative, we use shl (shift left) instead of srshr.

Performance benchmark on Apple M4:
./tests/checkasm/checkasm --test=hevc_dequant --bench
hevc_dequant_4x4_12_c:                                   9.9 ( 1.00x)
hevc_dequant_4x4_12_neon:                                5.7 ( 1.74x)

hevc_dequant_8x8_12_c:                                   1.7 ( 1.00x)
hevc_dequant_8x8_12_neon:                                1.3 ( 1.30x)

hevc_dequant_16x16_12_c:                               131.1 ( 1.00x)
hevc_dequant_16x16_12_neon:                              7.9 (16.52x)

hevc_dequant_32x32_12_c:                                69.7 ( 1.00x)
hevc_dequant_32x32_12_neon:                             28.4 ( 2.46x)

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-25 06:55:26 +00:00
Jun Zhao ce89d974c8 lavc/hevc: add aarch64 neon for 10-bit dequant
Implement NEON optimization for HEVC dequant at 10-bit depth.

For 10-bit: shift = 15 - 10 - log2_size = 5 - log2_size

Performance benchmark on Apple M4:
./tests/checkasm/checkasm --test=hevc_dequant --bench
hevc_dequant_4x4_10_c:                                  16.6 ( 1.00x)
hevc_dequant_4x4_10_neon:                                7.4 ( 2.23x)

hevc_dequant_8x8_10_c:                                  39.7 ( 1.00x)
hevc_dequant_8x8_10_neon:                                7.5 ( 5.28x)

hevc_dequant_16x16_10_c:                               168.7 ( 1.00x)
hevc_dequant_16x16_10_neon:                             10.2 (16.56x)

hevc_dequant_32x32_10_c:                                 1.9 ( 1.00x)
hevc_dequant_32x32_10_neon:                              1.9 ( 1.01x)

Note: 32x32 shift=0 is identity transform (no-op), so NEON has no
advantage over C which is also optimized away by the compiler.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-25 06:55:26 +00:00
Jun Zhao 24f296c7a1 lavc/hevc: optimize dequant for shift=0 case (identity transform)
The HEVC dequantization uses:
  shift = 15 - bit_depth - log2_size

When shift equals 0, the operation becomes an identity transform:
  - For shift > 0: output = (input + offset) >> shift
  - For shift < 0: output = input << (-shift)
  - For shift = 0: output = input << 0 = input (no change)

This occurs in the following cases:
  - 10-bit, 32x32 block: shift = 15 - 10 - 5 = 0
  - 12-bit, 8x8 block:   shift = 15 - 12 - 3 = 0

Previously, the code would still iterate through all coefficients
and perform redundant read-modify-write operations even when shift=0.

This patch adds an early return for shift=0, avoiding unnecessary
memory operations. checkasm benchmarks on Apple M4 show:
  - 10-bit 32x32: 69.1 -> 1.6 cycles (43x faster)
  - 12-bit 8x8:   30.9 -> 1.7 cycles (18x faster)

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-25 06:55:26 +00:00
Jun Zhao 0886e50c6b lavc/hevc: add aarch64 neon for 8-bit dequant
Implement NEON optimization for HEVC dequant at 8-bit depth.

The NEON implementation uses srshr (Signed Rounding Shift Right) which
does both the add with offset and right shift in a single instruction.

Optimization details:
- 4x4 (16 coeffs): Single load-process-store sequence
- 8x8 (64 coeffs): Fully unrolled, no loop overhead
- 16x16 (256 coeffs): Pipelined load/compute/store to hide memory latency
- 32x32 (1024 coeffs): Pipelined with all available NEON registers

Performance benchmark on Apple M4:
./tests/checkasm/checkasm --test=hevc_dequant --bench
hevc_dequant_4x4_8_c:                                   11.3 ( 1.00x)
hevc_dequant_4x4_8_neon:                                 6.3 ( 1.78x)

hevc_dequant_8x8_8_c:                                   33.9 ( 1.00x)
hevc_dequant_8x8_8_neon:                                 6.6 ( 5.11x)

hevc_dequant_16x16_8_c:                                153.8 ( 1.00x)
hevc_dequant_16x16_8_neon:                               9.0 (17.02x)

hevc_dequant_32x32_8_c:                                 78.1 ( 1.00x)
hevc_dequant_32x32_8_neon:                              31.9 ( 2.45x)

Note on Performance Anomaly:
The observation that hevc_dequant_32x32_8_c is faster than 16x16 (78.1 vs 153.8)
is due to Clang auto-vectorizing only for sizes >= 32x32.
Compiler: Apple clang version 17.0.0 (clang-1700.6.3.2)

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-25 06:55:26 +00:00
Zhao Zhili 1e1dde8798 avcodec/libx265: map ffmpeg log level to x265 log level
Previously x265 encoder used its default log level regardless of
FFmpeg's log level setting. Note the log level can be overwritten
by x265-params.

Fix #21462

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-25 13:09:30 +08:00
Ruikai Peng 905a432403 libavfilter/showcwt: fix OOB write for DU/RL position init
In config_output() for direction=DU/RL, the position
is initialized to s->sono_size, which equals h or w
when bar=0. That position is later used as an
in-bounds pixel coordinate without clamping in draw(),
causing writes past the end of the output planes.

Repro:
ffmpeg -f lavfi -i sine=frequency=1000:sample_rate=44100 \
  -filter_complex "[0:a]showcwt=s=640x512:bar=0:direction=du[v]" \
  -map "[v]" -frames:v 1 -f null -

AddressSanitizer: heap-buffer-overflow ... WRITE of size 1

Initialize and wrap the DU/RL position to sono_size - 1
(or 0 when empty), preventing out-of-bounds row/column
writes when bar=0 while preserving existing slide behavior.
2026-01-24 22:05:34 +00:00
Rost Kurylo 4c9953592f avformat/udp: don't bind sockets to 0.0.0.0 by default for unicast UDP inputs 2026-01-24 20:26:24 +00:00
Carl Eugen Hoyos aab0c23cb8 lavc/j2kdec: Do not ignore colour association for packed formats
Fixes ticket #9468.

Signed-off-by: Carl Eugen Hoyos <ceffmpeg@gmail.com
2026-01-24 20:25:05 +00:00
Timo Rothenpieler 4f77473b46 forgejo/workflows: update actions 2026-01-24 20:05:07 +00:00
GeoffreyAA ff63d4865b avfilter/vf_libplacebo: add chroma_location option
Add chroma_location option so that, in the subsampled-to-subsampled case, the destination's chroma siting can be changed from the source's without having to use other filters. Useful, for example, when converting BT.2020 to BT.709, where the former customarily uses "top left" and the latter "left."

Update documentation.

Closes: #21185
2026-01-24 11:01:34 +00:00
niyinghao ec8e0b3592 libavfilter: Use type-safe format negotiation functions with enum parameters
Replace generic format functions with type-safe variants to prevent undefined
behavior with -fshort-enums compiler flag.

- 44/20 filters: ff_set_common_formats_from_list2 -> ff_set_*_formats_from_list2 (sample/pixel)
- 16/41 filters: ff_make_format_list → ff_make_*_format_list (sample/pixel)

Signed-off-by: niyinghao <niyinghao@xiaomi.com>
2026-01-24 08:11:19 +00:00
Christopher Degawa a5d4c398b4 avcodec/libsvtav1: rename aq_mode for v4.0.0
Signed-off-by: Christopher Degawa <ccom@randomderp.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-23 23:07:18 -03:00
Michael Niedermayer 404775a141 swscale/utils: Sanity check sizeFactor
Fixes: multiple integer overflows
Fixes: out of array access

The PoC modifies filter parameters generally inaccessable to an attacker

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-23 17:53:33 +00:00
Michael Niedermayer 795bb37a39 swscale/utils: Avoid FF_ALLOC_TYPED_ARRAY() and use av_malloc_array() directly
Fixes: multiple integer overflows
Fixes: out of array access

Regression since: a408d03ee6

The PoC modifies filter parameters generally inaccessable to an attacker

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-23 17:53:33 +00:00
Lynne 8349565d52 aacsbr_template: fix SBR USAC coupling
This issue hid under the radar since the codebooks between coupling
modes very often result in identical bit counts regardless of the encoded
data, leading to no frame-level bitstream desyncs except in rare cases.

AAC Mps212 data is parsed immediately after the SBR data, where a loss
of sync in SBR will result in Mps212 being wildly different.
2026-01-23 14:40:52 +01:00
Ling, Edison a93cb79da2 avcodec/d3d12va_encode: Bug fix and refactor for motion estimation precision initialization
Move motion estimation precision check from standalone
`d3d12va_encode_init_motion_estimation_precision()` function into each
codec's init_sequence_params() to reuse existing feature support
queries.

 - fixes AV1 using wrong support structure (SUPPORT instead of SUPPORT1)
 - eliminates duplicate setup code
 - removes redundant CheckFeatureSupport API call
 - no intended functional changes other than bug fix
2026-01-23 13:25:55 +00:00
James Almer dd2976b9e1 avcodec/mlp: don't duplicate the AV_CRC_8_EBU table
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-22 17:44:46 -03:00
wangbin 4561fc5e48 configure: probe glslang
if shaderc is not installed and --glslc is not set
2026-01-22 03:05:01 +00:00
Marton Balint 0c3afc7e56 Revert "lavfi: make sure frame SAR matches the link value"
This reverts commit fcc33ada47.

It breaks playback of files with changing aspect ratio in ffplay, such as [1],
because the filter chain is initialized with the initial aspect ratio, so any
change is overwritten.

[1] https://samples.ffmpeg.org/archive/container/mpegts/mpegts+mpeg2video+mp2++aspect.ts
2026-01-21 22:06:12 +00:00
Marton Balint a275ae8d64 avfilter: do not overwrite frame aspect ratio with source frame props in histogram and vectorscrope
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:06:12 +00:00
Marton Balint 0ba9e272fa fftools/ffplay: add support for rendering without alpha
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Marton Balint e76c73afaf fftools/ffplay: add video_bg and aspect ratio support to vulkan renderer
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Marton Balint 50671a018d fftools/ffplay: add a new -video_bg option for transparent video
It allows controlling the background of a transparent video. Default is a
checker board pattern.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Lynne e2f9861036 hwcontext_vulkan: fix stride for host image copy uploads
Can this cursed extension ever bloody ever even work!?!
2026-01-21 21:21:32 +01:00
Hyunjun Ko b637624046 avcodec/vulkan_av1: fix mi_col_starts and mi_row_starts units
The spec says:
   pMiColStarts is a pointer to an array of TileCols number
   of unsigned integers that corresponds to MiColStarts
   defined in section 6.8.14 of the [AV1 Specification]

And the unit of MiColStarts is MI(mode info).

So is pMiRowStarts.
2026-01-21 10:42:02 +00:00
Jack Lau ba3cbc2b4a avformat/whip: fix hard code in SDP BUNDLE
In early code, the BUNDLE always has two stream
id "a=group:BUNDLE 0 1" even though there's only
one stream.

This patch aims to dynamically set BUNDLE value.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 09:18:59 +00:00
Jack Lau 69b6af0e68 avformat/whip: remove redundant NONBLOCK set for dtls
DTLS handshake already force set BLOCK mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau bbd63b5a82 avformat/whip: handle the error of dtls_initialize
Correct the log level to AV_LOG_ERROR when dtls fails

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau 42596578ee avformat/whip: put dtls init code into dtls_initialize
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Jack Lau ddf3e56514 avformat/whip: correct the ice time log
The ICE handshake actually finished after recieve
and handle binding request from peer when the peer
is not ice lite mode.

Log the ice status when it really done.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-21 08:52:28 +00:00
Ramiro Polla 96d8e19720 avcodec/mjpegdec: fix segfault on extern_huff and no extradata
Regression since 1debadd58e.
2026-01-21 03:26:02 +00:00
Jun Zhao 33dd3485ba lavf/format: skip multiple consecutive ID3v2 tags in probe
Files with multiple consecutive ID3v2 tags were getting low probe
scores (1) because av_probe_input_format3 only skipped the first tag,
leaving subsequent tags to be treated as non-audio data.

Fix by looping to skip all consecutive ID3v2 tags before probing.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-21 02:37:43 +00:00
James Almer 41a2eb735c avformat/iamf_parse: stop trying to parse files that report an unknown layout
Exporting unknown layouts as unspec type is pointless in a format that expects
the user to remix the channels in location specific ways.
This simplifies assumptions and reduces the chances of heap buffer overflows.

Fixes: heap-buffer-overflow
Fixes: clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6363647720095744
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-21 00:02:58 +00:00
Kyle Swanson 402676f130 .forgejo/CODEOWNERS: Add myself for libvmaf 2026-01-20 20:24:55 +00:00
realies c6c11b0b6d avfilter/af_loudnorm: fix limiter buffer over-allocation
The limiter_buf was being allocated with buf_size (3000ms worth of
samples) instead of limiter_buf_size (210ms worth of samples).

This resulted in allocating approximately 14x more memory than needed
for the limiter buffer. At 192kHz stereo:
- buf_size: 1,152,000 samples = 9.2 MB
- limiter_buf_size: 80,640 samples = 0.6 MB
- Wasted: ~8.2 MB per filter instance

The bug was introduced when the limiter buffer was added but the
wrong size variable was used in av_malloc_array().
2026-01-20 20:24:36 +00:00
Werner Robitza d25d133df3 avcodec/libx265: add pass and x265-stats option
Add support for standard -pass and -passlogfile options, matching the behavior
of libx264.
Add the -x265-stats option to specify the stats filename.
Update documentation.

Signed-off-by: Werner Robitza <werner.robitza@gmail.com>
2026-01-20 10:10:26 +00:00
Manuel Lauss d244d438c3 avcodec/sanm: fix BL16 c1/7 source overread
Fix the required size calculation.

Reported-by: Ruikai Peng <ruikai@pwno.io>
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2026-01-20 09:47:47 +00:00
Michael Niedermayer 70298ba1c7 .forgejo/CODEOWNERS: Add myself to MAINTAINERS
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-20 02:04:22 +00:00
Michael Niedermayer 3679341110 .forgejo/CODEOWNERS: Add myself as maintainer of CODEOWNERS
Noone is reviewing my pr for .forgejo/CODEOWNERS

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-20 02:04:22 +00:00
Andreas Rheinhardt 94b7385592 avcodec/mlpenc: Mark unreachable cases as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-20 00:38:35 +00:00
Ramiro Polla e960f0aa01 avcodec/mjpegdec: remove qscale_table field from MJpegDecodeContext
This field has been unused since 759001c534.
2026-01-19 22:42:09 +00:00
Michael Niedermayer 4d411d155a .forgejo/CODEOWNERS: Add Kyle for libavfilter/af_loudnorm.*
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-19 22:41:16 +00:00
Marton Balint 387a522106 avcodec/libvpxdec: use codec capabilities to determine if external frame buffer can be used
Previously we used the codec or at the time of decoding fb_priv for this, but
fb_priv can be nonzero even if an external frame buffer is not set, so it's
cleaner to use the capability flag directly.

Also check the result of vpx_codec_set_frame_buffer_functions.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-19 21:32:00 +00:00
Marton Balint a2688827f4 avcodec/libvpxdec: cache the decoder interface
This saves us some #ifdefry.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-19 21:32:00 +00:00
Marton Balint a6069092af avcodec/libvpxenc: log the error message from the correct encoder
It is possible that the error happens with the alpha encoder, not the normal
one, so let's always pass the affected encoder to the logging function.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-19 21:32:00 +00:00
Michael Niedermayer fc8a614f3d avcodec/omx: Check extradata size and nFilledLen
No testcase, its unknown if this is a real issue

Reported-by: Peter Teoh <htmldeveloper@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-19 20:47:22 +00:00
Michael Niedermayer 09ec2b397a avcodec/exr: use av_realloc_array()
Related to: #YWH-PGM40646-33
See: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21347
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-19 20:41:04 +00:00
Lynne 3ccafa5906 ffv1_vulkan: generate a CRC table during runtime
Since the recent CRC changes, get_table returns arch-dependent tables.
2026-01-19 16:37:17 +01:00
Lynne e3a96a69cb vulkan_dpx: remove host image upload path
The main reason this was written was due to Nvidia. Nvidia always
has a fickle upload path, and seemed to have a shortcut for the
host image upload path. This seems to have been patched out of
recent driver versions.

This upload path relies on the driver keeping the same layout,
down to the stride for the images. Which is an assumption that's
not portable.

Rather than relying on this fickle upload path, what we'd like when
we want pure bandwidth is to decouple uploads to a separate queue,
and let the GPU pull the data from RAM via uploads.

It'll be slower with a single-threaded decoder, but currently all
of our compute-based decoders and the decoders that sit underneath
them support frame threading.
2026-01-19 16:37:17 +01:00
Lynne 713e3c4f91 vulkan_decode: do not align single-plane images to subsampling
Unlike multiplane images, single-plane images do not need to be
aligned to chroma width.
Saves a bit of memory.
2026-01-19 16:37:16 +01:00
Lynne 8dcf02ac63 vulkan: remove IS_WITHIN macro
This is the more correct GLSL solution.
2026-01-19 16:37:15 +01:00
Araz Iusubov 850436a517 avcodec/amfenc: fix async_depth deadlock with lookahead
AMF encoders may deadlock when lookahead > async_depth.
Automatically adjust async_depth to lookahead + 1 to prevent hangs.
2026-01-19 15:36:37 +00:00
Zhao Zhili e35b9e7c5c configure: fix scale_vulkan_filter dependency
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-19 13:59:39 +00:00
Jack Lau 8bd5594a0f avformat/whip: fix potential out of bound read in is_dtls_packet
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau 5bc9e76ec6 avformat/whip: fix parameter order of ELAPSED
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau 5e73027099 avfotmat/whip: remove ssl_error_message since it's no longer in use
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:37:17 +08:00
Jack Lau d15a9d5961 avformat/whip: fix memleak when avio_alloc_context() fails
The buffer is prepared for avio, so we need to free
the buffer at the end when avio_alloc_context() fails,
otherwise, it will cause memleak.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-19 21:34:43 +08:00
Gyan Doshi 43dbc011fa avcodec/bsf/setts: add option prescale
When prescale is enabled, time fields are converted to the output
timebase before expression evaluation. This allows option specification
even if the input timebase is unknown.
2026-01-19 16:51:47 +05:30
Gyan Doshi 1ccd2f6243 avcodec/bsf/setts: rescale TS when changing TB
The setts bsf has an option to change TB. However the filter only
changed the TB and did not rescale the ts and duration, so it
effectively and silently stretched or squeezed the stream.

The pts, dts and duration are now rescaled to maintain temporal fidelity.
2026-01-19 16:51:31 +05:30
Dmitrii Ovchinnikov 6972b127de avfilter: Add vsrc_amf - AMF based screen capture
This patch adds screen capture support via AMF vsrc_amf:
ffmpeg -y \
    -filter_complex "vsrc_amf=framerate=120:capture_mode=keep_framerate" \
    -c:v hevc_amf \
    -frames:v 300 \
    output_grab.mp4

If the HW frames pool is insufficient,
increase extra_hw_frames in filter_complex.
2026-01-19 10:16:37 +00:00
niyinghao a5091f6d66 avfilter/formats: add type-safe functions for AVSampleFormat/AVPixelFormat lists
This avoids undefined behavior when -fshort-enums is enabled, where accessing enum arrays through int pointers causes incorrect memory reads.

Signed-off-by: niyinghao <niyinghao@xiaomi.com>
2026-01-19 09:33:49 +00:00
Zhao Zhili 8f9700bff0 avcodec/d3d12va_encode_h264: simplify deblock option to bool type
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-19 09:14:06 +00:00
Andreas Rheinhardt 063684efec avcodec/mlp: Don't use internals of CRC API
ff_mlp_restart_checksum() used the (undocumented) layout
of the CRC tables and therefore broke on x86 when the
clmul implementation added in dc03cffe9c
is used. This commit fixes this (and issue #21506).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-19 00:30:20 +01:00
Timo Rothenpieler 7379539685 avcodec/prores_raw: use av_popcount instead of limited lookup table
The calculation can yield bigger values than the lookup table provides.
So just use actual popcount instead.

Fixes #21503
2026-01-18 18:52:55 +01:00
Jack Lau cc8f392136 avformat/whip: add new option ts_buffer_size to deprecate buffer_size
See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20965#issuecomment-15854

The old option name `buffer_size` maybe confusing because there're some
protocols and muxer using this.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 03:42:05 +00:00
AnandajithS ed085692d9 doc: fix typos
Fix trivial grammatical errors.

Signed-off-by: AnandajithS <anandajiths2006@gmail.com>
2026-01-18 03:33:04 +00:00
Jack Lau 3b4ff18efe avformat/tls_gnutls: fix build error on linux
The fd_set need <sys/select.h> on linux, but it's
not included in os_support.h, it's included in os_support.c

So this patch use poll() to replace select() to avoid
this issue and simplify the code.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 01:58:37 +00:00
Jack Lau 74bc79e475 avformat/tls_gnutls: fix build error on linux
The fd_set need <sys/select.h> on linux, but it's
not included in os_support.h, it's included in os_support.c

So this patch use poll() to replace select() to avoid
this issue and simplify the code.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-18 01:57:56 +00:00
James Almer 685ceebd42 avcodec/vc1dec: fix memory leak on error
Regression since 8a1c2779a0.

Fixes CID 732271.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:56:06 -03:00
James Almer 5ec31dac94 avformat/mov: fix memory leak on error
Regression since 52b1977353.

Fixes CID 1680454.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:52:52 -03:00
James Almer c1a7c79624 avformat/hcom: check that all extradata bytes were read from the input
Fixes issue #21493.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 17:42:06 -03:00
averne 3829f4ba6a vulkan/prores: reduce push constants size
The VK specs only mandates 128B, and some platforms
don't actually implement more.  This moves the quantization
matrices to the per-frame buffer.
2026-01-17 17:33:31 +00:00
James Almer 52b1977353 avformat/mov: add overflow checks to item offset values
Fixes issue #21478.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 13:02:49 -03:00
James Almer f8e39f6c73 avcodec/hevc/ps: add missing check for profile tier level count
Fixes issue #21488.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 12:37:47 -03:00
James Almer f311969c03 avcodec/qdm2: propagate error values in the entire decoder
And add missing error value checks.

Fixes the rest of of issue #21476.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 12:03:51 -03:00
James Almer 1ffcd07400 avcodec/mimic: check return value of init_get_bits()
Fixes part of issue #21476.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 12:02:31 -03:00
James Almer bb29b51876 avcodec/vc1dec: don't overwrite error codes returned by init_get_bits8()
Done by mistake in 8a1c2779a0.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-17 11:01:21 -03:00
Ling, Edison c3d3377fe1 avcodec/d3d12va_encode: Add H264 deblock filter parameter support
add parameter `deblock` for users to explicitly enable/disable deblocking filter in d3d12 H264 encoding

usage:
-deblock enable or -deblock 1
-deblock disable or -deblock 0
-deblock auto or -deblock -1

sample command line:
```
.\ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -c:v h264_d3d12va -deblock enable -y output.mp4
```
2026-01-16 07:03:37 +00:00
Ruikai Peng be82aef7cc lavc/aacdec_usac: fix CPE channel index in ff_aac_usac_reset_state()
fix a simple index bug in ff_aac_usac_reset_state()
that writes past the end of ChannelElement.ch[2] for CPE

ff_aac_usac_reset_state() loops over channels with j < ch, but
incorrectly takes &che->ch[ch]. For CPE (ch == 2) this becomes
che->ch[2], which is one past the end of ChannelElement.ch[2], and the
subsequent memset() causes an intra-object out-of-bounds write.

index the channel element with the loop variable (j).
2026-01-15 19:32:52 +00:00
James Almer 8a1c2779a0 avcodec/vc1dec: check return values of all init_get_bits() calls
And replace them with init_get_bits8, to prevent integer overflows on huge
values.

Fixes issue #21463.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-15 16:07:46 -03:00
Michael Niedermayer 14ec28df5f tools/target_dec_fuzzer: Adjust threshold for ZMBV
Fixes: Timeout
Fixes: 464041539/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ZMBV_DEC_fuzzer-4758337414823936

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-15 19:49:43 +01:00
Raja Rathour 408dbf3c74 avfilter/vf_blackframe: add slice threading using stdatomic
Signed-off-by: Raja Rathour <imraja729@gmail.com>
2026-01-15 16:26:09 +00:00
Zhao Zhili e8daa03fee arm/timer: disable PMCCNTR timer for Android
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-15 16:06:13 +00:00
Zhao Zhili 9bb5ae3a42 avutil/hwcontext_vulkan: fix vulkan callback function prototype
Fix -Wincompatible-function-pointer-types.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-15 16:05:56 +00:00
Jun Zhao 6c878f8b82 lavf/movenc: fix missing padding for AV1 extradata
The extradata allocated in mov_write_single_packet() for AV1 was missing
the required AV_INPUT_BUFFER_PADDING_SIZE padding bytes. This could lead
to out-of-bounds reads when the extradata is parsed by bitstream readers.

Replace av_memdup() with av_malloc() + memset() + memcpy() to ensure
proper padding is present and zeroed.

Reproduced with:
./ffmpeg -y -f lavfi -i "testsrc=duration=1:size=320x240:rate=30" -c:v libaom-av1 -cpu-used 8 -crf 50 test-av1.mp4

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-14 23:56:39 +00:00
Jun Zhao b326b3a08d lavc/av1_parser: Extract SAR from render_size
Extract the Sample Aspect Ratio (SAR) from render_width_minus_1 and
render_height_minus_1 in the sequence header.

The AV1 specification defines the render dimensions, which can be used
in conjunction with the coded dimensions to determine the pixel aspect
ratio. This ensures consistent aspect ratio handling for AV1 streams
encapsulated in containers like MP4 or MKV, as observed in the updated
FATE tests where SAR changes from 0/1 to 1/1.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-14 23:56:39 +00:00
Lynne e51c549f6e vulkan/dpx: drop using the nontemporal extension
Its rarely respected by implementations, its fairly new (1 year old),
and it has a scuffed define (neither glslc nor glslang enable the
"GL_EXT_nontemporal_keyword" define if its enabled, unlike all other extensions).
2026-01-14 16:13:22 +01:00
Michael Niedermayer 805931dfc8 avfilter/scale_eval: Avoid undefined behavior with double to int cast
We use INT32_MIN/MAX so as to ensure we dont have to deal with 64bit width or height
on a int is int64 system. int64 width would overflow in a system where we assume the product of 2
values fit in int64

Fixes: #YWH-PGM40646-14
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 22:25:53 +00:00
Michael Niedermayer 5bbc8f828e avfilter/scale_eval: Use 64bit for factor_w/h
Avoids truncation and overflows

Fixes: #YWH-PGM40646-14
Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 22:25:53 +00:00
Michael Niedermayer 23c8123d5b avformat/http: Check white and blacklists on redirects
Noticed while fixing the previous

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 21:56:14 +00:00
Michael Niedermayer b9227d49ea avformat/http: Check that the protocol of redirects is http or https
Fixes: #YWH-PGM40646-10

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-13 21:56:14 +00:00
James Almer 80a3ba7d79 configure: add missing vulkan_1_4 check
Removed in f2affdfafb by mistake.
Also, fix the logic in probe_glslc() so it doesn't return false when debug is disabled.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-13 13:28:23 -03:00
James Almer f897bcd122 configure: fix glslc checks and add missing dependencies to relevant modules
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-12 18:20:01 -03:00
Lynne ab66bc5776 Makefile: add missing vpath for glsl/spv
Similar to CUDA. Fixes building on some systems.
2026-01-12 19:18:36 +01:00
Michael Niedermayer 7e9f99ef41 doc/mailing-list-faq.texi: Fix typo in link anchor
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 18:00:14 +00:00
Michael Niedermayer aa0a3e6223 .forgejo/CODEOWNERS: get notified for vf_find_rect
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 17:50:30 +00:00
Lynne 80229c161b scale_vulkan: use compile-time SPIR-V generation for debayering 2026-01-12 17:28:43 +01:00
Lynne f2a55af9a4 vulkan_dpx: switch to compile-time SPIR-V generation 2026-01-12 17:28:43 +01:00
Lynne 0f4667fc11 vulkan_prores_raw: clean up and optimize 2026-01-12 17:28:42 +01:00
averne 771b58c0b6 vulkan/prores: fix buffer alignments 2026-01-12 17:28:42 +01:00
Lynne 23ab1b1a66 vulkan/dct: embed DCT scaling values during SPIR-V generation
Instead of relying on rounded off values, use specialization constants
to bake the DCT values into the shader when its compiled.
2026-01-12 17:28:42 +01:00
Lynne e27b510da8 vulkan_prores: generate SPIR-V at compile-time 2026-01-12 17:28:42 +01:00
Lynne 026e94e339 vulkan_prores_raw: use compile-time SPIR-V generation 2026-01-12 17:28:42 +01:00
Lynne f3b0ca4f2c avgblur_vulkan: generate SPIR-V during compilation 2026-01-12 17:28:42 +01:00
Lynne a6391168f2 bwdif_vulkan: use compile-time SPIR-V 2026-01-12 17:28:42 +01:00
Lynne e32cb94258 hwcontext_vulkan: enable long vector extension
This enables us to do some neat tricks.
2026-01-12 17:28:41 +01:00
Lynne 95a23820f7 hwcontext_vulkan: enable non-uniform features we were already using 2026-01-12 17:28:41 +01:00
Lynne cf0ce1b7e4 hwcontext_vulkan: enable the VK_EXT_shader_replicated_composites extension
Its required to use certain features in SPIR-V that glslang uses.
2026-01-12 17:28:41 +01:00
Lynne dd69ebc9a8 vulkan_filter: don't use lg_size[2] as the number of workgroup.z
This was put there because who knows why, but it's wrong, this
ends up having double dispatches in the z direction if non-1.
2026-01-12 17:28:41 +01:00
Lynne e844b43776 vulkan: support shader compression 2026-01-12 17:28:41 +01:00
Lynne 7ce22b085e cuda/load_helper: move zlib decompression into a separate file
Allows it to be reused for Vulkan
2026-01-12 17:28:41 +01:00
Lynne 35235c762c configure: add zlib to suggests for shader_compression 2026-01-12 17:28:40 +01:00
Lynne 5996a9ad3d configure: rename PTX_COMPRESSION to SHADER_COMPRESSION
Its useful for GLSL and Metal as well.
2026-01-12 17:28:40 +01:00
Lynne 540c4df5c7 vulkan: add support for precompiled shaders 2026-01-12 17:28:40 +01:00
Lynne f2affdfafb configure/make: support compile-time SPIR-V generation 2026-01-12 17:28:40 +01:00
Lynne 17f9a64860 configure: rename spirv_compiler to spirv_library
More accurate.
2026-01-12 17:28:40 +01:00
Lynne f11aa29df8 configure: remove unused X86ASM dependency flag variables 2026-01-12 17:28:40 +01:00
Lynne 40edf7d75d vulkan: switch to static allocation for temporary descriptor data
Simplifies management, and the hardware is limited to 4 descriptor sets
and whatever bindings.
2026-01-12 17:28:35 +01:00
Soham ecfabc25c2 avcodec/get_bits: mark unused VLC parameters
This commit marks unused parameters in get_vlc_multi() to fix
-Wunused-parameter warnings when building with -Wall/-Wextra.

No functional changes intended.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 14:03:25 +01:00
stevxiao 21a3e44fbe avcodec/d3d12va_encode: add Region of Interest (ROI) support
This commit implements ROI (Region of Interest) encoding support for D3D12VA hardware encoders, enabling spatially-adaptive quality control for H.264, HEVC, and AV1 encoders.

Query for `D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAG_ENABLE_DELTA_QP` support during initialization to check whether the hardware support delta QP. If delta QP is supported, then process `AV_FRAME_DATA_REGIONS_OF_INTEREST` side data and generate delta QP maps for each frame.

Sample command line:
ffmpeg.exe -hwaccel d3d12va -hwaccel_output_format d3d12 -i input.mp4 -vf addroi=x=480:y=270:w=960:h=540:qoffset=-1/5 -c:v hevc_d3d12va output.mp4
2026-01-12 02:45:48 +00:00
Michael Niedermayer f99df7dbb3 avfilter/vf_find_rect: Fix handling odd sized images
Fixes: out of array read
Fixes: #YWH-PGM40646-17

Found-by: An0n99X
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-12 02:05:11 +00:00
Raja Rathour 06d799ce1a avfilter/dnn_backend_torch: handle lifecycle of worker thread
Initialize async resources in dnn_load_model_th and ensure proper cleanup and thread joining in dnn_free_model_th.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00
Raja Rathour 5e8ad5c39b avfilter/dnn_backend_torch: implement async execution logic
Update execute_model_th to support asynchronous execution by pushing tasks to the pending queue and notifying the worker thread.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00
Raja Rathour 910270b179 avfilter/dnn_backend_torch: add async infrastructure
Add worker thread, mutex, and condition variable to THModel.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
Reviewed-by: Wenbin Chen <wenbin.chen@intel.com>
Reviewed-by: Guo Yejun <yejun.guo@intel.com>
2026-01-12 08:53:42 +08:00
James Almer cd03e0a001 libavformat/evcdec.c: add a check to ensure evc_frame_merge_bsf is present
While the inclusion of the bsf is forced by a configure check, it's better to not
just have the code here assume filter will never be NULL.

Fixes Coverity issue CID 1680305.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-12 01:43:21 +00:00
Marton Balint 96e8f3b8cc avformat/vorbiscomment: fix writing huge chapter numbers and time offets to vorbiscomment
Previous code truncated chapter numbers more than 999 and and time offsets more
than 99 hours.

The Vorbis comment format only allows 1000 chapters, so cap the number of
written chapters there.

This also fixes the GCC warnings for truncated strings.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-12 00:47:20 +01:00
Marton Balint b2e077ad69 avformat/vorbiscomment: use null buf to calculate vorbis comment length
Also check possible failures when calculating length, and change return type to
int as bigger return values are no longer possible.
2026-01-12 00:47:20 +01:00
Marton Balint c80d3b35ae avformat/aviobuf: return error for ffio_close_null_buf() if written bytes exceed INT_MAX
Also check return value where it is used.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-12 00:47:20 +01:00
James Almer af136db1c3 avfilter/vf_lcevc: attach a reference to the source frame to each passed in base picture
And free them once they are guaranteed to be no longer needed, instead of freeing them
when returned with an enhanced output.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-11 17:59:15 -03:00
James Almer 188521c7ad avcodec/lcevc: attach a reference to the source frame to each passed in base picture
This way we can ensure a frame reference will always exists for as long as the
external library needs the base picture.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-11 17:59:15 -03:00
Jack Lau 24213d5db3 MAINTAINERS: add myself as whip maintainer
Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-11 04:24:55 +00:00
Jack Lau b0fe52ba4e avformat/tls_gnutls: add gnutls_pull_timeout() for dtls
See https://gnutls.org/manual/gnutls.html#index-gnutls_005ftransport_005fset_005fpull_005ftimeout_005ffunction

This callback is necessary for enforcing the DTLS mode timeouts when in blocking mode.

Otherwise the dtls pull function won't work.

The gnutls_pull_timeout() implementation refers to gnutls example:
https://gnutls.org/manual/gnutls.html#DTLS-echo-server-with-X_002e509-authentication-1

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2026-01-11 04:24:26 +00:00
Hassan Hany 202b7d29e8 avcodec/pngenc: disable background disposal for non-alpha formats 2026-01-11 00:47:17 +00:00
Andreas Rheinhardt 685011003f avcodec/x86/pngdsp: Remove MMXEXT function overridden by SSSE3
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-10 22:47:22 +01:00
Andreas Rheinhardt 31daa7cd87 avcodec/pngdsp: Use proper prefix ff_add_png->ff_png_add
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-10 22:47:22 +01:00
Andreas Rheinhardt 5f15c067fe avcodec/pngdsp: Constify
Also constify ff_png_filter_row().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-10 22:47:22 +01:00
Andreas Rheinhardt 3bbb3269a1 avcodec/pngdec: Move ff_add_png_paeth_prediction() to pngdsp.c
Also rename it to ff_png_add_paeth_prediction() so that it
has a proper prefix.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-10 22:47:22 +01:00
Zhao Zhili 8777fa60e6 avcodec/bswapdsp: improve performance by remove manually unroll
Manually unrolling loops increases code size, which can sometimes
improve performance, but more often than not, it degrades performance.
Keep the C version simple, and add assembly optimizations when needed.

                 x86-clang    x86-gcc-arch-native  x86-msvc     m1-clang      rpi5-clang       pi5-gcc-14
-------------------------------------------------------------------------------------------------------------
bswap_buf_c      57.3 ( 1.00x)  19.4 ( 1.00x)   55.4 ( 1.00x)   0.5 ( 1.00x)  143.5 ( 1.00x)   59.8 ( 1.00x)
bswap_buf_this*  49.0 ( 1.17x)  12.5 ( 1.56x)   17.7 ( 3.13x)   0.3 ( 2.04x)   57.9 ( 2.48x)   73.5 ( 0.81x)
bswap_buf_sse2   28.4 ( 2.02x)  24.3 ( 0.80x)   25.5 ( 2.18x)   -              -               -
bswap_buf_ssse3  24.6 ( 2.32x)  16.0 ( 1.22x)   19.0 ( 2.92x)   -              -               -
bswap_buf_avx2   21.2 ( 2.70x)  11.1 ( 1.74x)   11.2 ( 4.95x)   -              -               -

bswap_buf_c: C implementation before this patch
bswap_buf_this: C implementation after this patch

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-10 18:56:26 +00:00
Rémi Denis-Courmont bba42ce036 checkasm/riscv: add call checks for riscv32 2026-01-10 17:20:07 +02:00
Rémi Denis-Courmont 83477e2e18 checkasm/riscv: handle other float ABIs than double
This splits out the integer and floating point handling to add
support for software, single and quad float ABI's.
2026-01-10 17:20:07 +02:00
Rémi Denis-Courmont 2fb827bd38 checkasm/riscv: print clobbered register name
checkasm_fail_func takes a format string, so we can.
2026-01-10 17:20:07 +02:00
Rémi Denis-Courmont 68f3c1735e checkasm/riscv: restore stack before failure reporting
The faiure handling code is C and requires correct stack, global and
thread pointers. This restores them before returning to C. At the same
time, we no longer need to abort() afterwards.
2026-01-10 17:20:07 +02:00
Rémi Denis-Courmont c7dad004f3 checkasm/riscv: factor out the vector clobbers
No functional changes.
2026-01-10 17:20:07 +02:00
Jack Lau 6f2d23a009 avformat/tls_gnutls: implement dtls handshake logic
Get and set remote addr when dtls server mode.
(Refer to url_bio_bread in tls_openssl.c)

add tls_handshake function to handle the dtls
or tls handshake

TODO:
add gnutls_pull_timeout function to make dtls
handshake really work.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2026-01-10 05:30:50 +00:00
Timo Rothenpieler 69773c404a forgejo/workflows: don't cancel concurrent CI builds for non-PR pushes 2026-01-10 01:53:48 +00:00
0xBat f59968720c doc/examples/extract_mvs: fix memory leak in codec context initialization
Ensure the allocated AVCodecContext is properly freed if avcodec_parameters_to_context fails.

Signed-off-by: 0xBat <monsterbat02@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-09 23:45:07 +01:00
0xBat 786e245e80 doc/examples/qsv_transcode: check for allocation failure
Validate return value of av_malloc for dynamic_setting to avoid null pointer dereference.

Signed-off-by: 0xBat <monsterbat02@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-09 23:44:59 +01:00
0xBat 3b0409dd13 doc/examples/hw_decode: fix memory leak in codec context initialization
Properly free decoder_ctx on failure to prevent a memory leak during initialization.

Signed-off-by: 0xBat <monsterbat02@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-09 23:44:58 +01:00
Jun Zhao 91ae6d10ab lavfi/nlmeans: add aarch64 neon for compute_weights_line
Implement NEON optimization for compute_weights_line.

Also update the function signature to use ptrdiff_t for stack arguments
(max_meaningful_diff, startx, endx). This is done to unify the stack
layout between Apple platforms (which pack 32-bit stack arguments tightly)
and the generic AAPCS64 ABI (which requires 8-byte stack slots for 32-bit
arguments). Using ptrdiff_t ensures 8-byte slots are used on all AArch64
platforms, avoiding ABI mismatches with the assembly implementation.

The x86 AVX2 prototype is updated to match the new signature.

Performance benchmark (AArch64) in MacOS M4:
./tests/checkasm/checkasm --test=vf_nlmeans --bench
compute_weights_line_c:     151.1 ( 1.00x)
compute_weights_line_neon:  62.6 ( 2.42x)

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-01-09 16:10:10 +00:00
Desmond Liu 48c9c38684 fftools/ffmpeg_demux: Fix readrate sleep calculation
Calculation of max_pts and limit_pts may overflow because adding
(int64_t + int64_t + float) results in a float that easily
overflows. This can trigger a very long av_usleep().
2026-01-09 01:28:45 +00:00
Ramiro Polla 272c273d30 Revert "avcodec/jpeglsdec: Check get_bits_left() before decoding a picture"
This check has been made redundant by f80224ed19 and fe7fbf3a22.

This reverts commit 4bc3008d04.
2026-01-08 23:05:28 +00:00
Ramiro Polla 2170f397ea Revert "avcodec/mjpegdec: Check for for the bitstream end in mjpeg_decode_scan_progressive_ac()"
This commit has been made redundant by 909faca929, which is run more
often (once per mb instead of once per line).

This reverts commit 3782656631.
2026-01-08 22:33:01 +00:00
Georgii Zagoruiko 8acdffa22c aarch64/vvc: Optimisations of put_luma_v() functions for 10/12-bit
RPi4 (auto-vectorisation is on)
put_luma_v_10_4x4_c:                                   303.3 ( 1.00x)
put_luma_v_10_4x4_neon:                                 55.7 ( 5.45x)
put_luma_v_10_8x8_c:                                  1106.7 ( 1.00x)
put_luma_v_10_8x8_neon:                                163.8 ( 6.76x)
put_luma_v_10_16x16_c:                                2242.1 ( 1.00x)
put_luma_v_10_16x16_neon:                              672.7 ( 3.33x)
put_luma_v_10_32x32_c:                                7057.3 ( 1.00x)
put_luma_v_10_32x32_neon:                             2731.3 ( 2.58x)
put_luma_v_10_64x64_c:                               25699.8 ( 1.00x)
put_luma_v_10_64x64_neon:                            12145.6 ( 2.12x)
put_luma_v_10_128x128_c:                             90694.6 ( 1.00x)
put_luma_v_10_128x128_neon:                          44862.4 ( 2.02x)
put_luma_v_12_4x4_c:                                   304.4 ( 1.00x)
put_luma_v_12_4x4_neon:                                 55.6 ( 5.47x)
put_luma_v_12_8x8_c:                                  1107.4 ( 1.00x)
put_luma_v_12_8x8_neon:                                164.7 ( 6.72x)
put_luma_v_12_16x16_c:                                2235.8 ( 1.00x)
put_luma_v_12_16x16_neon:                              672.5 ( 3.32x)
put_luma_v_12_32x32_c:                                7049.2 ( 1.00x)
put_luma_v_12_32x32_neon:                             2731.6 ( 2.58x)
put_luma_v_12_64x64_c:                               25706.5 ( 1.00x)
put_luma_v_12_64x64_neon:                            12145.0 ( 2.12x)
put_luma_v_12_128x128_c:                             90672.5 ( 1.00x)
put_luma_v_12_128x128_neon:                          44857.1 ( 2.02x)

Apple M4 (auto-vectorisation is on):
put_luma_v_10_4x4_c:                                    25.6 ( 1.00x)
put_luma_v_10_4x4_neon:                                  3.1 ( 8.18x)
put_luma_v_10_8x8_c:                                    34.7 ( 1.00x)
put_luma_v_10_8x8_neon:                                 10.5 ( 3.32x)
put_luma_v_10_16x16_c:                                 103.9 ( 1.00x)
put_luma_v_10_16x16_neon:                               42.3 ( 2.45x)
put_luma_v_10_32x32_c:                                 399.7 ( 1.00x)
put_luma_v_10_32x32_neon:                              161.8 ( 2.47x)
put_luma_v_10_64x64_c:                                1276.7 ( 1.00x)
put_luma_v_10_64x64_neon:                              840.1 ( 1.52x)
put_luma_v_10_128x128_c:                              4981.3 ( 1.00x)
put_luma_v_10_128x128_neon:                           3008.0 ( 1.66x)
put_luma_v_12_4x4_c:                                    23.6 ( 1.00x)
put_luma_v_12_4x4_neon:                                  2.0 (11.84x)
put_luma_v_12_8x8_c:                                    31.8 ( 1.00x)
put_luma_v_12_8x8_neon:                                 12.4 ( 2.55x)
put_luma_v_12_16x16_c:                                 100.8 ( 1.00x)
put_luma_v_12_16x16_neon:                               44.9 ( 2.25x)
put_luma_v_12_32x32_c:                                 331.1 ( 1.00x)
put_luma_v_12_32x32_neon:                              175.2 ( 1.89x)
put_luma_v_12_64x64_c:                                1227.1 ( 1.00x)
put_luma_v_12_64x64_neon:                              712.7 ( 1.72x)
put_luma_v_12_128x128_c:                              5149.1 ( 1.00x)
put_luma_v_12_128x128_neon:                           2809.3 ( 1.83x)
2026-01-08 17:35:55 +00:00
Ramiro Polla 165448f7d1 avcodec/mjpegdec: remove buggy_avid field from MJpegDecodeContext
This field has been unused since b6c04b6821.
2026-01-08 16:29:32 +00:00
Nicolas Gaullier af6a1dd0b2 avformat/demux: duplicate side_data in parse_packet()
If an input packet results in several output packets, the side data will be
exported only by the first output packet, and be missing from the rest.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:18 -03:00
James Almer 0cca125a94 avformat/demux: prevent the loss of packet side data when using an parser
Many parsers will request data until they find what will be the start of the
next assembled packet in order to decide where to cut the current one. If this
happens, the loop in demux.c will, in case the demuxer exports already fully
assembled packets as is sometimes the case for MPEG-TS, discard the already
handled first input packet before it tries to move its side data to the output.

The affected FATE tests reflect this change by no longer dropping the side data
from the first input packet, nor exporting every other side data in the wrong
output packet.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:18 -03:00
James Almer 70d84bdd84 avformat/demux: use a stream specific temporary packet for the parser
This will be useful for the next commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-07 20:25:17 -03:00
Ruikai Peng f1dbef3e38 avcodec/mjpegdec: avoid negative len in APP parser
The APP parser can read a fixed number of bytes without checking len,
making len negative and passing it to bytestream2_skipu(), which takes
an unsigned size. This can advance the buffer by a huge amount and
results in undefined behavior.

Add small len guards in the fixed-size AVI1/LJIF paths and only skip
the tail if len > 0.

Signed-off-by: Ruikai Peng <ruikai@pwno.io>
2026-01-07 17:33:02 +00:00
Andreas Rheinhardt 1461dfcde7 avcodec/amfdec: Check correct value, return error upon error
Found via an unused-variable warning from GCC.
Also just forward the error from amf_init_frames_context().

This bug has been introduced in
4479d28103.

Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Reviewed-by: Mikhail Mironov <mikhail.mironov@amd.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 17:32:06 +01:00
Andreas Rheinhardt d595a18287 fftools/graph/graphprint: Replace always-false check by assert
This check makes no sense, as the pointer arithmetic involved
in &fg->graph_print_buf would be UB if fg were NULL.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt 9f77cb3a98 fftools/graph/graphprint: Remove always-false checks
init_graphprint() already returns an error upon allocation
failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt 9baf1b2f82 fftools/textformat/avtextformat: Move avtext_print_integers to ffprobe.c
This is its only user and because this function is so specialised
it is very likely to stay that way. So move it back to ffprobe.c
(where it already was before d7a3f68fea).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt 60684932fb fftools/textformat/avtextformat: Separate mutable and immutable data
Only two fields of AVTextFormatSection are ever modified:
entries_to_show and show_all_entries (they are only used
by ffprobe; the graph printing code always prints everything).
These fields do not belong into AVTextFormatSection, they are
more ffprobe-internal (and if the graph printing code ever
made use of them, these fields could very well be
per GraphPrintContext).

This commit therefore moves them out of AVTextFormatSection
and adds a callback to AVTextFormatContext to decide which
elements to discard. This also allows to make the AVTextFormatSections
const.

This also fixes a race when initializing the sections
for graphprint.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Vann Harl 41342aea22 configure: bump CONFIG_THIS_YEAR to 2026 2026-01-07 15:07:09 +01:00
Cosmin Stejerean 3474ec01e7 avutil/dovi_meta - fix L11 dovi metadata definition
deprecate the incorrect fields in AVDOVIDmLevel11 and schedule them
for removal
2026-01-07 13:14:11 +00:00
Cosmin Stejerean 56bc8fd0a1 avcodec/dovi_rpu(enc|dec) - fix parsing and writing of L11 DoVi metadata
sharpness, noise_reduction, mpeg_noise_reduction,
frame_rate_conversion, brightness and color are not actual fields in
L11 metadata, this appears to be based on perhaps an out of date
patent specification. Instead the two bytes are considered
reserved.

Drop reading them and write out 0s, the fields will be deprecated from
the struct in a future commit and scheduled for removal.
2026-01-07 13:14:11 +00:00
Leo Izen ec42a0aec0 avcodec/exif: avoid overflow with supplemental extra IFDs
If extra IFDs occur outside of the top level, we don't allocate enough
buffer space for them. This commit changes our calculation to include
their size always, and then we shrink the allocated buffer once every
IFD is written (by at most 192 bytes).

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2026-01-07 04:01:51 -05:00
cae e21a51b203 .forgejo/CODEOWNERS: Add myself for jpeg2000htdec
Original author

Signed-off-by: cae <etemesicaleb@gmail.com>
2026-01-06 15:32:32 +00:00
Gyan Doshi 03541f0026 avformat/hls: show stream IDs
The subdemuxer may be MPEG-TS which sets stream id, and users may
want to see it for stream selection.
2026-01-06 04:05:47 +00:00
Michael Niedermayer 6c68cbfa92 .forgejo/CODEOWNERS: Add myself for mjpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-01-06 00:25:25 +00:00
Andreas Rheinhardt 90920a645e avcodec/vc1dec: Reduce size of allocation
blk_mv_type is only set for block 0-3, not for chroma blocks,
so it only needs four elements per MB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-06 00:02:16 +01:00
Nicolas Gaullier 931b26528c avfilter/src_movie: fix support multiple frames per packet
Do not output more than one frame in one activate callback, though.

Fixes #20827.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-01-05 20:41:59 +00:00
stevxiao b9d49a333f forgejo/CODEOWNERS: add myself to d3d12va related files 2026-01-05 10:44:22 -05:00
Timo Rothenpieler b5d6cfd55b avcodec/notchlc: zero-initialize history buffer
Otherwise a specially crafted bitstream can potentially read
uninitialized stack memory.

Fixes #YWH-PGM40646-37
2026-01-05 13:30:38 +00:00
Timo Rothenpieler 7f44dcfbfb avcodec/notchlc: actually use HISTORY_SIZE to initialize history 2026-01-05 13:30:38 +00:00
Ramiro Polla 1debadd58e avcodec/mjpegdec: use GetByteContext instead of GetBitContext where possible
JPEG is mostly byte-aligned. We only really need GetBitContext while
decoding the image data.

Suggested-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-05 13:14:15 +00:00
Ramiro Polla 6f6826d2e0 avcodec/mxpegdec: remove unnecessary scope and indentation 2026-01-05 13:14:15 +00:00
Ramiro Polla fdff03425b avcodec/mjpegdec: fix indentation for previous commit 2026-01-05 13:14:15 +00:00
Ramiro Polla a84627aca9 avcodec/mjpegdec: add mjpeg_parse_len() helper
And check for length field in a consistent manner.
2026-01-05 13:14:15 +00:00
Ramiro Polla abb0247017 avcodec/mjpegdec: improve check for length in ff_mjpeg_decode_dqt() 2026-01-05 13:14:15 +00:00
wangwenchao10 2892815c45 avformat/pcmdec: Mark raw PCM stream as having no timestamps
Signed-off-by: wangwenchao10 <wangwenchao10@xiaomi.com>
2026-01-05 01:23:17 +00:00
Andreas Rheinhardt f4a1243481 doc/APIchanges: Fix typo
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 20:21:25 +01:00
Zhao Zhili 66f7e9db71 avutil/crc: use arm64 crc32 instruction
On rpi5 A76
crc_32_ieee_le_c:                       23146.3 ( 1.00x)
crc_32_ieee_le_crc:                      1060.1 (21.83x)

On RK3566 A55
crc_32_ieee_le_c:                       28773.8 ( 1.00x)
crc_32_ieee_le_crc:                      2602.4 (11.06x)

Co-authored-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Zhao Zhili 0645c48453 avutil/cpu: add CPU feature flag for arm crc32
Co-Authored-by: Martin Storsjö <martin@martin.st>
2026-01-04 15:49:30 +01:00
Martin Storsjö 3dcbcce80c configure: Check for the AArch64 CRC extension
Name the feature "arm_crc" rather than plain "crc", to make it
clear that this is about a CPU feature extension, not CRC
implementations in general.

This requires dealing with the extension slightly differently
than other extensions, as the name of the feature and the
".arch_extension" extension name differ.

Naming it with an "arm" prefix rather than "aarch64", as the
CPU extension also is available in 32 bit ARM form, even though
we don't intend to use it there.
2026-01-04 15:49:30 +01:00
Martin Storsjö 34784c89bf configure: Support aarch64 arch_extension with a different name than the feature
This allows naming the ffmpeg wide feature with a different (more
elaborate) name than the raw cpu extension as it is spelled in
the ".arch_extension" directives.
2026-01-04 15:49:30 +01:00
Martin Storsjö d4e5c08e18 configure: Use a different aarch64 feature in Clang workaround
We use a dummy aarch64 feature to work around an issue in older
Clang, where an .arch line such as ".arch armv8.2-a" doesn't take
effect immediately, while one like ".arch armv8.2-a+feature" works.

Previously, we used "crc" for this dummy feature to add (as an
old feature that would be supported widely by old toolchains).
But as we may want to actually use crc features and detect whether
they are supported, we may want to switch to another feature.

Use the "fp" feature instead, for the purposes of this extra
feature in the .arch lines. (The "fp" feature indicates floating
point support, which is implicitly part of the baseline feature
set anyway.)
2026-01-04 15:49:30 +01:00
Andreas Rheinhardt dc03cffe9c avutil/crc: Use x86 clmul for CRC when available
Observed near 10x speedup on AMD Zen4 7950x:
av_crc_c:                                            22057.0 ( 1.00x)
av_crc_clmul:                                         2202.8 (10.01x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Shreesh Adiga 1b6571c765 avutil/crc: add x86 SSE4.2 clmul SIMD implementation for av_crc
Implemented the algorithm described in the paper titled
"Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction"
by Intel.
It is not used yet; the integration will be added in a separate commit.

Observed near 10x speedup on AMD Zen4 7950x:
av_crc_c:                                            22057.0 ( 1.00x)
av_crc_clmul:                                         2202.8 (10.01x)
2026-01-04 15:49:30 +01:00
Andreas Rheinhardt 0629ebb5ff tests/checkasm: Add CRC test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Andreas Rheinhardt cf7e2b6773 tests/checkasm: Add support for using opaques to decide whether to test
This is in preparation for adding checkasm support for av_crc(),
which will always call the same function, but uses different CRC
tables to distinguish different implementations.
This reuses checkasm_check_func() for this; one could also add
a new function or use unions. This would allow to avoid casting
const away in the crc test to be added. It would also allow
to avoid converting function pointers to void* (which ISO C
does not allow).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Andreas Rheinhardt 52190efade avutil/crc: Don't assert AVCRCId to be valid
This function is supposed to return NULL on failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Shreesh Adiga e382772e4a avutil/cpu: add x86 CPU feature flag for clmul
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-04 15:49:30 +01:00
Ayose 120987543a avfilter/tests/drawvg: fix warnings on WIN32
The compiler was emitting a warning on every Cairo function replaced by
the `MOCK_FN_n` macros:

    warning: 'cairo_...': redeclared without dllimport attribute after
    being referenced with dll linkage

The macro `CAIRO_WIN32_STATIC_BUILD` prevents the attribute `dllimport` on
the declarations for these functions.

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Ayose 1333ee5294 doc/drawvg-reference: changes on color syntax.
Colors expressions (like `#RRGGBB`) can now be used as arguments for `setvar`
and `call`.

The trick of setting a variable with a `0xRRGGBBAA` value is not valid anymore.

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Ayose c7a2646bc7 avfilter/vf_drawvg: values from the p() function can be used as colors.
To be able to reuse colors from the original frame, the last value returned by
`p()` is tracked in the eval state, and if it is assigned to a variable, the
original color components are copied to `color_vars`. Thus, commands like
`setcolor` and `colorstop` can use those variables:

    setvar pixel (p(0, 0))
    ...
    setcolor pixel

`fate-filter-drawvg-video` now also verifies the `p()` function.

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Ayose 46c9584dc5 avfilter/vf_drawvg: support color expressions as setvar/call arguments.
The arguments for `setvar` and `call` commands can be colors (like `#rrggbb`).
This replaces the previous trick of using `0xRRGGBBAA` values to use colors as
procedure arguments.

The parser stores colors as the value expected by Cairo (a `double[4]`). This
array is allocated on the heap so the size of the union in `VGSArgument` is
not increased (i.e. it is still 8 bytes, instead of 32).

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Ayose 6300e340d3 avfilter/vf_drawvg: skip conversions when a color is assigned to a variable.
In libcairo, colors are defined as 4 separate components, and each one is double
between 0 and 1. Before this commit, colors stored in variables (like `defhsla`)
were converted to a `0xRRGGBBAA` value, which introduced some issues due to
rounding errors.

Now, when a color is assigned to a variable, the original values (a `double[4]`)
are stored in a dedicated array (`color_vars`), so no conversion is needed.

This change also reduces the cost of reading a color from a variable (no need
for `av_be2ne32`, or the `color[i] / 255` operations).

Signed-off-by: Ayose <ayosec@gmail.com>
2026-01-04 13:42:20 +00:00
Zhao Zhili 840183d823 aarch64/hpeldsp_neon: fix out-of-bounds read
Fix #21141

The performance improved a little bit.
On A76:
                              Before            After
put_pixels_tab[0][1]_neon:    32.4 ( 3.91x)     31.6 ( 3.99x)
put_pixels_tab[0][3]_neon:    88.0 ( 4.50x)     74.6 ( 5.31x)
put_pixels_tab[1][1]_neon:    33.5 ( 2.52x)     31.2 ( 2.71x)
put_pixels_tab[1][3]_neon:    30.5 ( 3.61x)     21.7 ( 5.08x)

On A55:
                             Before            After
put_pixels_tab[0][1]_neon:   175.2 ( 2.41x)    138.7 ( 3.04x)
put_pixels_tab[0][3]_neon:   334.3 ( 2.71x)    296.1 ( 3.07x)
put_pixels_tab[1][1]_neon:   168.3 ( 1.78x)     94.1 ( 3.19x)
put_pixels_tab[1][3]_neon:   112.3 ( 2.20x)     90.0 ( 2.74x)
2026-01-04 03:22:55 +00:00
James Almer 4fad136704 avfilter/vf_stack: add checks for the final canvas dimensions
Prevents potential integer overflows when trying to stitch absurdly huge images together.

Fixes #YWH-PGM40646-38.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-01-03 21:31:30 -03:00
Andreas Rheinhardt 649a4e98f4 tests/fate/demux: Fix dependencies of jxs-concat-demux test
It uses ffmpeg, not ffprobe.
Fixes https://fate.ffmpeg.org/report.cgi?time=20260102215443&slot=x86_64-archlinux-gcc-disableavfilter

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-03 01:27:53 +01:00
Andreas Rheinhardt 25c7f91256 tests/checkasm: Add report to tests missing them
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-03 00:04:05 +01:00
Andreas Rheinhardt 10b9984e59 tests/fate/checkasm: Run vvc_sao test during FATE
Forgotten in 45bea45c7b.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 19:48:23 +01:00
Andreas Rheinhardt fb72a3d567 avcodec/vc1_block: Simplify vc1_coded_block_pred()
Make it already apply the prediction, avoiding the pointer indirection.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 0d2ab41ec8 avcodec/h261: Remove H261Context
It only contains a single field, so add this directly to MPVContext
and remove private_ctx. This avoids an indirection in
ff_h261_loop_filter().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 3946e57797 avcodec/mpegvideo: Move permutated_intra scans to {H263Dec,MPVEnc}Ctx
Only used by these two.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt c9c452688b avcodec/wmv2dec: Avoid indirection
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 90191e8ab9 avcodec/wmv2: Remove WMV2Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt f02f948ed0 avcodec/wmv2dsp: Modify IDCTDSPContext directly
This allows to remove ff_wmv2_common_init() altogether.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 34c9438bbe avcodec/wmv2dsp: Move mspel motion functions out of WMV2DSPContext
They are only used by the decoder (which has them twice, because
the IntraX8Context contains a WMV2DSPContext whose put_mspel_pixels
functions were unused), so move them there.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 956bfec115 avcodec/wmv2: Move ff_msmpel_motion() to the decoder
mspel is not supported by the encoder.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:48 +01:00
Andreas Rheinhardt 70b58e770d avcodec/msmpeg4: Mark unreachable code as unreachable
Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:39:22 +01:00
Andreas Rheinhardt 1674ff14e9 avcodec/wmv2dec: Mark unreachable code as unreachable
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 224473b676 avcodec/wmv2dec: Don't put skip_type in context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 11b32b780f avcodec/msmpeg4: Avoid branch
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 4f4cbed928 avcodec/msmpeg4: Initialize WMV2 generically
WMV1 and WMV2 use other scantables and therefore
ff_msmpeg4_common_init() reinitializes them. Yet WMV2
also uses a different IDCT overwriting the ordinary one,
so that the IDCT permutation changes and therefore
ff_wmv2_common_init() (called after ff_msmpeg4_common_init())
needs to reinitialize the scantables again.

Avoid this by calling ff_wmv2_common_init() in
ff_msmpeg4_common_init().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 15e1e61888 avcodec/wmv2: Don't initialize BlockDSPContext redundantly
ff_mpv_common_init() already does it for us.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 18:30:43 +01:00
Andreas Rheinhardt 0e4a333683 tests/fate/checkasm: Run vf_idet tests during FATE
Forgotten in 00e05bcd68.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-02 16:58:55 +00:00
Timo Rothenpieler e6184bce67 forgejo/workflows: explicitly name all workflows and jobs 2026-01-02 16:56:03 +00:00
Zhao Zhili 85b5927083 avfilter/vf_libopencv: fix null pointer dereference
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-02 23:46:42 +08:00
Zhao Zhili 35eebc5045 avfilter/vf_libopencv: use av_unreachable
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-02 23:46:19 +08:00
Zhao Zhili 4d46eeed02 avfilter/vf_libopencv: fix memleak
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2026-01-02 23:45:52 +08:00
Ramiro Polla ee5d6e7ee1 avcodec/jpeglsdec: propagate error from ff_jpegls_decode_picture()
Fixes fe7fbf3a22
2026-01-01 23:57:08 +00:00
Marton Balint 8579037b6c avformat/file: respect pkt_size even in streaming mode
Also clarify the documentation a bit.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-01 18:20:58 +00:00
Russell Greene 38e89fe502 hwcontext_vulkan: add support for implict DRM sync for export
When a frame is exported to DRM, it may be written to to read to in an asyncronous fashion. Make sure, on unmap of a Vulkan frame that was mapped to DRM, to import any fences that were put on the dmabuf
2025-12-31 15:53:20 +00:00
Timo Rothenpieler f6a95c7eb7 avformat/img2dec: reject input images too big to fit into a single packet
Not entirely sure if it should instead use some entirely different
approach here, given that images exceeding 2GB don't seem that crazy
to me, but so far processing such images results in a heap overflow,
since the size addition overflows and a much too small packet is
allocated and its size never checked again when writing into it.

Fixes #YWH-PGM40646-32
2025-12-31 14:37:58 +00:00
Lynne 58bd5ad630 vulkan/prores_raw_idct: use the same prores_idct method for loading coeffs
This saves 2 barriers.
Also implement workbank avoidance.
2025-12-31 15:00:47 +01:00
Lynne 7f2783dcef vulkan_prores_raw: avoid long lines
Just some tidying up.
2025-12-31 15:00:47 +01:00
Lynne c3530d9a70 vulkan: remove FFVkBuffer.stage and access
Keeping global state for every buffer is unncessary and possibly
suboptimal.
2025-12-31 15:00:47 +01:00
Lynne c3e117670d vulkan_prores: use ff_vk_buf_barrier() 2025-12-31 15:00:47 +01:00
Lynne f956e9817c ffv1enc_vulkan: use ff_vk_buf_barrier() 2025-12-31 15:00:46 +01:00
Lynne 9ab3e962b4 nlmeans_vulkan: use ff_vk_buf_barrier() 2025-12-31 15:00:46 +01:00
Lynne eeeae0e0af vulkan_ffv1: use ff_vk_buf_barrier() 2025-12-31 15:00:46 +01:00
Lynne 95baff9b61 vulkan: add ff_vk_buf_barrier()
This is a shorthand way of writing buffer barrier structures.
2025-12-31 15:00:46 +01:00
Lynne b7d2469e4c vulkan_functions: add vkCmdDispatchBase
Its useful for multi-stage operations.
2025-12-31 15:00:46 +01:00
Lynne 9f3a04d2f6 vulkan: use HOST_CACHED memory flag only if such a heap exists
NVK does not offer such, so our code failed to allocate memory.
2025-12-31 15:00:46 +01:00
Lynne bb30126349 hwcontext_vulkan: enable the explicit shader workgroup extension
Its useful as it allows us to alias memory in shaders.
2025-12-31 15:00:45 +01:00
Lynne d70c6cb511 hwcontext_vulkan: enable subgroup extended types
We were already using them, but had forgotten to enable them.
2025-12-31 15:00:12 +01:00
Kacper Michajłow eea648ef1d avutil/hwcontext_vulkan: fix logic error when checking for encode support
Both FF_VK_EXT_VIDEO_ENCODE_QUEUE and FF_VK_EXT_VIDEO_MAINTENANCE_1 are
required, not only one of them.

Found by VVL.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-31 10:30:36 +00:00
Kacper Michajłow 20ac8c3688 avfilter/vulkan_filter: fix logic error when checking for encode support
Both FF_VK_EXT_VIDEO_ENCODE_QUEUE and FF_VK_EXT_VIDEO_MAINTENANCE_1 are
required, not only one of them.

Found by VVL.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-31 10:30:36 +00:00
Kacper Michajłow 0a8b915b04 avcodec/vulkan_decode: fix logic error when checking for encode support
Both FF_VK_EXT_VIDEO_ENCODE_QUEUE and FF_VK_EXT_VIDEO_MAINTENANCE_1 are
required, not only one of them.

Found by VVL.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-31 10:30:36 +00:00
hajin-chung 991ba3fbac avcodec/qsvdec: fix refcount leak in two-stage QSV init
The temporary hw_frames_ctx created for header parsing was not being
fully released, leading to a leak. Explicitly unreference the temporary
context after use to resolve the leak.

Signed-off-by: hajin-chung <hajinchung1@gmail.com>
2025-12-31 08:06:48 +00:00
Leo Izen 4bfac71ecd avcodec/exif.c: avoid buffer overflow with extra IFDs
Maliciously constructed input EXIF blocks could use the extra IFDs we
set aside in noncontinugous ways, which will cause them to be written
as subdirectories of IFD0 rather than existing IFDs. The base tag size
is (correctly) excluded from the size calculation, but if they are
being written as additional tags, the allocation will be too small and
a write may overflow.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-30 20:43:49 -05:00
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
Michael Niedermayer d1985442e1 avformat/hls: Check seg size and offset for overflow
Fixes: integer overflow
Fixes: signed integer overflow: 9223372036854775807 + 2039324394 cannot be represented in type 'int64_t' (aka 'long')

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
Michael Niedermayer 8ac6325143 avcodec/adpcm: check block_align for PSXC
Fixes: division by 0
Fixes: 457634826/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_PSXC_DEC_fuzzer-4903668521697280

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 02:51:20 +00:00
Jack Lau 13c91c97d1 avcodec/libjxldec: goto SUCCESS when frame is completed
Fix #21260

The early code didn't reset the JxlDecoder. If the
caller re-send the same packet to JxlDecoder after
avcodec_flush_buffers() (free ctx->frame). It will
directly hit SUCCESS event (skip all EVENTs).

In this case, the ctx->frame already flushed by
avcodec_flush_buffers, so the received frame
will be invalid (has no private_ref) that causes
assertion in decode_receive_frame_internal().

MPV meet this issue because it seek the jxl image
(second read the same pkt) when it does crop
through config `C vf toggle crop=in_w:in_w/2.4`.

This patch make sure hit the entire SUCCESS event
(contains reset the JxlDecoder) when frame_complete
is true.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-24 02:43:50 +00:00
Michael Niedermayer d60c1d72c1 avcodec/jpeg2000dec: Make M_b check broader
Fixes: shift exponent -1 is negative
Fixes: 429330004/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_DEC_fuzzer-4733213845291008

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-23 20:11:29 +00:00
Lynne e5eef271a5 vulkan: set .decode_extension to 0 for compute-based decoders
They require no special video decode extension. The push descriptor
extension was a placeholder for when the check was performed inside
the init function.
2025-12-23 15:42:24 +01:00
Damitha Gunawardena bb769d9d90 avcodec/gifenc: avoid redundant local color table when global palette is used
Addressing the fact that first frame has a LCT when global pallette is used for pal8.
issue: #20896
2025-12-23 14:34:13 +00:00
Andreas Rheinhardt 26a7fc2ac4 avfilter/vf_waveform: Avoid relocations
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-23 11:02:04 +01:00
Andreas Rheinhardt 6460d3bc81 avfilter/vf_waveform: don't cast const away
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-23 11:01:42 +01:00
Michael Niedermayer d41b8d95a7 swscale/output: Use 64bit in addition in yuv2gbrp16_full_X_c() for RGB + Y
Fixes: signed integer overflow: -1159988356 + -1082982400 cannot be represented in type 'int'
Fixes: 461519938/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4777382021234688

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-23 09:14:44 +00:00
Zhao Zhili 09d8300779 avutil/imgutils: use AV_CEIL_RSHIFT 2025-12-23 03:39:16 +00:00
Zhao Zhili 260f5a47a5 avformat/rawvideodec: add stride option to skip line padding
Some tools like v4l2-ctl dump data without skip padding. If the
padding size is not an integer multiple of the number of pixel
bytes, we cannot handle it by using a larger width, e.g.,, for
RGB24 image with 32 bytes padding in each line.
2025-12-23 03:20:34 +00:00
Zhao Zhili 49a15e70be avformat/rawvideodec: use AV_OPT_TYPE_PIXEL_FMT instead of parse from string manually 2025-12-23 03:20:34 +00:00
Romain Beauxis 5ae21f06a3 tests/fate/id3v2.mak: Use run wrapper in fate-id3v2-invalid-tags 2025-12-22 22:34:48 +00:00
Niklas Haas fafd72ef04 swscale/ops_internal: fix ff_sws_pack_op_decode()
This function was assuming that the bits are MSB-aligned, but they are
LSB-aligned in both practice (and in the actual backend).

Also update the documentation of SwsPackOp to make this clearer.

Fixes an incorrect omission of a clamp after decoding e.g. rgb4, since
the max value range was incorrectly determined as 0 as a result of unpacking
the MSB bits instead of the LSB bits:

 bgr4 -> gray:
   [ u8 XXXX -> +XXX] SWS_OP_READ         : 1 elem(s) packed >> 1
   [ u8 .XXX -> +++X] SWS_OP_UNPACK       : {1 2 1 0}
   [ u8 ...X -> +++X] SWS_OP_SWIZZLE      : 2103
   [ u8 ...X -> +++X] SWS_OP_CONVERT      : u8 -> f32
   [f32 ...X -> .++X] SWS_OP_LINEAR       : dot3 [...]
   [f32 .XXX -> .++X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 5}
+  [f32 .XXX -> .++X] SWS_OP_MIN          : x <= {255 _ _ _}
   [f32 .XXX -> +++X] SWS_OP_CONVERT      : f32 -> u8
   [ u8 .XXX -> +++X] SWS_OP_WRITE        : 1 elem(s) planar >> 0
     (X = unused, + = exact, 0 = zero)
2025-12-22 20:14:31 +00:00
Lynne 6656b11a7b hwcontext_vulkan: disable host transfers on MoltenVK
https://github.com/KhronosGroup/MoltenVK/issues/2618
2025-12-22 19:46:27 +01:00
Lynne d33bf66519 vulkan_functions: add vkCmdUpdateBuffer
It embeds the data to be uploaded directly into the command buffer,
which makes it useful for uploading transient data.
2025-12-22 19:46:27 +01:00
Lynne 8db6947700 vulkan_prores_raw: reduce zigzag table size
No need for full 32-bits.
2025-12-22 19:46:27 +01:00
Lynne cfcf52a08c vulkan: deduplicate shorthand casting defines to common.comp 2025-12-22 19:46:27 +01:00
Lynne 6eced88188 vulkan: merge ProRes and ProRes RAW iDCTs
This cleans up the code a bit, and reduces binary size.
2025-12-22 19:46:26 +01:00
Lynne ea14f8a28f vulkan_prores: split up shader creation functions
Its more mess that it has to be.
2025-12-22 19:46:26 +01:00
Rémi Denis-Courmont eb3b632b48 lavc/h264qpel: fix RISC-V stack usage
The function violated the ABI requirement not to write below SP
(this breaks asynchronous signal handling). On RV32, it also broke
did not align SP to 16 bytes and did not restore it correctly.

No changes to benchmarks as this patch only changes a few immediate
offsets.
2025-12-22 18:55:20 +02:00
Rémi Denis-Courmont 65018b3e83 lavu/float_dsp: fix R-V V scalarpdocut_double with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont 435623cbda lavu/float_dsp: fix R-V V vector_dmul_scalar with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont 56d933b0a7 lavu/float_dsp: fix R-V V vector_dmac_scalar with ILP32 ABI 2025-12-22 18:55:16 +02:00
Rémi Denis-Courmont a583639bf0 lavu/fixed_dsp: fix scalarproduct on riscv32
On riscv32, the result must be narrowed from 63 to 32 bit before being
moved to the scalar side.
2025-12-22 18:55:13 +02:00
Araz Iusubov 4479d28103 avcodec/avfilter_amf: correct handling of AMF errors
Fix several AMF-related issues.

Check the return value of amf_init_frames_context() correctly in amfdec,
as it returns int rather than AMF_RESULT.

Handle possible NULL surfaces returned from QueryInterface() in
vf_amf_common to avoid passing invalid data to amf_amfsurface_to_avframe().

Remove FILTER_SINGLE_PIXFMT from vf_sr_amf since it must not be used
together with a query formats function.
2025-12-22 14:58:59 +00:00
Romain Beauxis b43645b2ef libavformat/id3v2.c: return valid string in decode_str for empty strings
with no bom. Fixes: #YWH-PGM40646-12
2025-12-22 13:44:42 +00:00
Kacper Michajłow c50e5c7778 avcodec/libaomenc: remove enum type from codecctl_* functions
aom_codec_control() takes control id as int. It could be AV1E_ or common
AV1_ enum in encoder, and AV1D_ for decoder.

While upstream provides AOM_CODEC_CONTROL_TYPECHECKED() macro to check
the provided enum value, we wrap those calls in codecctl_ functions,
which makes it not feasible to use.

To avoid complicating this needlessly, just use int.

Fixes: warning: implicit conversion from enumeration type 'enum aom_com_control_id' to different enumeration type 'enum aome_enc_control_id'
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-22 07:05:58 +01:00
Kacper Michajłow 96afe665ef avcodec/libaomenc: remove UENUM1BYTE check
AOM had a short-lived API breakage introduced in commit [1], which was
workedaround in commit [2]. The original change, however, was reverted
shortly afterward in commit [3]. Since we require at least v2.0.0, there
is no need to keep this workaround.

[1] https://aomedia.googlesource.com/aom/+/4667aa1a373566e9c124afcd58c71731ab0d7377
[2] aaf9171574
[3] https://aomedia.googlesource.com/aom/+/9b1252eab0616d2c1f6d7990c6256441c0b6483f

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-22 07:05:58 +01:00
stevxiao 64b9be2dc5 avcodec/d3d12va_encode: support motion estimation precision mode
By default, the D3D12 video encoder uses MAXIMUM, which means no restriction—it uses the highest precision supported by the driver.

Applications may want to reduce precision to improve speed or reduce power consumption. This requires the encoder to support user-defined motion estimation precision modes.

D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE defines several precision modes:

maximum: No restriction, uses the maximum precision supported by the driver.
full_pixel: Allows only full-pixel precision.
half_pixel: Allows half-pixel precision.
quarter-pixel: Allows quarter-pixel precision.
eighth-pixel: Allows eighth-pixel precision (introduced in Windows 11).

Sample Command Line:

ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 -extra_hw_frames 20 -i input.mp4 -an -c:v h264_d3d12va -me_precision half_pixel out.mp4
2025-12-22 05:35:04 +00:00
Gyan Doshi 1fcb201ab1 configure: update dependencies
These muxers - hls, tee, whip - open other muxers.
In addition, whip requires http protocol.
2025-12-21 04:16:10 +00:00
Leo Izen 784aa09fa8 avcodec/exif: parse additional EXIF IFDs
Most EXIF metadata is in IFD0 and most EXIF payloads only contain
one IFD, but it is possible for there to be more IFDs after the
existing trailing one. exiftool and similar software report these IFDs
as IFD1, IFD2, etc. This commit reads those additional IFDs and attaches
them as dummy entries in the top-level IFD ranging from 0xFFFC down to
0xFFED, which are unused by the EXIF spec. The EXIF API is only able to
return and work with a single IFD, so by attaching it as a subdirectory
this metadata can be preserved.

This is done transparently through the read/write process. Upon parsing
an additional IFD1, it will be attached, but it will be written with
av_exif_write after IFD0 rather than as a subdirectory, as intended.

Existing files without more than one IFD, i.e. most files, will be unaffected
by this change, as well as API clients looking to parse specific fields, but
now more metadata is parsed and written, rather than simply being discarded
as trailing data.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-20 11:53:23 -05:00
Leo Izen 105b6fcd9c avcodec/exif: avoid leaking EXIF metadata upon parse failure
Before this commit, exif_parse_ifd_list didn't free *ifd upon failure,
relying on the caller to do so instead. We only guarded some of the
calls against this function, not all of them, so sometimes it leaked.

This commit fixes this, so exif_parse_ifd_list freeds *ifd upon failure
so callers do not have to guard its invocation with a free wrapper.

Fixes: ossfuzz 440747118: Integer-overflow in av_strerror

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-20 11:53:21 -05:00
Niklas Haas 7505264b6a swscale/ops: update comment on SWS_COMP_EXACT
That the integer is "in-range" is implied by the min/max range tracking,
not the flag itself.
2025-12-20 13:52:45 +00:00
Niklas Haas 1d0fd7fabf swscale/ops: categorize ops by type compatibility
This is a more useful grouping than the previous, somewhat arbitrary one.
2025-12-20 13:52:45 +00:00
Niklas Haas 94777ed2eb swscale/ops_chain: fix comment 2025-12-20 13:52:45 +00:00
Niklas Haas 75ba2bf457 swscale/ops: correctly truncate on ff_sws_apply_op_q(SWS_OP_RSHIFT)
Instead of using a "precise" division, simulate the actual truncation.

Note that the division by `den` is unneeded in principle because the
denominator *should* always be 1 for an integer, but this way we don't
explode if the user should happen to pass `4/2` or something.

Fixes a lot of unnecessary clamps w.r.t. xv36, e.g.:

 xv36be -> yuv444p12be:
   [u16 XXXX -> ++++] SWS_OP_READ         : 4 elem(s) packed >> 0
   [u16 ...X -> ++++] SWS_OP_SWAP_BYTES
   [u16 ...X -> ++++] SWS_OP_SWIZZLE      : 1023
   [u16 ...X -> ++++] SWS_OP_RSHIFT       : >> 4
-  [u16 ...X -> ++++] SWS_OP_CONVERT      : u16 -> f32
-  [f32 ...X -> ++++] SWS_OP_MIN          : x <= {4095 4095 4095 _}
-  [f32 ...X -> ++++] SWS_OP_CONVERT      : f32 -> u16
   [u16 ...X -> ++++] SWS_OP_SWAP_BYTES
   [u16 ...X -> ++++] SWS_OP_WRITE        : 3 elem(s) planar >> 0
     (X = unused, + = exact, 0 = zero)
2025-12-20 13:52:45 +00:00
Niklas Haas d1eaea1a03 swscale/ops: add type assertions to ff_sws_apply_op_q() 2025-12-20 13:52:45 +00:00
Niklas Haas 258dbfdbc9 swscale/format: only generate SHIFT ops when needed
Otherwise, we may spuriously generate illegal combinations like
SWS_OP_LSHIFT on SWS_PIXEL_F32.
2025-12-20 13:52:45 +00:00
Niklas Haas c31f3926d1 swscale/ops_optimizer: simplify loop slightly (cosmetic)
We always `goto retry` whenever an optimization case is hit, so we don't
need to defer the increment of `n`.
2025-12-20 13:52:45 +00:00
Niklas Haas 900d91b541 swscale/ops_optimizer: apply optimizations in a more predictable order
Instead of blindly interleaving re-ordering and minimizing optimizations,
separate this loop into several passes - the first pass will minimize the
operation list in-place as much as possible, and the second pass will apply any
desired re-orderings. (We also want to try pushing clear back before any other
re-orderings, as this can trigger more phase 1 optimizations)

This restructuring leads to significantly more predictable and stable behavior,
especially when introducing more operation types going forwards. Does not
actually affect the current results, but matters with some upcoming changes
I have planned.
2025-12-20 13:52:45 +00:00
Niklas Haas c51c63058c swscale/ops_optimizer: don't commute clear with itself
These would normally be merged, not swapped.
2025-12-20 13:52:45 +00:00
Andreas Rheinhardt b934dd1d4b avformat/whip: Fix leak of dtls_fingerprint
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:45:24 +01:00
Andreas Rheinhardt 34bc95ddfc avformat/whip: Check number of audio/video streams generically
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:45:21 +01:00
Andreas Rheinhardt e252bc0c3d avformat/whip: Remove dead code
This is checked generically after
6070ea29de.
Also set AVOutputFormat.subtitle_codec explicitly in order
not to rely on AV_CODEC_ID_NONE to be zero.

Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Jack Lau <jacklau1222gm@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 21:42:27 +01:00
Andreas Rheinhardt 6177af5acc avcodec/x86/lossless_videodsp: Avoid unnecessary reg push,pop
Happens on Win64.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:56:09 +01:00
Andreas Rheinhardt 9314d5cae8 avcodec/x86/lossless_videodsp: Avoid aligned/unaligned versions
For AVX2, movdqu is as fast as movdqa when used on aligned addresses,
so don't instantiate aligned/unaligned versions.

(The check was btw overtly strict: The AVX2 code only uses 16 byte
stores, so it would be enough for dst to be 16-byte aligned.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:55:53 +01:00
Andreas Rheinhardt 6368d2baae avcodec/x86/lossless_videodsp: Don't store in eight byte chunks
Use movu (movdqu) instead of movq+movhps.

Old benchmarks:
add_left_pred_int16_c:                                2265.5 ( 1.00x)
add_left_pred_int16_ssse3:                             595.4 ( 3.81x)
add_left_pred_rnd_acc_c:                              1255.0 ( 1.00x)
add_left_pred_rnd_acc_ssse3:                           326.2 ( 3.85x)
add_left_pred_rnd_acc_avx2:                            279.0 ( 4.50x)
add_left_pred_zero_c:                                 1249.5 ( 1.00x)
add_left_pred_zero_ssse3:                              326.1 ( 3.83x)
add_left_pred_zero_avx2:                               277.0 ( 4.51x)

New benchmarks:
add_left_pred_int16_c:                                2266.9 ( 1.00x)
add_left_pred_int16_ssse3:                             509.9 ( 4.45x)
add_left_pred_rnd_acc_c:                              1251.4 ( 1.00x)
add_left_pred_rnd_acc_ssse3:                           282.6 ( 4.43x)
add_left_pred_rnd_acc_avx2:                            208.9 ( 5.99x)
add_left_pred_zero_c:                                 1253.7 ( 1.00x)
add_left_pred_zero_ssse3:                              280.0 ( 4.48x)
add_left_pred_zero_avx2:                               206.8 ( 6.06x)

The checkasm test has been modified to use an unaligned destination
for this test.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:55:37 +01:00
Andreas Rheinhardt bb523a2d3f tests/checkasm/llviddsp: Reindent after the previous commit
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:55:33 +01:00
Andreas Rheinhardt b2dea09de1 tests/checkasm/llviddsp: Avoid unnecessary initializations, allocs
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:55:20 +01:00
Andreas Rheinhardt a6b8939e1e avcodec/x86/lossless_videodsp: Remove SSSE3 functions using MMX regs
These functions are only used on Conroe (they are overwritten
by SSSE3 functions using xmm registers if the SSSE3SLOW is not set)
which is very old (introduced in 2006), so remove them.

Btw: The checkasm test (which uses declare_func and not
declare_func_emms since cd8a33bcce)
would fail on a Conroe, yet no one ever reported any such failure.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 20:54:44 +01:00
Martin Storsjö cf608f6b65 checkasm: Use av_strlcatf for appending SME info after SVE
If we had SVE enabled and formatted info about its vector lengths,
it would be overwritten by the SME info.
2025-12-19 18:42:10 +00:00
Martin Storsjö ec2ceefcfa fate.sh: Allow specifying --ar through a separate variable
This avoids needing to use the extra_conf variable. That variable
is problematic for setting a value that contains spaces.

This adds options for another tool in the same fashion as other
tools were added in 523d688c2b.
2025-12-19 18:41:23 +00:00
Martin Storsjö 06a17fdafc tests: Fix fate-run.sh to handle busybox-w32 absolute paths
Busybox-w32 uses regular Windows style paths with drive letters,
but with forward slashes; thus an absolute path starts with "c:/".

Make the target_path() function in fate-run.sh (which converts a
potentially relative path to an absolute one, under the target_path
prefix) handle this case.

With this in place, running fate tests almost works in
busybox-w32 - only one issue remains. A patch [1] has been sent to
upstream busybox for fixing that issue (which also is present if
running fate tests on busybox on Linux), but it hasn't been
responded to yet.

[1] https://lists.busybox.net/pipermail/busybox/2025-December/091851.html
2025-12-19 18:38:33 +00:00
Martin Storsjö 6149ceadeb configure: Recognize uname "Windows_NT" as using an .exe suffix
Busybox-w32 [1] works for building ffmpeg on Windows (as an
alternative to msys2, cygwin or WSL).

On busybox-w32, "uname" returns "Windows_NT"; recognize this
in exesuf() as having an .exe suffix.

If building in this environment with a mingw toolchain, one has
to explicitly set --target-os=mingw32. (We probably don't
want to imply that this uname, set as target_os_default, would
default to mingw?) But despite what is set with --target-os,
one can't override the configure variable "host_os", which
exesuf() has to recognize.

[1] https://github.com/rmyorston/busybox-w32
2025-12-19 18:38:33 +00:00
Rémi Denis-Courmont 55200f999c lavc/mathops: R-V B optimisation for mid_pred
If Zbb is enabled at compilation (e.g. Ubuntu), the compiler should
compile the new C mid_pred() function correctly. But if Zbb is *not*
enabled (e.g. Debian), then we can at least fallback at run-time.

On SiFive-U74, before:
sub_median_pred_c:                                    1331.9 ( 1.00x)
sub_median_pred_rvb_b:                                 881.8 ( 1.51x)

After:
sub_median_pred_c:                                    1133.1 ( 1.00x)
sub_median_pred_rvb_b:                                 875.7 ( 1.29x)
2025-12-19 19:56:13 +02:00
Rémi Denis-Courmont ccd7e66f9e lavc/mathops: remove bespoke Arm mid_pred()
The C codegen is as good if not slightly better than the assembler at
this point.
2025-12-19 19:56:13 +02:00
Rémi Denis-Courmont 8dccb380cf lavc/mathops: simplify mid_pred()
This reduces the minimum instruction emission for mid_pred()
(i.e. median of 3) down to:
- 3 comparisons and 4 conditional moves, or
- 4 min/max.

With that the compiler can eliminate any branch. This optimal
situation is attainable with Clang 21 on Arm64, RVA22 and x86,
with GCC 15 on Arm64 and x86 (RVA22 goes from 2 to 1 branch).
These optimisations also work on Arm32 and LoongArch.

The same algorithm is already implemented via inline assembler for some
architectures such as x86 and Arm32, but notably not Arm64 and RVA22.
Besides, using C code allows the compiler to schedule instruction
properly.

Even on architectures with neither conditional moves nor min/max, this
leads to a visible performance improvement for C code, as seen here for
RVA20 code running on SiFive-U74:

Before:
sub_median_pred_c:                                    1657.5 ( 1.00x)
sub_median_pred_rvb_b:                                 875.9 ( 1.89x)

After:
sub_median_pred_c:                                    1331.9 ( 1.00x)
sub_median_pred_rvb_b:                                 881.8 ( 1.51x)

Note that this commit leaves the x86 and Arm32 code intact so it has
no effects on those ISA's.
2025-12-19 19:50:56 +02:00
Harishmcw 5946d2eadc compat: Fix .def file generation for ARM64EC builds on Windows
When building DLLs on ARM64EC, the default use of `dumpbin
-linkermember:1` fails because ARM64EC static libraries use a
different linker member format. Use `-linkermember:32` for ARM64EC
to correctly extract symbols.

Additionally, MSVC inserts $exit_thunk and $entry_thunk symbols
for ARM64EC to handle x64 ↔ ARM64 transitions. These are internal
thunks and must not be exported. Filter them out when generating
the .def file to avoid unresolved symbols or invalid exports.

Trim out the leading '#' on ARM64EC function symbols. This is only
relevant on ARM64EC, but it is benign to do that filtering on
all architectures (such symbols aren't expected on other
architectures).

Simplify the sed command by removing the symbol address with a
sed expression instead of a later "cut" command.

This ensures correct symbol extraction and stable DLL generation
on ARM64EC targets, while keeping behavior unchanged for other
Windows architectures.
2025-12-19 10:01:16 +00:00
Martin Storsjö 087f46674a doc: Document our stance on Windows ARM64EC
Explicitly spell it out that we are not going to modify the
individual libraries for the purposes of improving conformance
to ARM64EC.

We may (or may not) accept build system patches for making such
a build succeed, provided that it does not require changes to
the actual library code.
2025-12-19 10:01:16 +00:00
Andreas Rheinhardt 1c35a1b79b avformat/flvdec: Fix leak of channel layout map
Fixes: memleak
Fixes: 418396714/clusterfuzz-testcase-minimized-ffmpeg_dem_KUX_fuzzer-4595253332213760

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 08:02:52 +01:00
Andreas Rheinhardt 4aed9db83c avformat/flac_picture: Correct check
Since af97c9865f,
the return value of avio_read() has been compared against
an uint32_t, so that the int is promoted to uint32_t for
the comparison (on common systems with 32bit ints). The upshot was
that errors returned from avio_read() were ignored, so that
the buffer could be uninitialized on success.

Fix this by using ffio_read_size() instead.

Fixes: MemorySanitizer: use-of-uninitialized-value
Fixes: 443923343/clusterfuzz-testcase-minimized-ffmpeg_dem_FLAC_fuzzer-5458132865449984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-19 07:32:01 +01:00
Gyan Doshi 6070ea29de lavf/whip: add flag for default codecs only
The muxer does not accept any other codecs.
2025-12-19 04:13:34 +00:00
Gyan Doshi fdce17953c lavf/supenc: add flag for default codecs only
The muxer does not accept any other codecs.
2025-12-19 04:13:34 +00:00
Gyan Doshi 20b671f651 lavf/dvenc: add flag for default codecs only
The muxer does not accept any other codecs.
2025-12-19 04:13:34 +00:00
James Almer 78c75d546a avcodec/apv_parser: add support for AU assembly
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-18 01:24:35 +00:00
Timo Rothenpieler 0d7b8d8913 forgejo/workflows: fix error handling of configure result 2025-12-17 13:28:21 +00:00
Timo Rothenpieler 0be989edcb forgejo/workflows: cat .err files after running fate 2025-12-17 13:28:21 +00:00
Timo Rothenpieler 5e8dcd6db1 forgejo/workflows: run windows fate tests through wine 2025-12-17 13:28:21 +00:00
James Almer d828183d2d doc: add missing JPEG-XS details
Forgotten in 3332b2db84

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-17 00:20:41 -03:00
Timo Rothenpieler 4bb9b46486 avcodec/demux: validate avctx state in has_decode_delay_been_guessed 2025-12-16 22:45:17 -03:00
James Almer c9c95f6f32 avformat/demux: ensure avformat_find_stream_info updates internal stream contexts
read_frame_internal() may result in a stream being modified without also
returning a packet from it. Given said function only bothered to update the
internal stream context for the returned packet, the result would be a desync
between the stream's AVCodecParameters and the internal AVCodecContext.

This change makes sure all streams are updated within the
avformat_find_stream_info() loop.

Fixes #YWH-PGM40646-20

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-16 22:45:17 -03:00
Dariusz Marcinkiewicz c41155e614 libavcodec: support frame dropping in libvpxenc
vp8 encoder can be configured to drop frames, when e.g. bitrate
overshoot is detected. At present the code responsible for
managing an internal fifo assumes that we will get an output frame per
each frame fed into encoder. That is not the case if the encoder can
decide to drop frames.

Running:
ffmpeg -stream_loop 100 -i dash_video3.webm -c:v libvpx -b:v 50k
-drop-threshold 20 -screen-content-mode 2 output.webm

results in lots of warnings like:
[libvpx @ 0x563fd8aba100] Mismatching timestamps: libvpx 2187 queued
2185; this is a bug, please report it
[libvpx @ 0x563fd8aba100] Mismatching timestamps: libvpx 2189 queued
2186; this is a bug, please report it

followed by:
[vost#0:0/libvpx @ 0x563fd8ab9b40] [enc:libvpx @ 0x563fd8aba080] Error
submitting video frame to the encoder
[vost#0:0/libvpx @ 0x563fd8ab9b40] [enc:libvpx @ 0x563fd8aba080] Error
encoding a frame: No space left on device
[vost#0:0/libvpx @ 0x563fd8ab9b40] Task finished with error code: -28
(No space left on device)
[vost#0:0/libvpx @ 0x563fd8ab9b40] Terminating thread with return code
-28 (No space left on device)

The reason for the above error is that each dropped frame leaves an
extra item in the fifo, which eventually overflows.

The proposed fix is to keep popping elements from the fifo until the
one with the matching pts is found. A side effect of this change is that
the code no longer considers pts mismatch to be a bug.

This has likely regressed around 5bda4ec6c3
when fifo started to be universally used.

Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
2025-12-16 21:53:10 +00:00
Rémi Denis-Courmont 7ee5c907e5 lavfi/vf_blackdetect: R-V V count_pixels_16
SpacemiT X60:
blackdetect16_c:                                      7171.0 ( 1.00x)
blackdetect16_rvv_i32:                                 383.6 (18.69x)
2025-12-16 17:30:29 +02:00
Rémi Denis-Courmont 570908af09 lavfi/vf_blackdetect: R-V V count_pixels_8
SpacemiT X60:
blackdetect8_c:                                      14911.0 ( 1.00x)
blackdetect8_rvv_i32:                                  369.5 (40.35x)
2025-12-16 17:30:23 +02:00
James Almer 1d662641c5 tests/fate/demux: add a raw JPEG-XS demux test
Use the concat protocol, to test the parser's capabilities to differentiate between
EOC maker before SOC marker, on top of false EOC marker positives and EOC maker on EOF.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-16 10:38:56 -03:00
James Almer 1c804b349e avcodec/jpegxs_parser: fix bitstream assembly logic
JPEG-XS streams can have the bytes corresponding to certain markers as part of
slice data, and no considerations were made for it, so we need to add checks
for false positives.

This fixes assembling several samples.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-16 10:38:56 -03:00
Martin Storsjö 477e2dbc39 checkasm: Add a comment about adding new tests to checkasm.mak 2025-12-16 09:47:05 +00:00
rcombs d1962881ae swscale: use configured YUV matrix with paletted-RGB inputs
This replaces hardcoded BT601.
2025-12-16 01:24:40 +00:00
Rémi Denis-Courmont 29185f708f lavc/riscv: fix dependency for llvidencdsp 2025-12-15 18:40:13 +02:00
Rémi Denis-Courmont 468eca2854 checkasm: test all plane configurations with sub_left_predict
The original code didn't really make sense, never iterating the loop
and never testing non-first plane configurations.
2025-12-15 18:39:53 +02:00
Rémi Denis-Courmont acb38d320b lavc/llvidencdsp: fix R-V V sub_left_predict
The code assumed that the destination buffer was zeroed, a misbehaviour
with which checkasm is bug-compatible as it zeroes the destination
buffer. The fixed code is even faster:

SpacemiT X60:
sub_left_predict_c:                                  51792.5 ( 1.00x)
sub_left_predict_rvv_i32:                             3504.4 (14.78x)
2025-12-15 18:35:58 +02:00
Niklas Haas 18edb246c8 swscale/ops_optimizer: correctly commute swizzles with dither ops
This requires updating the order of the dither matrix offsets as well. In
particular, this can only be done cleanly if the dither matrix offsets are
compatible between duplicated channels; but this should be guaranteed after
the previous commits.

As a side note, this also fixes a bug where we pushed SWS_OP_SWIZZLE past
SWS_OP_DITHER even for very low bit depth output (e.g. rgb4), which led to
a big loss in accuracy due to loss of per-channel dither noise.

Improves loss of e.g. gray -> rgb444 from 0.00358659 to 0.00261414,
now beating legacy swscale in these cases as well.
2025-12-15 14:31:58 +00:00
Niklas Haas 7bce47cc63 swscale/ops_optimizer: only commute swizzle ops if coefficients are identical
Otherwise, this is invalid; as the result of applying the next operation
after channel duplication may not commute with the result of duplicating
the result of applying the next operation on only one channel.

In practice, this was using the last seen channel's coefficients.

Note that this did not actually affect anything in practice, because the only
relevant ops (MIN/MAX) were always generated with identical coefficients for
identical channel ranges.

However, it will matter moving forwards, as e.g. dither ops may not be
commuted freely if their matrix offsets differ per channel.
2025-12-15 14:31:58 +00:00
Niklas Haas 1cc4c2b236 swscale/ops_optimizer: rework ambiguous op_type_is_independent()
The current usage is ambiguous between "affects each component equally" and
"affects each component independently" - and arguably, the current behavior
was a bug (since SWS_OP_DITHER should not commute with a SWIZZLE, at least
from a bit-exactness PoV).

However, when trying to define cleaner replacements for these concepts, I
realized there are too many special cases; and given that we only have two
use sites, I decided to just split them directly into "commute" functions
for those particular usage cases.

As an added benefit, this moves the commutation logic out of the already-long
ff_sws_ops_list_optimize().
2025-12-15 14:31:58 +00:00
Niklas Haas 6184924892 swscale/format: don't add chroma noise when dithering grayscale content
On the surface, this trades a tiny bit of PSNR for not introducing chroma
noise into grayscale images. However, the main reason for this change is
actually motivated by a desire to avoid regressing the status quo of
duplicating swizzles being able to be commuted past dither ops.
2025-12-15 14:31:58 +00:00
Niklas Haas d5174f9e5b swscale/format: add source format info to ff_sws_encode_colors()
Specifically, I need access to this for generating a better dither matrix.
2025-12-15 14:31:58 +00:00
Niklas Haas 3f7e3cedb5 swscale/x86/ops_float: store and load per row dither offset directly
Instead of computing y + N with a hard-coded index offset, calculate the
relative offset as a 16-bit integer in C and add that to the pointer directly.
Since we no longer mask the resulting combined address, this may result in
overread, but that's fine since we over-provisioned the array in the previous
commit.
2025-12-15 14:31:58 +00:00
Niklas Haas 0744260ff0 swscale/x86/ops: over-allocate dither matrix
I want to change the way offsets are calculated inside the dither asm;
and the cleanest way to solve that problem is to just over-allocate the
entire dither matrix based on the maximum offset range we expected.
2025-12-15 14:31:58 +00:00
Niklas Haas b1c96b99fa swscale/x86/ops_float: remove special case for 2x2 matrix
This is an exceptionally unlikely (in fact, currently impossible) case to
actually hit, and not worth micro-optimizing for. More specifically, having
this special case prevents me from easily adding per-row offsets.
2025-12-15 14:31:58 +00:00
Niklas Haas d62102d679 swscale/ops_tmpl_float: actually skip allocation for !size_log2 case
This check was wrong; 1 << 0 = 1. The intent was to skip allocating a 1x1
matrix by assuming it is a constant 0.5. But as written, the check never
actually executed.

This did not affect the runtime performance, nor did it leak memory; but it
did mean we didn't hit the intended `assert`.
2025-12-15 14:31:58 +00:00
Niklas Haas 58f933798f swscale/ops_tmpl_float: respect specified dither matrix offsets
Since we only need 8 bytes to store the dither matrix pointer, we actually
still have 8 bytes left-over. That means we could either store the 8-bit
row offset directly, or alternatively compute a 16-bit pointer offsets.

I have chosen to do the former for the C backend, in the interest of
simplicity.

The one downside of this approach is that it would fail on hypothetical
128-bit platforms; although I seriously hope that this code does not live
long enough to see the need for 128-bit addressable memory.
2025-12-15 14:31:58 +00:00
Niklas Haas 960cf3015e swscale/ops: add explicit row offset to SwsDitherOp
To improve decorrelation between components, we offset the dither matrix
slightly for each component. This is currently done by adding a hard-coded
offset of {0, 3, 2, 5} to each of the four components, respectively.

However, this represents a serious challenge when re-ordering SwsDitherOp
past a swizzle, or when splitting an SwsOpList into multiple sub-operations
(e.g. for decoupling luma from subsampled chroma when they are independent).

To fix this on a fundamental level, we have to keep track of the offset per
channel as part of the SwsDitherOp metadata, and respect those values at
runtime.

This commit merely adds the metadata; the update to the underlying backends
will come in a follow-up commit. The FATE change is merely due to the
added offsets in the op list print-out.
2025-12-15 14:31:58 +00:00
averne b9078c0939 vulkan/prores: copy constant tables to shared memory
The shader needs ~3 loads per DCT coeff.
This data was not observed to get efficiently stored
in the upper cached levels, loading it explicitely in
shared memory fixes that.

Also reduce code size by moving the bitstream
initialization outside of the switch/case.
2025-12-15 12:29:00 +00:00
averne 00914cc3ef vulkan/prores: increase bitstream caching
Now caches 64B of data when the reader hits the refill codepath
2025-12-15 12:29:00 +00:00
averne a2475d16ed lavc/vulkan/common: allow configurable bitstream caching in shared memory 2025-12-15 12:29:00 +00:00
Niklas Haas 4ac3b3a6da avfilter/vf_libplacebo: rotate all input frames, not just reference
In commit 6e0034ab7e, the image crop adjustment
was moved after the fitting logic. However, this moved the adjustment inside the
`if (src == ref)` branch, thus missing applying the same un-rotation to input
frames that are *not* the reference frame.

Fix this by pulling the logic back out of the branch again. While we could just
move it after the fitting logic, I think it's more clear to the intent of the
code to just preserve the (rotated) crop rect as a separate variable
`crop_orig`.

Fixes: 6e0034ab7e
2025-12-15 11:29:58 +01:00
James Almer 3332b2db84 doc: add entries for SVT-JPEG-XS
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:47:08 -03:00
James Almer 35e68c6492 avcodec/libsvtjpegxsdec: only return AVERROR codes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:04 -03:00
James Almer 4269d69df1 avcodec/libsvtjpegxsdec: use AVCodecContext.lowres instead of a private option
It was evidently an oversight.

Found-by: Andreas Rheinhardt.
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:04 -03:00
James Almer 330984579b avcodec/libsvtjpegxsdec: move some stack structs to the private decoder context
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:04 -03:00
James Almer 2903a3c1ec avcodec/libsvtjpegxsdec: reindent after the previous changes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:04 -03:00
James Almer 4e9f5e2f3d avcodec/libsvtjpegxsdec: support parameter changes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:03 -03:00
James Almer 7bd793c647 avcodec/libsvtjpegxsdec: remove chunk decoding code
That's the job of the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:22:03 -03:00
James Almer 695b717944 avcodec/libsvtjpegxsdec: Replace divisions by shifts
Based on a patch by Andreas Rheinhardt

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 18:21:58 -03:00
James Almer c639ea5eeb avcodec/libsvtjpegxsenc: set bitrate to a sane default if unset
Better than failing with an impossibly low bitrate.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-14 17:34:57 -03:00
Andreas Rheinhardt 6f9849cbe5 avcodec/libsvtjpegxsenc: Replace divisions by shifts
Also simplify setting alloc_size.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:06:03 +01:00
Andreas Rheinhardt 7efd09813f avcodec/libsvtjpegxsenc: Don't copy unnecessarily
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:06:00 +01:00
Andreas Rheinhardt af70b24692 avcodec/libsvtjpegxs{dec,enc}: Don't call av_cpu_count() multiple times
(Like the old code, the new code limits the number of threads to 64,
even when the user explicitly set a higher thread count. I don't know
whether it is intentional to apply this limit even when the user
explicitly supplied the number of threads.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:05:57 +01:00
Andreas Rheinhardt 47179c3452 avcodec/libsvtjpegxsenc: Remove dead code
The pixel format has already been checked generically.
This also fixes the bug that the earlier code ignored
the return value of set_pix_fmt().

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:05:54 +01:00
Andreas Rheinhardt 9ed64db6a5 avcodec/libsvtjpegxs{dec,enc}: Don't get log level multiple times
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 21:05:33 +01:00
Ruikai Peng 16f89d342e avformat/mpegts: bounds-check JPEG-XS header_size before padding
Regression since: 536475ea05.

The JPEG-XS PES path trusted header_size from the payload and advanced
pkt->data/pkt->size without validation, so the trailing memset could
write out of bounds when header_size > pkt->size. Reject such packets,
marking them corrupt and returning an error to avoid the OOB write.

Repro (ASan):
ASAN_OPTIONS=halt_on_error=1:detect_leaks=0   ./ffmpeg -v debug -nostdin -i poc-jpegxs.ts -copy_unknown -map 0   -c copy -f null /dev/null

Crash in new_pes_packet memset on crafted TS with stream_id 0xbd,
stream_type 0x32, header_size 0xFFFFFF00, payload starting with jxes.

Found-by: Pwno
2025-12-14 17:42:59 +00:00
Marton Balint 131a33c808 avformat/xmv: do not set audio pts values
The format does not contain audio timestamps and the calculated audio pts
values were only correct for compressed audio. It is better to remove PTS
calculation entirely and let the generic code handle it.

Fixes ticket #8595.
Fixes #20983.

Fate test changes are because of the different audio time base which is now
always 1/sample_rate.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-14 17:08:37 +00:00
Andreas Rheinhardt b802eeabff avformat/Makefile: Add jpegxs->img2dec.o dependency
Forgotten in 3b1214a897.

Reported-by: Jamaika1 <lukaszcz18@wp.pl>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 14:27:46 +01:00
Andreas Rheinhardt 4715b9bac2 tests/checkasm/llviddspenc: Rename to llvidencdsp
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:48 +01:00
Andreas Rheinhardt f96829b5bf avcodec/x86/lossless_videoencdsp_init: Remove pointless av_unused
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:46 +01:00
Andreas Rheinhardt abe6ba17fa avcodec/x86/lossless_videoencdsp: Port sub_median_pred to NASM
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:43 +01:00
Andreas Rheinhardt 9ba33cc198 avcodec/x86/lossless_videoencdsp_init: Avoid special-casing first pixel
Old benchmarks:
sub_median_pred_c:                                     404.1 ( 1.00x)
sub_median_pred_sse2:                                   20.5 (19.67x)

New benchmarks:
sub_median_pred_c:                                     408.5 ( 1.00x)
sub_median_pred_sse2:                                   19.2 (21.27x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:40 +01:00
Andreas Rheinhardt 3a3e7080f1 avcodec/x86/lossless_videoencdsp_init: Port sub_median_pred to SSE2
Old benchmarks:
sub_median_pred_c:                                     405.7 ( 1.00x)
sub_median_pred_mmxext:                                 35.1 (11.57x)

New benchmarks:
sub_median_pred_c:                                     404.1 ( 1.00x)
sub_median_pred_sse2:                                   20.5 (19.67x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:35 +01:00
Andreas Rheinhardt 56b8769a1c tests/checkasm/llviddspenc: Add test for sub_median_pred
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:32 +01:00
Andreas Rheinhardt 3144652588 avcodec/x86/lossless_videoencdsp_init: Don't read too often
sub_median_pred_mmxext() calculates a predictor from the left, top
and topleft pixel values. The topleft values need to be initialized
differently for the first loop initialization than for the others
in order to avoid reading ptr[-1]. So it has been initialized before
the loop and then read again at the end of the loop, so that the last
value read was never used. Yet this can lead to reads beyond the end
of the buffer, e.g. with
ffmpeg -cpuflags mmx+mmxext -f lavfi -i "color=size=64x4,format=yuv420p" \
-vf vflip -c:v ffvhuff -pred median -frames 1 -f null -

Fix this by not reading the value at the end of the loop.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:29 +01:00
Andreas Rheinhardt 2b9aea7756 avcodec/x86/lossless_videoencdsp_init: Don't read from before the buffer
sub_median_pred_mmxext() calculates a predictor from the left, top
and topleft pixel values. The left value is simply read via
ptr[-1], although this is not guaranteed to be inside the buffer
in case of negative strides. This happens e.g. with

ffmpeg -i fate-suite/mpeg2/dvd_single_frame.vob -vf vflip \
       -c:v magicyuv -pred median -f null -

Fix this by reading the first value like the topleft value.
Also change the documentation of sub_median_pred to reflect this
change (and the one from 791b5954bc).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:16:25 +01:00
Andreas Rheinhardt f8a06da4ec fate/vcodec: Test median prediction in ffvhuff,huffyuv
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-14 10:13:29 +01:00
Rémi Denis-Courmont 71db4f3cc1 lavc/llvidencdsp: R-V V sub_median_pred
SpacemiT X60:
sub_median_pred_c:                                  297862.8 ( 1.00x)
sub_median_pred_rvb_b:                              101992.2 ( 2.92x)
sub_median_pred_rvv_i32:                              4820.0 (61.80x)
2025-12-14 10:33:40 +02:00
Rémi Denis-Courmont 87190fff6e lavc/llvidencdsp: R-V B sub_median_pred
SiFive U74:
sub_median_pred_c:                                  238947.3 ( 1.00x)
sub_median_pred_rvb_b:                              106686.9 ( 2.24x)

SpacemiT X60:
sub_median_pred_c:                                  297862.8 ( 1.00x)
sub_median_pred_rvb_b:                              101992.2 ( 2.92x)
2025-12-14 10:33:40 +02:00
Gyan Doshi 48d63b47bf doc/filters: list side data types
Doc readers may not have access to, or be able to read source code.
2025-12-14 12:41:00 +05:30
Gyan Doshi b89f1581b0 lavfi/sidedata: fix typo
S12M_TIMECOD --> S12M_TIMECODE

Old version is marked deprecated.
Should be removed at lavfi bump to 12.
2025-12-14 12:41:00 +05:30
James Almer b8ee68cffe doc/APIchanges: add an entry for JPEG-XS codec id
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 19:04:46 -03:00
jess 536475ea05 avformat/mpegts: add support for JPEG-XS streams
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 19:03:43 -03:00
James Almer 3b1214a897 avformat: add a raw JPEG-XS muxer and demuxer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 19:03:36 -03:00
Tomasz Szumski 08db850159 avcodec: add JPEG-XS decoder and encoder using libsvtjpegxs
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 19:00:35 -03:00
James Almer 52c097065c avcodec: add a JPEG-XS parser
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 18:45:17 -03:00
Tomasz Szumski 4243e6c870 avcodec/codec_id: add JPEG-XS
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 18:45:17 -03:00
James Almer 5fac8addc5 avutil/log: use atomics to load and store logging level, flags and callback pointer
Based on code setting cpu flags in libavutil/cpu.c

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-13 21:33:11 +00:00
Lynne 9e8e34d475 vulkan_ffv1: remove unused RCT shader files
The 2 files were made redundant when the RCT was merged into encode/decode.
2025-12-13 22:12:26 +01:00
Lynne 5bb9cd23b7 vulkan_dpx: fix GRAY16BE and big-endian marked 8-bit samples 2025-12-13 21:35:56 +01:00
Lynne c3291993eb vulkan_ffv1: use proper rounded divisions for plane width and height
Fixes #20314
2025-12-13 19:12:24 +01:00
Lynne 91deb96d3c vulkan_decode: don't set unnecessary function pointers for FFHWAccel
Invalidate is not used for SDR decoders, since they don't use session
parameters.
2025-12-13 19:12:24 +01:00
Lynne 72e83b42d1 vulkan_decode: clean up decoder initialization
Now that we don't reset on every seek, we can simplify it.
2025-12-13 19:12:24 +01:00
Lynne 018ba6b612 vulkan_decode: do not reset the decoder when flushing
The issue is that .flush gets called asynchronously, and modifies the
video session state while its being used for decoding. This did not
result in issues since all known vendors do not keep important state
there, but its not compliant with the specs.

Its not necessary to flush the decoder at all when seeking,
so simply don't.

Fixes #20487
2025-12-13 19:12:20 +01:00
Zhao Zhili 1e2d86201f Revert "avutil/tx_template: extend to 2M"
This reverts commit 8f48a62, 9af8782, and bd3e71b.

Commit 8f48a62 extends tx to 2M, resulting in the tx_float bss
section reaching a size of 4M.

This isn't a issue on devices with normal memory sizes and OS
supporting virtual memory. But it's a real issue for embedded devices
with realtime OS, which may not support virtual memory, e.g., Nuttx.
This 4M of bss section map to physical memory directly, which is a
scarce resource on embedded devices.
2025-12-13 15:14:38 +00:00
Andreas Rheinhardt 3da2a21710 avcodec/hq_hqadata: Avoid relocations for HQProfiles
Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-13 05:57:47 +01:00
Andreas Rheinhardt 2718874724 avcodec/hq_hqadata: Remove padding from tables
Each table needs only tab_w*tab_h*2 entries.

Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-13 05:55:44 +01:00
Andreas Rheinhardt 0cf187471f avcodec/hq_hqa: Don't rederive value
perm gets incremented in the loop in such a manner that
it already has the value it is set to here except for
the first loop iteration.

Reviewed-by: Marton Balint <cus@passwd.hu>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-13 05:55:20 +01:00
Jack Lau ec0173ab59 avformat/amr: add P bits check to avoid mis-detects
Fix #21056

Refer to RFC 3267 Section 4.4.2:

A ToC entry takes the following format in octet-aligned mode:

 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+
|F|  FT   |Q|P|P|
+-+-+-+-+-+-+-+-+

P bits: padding bits, MUST be set to zero.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-12 20:17:00 +00:00
Ruikai Peng c48b8ebbbb avcodec/vulkan: fix DPX unpack offset
The DPX Vulkan unpack shader computes a word offset as

    uint off = (line_off + pix_off >> 5);

Due to GLSL operator precedence this is evaluated as
line_off + (pix_off >> 5) rather than (line_off + pix_off) >> 5.
Since line_off is in bits while off is a 32-bit word index,
scanlines beyond y=0 use an inflated offset and the shader reads
past the end of the DPX slice buffer.

Parenthesize the expression so that the sum is shifted as intended:

    uint off = (line_off + pix_off) >> 5;

This corrects the unpacked data and removes the CRC mismatch
observed between the software and Vulkan DPX decoders for
mispacked 12-bit DPX samples. The GPU OOB read itself is only
observable indirectly via this corruption since it occurs inside
the shader.

Repro on x86_64 with Vulkan/llvmpipe (531ce713a0):

    ./configure --cc=clang --disable-optimizations --disable-stripping \
        --enable-debug=3 --disable-doc --disable-ffplay \
        --enable-vulkan --enable-libshaderc \
        --enable-hwaccel=dpx_vulkan \
        --extra-cflags='-fsanitize=address -fno-omit-frame-pointer' \
        --extra-ldflags='-fsanitize=address' && make

    VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json

PoC: packed 12-bit DPX with the packing flag cleared so the unpack
shader runs (4x64 gbrp12le), e.g. poc12_packed0.dpx.

Software decode:

    ./ffmpeg -v error -i poc12_packed0.dpx -f framecrc -
    -> 0, ..., 1536, 0x26cf81c2

Vulkan hwaccel decode:

    VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json \
    ./ffmpeg -v error -init_hw_device vulkan \
        -hwaccel vulkan -hwaccel_output_format vulkan \
        -i poc12_packed0.dpx \
        -vf hwdownload,format=gbrp12le -f framecrc -
    -> 0, ..., 1536, 0x71e10a51

The only difference between the two runs is the Vulkan unpack
shader, and the stable CRC mismatch indicates that it is reading
past the intended DPX slice region.

Regression since: 531ce713a0
Found-by: Pwno
2025-12-12 20:13:16 +00:00
Ruikai Peng cc43670268 avfilter/x86/vf_noise: Use unaligned access
Regression since: 3ba570de8b (port from MMX to SSE2).

The SSE2 inline asm in libavfilter/x86/vf_noise.c (line_noise_sse2 and
line_noise_avg_sse2) uses aligned loads/stores (movdqa, movntdq) but never
checks pointer alignment. When the filter reuses an input frame (common
path when av_frame_is_writable() is true), it may receive misaligned data
from upstream filters that adjust frame->data[i] in place, notably vf_crop:

- vf_crop adjusts plane pointers by arbitrary byte offsets
(frame->data[plane] += ...), so an x offset of 1 on 8-bit formats produces
a 1‑byte misalignment.
- The noise filter then calls the SSE2 path directly on those pointers
without realigning or falling back.

Repro on x86_64/SSE2 (current HEAD at that commit):

./ffmpeg -v error -f lavfi -i testsrc=s=320x240:rate=1 \
-vf "format=yuv420p,crop=w=319:x=1:h=240:exact=1,noise=alls=50" \
-frames:v 1 -f null -

This crashes with SIGSEGV at the aligned load in line_noise_sse2 (movdqa
(%r9,%rax),%xmm0; effective address misaligned by 1 byte).

Impact: denial of service via crafted filtergraphs (e.g., crop + noise).
Applies to planar 8-bit formats where upstream filters can shift data
pointers without reallocating.

Found-by: Pwno OSS Team
2025-12-12 19:25:21 +00:00
James Almer 9c14527f1a avcodec/vvc/refs: export in-band LCEVC side data in frames
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-12 15:21:49 -03:00
James Almer 94c491287c avcodec/vvc/sei: parse Registered and Unregistered SEI messages
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-12 15:21:48 -03:00
James Almer 6dad70507f avcodec/cbs_sei: store a pointer to the start of Registered and Unregistered SEI messages
Required for the following commit, where a parsing function expects the buffer
to include the country code bytes.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-12 15:21:48 -03:00
James Almer b6655e9594 avcodec/dpx: make the lack of break in a switch case explicit
Should fix CID 1676036

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-12 18:18:46 +00:00
Martin Storsjö 86f1ee1842 ffprobe: Include the RFC 4281 "mime codec string" in show_stream output 2025-12-12 18:40:01 +02:00
Martin Storsjö c9b5e145b7 avformat: Add av_mime_codec_str public API
Add a public API for producing RFC 4281/6381 codecs trings for
MIME types.

This can be required for providing alternative video files to
a web browser, letting the browser pick the best file it supports.
Such strings also allow querying a browser whether it supports
a certain codec combination.

Finally, if implementing a DASH/HLS segmenter outside of libavformat,
one also has to generate such strings.

Generating such strings for H264/AAC is very simple, but for
more modern codecs, it can require a lot of nontrivial codec
specific parsing of extradata.

As libavformat already implements this, expose it for users as well.

The old, internal function ff_make_codec_str is kept and used by
the HLS and DASH muxers; the old function takes a logging context
which can be used for logging auxillary info about how the string
generation worked out.
2025-12-12 18:40:00 +02:00
Martin Storsjö 360fda56cd avformat: Skip logging in ff_make_codec_str if logctx == NULL
This is in preparation for reusing the same codepaths for a public
API, where we don't want it to print various diagnostic logging.
2025-12-12 18:39:34 +02:00
Cameron Gutman 0637a28dc0 lavc/vulkan_video: fix leak on CreateVideoSessionKHR failure
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-12 12:43:00 +00:00
Cameron Gutman 4e4677bf58 lavc/vulkan_video: fix double-free if ff_vk_decode_init() fails
ff_vk_video_common_init() calls ff_vk_video_common_uninit() on failure
which leaves dangling object handles. Those get freed again when the
destructor of FFVulkanDecodeShared calls ff_vk_video_common_uninit()
again.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-12 12:43:00 +00:00
Andreas Rheinhardt a72e01b4ec avcodec/ppc/vc1dsp_altivec: Don't read too much data
vc1_inv_trans_8x4_altivec() is supposed to process a block
of 8x4 words, yet it read and processed eight lines. This led
to ASAN failures (see [1]) that this commit intends to fix.
It should also lead to performance improvements, but I don't have
real hardware to bench it.

[1]: https://fate.ffmpeg.org/report.cgi?time=20251207214004&slot=ppc64-linux-gcc-14.3-asan

Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-12 09:44:01 +01:00
Martin Storsjö 6258e61c4d configure: Fix detection of SME
Older versions of Clang (Xcode 14, llvm.org Clang 13 and 14)
do support and recognize SME, but when enabled through
".arch_extension sme" it fails to transitively enable support
for Streaming SVE; this was fixed in [1].

This issue results in those versions currently detecting support
for SME, but later failing to build cpu_sme.s with errors like
"error: instruction requires: sve or sme" or "error: instruction
requires: streaming-sve or sve", on the "cntb x0" instruction.

Extend the check for this instruction set extension, to test
with two instructions, both specifically a SME instruction
(smstart) and an instruction that is available in Streaming SVE
mode (cntb).

For the configure check, add an extra parameter to
check_archext_insn for an optional second instruction to check.

It would be tempting to just pass both instructions through
the same parameter, as "smstart; cntb x0". However, Darwin
targets use a different token (%%) for starting a new
instruction on the same line - those targets interpret ";"
as the start of a comment. Due to that, such a check would
entirely ignore the second instruction on Darwin targets.

To avoid dealing with the variability in passing multiple
instructions on one line, just pass the optional second
instruction on a separate line.

[1] https://github.com/llvm/llvm-project/commit/ff3f3a54e2d1b05c36943bf88ae0be7475d622ed
2025-12-12 08:15:12 +00:00
James Almer 04df80f973 avcodec/cavs_parser: check return value of init_get_bits8
Fixes Coverity issue CID 1676035

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-11 20:01:01 -03:00
Jan Ekström e54bd7065d fate/ffmpeg: remove comparison against ref from fix_sub_duration_heartbeat
After the full ffmpeg CLI multithreading changes went in, this
test started depending on how far the input side read and decoded
the input compared to how quickly the output encoded things, causing
spurious failures on the CI.

To my knowledge all of the failures have so far been valid correct
results, but unfortunately FATE's built in checks mostly consist of
whether there is a difference against an exact result.

This way we still get the CI and valgrind running of the code,
but stop its comparison. Reference file is left around so that
the previous reference is still available.
2025-12-11 22:48:26 +02:00
Ruikai Peng bb424927db avformat/sierravmd: fix header read error check
The header read check stored the comparison result into ret, so read
failures became ret=1 and were treated as success, leaving the VMD header
uninitialized and letting parsing continue with bogus state.

Regression since: ee623a43e3.
Found-by: Pwno
2025-12-11 16:26:17 +00:00
Rémi Denis-Courmont a4cb6c724b lavc/llvidencdsp: R-V V sub_left_predict
SpacemiT X60:
sub_left_predict_c:                                  51836.0 ( 1.00x)
sub_left_predict_rvv_i32:                             5843.1 ( 8.87x)
2025-12-11 17:24:38 +02:00
Leo Izen 37858dc6bd avcodec/libjxlenc: add EXIF box to output
We already parse the EXIF side data to extract the orientation, so we
should add it to the output file as an EXIF box.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-11 05:38:36 -05:00
Leo Izen e349118b4c avcodec/libjxlenc: avoid calling functions inside if statements
It leads to messier, less readable code, and can also lead to bugs.
I prefer this code style.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-11 05:38:35 -05:00
Leo Izen 6ec4b3a9cb avcodec/libjxlenc: give display matrix sidedata priority
Before this commit, we ignore the display matrix side data if any EXIF
side data is present, even if that side data contains no orientation
tag. This allows us to calculate the orientation from the display
matrix sidedata first, if present. Ideally the decoder will have
removed the orientation tag upon decoding and attached the data as
display matrix side data instead, so this makes our orientation code
respect this behavior.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-12-11 05:38:33 -05:00
James Almer 4f947880bd tests/fate/filter-video: add missing lavfi_indev dependency to fate-filter-feedback-hflip
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-10 22:07:05 -03:00
James Almer 44862a9d68 avutil/aarch64/cpu: fix check for SME on Linux
SME is a AT_HWCAP2 entry, not AT_HWCAP.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-10 21:51:11 -03:00
Kacper Michajłow f8929c4510 configure: make --disable-optimizations work on MSVC/ICC
_cflags_noopt was previously set to optimize for size as a workaround
for issues in MSVC builds without any optimizations. Specifically the
lack of DCE and constant merging. This is no longer needed, as those
issues have been fixed in our codebase.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-10 23:19:54 +00:00
Hyunjun Ko 6726359326 vulkan_vp9: fix subsampling source and show_frame flag 2025-12-10 18:41:20 +00:00
Georgii Zagoruiko cdb14bc74d configure: add detection of assembler support for SME
All changes are made during development/testing of SVE/SME for ffmpeg (vvc). Tested on Apple M4
2025-12-09 21:38:38 +00:00
Georgii Zagoruiko 2251ede69e Makefile: add missing variables in Makefile 2025-12-09 21:38:38 +00:00
Niklas Haas 440d58f5b1 avfilter/avfiltergraph: add missing newlines to format printing 2025-12-09 21:31:58 +00:00
Niklas Haas 978a0821ee avfilter/avfiltergraph: always retry format negotiation after auto-filters
There is an edge case not covered by the current logic: If there is only
a single auto-filter inserted, but the auto-inserted filter is incompatible
with a *different* format attribute (after settling the previous formats),
we may need a second auto-filter (e.g. `scale`) to settle the newly introduced
incompatibility.

A regression test demonstrating the issue is added.
2025-12-09 21:31:58 +00:00
James Almer 16050a1cef avformat/iamf_writer: ensure expanded_loudspeaker_layout is only written when using a single scalable layout layer
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-09 17:54:11 -03:00
James Almer 5cdc1cad77 avformat/iamf_parse: add a few extra sanity checks
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-09 17:54:11 -03:00
James Almer 2d5abf27e5 avformat/iamf_parse: fix parsing of Scalable layouts with Mono and Stereo layers
An ASAN heap-buffer-overflow in scalable_channel_layout_config was caused by an
unchecked assumption that the channel layout of a scalable audio layer is a
superset of the previous layer's channel layout.

scalable_channel_layout_config constructs a channel layout map by copying
channels from the previous layer and adding new ones. The memory allocation is
based on the target loudspeaker_layout. However, if the target layout doesn't
encompass all previous channels (e.g., Mono to Stereo), copying previous
channels followed by adding current ones could exceed the allocated size,
causing a heap buffer overflow.

This commit adds an exception for the know case of Mono -> Stereo, and a check
to ensure the previous layer's channel layout is a subset of the current
layer's layout by comparing their masks. If the condition isn't met,
an error is returned.

Fixes: https://issues.oss-fuzz.com/issues/464965414

Co-authored-by: Oliver Chang <ochang@google.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-09 17:54:11 -03:00
Cameron Gutman 8eae9d3310 fftools/ffplay_renderer: use new Vulkan extension API
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-09 19:13:50 +00:00
Cameron Gutman 95c81cc1f9 hwcontext_vulkan: add APIs to get optional extensions
These provide a way for apps that initialize Vulkan themselves to know
which extensions we may be able to use without having to hardcode it.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-09 19:13:50 +00:00
Niklas Haas 7b773aba82 swscale/format: merge fmt_* helpers into a single fmt_analyze()
Handles the split between "regular" and "irregular" pixel formats in a single
place, and opens up the door for more complicated formats.
2025-12-09 09:47:48 +00:00
Niklas Haas a8dc3a543c swscale/format: consolidate format information into a single struct
I use a switch/case instead of an array because this is only needed for
irregular formats, which are very sparse.
2025-12-09 09:47:48 +00:00
Niklas Haas 3160ace20a swscale/format: derive fmt_read_write() for regular formats 2025-12-09 09:47:48 +00:00
Niklas Haas 004127f00b swscale/format: explicitly test for unsupported subsampled formats
This includes semiplanar formats. Note that the first check typically
subsumes the second check, but I decided to keep both for clarity.
2025-12-09 09:47:48 +00:00
Niklas Haas 748855b227 swscale/format: derive fmt_shift() from AVPixFmtDescriptor
XV36 is the odd one out, being a byte-shifted packed format whose components
don't actually cross any byte boundaries.
2025-12-09 09:47:48 +00:00
Niklas Haas 2feb848252 swscale/format: derive fmt_swizzle() from AVPixFmtDescriptor when possible
Unfortunately, this is exceptionally difficult to handle in the general case,
when packed/bitstream formats come into play - the actual interpretation of
the offset, shift etc. are so difficult to deal with in a general case that
I think it's simpler to continue falling back to a static table of variants
for these exceptions. They are fortunately small in number.
2025-12-09 09:47:48 +00:00
Niklas Haas 83d572e6f6 swscale/format: check SwsPixelType in fmt_read_write()
This is the only function that actually has the ability to return an
error, so just move the pixel type assignment here and add a check to
ensure a valid pixel type is found.
2025-12-09 09:47:48 +00:00
Niklas Haas ef2ce57c31 swscale/format: exclude U32 from sws_pixel_type()
This function is supposed to give us representable pixel types; but U32 is not
representable (due only to the AVRational range limit).
2025-12-09 09:47:48 +00:00
Gyan Doshi 9507695d06 doc/htmlxref.cnf: add drawvg-reference
Fixes #21125
2025-12-09 10:22:36 +05:30
Andreas Rheinhardt 4baa5e638b tests/checkasm/checkasm: Don't test 3dnow
The last 3dnow functions have been removed in commit
5ef613bcb0, so don't test
it in checkasm.

(This will affect only one test, namely scalarproduct_and_madd_int16
from lossless_audiodsp: It does not use an SSSE3 function when
the 3dnow flag is set. So for old AMDs (which advertise support for
3dnow), said SSSE3 function is never tested. Now it will.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-09 03:03:07 +00:00
Andreas Rheinhardt fb20009f47 tests/ref/fate/source: Fix fate-source after last commit
Broken in ac9552bebf.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 23:33:47 +00:00
Cameron Gutman 45bf925d54 fftools/ffplay_renderer: use new Vulkan extension API
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-08 23:22:31 +00:00
Cameron Gutman 212eb8413a hwcontext_vulkan: add APIs to get optional extensions
These provide a way for apps that initialize Vulkan themselves to know
which extensions we may be able to use without having to hardcode it.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-08 23:22:31 +00:00
James Almer ac9552bebf avformat/cbs: add missing license headers
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-08 20:07:45 -03:00
Kacper Michajłow 04a46a2ae4 avcodec/d3d12va_encode_av1: don't ignore return value
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow f4fc14fb38 avcodec/d3d12va_encode_av1: fix size_t format specifier 2025-12-08 21:31:13 +00:00
Kacper Michajłow 5b2bd6f88d avcodec/d3d12va_encode_av1: remove unused variables
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 6083c9bb8c avutil/hwcontext_vaapi: mark try_all with av_unused to suppres warning
Fixes: warning: variable 'try_all' set but not used [-Wunused-but-set-variable]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 018041f150 swresample/soxr_resample: pass initialized data to soxr_process() in flush()
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 1f7182a991 avcodec/libx265: add explicit enum cast to suppress compiler warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow eaa2b3d4be avcodec/libsvtav1: add explicit enum cast to suppress compiler warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 490af2d4cf avcodec/libaomdec: add explicit enum cast to suppress compiler warnings
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow cca872b6fd avfilter/vf_libopencv: make sure there is space for null-terminator in shape_str
Fixes: warning: 'sscanf' may overflow; destination buffer in argument 7 has size 32, but the corresponding specifier may require size 33 [-Wfortify-source]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Kacper Michajłow 1fa5e001bc avfilter/vf_neighbor_opencl: add error condition when filter name doesn't match
This cannot really happen, but to suppress compiler warnings, we can
just return AVERROR_BUG here.

Fixes: warning: variable 'kernel_name' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 21:31:13 +00:00
Martin Storsjö 69b4474367 swscale/tests: Fix fate-sws-ops-list on Windows
Set stdout to binary mode, to avoid platform specific differences
in the output that is hashed.
2025-12-08 23:02:30 +02:00
Niklas Haas c94e8afe5d swscale/ops: clarify SwsOpList.src/dst semantics
Turns out these are not, in fact, purely informative - but the optimizer
can take them into account. This should be documented properly.

I tried to think of a way to avoid needing this in the optimizer, but any
way I could think of would require shoving this to SwsReadWriteOp, which I
am particularly unwilling to do.
2025-12-08 20:09:37 +00:00
Niklas Haas f39fe6380c swscale/ops_optimizer: set correct value range for subpixel reads
e.g. rgb4 only reads values up to 15, not 255.

Setting this correctly eliminates a number of redundant clamps in cases
like e.g. rgb4 -> monow.
2025-12-08 20:09:37 +00:00
Andreas Rheinhardt dc843cdd9a avcodec/x86/vp9mc: Reindent after the previous commit
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:35:07 +01:00
Andreas Rheinhardt 65e71b0837 avcodec/x86/vp9mc: Deduplicate coefficient tables
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:35:01 +01:00
Andreas Rheinhardt 38e2174ce4 avcodec/x86/vp9mc: Avoid MMX regs in width 4 hor 8tap funcs
Using wider registers (and pshufb) allows to halve the number of
pmaddubsw used. It is also ABI compliant (no more missing emms).

Old benchmarks:
vp9_avg_8tap_smooth_4h_8bpp_c:                          97.6 ( 1.00x)
vp9_avg_8tap_smooth_4h_8bpp_ssse3:                      15.0 ( 6.52x)
vp9_avg_8tap_smooth_4hv_8bpp_c:                        342.9 ( 1.00x)
vp9_avg_8tap_smooth_4hv_8bpp_ssse3:                     54.0 ( 6.35x)
vp9_put_8tap_smooth_4h_8bpp_c:                          94.9 ( 1.00x)
vp9_put_8tap_smooth_4h_8bpp_ssse3:                      14.2 ( 6.67x)
vp9_put_8tap_smooth_4hv_8bpp_c:                        325.9 ( 1.00x)
vp9_put_8tap_smooth_4hv_8bpp_ssse3:                     52.5 ( 6.20x)

New benchmarks:
vp9_avg_8tap_smooth_4h_8bpp_c:                          97.6 ( 1.00x)
vp9_avg_8tap_smooth_4h_8bpp_ssse3:                      10.8 ( 9.08x)
vp9_avg_8tap_smooth_4hv_8bpp_c:                        342.4 ( 1.00x)
vp9_avg_8tap_smooth_4hv_8bpp_ssse3:                     38.8 ( 8.82x)
vp9_put_8tap_smooth_4h_8bpp_c:                          94.7 ( 1.00x)
vp9_put_8tap_smooth_4h_8bpp_ssse3:                       9.7 ( 9.75x)
vp9_put_8tap_smooth_4hv_8bpp_c:                        321.7 ( 1.00x)
vp9_put_8tap_smooth_4hv_8bpp_ssse3:                     37.0 ( 8.69x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:34:35 +01:00
Andreas Rheinhardt dd5dc254ff avcodec/x86/vp9mc: Avoid reloads, MMX regs in width 4 vert 8tap func
Four rows of four bytes fit into one xmm register; therefore
one can arrange the rows as follows (A,B,C: first, second, third etc.
row)

xmm0: ABABABAB BCBCBCBC
xmm1: CDCDCDCD DEDEDEDE
xmm2: EFEFEFEF FGFGFGFG
xmm3: GHGHGHGH HIHIHIHI

and use four pmaddubsw to calculate two rows in parallel. The history
fits into four registers, making this possible even on 32bit systems.

Old benchmarks (Unix 64):
vp9_avg_8tap_smooth_4v_8bpp_c:                         105.5 ( 1.00x)
vp9_avg_8tap_smooth_4v_8bpp_ssse3:                      16.4 ( 6.44x)
vp9_put_8tap_smooth_4v_8bpp_c:                          99.3 ( 1.00x)
vp9_put_8tap_smooth_4v_8bpp_ssse3:                      15.4 ( 6.44x)

New benchmarks (Unix 64):
vp9_avg_8tap_smooth_4v_8bpp_c:                         105.0 ( 1.00x)
vp9_avg_8tap_smooth_4v_8bpp_ssse3:                      11.8 ( 8.90x)
vp9_put_8tap_smooth_4v_8bpp_c:                          99.7 ( 1.00x)
vp9_put_8tap_smooth_4v_8bpp_ssse3:                      10.7 ( 9.30x)

Old benchmarks (x86-32):
vp9_avg_8tap_smooth_4v_8bpp_c:                         138.2 ( 1.00x)
vp9_avg_8tap_smooth_4v_8bpp_ssse3:                      28.0 ( 4.93x)
vp9_put_8tap_smooth_4v_8bpp_c:                         123.6 ( 1.00x)
vp9_put_8tap_smooth_4v_8bpp_ssse3:                      28.0 ( 4.41x)

New benchmarks (x86-32):
vp9_avg_8tap_smooth_4v_8bpp_c:                         139.0 ( 1.00x)
vp9_avg_8tap_smooth_4v_8bpp_ssse3:                      20.1 ( 6.92x)
vp9_put_8tap_smooth_4v_8bpp_c:                         124.5 ( 1.00x)
vp9_put_8tap_smooth_4v_8bpp_ssse3:                      19.9 ( 6.26x)

Loading the constants into registers did not turn out to be advantageous
here (not to mention Win64, where this would necessitate saving
and restoring ever more register); probably because there are only two
loop iterations.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:31:59 +01:00
Andreas Rheinhardt 7bc35b8426 tests/checkasm/vp9dsp: Allow to run only a subset of tests
Make it possible to run only a subset of the VP9 tests
in addition to all of them (via the vp9dsp test). This
reduces noise and speeds up testing.
FATE continues to use vp9dsp.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:27:56 +01:00
Andreas Rheinhardt 36204fbc3c avcodec/vp9itxfm{,_16bpp}: Remove MMXEXT functions overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMXEXT functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:27:51 +01:00
Andreas Rheinhardt ea37f49aed avcodec/vp9intrapred: Remove MMXEXT functions overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMXEXT functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:27:44 +01:00
Andreas Rheinhardt 6e418af810 avcodec/vp9mc: Remove MMXEXT functions overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMXEXT functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-08 19:27:05 +01:00
Kacper Michajłow a8df08f628 swscale/x86/yuv2yuvX: don't use deprecated hexadecimal prefix
Fixes: warning: $ prefix for hexadecimal is deprecated [-w+number-deprecated-hex]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 17:43:29 +00:00
Kacper Michajłow 5b5d51cbc1 avcodec/x86/h264_idct: fix version check for NASM 3 and newer
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-08 17:43:29 +00:00
Niklas Haas fddeb84fb2 tests/fate: add fate-sws-ops-list test
This one uses the test framework added in the previous commit to add a
light-weight regression test to ensure the generated SwsOpsList is identical.

Only compare the md5sum, to make the reference file significantly smaller
(down from ~10 MB).
2025-12-08 16:58:53 +00:00
Niklas Haas 016749f2e1 swscale/tests: add new test for generated operation lists
This is similar to swscale/tests/swscale.c, but significantly cheaper - it
merely prints the generated (optimized) operation list for every format
conversion.

Mostly useful for my own purposes as a regression test when making changes
to the ops optimizer. Note the distinction between this and tests/swscale.c,
the latter of which tests the result of *applying* an operation list for
equality.

There is an argument to be made that the two tests could be merged, but
I think the amount of overlap is small enough to not be worth the amount
of differences.
2025-12-08 16:58:53 +00:00
Niklas Haas d54090fe9f swscale/format: add assertion to prevent nan/inf matrix coeffs 2025-12-08 16:58:53 +00:00
Niklas Haas 868426814a swscale/format: handle YA format swizzles more robustly
This code was previously broken; since YAF32BE/LE were not included as
part of the format enumeration. However, since we *always* know the correct
swizzle for YA formats, we can just special-case this by the number of
components instead.
2025-12-08 16:58:53 +00:00
Timo Rothenpieler 338889c0d9 avfilter/vf_scale_d3d12: fix integer overflow in input framerate calculation
Also removes pointless intermediate variables that caused
the overflow and truncation to happen in the first place.

Fixes #YWH-PGM40646-1
2025-12-08 14:22:16 +01:00
Araz Iusubov c4d22f2d2c avfilter: D3D12 scale video filter support
This filter allows scaling of video frames using Direct3D 12 acceleration.

Example:
    ffmpeg -hwaccel d3d12va -hwaccel_output_format d3d12 \
           -i input.mp4 -vf scale_d3d12=1920:1280 \
           -c:v hevc_d3d12va -y output_1920x1280.mp4
2025-12-07 21:22:23 +00:00
Lynne 3ed8c1eb8a forgejo/labeler: automatically flag Vulkan-related commits #20118 2025-12-07 19:41:58 +00:00
Oliver Chang 9849a274df avcodec/dpx: Fix heap-buffer-overflow in 16-bit decoding
Fixes a heap-buffer-overflow in `libavcodec/dpx.c` triggered by a stale
`unpadded_10bit` flag in the `DPXDecContext`. This flag, set for 10-bit
unpadded frames, persisted across `decode_frame` calls. If a subsequent
frame was 16-bit, the stale flag caused incorrect buffer size
validation, allowing truncated buffers to pass checks designed for
smaller 10-bit packed data. This led to an out-of-bounds read in
`av_image_copy_plane` during 16-bit decoding.

The fix explicitly resets `dpx->unpadded_10bit = 0` at the start of
`decode_frame` to ensure correct validation for each frame.

Fixes: https://issues.oss-fuzz.com/issues/464471792
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Fixes: out of array read
Fixes: 464471792/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DPX_DEC_fuzzer-5275522210004992
2025-12-07 19:41:02 +00:00
Marton Balint 07e3d760bf fate/filter-audio: add amerge layout_mode test
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
Marton Balint 315446da2f avfilter/af_amerge: fix indentation
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
Marton Balint 3d667b147a avfilter/af_amerge: add layout_mode option to control output channel layout
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
Marton Balint 4e0a8b745a avfilter/af_amerge: rework routing calculation
No change in functionality.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
Marton Balint e8b10a9b09 avfilter/af_amerge: fix possible crash with custom layouts
The check if a native layout can be created from the sources was incomplete and
casued a crash with custom layouts if the layout contained a native channel
multiple times, as in this example command line:

ffmpeg -lavfi "sine[a0];sine,pan=FL+FL[a1];[a0][a1]amerge[aout]" -map "[aout]" -t 1 -f framecrc -

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-12-07 19:36:49 +00:00
caifan3 40d7f7774a avformat/unix: add pkt_size option
Add a "pkt_size" AVOption to the Unix domain socket protocol. This option
allows the user to specify the maximum packet size for packet-oriented
sockets (SOCK_DGRAM and SOCK_SEQPACKET).

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-12-07 19:36:03 +00:00
Rémi Denis-Courmont 10ea5f8b99 lavc/h264idct: R-V V 9-bit h264_luma_dc_dequant_idct
Note that, like the C reference, the same function can be used for
larger bit depths.
2025-12-07 20:27:35 +02:00
Rémi Denis-Courmont d69a36a8d1 lavc/h264idct: R-V V 8-bit h264_luma_dc_dequant_idct
This does not improve performance with current hardware due to the poor
performance of segmented accesses. Performance should be slightly better
with expensive or near-future hardware that I don't have, however it is
still limited by two other factors:
- There are only 4 elements.
- The final stores are necessarily indexed and hit multiple cache lines,
  thus as slow as scalar.
2025-12-07 20:27:35 +02:00
Rémi Denis-Courmont f222eb2b08 lavc/mpv_unquantize: R-V V H.263 DCT unquantize
SpacemiT X60:
dct_unquantize_h263_inter_c:                           417.8 ( 1.00x)
dct_unquantize_h263_inter_rvv_i32:                      66.0 ( 6.33x)
dct_unquantize_h263_intra_c:                           140.2 ( 1.00x)
dct_unquantize_h263_intra_rvv_i32:                      67.7 ( 2.07x)

Note that the C benchmarks are not stable, depending heavily on the
number of coefficients picked by the RNG. The R-V V benchmarks are
however very stable and generally better than C's.
2025-12-07 20:20:38 +02:00
averne c384b1e803 vulkan/prores: use vkCmdClearColorImage
The VK spec forbids using clear commands on YUV images,
so we need to allocate separate per-plane images.
This removes the need for a separate reset shader.
2025-12-07 18:17:36 +00:00
Marvin Scholz facc32b0d8 .forgejo/labeler: consistently quote strings 2025-12-07 16:24:10 +00:00
James Almer 00caeba050 avcodec: rename avcodec_receive_frame2 to avcodec_receive_frame_flags
It's a name that communicates its functionality in a better way.
Since the function was introduced very recently, we can safely rename it.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-07 12:47:46 -03:00
Michael Niedermayer 88f26718a0 avcodec/decode: Fix build due to ff_thread_receive_frame()
Regression since: 5e56937b74

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-12-07 11:58:01 +01:00
Kacper Michajłow 6a14a93af5 checkasm/sw_xyz2rgb: fix function type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-05 21:55:03 +00:00
Niklas Haas 929a2ced9b fftools/ffmpeg_dec: decode the first frame synchronously
In an ideal world, a filtergraph like `-i A -i B ... -filter_complex concat`
would only keep resources in memory related to the file currently being output
by the concat filter. So ideally, we'd open and fully decode A, then open and
fully decode B, and so on.

Practically, however, fftools wants to get one frame from each input file in
order to initialize the filter graph (buffersrc parameters). So what happens
currently is that fftools will request a single frame from each input A, B, etc
that is plugged into the filtergraph.

When using frame threading, the design of the decoder (ff_thread_receive_frame)
is that it will not output any frames until we have received enough packets to
saturate all threads. This, however, forces the decoder to buffer at least as
many frames for each input file as we have threads, before outputting anything.

By decoding the first frame synchronously, we avoid this issue and allow
configuring the filter graph more quickly and without wasting excess resources
on frames that will not (yet) be used.
2025-12-05 19:42:45 +01:00
Niklas Haas 5e56937b74 avcodec: allow bypassing frame threading with an optional flag
Normally, this function tries to make sure all threads are saturated with
work to do before returning any frames; and will continue requesting packets
until that is the case.

However, this significantly slows down initial decoding latency when only
requesting a single frame (to e.g. configure the filter graph), and also
wastes a lot of unnecessary memory in the event that the user does not intend
to decode more frames until later.

By introducing a new `flags` paramater and a new flag
`AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS` to go along with it, we can allow
users to temporarily bypass this logic.
2025-12-05 19:42:41 +01:00
Araz Iusubov 077864dfd6 avcodec/amf: fix hw_device_ctx handling 2025-12-05 15:53:19 +00:00
Zhao Zhili d3953237d1 avcodec/h264_slice: don't force ff_get_format unconditionally after flush
h->context_initialized is zero after flush, which triggers call to
ff_get_format unconditionally. ff_get_format can be heavy with
ff_hwaccel_uninit and hwaccel_init. For example, it takes 20 ms on
macOS with videotoolbox. ff_get_format should not be called if
nothing changed. ff_get_format is guarantee to be called at the
first time and when video information changed with
(must_reinit || needs_reinit).

Fix #20760.
2025-12-05 13:54:08 +00:00
Andreas Rheinhardt 1d47ae65bf avcodec/tableprint_vlc: Unbreak hardcoded tables
Forgotten in d8ffec5bf9.
Fixes issue #21102.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-05 11:31:23 +01:00
Arpad Panyik 1f30ff30fb swscale: Add AArch64 Neon path for xyz12Torgb48 LE
Add optimized Neon code path for the little endian case of the
xyz12Torgb48 function. The innermost loop processes the data in 4x2
pixel blocks using software gathers with the matrix multiplication
and clipping done by Neon.

Relative runtime of micro benchmarks after this patch on some
Cortex and Neoverse CPU cores:

 xyz12le_rgb48le    X1      X3      X4    X925      V2
 16x4_neon:       2.55x   4.34x   3.84x   3.31x   3.22x
 32x4_neon:       2.39x   3.63x   3.22x   3.35x   3.29x
 64x4_neon:       2.37x   3.31x   2.91x   3.33x   3.27x
 128x4_neon:      2.34x   3.28x   2.91x   3.35x   3.24x
 256x4_neon:      2.30x   3.17x   2.91x   3.32x   3.10x
 512x4_neon:      2.26x   3.10x   2.91x   3.30x   3.07x
 1024x4_neon:     2.26x   3.07x   2.96x   3.30x   3.05x
 1920x4_neon:     2.26x   3.06x   2.93x   3.28x   3.04x

 xyz12le_rgb48le   A76     A78    A715    A720    A725
 16x4_neon:       2.33x   2.28x   2.53x   3.33x   3.19x
 32x4_neon:       2.35x   2.18x   2.45x   3.23x   3.24x
 64x4_neon:       2.35x   2.16x   2.42x   3.15x   3.21x
 128x4_neon:      2.35x   2.13x   2.39x   3.00x   3.09x
 256x4_neon:      2.36x   2.12x   2.35x   2.85x   2.99x
 512x4_neon:      2.35x   2.14x   2.35x   2.78x   2.95x
 1024x4_neon:     2.31x   2.09x   2.33x   2.80x   2.91x
 1920x4_neon:     2.30x   2.07x   2.32x   2.81x   2.94x

 xyz12le_rgb48le   A55    A510    A520
 16x4_neon:       2.09x   1.92x   2.36x
 32x4_neon:       2.05x   1.89x   2.38x
 64x4_neon:       2.02x   1.77x   2.35x
 128x4_neon:      1.96x   1.74x   2.25x
 256x4_neon:      1.90x   1.72x   2.19x
 512x4_neon:      1.83x   1.75x   2.16x
 1024x4_neon:     1.83x   1.62x   2.15x
 1920x4_neon:     1.82x   1.60x   2.15x

Signed-off-by: Arpad Panyik <Arpad.Panyik@arm.com>
2025-12-05 10:28:18 +00:00
Arpad Panyik a13871ae19 checkasm: Add xyz12Torgb48le test
Add checkasm coverage for the XYZ12LE to RGB48LE path via the
ctx->xyz12Torgb48 hook. Integrate the test into the build and runner,
exercise a variety of widths/heights, compare against the C reference,
and benchmark when width is multiple of 4.

This improves test coverage for the new function pointer in preparation
for architecture-specific implementations in subsequent commits.

Signed-off-by: Arpad Panyik <Arpad.Panyik@arm.com>
2025-12-05 10:28:18 +00:00
Arpad Panyik ef651b84ce swscale: Refactor XYZ+RGB state and add function hooks
Prepare for xyz12Torgb48 architecture-specific optimizations in
subsequent patches by:
 - Grouping XYZ+RGB gamma LUTs and 3x3 matrices into SwsColorXform
   (ctx->xyz2rgb and ctx->rgb2xyz), replacing scattered fields.
 - Dropping the unused last matrix column giving the same or smaller
   SwsInternal size.
 - Renaming ff_xyz12Torgb48 and ff_rgb48Toxyz12 and routing calls via
   the new per-context function pointer (ctx->xyz12Torgb48 and
   ctx->rgb48Toxyz12) in graph.c and swscale.c.
 - Adding ff_sws_init_xyzdsp and invoking it in swscale init paths
   (normal and unscaled).
 - Making fill_xyztables public to ease its setup later in checkasm.

These modifications do not introduce any functional changes.

Signed-off-by: Arpad Panyik <Arpad.Panyik@arm.com>
2025-12-05 10:28:18 +00:00
Andreas Rheinhardt 9e038fd959 swscale/tests/swscale: Fix typo
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-05 10:42:01 +01:00
James Almer 52c84b06d5 avfilter/f_sidedata: also handle global side data in filter links
Should fix issue #21071

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-04 13:50:45 -03:00
Andreas Rheinhardt e0845ec2cf avformat/movenc: Fix leak of IAMFContext on error
Forgotten in 5b87869c09.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 16:15:09 +00:00
Lynne f80addbb07 ffv1enc_vulkan: fix encoding with large contexts
When RGB_LINECACHE == 2, then top2 is not the current line.
2025-12-04 16:53:58 +01:00
Andreas Rheinhardt 4b6e40a298 avcodec/vp8dsp: Don't compile unused functions
The width 16 epel functions never use four taps in any direction*,
so don't build said functions. Saves 4352B of .text and 89B of
.text.unlikely here.

*: mx and my in vp8_mc_luma() are always even.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 9cff236e2f avcodec/riscv/vp8dsp_rvv: Remove unused functions
Only the sixtap functions are used for size 16.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 050c80a526 avcodec/x86/vp8dsp: Don't use saturated addition when unnecessary
For the epel functions, there can be no overflow as long as the sum
contains only one of the two large central coefficients; for bilinear
functions, there can be no overflow whatsoever.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 575e9e9c08 avcodec/x86/vp8dsp: Reduce number of coefficient tables
By changing the permutations used in the epel8_h{4,6} case
we can simply reuse the coefficient tables from the vertical epel
filters.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 99fb257f58 avcodec/x86/vp8dsp: Don't use MMX registers in ff_put_vp8_epel4_h6_ssse3
Doubling the register width allowed to avoid a pshufb and a pmaddubsw.

Old benchmarks:
vp8_put_epel4_h6_c:                                    115.9 ( 1.00x)
vp8_put_epel4_h6_ssse3:                                 20.2 ( 5.74x)
vp8_put_epel4_h6v4_c:                                  276.3 ( 1.00x)
vp8_put_epel4_h6v4_ssse3:                               58.6 ( 4.71x)
vp8_put_epel4_h6v6_c:                                  363.6 ( 1.00x)
vp8_put_epel4_h6v6_ssse3:                               62.5 ( 5.82x)

New benchmarks:
vp8_put_epel4_h6_c:                                    116.4 ( 1.00x)
vp8_put_epel4_h6_ssse3:                                 16.0 ( 7.29x)
vp8_put_epel4_h6v4_c:                                  280.9 ( 1.00x)
vp8_put_epel4_h6v4_ssse3:                               44.3 ( 6.33x)
vp8_put_epel4_h6v6_c:                                  365.6 ( 1.00x)
vp8_put_epel4_h6v6_ssse3:                               53.1 ( 6.89x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 3135bc0d3a avcodec/x86/vp8dsp: Don't use MMX registers in ff_put_vp8_epel4_h4_ssse3
Doubling the register width allows to use only one pshufb and pmaddubsw.

Old benchmarks:
vp8_put_epel4_h4_c:                                     82.8 ( 1.00x)
vp8_put_epel4_h4_ssse3:                                 13.9 ( 5.96x)

New benchmarks:
vp8_put_epel4_h4_c:                                     82.7 ( 1.00x)
vp8_put_epel4_h4_ssse3:                                 11.7 ( 7.08x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 714cbf1c70 avcodec/x86/vp8dsp: Don't use MMX registers in ff_put_vp8_epel4_v4_ssse3
Switching to xmm registers allows to process two rows in parallel,
leading to speedups. It is also ABI compliant (no more missing emms).

Old benchmarks:
vp8_put_epel4_v4_c:                                     96.8 ( 1.00x)
vp8_put_epel4_v4_ssse3:                                 28.2 ( 3.43x)

New benchmarks:
vp8_put_epel4_v4_c:                                     95.1 ( 1.00x)
vp8_put_epel4_v4_ssse3:                                 22.8 ( 4.17x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt f017806829 avcodec/x86/vp8dsp: Don't use MMX registers in ff_put_vp8_epel4_v6_ssse3
Switching to xmm registers allows to process two rows in parallel,
leading to speedups. It is also ABI compliant (no more missing emms).

Old benchmarks:
vp8_put_epel4_v6_c:                                    132.8 ( 1.00x)
vp8_put_epel4_v6_ssse3:                                 34.3 ( 3.87x)

New benchmarks:
vp8_put_epel4_v6_c:                                    131.5 ( 1.00x)
vp8_put_epel4_v6_ssse3:                                 27.1 ( 4.86x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 7411998757 avcodec/x86/vp8dsp: Avoid unpacking multiple times
Always pair row i with row i+2 for the vertical four-tap filter
and row i+3 for the vertical six-tap filter (instead of pairing
the first with the sixth, the second with the third and the fourth
and the fifth). This allows to unpack each row only once instead
of (at most) three times.

Old benchmarks:
vp8_put_epel4_v4_c:                                     98.4 ( 1.00x)
vp8_put_epel4_v4_ssse3:                                 28.6 ( 3.44x)
vp8_put_epel4_v6_c:                                    131.6 ( 1.00x)
vp8_put_epel4_v6_ssse3:                                 38.5 ( 3.42x)
vp8_put_epel8_v4_c:                                    362.5 ( 1.00x)
vp8_put_epel8_v4_sse2:                                  63.8 ( 5.68x)
vp8_put_epel8_v4_ssse3:                                 44.4 ( 8.16x)
vp8_put_epel8_v6_c:                                    538.3 ( 1.00x)
vp8_put_epel8_v6_sse2:                                  86.5 ( 6.22x)
vp8_put_epel8_v6_ssse3:                                 57.0 ( 9.44x)
vp8_put_epel16_v6_c:                                  1044.6 ( 1.00x)
vp8_put_epel16_v6_sse2:                                158.0 ( 6.61x)
vp8_put_epel16_v6_ssse3:                               106.7 ( 9.79x)

New benchmarks:
vp8_put_epel4_v4_c:                                    100.0 ( 1.00x)
vp8_put_epel4_v4_ssse3:                                 28.4 ( 3.52x)
vp8_put_epel4_v6_c:                                    131.7 ( 1.00x)
vp8_put_epel4_v6_ssse3:                                 34.3 ( 3.84x)
vp8_put_epel8_v4_c:                                    364.4 ( 1.00x)
vp8_put_epel8_v4_sse2:                                  63.7 ( 5.72x)
vp8_put_epel8_v4_ssse3:                                 43.3 ( 8.42x)
vp8_put_epel8_v6_c:                                    550.2 ( 1.00x)
vp8_put_epel8_v6_sse2:                                  86.4 ( 6.37x)
vp8_put_epel8_v6_ssse3:                                 52.9 (10.40x)
vp8_put_epel16_v6_c:                                  1052.5 ( 1.00x)
vp8_put_epel16_v6_sse2:                                158.3 ( 6.65x)
vp8_put_epel16_v6_ssse3:                                98.9 (10.64x)

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 24cdd4100d avcodec/x86/vp8dsp_init: Remove unused macro
Forgotten in 6a551f1405.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 76900089fb avcodec/x86/vp8dsp: Avoid reload
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 86aa1b81ec avcodec/x86/vp8dsp: Increment src pointer earlier
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt e59ed3470d avcodec/x86/vp8dsp: Directly use negated stride
There is a register available. No change in benchmarks here.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:37 +01:00
Andreas Rheinhardt 8fb6b0c733 avcodec/x86/vp8dsp: Don't use MMX registers in put_vp8_pixels8
Use GPRs on x64 and xmm registers else (using GPRs reduces codesize).
This avoids clobbering the floating point state and therefore no longer
breaks the ABI.
No change in benchmarks here.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:36 +01:00
Andreas Rheinhardt ed5e0f9c68 avcodec/x86/vp8dsp: Remove MMXEXT functions overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-04 15:17:36 +01:00
Lynne 9b14ea0aa1 vulkan_dpx: fix alignment issue
12-bit images apparently require mod-32 alignment for each line.
Go figure.
2025-12-04 15:08:46 +01:00
Oliver Chang d6458f6a8b avcodec/aacdec: Fix heap-use-after-free in USAC decoding
A heap-use-after-free vulnerability was identified in
`libavcodec/aac/aacdec.c`.  When `che_configure` frees a
`ChannelElement` (`ac->che[type][id]`), it failed to clear all
references to it in `ac->tag_che_map`.  `ac->tag_che_map` caches
pointers to `ChannelElement`s and can contain cross-type mappings (e.g.,
a `TYPE_SCE` tag mapping to a `TYPE_LFE` element).

In a USAC stream reconfiguration scenario, an LFE element was freed, but
a stale pointer remained in `ac->tag_che_map`. Subsequent calls to
`ff_aac_get_che` returned this dangling pointer, leading to a crash in
`decode_usac_core_coder`.

This commit fixes the issue by iterating over the entire
`ac->tag_che_map` in `che_configure` and clearing any entries that point
to the `ChannelElement` about to be freed, ensuring no dangling pointers
remain.

Fixes: https://issues.oss-fuzz.com/issues/440220467
2025-12-04 09:34:32 +00:00
Xia Tao 7922d4ca7d avcodec/wasm/hevc: fix typo in butterfly macro
Signed-off-by: Xia Tao <xiatao@gmail.com>
2025-12-04 08:40:43 +00:00
stevxiao 7b2ae2ccf7 avcodec/d3d12va_encode: add intra refresh support for d3d12va encode
Intra refresh is a technique that gradually refreshes the video by encoding rows or regions as intra macroblocks/CTUs spread over multiple frames, rather than using periodic I-frames.
This provides better error resilience for video streaming while maintaining more consistent bitrate.

Disable Intra Refresh (This is the default)
ffmpeg -init_hw_device d3d12va -hwaccel d3d12va -hwaccel_output_format d3d12 \
-i input.mp4 \
-c:v h264_d3d12va \
-intra_refresh_mode none \
-intra_refresh_duration 30 \
-g 60 \
output.h264

Enable Intra Refresh
ffmpeg -init_hw_device d3d12va -hwaccel d3d12va -hwaccel_output_format d3d12 \
-i input.mp4 \
-c:v h264_d3d12va \
-intra_refresh_mode row_based \
-intra_refresh_duration 30 \
-g 60 \
output.h264

Parameters
- `-intra_refresh_mode`: Set to `row_based` to enable row-based intra refresh, or `NONE` to disable
- `-intra_refresh_duration`: Number of frames over which to spread the intra refresh (default: 0 = use GOP size)
- `-g`: GOP size (should typically be larger than intra refresh duration)
2025-12-04 08:26:26 +00:00
Michael Niedermayer 12e7d095b1 Revert "avformat/rawdec: set framerate in codec parameters"
Fixes single image videos
this works and creates our single image video
./ffmpeg -i lena.pnm /tmp/file.m2v

this fails after 3d96d83a0a:
./ffmpeg -i /tmp/file.m2v /tmp/file.jpg -y

This reverts commit 3d96d83a0a.
2025-12-04 01:59:04 +00:00
Kacper Michajłow 9ed71a837b avutil/vulkan: fix device memory size truncation
size_t cannot fit VK_WHOLE_SIZE on 32-bit builds.

Fixes: warning: conversion from 'long long unsigned int' to 'size_t' {aka 'unsigned int'} changes value from '18446744073709551615' to '4294967295'

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-03 23:45:44 +00:00
Kacper Michajłow 3cc10b5ff6 fftools/cmdutils: use strcpy directly, the length is computed already
There is no need to scan for NULL, if we inject it ourselves.

Fixes: warning: 'strncat' specified bound 10 equals source length [-Wstringop-overflow=]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-03 23:45:44 +00:00
Kacper Michajłow f7b7972f78 avdevice/gdigrab: suppress int to pointer cast warning
Fixes: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-03 23:45:44 +00:00
wutno f4312ea138 avformat/xmv: Handle zero sized packet at end of file
Some XMVs introduce a blank packet at the end of the stream. Previously, we
didn't account for this and returned AVERROR_INVALIDDATA, indicating an issue
with the file. Instead, let's check for this and close out with AVERROR_EOF.
2025-12-03 22:09:20 +00:00
Lynne a8e8daa276 hwcontext_vulkan: fix final error to let old header files work
........
2025-12-03 22:34:32 +01:00
Jack Lau c4b050fd67 tests/fate/filter-video: add two feedback tests
- Add fate-filter-feedback-yadif

- add fate-filter-feedback-hflip

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-03 21:23:51 +00:00
Jack Lau 3f0842294f avfilter/vf_feedback: fix feedback block
Fix #20940

The feedback and its sub-filter both request frame
from each other, casuing block since 4440e499ba

The feedback should only request inputs[1] once
rather than continuously request frame cause blocking.

This patch add check whether feedback already request
inputs[1] via ff_outlink_frame_wanted(ctx->outputs[1]),
if true, then exit and waiting inputs[0] because it means
we need more frames input to proceed.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-12-03 21:23:51 +00:00
Lynne bce14bb160 hwcontext_vulkan: fix compilation with older header versions 2025-12-03 21:22:54 +01:00
Oliver Chang 041d4f010e libavcodec/prores_raw: Fix heap-buffer-overflow in decode_frame
Fixes a heap-buffer-overflow in `decode_frame` where `header_len` read
from the bitstream was not validated against the remaining bytes in the
input buffer (`gb`). This allowed `gb_hdr` to be initialized with a size
exceeding the actual packet data, leading to an out-of-bounds read.

The fix adds a check to ensure `bytestream2_get_bytes_left(&gb)` is
greater than or equal to `header_len - 2` before initializing `gb_hdr`.

Fixes: https://issues.oss-fuzz.com/issues/439711053
2025-12-03 16:40:02 +00:00
Andreas Rheinhardt e3e3265034 tests/checkasm/mpegvideo_unquantize: Add missing const
Fixes this test under UBSan:
runtime error: call to function dct_unquantize_mpeg1_intra_c through pointer to incorrect function type 'void (*)(struct MpegEncContext *, short *, int, int)'
I don't know how I could forget this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 14:17:58 +01:00
Martin Storsjö b98179cec6 avcodec/{arm,neon}/mpegvideo: Readd a missed initialization
This was accidentally removed in
357fc5243c.

This fixes test failures when built with Clang and MSVC;
surprisingly, the checkasm test did seem to pass when built with
GCC. Clang and MSVC also warn about the use of the uninitialized
variable, while GCC didn't.
2025-12-03 13:53:54 +02:00
Andreas Rheinhardt 5d9270df7f libavutil/internal: Remove {SIZE,PTRDIFF}_SPECIFIER
Possible since 222127418b.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 11:52:54 +01:00
Andreas Rheinhardt c22c2c5e03 avcodec/mpegvideo: Port dct_unquantize_mpeg2_intra_mmx to SSE2
Benefits from wider registers.

Benchmarks:
dct_unquantize_mpeg2_intra_c:                          228.2 ( 1.00x)
dct_unquantize_mpeg2_intra_mmx:                         28.2 ( 8.10x)
dct_unquantize_mpeg2_intra_sse2:                        18.4 (12.37x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 6e2153111d avcodec/x86/mpegvideo: Port dct_unquantize_mpeg2_inter_mmx to SSSE3
Benefits from wider registers, pabsw and psignw.

Benchmarks:
dct_unquantize_mpeg2_inter_c:                          131.2 ( 1.00x)
dct_unquantize_mpeg2_inter_mmx:                         50.2 ( 2.62x)
dct_unquantize_mpeg2_inter_ssse3:                       20.5 ( 6.38x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 60084b1369 avcodec/x86/mpegvideo: Port MPEG-1 unquantize functions to SSSE3
Benefits from wider registers and pabsw, psignw.

Benchmarks:
dct_unquantize_mpeg1_inter_c:                          343.0 ( 1.00x)
dct_unquantize_mpeg1_inter_mmx:                         50.6 ( 6.78x)
dct_unquantize_mpeg1_inter_ssse3:                       17.2 (19.94x)
dct_unquantize_mpeg1_intra_c:                          352.1 ( 1.00x)
dct_unquantize_mpeg1_intra_mmx:                         48.8 ( 7.22x)
dct_unquantize_mpeg1_intra_ssse3:                       19.5 (18.03x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 1cb987d25b avcodec/x86/mpegvideo: Port dct_unquantize_h263_{intra,inter}_mmx to SSSE3
It benefits from wider registers and psignw.

Benchmarks:
dct_unquantize_h263_inter_c:                            88.3 ( 1.00x)
dct_unquantize_h263_inter_mmx:                          24.7 ( 3.58x)
dct_unquantize_h263_inter_ssse3:                         9.3 ( 9.47x)
dct_unquantize_h263_intra_c:                            93.7 ( 1.00x)
dct_unquantize_h263_intra_mmx:                          30.6 ( 3.06x)
dct_unquantize_h263_intra_ssse3:                        16.5 ( 5.69x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt a9a23925df avcodec/x86/mpegvideo: Don't duplicate register
Currently several inline ASM blocks used a value as
an input and rax as clobber register. The input value
was just moved into the register which then served as loop
counter. This is wasteful, as one can just use the value's
register directly as loop counter.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 1fa8ffc1db avcodec/x86/mpegvideo: Improve unquantizing MPEG-2 intra blocks
Unquantizing involves calculating
    (block[j] * qscale * quant_matrix[j]) / 16
where / rounds towards zero. Arithmetic right shifts
naturally round towards -inf, so the earlier code
calculated the absolute value first, then used a right-shift
and then negated the result if necessary.

This commit uses a different procedure: It biases the product
for negative values of block[j] by 0xf. The combination of
this and the arithmetic right shift is the same as rounding
towards zero.

Furthermore, a write-only store to mm7 has been removed.

Benchmarks:
dct_unquantize_mpeg2_intra_c:                          214.3 ( 1.00x)
dct_unquantize_mpeg2_intra_mmx (old):                   43.0 ( 4.98x)
dct_unquantize_mpeg2_intra_mmx (new):                   28.4 ( 7.56x)

(The bitexact flag and the test for correctness have beem removed
from checkasm for the benchmarks.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 6d56807a06 avcodec/x86/mpegvideo: Use correct inline assembly constraints
The H.263 unquantize functions modified an input parameter.
(And they did so since this code was added in
7f3f5ec87b. I am surprised
that this didn't cause issues, particularly with the intra function.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 0f7cc6aeea avcodec/mpegvideo: Move ff_init_scantable() to mpegvideo_unquantize.c
This is necessary so that the mpegvideo_unquantize checkasm test
does not pull mpegvideo.o and then all of libavcodec into checkasm.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:43 +01:00
Andreas Rheinhardt 357fc5243c avcodec/{arm,neon}/mpegvideo: Fix h263 unquantize functions
These functions currently operate on the assumption that the number
of coefficients to process is always of the form 16k+m with m<=4 or >8.
Yet this is not true when the IDCT permutation is of type FF_IDCT_PERM_LIBMPEG2
(i.e. when FF_IDCT_INT is in use).

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:39 +01:00
Andreas Rheinhardt 581050a175 tests/checkasm: Add mpegvideo unquantize test
This adds a test for the mpegvideo unquantize functions.

It has been written in order to be able to easily bench
these functions. It should be noted that the random input
fed to the tested functions is not necessarily representative
of the stuff actually occuring in the wild. So benchmarks should
be taken with a grain of salt; but comparisons between two functions
that do not depend on branch predictions are valid (the usecase
for this is to port the x86 mmx functions to use xmm registers).

During testing I have found a bug in the arm/aarch64 neon optimizations
when using the LIBMPEG2 permutation (used by FF_IDCT_INT): The code
seems to be based on the presumption that the remainder of the number
of coefficients to process is always <= 4 mod 16. The test therefore
sometimes fails for these arches.

Hint: I am not certain that 16 bits are enough for the intermediate
values of all the computations involved; e.g. both FLV and MPEG-4
escape values can go beyond that after the corresponding
multiplications. The input in this test is nevertheless designed
to fit into 16 bits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:23:39 +01:00
Andreas Rheinhardt e7a629049f avcodec/{arm,neon}/mpegvideo: Use intra scantable to unquant H263 intra
Forgotten in 70a7df049c.

Using the wrong scantable matters for codecs for which both scantables
can differ, namely the MPEG-4 decoder and the WMV1/2 codecs.

For WMV1 it can lead to wrong output in case the IDCT permutation
is FF_IDCT_PERM_PARTTRANS, because in this case the entries of
of the intra scantable's raster end are not always <= the corresponding
entries of the inter scantable's raster end when the former is
initialized via ff_wmv1_scantable[1] and the latter via ff_wmv1_scantable[0].
FF_IDCT_PERM_PARTTRANS is used iff the Neon IDCT is used (for both arm
and aarch64).* Said IDCT is not used during FATE, so that this issue
went unnoticed.

WMV2 uses the same scantables, but uses a custom IDCT
which always uses FF_IDCT_PERM_NONE for which the inter_scantable,
so that the output is always correct for it.

The scantable for MPEG-4 can change mid-stream (for the decoder),
but since c41818dc5d only the intra
scantable is updated, so that both scantables can get out of sync.
In such a case the unquantize intra functions could unquantize
an incorrect number of coefficients.

Using raster_end of the wrong scantable can also lead to an
unnecessarily large amount of coefficients unquantized.

*: FF_IDCT_PERM_SIMPLE and FF_IDCT_PERM_TRANSPOSE would also not work,
but they are not used at all by arm and aarch64.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:20:42 +01:00
Andreas Rheinhardt 5d41d3e21d avcodec/ppc/mpegvideo_altivec: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:20:42 +01:00
Andreas Rheinhardt 011ef7fc65 avcodec/ppc/mpegvideo_altivec: Split intra/inter unquantizing
Don't use a single function that checks mb_intra. Forgotten
in d50635cd24.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:20:42 +01:00
Andreas Rheinhardt 358c569b05 avcodec/mpegvideo_unquantize: Constify MPVContext pointee
Also use MPVContext instead of MpegEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-12-03 10:20:41 +01:00
yuanhecai f7551e7505 avcodec: fix checkasm-hpeldsp failed on LA 2025-12-03 01:36:01 +00:00
Zhao Zhili 413346bd06 tests/fate/ffmpeg: add test for -force_key_frames scd_metadata 2025-12-02 03:03:55 +00:00
Zhao Zhili 540aacf759 fftools/ffmpeg: add force key frame by scdet metadata support
For example:

./ffmpeg -hwaccel videotoolbox \
	-i input.mp4 -c:a copy \
	-vf scdet=threshold=10 \
	-c:v h264_videotoolbox \
	-force_key_frames scd_metadata \
	-g 1000 -t 30 output.mp4
2025-12-02 03:03:55 +00:00
Thomas Gritzan 27e94281d1 libavdevice/decklink: add support for DeckLink SDK 14.3
This patch adds support for DeckLink SDK 14.3 and newer by using
the legacy interfaces in the header <DeckLinkAPI_v14_2_1.h>.

The missing QueryInterface implementations are also provided.
2025-12-01 21:37:12 +00:00
averne 1e90047fe6 vulkan: fix host copy stride
memoryRowLength is is texels, not bytes
2025-12-01 15:40:40 +01:00
llyyr 7043522fe0 avutil/hwcontext_d3d12va: use hwdev context for logging
This fixes warning about av_log being called with NULL AVClass. This is
also an API violation

Fixes: https://trac.ffmpeg.org/ticket/11335
2025-12-01 03:15:25 +00:00
Lynne 932a872dbc hwcontext_vulkan: fix VkImageToMemoryCopyEXT.sType
It was copy pasted from the upload path.
Somehow, it was missed, despite god knows how many validation layer runs.
2025-11-30 23:11:46 +01:00
Kacper Michajłow 17456c553e tests/checkasm: fix check for 32-bit Windows build
With --disable-asm, ARCH_X86_32 is set to 0, but we still build the
checkasm binary. Update the check so it is config.h agnostic.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-30 22:07:39 +00:00
Russell Greene 3beaa2d70f hwcontext_vulkan: remove VK_HOST_IMAGE_COPY_MEMCPY flag
Reading the spec for what this flag means, it copies the data verbatim, including any swizzling/tiling, this has two issues

1. the format may not be what ffmpeg expects elsewhere, as it is expecing normal pitch linear host memeory in `swf`
2. the size of the copied data may not match the size of buffer provided, causing heap buffer overflow

It seems like addition of this flag is an oversight as it seems to be for caching/backups of image data, just to be used with copying back to the GPU with the MEMCPY flag, which is *not* how its used in ffmpeg.

Additionally, set memoryRowLength as if it isn't set, it assumes pitch = width_in_bytes, which I don't think is necessarily the case
2025-11-30 21:47:12 +00:00
Andreas Rheinhardt 59d75bf9e4 avutil/x86/Makefile: Only compile ASM init files when X86ASM is enabled
To do so, simply add these init files to X86ASM-OBJS instead of OBJS
in the Makefile. The former is already used for the actual assembly
files, but using them for the C init files just works, because the build
system uses file extensions to derive whether it is a C or a NASM file.

This avoids compiling unused function stubs and also reduces our
reliance on DCE: We don't add %if checks to the asm files except
for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4
functions will be available. It also allows to remove HAVE_X86ASM checks
in these init files.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt d5a47bf2b3 swresample/x86/Makefile: Only compile ASM init files when X86ASM is enabled
To do so, simply add these init files to X86ASM-OBJS instead of OBJS
in the Makefile. The former is already used for the actual assembly
files, but using them for the C init files just works, because the build
system uses file extensions to derive whether it is a C or a NASM file.

This avoids compiling unused function stubs and also reduces our
reliance on DCE: We don't add %if checks to the asm files except
for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4
functions will be available. It also allows to remove HAVE_X86ASM checks
in these init files.

(x86/ops.c has already been put in X86ASM-OBJS.)

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt 7356981bec avfilter/x86/Makefile: Only compile ASM init files when X86ASM is enabled
To do so, simply add these init files to X86ASM-OBJS instead of OBJS
in the Makefile. The former is already used for the actual assembly
files, but using them for the C init files just works, because the build
system uses file extensions to derive whether it is a C or a NASM file.

This avoids compiling unused function stubs and also reduces our
reliance on DCE: We don't add %if checks to the asm files except
for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4
functions will be available. It also allows to remove HAVE_X86ASM checks
in these init files.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt eccf130fdb {lib{avcodec,swscale}/x86/,}Makefile: Kill MMX-OBJS
Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt ba94177242 avcodec/x86/Makefile: Only compile ASM init files when X86ASM is enabled
To do so, simply add these init files to X86ASM-OBJS instead of OBJS
in the Makefile. The former is already used for the actual assembly
files, but using them for the C init files just works, because the build
system uses file extensions to derive whether it is a C or a NASM file.

This avoids compiling unused function stubs and also reduces our
reliance on DCE: We don't add %if checks to the asm files except
for AVX, AVX2, FMA3, FMA4, XOP and AVX512, so all the MMX-SSE4
functions will be available. It also allows to remove HAVE_X86ASM checks
in these init files.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
Andreas Rheinhardt 65b4feb782 avcodec/x86/Makefile: Remove redundant WebP decoder->vp8dsp dependencies
Redundant since 35b02732b9.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 22:20:13 +01:00
averne 1d1643b42a vulkan/prores: use cached bitstream reader
Speedup is around 75% on NVIDIA 3050, 20% on AMD 6700XT, 5% on Intel TigerLake.
2025-11-30 22:01:17 +01:00
averne fd2fd3828c libavcodec/vulkan: remove unnessary member in GetBitContext
The number of remaining bits can be calculated using existing state.
This simplifies calculations and frees up one register.
2025-11-30 19:21:08 +01:00
averne ef7354d471 libavcodec/vulkan: introduce cached bitstream reader
This stores a small buffer in shared memory per decode thread (16 bytes),
which helps reduce the number of memory accesses.
The bitstream buffer is first aligned to a 4 byte boundary, so that the
buffer can be filled with a single memory request.
2025-11-30 19:21:04 +01:00
Kacper Michajłow 2456a39581 avfilter/avfiltergraph: fix constant string comparision
It's not guaranteed that the conversion filter name string will be
deduplicated to the same memory location. While this is common
optimization to do, we cannot rely on it always happening.

Fixes regression since 8b375b2ffd.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-30 03:02:41 +01:00
Andreas Rheinhardt 89f984e3d1 avcodec/x86/h264_idct: Fix ff_h264_luma_dc_dequant_idct_sse2 checkasm failures
ff_h264_luma_dc_dequant_idct_sse2() does not pass checkasm for certain
seeds, because the input to packssdw no longer fits into an int16_t,
leading to saturation, where the C code just truncates. I don't know
whether the spec contains provisions that ensure that valid input
must not exceed 16 bit or whether the such inputs (even if invalid)
can be triggered by the actual code and not only the test.

This commit adapts the behavior of the function to the C reference code
to fix the test. packssdw is avoided, instead the lower words are
directly transfered to GPRs to be written out. This has unfortunately
led to a slight performance regression here (14.5 vs 15.1 cycles).

Fixes issue #20835.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt e6ae2802a3 avcodec/x86/h264_idct: Deduplicate generating constant
pw_1 is currently loaded in both codepaths. Generate it earlier instead.
Gives tiny speedups (15 vs 14.5 cycles) and reduces codesize.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt ada0a81577 avcodec/x86/h264_idct: Don't use MMX registers in ff_h264_luma_dc_dequant_idct_sse2
It is ABI compliant and gives a tiny speedup here (and is 16B smaller).

Old benchmarks:
h264_luma_dc_dequant_idct_8_c:                          33.2 ( 1.00x)
h264_luma_dc_dequant_idct_8_sse2:                       16.0 ( 2.07x)

New benchmarks:
h264_luma_dc_dequant_idct_8_c:                          33.0 ( 1.00x)
h264_luma_dc_dequant_idct_8_sse2:                       15.0 ( 2.20x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt 012c25bac4 avcodec/x86/h264_idct: Zero with full-width stores
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt b9cbbd9074 avcodec/x86/h264_idct: Use tail call where advantageous
It is possible on UNIX64.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt 0ec9c1b68d avutil/x86/x86inc: Use parentheses in has_epilogue
Prevents surprises.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt 01ff05e4bc avcodec/x86/h264_idct: Avoid call where possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt b51cbd4116 avcodec/x86/h264_idct: Remove redundant movsxdifnidn
Only exported (i.e. cglobal) functions need it; stride is already
sign-extended when it reaches any of the internal functions used here,
so don't sign-extend again.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Andreas Rheinhardt 18019f177e avcodec/x86/h264idct: Remove dead MMX macros
Forgotten in 4618f36a24.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-30 00:15:43 +01:00
Kacper Michajłow 9cd4be6d7c tools/sofa2wavs: fix build on Windows
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-29 21:43:12 +00:00
averne 1c5bb1b12d vulkan/prores: normalize coefficients during IDCT
This allows increased internal precision.
In addition, we can introduce an offset to the DC coefficient
during the second IDCT step, to remove a per-element addition
in the output codepath.
Finally, by processing columns first we can remove the barrier
after loading coefficients.

Signed-off-by: averne <averne381@gmail.com>
2025-11-29 17:56:28 +01:00
averne 1982add485 vulkan/prores: fix dequantization for 4:2:2 subsampling
Bug introduced in d00f41f due to an oversight.
2025-11-29 17:27:21 +01:00
Niklas Haas 04eeaeed11 avfilter/vf_libplacebo: also rotate SAR when fitting 2025-11-29 08:45:24 +00:00
Niklas Haas f83fdad550 avfilter/vf_libplacebo: fix math when AVRationals are undefined 2025-11-29 08:45:24 +00:00
Niklas Haas 6e0034ab7e avfilter/vf_libplacebo: un-rotate image crop after fitting
When combining rotation with a FIT_ mode other than FIT_FILL, the fitting
logic was operating on the un-rotated rects, when it should have been
operating on the rotated (output) rects.
2025-11-29 08:45:24 +00:00
Piotr Pawlowski 372dab2a4d All: Removed reliance on compiler performing dead code elimination, changed various macro constant checks from if() to #if 2025-11-28 19:52:51 +01:00
Hao Chen a6206a31ea swscale: Fix out-of-bounds write errors in yuv2rgb_lasx.c file.
The patch adds support for dstw values ending in 2, 4, 6, 8, 10, 12, and 14,
which fixes the out-of-bounds write problem.
2025-11-28 03:40:47 +00:00
Ayose c1b86a009e tests/fate-filter-drawvg-video: copy drawvg.lines file to tests/data.
If the SRC_PATH variable contains certain characters (like a `:`, which may
happen when FATE is executed on Windows), the value for the `file` option is
broken, so `make fate-filter-drawvg-video` always fails.

The solution in this commit is to copy the `drawvg.lines` to the `tests/data`
directory (which already has temp files), so the value for `file` is a fixed
string with no problematic characters.

Signed-off-by: Ayose <ayosec@gmail.com>
2025-11-28 02:38:09 +00:00
Gavin Li 3d96d83a0a avformat/rawdec: set framerate in codec parameters
Commit ba4b73c977 caused a regression in
the usage of avg_frame_rate to detect the frame rate of raw h264/hevc
bitstreams: after the commit, avg_frame_rate is always the value of the
-framerate option (which is set to 25 by default) instead of the actual
frame rate derived from the bitstream SPS/VPS NALUs.

This commit fixes the regression by setting the framerate codec
parameter to the value of the framerate option instead. After this
change, bitstreams without timing information will derive avg_frame_rate
from the -framerate option, while bitstreams with timing information
will derive avg_frame_rate from the bitstream itself.

The h264-bsf-dts2pts test now returns the correct frame durations for a
bitstream with a mix of single-field and double-field frames.

Signed-off-by: Gavin Li <git@thegavinli.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-27 20:01:54 -03:00
James Almer 69534d4e7e avcodec/cavs_parser: parse sequence headers for stream parameters
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-27 20:01:54 -03:00
Diego de Souza 75b8567591 avfilter/scale_cuda: Add support for 4:2:2 chroma subsampling
The supported YUV pixel formats were separated between planar
and semiplanar. This approach reduces the number of CUDA kernels
for all pixel formats.

This patch:
1. Adds support for YUV 4:2:2 planar and semi-planar formats:
        yuv422p, yuv422p10, nv16, p210, p216
2. Implements new conversion structures and kernel definitions
        for planar and semi-planar formats

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2025-11-27 22:11:57 +01:00
Diego de Souza 04b5e25d35 avfilter/hwupload_cuda: Expands pixel formats support
Add support for uploading additional pixel formats to NVIDIA GPUs:
- Planar formats (yuv420p10, yuv422p, yuv422p10, yuv444p10)
- Semiplanar formats (nv16, p210, p216)

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2025-11-27 22:11:57 +01:00
Diego de Souza 9c76d7db86 avutil/hwcontext_cuda: Expands pixel formats support
Add support for additional pixel formats in CUDA hardware context:
- Planar formats (yuv420p10, yuv422p, yuv422p10, yuv444p10)
- Semiplanar formats (nv16, p210, p216)

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2025-11-27 22:11:57 +01:00
Thomas Gritzan 0cd75dbfa0 libavdevice/decklink: Implement QueryInterface to support newer driver
Playback to a decklink device with a newer version of the
DeckLink SDK (14.3) stalls because the driver code calls
IDeckLinkVideoFrame::QueryInterface, which is not
implemented by ffmpeg.
This patch implements decklink_frame::QueryInterface,
so that playback works with both older (12.x) and
newer (>= 14.3) drivers.

Note: The patch still does not allow the code to compile
with DeckLink SDK 14.3 or newer, as the API has changed.
2025-11-27 20:12:03 +00:00
Frank Plowman 5169b0c3dc lavc/vvc: Ensure seq_decode is always updated with SPS
seq_decode is used to ensure that a picture and all of its reference
pictures use the same SPS. Any time the SPS changes, seq_decode should
be incremented. Prior to this patch, seq_decode was incremented in
frame_context_setup, which is called after the SPS is potentially
changed in decode_sps. Should the decoder encounter an error between
changing the SPS and incrementing seq_decode, the SPS could be modified
while seq_decode was not incremented, which could lead to invalid
reference pictures and various downstream issues. By instead updating
seq_decode within the picture set manager, we ensure seq_decode and the
SPS are always updated in tandem.
2025-11-27 14:51:52 +00:00
Anthony Bajoua 93ccca22bb libavformat/mov: Fixes individual track duration on fragmented files 2025-11-27 14:05:33 +00:00
mux47 618fc15e65 libavcodec/opus/parser: Fix spurious 'Error parsing Opus packet header'
When PARSER_FLAG_COMPLETE_FRAMES is set, opus_parse() calls
set_frame_duration even on flush (buf_size==0), which triggers
a spurious "Error parsing Opus packet header" at EOF.

Match streaming-path behavior by skipping duration parsing on empty buffers.
Fixes #20954
2025-11-27 14:04:20 +00:00
Zhao Zhili cac5018eb9 avformat/mov: fix crash when stsz_sample_size is zero and sample_sizes is null
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-27 14:03:06 +00:00
Andreas Rheinhardt f0f7834726 avcodec/cbs_apv: Use ff_cbs_{read,write}_simple_unsigned()
Avoids checks and makes the calls cheaper.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 14:00:45 +00:00
Andreas Rheinhardt 7018ce14df avcodec/x86/vp6dsp: Avoid packing+unpacking
Store the intermediate values as words, clipped to the 0..255 range
instead.

Old benchmarks:
filter_diag4_c:                                        353.4 ( 1.00x)
filter_diag4_sse2:                                      57.5 ( 6.15x)

New benchmarks:
filter_diag4_c:                                        350.6 ( 1.00x)
filter_diag4_sse2:                                      55.1 ( 6.36x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:49 +01:00
Andreas Rheinhardt 300cd2c2f2 avcodec/x86/vp6dsp: Avoid saturated addition
Only the two middle coefficients are so huge that overflow can happen.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:46 +01:00
Andreas Rheinhardt dcc101167c avcodec/x86/vp6dsp: Simplify splatting
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:43 +01:00
Andreas Rheinhardt 111fabf5b4 avcodec/x86/vp6dsp: Don't align the stack manually
For most systems (particularly all x64), the stack is already
guaranteed to be sufficiently aligned. So just use x86inc's
stack feature which does the right thing.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:40 +01:00
Andreas Rheinhardt 363a34a7cb avcodec/x86/vp6dsp: Fix outdated comment
Forgotten in 6cb3ee80b3.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:37 +01:00
Andreas Rheinhardt aabaab10d2 tests/checkasm: Test VP6DSP
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:34 +01:00
Andreas Rheinhardt 962858169a avcodec/vp6dsp: Constify source in vp6_filter_diag4
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:32 +01:00
Andreas Rheinhardt f397fe86c3 avcodec/vp56dsp: Separate VP5DSP and VP6DSP
They don't have anything in common since
160ebe0a8d.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:29 +01:00
Andreas Rheinhardt 5dadae9feb avcodec/vp56: Fix indentation
Forgotten in 160ebe0a8d.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:10:26 +01:00
Andreas Rheinhardt 8443940002 avcodec/arm/vp6dsp: Remove VP6 edge filter functions
Forgotten in 160ebe0a8d.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 12:08:45 +01:00
Andreas Rheinhardt 0ea961c070 avcodec/vp3: Redo updating frames
VP3's frame managment is actually simple: It has three frame slots:
current, last and golden. After having decoded the current frame,
the old last frame will be freed and replaced by the current frame.
If the current frame is a keyframe, it also takes over the golden slot.

The VP3 decoder handled this like this: In single-threaded mode,
the above procedure was carried out (on success). Doing so with
frame-threading is impossible, as it would lead to data races.
Instead vp3_update_thread_context() created new references
to these frames and then carried out said procedure.

This means that vp3_update_thread_context() is not just a "dumb"
function that only copies certain fields from src to dst; instead
it actually processes them. E.g. trying to copy the decoding state
from A to B and then from B to C (with no decode_frame call in between)
will not be equivalent to copying from A to C, as both current and last
frames will be blank in the first case.

This commit changes this: Because last_frame won't be needed after
decoding, no reference to it will be created to it in
vp3_update_thread_context(); instead it is now always unreferenced
after decoding it (even on error). Replacing last_frame with the new
frame is now always performed when the new frame is allocated.
Replacing the golden frame is now done earlier, namely in decode_frame()
before ff_thread_finish_setup(), so that update_thread_context only
has to reference current frame and golden frame. Being dumb means
that update_thread_context also no longer checks whether the current
frame is valid, so that it can no longer error out.

This unifies the single- and multi-threaded codepaths; it can lead
to changes in output in single threaded mode: When erroring out,
the current frame would be discarded and not be put into one
of the reference slots at all in single-threaded mode. The new
code meanwhile does everything as the frame-threaded code already did
in order to reduce discrepancies between the two. It would be possible
to keep the old single-threaded behavior (one would need to postpone
replacing the golden frame to the end of vp3_decode_frame and would
need to swap the current frame and the last frame on error,
unreferencing the former).

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 11:34:25 +01:00
Andreas Rheinhardt 2ca072e168 avcodec/vp3: Remove always-false checks
The dimensions are only set at two places: theora_decode_header()
and vp3_decode_init(). These functions are called during init
and during dimension changes, but the latter is only supported
(and attempted) when frame threading is not active. This implies that
the dimensions of the various worker threads in
vp3_update_thread_context() always coincide, so that these checks
are dead and can be removed.

(These checks would of course need to be removed when support
for dimension changes during frame threading is implemented;
and in any case, a dimension change is not an error.)

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 11:33:00 +01:00
Andreas Rheinhardt d52bca36ef avcodec/vp3: Move last_qps from context to stack
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 11:32:54 +01:00
Andreas Rheinhardt 90551b7d80 avcodec/vp3: Sync VLCs once during init, fix crash
6c7a344b65 made the VLCs shared between
threads and did so in a way that was designed to support stream
reconfigurations, so that the structure containing the VLCs was
synced in update_thread_context. The idea was that the currently
active VLCs would just be passed along between threads.

Yet this was broken by 5acbdd2264:
Before this commit, submit_packet() was a no-op during flushing
for VP3, as it is a no-delay decoder, so it won't produce any output
during flushing. This meant that prev_thread in pthread_frame.c
contained the last dst thread that update_thread_context()
was called for (so that these VLCs could be passed along between
threads). Yet after said commit, submit_packet was no longer
a no-op during flushing and changed prev_thread in such a way
that it did not need to contain any VLCs at all*. When flushing,
prev_thread is used to pass the current state to the first worker
thread which is the one that is used to restart decoding.
It could therefore happen that the decoding thread did not contain
the VLCs at all any more after decoding restarts after flushing
leading to a crash (this scenario was never anticipated and
must not happen at all).

There is a simple, easily backportable fix given that we do not
support stream reconfigurations (yet) when using frame threading:
Don't sync the VLCs in update_thread_context(), instead do it once
during init.

This fixes forgejo issue #20346 and trac issue #11592.

(I don't know why 5acbdd2264
changed submit_packet() to no longer be a no-op when draining
no-delay decoders.)

*: The exact condition for the crash is nb_threads > 2*nb_frames.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-27 11:30:55 +01:00
Zhao Zhili 61b034a47c avcodec/rkmppenc: add h264/hevc rkmpp encoder
Bump rockchip_mpp to 1.3.8.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-27 15:54:49 +08:00
Zhao Zhili d8e095b56d configure: cleanup rkmpp check
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-27 15:54:42 +08:00
Lynne 7d0483e6a7 vulkan_dpx: fix compilation with older headers
Fixes #21028
2025-11-27 03:12:30 +01:00
Timo Rothenpieler f7aaa8ecb5 forgejo/workflows: make test shared/static mode more human readable 2025-11-26 23:21:11 +00:00
Lynne 231f735d55 vulkan_dpx: use host visible allocation for host image copy buffer
Fixes black screen on Nvidia.
2025-11-26 18:33:10 +01:00
Lynne 162e07da61 vulkan_dpx: fix "upoad" typo 2025-11-26 18:32:25 +01:00
James Almer faa382e5b1 avformat/iamf_parse: ensure the stream count in a scalable channel representation is equal to the audio element's stream count
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-26 12:01:17 -03:00
James Almer 554ae5ada9 avformat/iamf_parse: ensure each layout in an scalable channel representation has an increasing number of channels
Fixes issue #21013

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-26 12:01:17 -03:00
Lynne 3bcf2be06c Changelog: bump lavc minor and add entry for the DPX Vulkan hwaccel 2025-11-26 15:16:43 +01:00
Lynne 531ce713a0 dpxdec: add a Vulkan hwaccel 2025-11-26 15:16:43 +01:00
Lynne a9acae202a dpxdec: add hardware decoding hooks 2025-11-26 15:16:42 +01:00
Lynne 61ae1ec85f dpxdec: move data parsing into a separate function 2025-11-26 15:16:42 +01:00
Lynne bc07d03d06 dpx: add a context
This simply adds a context with 4 fields to enable hardware unpacking.
2025-11-26 15:16:42 +01:00
Lynne 7af5b5cec3 vulkan_prores_raw: use the native image representation
It allows us to easily synchronize the software and hardware
decoders, by removing the abstraction the Vulkan layer added by changing
the values written.
2025-11-26 15:16:42 +01:00
Lynne a811a6885a vulkan_prores_raw: read the header length rather than assuming its 8
In all known samples, it is equal to 8.
2025-11-26 15:16:42 +01:00
Lynne 0db891366d vulkan_prores_raw: fix dynamically non-uniform accesses to pushconsts
The Vulkan spec requires that all accesses to push data are uniform for
all invocations (e.g. can't be based on gl_WorkGroupID or gl_LocalInvocationID).
2025-11-26 15:16:41 +01:00
Lynne edb844510e vulkan_prores_raw: use regular descriptors for tile data instead of BDA
Regular descriptors are faster.
2025-11-26 15:16:41 +01:00
Lynne bb30a0d0d8 vulkan_prores_raw: split up decoding and DCT
This commit optimizes the Vulkan decoder by splitting up decoding
from iDCT, and merging the few tables needed directly into the shader.

The speedup on Intel is 10x.
2025-11-26 15:16:41 +01:00
Lynne 0c20edaa7a vulkan_prores: initialize only the necessary shaders on init 2025-11-26 15:16:41 +01:00
Lynne a160e4a9e2 prores_raw: call ff_get_format if the version changes 2025-11-26 15:16:41 +01:00
Lynne 3934089de2 vulkan_prores: initialize only the necessary shaders on init 2025-11-26 15:16:41 +01:00
Lynne 8c0314d44a proresdec: call ff_get_format if the interlacing changes
Decoders need to track all state that hwaccels may be intersted in,
and trigger a reconfiguration if it changes.
2025-11-26 15:16:41 +01:00
Lynne 56dea1a9e8 vulkan_ffv1: initialize only the necessary shaders on init
The decoder will reinit the hwaccel upon pixfmt/dimension changes,
so we can remove the f->use32bit and is_rgb variants of all shaders.

This speeds up init time.
2025-11-26 15:16:40 +01:00
Lynne a1154b74a4 ffv1dec: call ff_get_format if the EC coding changes
Decoders need to track all state that hwaccels may be intersted in,
and trigger a reconfiguration if it changes.
2025-11-26 15:16:40 +01:00
Lynne be9998674a vulkan_ffv1/prores: remove unnecessary slice buffer unref
The slice buffer is already unref'd by ff_vk_decode_free_frame().
2025-11-26 15:16:40 +01:00
Lynne 615b26f1b1 vulkan_ffv1: fix swapped colors for x2bgr10 2025-11-26 15:16:40 +01:00
Lynne 3ddcf042b2 ffv1enc_vulkan: add support for x2bgr10/x2rgb10 2025-11-26 15:16:40 +01:00
Lynne 23cfcf93d2 vulkan: change ff_vk_frame_barrier access and stage type to sync2
Cleans up a compiler warning.
2025-11-26 15:16:40 +01:00
Lynne d36d88dcbb vulkan/common: add reverse2 endian reversal macro 2025-11-26 15:16:39 +01:00
Lynne 6c3984db7f vulkan/common: add a function to flush/invalidate a buffer and use it
Just for convenience.
2025-11-26 15:16:39 +01:00
Lynne d288d4a24e hwcontext_vulkan: use vkTransitionImageLayoutEXT to switch layouts
Falls back to regular submit-based layout switching if unsupported.
2025-11-26 15:16:39 +01:00
Lynne 5c89528342 hwcontext_vulkan: disable host image transfers for Nvidia devices
Nvidia's binary drivers have a very buggy implementation that is
yet to be fixed.
2025-11-26 15:16:39 +01:00
Lynne 686951849b hwcontext_vulkan: re-enable host image copy extension
We'll slowly start to use it in the code in safe places
rather than globally.
2025-11-26 15:16:39 +01:00
Lynne fc2dd6c751 hwcontext_vulkan: enable runtime descriptor sizing
We were already using this in places, but it seems validation
layers finally got support to detect it.
2025-11-26 15:16:39 +01:00
Lynne 58d26c2055 Changelog: add ProRes Vulkan hwaccel to the list
Forgotten when it got merged.
2025-11-26 15:16:34 +01:00
Niklas Haas 38a5fcc02c fftools/ffmpeg_filter: close all no-longer needed inputs
Currently, the thread loop of ffmpeg_filter essentially works like this:

while (1) {
    frame, idx = get_from_decoder();
    err = send_to_filter_graph(frame);
    if (err) { // i.e. EOF
        close_input(idx);
        continue;
    }

    while (filtered_frame = get_filtered_frame())
        send_to_encoder(filtered_frame);
}

The exact details are not 100% correct since the actual control flow is a bit
more complicated as a result of the scheduler, but this is the general flow.

Notably, this leaves the possibility of leaving a no-longer-needed input
permanently open if the filter graph starts producing infinite frames (during
the second loop) *after* it finishes reading from an input, e.g. in a filter
graph like -af atrim,apad.

This patch avoids this issue by always querying the status of all filter graph
inputs and explicitly closing any that were closed downstream; after each round
of reading output frames. As a result, information about the filtergraph being
closed can now propagate back upstream, even if the filter is no longer
requesting any input frames (i.e. input_idx == fg->nb_inputs).

Fixes: https://trac.ffmpeg.org/ticket/11061
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20457#issuecomment-6208
2025-11-26 13:15:16 +00:00
Niklas Haas 623669a02c avfilter/buffersrc: add av_buffersrc_get_status()
There is currently no way for API users to know that a buffersrc is no longer
accepting input, except by trying to feed it a frame and seeing what happens.

Of course, this is not possible if the user does not *have* a frame to feed,
but may still wish to know if the filter is still accepting input or not.

Since passing `frame == NULL` to `av_buffersrc_add_frame()` is already treated
as closing the input, we are left with no choice but to introduce a new
function for this.

We don't explicitly return the result of `ff_outlink_get_status()` to avoid
leaking internal status codes, and instead translate them all to AVERROR(EOF).
2025-11-26 13:15:16 +00:00
Araz Iusubov 92f2f9ea5c avcodec/d3d12va_encode: D3D12 AV1 encoding support
Implement AV1 hardware encoding
using Direct3D 12 Video API (D3D12VA).
2025-11-26 09:58:44 +00:00
Andreas Rheinhardt 81362b319e avcodec/x86/me_cmp: Avoid call on UNIX64
The internal functions for calculating the hadamard difference
of two 8x8 blocks have no epilogue on UNIX64, so one can avoid
the call altogether by placing the 8x8 function so that it directly
falls into the internal function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-26 00:01:09 +00:00
Andreas Rheinhardt 23720df371 avcodec/me_cmp: Remove MMXEXT hadamard diff functions
The SSE2 and SSSE3 functions are now available everywhere,
making the MMXEXT functions irrelevant.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-26 00:01:09 +00:00
Andreas Rheinhardt 6588bf3686 avcodec/x86/me_cmp: Avoid manual stack handling
Use x86inc's stack alignment feature instead of allocating the stack
manually*; this means that this code now also automatically supports
unaligned stacks, so that the SSE2 and SSSE3 functions will now be
available everywhere.

*: The code for this was also buggy: It resulted in the stack pointer
to be 4 mod 8 for x64 for the mmxext version before it was disabled
in 542765ce3e, because it hardcode 4
instead of using gprsize.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-26 00:01:09 +00:00
Niklas Haas f3346ca6f7 avfilter/x86/f_ebur128: only use filter_channels_avx for >= 2 channels
The approach of this ASM routine is to process two channels at a time using
AVX instructions. Obviously, there is no point in doing this if there is only
a single channel; in which case the scalar loop would be better.

Fixes a performance regression when filtering mono audio on certain CPUs,
notably e.g. the Intel N100.
2025-11-25 22:13:57 +00:00
Kacper Michajłow a75b15a4ab avfilter/vf_drawvg: round color values to avoid differences on some platforms
This ensures consistent color conversion between double and u8 and
guarantees that values remain consistent across different platforms,
especially when x87 math is used.

Note that libcairo also performs rounding internally when converting
doubles to integers, see _cairo_color_double_to_short().

Fixes: fate-filter-drawvg-interpreter
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-25 22:32:50 +01:00
averne 1d84ab331c vulkan/prores: Adopt the same IDCT routine as the prores-raw hwaccel
The added rounding at the final output conforms
to the SMPTE document and reduces the deviation
against the software decoder.
2025-11-25 17:54:56 +00:00
Gyan Doshi 2b221fdb4a avfilter/zscale: add support for resize filter spline64
Fixes #20928
2025-11-25 12:42:41 +05:30
Jack Lau 0486ad61ce configure: replace openssl header check with 1.1.1 API
Fix #20571

Avoid build errors with openssl forks (like libressl)
that lack some APIs.

This patch replace header check for OPENSSL_init_ssl
(was added in 1.1.0) with the OpenSSL 1.1.1 new API
DTLS_get_data_mtu.

Signed-off-by: Jack Lau <jacklau1222gm@gmail.com>
2025-11-24 21:29:45 +00:00
Georgii Zagoruiko f790de2a87 aarch64/vvc: Optimisations of put_luma_h() functions for 10/12-bit
RPi4 (auto-vectorisation is turned on)
put_luma_h_10_4x4_c:                                   282.8 ( 1.00x)
put_luma_h_10_8x8_c:                                  1069.5 ( 1.00x)
put_luma_h_10_8x8_neon:                                207.5 ( 5.15x)
put_luma_h_10_16x16_c:                                1999.6 ( 1.00x)
put_luma_h_10_16x16_neon:                              777.5 ( 2.57x)
put_luma_h_10_32x32_c:                                6612.9 ( 1.00x)
put_luma_h_10_32x32_neon:                             3201.6 ( 2.07x)
put_luma_h_10_64x64_c:                               25059.0 ( 1.00x)
put_luma_h_10_64x64_neon:                            13623.5 ( 1.84x)
put_luma_h_10_128x128_c:                             91310.1 ( 1.00x)
put_luma_h_10_128x128_neon:                          50358.3 ( 1.81x)
put_luma_h_12_4x4_c:                                   282.1 ( 1.00x)
put_luma_h_12_8x8_c:                                  1068.4 ( 1.00x)
put_luma_h_12_8x8_neon:                                207.7 ( 5.14x)
put_luma_h_12_16x16_c:                                1998.0 ( 1.00x)
put_luma_h_12_16x16_neon:                              777.5 ( 2.57x)
put_luma_h_12_32x32_c:                                6612.0 ( 1.00x)
put_luma_h_12_32x32_neon:                             3201.6 ( 2.07x)
put_luma_h_12_64x64_c:                               25036.8 ( 1.00x)
put_luma_h_12_64x64_neon:                            13595.1 ( 1.84x)
put_luma_h_12_128x128_c:                             91305.8 ( 1.00x)
put_luma_h_12_128x128_neon:                          50359.7 ( 1.81x)

Apple M2 Air (auto-vectorisation is turned on)
put_luma_h_10_4x4_c:                                     0.3 ( 1.00x)
put_luma_h_10_8x8_c:                                     1.0 ( 1.00x)
put_luma_h_10_8x8_neon:                                  0.4 ( 2.59x)
put_luma_h_10_16x16_c:                                   2.9 ( 1.00x)
put_luma_h_10_16x16_neon:                                1.4 ( 2.01x)
put_luma_h_10_32x32_c:                                   9.4 ( 1.00x)
put_luma_h_10_32x32_neon:                                5.8 ( 1.62x)
put_luma_h_10_64x64_c:                                  35.6 ( 1.00x)
put_luma_h_10_64x64_neon:                               23.6 ( 1.51x)
put_luma_h_10_128x128_c:                               131.1 ( 1.00x)
put_luma_h_10_128x128_neon:                             92.6 ( 1.42x)
put_luma_h_12_4x4_c:                                     0.3 ( 1.00x)
put_luma_h_12_8x8_c:                                     1.0 ( 1.00x)
put_luma_h_12_8x8_neon:                                  0.4 ( 2.58x)
put_luma_h_12_16x16_c:                                   2.9 ( 1.00x)
put_luma_h_12_16x16_neon:                                1.4 ( 2.00x)
put_luma_h_12_32x32_c:                                   9.4 ( 1.00x)
put_luma_h_12_32x32_neon:                                5.8 ( 1.61x)
put_luma_h_12_64x64_c:                                  35.3 ( 1.00x)
put_luma_h_12_64x64_neon:                               23.3 ( 1.52x)
put_luma_h_12_128x128_c:                               131.2 ( 1.00x)
put_luma_h_12_128x128_neon:                             92.4 ( 1.42x)
2025-11-24 21:22:55 +00:00
Martin Storsjö 8b71eeb72e tools: Make indent_arm_assembly.pl able to reformat a file in place
This allows using the tool for one-off reindentations without needing
the check_arm_indent.sh script (e.g. for use outside of ffmpeg),
without having to pipe the file through stdin/stdout.
2025-11-24 23:02:05 +02:00
Dmitrii Ovchinnikov 140b4f28c3 avutil/hwcontext_amf: move AVMutex to internal context 2025-11-24 20:06:24 +00:00
Ayose efd6e85abb fftools/tf_mermaid: close subgraph header when there are no inputs.
Ensure that the fragment to close the header (`</div>\"]`) is written when the
function `mermaid_print_section_header` is called only once, which happens when
the filtergraph has no inputs.
2025-11-24 20:01:40 +00:00
Ayose 5717c5c1e1 fftools/tf_mermaid: logic to complete subgraphs in a reusable function.
`subgraph` blocks can be closed in different places. The logic to complete the
header is moved to a function, so it can be reused later.
2025-11-24 20:01:40 +00:00
Andreas Rheinhardt 04a9e2a809 avutil/error: Avoid relocations and unused information
Use a string table instead to avoid relocations and don't add
the tag string to libavutil/error.c: It is only used
during the test program, so move it there.

Reviewed-by: Rémi Denis-Courmont <remi@remlab.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-24 16:48:31 +01:00
Andreas Rheinhardt 0eb423866f avcodec/j2kenc: Remove dead, disabled debug code
Seems to have never worked, even when this was added in
83654c7b1b.

Reviewed-by: Rémi Denis-Courmont <remi@remlab.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-24 16:48:31 +01:00
Andreas Rheinhardt 2a90e7d725 av{codec,util}/tests: Remove pointless undefs
Before commit e96d90eed6 lavu/internal.h
contained redefined various discouraged/forbidden functions to induce
compilation failures upon use, like e.g.
 #define malloc please_use_av_malloc
In order to use these functions, some files had to undefine these
macros. This commit removes the remaining pointless undefs.

Reviewed-by: Rémi Denis-Courmont <remi@remlab.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-24 16:48:31 +01:00
James Almer ee623a43e3 avformat: don't return EIO on demuxer errors
Demuxers should not generate this error code when they encounter truncated
or otherwise invalid files. It's a code the underlying protocol should generate
when there are legitimate reading errors.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-24 12:07:15 -03:00
Zhao Zhili c732564d2e avutil/hwcontext_vaapi: fix use fourcc not supported by devices
1. A AVPixelFormat can map to multiple VA_FOURCCs, while
vaapi_format_from_pix_fmt() only returns the first item matched
before this patch.
2. vaapi_frames_init() use vaapi_format_from_pix_fmt() to get the
first item. Fourcc in this item may not be supported by the device.

This patch makes vaapi_format_from_pix_fmt return all matched items
iteratively, then use strict check in vaapi_frames_init to get the
right fourcc.
2025-11-24 08:51:17 +00:00
Frank Plowman 76827a6f3b lavc/hevc: Fix usage of slice segment in invalid state
Previously, we set s->slice_initialized to 0 to prevent other slice
segments from depending on this slice segment only if hls_slice_header
failed.  If decode_slice fails for some other reason, however, before
decode_slice_data is called to bring the context back into a consistent
state, then slices could depend on this slice segment while it is in an
invalid state.  This can cause segmentation faults and other sorts of
nastiness.  Patch fixes this by always setting s->slice_initialized to 0
while the state is inconsistent.

Resolves #11652.
2025-11-24 05:08:58 +00:00
Neal Gompa 069d465895 configure: Lower libdvdnav and libdvdread minimum versions for EL9
Red Hat Enterprise Linux 9 is one patch version lower than what
FFmpeg currently requests. The slightly older versions still result
in a working build of FFmpeg with DVD support, so allow those
versions to be consumed to build FFmpeg.

Signed-off-by: Neal Gompa <neal@gompa.dev>
2025-11-24 03:08:20 +00:00
James Almer 6f4a3be9dc avformat/movenc: add support for writing srat box
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-24 02:59:02 +00:00
Kacper Michajłow 148cf61585 fate: add missing options in config template
Fixes: f01c771577
Fixes: 523d688c2b
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-24 02:47:08 +00:00
Kacper Michajłow 6cb002610b fate: add skip_clean option
This is useful if one wants to inspect build artifacts after running
fate.sh script.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-24 02:47:08 +00:00
James Almer fd4e86be9e avformat/mov: reindent after the previous change
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-23 17:01:39 -03:00
Dmitrii Okunev eccbbd528e fftools: Fix MediaCodec on Android15+
On Android15+ MediaCodec HAL backend was switched from HIDL to AIDL.
As a result, MediaCodec operations started to hang, see:

    https://trac.ffmpeg.org/ticket/11363
    https://github.com/termux/termux-packages/issues/21264
    https://issuetracker.google.com/issues/382831999

To fix that it is necessary to initialize binder thread pool.

Signed-off-by: Dmitrii Okunev <xaionaro@dx.center>
2025-11-23 12:53:43 +00:00
Zhao Zhili d3e80837e7 avformat/mov: fix incorrect sample rate by parse srat box 2025-11-23 12:13:07 +00:00
James Almer c0044ec9c4 avformat/mov: don't parse reserved ISOBMFF fields as if they were QT
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-23 11:51:26 +00:00
James Almer 9e09be513d configure: move libtls out of non-free libraries list
LibreSSL uses a permisive license, and the OpenSSL code has the same license as
OpenSSL < 3.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-22 23:19:01 -03:00
Romain Beauxis c75ada5040 ffplay: print new metadata 2025-11-22 18:38:40 +00:00
Anders Rein 32f73138f5 fate/filter-audio: Added test for aselect 2025-11-22 18:36:41 +00:00
Anders Rein 7411e902da avfilter/f_select: Added activate for aselect
During migration to the activation filter API the aselect filter was
accidentally turned into a no-op filter.
2025-11-22 18:36:41 +00:00
Martin Storsjö 3cc1dc3358 swscale: Remove the unused ff_sws_pixel_type_to_uint
This function uses ff_sws_pixel_type_size to switch on the
size of the provided type. However, ff_sws_pixel_type_size returns
a size in bytes (from sizeof()), not a size in bits. Therefore,
this would previously never return the right thing but always
hit the av_unreachable() below.

As the function is entirely unused, just remove it.

This fixes compilation with MSVC 2026 18.0 when targeting ARM64,
which previously hit an internal compiler error [1].

[1] https://developercommunity.visualstudio.com/t/Internal-Compiler-Error-targeting-ARM64-/10962922
2025-11-21 21:07:34 +00:00
Andreas Rheinhardt 775b102182 avformat/oggenc: Schedule pagesize option for removal
Deprecated in 59220d559b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-21 18:41:15 +00:00
James Almer 191f7e4869 tests/checkasm/sw_ops: fix signed integer related UB when shifting values
Fixes:
src/tests/checkasm/sw_ops.c:441:34: runtime error: shift exponent 32 is too large for 32-bit type 'int'
src/tests/checkasm/sw_ops.c:591:37: runtime error: shift exponent 32 is too large for 32-bit type 'int'

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-21 18:40:58 +00:00
James Almer 06b3a20761 swscale/ops_tmpl_int: fix signed integer related UB when shifting values
Fixes:
src/libswscale/ops_tmpl_int.c:292:23: runtime error: left shift of 188 by 24 places cannot be represented in type 'int'
src/libswscale/ops_tmpl_int.c:290:23: runtime error: left shift of 158 by 24 places cannot be represented in type 'int'
src/libswscale/ops_tmpl_int.c:293:23: runtime error: left shift of 136 by 24 places cannot be represented in type 'int'
src/libswscale/ops_tmpl_int.c:291:23: runtime error: left shift of 160 by 24 places cannot be represented in type 'int'

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-21 18:40:58 +00:00
James Almer 30d66be21a swscale/x86/ops: fix signed integer related UB in normalize_clear()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-21 18:40:58 +00:00
Andreas Rheinhardt 43abd1ced9 avcodec/mpegvideo: Move last_dc to {H263Dec,Mpeg12Slice,MPVEnc}Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-21 11:55:09 +01:00
Andreas Rheinhardt b497de698c avcodec/Makefile: Remove mpegvideo_parser->mpeg12.o dependency
Forgotten in 3ceffe7839.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-21 11:55:09 +01:00
Andreas Rheinhardt 2586763376 avcodec/mpeg12: Inline ff_mpeg1_clean_buffers() into its callers
This function is extremely small, so inlining it is appropriate (and
actually beneficial size-wise here). It furthermore allows to remove
the mpeg12codecs.h header and the mpeg12-encoders->mpeg12.o dependency.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-21 11:55:09 +01:00
Kacper Michajłow fc3893f5e7 Makefile: remove config_components.asm on distclean
Forgotten in c607aae2b9.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-20 21:20:24 +00:00
James Zern 32cefd3789 avcodec/libaomenc: Fix use of uninitialized value
codecctl_intp() is used to populate values via aom_codec_control(), not
set them. This change moves the output of the return pointer's value
after the aom_codec_control() to avoid a memory sanitizer warning (use
of uninitialized value).

Signed-off-by: James Zern <jzern@google.com>
2025-11-19 12:43:12 -08:00
Zhao Zhili 0ae8df5f2c avutil/common: cast GET_BYTE/GET_16BIT returned value
In case of GET_BYTE/GET_16BIT return signed value.
2025-11-19 17:46:06 +00:00
Zhao Zhili a5cc0e5c9e avfilter/vf_drawtext: fix call GET_UTF8 with invalid argument
For GET_UTF8(val, GET_BYTE, ERROR), val has type of uint32_t,
GET_BYTE must return an unsigned integer, otherwise signed
extension happened due to val= (GET_BYTE), and GET_UTF8 went to
the error path.

This bug incidentally cancelled the bug where hb_buffer_add_utf8
was being called with incorrect argument, allowing drawtext to
function correctly on x86 and macOS ARM, which defined char as
signed. However, on Linux and Android ARM environments, because
char is unsigned by default, GET_UTF8 now returns the correct
return, which unexpectedly revealed issue #20906.
2025-11-19 17:46:06 +00:00
Zhao Zhili 9bc3c572ea avfilter/vf_drawtext: fix incorrect text length
From the doc of HarfBuzz, what hb_buffer_add_utf8 needs is the
number of bytes, not Unicode character:
hb_buffer_add_utf8(buf, text, strlen(text), 0, strlen(text));

Fix issue #20906.
2025-11-19 17:46:06 +00:00
Zhao Zhili 551e964e8a avcodec/videotoolboxenc: remove redundant "Error: " in error message 2025-11-20 00:56:12 +08:00
Zhao Zhili d4031984db avcodec/videotoolboxenc: reorder and cleanup headers 2025-11-20 00:56:12 +08:00
Zhao Zhili 7049df14c8 avcodec/videotoolboxenc: fix crash with negative linesize 2025-11-20 00:56:05 +08:00
Zhao Zhili 0da15c93c8 avcodec/videotoolboxenc: improve Lock/Unlock BaseAddress error handling
1. Fix continue after CVPixelBufferLockBaseAddress.
2. Remove redundant "Error: " in error message.
2025-11-20 00:55:32 +08:00
GyanD f283750ba8 doc/encoders: minor mediafoundation encoders updates 2025-11-19 04:48:11 +00:00
Harshitha 4e556b0c0c doc/encoders: Document MediaFoundation encoders 2025-11-19 04:48:11 +00:00
Hendi b399896046 avformat/dashdec: Fix urls with special characters in manifest
This was especially a problem with ampersands, which occur
frequently as part of query parameters.
2025-11-18 22:10:34 +00:00
Stefan Breunig 4c4ab2ec6f fate/filter-video: add frei0r test where input is realigned
An installation of frei0r-plugins is required to run the tests,
which is usually seperate from the build headers. Some systems
have it packaged (e.g. apt install frei0r-plugins). An upstream
release extracted to FREI0R_PATH also works.

The distort0r filter requires dimensions to be divisible by 8.
2025-11-18 21:26:36 +00:00
Stefan Breunig f8bfc20281 avfilter/vf_frei0r: fix time when input is realigned
av_frame_copy doesn't copy the input's PTS property, which resulted
in the frei0r filter always receiving the same static time.

Example that has a static distortion without patch:

ffmpeg -filter_complex "testsrc2=s=328x240:d=5,frei0r=distort0r" out.mp4
2025-11-18 21:26:36 +00:00
Andreas Rheinhardt 5bf57a925c avutil/x86/asm: Remove wrong comment, rename FF_REG_sp
Before FFmpeg commit 531b0a316b,
FFmpeg used REG_SP as macro for the stack pointer, yet this
clashed with a REG_SP define in Solaris system headers, so it
was changed to REG_sp and a comment was added for this.

Libav fixed it by adding an FF_ prefix to the macros in
1e9c5bf4c1. FFmpeg switched
to using these prefixes in 9eb3da2f99,
using FF_REG_sp instead of Libav's FF_REG_SP. In said commit
the comment was changed to claim that Solaris system headers
define FF_REG_SP, but this is (most likely) wrong.

This commit removes the wrong comment and renames the (actually unused)
macro to FF_REG_SP to make it consistent with FF_REG_BP.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:13 +01:00
Andreas Rheinhardt 99209c2876 avcodec/x86/mpegvideoenc_template: Reduce number of registers used
qmat and bias always have a constant offset, so one can use one register
to address both of them. This allows to remove the check for HAVE_6REGS
(untested on a system where HAVE_6REGS is false).
Also avoid FF_REG_a while at it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:13 +01:00
Andreas Rheinhardt b890cd0f73 avcodec/x86/mpegvideoenc_template: Avoid touching nonvolatile register
xmm7 is nonvolatile on x64 Windows.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:13 +01:00
Andreas Rheinhardt aeb138679a avcodec/x86/mpegvideoencdsp: Port add_8x8basis_ssse3() to ASM
Both GCC and Clang completely unroll the unlikely loop at -O3,
leading to codesize bloat; their code is also suboptimal, as they
don't make use of pmulhrsw (even with -mssse3). This commit
therefore ports the whole function to external assembly. The new
function occupies 176B here vs 1406B for GCC.

Benchmarks for a testcase with huge qscale (notice that the C version
is unrolled just like the unlikely loop in the SSSE3 version):
add_8x8basis_c:                                         43.4 ( 1.00x)
add_8x8basis_ssse3 (old):                               43.6 ( 1.00x)
add_8x8basis_ssse3 (new):                               11.9 ( 3.63x)

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt 0d3a88e55f tests/checkasm/mpegvideoencdsp: Test denoise_dct
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt 1c00e09427 avcodec/mpegvideo_enc: Port denoise_dct to MpegvideoEncDSPContext
It is very simple to remove the MPVEncContext from it.
Notice that this also fixes a bug in x86/mpegvideoenc.c: It only
used the SSE2 version of denoise_dct when dct_algo was auto or mmx
(and it was therefore unused during FATE).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt d633fa0433 avcodec/x86/mpegvideoenc: Port denoise_dct_sse2 to external assembly
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt 2cfef7031c avcodec/x86/mpegvideoenc: Reduce number of registers used
Avoids a push+pop on x64 Windows.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Andreas Rheinhardt 503afa40f7 avcodec/x86/mpegvideoenc: Remove check for MMX
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-18 20:41:12 +01:00
Marvin Scholz 00ef656a85 .forgejo/CODEOWNERS: add myself to VideoToolbox and Icecast 2025-11-18 15:17:05 +01:00
Carl Hetherington via ffmpeg-devel 1eb2cbd865 avfilter/f_ebur128: Fix incorrect ebur128 peak calculation.
Since 3b26b782ee it would only look at the
first channel.

Signed-off-by: Carl Hetherington <cth@carlh.net>
Reviewed-by: Niklas Haas <ffmpeg@haasn.xyz>
2025-11-18 08:40:08 +01:00
Gyan Doshi f60db2e566 doc/fate: document setting of session-wide env variables 2025-11-18 04:19:06 +00:00
Kacper Michajłow 9b2162275b configure: filter out -guard:signret from armasm flags
While cl.exe supports -guard:signret, armasm64 complains about
unknown flag. Note that -guard:ehcont is accepted by armasm64.

Fixes:
error A2029: unknown command-line argument or argument value -guard:signret

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-17 20:41:34 +00:00
Kacper Michajłow 523d688c2b fate: add more configure flags to fate config
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-17 20:25:24 +00:00
Andreas Rheinhardt ddf443f1e9 avfilter/vf_fsppdsp: Fix left shifts of negative numbers
They are undefined behavior and UBSan warns about them
(in the checkasm test). Put the shifts in the constants
instead. This even gives a tiny speedup here:

Old benchmarks:
column_fidct_c:                                       3369.9 ( 1.00x)
column_fidct_sse2:                                     829.1 ( 4.06x)
New benchmarks:
column_fidct_c:                                       3304.2 ( 1.00x)
column_fidct_sse2:                                     827.9 ( 3.99x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt f8bcea4946 avfilter/vf_fsppdsp: Remove pointless cast
Also don't cast const away and use a smaller scope.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt 0c556a6b09 avfilter/vf_fspp: Pre-reorder threshold table
Avoids reordering at runtime.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt 778ff97efa avfilter/vf_fspp: Make output endian-independent
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt f442145729 avfilter/vf_fspp: Avoid casts, effective-type violations
Maybe uint64_t has been used as a poor man's alignment specifier?
Anyway, reading an uint64_t via an lvalue of type int16_t (as happens
in the C versions of the dsp functions) is undefined behavior.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt c0648b2004 avfilter/x86/vf_spp: Fix comment
Forgotten in dcb28ed860.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt 06b0dae51b avfilter/vf_fsppdsp: Constify
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt cc97f1e276 avfilter/vf_fspp: Fix effective type violation
Also don't use unnecessarily large alignment; it avoids having to align
the stack.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt 3cd452cbf1 avfilter/x86/vf_fspp: Avoid stack on x64
Possible due to the amount of registers.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:12 +01:00
Andreas Rheinhardt ddd74276f8 avfilter/x86/vf_fspp: Port ff_column_fidct_mmx() to SSE2
It gains a lot because it has to operate on eight words;
it also saves 608B of .text here.

Old benchmarks:
column_fidct_c:                                       3365.7 ( 1.00x)
column_fidct_mmx:                                     1784.6 ( 1.89x)

New benchmarks:
column_fidct_c:                                       3361.5 ( 1.00x)
column_fidct_sse2:                                     801.1 ( 4.20x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt 68b11cde82 tests/checkasm/vf_fspp: Add test for column_fidct
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt 63493bf0e0 avfilter/x86/vf_fspp: Put shifts into constants
This avoids some shift instructions and also gives us more headroom
in the registers. In fact, I have proven to myself that everything
that is supposed to fit into 16bits now actually does so.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt 66af18d06a avfilter/x86/vf_fspp: Make ff_column_fidct_mmx() bitexact
It currently is not, because the shortcut mode uses different rounding
than the C code (as well as the non-shortcut code).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 12:18:11 +01:00
Andreas Rheinhardt 1049a5fba8 avfilter/vf_fsppdsp: Reduce discrepancies between C code and x86 asm
The x86 assembly uses the following pattern to zero all
the values with abs<threshold:
    x -= threshold;
    x satu+= threshold (unsigned saturated addition)
    x += threshold
    x satu-= threshold (unsigned saturated subtraction)
The reference C code meanwhile zeroed everything
with abs <= threshold. This commit makes the C code behave
like the x86 assembly to reduce discrepancies between the two.

An alternative would be to require SSSE3, so that
one can use pabsw, pcmpgtw for abs>threshold, followed by
a pand with the original data. Or one could modify the thresholds
to make both equal.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt d19050a1ae avfilter/vf_fsppdsp: Use restrict
It is possible because the requirements are fulfilled;
it is also beneficial performance and code-size wise.
For GCC 14 (with -O3), this reduced codesize by 26750B
here; for Clang 20, it was 432B.

Old benchmarks:
mul_thrmat_c:                                            4.3 ( 1.00x)
mul_thrmat_sse2:                                         4.3 ( 1.00x)
store_slice_c:                                        2810.8 ( 1.00x)
store_slice_sse2:                                      542.5 ( 5.18x)
store_slice2_c:                                       3817.0 ( 1.00x)
store_slice2_sse2:                                     410.4 ( 9.30x)

New benchmarks:
mul_thrmat_c:                                            4.3 ( 1.00x)
mul_thrmat_sse2:                                         4.3 ( 1.00x)
store_slice_c:                                        1510.1 ( 1.00x)
store_slice_sse2:                                      545.2 ( 2.77x)
store_slice2_c:                                       1763.5 ( 1.00x)
store_slice2_sse2:                                     408.3 ( 4.32x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt ff85a20b7d avfilter/x86/vf_fspp: Port store_slice to SSE2
Old benchmarks:
store_slice_c:                                        2798.3 ( 1.00x)
store_slice_mmx:                                       950.2 ( 2.94x)
store_slice2_c:                                       3811.7 ( 1.00x)
store_slice2_mmx:                                      682.3 ( 5.59x)

New benchmarks:
store_slice_c:                                        2797.2 ( 1.00x)
store_slice_sse2:                                      543.5 ( 5.15x)
store_slice2_c:                                       3817.0 ( 1.00x)
store_slice2_sse2:                                     408.2 ( 9.35x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 570f8fc6c9 tests/checkasm/vf_fspp: Test store_slice
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt e042f17e99 avfilter/vf_fsppdsp: Use standard clamping
This is obviously what is intended and what the MMX code does;
yet I cannot rule out that it changes the output for some inputs:
I have observed individual src values which would lead to temp
values just above 512 if they came in pairs (i.e. if both inputs
were simultaneously huge).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 52ba2ac7bd avfilter/x86/vf_fspp: Port mul_thrmat to SSE2
This fixes an ABI violation, as mul_thrmat did not issue emms.
It seems that this ABI violation could reach the user, namely
if ff_get_video_buffer() fails. Notice that ff_get_video_buffer()
itself could fail because of this, namely if the allocator uses
floating point registers.

On x64 (where GCC already used SSE2 in the C version)
mul_thrmat_c:                                            4.4 ( 1.00x)
mul_thrmat_mmx:                                          8.6 ( 0.52x)
mul_thrmat_sse2:                                         4.4 ( 1.00x)

On 32bit (where SSE2 is not known to be available):
mul_thrmat_c:                                           56.0 ( 1.00x)
mul_thrmat_sse2:                                         6.0 ( 9.40x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 70eb8a76a9 tests/checkasm: Add vf_fspp mul_thrmat test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 9f4d5d818d avfilter/x86/vf_fspp: Don't duplicate dither table
Reuse the one from vf_fsppdsp.c; also don't overalign said table too
much.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 1699de0955 avfilter/vf_fsppdsp: Use enum for constants
It means that the compiler does not have to optimize the static const
object away.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 9b34088c4d avfilter/vf_fspp: Add DSPCtx, move DSP functions to file of their own
This is in preparation for adding checkasm tests; without it,
checkasm would pull all of libavfilter in.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 11:28:04 +01:00
Andreas Rheinhardt 57d6898730 configure: Only test for SSE2 intrinsics on x86
Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-17 10:36:54 +01:00
Artem Smorodin e94439e49b avformat/tee: fix the default onfail setting of the tee salves
I found that the default value is not set for onfail option. I see that there is an attempt to set this value by default inside parse_slave_failure_policy_option. But look at the CONSUME_OPTION macro. If av_dict_get cannot find this option, then this function is not even called.
2025-11-17 00:01:42 +00:00
Michael Niedermayer 88b676105d avcodec/prores_raw: Check bits in get_value()
The code loads 32bit so we can at maximum use 32bit

the return type is also changed to uint16_t (was requested in review),

no path is known where a return value above 32767 is produced, but that was not exhaustively checked

Fixes: runtime error: shift exponent -9 is negative
Fixes: 439483046/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PRORES_RAW_DEC_fuzzer-6649466540326912

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 21:43:17 +01:00
Michael Niedermayer 9ccc33d84d avcodec/prores_raw: Prettify ff_prores_raw_*_cb
the values contain 3 4 bit values, thus using hex is more natural
and shows more information

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 21:34:38 +01:00
Michael Niedermayer ad956ff076 avfilter/vf_drawtext: Account for bbox text seperator
Fixes: out of array access
no test case

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-16 20:32:11 +01:00
Andreas Rheinhardt 643e2e10f9 avutil/cpu: Deprecate AV_CPU_FLAG_FORCE
This flag does nothing since the deactivation of
the dsp_mask field of AVCodecContext in
commits 9ae6ba2883 and
9ae6ba2883 (it has
been superseded with better ways to override the CPU flags).
So deprecate it.

Reviewed-by: Lynne <dev@lynne.ee>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-16 11:24:00 +01:00
Zhao Zhili 925282fafc doc/filters: add section for VideoToolbox filter
Move scale_vt and transpose_vt to this section.
2025-11-16 10:22:19 +00:00
Martin Storsjö e096a592cb doc: Fix building with makeinfo 4.8
This fixes building after commit
1ce88d29d0.

That commit caused the following errors:

    src/doc/fate.texi:234: @anchor expected braces.
    src/doc/fate.texi:245: @item found outside of an insertion block.
    src/doc/fate.texi:249: @item found outside of an insertion block.
    src/doc/fate.texi:261: @item found outside of an insertion block.
    src/doc/fate.texi:265: @item found outside of an insertion block.
    src/doc/fate.texi:268: @item found outside of an insertion block.
    src/doc/fate.texi:274: @item found outside of an insertion block.
    src/doc/fate.texi:277: @item found outside of an insertion block.
    src/doc/fate.texi:281: @item found outside of an insertion block.
    src/doc/fate.texi:287: Unmatched `@end'.
    ./src/doc/fate.texi:65: Cross reference to nonexistent node `makefile variables' (perhaps incorrect sectioning?).
2025-11-15 19:29:08 +02:00
Gyan Doshi 1ce88d29d0 doc/fate: improve section on running FATE
With thanks to Adam Koszek.
2025-11-15 08:28:51 +00:00
Cameron Gutman d3dea2b142 avcodec/v4l2_buffers: map additional V4L2 TRCs
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-11-15 00:39:43 +00:00
Andreas Rheinhardt e293091d98 avcodec/prores_raw: Reuse permutation
The ProresDSPContext already contains the idct_permutation.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-14 14:27:53 +01:00
Michael Niedermayer 41a9c6ec5f avcodec/mediacodecdec_common: Check that the input to mediacodec_wrap_sw_audio_buffer() contains channel * sample_size
Fixes: out of array access
no testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-14 12:16:48 +00:00
James Almer b478037423 avdevice/lavfi: stop setting deprecated buffersink options
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-13 21:02:10 -03:00
Dmitrii Ovchinnikov 62184be548 avutil/hwcontext_amf: Simplified blocking before frame submission
Instead of blocking the entire context, which can cause issues in more
complex pipelines, now only frame sending is blocked via AVMutex
2025-11-13 15:49:42 +01:00
James Almer 6cdd2cbe32 avformat/riffenc: add support for HEAACWAVEFORMAT
This is an extension to WAVEFORMATEX used for some AAC streams, defined in the
Windows SDK.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-12 21:30:02 -03:00
James Almer 362d673ad6 avformat/riffdec: add support for HEAACWAVEFORMAT
This is an extension to WAVEFORMATEX used for some AAC streams, defined in the
Windows SDK.

Fixes issue #20887.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-12 21:29:49 -03:00
Sean McGovern 35464ad9eb libavcodec/ppc: remove broken AltiVec acceleration for lossless audio
It fails sporadically on big- or little-endian POWER/PPC, as well as
triggers the undefined-behaviour & address scanners in GCC.
2025-11-12 14:40:14 -05:00
Niklas Haas 203c6a93d7 avutil/hwcontext_vulkan: actually limit number of queues
This option is parsed after it is used.
2025-11-12 15:25:07 +00:00
Andreas Rheinhardt 2452b81769 avcodec/h264idct_template: Deduplicate h264_{luma,chroma}_dc_dequant_idct
All the high bit depth functions of these types are identical.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-12 14:50:46 +01:00
Andreas Rheinhardt 1fafb13cd4 avcodec/bit_depth_template: Add PIXELSIZE
Sometimes functions for bit depth 9..16 are the same (because they
actually only depend on the underlying pixel type). The macros added
here allow to support this usecase.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-12 14:50:21 +01:00
Lynne f39884b3fd vulkan: fix driver warning for unrecognized structure
VkQueueFamilyQueryResultStatusPropertiesKHR was added with the
VK_KHR_video_queue extension, which NVK does not support yet.
Correctly classify it as part of the video extensions.
2025-11-12 10:36:48 +01:00
Lynne 418235e98a vulkan_prores: fix buffer leaks on error 2025-11-12 00:37:25 +01:00
Lynne d12bb4a2a5 vulkan_prores: fix pushconst updating
ff_vk_shader_update_push_const executes a command that
updates push data for the currently bound shader.
2025-11-12 00:37:25 +01:00
Lynne dd32bb8855 vulkan: allow arrays of buffers
Could be useful.
2025-11-12 00:37:25 +01:00
Lynne a0d0b5cf73 ffv1enc_vulkan: only use native image representation
This was done for an unknown reason, and for whatever reason,
non-rgb 8+ bit formats were broken by this.
2025-11-12 00:37:24 +01:00
Lynne 9860017495 vulkan/ffv1: use u32vec2 for slice offsets
Simplifies calculations slightly.
2025-11-12 00:37:24 +01:00
Lynne 6080db7d23 ffv1dec: call ff_get_format if width and height change 2025-11-12 00:37:24 +01:00
Lynne 18d7ded29e prores_raw: call ff_get_format if width and height change 2025-11-12 00:37:24 +01:00
Lynne e93e2a5be1 prores: call ff_get_format if width and height change
The issue is that hardware decoders may have some state they depend on,
which would get broken if the dimensions change.
2025-11-12 00:37:19 +01:00
Zhao Zhili cbc6134a4a avcodec/nvenc: fix -Wenum-conversion on colorspace/pri/trc
SDK 12.0 defined enum types for colorspace/pri/trc, while lower
versions use uint32_t.
2025-11-11 20:08:36 +00:00
Rémi Denis-Courmont 9b348aa60b riscv/cpu: add V subset feature detection
This adds support for detecting Zve32x, Zve32f, Zve64x and Zve64d on
a system that does not support (or declare) the full V feature set.

Because the code assumes that vector detected at runtime are at least
128-bit long, we have to manually check that too (in theory, vectors
can be 32-bit or 64-bit, though that makes little sense in 2025).
2025-11-11 18:40:47 +00:00
Lynne be99d2c0b2 vf_colorspace: allow for extended primaries and colorspace 2025-11-10 21:50:58 +00:00
Lynne d916803290 swscale: allow extended primaries 2025-11-10 21:50:58 +00:00
Martin Storsjö 032bdf8ebd Revert "Re-initialize stream on new metadata."
This reverts commit 7b18eafabd.

That commit added tests that don't work on Windows, and which
also fail in setups with cross/remote testing (with --target-exec
and --target-path).

See https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20876 for more
discussions about issues with that commit.
2025-11-10 14:03:43 +02:00
Niklas Haas 133a0bcb13 fftools/ffmpeg_sched: prevent demuxers from getting stuck
When the furthest-behind stream is being fed by a demuxer that is also
feeding packets to a choked filter graph, we need to unchoke that filter
graph to prevent the demuxer from getting stuck trying to write packets to
the choked filter graph.

This situation can also apply recursively - if the demuxer is also writing
to a filtergraph that is also reading from a choked demuxer, there is a
similar deadlock.

Solve all such deadlocks by just brute-force recursively unchoking all
nodes that can somehow prevent this demuxer from writing packets. This
should normally not result in any change in behavior, unless audio/video
streams are badly desynchronized, in which case it may result in extra
memory usage from the too-far-ahead stream buffering packets inside the
muxer. (But this is, of course, preferable to a deadlock)

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/20611
2025-11-10 09:55:40 +00:00
Zhao Zhili 071db4b81c tests/fate/hevc: add a mv-hevc sample using long term ref 2025-11-10 12:22:05 +08:00
Zhao Zhili 141f5c9071 avcodec/hevc: reset long_term_rps.nb_refs for IDR
For mv-hevc, the second layer of IDR frame can be a P slice.
long_term_rps wasn't been reset before the patch, which leading to
ff_hevc_frame_nb_refs return incorrect result.

This fix decoding failure for samples from Pico VR.
2025-11-10 12:22:05 +08:00
Zhao Zhili 6bdea3ae23 avcodec/hevc: remove an always true condition
long_rps is &sh->long_term_rps.
2025-11-10 12:22:05 +08:00
Zhao Zhili c4ce51ee62 avfilter/vf_libopencv: bump to opencv4 2025-11-10 04:12:50 +00:00
Michael Niedermayer 729d0379ab avcodec/rv60dec: Clear blk_info
Fixes: use of uninitialized memory
Fixes: 418335931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5103986067963904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-10 01:46:52 +00:00
Michael Niedermayer c199b3d48f avformat/whip: Fix rtp_ctx->streams access
Fixes: out of array access
No testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-10 00:24:44 +00:00
Romain Beauxis 7b18eafabd Re-initialize stream on new metadata. 2025-11-09 11:45:37 -06:00
Andreas Rheinhardt dd05022def avformat/mp3enc: Avoid av_unused
Possible now that -Wdeclaration-after-statement is no more.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-09 13:44:18 +01:00
Andreas Rheinhardt 08b74d5d5c swresample/swresample: Avoid av_unused
Possible now that -Wdeclaration-after-statement is no longer used.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-09 13:42:27 +01:00
Romain Beauxis f2b9b1923d Don't reset last{pts,dts} on new sequentialized ogg streams.
This fixes PTS/DTS discontinuity on sequentialized ogg streams.
2025-11-09 10:46:08 +00:00
Michael Niedermayer 59db32b433 avcodec/utvideodec: Set B for the width= 1 case in restore_median_planar_il()
Fixes: use of uninitialized memory
Fixes: 439878388/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_DEC_fuzzer-5635866203848704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-09 10:44:09 +00:00
Michael Niedermayer 08816b9376 avcodec/osq: Fix 32bit sample overflow
Fixes: signed integer overflow: 2147483565 + 128 cannot be represented in type 'int'
Fixes: 428055715/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-6358069900804096

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-09 02:42:17 +01:00
averne d00f41f213 vulkan/prores: forward quantization parameter to the IDCT shader
The qScale syntax element has a maximum value of 512, which would overflow the 16-bit store from the VLD shader in extreme cases.
This fixes that edge case by forwarding the element in a storage buffer, and applying the inverse quantization fully in the IDCT shader.
2025-11-08 22:31:21 +00:00
Tim Blechmann 28461f2c43 libavutil: fix memory leak of drmVersion
address sanitizer showed some leaks of drmVersion structs.
`vaapi_device_create` did not call drmFreeVersion in all possible code
paths.
2025-11-08 21:48:00 +00:00
Martin Storsjö 586898dc1f avformat: Make ff_make_codec_str output to an AVBPrint object 2025-11-08 21:19:31 +00:00
Martin Storsjö 900b77b1b7 hlsenc, dashenc: Share the routine for generating a codec string
The one in dashenc was added in
fe5e6e34c0, while the one in hlsenc
was added later in 0afa171f25. Both
have had various additions on top; merge both implementations
into one shared. (Notable additions in
060e74e2a9,
1cf2f040e3,
a2b1dd0ce3 and
797f0b27c175022d896e46db4ac2873e3e0a70af.)

For H264/avc1, use the implementation from hlsenc (which doesn't
use temporary allocations). For most other codecs, use the
only implementation from whichever had one.

The original dashenc implementation tried to be generic based
on RFC 6381, looking up codec tags in ff_codec_movvideo_tags
or ff_codec_movaudio_tags, and doing specific extra additions
for "mp4a" and "mp4v". In practice, only AV_CODEC_ID_AAC
and AV_CODEC_ID_MPEG4 ever mapped to these; simplify this to
a more straightforward codec id based handling, and merge
with the AAC profile based code from hlsenc.

There's a slight behaviour difference from the old one in
dashenc; if there's no code for a specific codec ID, we previously
just output what we matched from the mov tag tables, but now
we won't output anything. But most commonly used codecs in
DASH should be covered here.
2025-11-08 21:19:31 +00:00
Martin Storsjö ee22107c67 avformat/vpcc: Make input pointers const 2025-11-08 21:19:31 +00:00
Martin Storsjö d015382f4a avformat/vpcc: Generalize the AVFormatContext parameter to void*
This parameter is only used as a logging context; don't require
a full AVFormatContext here.
2025-11-08 21:19:31 +00:00
Stefan Breunig 549b45459e avfilter/vf_frei0r: fix time not being passed in seconds
The frei0r API expects the time in seconds, but was given it in
milliseconds. The bug might exist since 41f1d3a (~14 years ago),
but plugins depending on the time are unwatchable without this
patch. For example:

ffmpeg -filter_complex "testsrc2=d=5,frei0r=distort0r" out.mp4

Signed-off-by: Stefan Breunig <stefan-ffmpeg-devel@breunig.xyz>
2025-11-08 20:55:03 +00:00
Andreas Rheinhardt cb7b962a4a avutil/timecode: Fix -Wformat-truncation warning
Using unsigned for fps is more natural since the corresponding
AVTimecode field is unsigned. It also fixes a -Wformat-truncation
warning from GCC 16: in case fps were negative, hours, minutes
and seconds would be negative, leading to additional '-' characters
which are not accounted for in AV_TIMECODE_STR_SIZE.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 19:33:11 +01:00
Andreas Rheinhardt 32f32537b6 avcodec/dvdec,mjpegdec: Remove emms_c
It is no longer necessary now that the IDCTDSP is always ABI-compliant
(and free of MMX).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt ade54335b2 avcodec/x86/simple_idct: Port to SSE2
Before this commit, the (32-bit only) simple idct came in three
versions: A pure MMX IDCT and idct-put and idct-add versions
which use SSE2 at the put and add stage, but still use pure MMX
for the actual IDCT.

This commit ports said IDCT to SSE2; this was entirely trivial
for the IDCT1-5 and IDCT7 parts (where one can directly use
the full register width) and was easy for IDCT6 and IDCT8
(involving a few movhps and pshufds). Unfortunately, DC_COND_INIT
and Z_COND_INIT still use only the lower half of the registers.

This saved 4658B here; the benchmarking option of the dct test tool
showed a 15% speedup.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt 625f5c993c avcodec/tests/dct: Remove unnecessary emms_c
Unnecessary since the Xvid IDCT no longer uses MMX registers at all.
(Notice that the simple MMX IDCT issues emms and is therefore ABI
compliant.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt a26b99f793 avcodec/x86/xvididct: Remove remnants of MMX
The non-MMX code only uses the first six rounders.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt b03b09aeda avcodec/x86/xvididct: Don't use MMX registers in SSE2 function
It is higly surprising and would necessitate emms in order to be ABI
compliant; but it is better just not to use them in the first place.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt a7013f813c avcodec/tests/x86/dct: Test 32bit simple idct
The test has been removed in bfb28b5ce8
when MMX idctdsp functions overridden by SSE2 were removed;
ff_simple_idct_mmx() has been completely disabled in this patch
for x64 and so the test should have been disabled on x64 instead
of removing it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Andreas Rheinhardt 86f8adc58e avcodec/x86/idctdsp_init: Fix IDCT permutation for 32bit without SSE2
bfb28b5ce8 removed the MMX idct_put
and idct_add functions, because they were overridden by SSE2 versions
(which use SSE2 only for the put/add part, not the actual IDCT).
This meant that for MMX, the idct functions are not set in unison,
so that the permutation which is meant to apply to all three
is incorrect on 32bit systems if SSE2 is unavailable/disabled.

Fix this by setting the MMX version only if SSE2 is enabled.

(No one complained, so apparently no one uses a new FFmpeg
with non-SSE2 capable systems.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 18:48:54 +01:00
Michael Niedermayer d4e0d5ed48 avformat/rtpdec_rfc4175: Check dimensions
Fixes: out of array access
Fixes: zeropath/int_overflow_in_rtpdec_rfc4175

Found-by: Joshua Rogers <joshua@joshua.hu>
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 18:41:24 +01:00
Michael Niedermayer c03e49dd1d avformat/rtpdec_rfc4175: Only change PayloadContext on success
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 18:41:24 +01:00
Michael Niedermayer af3dee3132 avformat/rtpdec_rfc4175: Fix memleak of sampling
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 18:41:17 +01:00
Andreas Rheinhardt a8dd83b4b1 avcodec/get_bits: Avoid unused variable
Fixes lots of warnings from MSVC (which does not support av_unused).

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-08 14:48:12 +01:00
Zhao Zhili 36e5576a44 avutil/hwcontext_d3d12va: fix buf size when call av_buffer_create 2025-11-08 08:15:17 +00:00
Michael Niedermayer b518c027a0 avformat/http: Fix off by 1 error
Fixes: out of array access
Fixes: zeropath/off-by-one-one-byte

Found-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 02:26:36 +01:00
Michael Niedermayer d80f8f3651 avcodec/exr: spelling
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 01:17:46 +01:00
oblivionsage 8abeb879df avcodec/rv60dec: add upper bound check for qp
The quantization parameter (qp) can exceed 63 when the base value
from frame header (0-63) is combined with the offset from slice data
(up to +2), resulting in qp=65. This causes out-of-bounds access to
the rv60_qp_to_idx[64] array in decode_cbp8(), decode_cbp16(), and
get_c4x4_set().

Fixes: Out-of-bounds read
Signed-off-by: oblivionsage <cookieandcream560@gmail.com>

No testsample is available

This is related to 61cbcaf93f and clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5160167345291264
which fixed rv60_qp_to_idx[qp + 32] out of array access
These 2 checks are not redundant and neither covers the cases of the other

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-08 01:16:39 +01:00
veygax 162f75b5e6 avcodec/exr: use tile dimensions in pxr24 UINT case
update the switch statement for EXR_UINT in pxr24_uncompress to
correctly use the tile width td->xsize instead of using the full window
width s->xdelta. s->delta is larger than td->xsize which lead to two
buffer overflows when interacting with the ptr variable in the same
switch statement.

Fixes: out of bounds read and write
Found-by: veygax's insomnia network (INSOMNIA-1)
Signed-off-by: veygax <veyga@veygax.dev>
2025-11-07 23:27:34 +01:00
Michael Niedermayer 6e8cf0377f avcodec/exr: Simple check for available channels
The existing is_luma check is fragile as depending on the order
of channels it can be set or reset

No testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-07 23:12:42 +01:00
Andreas Rheinhardt dd092f7fd9 avcodec/avcodec: Simplify sentinel checks
There is no need to check the whole AVChannelLayout; checking
its nb_channels is enough.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt 946a1dbd94 avcodec/tests/avcodec: Check codec {pix,sample}_fmt etc. arrays
E.g. check that the ordinary entries are valid (e.g. no negative sample
rates, must have pix fmt descriptor) and also that the sentinels
are valid where they contain redundant information.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt e9be8b831d avcodec/tests/avcodec: Test that decoders don't set encoder-only fields
For decoders, the pixel format is negotiated via the get_format callback
(if there is a choice at all), so decoders should not set pix_fmts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt 2523235a31 avcodec/amfdec: Don't set AVCodec.pix_fmts
It is not supposed to be set by decoders (where format negotiation
happens via the get_format callback).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt ef3e337079 avcodec/tests/avcodec: Test color_ranges and alpha_modes
Test that they are only set by video codecs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt ab70751c8a avcodec/codec_internal: Use bitfield for alpha_modes
Right now, FFCodec contains a dedicated pointer for
alpha_mode; this is wasteful, as there is only a very limited
range of options for this value, namely four.
So store it as a two-bit bitfield like color_ranges.
This reduces sizeof(FFCodec) by 16 here (the placement
of alpha_mode entailed unnecessary padding) and
saves 11328B of .data.rel.ro here (on a standard build with
no external libraries).

(If it were not for effective-type violations, one could
share the code and the table with AV_CODEC_CONFIG_COLOR_RANGE.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt df1b6f9cfd avcodec/avcodec: Avoid relocations for color ranges
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt 1d68ae7389 avcodec/avcodec: Remove always-true branches
avcodec_get_supported_config() always sets a dummy for
the pointer to the number of entries in case it is not set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:55:43 +00:00
Andreas Rheinhardt a2210902ff avcodec/encode: Use enum AVPictureType in ff_encode_add_stats_side_data
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt 08e75b8211 avcodec/packet: Move ff_side_data_set_encoder_stats() to encode.c
And rename it to ff_encode_add_stats_side_data() and move its
declaration to encode.h. Also constify the error pointee.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt ec239259a7 avcodec/libx265: Remove stray FF_ENABLE_DEPRECATION_WARNINGS
Forgotten in 7d07723db5.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt 8a46fe1a7d avcodec/libaomenc: Avoid av_unused
pict_type is always used since 5e0eac3d4566839598f6d6fe5d77770023d6713a;
ctx in set_pix_fmt() seems to have been always unused.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Rémi Denis-Courmont 7435a3180d riscv/cpu: add av_const for VLEN helpers
This is read from a read-only constant system register.
2025-11-07 08:43:23 +00:00
Rémi Denis-Courmont 39abb1ac94 pixblockdsp: avoid segments on R-V V diff_pixels_unaligned
On SpacemiT X86, before:
diff_pixels_unaligned_rvv_i32:                         250.2 ( 0.59x)
...after:
diff_pixels_unaligned_rvv_i32:                          56.9 ( 2.60x)
2025-11-07 08:43:23 +00:00
Rémi Denis-Courmont c17d304e1f pixblockdsp: avoid segments on R-V V get_pixels_unaligned
On SpacemiT X86, before:
get_pixels_unaligned_rvv_i32:                          172.4 ( 0.37x)
...after:
get_pixels_unaligned_rvv_i32:                           34.4 ( 1.84x)
2025-11-07 08:43:23 +00:00
Rémi Denis-Courmont e3b0d58394 Revert "lavc/pixblockdsp: rework R-V V get_pixels_unaligned"
The optimised version does not work if the stride is not a multiple 8,
which can occur as reproduce by vsynth3-asv1 and vsynth3-asv2 tests.

This reverts commit 02594c8c01.

Conflicts:
	libavcodec/riscv/pixblockdsp_init.c
	libavcodec/riscv/pixblockdsp_rvv.S
2025-11-07 08:43:23 +00:00
Michael Yang df1fd43db4 libavcodec/vulkan_encode_av1: fix non-monotonic DTS
Combine P-frame with following B-frame into a single packet with the
latter's order. Emit a tail packet with a show_existing_frame header
to show it at the correct PTS.
2025-11-06 22:06:42 +00:00
Lynne dd80ecb666 doc/APIchanges: bump lavu minor and remove reverted pixfmts 2025-11-06 21:47:08 +01:00
Lynne 6720f71247 Revert "vulkan/prores: output LSB-padded data"
This reverts commit 909d71322a.

The issue was elsewhere, not in our code.
2025-11-06 21:46:43 +01:00
Lynne 9a7174bc9a Revert "lavu/pixfmt: add grayscale 10 and 12-bit MSB padded variants"
This reverts commit ed5b694ebe.
2025-11-06 21:46:43 +01:00
Lynne 26236a47b2 Revert "lavu/pixfmt: add 420 and 422, 10 and 12-bit MSB padded variants"
This reverts commit e42c7698f5.
2025-11-06 21:46:43 +01:00
Lynne b982b2a2a3 Revert "swscale: add support for 10/12-bit grayscale MSB pixfmts"
This reverts commit a5be0ecbfd.
2025-11-06 21:46:41 +01:00
Lynne 72a19a1c4a Revert "swscale: add support for 10/12-bit 422 and 444 MSB pixfmts"
This reverts commit bc0ee8b7cc.
2025-11-06 21:44:13 +01:00
Lynne 22cc958c58 Revert "hwcontext_vulkan: fix grayscale 10 and 12-bit formats using the new MSB formats"
This reverts commit 471acedec2.
2025-11-06 21:44:13 +01:00
Lynne 2c7732a676 Revert "hwcontext_vulkan: fix 3-plane 444 10 and 12-bit formats using the new MSB formats"
This reverts commit 41ecb203c5.
2025-11-06 21:44:13 +01:00
Lynne 38df9ba71b Revert "hwcontext_vulkan: fix planar 10 and 12-bit RGB formats using the new MSB formats"
This reverts commit 98ee3f6718.
2025-11-06 21:44:13 +01:00
Lynne 15e82dc452 Revert "hwcontext_vulkan: remove unsupported/broken pixel formats"
This reverts commit 5b388f2838.
2025-11-06 21:44:13 +01:00
Lynne deaece6e56 Revert "swscale/format: add missing fmt_shift for gray12/12 msb formats"
This reverts commit c9710dae3c.
2025-11-06 21:44:13 +01:00
Ramiro Polla 4bee010844 swscale/range_convert: fix truncation bias in range conversion
384fe39623 introduced a regression in the
range conversion offset calculation, resulting in a slight green tint
in full-range RGB to YUV conversions of grayscale values.

The offset being calculated was not taking into consideration a bias
needed for correctly rounding the result from the multiplication stage,
leading to a truncated value.

Fixes issue #11646.
2025-11-06 20:36:08 +00:00
Niklas Haas 01b105bb06 tests/fate/swscale: add swscale self-test
This one takes about 2.93s on my machine, but ensures that every pixel
format conversion roundtrips correctly. Note that due to existing bugs in
libswscale, this one only passes when using the new format conversion code.

Restrict the test to -v 16 (AV_LOG_ERROR) to avoid excess amounts of output.
2025-11-06 20:34:51 +00:00
Niklas Haas 9a386078cc tests/swscale: use av_log() where appropriate
We can't use ANSI color codes inside av_log(), so fall back to printf()
for these; but match the INFO verbosity level.

Also change the format slightly to drop SSIM numbers down to just below
VERBOSE level, since VERBOSE tends to generate a lot of swscale related
spam.
2025-11-06 20:34:51 +00:00
Niklas Haas 84b365d522 avfilter/avfiltergraph: print both failing links on conversion error
This is more informative than the current behavior, because when the first
MERGE() succeeds but the second fails, the original link already has
merged formats and thus the error message is confusing.
2025-11-06 18:16:10 +01:00
Niklas Haas 6c3a63112b avfilter/avfiltergraph: only print format lists for failing mergers
Instead of printing all format lists on a link negotiation error, just print
the relevant/failing format lists.
2025-11-06 18:09:36 +01:00
Niklas Haas 7b564e2efc avfilter/avfiltergraph: print all format lists on config failure
Instead of just printing the pixel/sample formats.
2025-11-06 18:01:37 +01:00
Niklas Haas ad5b151f88 avfilter/formats: add name field to AVFilterFormatMerger
Needed to properly print format lists on format configuration failure.
2025-11-06 18:01:33 +01:00
Niklas Haas f5bc9704ed avfilter/formats: constify ff_filter_get_negotiation 2025-11-06 17:48:50 +01:00
Niklas Haas c1717cb666 avfilter/format: add print_list() to AVFilterFormatsMerger
So that the generic code can correctly print format lists for failing mergers.
2025-11-06 17:34:43 +01:00
Niklas Haas c9710dae3c swscale/format: add missing fmt_shift for gray12/12 msb formats
The MSB YUV formats were added, but the gray formats were not. Seems to have
been an oversight.

Fixes: a5be0ecbfd
2025-11-06 15:56:24 +01:00
Zhao Zhili 222127418b avutil/internal: remove some compats for msvc
They are supported by MSVC with C11.
2025-11-06 02:16:27 +00:00
Andreas Rheinhardt 79080a547a avcodec/x86/h264_chromamc: Use xmm regs in chroma_mc4 SSSE3 functions
Doubling the register size allowed to avoid two pmaddubsw.
It is also ABI compliant (the old version lacked an emms)
and the average versions no longer rely on padding (the old versions
used pavgb with a memory operand reading eight bytes,
although only four are needed).

Old benchmarks (the latter four refer to RV40):
avg_h264_chroma_mc4_8_c:                               145.7 ( 1.00x)
avg_h264_chroma_mc4_8_ssse3:                            32.3 ( 4.51x)
put_h264_chroma_mc4_8_c:                               136.1 ( 1.00x)
put_h264_chroma_mc4_8_ssse3:                            29.0 ( 4.70x)
avg_chroma_mc4_c:                                      162.1 ( 1.00x)
avg_chroma_mc4_ssse3:                                   31.1 ( 5.22x)
put_chroma_mc4_c:                                      137.5 ( 1.00x)
put_chroma_mc4_ssse3:                                   28.6 ( 4.81x)

New benchmarks:
avg_h264_chroma_mc4_8_c:                               146.7 ( 1.00x)
avg_h264_chroma_mc4_8_ssse3:                            26.5 ( 5.53x)
put_h264_chroma_mc4_8_c:                               136.8 ( 1.00x)
put_h264_chroma_mc4_8_ssse3:                            22.5 ( 6.09x)
avg_chroma_mc4_c:                                      165.5 ( 1.00x)
avg_chroma_mc4_ssse3:                                   27.2 ( 6.08x)
put_chroma_mc4_c:                                      138.1 ( 1.00x)
put_chroma_mc4_ssse3:                                   23.2 ( 5.96x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-06 02:16:28 +01:00
Kacper Michajłow 3eb0cb3b0b avutil/hwcontext_vulkan: use correct bitmask types
Vulkan headers define *FlagBits enum with individual bit values, and
coresponding *Flags typedef to be used to store the bitmask of
coresponding bits.

In practice those two types map to the same type, but for consistency
*Flags should be used.

Fixes MSVC warnings about type mismatch.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:09 +01:00
Kacper Michajłow f478964226 avcodec/vulkan_encode_av1: fix unit_elems check
Wrong enum value was used to check unit_elems. While
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA (11) would trigger when
UNIT_MASTERING_DISPLAY (2) was set, it also would match
UNIT_CONTENT_LIGHT_LEVEL (1) which is not expected.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:01 +01:00
Kacper Michajłow c3ff7d23f5 avcodec/dxva2: move variable declaration to for loop to avoid warning
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:01 +01:00
Kacper Michajłow 08d327e92c fftools/ffmpeg: suppress unused variable warning, but using it
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:00 +01:00
Lynne 873a173328 aacpsy: fix whitespace and code style
The last merged patch contained garbage.
2025-11-05 16:31:59 +00:00
Zhao Zhili 632958d2bf avformat/mov: log unknown tag via av_fourcc2str
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Zhao Zhili 07581d6736 avformat/mov: check prji box version and flags
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Zhao Zhili 0734d1c55a avformat/mov: relax check on proj box size
Pico VR adds a '\0' after projection_type (a real C string than
a fourcc). It's not strictly correct, but doesn't affect parsing.

[prji: Projection Information Box]
    position = 149574743
    size = 17
    version = 0
    flags = 0x000000
    projection_type = rect

Co-Authored-by: Keven Ma
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-11-05 23:45:31 +08:00
Zhao Zhili 84fcbce16c fate/hevc: add tests for the dts2pts bsf 2025-11-05 15:13:54 +00:00
Zhao Zhili 2d241202ff avcodec/bsf/dts2pts: add hevc support 2025-11-05 15:13:54 +00:00
Zhao Zhili 6c83bcadbb avcodec/hevc: add ff_hevc_compute_poc2 which don't depend on HEVCSPS directly
So it can be used in other places like bsf.
2025-11-05 15:13:54 +00:00
Zhao Zhili 5f15734d92 avcodec/bsf/dts2pts: fix return 0 on error path 2025-11-05 15:13:54 +00:00
Zhao Zhili 91b2fe71cc avcodec/bsf/dts2pts: remove always true check 2025-11-05 15:13:54 +00:00
Kacper Michajłow 671e54d715 configure: add -static suffix to internal static libs for test programs
In MSVC builds, object files built for shared or static libraries are
technically not compatible with each other. That's why building both
shared and static libraries simultaneously is not allowed in configure.
This may change in the future once dllimport/dllexport attributes are no
longer used. Which will be possible on next major bump. The only
remaining use of dllexport was changed in c6c8063186.

However, for test programs, we still build internal static libraries
that allow the test programs to access internal symbols.

In commit 8eca3fa619, I assumed that when
CONFIG_STATIC=0, we would never build a static library. We actually do
build one for internal purposes, for the test executables. In that case,
we only link the tested library statically (using the same object files
as built for the shared library), the rest of the libraries are still
linked dynamically.

Such libraries are never installed and are used only for test programs.
This change adds a -static suffix to these internal libraries to avoid
name conflicts. In the MSVC world, static libraries and import libraries
are generally the same thing and share the same naming conventions.

Fixes: 8eca3fa619
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 13:00:09 +00:00
Niklas Haas 08eda05967 avfilter/vf_libplacebo: make rotation check more robust
This currently does not make any difference, but it makes the check
more robust against possible future changes to the rotation parameter.
2025-11-04 12:38:55 +00:00
Niklas Haas 49452967e7 avfilter/vf_libplacebo: don't override existing rotation attribute
This is a regression introduced by the addition of the rotation option,
which overrode the existing rotation attribute that may have been set to
the image.

To fix it, add the rotation istead of setting it - however we have to do this
directly when mapping, so as to not add it multiple times.

Fixes: 4f623b4c59
2025-11-04 12:38:55 +00:00
Andreas Rheinhardt 6c1acbbffb avcodec/x86/fdct: Remove obsolete comment
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:41:32 +01:00
Andreas Rheinhardt 18e08101eb avcodec/x86/Makefile: Don't use MMX-OBJS for fdct.o
MMX has been removed in d402ec6be9.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:41:29 +01:00
Andreas Rheinhardt 8157aa1a3f avcodec/x86/me_cmp: Remove MMX sse functions
They are overridden by SSE2 and no longer needed by the no longer
existing nsse MMX functions. Saves 240B here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:41:11 +01:00
Andreas Rheinhardt 3f596ec478 avcodec/x86/me_cmp: Port nsse{8,16} to SSSE3
Even nsse8 has to operate on eight words and therefore gains
a lot from xmm registers (and pabsw).

Old benchmarks:
nsse_0_c:                                              359.2 ( 1.00x)
nsse_0_mmx:                                            151.8 ( 2.37x)
nsse_1_c:                                              151.2 ( 1.00x)
nsse_1_mmx:                                             77.5 ( 1.95x)

New benchmarks:
nsse_0_c:                                              358.8 ( 1.00x)
nsse_0_ssse3:                                           62.2 ( 5.77x)
nsse_1_c:                                              151.2 ( 1.00x)
nsse_1_ssse3:                                           33.6 ( 4.50x)

The MMX nsse functions have been removed.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:40:39 +01:00
Andreas Rheinhardt 86062cfa03 avcodec/x86/me_cmp: Add ff_sse8_sse2()
Benchmarks:
sse_1_c:                                                51.9 ( 1.00x)
sse_1_mmx:                                              16.5 ( 3.15x)
sse_1_sse2:                                              9.7 ( 5.36x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:40:32 +01:00
Andreas Rheinhardt 232e72d00e avcodec/x86/me_cmp: Rename registers
This will avoid using xmm registers that are volatile for Win64
in the next commit.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:40:19 +01:00
Andreas Rheinhardt 87cfbcb74a avcodec/x86/me_cmp: Avoid unnecessary instruction
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-04 11:39:25 +01:00
Manuel Lauss d058d5db10 avcodec/sanm: implement codec45
This is a post-processing codec: given delta-x/y coordinates and a run length,
the r/g/b components of the 4 surrounding pixels are summed up, and the resulting
15bit value is used as index into a color quantization table to derive the
resulting pixel at the center.

It is only used in 10-20 frames of the Rebel Assault 2 LxxRETRY.SAN files
to slightly blur the outline of the "opening aperture" effect.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-11-04 10:28:57 +00:00
Martin Storsjö 8313dc1120 movenc: Make hybrid_fragmented retain the fragmented form headers
This makes the final file truly hybrid: Externally the file
is a regular, non-fragmented file, but internally, the fragmented
form also exists un-overwritten.

To make any use of that, first, the fragments need to be muxed in
a position independent form, i.e. with empty_moov+default_base_moof
(or the dash or cmaf meta-flags).

Making use of the fragmented form when the file is finalized is
not entirely obvious though. One can dump the contents of the
single mdat box, and get the fragmented form. (This is a neat
trick, but not something that anybody really is expected to
want to do.)

The main expected use case is accessing fragments in the form of
byte range segments, for e.g. HLS.

Previously, the start of the file would look like this:

- ftyp
- free
- moov
 - (moov contents)

After finalizing the file, it would look like this:

- ftyp
- free
- mdat (previously moov)
 - (moov contents)

In this form, the size and type of the original moov box were
overwritten, and the original moov contents is just leftover
as unused data in the mdat box.

To avoid this issue, the start of the file now looks like this:

- ftyp
- free
- free
 - ftyp
- moov
 - (moov contents)

The second, hidden ftyp box inside mdat, would normally never be
seen.

After finalizing, the difference is that the mdat box now is
extended to cover the ftyp and the whole moov including its header
(and all the following fragments).

I.e., the start of the file looks like this:

- ftyp
- free
- mdat
 - ftyp
 - moov
  - (moov contents)

This allows accessing the "ftyp+moov" pair sequentially as such,
with a byte range - this range is untouched when finalizing,
producing the same ftyp+moov pair both while writing, when the
file is fragmented, and after finalizing, when the file is
transformed to non-fragmented externally.

Note; the sequential two "free+free" boxes may look slightly
silly; it could be tempting to make the second one an mdat
from the get-go. However, some players of fragmented mp4 (in
particular, Apple's HLS player) bail out if the initialization
segment contains an mdat box - therefore, use a free box.

It could also be possible to use just one single free box with
8 bytes of padding at the start - but that would require more
changes to the finalization logic.

For a segmenting user of the muxer, the only unclarity is how
to determine the right byte range for the internal ftyp+moov
pair. Currently, this requires parsing the muxer output and skip
past anything up to the start of the non-empty free box.
2025-11-04 10:23:31 +00:00
Agent45 a06aee359b revert 458a942481151ede27478e6ac6d9d2866d438b84
revert avcodec/aacenc: add bitrate threshold for PNS
2025-11-04 09:55:51 +00:00
Agent45 e11dfb3f09 trim trailing whitespace in aacpsy.c 2025-11-04 09:55:51 +00:00
Agent45 d907f7d555 avcodec/aacpsy: fix attack detection logic and subblock indexing
Fix several indexing errors in attack detection logic and refine transient handling in the AAC psychoacoustic model.

- Change PSY_LAME_NUM_SUBBLOCKS from 3 to 2 to ensure full coverage of all 1024 MDCT samples, with each subblock containing exactly 1024 / (8 * 2) = 64 samples—matching LAME’s empirical design.
- Introduce next_attack0_zero state flag to stabilize attack[0] prediction across frames.
- Adjust attack threshold presets.

These changes improve the handling of periodic signals such as trumpet, especially under low bitrate conditions.
2025-11-04 09:55:51 +00:00
Agent45 9bded2145f avcodec/aacenc: add bitrate threshold for PNS 2025-11-04 09:55:51 +00:00
Timo Rothenpieler d479a4926a forgejo/workflows: make one of the builds shared 2025-11-03 19:03:16 +00:00
James Almer 4bdc932ec9 avcodec/pthread_frame: sync alpha_mode across worker threads and the user context
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-03 00:16:03 -03:00
James Almer f5eb11a71d avcodec/decode: add missing syncing of side_data_pref_mask to worker threads
Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-02 18:14:17 -03:00
Andreas Rheinhardt 8e90f150eb avcodec/decode: Optimize lcevc away if disabled
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 16:50:36 +01:00
Andreas Rheinhardt 63685709b9 avcodec/decode: Mark init,close functions as av_cold
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 16:49:26 +01:00
Andreas Rheinhardt 2786e5a9ad avcodec/decode: Put lcevc fields into structure of their own
Makes it easier to see that width and height in DecodeContext is
actually a lcevc field.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 16:00:06 +01:00
Andreas Rheinhardt 182b9c7a4a avcodec/decode: Don't allocate LCEVC context for non-video
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 15:29:59 +01:00
Andreas Rheinhardt abf819cff6 avcodec/pthread_frame: Call ff_decode_internal_sync() only during init
It is not necessary to do it more than once, as none of the fields
set change after init.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 15:09:43 +01:00
Andreas Rheinhardt 1e0cd4b650 .gitignore: Add config_components.asm
Forgotten in c607aae2b9.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 13:10:58 +00:00
Andreas Rheinhardt a2914a1ec3 avcodec/x86/hpeldsp: Don't use PAVGB macro
It was only needed for MMX and there are no MMX functions here any more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 12:05:52 +01:00
Andreas Rheinhardt c5e94a564c avcodec/x86/hpeldsp: Don't use saturated addition when unnecessary
The numbers here are small (sums of values unpacked from bytes).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 12:05:52 +01:00
Andreas Rheinhardt 2be1b2ea96 avcodec/x86/hpeldsp: Actually use constants in registers
Forgotten in 36f92206bb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 12:05:52 +01:00
Andreas Rheinhardt a677b38298 avcodec/x86/vp3dsp: Remove remnants of MMX
Forgotten in eefec06634.

Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 12:01:52 +01:00
Andreas Rheinhardt d355749ca6 avcodec/x86/hevc/add_res: Avoid unnecessary modification
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 09:46:15 +01:00
Andreas Rheinhardt f4d9fb0bd0 avcodec/x86/hevc/add_res: Reduce number of registers used
This makes these functions use only volatile registers (even on Win64).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 09:46:15 +01:00
Andreas Rheinhardt 23efbb5e2e avcodec/x86/hevc/add_res: Remove AVX add_residual functions
The AVX and SSE2 functions are identical except for the VEX encodings
used since e9abef437f and
8b8492452d.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-02 09:46:15 +01:00
James Almer 7770c0bf0d avcodec/exr: don't remove Float2HalfTables tables alongside the deprecated gamma code
It's used by other parts of the module that will fail to build otherwise after
the aforementioned removal.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-02 00:21:18 -03:00
Michael Niedermayer 5b98cea4bf avformat/sctp: Check size in sctp_write()
Fixes: out of array access
No testcase

Found-by: Joshua Rogers <joshua@joshua.hu> with ZeroPath
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 23:22:32 +01:00
Michael Niedermayer 83e0298de2 avformat/rtmpproto: consider command line argument lengths
Fixes: out of array access
Fixes: zeropath/rtmp-2025-10

Found-by: Joshua Rogers <joshua@joshua.hu>
Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 19:54:07 +01:00
Michael Niedermayer a64e037429 avformat/rtmpproto_ Check tcurl and flashver length
Fixes: out of array accesses

Reviewed-by: Joshua Rogers <joshua@joshua.hu>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-11-01 19:53:46 +01:00
Andreas Rheinhardt fa959bb135 avcodec/parsers: Silence deprecation warnings
Slipped through because Clang (in contrast to GCC) does not warn about
this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 18:48:17 +01:00
Andreas Rheinhardt 25968dbb05 avcodec/parser_internal: Rename PASSTHROUGH macro to avoid name conflict
wingdi.h defines its own PASSTHROUGH and it is included implicitly
by the VC-1 parser (which is mpegvideo-based and therefore includes
a lot of stuff).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 18:41:27 +01:00
Andreas Rheinhardt 8a322c956f avcodec/avcodec: Schedule parser API to use enum AVCodecID for codec ids
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:03 +01:00
Andreas Rheinhardt 7c43cc4cb7 avcodec/parser_internal: Remove prefix from parser_{init,parse,close}
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:03 +01:00
Andreas Rheinhardt e0b0ca8111 avcodec/avcodec: Schedule moving private fields of AVCodecParser out of avcodec.h
AVCodecParser has several fields which are not really meant
to be accessed by users, but it has no public-private
demarkation line, so these fields are technically public
and can therefore not simply be made private like
20f9727018 did for AVCodec.*

This commit therefore deprecates these fields and
schedules them to become private. All parsers have already
been switched to FFCodecParser, which (for now) is a union
of AVCodecParser and an unnamed clone of AVCodecParser
(new fields can be added at the end of this clone).

*: This is also the reason why split has never been removed despite
not being set for several years now.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:02 +01:00
Andreas Rheinhardt e9fe30ccd1 avcodec/parsers: Add macro to set list of codec ids
The current code relies on AV_CODEC_ID_NONE being zero, so that
unused codec ids are set to their proper value. This commit adds
a macro to set unset ids to AV_CODEC_ID_NONE.

(The actual rationale for this macro is to simplify
the transition to making the private fields that are
currently public in avcodec.h really private.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:02 +01:00
Andreas Rheinhardt 12f7a7724d avcodec: Remove unnecessary parser.h inclusions
It only contains declarations for some auxiliary functions for parsing
that parsers that only work with complete packets don't need.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 16:57:02 +01:00
James Almer 633d424b1b avutil/csp: don't dereference NULL pointer in av_csp_primaries_desc_from_id()
Fixes CID 1668265.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:41:23 -03:00
James Almer 492310ec6e fftools/ffmpeg_demux: fix memory leak when creating tile grid filtergraphs
If av_packet_side_data_to_frame() fails, graph_str will leak.

Fixes CID 1668266.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:41:23 -03:00
James Almer acd2cfe2eb fftools/ffmpeg: make fg_create{_simple,} clear the input string pointer
The graph string is either freed or attached to the filtergraph, so it's best to
not leave a dangling pointer with the caller.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:41:23 -03:00
James Almer 9c266084fe avcodec/vc1_parser: stop splitting ENDOFSEQ markers into separate packets
The decode API can handle outputting delayed frames without relying on the
parser splitting off the ENDOFSEQ marker.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:23:19 -03:00
James Almer 9ab6a94195 avcodec/vc1dec: look for ENDOFSEQ markers at the end of a packet's payload
This is in preparation for the parser no longer splitting them into their own
packets.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:22:49 -03:00
Andreas Rheinhardt fc2c030fb2 avcodec/vc1dec: Deduplicate cleanup code
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:47:45 +01:00
Andreas Rheinhardt a44f7b6c4f avcodec/vc1dec: Don't initialize write-only intra_scantable
VC-1 does not use it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:47:45 +01:00
Andreas Rheinhardt b91081274f avcodec/x86/h264_qpel: Add and use ff_{avg,put}_pixels16x16_l2_sse2()
This avoids mmx (the size 16 h264qpel dsp now no longer uses any mmx)
and improves performance, particularly for the avg case:

Old benchmarks:
avg_h264_qpel_16_mc01_8_c:                             780.0 ( 1.00x)
avg_h264_qpel_16_mc01_8_sse2:                           91.2 ( 8.55x)
avg_h264_qpel_16_mc03_8_c:                             804.0 ( 1.00x)
avg_h264_qpel_16_mc03_8_sse2:                           91.2 ( 8.82x)
put_h264_qpel_16_mc01_8_c:                             779.5 ( 1.00x)
put_h264_qpel_16_mc01_8_sse2:                           82.8 ( 9.41x)
put_h264_qpel_16_mc03_8_c:                             770.1 ( 1.00x)
put_h264_qpel_16_mc03_8_sse2:                           82.5 ( 9.33x)

New benchmarks:
avg_h264_qpel_16_mc01_8_c:                             783.9 ( 1.00x)
avg_h264_qpel_16_mc01_8_sse2:                           84.1 ( 9.32x)
avg_h264_qpel_16_mc03_8_c:                             797.4 ( 1.00x)
avg_h264_qpel_16_mc03_8_sse2:                           83.9 ( 9.51x)
put_h264_qpel_16_mc01_8_c:                             767.4 ( 1.00x)
put_h264_qpel_16_mc01_8_sse2:                           80.5 ( 9.53x)
put_h264_qpel_16_mc03_8_c:                             779.9 ( 1.00x)
put_h264_qpel_16_mc03_8_sse2:                           80.3 ( 9.71x)

(qpeldsp will use these functions when it gets ported to SSE2;
then the mmxext functions will be removed as well.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:17:05 +01:00
Andreas Rheinhardt 529a048c31 avcodec/x86/qpel: Add specializations for put_l2 functions
These functions are currently always called with height either
being equal to the block size or block size+1. height is
a compile-time constant at every callsite. This makes it possible
to split this function into two to avoid the check inside
the function for whether height is odd or even.

The corresponding avg function is only used with height == block size,
so that it does not have a height parameter at all. Removing the
parameter from the put_l2 functions as well therefore simplifies
the C code.

The new functions increase the size of .text from qpel{dsp}.o
by 32B here, yet they save 464B of C code here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:17:05 +01:00
Andreas Rheinhardt 5715eb1274 avcodec/x86/{h264_qpel,qpeldsp_init}: Move shared decls into header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 15:17:05 +01:00
Andreas Rheinhardt b03b45cf22 avcodec/x86/h264_chromamc: Remove MMX(EXT) funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:34:23 +01:00
Andreas Rheinhardt cb054ee89b avcodec/x86/h264_chromamc: Add SSSE3 RV40 chroma motion compensation functions
The only difference between it and the H.264/VC-1 versions is the
bias constant which depends on the shift parameters for RV40.
This value ends up in a register and therefore one can reuse
the H.264 code by setting the registers for RV40 and then jumping
into the relevant H.264 function, making the four new functions
cheap (just 256 bytes in total). This approach uses one jump more
for the no-filter case and one jump less in the one-dimensional
case than an approach using separate functions.

avg_chroma_mc4_c:                                      167.5 ( 1.00x)
avg_chroma_mc4_mmxext:                                  48.1 ( 3.48x)
avg_chroma_mc4_ssse3:                                   31.1 ( 5.39x)
avg_chroma_mc8_c:                                      325.5 ( 1.00x)
avg_chroma_mc8_mmxext:                                 103.2 ( 3.15x)
avg_chroma_mc8_ssse3:                                   33.5 ( 9.71x)
put_chroma_mc4_c:                                      137.4 ( 1.00x)
put_chroma_mc4_mmx:                                     44.5 ( 3.09x)
put_chroma_mc4_ssse3:                                   28.4 ( 4.83x)
put_chroma_mc8_c:                                      271.4 ( 1.00x)
put_chroma_mc8_mmx:                                     99.9 ( 2.72x)
put_chroma_mc8_ssse3:                                   30.6 ( 8.86x)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:34:00 +01:00
Andreas Rheinhardt c607aae2b9 configure: Add config_components.asm
This is in preparation for the next commit.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:33:56 +01:00
Andreas Rheinhardt c6efe1abda avcodec/h264chroma: Move mc1 function to mpegvideo_dec.c
It is only used by mpegvideo decoders (for lowres). It is also only used
for bitdepth == 8, so don't build the bitdepth == 16 function at all any
more.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-01 13:31:57 +01:00
lholliger e59d964a3c libavformat/mov: add support for name udta
In the QTFF documentation for udta/"user data atoms", "name" is a
valid entry for "name of object" however it is currently skipped
leading to some missing metadata when copying for some files. This
isn't classified the same as "(C)nam" which is "Title of content"
so they aren't necessarily the same.
2025-10-31 14:28:23 +00:00
Desmond Liu 4348bde2d2 libavformat/udp: Fix call to recvfrom(2)
Last parameter to recvfrom() is not initialized, causing
recvfrom() to randomly return EINVAL. Issue was introduced in
af04a27893.
2025-10-30 17:22:12 -07:00
James Almer 746650dfe5 Changelog: add entry about tiled HEIF support with the CLI
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 13:46:36 -03:00
James Almer a979c9b935 tests/ffmpeg: add test for HEIF automatic tile merging
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 5ff8395e78 fftools/ffmpeg_demux: create a filtegraph to merge HEIF tiles automatically
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 433d18a1d9 fftools/ffmpeg_filter: handle metadata from stream group in relevant the filtergraphs
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer dec3cc0138 fftools/ffmpeg_filter: allow binding unlabeled filtergraphs
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer e7cf188bb6 fftools/ffmpeg_filter: reindent after the previous commit
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 9dcd25b7cd fftools/ffmpeg_filter: allow removing filtergraphs that contain unbound outputs
Actual practical implementation of the previous commit.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer cce85642c9 fftools/ffmpeg_sched: add a function to remove a filtergraph from the scheduler
For the purpose of merging streams in a stream group, a filtergraph can't be
created once we know it will be used. Therefore, allow filtergraphs to be
removed from the scheduler after being added.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer c751ad2c36 fftools/ffmpeg_mux_init: allow creating streams from filtergraphs created out of stream groups
Several formats are being designed where more than one independent video or
audio stream within a container are part of what should be a single combined
output. This is the case for HEIF (Defining a grid where the decoded output
of several separate video streams are to be placed to generate a single output
image) and IAMF (Defining audio streams where channels are present in separate
coded stream).

AVStreamGroup was designed and implemented in libavformat to convey this
information, but the actual merging is left to the caller.
This change allows the FFmpeg CLI to take said information, parse it, and
create filtergraphs to merge the streams, making the combined output be usable
automatically further in the process.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 99ec0752d7 fftools/ffmpeg_demux: add InputStreamGroup to store stream groups
Preparatory work for upcoming changes. Make ffmpeg keep track of stream groups
internally.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer ba0dc3d49e fftools/ffmpeg_opt: add helpers to match stream groups
Will be used to check for specifiers that match a given stream group and not
a stream within one.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 7b18beb477 fftools: pass global side data through using a separate array
This keeps global and per frame side data clearly separated, and actually
propagates the former as it comes out from the buffersink filter.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 7ac1b410e1 fftools/ffmpeg_filter: fix passing certain parameters to inputs bound to a filtergraph output
Certain parameters, like calculated framerate, are unavailable when connecting
the output of a filtergraph to the input of another.

This fixes command lines like

ffmpeg -lavfi "testsrc=rate=1:duration=1[out0]" -filter_complex "[out0]null[out1]" -map [out1] -y out.png

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer 6879c8ee5d avcodec/avcodec: add helpers to convert between packet and frame side data
They will be used in following commits.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 10:54:01 -03:00
Andreas Rheinhardt 0242cb36a5 avcodec/rv34dsp: Reduce size of qpel functions arrays
Only size 16 and 8 are used (and set).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-30 12:17:25 +01:00
Gyan Doshi 00c23bafb0 doc/filters: add link to rendered doc of drawvg 2025-10-30 15:35:14 +05:30
Zhao Zhili 82c495fd15 avcodec/hevc: fix false alarm when build with enable-small
profile_name is always NULL with --enable-small, which leading to
a warning message "Unknown profile bitstream".
2025-10-30 09:26:17 +00:00
Andreas Rheinhardt 0f105b96a3 avcodec/x86/hevc/idct: Port ff_hevc_idct_4x4_dc_{8,10,12}_mmxext to SSE2
Practically no change in benchmarks (and in codesize).

hevc_idct_4x4_dc_8_c:                                    7.8 ( 1.00x)
hevc_idct_4x4_dc_8_mmxext:                               6.9 ( 1.14x)
hevc_idct_4x4_dc_8_sse2:                                 6.8 ( 1.15x)
hevc_idct_4x4_dc_10_c:                                   7.9 ( 1.00x)
hevc_idct_4x4_dc_10_mmxext:                              6.9 ( 1.16x)
hevc_idct_4x4_dc_10_sse2:                                6.8 ( 1.16x)
hevc_idct_4x4_dc_12_c:                                   7.8 ( 1.00x)
hevc_idct_4x4_dc_12_mmxext:                              7.0 ( 1.13x)
hevc_idct_4x4_dc_12_sse2:                                6.8 ( 1.15x)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-30 08:56:45 +01:00
Michael Niedermayer 909af3a571 avcodec/g723_1enc: Make min_err 64bit
This is intending to fix the case described in https://lists.ffmpeg.org/archives/list/ffmpeg-devel@ffmpeg.org/thread/AAZ7GJPPUJI5SCVTDGJ6QL7UUEP56WOM/
Where FCBParam optim is used uninitialized

a min_err of 1<<30, allows the struct to be never initilialized as all
err (which is int32_t) can be larger than min_err. By increasing min_err
above the int32_t range this is no longer possible

Untested, as i do not have the testcase

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>i
2025-10-30 03:41:24 +01:00
Michael Niedermayer d8ffec5bf9 avcodec/vlc: Clear val8/16 in vlc_multi_gen() by av_mallocz()
Fixes: use of uninitialized memory
Fixes: 427814450/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MAGICYUV_DEC_fuzzer-646512196065689
Fixes: 445961558/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_DEC_fuzzer-5515158672965632

the multi vlc code will otherwise return uninitialized data. Now one can argue that this data should
not be used, but on errors this data can remain ...

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-30 02:08:14 +01:00
Michael Niedermayer d03483bd26 avformat/rtpenc_h264_hevc: Check space for nal_length_size in ff_rtp_send_h264_hevc()
Fixes: memcpy with negative size
Fixes: momo_trip-poc/input

Reported-by: Momoko Shiraishi <shiraishi@os.is.s.u-tokyo.ac.jp>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-30 01:24:23 +01:00
Lynne afd927e0ca prores_raw: skip frames if the discard flag is set
All other decoders do this.
2025-10-28 23:10:15 +01:00
Lynne 0d11c5c2f9 libplacebo: extend allowed range of color primaries and transfer functions
This was left out of the earlier commits.
2025-10-28 22:19:34 +01:00
Lynne 3d12d5682b doc/APIchanges: add AVCOL_PRI_EXT_BASE and AVCOL_PRI_V_GAMUT
They were left out.
2025-10-28 22:19:34 +01:00
Araz Iusubov d31983dc8e MAINTAINERS: Update the entries for AMF 2025-10-28 21:06:37 +00:00
Andreas Rheinhardt 0941646182 avcodec/fflcms2: Don't access inexistent array elements
This would happen if one of the extended transfer characteristics is in
use (currently only AVCOL_TRC_V_LOG).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-28 21:40:50 +01:00
Lynne e85947576c ffv1enc_vulkan: limit probability caching to RADV only
Nvidia's drivers recently broke this.
2025-10-28 20:46:25 +01:00
Lynne bcfb4b2e3e prores_raw_parser: set color params based on vendor
Panasonic cameras record ProRes RAW in V-Log/V-Gamut internally.

Atomos is a brand of recorders which can record uncompressed
non-debayered RAW over HDMI.
All known cameras output linear RAW over HDMI, so mark the transfer function
as linear in that case.
2025-10-28 20:46:21 +01:00
Lynne 71c7b9156b lavu: bump minor and add APIchanges entry for V-Log/V-Gamut 2025-10-28 20:46:21 +01:00
Lynne 92a688cabd lavu: add support for Panasonic V-Gamut 2025-10-28 20:46:21 +01:00
Lynne aeb9b19ebc lavu: add support for Panasonic V-Log 2025-10-28 20:46:21 +01:00
James Almer 08c94518c9 avfilter/vsrc_testsrc: add support for YUV444P1{0,2}MSB to yuvtestsrc
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 19:16:58 +00:00
Baptiste Coudurier 1025beeef1 lavf/id3v2: allow empty strings without bom, fixes #20597 2025-10-28 10:59:25 -07:00
James Almer c7a2b31f84 avformat/demux: pass new extradata to the parser
The parser API doesn't work with packets, only raw data, so in order for it to
be made aware of new extradata propagated through packet side data we need to
pass it in some other form, namely, replacing the main extradata and ensuring
it will be parsed by restarting the parser.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 10:10:22 -03:00
James Almer 530ca627a3 avcodec/mlpdec: don't depend on context channel layout when setting substream masks
If avctx->ch_layout is unset (as it's allowed and even expeced by the
AV_CODEC_CAP_CHANNEL_CONF flag), the code setting substream masks will fail for
stereo and mono layouts unless a downmix channel was requested.
Fix this by deriving the mask with coded values only.

Fixes issue #20764.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-28 13:08:02 +00:00
xin.guo 0a4bd6cc23 avcodec/h264_vulkan: Fix param error in set_sps
Signed-off-by: xin.guo <xin.guo@sophgo.com>
2025-10-28 06:12:36 +00:00
averne 909d71322a vulkan/prores: output LSB-padded data
For consistency with existing Vulkan-based hwaccels
2025-10-28 06:12:14 +00:00
Lynne 70be2e2ae2 lavc/hwaccels: properly order list 2025-10-28 07:11:26 +01:00
Lynne 51843adfe5 vulkan/rangecoder: ifdef out encode and decode chunks
There's little code sharing between them.
2025-10-28 07:11:26 +01:00
Lynne 3cd678506c vulkan_decode: align images to the subsampling
Normally, the Vulkan drivers handle this. But Vulkan decided "nah".

This requires API users to crop out odd-numbered images with subsampling.
2025-10-28 07:11:26 +01:00
Lynne 964e9cc63b hwcontext_vulkan: add support for VK_EXT_zero_initialize_device_memory 2025-10-28 07:11:21 +01:00
caifan3 91512f0856 fftools/cmdutils: Rename file_read to read_file_to_string to avoid symbol collision with NuttX
The function name 'file_read' is too generic and conflicts with a function
of the same name in the NuttX kernel. Since NuttX links kernel and userspace
into a single binary, this causes a symbol collision when building FFmpeg tools.

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-10-28 02:48:05 +00:00
Lynne 5b388f2838 hwcontext_vulkan: remove unsupported/broken pixel formats
We have no use for 14-bit pixel formats for now, so remove support for gray14,
which was broken due to the LSB padding issue.

Similarly YUVA at 10/12 bit was broken for the same reason.
2025-10-27 22:59:41 -03:00
Lynne 98ee3f6718 hwcontext_vulkan: fix planar 10 and 12-bit RGB formats using the new MSB formats 2025-10-27 22:59:41 -03:00
Lynne 41ecb203c5 hwcontext_vulkan: fix 3-plane 444 10 and 12-bit formats using the new MSB formats
We previously tried to fudge this somehow, but the pixel formats
are simply broken and we cannot use them without declaring them as MSB.
2025-10-27 22:59:41 -03:00
Lynne 471acedec2 hwcontext_vulkan: fix grayscale 10 and 12-bit formats using the new MSB formats 2025-10-27 22:59:41 -03:00
Lynne dc34d0764f lavu: bump minor and add APIchanges entry for the new pixfmts 2025-10-27 22:59:41 -03:00
Lynne bc0ee8b7cc swscale: add support for 10/12-bit 422 and 444 MSB pixfmts 2025-10-27 22:59:41 -03:00
Lynne a5be0ecbfd swscale: add support for 10/12-bit grayscale MSB pixfmts 2025-10-27 22:59:40 -03:00
Lynne e42c7698f5 lavu/pixfmt: add 420 and 422, 10 and 12-bit MSB padded variants
Vulkan has defined all its 3-plane formats as MSB padded.
2025-10-27 22:59:39 -03:00
Lynne ed5b694ebe lavu/pixfmt: add grayscale 10 and 12-bit MSB padded variants 2025-10-27 22:58:21 -03:00
Chris Hodges d12791ef7f libavformat: fix rtpdec_av1 regarding OBU size
Fix the AV1 RTP depacketizer for instances where the OBU elements
did not have their OBU size fields removed according to the
recommendation (SHOULD) of the AV1 RTP specification.

Roger Hardiman courteously reported that the depacketizer doesn't
work correctly for fragmented OBU elements with their OBU size
fields still present and will incorrectly state that the
continuation of such a fragment was unexpected, because the
frag_obu_size field was used as a state and only incremented
when the size field needed to be updated on OBU size field
restoration. This patch solves the slip.

Change-Id: I95af8cc89862e8ecf79aabcf029dd95a20dfd7ad
2025-10-27 22:11:58 +00:00
James Almer e10473f13e avformat/matroskadec: relax the check for cropped dimensions
There seem to be samples with no Video element on video tracks in the wild,
which even if not spec compliant, can be demuxed fine after lavf probes the
stream with a decoder/parser.
Relax the check to allow tracks with no dimensions to work, and also add a
check for strict spec compliance to maintain the current behavior if desired.

Fixes issue #20649.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-27 15:54:22 -03:00
Kacper Michajłow ccb1865a82 avfilter/buffersink: move ret declaration to suppress unused warning
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
Kacper Michajłow a6ccaa2eea avcodec/d3d12va_encode_h264: remove unused variables
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
Kacper Michajłow d57de83352 avcodec/d3d12va_encode: fix format specifier for HRESULT
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 15:39:39 +01:00
David Rosca a0a16f2ea4 cbs_vp9: Always update loop filter and segmentation from current frame
Fixes decoding vp90-2-09-aq2, vp90-2-15-segkey_adpq, vp90-2-15-segkey
and vp90-2-22-svc_1280x720_1 with Vulkan hwaccel.

Fixes: 26a2a76346 ("cbs_vp9: Fix VP9 passthrough")
2025-10-27 13:44:03 +00:00
Kacper Michajłow 4deb8b3a7a avutil/vulkan_glslang: use AVMutex instead of pthread_mutex_t
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 11:54:53 +01:00
Anthony Bajoua 68152978b5 libavformat/movenc: Output ftyp atom with hybrid_fragmented+delay_moov 2025-10-27 09:06:06 +00:00
Kacper Michajłow 8c633f45b0 configure: fix glslang linking on platforms without pthreads
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-27 02:59:09 +01:00
Andreas Rheinhardt d01608e022 avcodec/proresdec: Remove unused hwaccel_last_picture_private
ProRes is an intra-only codec.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-25 22:34:30 +02:00
averne 23df9d4172 avcodec/prores: add parser
Introduce a basic parser for ProRes frame headers.
This avoid having to decode an entire frame to
extract codec information.
2025-10-25 19:56:44 +00:00
averne 98412edfed lavc: add a ProRes Vulkan hwaccel
Add a shader-based Apple ProRes decoder.
It supports all codec features for profiles up to
the 4444 XQ profile, ie.:
- 4:2:2 and 4:4:4 chroma subsampling
- 10- and 12-bit component depth
- Interlacing
- Alpha

The implementation consists in two shaders: the
VLD kernel does entropy decoding for color/alpha,
and the IDCT kernel performs the inverse transform
on color components.

Benchmarks for a 4k yuv422p10 sample:
- AMD Radeon 6700XT:   178 fps
- Intel i7 Tiger Lake: 37 fps
- NVidia Orin Nano:    70 fps
2025-10-25 19:54:13 +00:00
averne 3fd55d952e avcodec/proresdec: save slice width parameter in codec context
Save the log2_desired_slice_size_in_mb syntax
element in the codec context.
Required by the Vulkan hwaccel to compute slice
widths and positions.
2025-10-25 19:54:13 +00:00
averne 987368ef25 avcodec/prores: adapt hwaccel code for slice-based accelerators
In preparation for the Vulkan hwaccel.
The existing hwaccel code was designed around
videotoolbox, which ingests the whole frame
bitstream including picture headers.
This adapts the code to accomodate lower-level,
slice-based hwaccels.
2025-10-25 19:54:13 +00:00
averne 9195af77eb proresdec: allocate private memory for hwaccel pictures
In preparation for the Vulkan hwaccel, which
stores per-frame acceleration structures.
2025-10-25 19:54:13 +00:00
Anders Rein f5f72b4f8a Fix incorrect extraction of Origin
The code that attempted to extract origin (4B.02) was put in the wrong
metadata handler and was also read as the wrong integer type. According
ST 377-1 Origin is of type "Position" (Int64) in the Timeline Track, not
a 8 bit unsigned integer in the Sequence.
2025-10-25 19:22:48 +00:00
James Almer defd5f3f64 Changelog: fix ordering for drawvg entry
Entries should be sorted chronologically from oldest to youngest.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-25 10:59:42 -03:00
James Almer d9853e66d3 avfilter/Makefile: fix dependency for drawvg test
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-25 10:57:56 -03:00
Ayose 016d767c8e lavfi: add drawvg video filter.
The drawvg filter can draw vector graphics on top of a video, using libcairo. It
is enabled if FFmpeg is configured with `--enable-cairo`.

The language for drawvg scripts is documented in `doc/drawvg-reference.texi`.

There are two new tests:

- `fate-filter-drawvg-interpreter` launch a script with most commands, and
  verify which libcairo functions are executed.
- `fate-filter-drawvg-video` render a very simple image, just to verify that
  libcairo is working as expected.

Signed-off-by: Ayose <ayosec@gmail.com>
2025-10-25 13:21:50 +00:00
Kacper Michajłow d77f917621 ffbuild/common: silence DEPCXX output
Fixes: 0ce413af9c

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:15:06 +02:00
Kacper Michajłow 25fe4105c8 tests/fate/api: fix fate-lavf-flv test
fate-lavf-flv is dependency of fate-api-seek, but the fate-api-seek is
setting CMP = null, which affects fate-lavf-flv. Reset CMP value to
expected by the flv test and use default diff compare.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow c5edd125f4 tests/ref/fate: remove leftover mapchan ref files
Those tests were removed in e48055fdce.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow 51762c956c tests/ref/fate/iirfilter: remove leftover ref file
Test doesn't exist anymore.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow df7b6b23ff tests/fate/filter-atempo: remove leftover ref file
Test was onverted to oneoff in 6cde03739e.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow dd4c524dbc api-h264-test: indent output
This matches tests/ref files.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow 63bb6201c7 avutil/tests/hash: don't print trailing spaces
This matches the tests/ref files, which were manually stripped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow c819e59721 avutil/tests/dict: don't print trailing spaces
This matches the tests/ref files, which were manually stripped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow 8d16f85764 avutil/tests/fifo: don't print trailing spaces
This matches the tests/ref files, which were manually stripped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:41 +02:00
Kacper Michajłow 3e69541ff3 avutil/tests/audio_fifo: don't print trailing spaces
This matches the tests/ref files, which were manually stripped.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 11:11:34 +02:00
Andreas Rheinhardt 7b5b29910a avutil/x86/cpu: Remove 3dnow flags, macros
Unused since 5ef613bcb0.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-25 07:27:11 +02:00
Andreas Rheinhardt 9a9edd8024 configure: Remove 3dnow
The last 3dnow functions have been removed in commit
5ef613bcb0. So remove 3dnow
from configure; the only thing kept is that --disable-amd3dnow
is still accepted, but no longer advertised by --help.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-25 07:04:39 +02:00
Kacper Michajłow ddeec523a2 avcodec/x86/idctdsp: add restrict to match function pointer types
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow 49cfafefd4 avcodec/rectangle: use uintptr_t for integer pointer type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow 0cd999266f avcodec/put_bits: add explicit cast to suppress MSVC warning
Supresses:
warning C4334: '<<': result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)

Also drop L, as shift will never exceed 31.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow fe425d97d1 avcodec/cbs*: remove redundant const, it's already in typedef
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow 9ad20839fb avcodec/pixblockdsp: be consistent about restrict use in ff_{get,diff}_pixels
Suppresses warnings about function pointer mismatch.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:15 +02:00
Kacper Michajłow c597d8cac1 avcodec/aacpsdsp: add restrict to function pointers to match declarations
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:14 +02:00
Kacper Michajłow 20f59bfc6b fftools/ffmpeg: use enum VideoSyncMethod instead of int
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-25 01:01:14 +02:00
Kacper Michajłow a2b47ccfbf avcodec/{png,mov}enc: use EOTF gamma approximation for gAMA chunk
This is how images encoded with specific transfer function should be
viewed. Image viewers that doesn't support named trc metadata, will
fallback to simple gAMA value and both of those cases should produce the
same image apperance for the viewer.

Fixes: https://github.com/mpv-player/mpv/issues/13438

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-24 22:24:54 +00:00
Kacper Michajłow 00e43619cd avutil/csp: add av_csp_approximate_eotf_gamma()
2.2 gamma was used for bt.1886 aproximation as the most common target in
real world.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-24 22:24:54 +00:00
Bin Peng 3115c0c0e6 lavc/aarch64: Fix addp overflow in ff_pred16x16_plane_neon_10
The mismatch between neon and C functions can be reproduced
using the following bitstream and command line on aarch64 devices.

wget https://streams.videolan.org/ffmpeg/incoming/replay_intra_pred_16x16.h264
 ./ffmpeg -cpuflags 0  -threads 1 -i replay_intra_pred_16x16.h264  -f framemd5 -y md5_ref
 ./ffmpeg              -threads 1 -i replay_intra_pred_16x16.h264 -f framemd5 -y md5_neon

Signed-off-by: Bin Peng <pengbin@visionular.com>
2025-10-24 15:32:35 +00:00
Andreas Rheinhardt 7e8ef2ded2 configure: Add mxpeg->hpeldsp dependency
Forgotten in 124c856d38.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-24 12:56:24 +02:00
Baptiste Coudurier 7f7335ec43 lavf/mxfenc: fix muxing for DNxHD/DNxHR 444 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 548bdee8db lavf/mxfenc: factorize cdci descriptor functions 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 48c6b8a907 lavf/mxfenc: fix return value to int64_t 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 1cd3f61ad8 lavf/mxfenc: correctly add jpeg2000 subdescriptor reference in cdci, factorize 2025-10-24 00:16:21 +00:00
Baptiste Coudurier cfcd996575 lavf/mxfenc: remove cdci pixel format specific values from stream context 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 06b04da4dc lavf/mxfenc: require pixel format to be set for video streams 2025-10-24 00:16:21 +00:00
Baptiste Coudurier 0b0cb7cd6c lavf/movenc: improve AVdh atom generation for DNxHD/DNxHR 2025-10-24 00:16:21 +00:00
cenzhanquan1 1120b3db30 avcodec/liblc3enc: support packed float (AV_SAMPLE_FMT_FLT) input.
Previously, the LC3 encoder only accepted planar float (AV_SAMPLE_FMT_FLTP).
This change extends support to packed float (AV_SAMPLE_FMT_FLT) by properly
handling channel layout and sample stride.

The pcm data pointer and stride are now calculated based on the sample
format: for planar, use frame->data[ch]; for packed, use frame->data[0]
with channel offset. The stride is set to 1 for planar and number of
channels for packed layout.

This enables encoding from common packed audio sources without requiring
a prior planar conversion, improving usability and efficiency.

Signed-off-by: cenzhanquan1 <cenzhanquan1@xiaomi.com>
2025-10-23 14:42:50 +00:00
cenzhanquan1 0eb572f080 avcodec/liblc3dec: support sample format negotiation and planar layout.
1. Adds support for respecting the requested sample format. Previously,
   the decoder always used AV_SAMPLE_FMT_FLTP. Now it checks if the
   caller requested a specific format via avctx->request_sample_fmt and
   honors that request when supported.

2. Improves planar/interleaved audio buffer handling. The decoding
   logic now properly handles both planar and interleaved sample
   formats by calculating the correct stride and buffer pointers based
   on the actual sample format.

The changes include:
- Added format mapping between AVSampleFormat and lc3_pcm_format
- Implemented format selection logic in initialization.
- Updated buffer pointer calculation for planar/interleaved data.
- Maintained backward compatibility with existing behavior.

Signed-off-by: cenzhanquan1 <cenzhanquan1@xiaomi.com>
2025-10-23 22:06:04 +08:00
Jack Lau cb5e201f5c avformat/whip: cleanup the redundant variable
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-23 10:58:45 +00:00
Jack Lau 0e8cff52bc avformat/whip: add DTLS active role support
Add dtls_active flag to specify the dtls role.

Properly set the send key and recv key depends on DTLS role:

As DTLS server, the recv key is client master key plus salt,
the send key is server master key plus salt.
As DTLS client, the recv key is server master key plus salt,
the send key is client master key plus salt.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-23 10:58:45 +00:00
Gyan Doshi 535d4047d3 ffmpeg: unbreak max_error_rate application
The calculation of decode error rate neglected to cast
its operands to float, thus always leading to a value of 0.
2025-10-21 13:22:08 +00:00
Zhao Zhili edf5b777c9 avcodec/vvc: fix false alarm of missing ref on RASL 2025-10-21 13:21:52 +00:00
Andreas Rheinhardt 05b8608c76 avcodec/x86/mpegvideoencdsp_init: Fix left shift of negative number
Uncovered by UBSan when running the mpegvideoencdsp checkasm
test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-21 12:11:55 +02:00
Martin Storsjö e442128944 movenc: Make sure to flush the delayed moov atom for hybrid fragmented
If using the delay_moov flag in combination with hybrid_fragment
(which is a potentially problematic combination otherwise - the
ftyp box does end up hidden in the end), then we need to flush
twice to get both the moov box and the first fragment, if the
file is finished before the first fragment is completed.
2025-10-21 08:38:32 +00:00
Martin Storsjö 27f5561885 movenc: Fix sample clustering for hybrid_fragmented+delay_moov
If samples were available when the moov was written, chunking
for those samples has been done already, which has to be reset
here.

This is the case when not using empty_moov, when the moov box
describes the first fragment - this case was accounted for already.
But if using the delay_moov flag, then those samples also were
available when writing the moov, so chunking for them has already
been done in this case as well.

Therefore, always reset chunking here (it should be harmless to
always do it), and update the comment to clarify the cases
involved here.
2025-10-21 08:38:32 +00:00
Leo Izen dc39a576ad avcodec/pngenc: include EXIF buffer in max_packet_size
When calculating the max size of an output PNG packet, we should
include the size of a possible eXIf chunk that we may write.

This fixes a regression since d3190a64c3
as well as a bug that existed prior in the apng encoder since commit
4a580975d4.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-10-19 09:17:38 -04:00
Michael Niedermayer 51d3c4b4b6 tools/target_dec_fuzzer: Adjust threshold for PIXLET
Fixes: Timeout
Fixes: 425754611/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PIXLET_fuzzer-4778526102585344

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 02:07:03 +02:00
Michael Niedermayer 388e6fb3be avcodec/ffv1enc: Consider variation in slice sizes
When splitting a 5 lines image in 2 slices one will be 3 lines and thus need more space

Fixes: Assertion sc->slice_coding_mode == 0 failed at libavcodec/ffv1enc.c:1668
Fixes: 422811239/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-4933405139861504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:26 +02:00
Michael Niedermayer 56ef66d350 tools/target_dec_fuzzer: Adjust threshold for CRI
Fixes: Timeout
Fixes: 421997576/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CRI_fuzzer-5335057265131520

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:17 +02:00
Michael Niedermayer b132c1755a tools/target_dec_fuzzer: Adjust threshold for qdraw
Fixes: Timeout
Fixes: 421954735/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_QDRAW_fuzzer-4515776981172224

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:14 +02:00
Michael Niedermayer 8988734d09 tools/target_dec_fuzzer: Adjust threshold for CAVS
Fixes: Timeout
Fixes: 421951267/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CAVS_fuzzer-4766360421072896

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpe
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:10 +02:00
Michael Niedermayer 51f0f2d2cf tools/target_dec_fuzzer: Adjust threshold for interplay video
Fixes: Timeout
Fixes: 421945523/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_VIDEO_fuzzer-4776910965506048

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:06 +02:00
Michael Niedermayer d43f19064e MAINTAINERS: libtheoraenc seems unmaintained
See: [FFmpeg-devel] libtheora maintainer ?

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:37:00 +02:00
Michael Niedermayer 4666c1eed3 libavcodec/cbs_apv_syntax_template: limit tile to 2gb
We do not support larger tiles as we use signed int
Alternatively we can check this in apv_decode_tile_component() or init_get_bits*()
or support bitstreams above 2gb length

Fixes: init_get_bits() failure later
Fixes: 421817631/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-4957386534354944

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-19 01:32:42 +02:00
Araz Iusubov d19b7c283c avcodec/d3d12va_encode: D3D12 H264 encoding support
This patch introduces hardware-accelerated H.264 encoding
using Direct3D 12 Video API (D3D12VA).
2025-10-18 12:20:11 +00:00
Andreas Rheinhardt ed007ad427 avcodec/x86/fpel: Port ff_put_pixels8_mmx() to SSE2
This has the advantage of not violating the ABI by using
MMX registers without issuing emms; it e.g. allows
to remove an emms_c from bink.c.

This commit uses GP registers on Unix64 (there are not
enough volatile registers to do likewise on Win64) which
reduces codesize and is faster on some CPUs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:27:56 +02:00
Andreas Rheinhardt d91b1559e0 avcodec/x86/me_cmp: Replace MMXEXT size 16 funcs by unaligned SSE2 funcs
Snow calls some of the me_cmp_funcs with insufficient alignment
for the first pointer (see get_block_rd() in snowenc.c);
therefore SSE2 functions which really need this alignment
don't get set for Snow and 542765ce3e
consequently didn't remove MMXEXT functions which are overridden
by these SSE2 functions for normal codecs.

For reference, here is a command line which would segfault
if one simply used the ordinary SSE2 functions for Snow:

./ffmpeg -i mm-short.mpg -an -vcodec snow -t 0.2 -pix_fmt yuv444p \
-vstrict -2 -qscale 2 -flags +qpel -motion_est iter 444iter.avi

This commit adds unaligned SSE2 versions of these functions
and removes the MMXEXT ones. This in particular implies that
sad 16x16 now never uses MMX which allows to remove an emms_c
from ac3enc.c.

Benchmarks (u means unaligned version):
sad_0_c:                                                 8.2 ( 1.00x)
sad_0_mmxext:                                           10.8 ( 0.76x)
sad_0_sse2:                                              6.2 ( 1.33x)
sad_0_sse2u:                                             6.7 ( 1.23x)

vsad_0_c:                                               44.7 ( 1.00x)
vsad_0_mmxext (approx):                                 12.2 ( 3.68x)
vsad_0_sse2 (approx):                                    7.8 ( 5.75x)

vsad_4_c:                                               88.4 ( 1.00x)
vsad_4_mmxext:                                           7.1 (12.46x)
vsad_4_sse2:                                             4.2 (21.15x)
vsad_4_sse2u:                                            5.5 (15.96x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:05:07 +02:00
Andreas Rheinhardt 69a700043d avcodec/x86/me_cmp: Remove MMXEXT functions overridden by SSE2
The SSE2 function overriding them are currently only set
if the SSE2SLOW flag is not set and if the codec is not Snow.
The former affects only outdated processors (AMDs from
before Barcelona (i.e. before 2007)) and is therefore irrelevant.
Snow does not use the pix_abs function pointers at all,
so this is also no obstacle.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:05:07 +02:00
Andreas Rheinhardt 20c4608af8 avcodec/x86/me_cmp: Add SSE2 sad 8,16 xy2 functions
The new functions are faster than the existing exact
functions, yet get beaten by the nonexact functions
(they can avoid unpacking to words and back).
The exact (slow) MMX functions have therefore been
removed, which was actually beneficial size-wise
(416B of new functions, 619B of functions removed).

pix_abs_0_3_c:                                         216.8 ( 1.00x)
pix_abs_0_3_mmx:                                        71.8 ( 3.02x)
pix_abs_0_3_mmxext (approximative):                     17.6 (12.34x)
pix_abs_0_3_sse2:                                       23.5 ( 9.23x)
pix_abs_0_3_sse2 (approximative):                        9.9 (21.94x)

pix_abs_1_3_c:                                          98.4 ( 1.00x)
pix_abs_1_3_mmx:                                        36.9 ( 2.66x)
pix_abs_1_3_mmxext (approximative):                      9.2 (10.73x)
pix_abs_1_3_sse2:                                       14.8 ( 6.63x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-17 13:05:07 +02:00
Michael Yang 20051ed3af avcodec/vulkan_encode_av1: fix level index 2025-10-16 21:59:24 +00:00
Michael Yang 62d43ba2e3 libavfilter/vf_nlmeans_vulkan: fix str defaults
Revert back to NAN as -1.0 was erroneously to 0.0 to fit in the options
range.

Add special handling of str per requested.
2025-10-16 21:32:43 +00:00
Michael Yang e8213f766f libavfilter/vf_nlmeans_vulkan: amend doc 2025-10-16 21:32:43 +00:00
Michael Yang 7d65ce7763 libavfilter/vf_nlmeans_vulkan: clean up defaults
Change per-plane strength defaults to -1.0.
2025-10-16 21:32:43 +00:00
Michael Yang 26dee5b43e libavfilter/vf_nlmeans_vulkan: reverse img_bar 2025-10-16 21:32:43 +00:00
Michael Yang 71ff349cc1 libavfilter/vf_nlmeans_vulkan: lower strength min
Lower (per-component) strength minimum from 1.0 to 0.0, with 0.0 skipping
integral and weights calculations.
2025-10-16 21:32:43 +00:00
Michael Yang 2e12b3251d libavfilter/vf_nlmeans_vulkan: clean up naming
Add `nb_components` to push data.

Rename `ws_total_*`` to `ws_*`.
2025-10-16 21:32:43 +00:00
Michael Yang 3fac2d8593 avfilter/vf_nlmeans_vulkan: rewrite filter
This is a major rewrite of the exising nlmeans vulkan code, with bug
fixes and major performance improvement.

Fix visual artifacts found in ticket #10661, #10733. Add OOB checks for
image loading and patch sized area around the border. Correct chroma
plane height, strength and buffer barrier index.

Improve parallelism with component workgroup axis and more but smaller
workgroups. Split weights pass into vertical/horizontal (integral) and
weights passes. Remove h/v order logic to always calculate sum on
vertical pass. Remove atomic float requirement, which causes high memory
locking contentions, at the cost of higher memory usage of w/s buffer.
Use cache blocking in h pass to reduce memory bandwidth usage.
2025-10-16 21:32:43 +00:00
Martin Storsjö 36896af64a movenc: Make the hybrid_fragmented mode more robust
Write the moov tag at the end first, before overwriting the mdat size
at the start of the file.

In case writing the final moov box fails (e.g. due to being out
of disk), we haven't broken the initial moov box yet.

Thus if writing stops between these steps, we could end up with
a file with two moov boxes - which arguably is more feasible to
recover from, than from a file with no moov boxes at all.
2025-10-16 18:58:54 +00:00
Niklas Haas a45d30a675 avutil/hwcontext_vulkan: always enable baseline usage flags
The documentation states that this field is for enabling "extra" usage
flags. This conflicts with the implementation, and the rest of the comment,
though.

In resolving this ambiguity, I think it's better to lean towards the first
sentence and treat this field purely as specifying *extra* usage flags to
enable. Otherwise, this may break vulkan encoding or subsequent hwdownload
if the upstream filter did not specifically advertise this.

Change the default behavior and update the documentation slightly to more
clearly document the semantics.
2025-10-16 17:40:25 +00:00
Andreas Rheinhardt b1f2eea1cd avfilter/vf_noise: Deduplicate option flags
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 19:10:51 +02:00
Andreas Rheinhardt 3ba570de8b avfilter/x86/vf_noise: Port line_noise funcs to SSE2
This avoids having to fix up ABI violations via emms_c and
also leads to a 73% speedup for the line noise average version
here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 19:09:45 +02:00
Andreas Rheinhardt adfec0f52e avfilter/x86/vf_noise: Make line_noise_avg_mmx() match C function
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:19 +02:00
Andreas Rheinhardt 214b52df43 avfilter/vf_noise: Avoid cast
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:19 +02:00
Andreas Rheinhardt ece623b1b3 avfilter/vf_noise: Fix race with very tall images
When using averaged noise with height > MAX_RES (i.e. 4096),
multiple threads would access the same prev_shift slot,
leading to races. Fix this by disabling slice threading
in such scenarios.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:19 +02:00
Andreas Rheinhardt 6a53a4e341 avfilter/vf_noise: Don't write beyond end-of-array
This is not only UB, but also leads to races and nondeterministic
output, because the write one last the end of the buffer actually
conflicts with accesses by the thread that actually owns it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:18 +02:00
Andreas Rheinhardt 94948bd6b9 avfilter/vf_noise: Make private context smaller
"all" only exists to set options; it does not need the big arrays
contained in FilterParams.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-16 18:41:18 +02:00
Zhao Zhili cd4b01707d Revert "avformat/movenc: sidx earliest_presentation_time is applied after editlist"
This reverts commit 301141b576.

cluster[0].dts, pts and frag_info[0].time are already in presentation
timeline, so they shouldn't be shift by start_pts.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-16 11:22:37 +08:00
Zhao Zhili 0de3b1f358 avformat/mov: don't shift sidx_pts
sidx_pts is already in presentation time, so it shouldn't be shift
by sc->time_offset again.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-16 11:22:37 +08:00
James Almer 2e1d702cfc avformat/dump: fix log level passed to av_log when printing stream group side data
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-15 17:49:11 -03:00
Andreas Rheinhardt 74a3c1ddb6 avfilter/x86/vf_pullup: Port pullup functions to SSE2, SSSE3
The diff and var functions benefit from psadbw, comb from wider
registers which allows to avoid reloading values, reducing the number
of loads from 48 to 10. Performance increased by 117% (the loop
in compute_metric() has been timed); codesize decreased by 144B.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 19:43:37 +02:00
Andreas Rheinhardt dcb28ed860 avfilter/x86/vf_spp: Port store_slice to SSE2
This allows to remove an emms_c from the filter. It also gives
25% speedup here (when timing the calls to store_slice using
START/STOP_TIMER).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 19:43:37 +02:00
Andreas Rheinhardt f4a87d8ca4 avcodec/x86/mpegvideoencdsp_init: Use xmm registers in SSSE3 functions
Improves performance and no longer breaks the ABI (by forgetting
to call emms).

Old benchmarks:
add_8x8basis_c:                                         43.6 ( 1.00x)
add_8x8basis_ssse3:                                     12.3 ( 3.55x)

New benchmarks:
add_8x8basis_c:                                         43.0 ( 1.00x)
add_8x8basis_ssse3:                                      6.3 ( 6.79x)

Notice that the output of try_8x8basis_ssse3 changes a bit:
Before this commit, it computes certain values and adds the values
for i,i+1,i+4 and i+5 before right shifting them; now it adds
the values for i,i+1,i+8,i+9. The second pair in these lists
could be avoided (by shifting xmm0 and xmm1 before adding both together
instead of only shifting xmm0 after adding them), but the former
i,i+1 is inherent in using pmaddwd. This is the reason that this
function is not bitexact.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 08:55:13 +02:00
Andreas Rheinhardt cffd029e98 avcodec/x86/mpegvideoencdsp_init: Don't use slow path unnecessarily
The only requirement of this code (and essentially the pmulhrsw
instruction) is that the scaled scale fits into an int16_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 08:55:13 +02:00
Andreas Rheinhardt ce499ebf96 tests/checkasm/mpegvideoencdsp: Add test for add_8x8basis
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-15 08:55:13 +02:00
Michael Niedermayer 566e9032b1 swscale/output: Fix unsigned cast position in yuv2*
Fixes: signed overflow

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-14 20:55:54 +02:00
Michael Niedermayer 0c6b7f9483 swscale/output: Fix integer overflow in yuv2ya16_X_c_template()
Found-by: colod colod <colodcolod7@gmail.com>

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-14 20:55:53 +02:00
Zhao Zhili 6b961f5963 avformat/mov: fix missing video size when some decoders are disabled
Fix #20667

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-14 20:05:55 +08:00
Andreas Rheinhardt a24e0f536d avcodec/x86/hpeldsp_init: Remove check for inline mmx
Forgotten in 4c55724da8.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-14 12:31:15 +02:00
Frank Plowman b0c77e5a12 lavc/vvc: Store RefStruct references to referenced PSs/headers in slice
This loosens the coupling between CBS and the decoder by no longer using
CodedBitstreamH266Context (containing the most recently parsed PSs & PH)
to retrieve the PSs & PH in the decoder. Doing so is beneficial in two
ways:
1. It improves robustness to the case in which an AVPacket doesn't
   contain precisely one PU.
2. It allows the decoder parameter set manager to properly handle the
   case in which a single PU (erroneously) contains conflicting
   parameter sets.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-10-13 19:05:36 +01:00
Andreas Rheinhardt 31f0749cd4 avcodec/vp3: Optimize alignment check away when possible
Check only on arches that need said check.

(Btw: I do not see how h_loop_filter benefits from alignment
at all and why h_loop_filter_unaligned exists.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-13 18:59:49 +02:00
Andreas Rheinhardt 5823ab347a avcodec/vp3dsp: Remove unused flags parameter from ff_vp3dsp_init()
No longer necessary now that the x86 loop filter functions are
bitexact.

Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-13 18:59:24 +02:00
Andreas Rheinhardt e3ca57ae8f avcodec/x86/vp3dsp: Port loop filters to SSE2
The old code operated on bytes and did lots of tricks
due to their limited range; it did not completely succeed,
which is why the old versions were not used when bitexact
output was requested.

In contrast, the new version is much simpler: It operates
on signed 16 bit words whose range is more than sufficient.
This means that these functions don't need a check for bitexactness
(and can be used in FATE).

Old benchmarks (for this, the AV_CODEC_FLAG_BITEXACT check has been
removed from checkasm):
h_loop_filter_c:                                        29.8 ( 1.00x)
h_loop_filter_mmxext:                                   32.2 ( 0.93x)
h_loop_filter_unaligned_c:                              29.9 ( 1.00x)
h_loop_filter_unaligned_mmxext:                         31.4 ( 0.95x)
v_loop_filter_c:                                        39.3 ( 1.00x)
v_loop_filter_mmxext:                                   14.2 ( 2.78x)
v_loop_filter_unaligned_c:                              38.9 ( 1.00x)
v_loop_filter_unaligned_mmxext:                         14.3 ( 2.72x)

New benchmarks:
h_loop_filter_c:                                        29.2 ( 1.00x)
h_loop_filter_sse2:                                     28.6 ( 1.02x)
h_loop_filter_unaligned_c:                              29.0 ( 1.00x)
h_loop_filter_unaligned_sse2:                           26.9 ( 1.08x)
v_loop_filter_c:                                        38.3 ( 1.00x)
v_loop_filter_sse2:                                     11.0 ( 3.47x)
v_loop_filter_unaligned_c:                              35.5 ( 1.00x)
v_loop_filter_unaligned_sse2:                           11.2 ( 3.18x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-13 18:58:50 +02:00
Andreas Rheinhardt 5d9a392bce tests/checkasm: Add VP3 loop filter test
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-13 18:58:50 +02:00
zhanghongyuan 0bc54cddb1 fftools/opt_common: add long-form license option
Add "license" as a long-form command line option alongside the existing
"L" short option for showing license information. This maintains
consistent option naming patterns with other commands that provide both
short and long forms (help/?/help, etc.) and improves command line
usability by providing more descriptive option names.
2025-10-12 03:26:21 +00:00
Tong Wu 10e9672a8c avcodec/d3d12va_encode: use macros to set QP range and max frame size
Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-10-12 01:50:57 +00:00
Andreas Rheinhardt 36f92206bb avcodec/x86/hpeldsp: Improve ff_{avg,put}_pixels8_xy2_ssse3()
This SSSE3 function uses MMX registers (of course without emms
at the end) and processes eight bytes of input by unpacking
it into two MMX registers. This is very suboptimal given
that one can just use XMM registers to process eight words.
This commit switches them to using XMM registers.

Old benchmarks:
avg_pixels_tab[1][3]_c:                                114.5 ( 1.00x)
avg_pixels_tab[1][3]_ssse3:                             43.6 ( 2.62x)
put_pixels_tab[1][3]_c:                                 83.6 ( 1.00x)
put_pixels_tab[1][3]_ssse3:                             34.0 ( 2.46x)

New benchmarks:
avg_pixels_tab[1][3]_c:                                115.3 ( 1.00x)
avg_pixels_tab[1][3]_ssse3:                             24.6 ( 4.69x)
put_pixels_tab[1][3]_c:                                 83.8 ( 1.00x)
put_pixels_tab[1][3]_ssse3:                             19.7 ( 4.24x)

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-12 02:45:37 +02:00
Andreas Rheinhardt 4c55724da8 avcodec/x86/hpeldsp: Add ff_put_no_rnd_pixels8_xy2_ssse3()
Given that one has to deal with 16 byte intermediates it is
unsurprising that SSE2 wins against MMX; the MMX version has
therefore been removed (as well as the now unused inline_asm.h).
The new function is even 32B smaller than the old MMX one.

Old benchmarks:
put_no_rnd_pixels_tab[1][3]_c:                          84.1 ( 1.00x)
put_no_rnd_pixels_tab[1][3]_mmx:                        41.1 ( 2.05x)

New benchmarks:
put_no_rnd_pixels_tab[1][3]_c:                          84.0 ( 1.00x)
put_no_rnd_pixels_tab[1][3]_ssse3:                      22.1 ( 3.80x)

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-12 02:45:25 +02:00
Andreas Rheinhardt f84e06026a avcodec/x86/hpeldsp: Add SSE2 of {avg,put} no_rnd xy2 with blocksize 16
Also remove the now superseded MMX versions (the new functions have the
exact same codesize as the removed ones).

Old benchmarks:
avg_no_rnd_pixels_tab[0][3]_c:                         233.7 ( 1.00x)
avg_no_rnd_pixels_tab[0][3]_mmx:                       121.5 ( 1.92x)
put_no_rnd_pixels_tab[0][3]_c:                         171.4 ( 1.00x)
put_no_rnd_pixels_tab[0][3]_mmx:                        82.6 ( 2.08x)

New benchmarks:
avg_no_rnd_pixels_tab[0][3]_c:                         233.3 ( 1.00x)
avg_no_rnd_pixels_tab[0][3]_sse2:                       45.0 ( 5.18x)
put_no_rnd_pixels_tab[0][3]_c:                         172.1 ( 1.00x)
put_no_rnd_pixels_tab[0][3]_sse2:                       40.9 ( 4.21x)

Reviewed-by: Kieran Kunhya <kieran@kunhya.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-12 02:43:29 +02:00
Andreas Rheinhardt ce9d181444 avcodec/mjpegdec: Remove unnecessary reloads
Hint: The parts of this patch in decode_block_progressive()
and decode_block_refinement() rely on the fact that GET_VLC
returns -1 on error, so that it enters the codepaths for
actually coded block coefficients.

Reviewed-by: Ramiro Polla <ramiro.polla@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-11 08:20:42 +02:00
Andreas Rheinhardt dad06a445f avcodec/Makefile: Remove h263 decoder->mpeg4videodec.o dependency
Also prefer using #if CONFIG_MPEG4_DECODER checks in order not
to rely on DCE.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-11 07:51:01 +02:00
Andreas Rheinhardt 10d3479da0 avcodec/h263dec: Avoid redundant branch
Only the MPEG-4 decoder can have partitioned frames here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-11 07:51:01 +02:00
Andreas Rheinhardt d96f8d32ad avcodec/x86/h264_qpel: Don't instantiate unused functions
The v_lowpass wrappers (which are instantiated by this macro)
are only used in the put (and not the avg) form for SSSE3
(the avg form is only used for mc02, which doesn't exist
for SSSE3). Clang warns about the unused functions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-10 16:27:57 +02:00
Niklas Haas 6f1ab828d3 libavfilter/vf_libplacebo: add temperature option 2025-10-09 20:45:09 +00:00
Leo Izen eab3b68237 avcodec/exif: avoid printing errors for makernote non-IFD parsing
When we parse a MakerNote, we first try to parse it as an IFD and if
that fails, we try to re-parse it as a binary blob. This is because
MakerNote is not well-documented in its nature.

However, if we fail to parse it the first time, we should not av_log
error messages about the parse failure, so instead we log these as
AV_LOG_DEBUG.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Ramiro Polla <ramiro.polla@gmail.com>
2025-10-09 12:40:41 -04:00
James Almer 41c168444e avcodec/hevc/sei: don't attempt to use stale values in HEVCSEITimeCode
Invalidate the whole struct on SEI reset.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-09 12:09:35 -03:00
James Almer 8e01bff774 avcodec/hevc/sei: don't attempt to use stale values in HEVCSEITDRDI
Invalidate the whole struct on SEI reset.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-09 12:09:35 -03:00
James Almer d448d6d1a0 avcodec/hevc/sei: prevent storing a potentially bogus num_ref_displays value in HEVCSEITDRDI
Fixes: 439711052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-4956250308935680
Fixes: out of array access

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-09 12:09:35 -03:00
Jack Lau a934d48440 doc/muxers: correct default pkt_size value of whip
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:33:02 +00:00
Jack Lau b43f8dec18 avformat/whip: add macros to replace magic number
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau bc6164eb6f avformat/whip: remove WHIP_STATE_DTLS_CONNECTING
This value is only useful when dtls handshake is NONBLOCK mode,
dtls handshake just need to call ffurl_handshake once since it
force block mode.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau 76b13ca0a6 avformat/whip: check the peer whether is ice lite
See RFC 5245 Section 4.3
If an agent is a lite implementation, it MUST include an "a=ice-lite"
session-level attribute in its SDP.  If an agent is a full
implementation, it MUST NOT include this attribute.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 14:32:03 +00:00
Jack Lau ec0a04de0d avformat/whip: remind user increase -buffer_size
The udp buffer size might be too small to easily
be full temporarily and return WSAEWOULDBLOCK.
The udp code will handle the windows error code
and convert it to AVERROR(EAGAIN).

This issue just can be reproduced on windows.

If sleep a interval and retry to send pkt when hit
EAGAIN, it will increase latency, and appropriate
interval is hard to define.

So this patch just remind user increase the buffer
size via -buffer_size to avoid this issue.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:55:18 +00:00
Jack Lau b3793d9941 avformat/whip: pass through buffer_size option to udp
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:55:18 +00:00
Jack Lau 469aad3897 avformat/whip: add ICE consent freshness support
Refer to RFC 9725 4.2,
"Once a session is set up, consent freshness as per
[RFC7675] SHALL be used to detect non-graceful
disconnection by full ICE implementations and DTLS
teardown for session termination by either side"

Refer to RFC 7675,
send STUN Binding request every 5s,
expire consent after 30s without response,
terminate session when the consent expired.

TODO:
Random consent check interval (4-6s) will be
added later.

Co-authored-by: Sergio Garcia Murillo <sergio.garcia.murillo@gmail.com>
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:29:25 +00:00
Jack Lau aba84db96f avformat/whip: add WHIP_US_PER_MS macro to replace 1000
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-09 09:29:25 +00:00
Manuel Lauss aa91ae25b8 avcodec/sanm: minor comment and size detection changes
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss c46c1cb0db avcodec/sanm: remove rotate_code context member
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss 72df8f271d avcodec/sanm: implement 3 blits for codec37/47/48
The various game engines implement the following blit types, from the decoded
result to the main canvas:
- normal (opaque) blit (c37/c47/c48)
- masked blit (c37/c48)
- interpolated-frame blit (c48)
  Here an artificial frame is generated by looking up the pixels
  from both buffers and picking a color from the interpolation table
  for the artificial frame.
  This is only supported in the decoder of "Making Magic".

Implement and hook up these 3 schemes for each of the 3 compresstion types,
and switch codec20 to a call to the opaque blit function.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss d7d97ea32c avcodec/sanm: partially fix codec48 for Making Magic
Making Magic makes use of codec48 flag bit 0, which, when set,
means NOT to swap both buffers on even sequence numbers.

This fixes most of the artifacts in the Making Magic videos.
It's not complete though, bits 1 and 4 still need to be handled.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss 9e72b2f2d0 avcodec/sanm: codec37/47/48 updates
- align the incoming widths to 4(c37) / 8(c47/78) pixels. LucasArts
   game videos have these aligned.
- since these codecs use their 2/3 buffers for themselves, adjust the
  stride to the aligned width, keeping it even, which gets rid of
  an unaligned store in c48_4to8() found by the fuzzer with an
  odd stride.
- clear the whole diff buffer, not just the area described by w/h.
- adjust the RLE "decoded_size" to the product of the aligned width
   and reported height.

These changes are the result of various fuzzer-found issues; all my
test videos still work fine.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:02 +02:00
Manuel Lauss 0eb58e40cb avcodec/sanm: codec20 left/top offset support
Add left/top offsets and clipping to codec20 (raw images),
use it for the copying of codec37/47/48 images to main buffer.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss a108be2ba3 avcodec/sanm: for ANIM codecs with own buffers, really check dimensions
Codec37/47/48 have their own buffers; left/top are applied after
the decoding is done when copying to the main buffer.  Don't add left/top
to their width/height when doing checks against the established buffer sizes.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss b6a9c4671a avcodec/sanm: reimplement XPAL algorithm identical to DOS smush engine
This implements XPAL the same way the DOS/Windows players do, with an
additional 768-entry table holding the palette left-shifted by 7 bits,
and adding the deltapal values to this.

This results in a perfectly smooth day-to-night transition in the last
30 seconds of the Outlaws RAE.SAN (ending) video, while before there
were visible brightness "pulses" when a new palette was loaded.
It also fixes color banding in the The Dig Intro (sq1.san), in the
scene showing the shuttle launch pad and the night sky.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 4316914b39 avcodec/sanm: codec37: comp1: guard against invalid mv index
the c37 mvtable has only 255 pairs, change index 255 to zero to
avoid reading outside the table boundaries.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 5f1f5dd2d4 avcodec/sanm: guard against image area growing larger than buffer
When checking for oversized frames, check not only for the width
and height being larger, but also the area not outgrowing the
allocated buffer.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 556cef27d9 avcodec/sanm: enforce SANM min and max sizes at decode_init()
Enforce at least 8x8 and at max 800x600 for SANM/BL16.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 70b04717d0 avcodec/sanm: distrust dimensions for ANIM in decode_init
When decode_init() is called for ANIM content, zero the dimensions
set in avctx width/height. Only SANM files have image dimensions in
their header, while ANIM do not.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 0802044d81 avcodec/sanm: codec48: reimplement block scaling
Reimplement opcodes 0xFF and 0xFD the same way the c48 decoder
in the "Mysteries of the Sith" game engine does it:
The source pixel(s) and various pixels from inside the same and above
block of the second to last image rendered to the destination buffer
are used together with the interpolation table to generate a 4x4 pattern,
which is then expanded by doubling each pixel horizontally and vertically
to produce the final 8x8 block.

This fixes visible artifacts in frames 25-50 of the S1L1OCS.SAN
video of Mysteries of the Sith.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss b99b7a6f90 avcodec/sanm: change codec37 opcode FE to 4 2x2 blocks
It was initially implemented as 4 4x1 blocks, reimplement it as 4 2x2 blocks.
Fixes a few The Dig videos, esp. black dots on the asteroid in the
intro scene.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss d618577747 avcodec/sanm: check codec48 subblock mv index
Codec48 opcodes F9 and FC take per-subblock indices into the motion vector
table from the source stream, however the table has only 255 entries.
Luckily, index 255 is index 0 of the following table, which means no
motion vector, the same as index 0 of the current table.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss dd875f56b7 avcodec/sanm: invalidate STOR data when subversion changes
since the STOR data is a different format.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss b7e55ef8a1 avcodec/sanm: per-fobj GetByteContext
Create a separate GetByteContext from the general one, to be able
to limit the size of the FOBJ to the size described in the tag size.
Otherwise each fobj could theoretically use all the remaining data
in the FRME (which also contains audio, subtitles, ...).

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss a0c4dfc63b avcodec/sanm: handle FTCH on video start
some videos have a FTCH at the start of the video, to restore the
last image produced by the previous game file.  This leads to
ugly messages like these:

[sanm @ 0x7f18cc001980] [IMGUTILS @ 0x7f18d7ffe8e0] Picture size 0x0 is invalid
[sanm @ 0x7f18cc001980] video_get_buffer: image parameters invalid
[sanm @ 0x7f18cc001980] get_buffer() failed

Fix this by not setting the got_frame_ptr when there is nothing to
restore/fetch.  Seen with a lot of RA1 and the RA2 Level 11/12 videos.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:01 +02:00
Manuel Lauss 7c205b5397 avcodec/sanm: rename motion_vectors[] table to c47_mv[]
Rename the generic motion_vectors to c47_mv, as this vector table
was initially introduced with codec47 which predates bl16 by 1-2 years,
and bl16 is a development of codec47 (with a bit of c48 thrown in).

No functional change.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 3945d100ef avcodec/sanm: remove unused SANMFrameHeader
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 2ef26c30eb avcodec/sanm: implement BL16 subcodecs 1 and 7
Both of these encode a quarter-sized keyframe, with missing pixels
interpolated from the immediate neighbours.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss b1a7f8b7cf avcodec/sanm: factor out the ANIM decoding into separate function
Mainly for readability. No functional changes.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 49c552d066 avcodec/sanm: restructure SANM like the other block codecs
Restructe the SANM (or BL16 as LucasArts calls it) decoder to make it
look like the others, as it is basically a development of old_codec47
for rgb565 values.

No functional changes.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 4d5e87eaa4 Revert "avcodec/sanm: Check w,h,left,top"
This reverts commit 134fbfd1dc.

As it breaks valid uses of this in Rebel Assault 1 videos.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 75b6937527 avcodec/sanm: reset rotate_code every iteration
and eliminate the explicit reset in the other decoders that
don't need it.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss de7db62acc avcodec/sanm: rename process_block to codec47_block
the new name better indicates where it belongs to.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 043dafc4c2 avcodec/sanm: codec37/47/48 size checks
Add more size checks to old_codec37/47/48, esp. the headers.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss f98cd66b4b avcodec/sanm: codec47: read the small codebook
codec47 carries a 4-byte small codebook in its header. Read those
4 bytes into context member instead of awkwardly redirecting the
bytestream pointer every time it needs to be accessed.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 72e6206c88 avcodec/sanm: partially fix codec48
The mv check introduced with d5bdb0b705 broke MotS videos:
- their height (300 lines) is 37,5 blocks; unfortunately the videos try to
  access up to 1 block more.
  Extend the mv check to the aligned_height, which fixes most artifacts.
- don't return an error when an mv is invalid; rather skip the (subblock).
  Gets rid of almost all artifacts.

Some artifacts still remain, esp in space scenes where the original
encoder apparently fetched black pixels from outside of the aligned
height.  An increase of the buffer size by 8 lines will fix that later.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss 24ce42b406 avcodec/sanm: codec4 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss dfe4a0626f avcodec/sanm: codec31 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge
  this is especially noticeable in the e.g. O1OPEN.ANM, C1C3PO.ANM
  RA1 files with planets wrapping around.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:29:00 +02:00
Manuel Lauss da4b88494c avcodec/sanm: codec1 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge
  this is especially noticeable in the e.g. O1OPEN.ANM, C1C3PO.ANM
  RA1 files with planets wrapping around.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:28:59 +02:00
Manuel Lauss d18c25f1a9 avcodec/sanm: codec21 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:28:59 +02:00
Manuel Lauss 67b28acba3 avcodec/sanm: codec23 improvements
- don't draw outside the buffers
- don't wrap around when coordinates go over the edge

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-10-09 10:28:59 +02:00
Kacper Michajłow 3a8ea78b88 avutil/attributes: add AV_HAS_ATTRIBUTE
Maybe useful and to fix MSVC preprocessor warnings.

Fixes: afad332d77
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-09 06:25:06 +02:00
Zhao Zhili 9034ca30ef avformat/flacdec: fix self assign warning 2025-10-09 03:41:29 +00:00
Kacper Michajłow afad332d77 avutil/attributes: use __has_attribute to test for format attribute
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-09 03:35:16 +00:00
Kacper Michajłow 086597adae avutil/attributes: don't force format checking to __gnu_printf__ on mingw build
Use __MINGW_{PRINTF,SCANF}_FORMAT which matches the format check for
implementation that is actually used.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-10-09 03:35:16 +00:00
James Almer 4377affc28 avcodec/hevc/refs: don't unconditionally discard non-IRAP frames if no IRAP frame was seen before
Should fix issue #20661

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-09 02:52:46 +00:00
Andreas Rheinhardt 378d5bb08a avcodec/x86/fpel: Add blocksize x blocksize avg/put functions
This commit deduplicates the wrappers around the fpel functions
for copying whole blocks (i.e. height equaling width). It does
this in a manner which avoids having push/pop function arguments
when the calling convention forces one to pass them on the stack
(as in 32bit systems).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:53 +02:00
Andreas Rheinhardt ad498f9759 avcodec/x86/cavsdsp: Remove MMXEXT Qpeldsp
Superseded by SSE2. Saves about 11630B here.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt 650098955e avcodec/x86/cavs_qpel: Add SSE2 vertical motion compensation
This is not based on the MMXEXT one, because the latter is quite
suboptimal: Motion vector types mc01 and mc03 (vertical motion vectors
with remainder of one quarter or three quarter) use different neighboring
lines for interpolation: mc01 uses two lines above and two lines below,
mc03 one line above and three lines below. The MMXEXT code uses
a common macro for all of them and therefore reads six lines
before it processes them (even reading lines which are not used
at all), leading to severe register pressure.

Another difference to the old code is that the positive and negative
parts of the sum to calculate are accumulated separately and
the subtraction is performed with unsigned saturation, so
that one can avoid biasing the sum.

The fact that the mc01 and mc03 filter coefficients are mirrors
of each other has been exploited to reduce mc01 to mc03.

But of course the most important different difference between
this code and the MMXEXT one is that XMM registers allow to
process eight words at a time, ideal for 8x8 subblocks,
whereas the MMXEXT code processes them in 4x8 or 4x16 blocks.

Benchmarks:
avg_cavs_qpel_pixels_tab[0][4]_c:                      917.0 ( 1.00x)
avg_cavs_qpel_pixels_tab[0][4]_mmxext:                 222.0 ( 4.13x)
avg_cavs_qpel_pixels_tab[0][4]_sse2:                    89.0 (10.31x)
avg_cavs_qpel_pixels_tab[0][12]_c:                     885.7 ( 1.00x)
avg_cavs_qpel_pixels_tab[0][12]_mmxext:                223.2 ( 3.97x)
avg_cavs_qpel_pixels_tab[0][12]_sse2:                   88.5 (10.01x)
avg_cavs_qpel_pixels_tab[1][4]_c:                      222.4 ( 1.00x)
avg_cavs_qpel_pixels_tab[1][4]_mmxext:                  57.2 ( 3.89x)
avg_cavs_qpel_pixels_tab[1][4]_sse2:                    23.3 ( 9.55x)
avg_cavs_qpel_pixels_tab[1][12]_c:                     216.0 ( 1.00x)
avg_cavs_qpel_pixels_tab[1][12]_mmxext:                 57.4 ( 3.76x)
avg_cavs_qpel_pixels_tab[1][12]_sse2:                   22.6 ( 9.56x)
put_cavs_qpel_pixels_tab[0][4]_c:                      750.9 ( 1.00x)
put_cavs_qpel_pixels_tab[0][4]_mmxext:                 210.4 ( 3.57x)
put_cavs_qpel_pixels_tab[0][4]_sse2:                    84.2 ( 8.92x)
put_cavs_qpel_pixels_tab[0][12]_c:                     731.6 ( 1.00x)
put_cavs_qpel_pixels_tab[0][12]_mmxext:                210.7 ( 3.47x)
put_cavs_qpel_pixels_tab[0][12]_sse2:                   84.1 ( 8.70x)
put_cavs_qpel_pixels_tab[1][4]_c:                      191.7 ( 1.00x)
put_cavs_qpel_pixels_tab[1][4]_mmxext:                  53.8 ( 3.56x)
put_cavs_qpel_pixels_tab[1][4]_sse2:                    24.5 ( 7.83x)
put_cavs_qpel_pixels_tab[1][12]_c:                     179.1 ( 1.00x)
put_cavs_qpel_pixels_tab[1][12]_mmxext:                 53.9 ( 3.32x)
put_cavs_qpel_pixels_tab[1][12]_sse2:                   24.0 ( 7.47x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt 74a88c0c11 avcodec/x86/cavsdsp: Add SSE2 mc20 horizontal motion compensation
Basically a direct port of the MMXEXT one. The main difference
is of course that one can process eight pixels (unpacked to words)
at a time, leading to speedups.

avg_cavs_qpel_pixels_tab[0][2]_c:                      700.1 ( 1.00x)
avg_cavs_qpel_pixels_tab[0][2]_mmxext:                 158.1 ( 4.43x)
avg_cavs_qpel_pixels_tab[0][2]_sse2:                    86.0 ( 8.14x)
avg_cavs_qpel_pixels_tab[1][2]_c:                      171.9 ( 1.00x)
avg_cavs_qpel_pixels_tab[1][2]_mmxext:                  39.4 ( 4.36x)
avg_cavs_qpel_pixels_tab[1][2]_sse2:                    21.7 ( 7.92x)
put_cavs_qpel_pixels_tab[0][2]_c:                      525.7 ( 1.00x)
put_cavs_qpel_pixels_tab[0][2]_mmxext:                 148.5 ( 3.54x)
put_cavs_qpel_pixels_tab[0][2]_sse2:                    75.2 ( 6.99x)
put_cavs_qpel_pixels_tab[1][2]_c:                      129.5 ( 1.00x)
put_cavs_qpel_pixels_tab[1][2]_mmxext:                  36.7 ( 3.53x)
put_cavs_qpel_pixels_tab[1][2]_sse2:                    19.0 ( 6.81x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt 54598238e4 tests/checkasm: Add CAVS qpel test
This test already uncovered a bug in the vertical qpel motion
compensation code.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt cc2e2f12ca avcodec/x86/cavsdsp: Fix vertical qpel motion compensation
The prediction involves terms of the form
(-1 * s0 - 2 * s1 + 96 * s2 + 42 * s3 - 7 * s4 + 64) >> 7,
where the s values are in the range of 0..255.
The sum can have values in the range -2550..35190, which
does not fit into a signed 16bit integer. The code uses
an arithmetic right shift, which does not yield the correct
result for values >= 2^15; such values should be clipped
to 255, yet are clipped to 0 instead.

Fix this by shifting the values by 4096, so that the range
is positive, use a logical right shift and subtract 32.

bunny.mp4 from the FATE suite can be used to reproduce the problem.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Andreas Rheinhardt ec2fe94b3f avcodec/cavs: Remove unused parameter
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-08 20:40:08 +02:00
Michael Niedermayer 7896cc67c1 avcodec/exr: Check that DWA has 3 channels
The implementation hardcodes access to 3 channels, so we need to check that
Fixes: out of array access
Fixes: BIGSLEEP-445394503-crash.exr

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-08 00:27:49 +00:00
Michael Niedermayer c911e00011 avcodec/exr: Round dc_w/h up
Without rounding them up there are too few dc coeffs for the blocks.
We do not know if this way of handling odd dimensions is correct, as we have
no such DWA sample.
thus we ask the user for a sample if she encounters such a file

Fixes: out of array access
Fixes: BIGSLEEP-445392027-crash.exr

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-08 00:27:49 +00:00
Michael Niedermayer 8e078826da avcodec/exr: check ac_size
Fixes: out of array read
Fixes: dwa_uncompress.py.crash.exr

The code will read from the ac data even if ac_size is 0, thus that case
is not implemented and we ask for a sample and error out cleanly

Found-by: Google Big Sleep

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-08 00:27:49 +00:00
Baptiste Coudurier ef60d5ac32 general: fix warning 'av_malloc_array' sizes specified with 'sizeof'
in the earlier argument and not in the later argument [-Wcalloc-transposed-args]

Fixes trac ticket #11620
2025-10-07 14:51:46 -07:00
Andreas Rheinhardt 00225e9ebc avcodec/x86/h264_qpel: Simplify macros
1. Remove the OP parameter from the QPEL_H264* macros. These are
a remnant of inline assembly and were forgotten in
610e00b359.
2. Pass the instruction set extension for the shift5 function
explicitly in the macro instead of using magic #defines.
3. Likewise, avoid magic #defines for (8|16)_v_lowpass_ssse3.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 3049694e9f avcodec/x86/h264_qpel: Split hv2_lowpass_sse2 into size 8,16 funcs
This is beneficial size-wise: 384B of new asm functions are more
than outweighted by 416B savings from simpler calls here (for size 16,
the size 8 function had been called twice).
It also makes the code more readable, as it allowed to remove
several wrappers in h264_qpel.c.

It is also beneficial performance-wise. Old benchmarks:
avg_h264_qpel_16_mc12_8_c:                            1757.7 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          197.7 ( 8.89x)
avg_h264_qpel_16_mc12_8_ssse3:                         204.6 ( 8.59x)
avg_h264_qpel_16_mc21_8_c:                            1631.6 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          276.4 ( 5.90x)
avg_h264_qpel_16_mc21_8_ssse3:                         290.7 ( 5.61x)
avg_h264_qpel_16_mc22_8_c:                            1122.7 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2:                          179.5 ( 6.25x)
avg_h264_qpel_16_mc22_8_ssse3:                         181.8 ( 6.17x)
avg_h264_qpel_16_mc23_8_c:                            1626.7 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          276.8 ( 5.88x)
avg_h264_qpel_16_mc23_8_ssse3:                         290.9 ( 5.59x)
avg_h264_qpel_16_mc32_8_c:                            1754.1 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          193.8 ( 9.05x)
avg_h264_qpel_16_mc32_8_ssse3:                         203.6 ( 8.62x)
put_h264_qpel_16_mc12_8_c:                            1733.6 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          189.6 ( 9.14x)
put_h264_qpel_16_mc12_8_ssse3:                         199.6 ( 8.69x)
put_h264_qpel_16_mc21_8_c:                            1616.0 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          284.3 ( 5.69x)
put_h264_qpel_16_mc21_8_ssse3:                         296.5 ( 5.45x)
put_h264_qpel_16_mc22_8_c:                             963.7 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2:                          169.9 ( 5.67x)
put_h264_qpel_16_mc22_8_ssse3:                         186.1 ( 5.18x)
put_h264_qpel_16_mc23_8_c:                            1607.2 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          275.0 ( 5.84x)
put_h264_qpel_16_mc23_8_ssse3:                         297.8 ( 5.40x)
put_h264_qpel_16_mc32_8_c:                            1734.7 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          189.4 ( 9.16x)
put_h264_qpel_16_mc32_8_ssse3:                         199.4 ( 8.70x)

New benchmarks:
avg_h264_qpel_16_mc12_8_c:                            1743.7 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          189.7 ( 9.19x)
avg_h264_qpel_16_mc12_8_ssse3:                         204.4 ( 8.53x)
avg_h264_qpel_16_mc21_8_c:                            1637.7 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          267.7 ( 6.12x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.5 ( 5.62x)
avg_h264_qpel_16_mc22_8_c:                            1150.3 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2:                          164.6 ( 6.99x)
avg_h264_qpel_16_mc22_8_ssse3:                         182.1 ( 6.32x)
avg_h264_qpel_16_mc23_8_c:                            1635.3 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          268.5 ( 6.09x)
avg_h264_qpel_16_mc23_8_ssse3:                         298.5 ( 5.48x)
avg_h264_qpel_16_mc32_8_c:                            1740.6 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          182.6 ( 9.53x)
avg_h264_qpel_16_mc32_8_ssse3:                         201.9 ( 8.62x)
put_h264_qpel_16_mc12_8_c:                            1727.4 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          188.1 ( 9.18x)
put_h264_qpel_16_mc12_8_ssse3:                         199.6 ( 8.65x)
put_h264_qpel_16_mc21_8_c:                            1623.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          265.9 ( 6.11x)
put_h264_qpel_16_mc21_8_ssse3:                         299.4 ( 5.42x)
put_h264_qpel_16_mc22_8_c:                             954.0 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2:                          161.8 ( 5.89x)
put_h264_qpel_16_mc22_8_ssse3:                         180.4 ( 5.29x)
put_h264_qpel_16_mc23_8_c:                            1611.2 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          265.8 ( 6.06x)
put_h264_qpel_16_mc23_8_ssse3:                         300.3 ( 5.37x)
put_h264_qpel_16_mc32_8_c:                            1734.5 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          180.0 ( 9.63x)
put_h264_qpel_16_mc32_8_ssse3:                         199.7 ( 8.69x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 3ed590c7b9 avcodec/x86/h264_qpel: Port qpel8or16_hv2_lowpass_op_mmxext to SSE2
This means that only blocksize 4 still uses mmx(ext).

Old benchmarks:
avg_h264_qpel_8_mc12_8_c:                              428.4 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2:                            74.3 ( 5.77x)
avg_h264_qpel_8_mc12_8_ssse3:                           69.3 ( 6.18x)
avg_h264_qpel_8_mc21_8_c:                              401.4 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2:                            97.8 ( 4.10x)
avg_h264_qpel_8_mc21_8_ssse3:                           93.7 ( 4.28x)
avg_h264_qpel_8_mc22_8_c:                              281.8 ( 1.00x)
avg_h264_qpel_8_mc22_8_sse2:                            66.7 ( 4.23x)
avg_h264_qpel_8_mc22_8_ssse3:                           62.6 ( 4.50x)
avg_h264_qpel_8_mc23_8_c:                              397.2 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2:                            97.9 ( 4.06x)
avg_h264_qpel_8_mc23_8_ssse3:                           93.7 ( 4.24x)
avg_h264_qpel_8_mc32_8_c:                              432.4 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2:                            73.9 ( 5.85x)
avg_h264_qpel_8_mc32_8_ssse3:                           69.5 ( 6.22x)
avg_h264_qpel_16_mc12_8_c:                            1756.4 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          240.0 ( 7.32x)
avg_h264_qpel_16_mc12_8_ssse3:                         204.5 ( 8.59x)
avg_h264_qpel_16_mc21_8_c:                            1635.3 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          321.2 ( 5.09x)
avg_h264_qpel_16_mc21_8_ssse3:                         288.5 ( 5.67x)
avg_h264_qpel_16_mc22_8_c:                            1130.8 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2:                          219.4 ( 5.15x)
avg_h264_qpel_16_mc22_8_ssse3:                         182.2 ( 6.21x)
avg_h264_qpel_16_mc23_8_c:                            1622.5 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          321.3 ( 5.05x)
avg_h264_qpel_16_mc23_8_ssse3:                         289.5 ( 5.60x)
avg_h264_qpel_16_mc32_8_c:                            1762.5 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          236.1 ( 7.46x)
avg_h264_qpel_16_mc32_8_ssse3:                         205.2 ( 8.59x)
put_h264_qpel_8_mc12_8_c:                              427.2 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2:                            72.1 ( 5.93x)
put_h264_qpel_8_mc12_8_ssse3:                           67.0 ( 6.38x)
put_h264_qpel_8_mc21_8_c:                              402.9 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2:                            95.9 ( 4.20x)
put_h264_qpel_8_mc21_8_ssse3:                           91.9 ( 4.38x)
put_h264_qpel_8_mc22_8_c:                              235.0 ( 1.00x)
put_h264_qpel_8_mc22_8_sse2:                            64.6 ( 3.64x)
put_h264_qpel_8_mc22_8_ssse3:                           60.0 ( 3.92x)
put_h264_qpel_8_mc23_8_c:                              403.6 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2:                            95.9 ( 4.21x)
put_h264_qpel_8_mc23_8_ssse3:                           91.7 ( 4.40x)
put_h264_qpel_8_mc32_8_c:                              430.7 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2:                            72.1 ( 5.97x)
put_h264_qpel_8_mc32_8_ssse3:                           67.0 ( 6.43x)
put_h264_qpel_16_mc12_8_c:                            1724.2 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          230.7 ( 7.47x)
put_h264_qpel_16_mc12_8_ssse3:                         199.8 ( 8.63x)
put_h264_qpel_16_mc21_8_c:                            1613.3 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          327.5 ( 4.93x)
put_h264_qpel_16_mc21_8_ssse3:                         297.2 ( 5.43x)
put_h264_qpel_16_mc22_8_c:                             959.2 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2:                          211.9 ( 4.53x)
put_h264_qpel_16_mc22_8_ssse3:                         186.1 ( 5.15x)
put_h264_qpel_16_mc23_8_c:                            1619.0 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          319.7 ( 5.06x)
put_h264_qpel_16_mc23_8_ssse3:                         299.2 ( 5.41x)
put_h264_qpel_16_mc32_8_c:                            1741.7 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          230.9 ( 7.54x)
put_h264_qpel_16_mc32_8_ssse3:                         199.4 ( 8.74x)

New benchmarks:
avg_h264_qpel_8_mc12_8_c:                              427.2 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2:                            63.9 ( 6.69x)
avg_h264_qpel_8_mc12_8_ssse3:                           69.2 ( 6.18x)
avg_h264_qpel_8_mc21_8_c:                              399.2 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2:                            87.7 ( 4.55x)
avg_h264_qpel_8_mc21_8_ssse3:                           93.9 ( 4.25x)
avg_h264_qpel_8_mc22_8_c:                              285.7 ( 1.00x)
avg_h264_qpel_8_mc22_8_sse2:                            56.4 ( 5.07x)
avg_h264_qpel_8_mc22_8_ssse3:                           62.6 ( 4.56x)
avg_h264_qpel_8_mc23_8_c:                              398.6 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2:                            87.6 ( 4.55x)
avg_h264_qpel_8_mc23_8_ssse3:                           93.8 ( 4.25x)
avg_h264_qpel_8_mc32_8_c:                              425.8 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2:                            63.8 ( 6.67x)
avg_h264_qpel_8_mc32_8_ssse3:                           69.0 ( 6.17x)
avg_h264_qpel_16_mc12_8_c:                            1748.2 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          198.5 ( 8.81x)
avg_h264_qpel_16_mc12_8_ssse3:                         203.2 ( 8.60x)
avg_h264_qpel_16_mc21_8_c:                            1638.1 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          277.4 ( 5.91x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.1 ( 5.63x)
avg_h264_qpel_16_mc22_8_c:                            1140.7 ( 1.00x)
avg_h264_qpel_16_mc22_8_sse2:                          180.3 ( 6.33x)
avg_h264_qpel_16_mc22_8_ssse3:                         181.9 ( 6.27x)
avg_h264_qpel_16_mc23_8_c:                            1629.9 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          278.0 ( 5.86x)
avg_h264_qpel_16_mc23_8_ssse3:                         291.0 ( 5.60x)
avg_h264_qpel_16_mc32_8_c:                            1752.1 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          193.7 ( 9.05x)
avg_h264_qpel_16_mc32_8_ssse3:                         203.4 ( 8.61x)
put_h264_qpel_8_mc12_8_c:                              421.8 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2:                            61.7 ( 6.83x)
put_h264_qpel_8_mc12_8_ssse3:                           67.2 ( 6.28x)
put_h264_qpel_8_mc21_8_c:                              396.8 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2:                            85.4 ( 4.65x)
put_h264_qpel_8_mc21_8_ssse3:                           91.6 ( 4.33x)
put_h264_qpel_8_mc22_8_c:                              234.1 ( 1.00x)
put_h264_qpel_8_mc22_8_sse2:                            54.4 ( 4.30x)
put_h264_qpel_8_mc22_8_ssse3:                           60.2 ( 3.89x)
put_h264_qpel_8_mc23_8_c:                              399.2 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2:                            85.5 ( 4.67x)
put_h264_qpel_8_mc23_8_ssse3:                           91.8 ( 4.35x)
put_h264_qpel_8_mc32_8_c:                              422.2 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2:                            61.8 ( 6.83x)
put_h264_qpel_8_mc32_8_ssse3:                           67.0 ( 6.30x)
put_h264_qpel_16_mc12_8_c:                            1720.3 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          189.9 ( 9.06x)
put_h264_qpel_16_mc12_8_ssse3:                         199.9 ( 8.61x)
put_h264_qpel_16_mc21_8_c:                            1624.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          285.4 ( 5.69x)
put_h264_qpel_16_mc21_8_ssse3:                         296.4 ( 5.48x)
put_h264_qpel_16_mc22_8_c:                             963.9 ( 1.00x)
put_h264_qpel_16_mc22_8_sse2:                          170.1 ( 5.67x)
put_h264_qpel_16_mc22_8_ssse3:                         186.4 ( 5.17x)
put_h264_qpel_16_mc23_8_c:                            1613.5 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          274.6 ( 5.88x)
put_h264_qpel_16_mc23_8_ssse3:                         300.4 ( 5.37x)
put_h264_qpel_16_mc32_8_c:                            1735.9 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          189.6 ( 9.15x)
put_h264_qpel_16_mc32_8_ssse3:                         199.5 ( 8.70x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 617c042093 avcodec/x86/h264_qpel_8bit: Avoid doing unnecessary work
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 29f439077a avcodec/h264_qpel: Move loop into qpel4_hv_lowpass_v_mmxext()
Every caller calls it three times in a loop, with slightly
modified arguments. So it makes sense to move the loop
into the callee.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 4539f7e4d4 avcodec/x86/h264_qpel_8bit: Don't duplicate qpel4_hv_lowpass_v_mmxext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 3e2d9b73c1 avcodec/h264qpel: Move Snow-only code to snow.c
Blocksize 2 is Snow-only, so move all the code pertaining
to it to snow.c. Also make the put array in H264QpelContext
smaller -- it only needs three sets of 16 function pointers.
This continues 6eb8bc4217
and b0c91c2fba.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Andreas Rheinhardt 15a4289b79 avcodec/x86/h264_qpel_8bit: Improve register allocation
None of the other registers need to be preserved at this time,
so six XMM registers are always enough. Forgotten in
fa9ea5113b.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 18:06:40 +02:00
Zhao Zhili c7815a4b70 avfilter/vf_chromakey: specify alphamode of chromakey filter
Fix assert failure with:
ffmpeg -i input.mp4 \
	-vf chromakey=similarity=0.1,format=yuva420p,alphaextract \
	-f null -

Assertion frame->alpha_mode == link->alpha_mode failed at src/libavfilter/avfilter.c:1085
2025-10-07 16:00:27 +00:00
Zhao Zhili ba9c635784 avfilter/vf_chromakey_cuda: specify alpha_mode of output
Fix assert failure with:

ffmpeg -init_hw_device cuda=gpu -filter_hw_device gpu \
	-i input.mp4 -an \
	-vf hwupload,format=cuda,chromakey_cuda=color=black,hwdownload,format=yuva420p,alphaextract \
	-f null -

Assertion frame->alpha_mode == link->alpha_mode failed at src/libavfilter/avfilter.c:1085
2025-10-07 16:00:27 +00:00
Zhao Zhili 027497891b avfilter/vf_chromakey_cuda: simplify frame management 2025-10-07 16:00:27 +00:00
Zhao Zhili bb3a4de5a7 avfilter/vf_bilateral_cuda: remove a goto which has no effect 2025-10-07 16:00:27 +00:00
Zhao Zhili 4e27a4ba03 avfilter/vf_bilateral_cuda: remove some variables and redundant operations
Since output format is equal to input format, there is no point to
save two groups of fmt and desc.
2025-10-07 16:00:27 +00:00
Zhao Zhili d5f0c55f3f avfilter/vf_bilateral_cuda: don't create a new hwframe_ctx
There is no change on properties, so just reference the input
link's hwframe ctx.
2025-10-07 16:00:27 +00:00
Zhao Zhili adf51312ee avfilter/vf_bilateral_cuda: simplify frame management 2025-10-07 16:00:27 +00:00
Zhao Zhili a91cf4f38f avfilter/vf_bilateral_cuda: simplify the checking of window_size 2025-10-07 16:00:27 +00:00
Zhao Zhili 2749f5f91e avfilter/vf_bilateral_cuda: remove write only variable 2025-10-07 16:00:27 +00:00
Andreas Rheinhardt dcfef80bd9 avcodec/pngenc: Mark unreachable default switch cases as such
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-07 17:36:25 +02:00
James Almer 660983b7f3 avformat/mccenc: use Lavf version string instead of FFmpeg
The muxed subtitle is created by libavformat, and as such that's what should be
reported. This is in line with the string we write for every other muxer.
After this change, the muxer will no longer be recompiled every time a commit
is made.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-06 11:51:50 -03:00
James Almer 6231fa7fb7 avcodec/av1dec: don't emit a warning when parsing isobmff style extradata
No OBUs may be present and it's a valid scenario, so only warn when parsing raw
extradata.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 22:23:51 -03:00
James Almer 78a16e42bd avcodec/av1dec: don't overwrite container level color information if none is coded in the bitstream
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 13:22:23 -03:00
James Almer 009e4a1c20 avcodec/libdav1d: also consider user defined color information when selectiog pix_fmt
Fixes issue #20624.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 13:22:23 -03:00
James Almer 9b709532d5 avformat/demux: don't overwrite container level color information if set
If the information is coded at the container level, then that's what should be
exported. The user will still have access to values coded at the bitstream
level by firing a decoder.

Fixes issue #20121

Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 13:22:17 -03:00
James Almer 95850f339e tests/checkasm: add a test for dcadsp
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-05 10:09:04 -03:00
James Almer 99034b581f avcodec/dcadsp: constify lfe_samples parameter
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-04 14:18:30 -03:00
Andreas Rheinhardt e05f8acabf avfilter/blend_modes: Don't build duplicate functions
Some of the blend mode functions only depend on the underlying type
and therefore need only one version for 9, 10, 12, 14, 16 bits.
This saved 35104B with GCC and 26880B with Clang.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 17:49:08 +02:00
Andreas Rheinhardt ea346a23de avfilter/blend_modes: Use stride in bytes
The blend functions currently convert strides from bytes to elements
of the type by using the stride /= sizeof(pixel) idiom. Yet this has
several drawbacks:
1. It invokes undefined behavior that happens to work when stride is
negative: size_t is typically the unsigned type of ptrdiff_t and
therefore the division will be performed as size_t, i.e. use logical
right shifts, making stride very big when sizeof(pixel) is > 1. This
works, because pointer to pixel for accesses entails an implicit
factor of sizeof(pixel) so that everything is correct modulo SIZE_MAX.
Yet this is UB and UBSan complains about it.
2. It makes the compiler emit actual shifts/ands to discard the low bits
shifted away.
3. There may be systems where alignof(uint16_t) or alignof(float) is
strictly smaller than their sizeof, so that the stride (in bytes) is
not guaranteed to be multiple of these sizeofs. In this case, dividing
by sizeof(pixel) is simply wrong.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 17:49:08 +02:00
Andreas Rheinhardt 8fad52bd57 avcodec/x86/h264_qpel: Use ptrdiff_t for strides
Avoids having to sign-extend the strides in the assembly
(it also is more correct given that the qpel_mc_func
already uses ptrdiff_t).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 495c3d03ae avcodec/x86/h264_qpel_10bit: Remove SSE2 "cache64" duplicates
The horizontal 10bit MC SSE2 functions are currently duplicated:
They exist both in ordinary form as well as with a "sse2_cache64"
suffix. A comment in ff_h264qpel_init_x86() indicates that this
is due to older processors not liking accesses that cross cache
lines, yet these functions are identical to the non-cache64
functions (apart from the unavoidable changes in the rip-offset).

The only difference between these functions and the ordinary ones
are that the cache64 ones are created via a special form of the
INIT_XMM macro: "INIT_XMM sse2, cache64". This affects the name
and apparently defines cpuflags_cache64, yet nothing checks for
this, so both versions are identical. So remove the cache64 ones
and treat the remaining ones like ordinary SSE2 functions.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 697da64c8e avcodec/x86/h264_qpel: Port pixel8_l2_shift5 from MMXEXT to SSE2
This abides by the ABI (no missing emms) and yields a tiny
performance improvement here.

Old benchmarks:
avg_h264_qpel_8_mc12_8_c:                              419.9 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2:                            78.9 ( 5.32x)
avg_h264_qpel_8_mc12_8_ssse3:                           71.7 ( 5.86x)
avg_h264_qpel_8_mc32_8_c:                              429.1 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2:                            76.9 ( 5.58x)
avg_h264_qpel_8_mc32_8_ssse3:                           73.4 ( 5.84x)
put_h264_qpel_8_mc12_8_c:                              424.0 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2:                            78.6 ( 5.40x)
put_h264_qpel_8_mc12_8_ssse3:                           70.6 ( 6.00x)
put_h264_qpel_8_mc32_8_c:                              425.7 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2:                            75.2 ( 5.66x)
put_h264_qpel_8_mc32_8_ssse3:                           70.4 ( 6.05x)

New benchmarks:
avg_h264_qpel_8_mc12_8_c:                              425.7 ( 1.00x)
avg_h264_qpel_8_mc12_8_sse2:                            77.5 ( 5.49x)
avg_h264_qpel_8_mc12_8_ssse3:                           69.8 ( 6.10x)
avg_h264_qpel_8_mc32_8_c:                              423.7 ( 1.00x)
avg_h264_qpel_8_mc32_8_sse2:                            74.6 ( 5.68x)
avg_h264_qpel_8_mc32_8_ssse3:                           71.9 ( 5.89x)
put_h264_qpel_8_mc12_8_c:                              422.2 ( 1.00x)
put_h264_qpel_8_mc12_8_sse2:                            75.8 ( 5.57x)
put_h264_qpel_8_mc12_8_ssse3:                           67.9 ( 6.22x)
put_h264_qpel_8_mc32_8_c:                              421.8 ( 1.00x)
put_h264_qpel_8_mc32_8_sse2:                            72.6 ( 5.81x)
put_h264_qpel_8_mc32_8_ssse3:                           67.7 ( 6.23x)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 4ac9162beb avcodec/x86/h264_qpel: Don't use ff_ prefix for static functions
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt cd077e88d1 avcodec/x86/h264_qpel: Add ff_{avg,put}_h264_qpel16_h_lowpass_l2_sse2()
These functions are currently emulated via four calls to the versions
for 8x8 blocks. In fact, the size savings from the simplified calls
in h264_qpel.c (GCC 1344B, Clang 1280B) more than outweigh the size
of the added functions (512B) here.

It is also beneficial performance-wise. Old benchmarks:
avg_h264_qpel_16_mc11_8_c:                            1414.1 ( 1.00x)
avg_h264_qpel_16_mc11_8_sse2:                          206.2 ( 6.86x)
avg_h264_qpel_16_mc11_8_ssse3:                         177.7 ( 7.96x)
avg_h264_qpel_16_mc13_8_c:                            1417.0 ( 1.00x)
avg_h264_qpel_16_mc13_8_sse2:                          207.4 ( 6.83x)
avg_h264_qpel_16_mc13_8_ssse3:                         178.2 ( 7.95x)
avg_h264_qpel_16_mc21_8_c:                            1632.8 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          349.3 ( 4.67x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.3 ( 5.60x)
avg_h264_qpel_16_mc23_8_c:                            1640.2 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          351.3 ( 4.67x)
avg_h264_qpel_16_mc23_8_ssse3:                         290.8 ( 5.64x)
avg_h264_qpel_16_mc31_8_c:                            1411.7 ( 1.00x)
avg_h264_qpel_16_mc31_8_sse2:                          203.4 ( 6.94x)
avg_h264_qpel_16_mc31_8_ssse3:                         178.9 ( 7.89x)
avg_h264_qpel_16_mc33_8_c:                            1409.7 ( 1.00x)
avg_h264_qpel_16_mc33_8_sse2:                          204.6 ( 6.89x)
avg_h264_qpel_16_mc33_8_ssse3:                         178.1 ( 7.92x)
put_h264_qpel_16_mc11_8_c:                            1391.0 ( 1.00x)
put_h264_qpel_16_mc11_8_sse2:                          197.4 ( 7.05x)
put_h264_qpel_16_mc11_8_ssse3:                         176.1 ( 7.90x)
put_h264_qpel_16_mc13_8_c:                            1395.9 ( 1.00x)
put_h264_qpel_16_mc13_8_sse2:                          196.7 ( 7.10x)
put_h264_qpel_16_mc13_8_ssse3:                         177.7 ( 7.85x)
put_h264_qpel_16_mc21_8_c:                            1609.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          341.1 ( 4.72x)
put_h264_qpel_16_mc21_8_ssse3:                         289.2 ( 5.57x)
put_h264_qpel_16_mc23_8_c:                            1604.0 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          340.9 ( 4.71x)
put_h264_qpel_16_mc23_8_ssse3:                         289.6 ( 5.54x)
put_h264_qpel_16_mc31_8_c:                            1390.2 ( 1.00x)
put_h264_qpel_16_mc31_8_sse2:                          194.6 ( 7.14x)
put_h264_qpel_16_mc31_8_ssse3:                         176.4 ( 7.88x)
put_h264_qpel_16_mc33_8_c:                            1400.4 ( 1.00x)
put_h264_qpel_16_mc33_8_sse2:                          198.5 ( 7.06x)
put_h264_qpel_16_mc33_8_ssse3:                         176.2 ( 7.95x)

New benchmarks:
avg_h264_qpel_16_mc11_8_c:                            1413.3 ( 1.00x)
avg_h264_qpel_16_mc11_8_sse2:                          171.8 ( 8.23x)
avg_h264_qpel_16_mc11_8_ssse3:                         173.0 ( 8.17x)
avg_h264_qpel_16_mc13_8_c:                            1423.2 ( 1.00x)
avg_h264_qpel_16_mc13_8_sse2:                          172.0 ( 8.27x)
avg_h264_qpel_16_mc13_8_ssse3:                         173.4 ( 8.21x)
avg_h264_qpel_16_mc21_8_c:                            1641.3 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          322.1 ( 5.10x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.3 ( 5.63x)
avg_h264_qpel_16_mc23_8_c:                            1629.1 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          323.0 ( 5.04x)
avg_h264_qpel_16_mc23_8_ssse3:                         293.3 ( 5.55x)
avg_h264_qpel_16_mc31_8_c:                            1409.2 ( 1.00x)
avg_h264_qpel_16_mc31_8_sse2:                          172.0 ( 8.19x)
avg_h264_qpel_16_mc31_8_ssse3:                         173.7 ( 8.11x)
avg_h264_qpel_16_mc33_8_c:                            1402.5 ( 1.00x)
avg_h264_qpel_16_mc33_8_sse2:                          172.5 ( 8.13x)
avg_h264_qpel_16_mc33_8_ssse3:                         173.6 ( 8.08x)
put_h264_qpel_16_mc11_8_c:                            1393.7 ( 1.00x)
put_h264_qpel_16_mc11_8_sse2:                          170.4 ( 8.18x)
put_h264_qpel_16_mc11_8_ssse3:                         178.2 ( 7.82x)
put_h264_qpel_16_mc13_8_c:                            1398.0 ( 1.00x)
put_h264_qpel_16_mc13_8_sse2:                          170.2 ( 8.21x)
put_h264_qpel_16_mc13_8_ssse3:                         178.6 ( 7.83x)
put_h264_qpel_16_mc21_8_c:                            1619.6 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          320.6 ( 5.05x)
put_h264_qpel_16_mc21_8_ssse3:                         297.2 ( 5.45x)
put_h264_qpel_16_mc23_8_c:                            1617.4 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          320.0 ( 5.05x)
put_h264_qpel_16_mc23_8_ssse3:                         297.4 ( 5.44x)
put_h264_qpel_16_mc31_8_c:                            1389.7 ( 1.00x)
put_h264_qpel_16_mc31_8_sse2:                          169.9 ( 8.18x)
put_h264_qpel_16_mc31_8_ssse3:                         178.1 ( 7.80x)
put_h264_qpel_16_mc33_8_c:                            1394.0 ( 1.00x)
put_h264_qpel_16_mc33_8_sse2:                          170.9 ( 8.16x)
put_h264_qpel_16_mc33_8_ssse3:                         176.9 ( 7.88x)

Notice that the SSSE3 versions of mc21 and mc23 benefit from
an optimized version of hv2_lowpass.

Also notice that there is no SSE2 version of the purely horizontal
motion compensation. This means that src2 is currently always aligned
when calling the SSE2 functions (and that srcStride is always equal
to the block width). Yet this has not been exploited (yet).

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 4880fa4dca avcodec/x86/h264_qpel_8bit: Remove dead macro
Forgotten in 4011a76494.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 35aaf697e9 avcodec/x86/h264_qpel_8bit: Replace qpel8_h_lowpass_l2 MMXEXT by SSE2
Using xmm registers here is very natural, as it allows to
operate on eight words at a time. It also saves 48B here
and does not clobber the MMX state.

Old benchmarks (only tests affected by the modified function are shown):
avg_h264_qpel_8_mc11_8_c:                              352.2 ( 1.00x)
avg_h264_qpel_8_mc11_8_sse2:                            70.4 ( 5.00x)
avg_h264_qpel_8_mc11_8_ssse3:                           53.9 ( 6.53x)
avg_h264_qpel_8_mc13_8_c:                              353.3 ( 1.00x)
avg_h264_qpel_8_mc13_8_sse2:                            72.8 ( 4.86x)
avg_h264_qpel_8_mc13_8_ssse3:                           53.8 ( 6.57x)
avg_h264_qpel_8_mc21_8_c:                              404.0 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2:                           116.1 ( 3.48x)
avg_h264_qpel_8_mc21_8_ssse3:                           94.3 ( 4.28x)
avg_h264_qpel_8_mc23_8_c:                              398.9 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2:                           118.6 ( 3.36x)
avg_h264_qpel_8_mc23_8_ssse3:                           94.8 ( 4.21x)
avg_h264_qpel_8_mc31_8_c:                              352.7 ( 1.00x)
avg_h264_qpel_8_mc31_8_sse2:                            71.4 ( 4.94x)
avg_h264_qpel_8_mc31_8_ssse3:                           53.8 ( 6.56x)
avg_h264_qpel_8_mc33_8_c:                              354.0 ( 1.00x)
avg_h264_qpel_8_mc33_8_sse2:                            70.6 ( 5.01x)
avg_h264_qpel_8_mc33_8_ssse3:                           53.7 ( 6.59x)
avg_h264_qpel_16_mc11_8_c:                            1417.0 ( 1.00x)
avg_h264_qpel_16_mc11_8_sse2:                          276.9 ( 5.12x)
avg_h264_qpel_16_mc11_8_ssse3:                         178.8 ( 7.92x)
avg_h264_qpel_16_mc13_8_c:                            1427.3 ( 1.00x)
avg_h264_qpel_16_mc13_8_sse2:                          277.4 ( 5.14x)
avg_h264_qpel_16_mc13_8_ssse3:                         179.7 ( 7.94x)
avg_h264_qpel_16_mc21_8_c:                            1634.1 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          421.3 ( 3.88x)
avg_h264_qpel_16_mc21_8_ssse3:                         291.2 ( 5.61x)
avg_h264_qpel_16_mc23_8_c:                            1627.0 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          420.8 ( 3.87x)
avg_h264_qpel_16_mc23_8_ssse3:                         291.0 ( 5.59x)
avg_h264_qpel_16_mc31_8_c:                            1418.4 ( 1.00x)
avg_h264_qpel_16_mc31_8_sse2:                          278.5 ( 5.09x)
avg_h264_qpel_16_mc31_8_ssse3:                         178.6 ( 7.94x)
avg_h264_qpel_16_mc33_8_c:                            1407.3 ( 1.00x)
avg_h264_qpel_16_mc33_8_sse2:                          277.6 ( 5.07x)
avg_h264_qpel_16_mc33_8_ssse3:                         179.9 ( 7.82x)
put_h264_qpel_8_mc11_8_c:                              348.1 ( 1.00x)
put_h264_qpel_8_mc11_8_sse2:                            69.1 ( 5.04x)
put_h264_qpel_8_mc11_8_ssse3:                           53.8 ( 6.47x)
put_h264_qpel_8_mc13_8_c:                              349.3 ( 1.00x)
put_h264_qpel_8_mc13_8_sse2:                            69.7 ( 5.01x)
put_h264_qpel_8_mc13_8_ssse3:                           53.7 ( 6.51x)
put_h264_qpel_8_mc21_8_c:                              398.5 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2:                           115.0 ( 3.46x)
put_h264_qpel_8_mc21_8_ssse3:                           95.3 ( 4.18x)
put_h264_qpel_8_mc23_8_c:                              399.9 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2:                           120.8 ( 3.31x)
put_h264_qpel_8_mc23_8_ssse3:                           95.4 ( 4.19x)
put_h264_qpel_8_mc31_8_c:                              350.4 ( 1.00x)
put_h264_qpel_8_mc31_8_sse2:                            69.6 ( 5.03x)
put_h264_qpel_8_mc31_8_ssse3:                           54.2 ( 6.47x)
put_h264_qpel_8_mc33_8_c:                              353.1 ( 1.00x)
put_h264_qpel_8_mc33_8_sse2:                            71.0 ( 4.97x)
put_h264_qpel_8_mc33_8_ssse3:                           54.2 ( 6.51x)
put_h264_qpel_16_mc11_8_c:                            1384.2 ( 1.00x)
put_h264_qpel_16_mc11_8_sse2:                          272.9 ( 5.07x)
put_h264_qpel_16_mc11_8_ssse3:                         178.3 ( 7.76x)
put_h264_qpel_16_mc13_8_c:                            1393.6 ( 1.00x)
put_h264_qpel_16_mc13_8_sse2:                          271.1 ( 5.14x)
put_h264_qpel_16_mc13_8_ssse3:                         178.3 ( 7.82x)
put_h264_qpel_16_mc21_8_c:                            1612.6 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          416.5 ( 3.87x)
put_h264_qpel_16_mc21_8_ssse3:                         289.1 ( 5.58x)
put_h264_qpel_16_mc23_8_c:                            1621.3 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          416.9 ( 3.89x)
put_h264_qpel_16_mc23_8_ssse3:                         289.4 ( 5.60x)
put_h264_qpel_16_mc31_8_c:                            1408.4 ( 1.00x)
put_h264_qpel_16_mc31_8_sse2:                          273.5 ( 5.15x)
put_h264_qpel_16_mc31_8_ssse3:                         176.9 ( 7.96x)
put_h264_qpel_16_mc33_8_c:                            1396.4 ( 1.00x)
put_h264_qpel_16_mc33_8_sse2:                          276.3 ( 5.05x)
put_h264_qpel_16_mc33_8_ssse3:                         176.4 ( 7.92x)

New benchmarks:
avg_h264_qpel_8_mc11_8_c:                              352.1 ( 1.00x)
avg_h264_qpel_8_mc11_8_sse2:                            52.5 ( 6.71x)
avg_h264_qpel_8_mc11_8_ssse3:                           53.9 ( 6.54x)
avg_h264_qpel_8_mc13_8_c:                              350.8 ( 1.00x)
avg_h264_qpel_8_mc13_8_sse2:                            54.7 ( 6.42x)
avg_h264_qpel_8_mc13_8_ssse3:                           54.3 ( 6.46x)
avg_h264_qpel_8_mc21_8_c:                              400.1 ( 1.00x)
avg_h264_qpel_8_mc21_8_sse2:                            98.6 ( 4.06x)
avg_h264_qpel_8_mc21_8_ssse3:                           95.5 ( 4.19x)
avg_h264_qpel_8_mc23_8_c:                              400.4 ( 1.00x)
avg_h264_qpel_8_mc23_8_sse2:                           101.4 ( 3.95x)
avg_h264_qpel_8_mc23_8_ssse3:                           95.9 ( 4.18x)
avg_h264_qpel_8_mc31_8_c:                              352.4 ( 1.00x)
avg_h264_qpel_8_mc31_8_sse2:                            52.9 ( 6.67x)
avg_h264_qpel_8_mc31_8_ssse3:                           54.4 ( 6.48x)
avg_h264_qpel_8_mc33_8_c:                              354.5 ( 1.00x)
avg_h264_qpel_8_mc33_8_sse2:                            52.9 ( 6.70x)
avg_h264_qpel_8_mc33_8_ssse3:                           54.4 ( 6.52x)
avg_h264_qpel_16_mc11_8_c:                            1420.4 ( 1.00x)
avg_h264_qpel_16_mc11_8_sse2:                          204.8 ( 6.93x)
avg_h264_qpel_16_mc11_8_ssse3:                         177.9 ( 7.98x)
avg_h264_qpel_16_mc13_8_c:                            1409.8 ( 1.00x)
avg_h264_qpel_16_mc13_8_sse2:                          206.4 ( 6.83x)
avg_h264_qpel_16_mc13_8_ssse3:                         178.0 ( 7.92x)
avg_h264_qpel_16_mc21_8_c:                            1634.1 ( 1.00x)
avg_h264_qpel_16_mc21_8_sse2:                          349.6 ( 4.67x)
avg_h264_qpel_16_mc21_8_ssse3:                         290.0 ( 5.63x)
avg_h264_qpel_16_mc23_8_c:                            1624.1 ( 1.00x)
avg_h264_qpel_16_mc23_8_sse2:                          350.0 ( 4.64x)
avg_h264_qpel_16_mc23_8_ssse3:                         291.9 ( 5.56x)
avg_h264_qpel_16_mc31_8_c:                            1407.2 ( 1.00x)
avg_h264_qpel_16_mc31_8_sse2:                          205.8 ( 6.84x)
avg_h264_qpel_16_mc31_8_ssse3:                         178.2 ( 7.90x)
avg_h264_qpel_16_mc33_8_c:                            1400.5 ( 1.00x)
avg_h264_qpel_16_mc33_8_sse2:                          206.3 ( 6.79x)
avg_h264_qpel_16_mc33_8_ssse3:                         179.4 ( 7.81x)
put_h264_qpel_8_mc11_8_c:                              349.7 ( 1.00x)
put_h264_qpel_8_mc11_8_sse2:                            50.2 ( 6.96x)
put_h264_qpel_8_mc11_8_ssse3:                           51.3 ( 6.82x)
put_h264_qpel_8_mc13_8_c:                              349.8 ( 1.00x)
put_h264_qpel_8_mc13_8_sse2:                            50.7 ( 6.90x)
put_h264_qpel_8_mc13_8_ssse3:                           51.7 ( 6.76x)
put_h264_qpel_8_mc21_8_c:                              398.0 ( 1.00x)
put_h264_qpel_8_mc21_8_sse2:                            96.5 ( 4.13x)
put_h264_qpel_8_mc21_8_ssse3:                           92.3 ( 4.31x)
put_h264_qpel_8_mc23_8_c:                              401.4 ( 1.00x)
put_h264_qpel_8_mc23_8_sse2:                           102.3 ( 3.92x)
put_h264_qpel_8_mc23_8_ssse3:                           92.8 ( 4.32x)
put_h264_qpel_8_mc31_8_c:                              349.4 ( 1.00x)
put_h264_qpel_8_mc31_8_sse2:                            50.8 ( 6.88x)
put_h264_qpel_8_mc31_8_ssse3:                           51.8 ( 6.75x)
put_h264_qpel_8_mc33_8_c:                              351.1 ( 1.00x)
put_h264_qpel_8_mc33_8_sse2:                            52.2 ( 6.73x)
put_h264_qpel_8_mc33_8_ssse3:                           51.7 ( 6.79x)
put_h264_qpel_16_mc11_8_c:                            1391.1 ( 1.00x)
put_h264_qpel_16_mc11_8_sse2:                          196.6 ( 7.07x)
put_h264_qpel_16_mc11_8_ssse3:                         178.2 ( 7.81x)
put_h264_qpel_16_mc13_8_c:                            1385.2 ( 1.00x)
put_h264_qpel_16_mc13_8_sse2:                          195.6 ( 7.08x)
put_h264_qpel_16_mc13_8_ssse3:                         176.6 ( 7.84x)
put_h264_qpel_16_mc21_8_c:                            1607.5 ( 1.00x)
put_h264_qpel_16_mc21_8_sse2:                          341.0 ( 4.71x)
put_h264_qpel_16_mc21_8_ssse3:                         289.1 ( 5.56x)
put_h264_qpel_16_mc23_8_c:                            1616.7 ( 1.00x)
put_h264_qpel_16_mc23_8_sse2:                          340.8 ( 4.74x)
put_h264_qpel_16_mc23_8_ssse3:                         288.6 ( 5.60x)
put_h264_qpel_16_mc31_8_c:                            1397.6 ( 1.00x)
put_h264_qpel_16_mc31_8_sse2:                          197.3 ( 7.08x)
put_h264_qpel_16_mc31_8_ssse3:                         175.4 ( 7.97x)
put_h264_qpel_16_mc33_8_c:                            1394.3 ( 1.00x)
put_h264_qpel_16_mc33_8_sse2:                          197.7 ( 7.05x)
put_h264_qpel_16_mc33_8_ssse3:                         175.2 ( 7.96x)

As can be seen, the SSE2 version is often neck-to-neck with the SSSE3
version (which also benefits from a better hv2_lowpass SSSE3
implementation for mc21 and mc23) for eight byte block sizes.
Unsurprisingly, SSSE3 beats SSE2 for 16x16 blocks: For SSE2,
these blocks are processed by calling the 8x8 function four times
whereas SSSE3 has a dedicated function (on x64).
This implementation should also be extendable to an AVX version
for 16x16 blocks.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt fa9ea5113b avcodec/x86/h264_qpel_8bit: Optimize branch away
ff_{avg,put}_h264_qpel8or16_hv2_lowpass_ssse3()
currently is almost the disjoint union of the codepaths
for sizes 8 and 16. This size is a compile-time constant
at every callsite. So split the function and avoid
the runtime branch.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 400203c00c avcodec/x86/h264_qpel: Remove unused parameter from hv2_lowpass funcs
tmpstride is unused. This also allows to remove said parameter
from lots of functions in h264_qpel.c.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt b84c818c83 avcodec/x86/h264_qpel: Remove constant parameters from shift5 funcs
They are constant since the size 16 version is no longer emulated
via the size 8 version.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 810bd3e62a avcodec/x86/h264_qpel: Add ff_{avg,put}_pixels16_l2_shift5_sse2
Up until now this function was emulated via two calls
to ff_{avg,pull}_pixels8_l2_shift5_mmxext(). Adding a dedicated
function proved beneficial both size wise and performance wise:
The new functions take 192B, yet the simplified calls save
256B with GCC and 320B with Clang here.

This change will also allow further optimizations.

Old benchmarks:
avg_h264_qpel_16_mc12_8_c:                            1735.8 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          300.8 ( 5.77x)
avg_h264_qpel_16_mc12_8_ssse3:                         233.3 ( 7.44x)
avg_h264_qpel_16_mc32_8_c:                            1777.9 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          275.6 ( 6.45x)
avg_h264_qpel_16_mc32_8_ssse3:                         235.7 ( 7.54x)
put_h264_qpel_16_mc12_8_c:                            1808.2 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          267.2 ( 6.77x)
put_h264_qpel_16_mc12_8_ssse3:                         231.9 ( 7.80x)
put_h264_qpel_16_mc32_8_c:                            1766.9 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          272.9 ( 6.47x)
put_h264_qpel_16_mc32_8_ssse3:                         229.5 ( 7.70x)

New benchmarks:
avg_h264_qpel_16_mc12_8_c:                            1742.3 ( 1.00x)
avg_h264_qpel_16_mc12_8_sse2:                          240.3 ( 7.25x)
avg_h264_qpel_16_mc12_8_ssse3:                         214.8 ( 8.11x)
avg_h264_qpel_16_mc32_8_c:                            1748.0 ( 1.00x)
avg_h264_qpel_16_mc32_8_sse2:                          238.0 ( 7.35x)
avg_h264_qpel_16_mc32_8_ssse3:                         209.2 ( 8.35x)
put_h264_qpel_16_mc12_8_c:                            2014.4 ( 1.00x)
put_h264_qpel_16_mc12_8_sse2:                          243.7 ( 8.27x)
put_h264_qpel_16_mc12_8_ssse3:                         211.5 ( 9.52x)
put_h264_qpel_16_mc32_8_c:                            1800.0 ( 1.00x)
put_h264_qpel_16_mc32_8_sse2:                          238.8 ( 7.54x)
put_h264_qpel_16_mc32_8_ssse3:                         206.7 ( 8.71x)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 279b6f3cf5 avcodec/fpel: Avoid loop in ff_avg_pixels4_mmxext()
It is only used by h264_qpel.c and only with height four
(which is unrolled) and uses a loop in order to handle
multiples of four as height. Remove the loop and the height
parameter and move the function to h264_qpel_8bit.asm.
This leads to a bit of code duplication, but this is simpler
than all the %if checks necessary to achieve the same outcome
in fpel.asm.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt e340f31b89 avcodec/x86/fpel: Remove redundant repetition
The repetition count is always one since
2cf9e733c6.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt b0c91c2fba avcodec/h264qpel: Make avg_h264_qpel_pixels_tab smaller
avg_h264_qpel only supports 16x16,8x8 and 4x4 blocksizes,
so it is currently unnecessarily large.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 6eb8bc4217 avcodec/h264qpel: Don't build unused 2x2 size funcs for bitdepths > 8
The 2x2 put functions are only used by Snow and Snow uses
only the eight bit versions. The rest is dead code. Disabling
it saved 41277B here.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:33 +02:00
Andreas Rheinhardt 92ae9d1ffc configure: Remove vc1dsp->qpeldsp dependency
It only needs it for some x86 fpel functions; instead
add a direct dependency for that.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 16d5e074dc avcodec/mips/Makefile: Fix VC1DSP build rules
Affected standalone builds of the VC-1 parser.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt d09f4f3c78 configure: Remove h263_decoder->h263_parser,qpeldsp dependency
The former is unnecessary since
3ceffe7839. The latter is since
ff_mpeg4_workaround_bugs() (and thereby setting the "old" qpeldsp
functions) has been moved inside #if CONFIG_MPEG4_DECODER.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 0035d99c61 configure: Avoid mpeg4video_parser->{h263,qpel}dsp dependency
This can be easily achieved by moving code only used by the MPEG-4
decoder behind #if CONFIG_MPEG4_DECODER.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 770f78b24a configure: Remove mss2->qpeldsp dependency
Forgotten in 9cc38cc636.
(mss2 still has an implicit dependency on qpeldsp
via the VC-1 decoder.)

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt c4c616db53 avcodec/x86/qpel: Move ff_{put,avg}_pixels4_l2_mmxext to h264_qpel
Only used there.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 1e11fdff52 avcodec/x86/qpel{,dsp_init}: Remove constant function parameters
ff_avg_pixels{4,8,16}_l2_mmxext() are always called with height
equal to their blocksize. And ff_{put,avg}_pixels4_l2_mmxext()
are furthermore always called with both strides being equal.
So remove these redundant function parameters.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 52a77128fd avcodec/x86/qpel{dsp,dsp_init}: Use ptrdiff_t for stride
This is more correct given that qpel_mc_func already uses ptrdiff_t;
it also allows to avoid movsxdifnidn.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt cacf854fe7 avcodec/x86/qpel: Remove always-false branches
The ff_avg_pixels{4,8,16}_l2_mmxext() functions are only ever
used in the last step (the one that actually writes to the dst buffer)
where the number of lines to process is always equal to the
dimensions of the block, whereas ff_put_pixels{8,16}_mmxext()
are also used in intermediate calculations where the number of
lines can be 9 or 17.

The code in qpel.asm uses common macros for both and processes
more than one line per loop iteration; it therefore checks
for whether the number of lines is odd and treats this line separately;
yet this special handling is only needed for the put functions,
not the avg functions. It has therefore been %if'ed away for these.

The check is also not needed for ff_put_pixels4_l2_mmxext() which
is only used by H.264 which always processes four lines. Because
ff_{avg,put}_pixels4_l2_mmxext() processes four lines in a single loop
iteration, not only the odd-height handling, but the whole loop
could be removed.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 8820e2205c tests/checkasm/hpeldsp: Use instruction-set independent height
Otherwise the benchmark numbers are incomparable.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 9a0581fca0 tests/checkasm: Add qpeldsp checkasm
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 07:06:32 +02:00
Andreas Rheinhardt 15a9c8dea3 avcodec/liblc3enc: Avoid allocating buffer to send a zero frame
liblc3 supports arbitrary strides, so one can simply use a stride
of zero to make it read the same zero value again and again.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-04 06:07:37 +02:00
Andreas Rheinhardt ab7d1c64c9 avcodec/x86/h263_loopfilter: Port loop filter to SSE2
Old benchmarks:
h263dsp.h_loop_filter_c:                                41.2 ( 1.00x)
h263dsp.h_loop_filter_mmx:                              39.5 ( 1.04x)
h263dsp.v_loop_filter_c:                                43.5 ( 1.00x)
h263dsp.v_loop_filter_mmx:                              16.9 ( 2.57x)

New benchmarks:
h263dsp.h_loop_filter_c:                                41.6 ( 1.00x)
h263dsp.h_loop_filter_sse2:                             28.2 ( 1.48x)
h263dsp.v_loop_filter_c:                                42.4 ( 1.00x)
h263dsp.v_loop_filter_sse2:                             15.1 ( 2.81x)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-03 17:05:46 +00:00
Andreas Rheinhardt a8a16c15c8 tests/checkasm/llviddsp: Use the same width for each cpuflag
Otherwise the benchmark numbers would be incomparable nonsense.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-10-03 17:05:46 +00:00
Cameron Gutman df4587789f avcodec/amfenc: avoid unnecessary output delay in low delay mode
The code optimizes throughput by letting the encoder work on frame N
until frame N+1 is ready for submission, but this hurts low-delay uses
by delaying output by one frame. Don't delay output beyond what is
necessary when AV_CODEC_FLAG_LOW_DELAY is used.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-10-03 11:05:03 +00:00
Marton Balint f1d5114103 avformat/tls_openssl: do not cleanup tls after a successful dtls_start()
Regression since 8e11e2cdb8.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-02 18:41:47 +02:00
Michael Niedermayer 61b6877637 avcodec/mjpegdec: Explain buf_size/width/height check
Suggested-by: Ramiro

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-10-02 12:52:43 +00:00
Zhao Zhili 1a02412170 avformat/movenc_ttml: fix memleaks
Memory leaks can happen on normal case when break from while loop
early, and it can happen on error path with goto cleanup.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-10-01 22:31:03 +08:00
Romain Beauxis cb4052beae libavformat/oggparseopus.c: Parse comments from secondary chained streams header packet. 2025-10-01 14:20:55 +00:00
Romain Beauxis 45d7d5d3e2 libavformat/oggparseflac.c: Parse ogg/flac comments in new ogg packets, add them to ogg stream
new_metadata.
2025-10-01 14:20:55 +00:00
Romain Beauxis 7dbf7d2a45 libavformat/oggdec.c: Use AV_PKT_DATA_STRINGS_METADATA to pass metadata updates. 2025-10-01 14:20:55 +00:00
Romain Beauxis cebbb6ae8a libavformat/oggdec.h, libavformat/oggparsevorbis.c: Factor out vorbis metadata update mechanism. 2025-10-01 14:20:55 +00:00
Romain Beauxis de8d57e4c5 ogg/vorbis: implement header packet skip in chained ogg bitstreams. 2025-10-01 14:20:55 +00:00
James Almer 5511641365 avcodec/atrac9dec: use av_zero_extend()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-01 01:26:19 +00:00
James Almer 7ce3a14496 avcodec/apv_entropy: use av_zero_extend()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-01 01:26:19 +00:00
James Almer 776ee07990 avcodec/aom_film_grain: use av_zero_extend()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-01 01:26:19 +00:00
Marton Balint 8e11e2cdb8 avformat/tls_openssl: initialize underlying protocol early for dtls_start()
The same way we do with TLS, so all tls URL options will be properly supported.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 2762ae74c5 avformat/tls: use ff_parse_opts_from_query_string() to set URL parameters
Note that this changes the code to work the same way as other protocols where
an URL parameter can override an AVOption.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 3166e3b539 avformat/rtpproto: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint f231439ee7 avformat/sctp: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 49c6e6cc44 avformat/tcp: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 7e58fff9d0 avformat/udp: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 2d06ed9308 avformat/libsrt: use ff_parse_opts_from_query_string() to set URL parameters
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:19 +02:00
Marton Balint 70e0e3e257 avformat/utils: add helper function to set opts from query string
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-10-01 00:34:18 +02:00
Marton Balint c5be4b7075 avformat: compile urldecode unconditionally
It will be used by the generic helper function to set options from URLs.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-30 23:48:14 +02:00
Marton Balint 6f17053e6c avformat/urldecode: add ff_urldecode_len function
This will be used later to decode partial strings.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-30 23:48:14 +02:00
Michael Niedermayer 8cb1ff78ac avformat/dhav: Factorize some code in get_duration()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-30 21:13:56 +00:00
Niklas Haas b80f28fcbc avfilter/vf_libplacebo: introduce fit_sense option
This allows choosing whether the `fit_mode` merely controls the placement
of the image within the output resolution, or whether the output resolution
is also adjusted according to the given `fit_mode`.
2025-09-30 15:39:39 +00:00
Niklas Haas 12d696cff4 avfilter/vf_libplacebo: introduce fit_mode option
The semantics of these keywords are well-defined by the CSS 'object-fit'
property. This is arguably more user-friendly and less obtuse than the
existing `normalize_sar` and `pad_crop_ratio` options. Additionally, this
comes with two new (useful) behaviors, `none` and `scale_down`, neither of
which map elegantly to the existing options.

One additional benefit of this option is that, unlike `normalize_sar`, it
does *not* also imply `reset_sar`; meaning that users can now choose to
have an anamorphic base layer and still have the overlay images scaled to fit
on top of it according to the chosen strategy.

See-Also: https://drafts.csswg.org/css-images/#the-object-fit
2025-09-30 15:39:39 +00:00
Niklas Haas 6ad839ff2e avfilter/vf_scale_*: add enum names for force_oar magic values 2025-09-30 15:39:39 +00:00
Gyan Doshi 74115b017c doc: indicate libmpeghdec is non-free 2025-09-30 11:55:02 +00:00
Niklas Haas fd1fd5850d fftools/ffmpeg_sched: unchoke upstream nodes on recv-closed filter inputs
This allows upstream filters to observe EOF on their corresponding outputs
and terminate early, which is particularly useful for decoders and demuxers
that may then gracefully release their resources.

Prevents "leaking" memory for previously used, but now unused, filter inputs.
2025-09-30 13:16:59 +02:00
Niklas Haas d43fd5b332 fftools/ffmpeg_sched: close stream when sch_filter_send receives EOF
THis is currently done by sch_demux_send() (via demux_stream_send_to_dst()),
sch_enc_send() (via enc_send_to_dst()), and sch_dec_send() (via
dec_send_to_dst()), but not by sch_filter_send().

Implement the same queue-closing logic for them. The main benefit here is that
this will allow them to mark downstream inputs as send-done (in addition
to received-done), which is useful for a following commit.
2025-09-30 13:16:59 +02:00
Niklas Haas 56d9ca69d7 fftools/ffmpeg_dec: free decoder ctx after EOF
The codec context is no longer used after the decoder thread exits, but
still idly sticks around until program exit, wasting memory.
2025-09-30 13:16:59 +02:00
Niklas Haas 9d0b88feb1 fftools/ffmpeg_sched: forward demuxer choke status to dst queues
Cut off a choked demuxer's output codec/filter queues, effectively preventing
them from processing packets while the demuxer is choked. Avoids downstream
nodes from piling up extra input that a demuxer shouldn't currently be
sending.

The main benefit of this is to avoid queuing up excess packets that don't want
to be decoded yet, reducing memory consumption for idle inputs by preventing
them from being read earlier than needed.
2025-09-30 13:16:59 +02:00
Niklas Haas 59a847a237 fftools/thread_queue: allow choking thread queues directly
Currently, when a demuxer thread is choked, it will avoid queuing more
packets, but any packets already present on the thread queue will still be
processed.

This can be quite wasteful if the choke is due to e.g. decoder not being
needed yet, such as in a filter graph involving concatenation-style filters.
Adding the ability to propagate the choke status to the thread queue directly
allows downstream decoders and filter graphs to avoid unnecessary work and
buffering.

Reduces the effective latency between scheduler updates and changes in the
thread workfload.
2025-09-30 13:16:59 +02:00
Niklas Haas 5f4cbb5617 fftools/ffmpeg_sched: choke inputs during filtergraph configuration
Currently, while the filter graph is being initially created, the scheduler
continues demuxing frames on the last input that happened to be active before
the filter graph was complete.

This can lead to an excess number of decoded frames "piling" up on this input,
regardless of whether or not it will actually be requested by the configured
filter graph. Suspending the filter graph during this initialization phase
reduces the amount of wasted memory.
2025-09-30 13:16:59 +02:00
Niklas Haas 23f1f094f8 fftools/ffmpeg_sched: get rid of src_sched
This field is just saving (typically) a single pointer indirection; and IMO
makes the logic and graph relations unnecessarily complicated. I am also
considering adding choking logic to decoders and encoders as well, which this
field would get in the way of.

Apart from the unchoking logic in unchoke_for_input(), the only other place
that uses this field is the (cold) function check_acyclic(), which can be
served just as well with a simple function to do the graph traversal there.
2025-09-30 13:16:59 +02:00
Niklas Haas fd4b5b24ce fftools/ffmpeg_sched: lower default frame queue size
I tested this extensively under different conditions and could not come up
with any scenario where using a larger queue size was actually beneficial.
Moreover, having such a large default queue is very wasteful especially
for larger frame sizes; and can in the worst case lead to an extra ~50% memory
footprint per input (with the default 16 threads), regardless of whether that
input is currently in use or not.

My methodology was to add logging in the event of a queue underrun/overrun,
and then observe and then observe the frequency of such events in practice,
as well as the impact on performance. I came up with an example filter graph
involving decoding, filtering and encoding with several input files and
various changes to move the bottleneck around.

I found that, in all configurations I tested, with all thread counts and
bottlenecks, using a queue size of 2 frames yielded practically identical
performance to a queue size of 8 frames. I was only able to consistently
measure a slowdown when restricting the queue to a single frame, where the
underruns ended up making up almost 1.1% of frame events in the worst case.

A summary of my test log follows:

= Bottleneck in decoder =

ffmpeg -i A -i B -i C -filter_complex "concat=n=3" -f null -

== 16 threads ==

=== Queue statistics (dec -> filtergraph) ===
- 8 frames = 91355 underruns, 1 overrun
- 4 frames = 91381 underruns, 2 overruns
- 2 frames = 91326 underruns, 21 overruns
- 1 frame  = 91284 underruns, 102 overruns

=== Time elapsed ===
- 8 frames = 14.37s
- 4 frames = 14.28s
- 2 frames = 14.27s
- 1 frame  = 14.35s

== 1 thread ==

=== Queue statistics (dec -> filtergraph) ===
- 8 frames = 91801 underruns, 0 overruns
- 4 frames = 91929 underruns, 1 overrun
- 2 frames = 91854 underruns, 7 overruns
- 1 frame  = 91745 underrons, 83 overruns

=== Time elapsed ===
- 8 frames = 39.51s
- 4 frames = 39.94s
- 2 frames = 39.91s
- 1 frame  = 41.69s

= Bottleneck in filter graph: =

ffmpeg -i A -i B -i C -filter_complex "concat=n=3,scale=3840x2160" -f null -

== 16 threads ==

=== Queue statistics (dec -> filtergraph) ===
- 8 frames =  277 underruns, 84673 overruns
- 4 frames =  640 underruns, 86523 overruns
- 2 frames =  850 underruns, 88751 overruns
- 1 frame  = 1028 underruns, 89957 overruns

=== Time elapsed ===
- 8 frames = 26.35s
- 4 frames = 26.31s
- 2 frames = 26.38s
- 1 frame  = 26.55s

== 1 thread ==

=== Queue statistics (dec -> filtergraph) ===
- 8 frames = 29746 underruns, 57033 overruns
- 4 frames = 29940 underruns, 58948 overruns
- 2 frames = 30160 underruns, 60185 overruns
- 1 frame  = 30259 underruns, 61126 overruns

=== Time elapsed ===
- 8 frames = 52.08s
- 4 frames = 52.49s
- 2 frames = 52.25s
- 1 frame  = 52.69s

= Bottleneck in encoder: =

ffmpeg -i A -i B -i C -filter_complex "concat=n=3" -c:v libx264 -preset veryfast -f null -

== 1 thread ==

== Queue statistics (filtergraph -> enc) ==
- 8 frames = 26763 underruns, 63535 overruns
- 4 frames = 26863 underruns, 63810 overruns
- 2 frames = 27243 underruns, 63839 overruns
- 1 frame  = 27670 underruns, 63953 overruns

== Time elapsed ==
- 8 frames = 89.45s
- 4 frames = 89.04s
- 2 frames = 89.24s
- 1 frame  = 90.26s
2025-09-30 13:16:59 +02:00
Niklas Haas 15407cf90b fftools/ffmpeg_sched: relax queue size assertion
The code in the decoder just cares about allocating enough extra hw frames
to cover the size of the queue; but there's no reason we actually *have* to
use this many. We can safely relax the assertion to a <= check.
2025-09-30 13:16:59 +02:00
Nikolay Aleksandrov 1608aa38a2 doc/infra: More details about hosting and security
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

I have redacted the exact location of the FFmpeg server as writing
that in public seems just a bad idea
2025-09-30 13:14:03 +02:00
Koushik Dutta via ffmpeg-devel fd136a4d82 ffv1enc_vulkan: fix empty struct build error on msvc
Signed-off-by: Koushik Dutta <koushd@gmail.com>
2025-09-30 19:36:56 +09:00
Jack Lau bc561013c9 avformat/whip: add RTX initial support
Refer to RFC 4588.

Add and set the basic param of RTX like
ssrc, payload_type, srtp.

Modify the SDP to add RTX info so that
the peer be able to parse the RTX packet.

There are more pateches to make RTX really
work.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-30 05:42:40 +00:00
Gyan Doshi f1e9032a20 configure: unbreak glslang build
Don't unconditionally link to libSPVRemapper which was removed in 16.0 in 3a7f787
2025-09-30 04:26:18 +00:00
James Almer d975dbd7b7 avcodec/libdav1d: bump minimum supported version to 1.0.0
This allows us to remove old deprecated options.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-28 23:53:27 -03:00
Kaarle Ritvanen 0fdb5829e3 avformat/rtsp: set AVFMTCTX_UNSEEKABLE flag
for live RTP streams. Some external applications, such as Qt Multimedia,
depend on this flag being set correctly.

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
2025-09-28 13:37:43 +00:00
Rémi Denis-Courmont dd977adcfe Add myself to CODEOWNERS 2025-09-28 12:35:14 +00:00
Andreas Rheinhardt 635cb4543f avcodec/bsf/ahx_to_mp2: Don't output uninitialized data
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-27 17:57:15 +02:00
Andreas Rheinhardt 8a34faa250 swscale/ppc/swscale_ppc_template: Fix av_unused placement
Forgotten in d6cb0d2c2b.

Reviewed-by: Sean McGovern <gseanmcg@gmail.com>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 22:38:13 +02:00
Andreas Rheinhardt 0f1f345c37 avcodec/x86/qpeldsp_init: Fix compilation without external assembly
Broken in 2cf9e733c6.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 18:30:53 +02:00
Kacper Michajłow 941eae01b1 avutil/attributes: prefer clang attributes even in non-gnu builds
In MSVC mode Clang doesn't define __GNUC__, but we can still attributes.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
Kacper Michajłow b7ab357db4 avutil/attributes: use standard attributes when they are available
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
Kacper Michajłow a7f0377a3d avutil/attributes: add AV_HAS_STD_ATTRIBUTE
For testing language standard attributes, for both C++ and C.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
Kacper Michajłow d6cb0d2c2b ALL: move av_unused to conform with standard requirement
This is required placement by standard [[maybe_unused]] attribute, works
the same for __attribute__((unused)).

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-26 16:15:46 +00:00
James Almer b9cc8e3210 avfilter/vf_scale: don't attempt to rescale AV_NOPTS_VALUE
Finishes fixing issue #20589.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-26 12:24:04 -03:00
James Almer 5614672d1b avfilter/framesync: don't attempt to rescale AV_NOPTS_VALUE
Part of a fix for issue #20589.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-26 12:24:04 -03:00
Sean McGovern c605d2a7ae MAINTAINERS: add me for Linux / PowerPC architecture 2025-09-26 13:16:53 +00:00
Sean McGovern 9ed6503b62 MAINTAINERS: add my OpenPGP key
My key is available at:

https://keys.openpgp.org/vks/v1/by-fingerprint/6D03BC603A33E6156E2E06AD8C0681756F598684

and

https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x6d03bc603a33e6156e2e06ad8c0681756f598684
2025-09-26 13:16:53 +00:00
Timo Rothenpieler 994a368451 configure: deprecate support for libnpp 2025-09-26 12:31:39 +00:00
Andreas Rheinhardt a54d6b1d91 avcodec/x86/rnd_template: Merge into hpeldsp_init.c
It is now only included exactly once.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:58 +02:00
Andreas Rheinhardt 43fe9554cc avcodec/x86/hpeldsp_init: Avoid complicating macro
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:55 +02:00
Andreas Rheinhardt 00e046df13 avcodec/x86/hpeldsp_init: Remove MMX(EXT) funcs overridden by SSE2
This affects the {avg,put}_no_rnd_pixels16_{x,y}2 MMX and
(put-only) MMXEXT versions. Removing these functions saved
1184B here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:53 +02:00
Andreas Rheinhardt 30c4007c65 avcodec/x86/hpeldsp: Add SSE2 avg_no_rnd size 16 versions
These currently only exist as MMX versions.
The added functions occupy 320B here. So far, they are only for
the x2 and y2 (i.e. right and down, not down-right) directions.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:49 +02:00
Andreas Rheinhardt 1e677e6964 avcodec/x86/hpeldsp: Add SSE2 put_no_rnd size 16 versions
These currently only exist as MMX and (not bitexact) MMXEXT versions.
The added functions occupy 288B here. So far, they are only for
the x2 and y2 (i.e. right and down, not down-right) directions.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:46 +02:00
Andreas Rheinhardt 262791b8d8 avcodec/hpeldsp: Make put_no_rnd_pixels_tab smaller
Only the blocksizes 16 and 8 are implemented, yet the motion estimation
code touches the blocksize 4 entries. But really nothing touches
the blocksize 2 entries, so that we can reduce the put_no_rnd_pixels_tab
array size to [3][4].

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:43 +02:00
Andreas Rheinhardt c7161befb4 avcodec/x86/h264_qpel: Remove MMX(EXT) funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:39 +02:00
Andreas Rheinhardt 4fc05c28f4 avfilter/x86/vf_gradfun: Remove MMXEXT func overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 version
of filter_line.
This commit therefore removes the overridden MMXEXT version
(which didn't abide by the ABI) which allows us to remove
an emms_c() from vf_gradfun.c, so that users with SSSE3 no longer
pay a price for the mere existence of an MMXEXT version.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:35 +02:00
Andreas Rheinhardt 5ef613bcb0 avcodec/x86/mpegvideoencdsp_init: Remove MMX, 3DNOw funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX and 3DNOW functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Also merge the mpegvideoenc_qns_template.c file into the main file.

The 3DNOW functions removed in this commit were the last in the
codebase.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:31 +02:00
Andreas Rheinhardt 6a47ea5f9f avcodec/x86/vvc/sao_10bit: Remove unused functions
Saves 65280B here.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:26 +02:00
Andreas Rheinhardt 918d37d9d1 avcodec/x86/rv40dsp_init: Remove MMX(EXT) funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:23 +02:00
Andreas Rheinhardt e86f137514 avcodec/x86/hpeldsp_init: Remove MMX(EXT) funcs overridden by SSSE3
SSSE3 is already quite old (introduced 2006 for Intel, 2011 for AMD),
so that the overwhelming majority of our users (particularly those
that actually update their FFmpeg) will be using the SSSE3 versions.
This commit therefore removes the MMX(EXT) functions overridden
by them (which don't abide by the ABI) to get closer to a removal
of emms_c.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:19 +02:00
Andreas Rheinhardt 2cf9e733c6 avcodec/x86/qpeldsp_init: Use SSE2 versions where possible
The mc00 versions (i.e. the qdsp functions with no subpixel
interpolation) are just wrappers around their fpel versions.
There are SSE2 versions of these, yet the qpel code only
uses the MMX(EXT) versions. This commit changes this and
also removes the MMX(EXT) versions.

This also allowed to remove ff_avg_pixels16_mmxext,
ff_put_pixels16_mmx.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:16 +02:00
Andreas Rheinhardt 1f9ef6a8dc avcodec/x86/h264_qpel: Remove MMX(EXT) functions overridden by SSE2FAST
CPUs which support SSE2, but not in a fast way (so that
they get the additional AV_CPU_FLAG_SSE2SLOW) are ancient
nowadays (2007 and older), so ignore the distinction between
the two and remove MMX and MMXEXT functions that are now
overridden by SSE2 functions.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:12 +02:00
Andreas Rheinhardt 8a7858dacf avcodec/x86/hpeldsp_init: Remove MMX(EXT) functions overridden by SSE2FAST
CPUs which support SSE2, but not in a fast way (so that
they get the additional AV_CPU_FLAG_SSE2SLOW) are ancient
nowadays (2007 and older), so ignore the distinction between
the two and remove MMX and MMXEXT functions that are now
overridden by SSE2 functions.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:08 +02:00
Andreas Rheinhardt 4d691da5ed avcodec/x86/hpeldsp_init: Remove MMX functions overridden by MMXEXT
Forgotten in a51279bbde because
I only looked for MMX(EXT) functions overridden by SSE2.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:04 +02:00
Andreas Rheinhardt 4e2ef29cba tests/checkasm: Add hpeldsp checkasm
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:21:02 +02:00
Andreas Rheinhardt fcb9e0b5f0 avcodec/hpel{dsp,_template}: Use ptrdiff_t for strides
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:20:56 +02:00
Andreas Rheinhardt 89f2016ece avcodec/hpel_template: Fix unintentional usage of unsigned offsets
The value of sizeof() is of type size_t which means that
an expression like
src1[i * src_stride1 + 4 * (int)sizeof(pixel)]
will use a very large offset if src_stride1 is sufficiently negative.
It works in practice (because it is correct modulo SIZE_MAX),
but UBSan treats it as error:
libavcodec/hpel_template.c:104:1: runtime error: addition of unsigned offset to 0x7ffdfa0391d8 overflowed to 0x7ffdfa0391cc
Fix this by casting sizeof(pixel) to int.

(This has been uncovered by a checkasm test for the hpeldsp
which will be added in a later commit.)

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:20:52 +02:00
Andreas Rheinhardt b316a1bdd1 avcodec/hpeldsp: Fix documentation
This commit fixes two issues in the documentation:
a) The documentation for {put,avg}_pixels_tab only mentions
widths 16 and 8, although it explicitly mentions that there
are four horizontal blocksizes. This part of the patch
basically reverts e5771f4f37.
b) The restrictions on height don't match the reality. While
most users abide by it, some do not:
i) vp56.c copies a 16x12 block.
ii) indeo3 can copy an arbitrary multiple of four lines
for block widths 4, 8 and 16.
iii) SVQ3 can use block sizes luma block sizes 16x16, 8x16,
16x8, 8x8, 4x8, 8x4 and 4x4 and the corresponding
8x8, 4x8, 8x4, 4x4, 2x4, 4x2 and 2x2 chroma block sizes.

This implies that for widths 2 and 4 height can be two
and is guaranteed to be at least even. For all other widths,
height can be a multiple of four.

Furthermore, a comment for the SVQ3 blocksizes has been added.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:20:30 +02:00
Andreas Rheinhardt baace56169 avfilter/vf_tonemap_opencl: Make array smaller
Also makes the code more independent of AVCOL_TRC_NB.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:00:43 +02:00
Andreas Rheinhardt f0586ffa95 avfilter/vf_colorspace: Make array smaller
Also makes it more independent of AVCOL_TRC_NB.

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 06:00:14 +02:00
Andreas Rheinhardt 188440929d avcodec/libmpeghdec: Check channel layouts generically
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:38:46 +02:00
Andreas Rheinhardt ca7679c82f avcodec/libmpeghdec: Don't set AVCodecContext.frame_size
It indicates a constant frame size (in samples); yet the documentation
of the MPEGH_DECODER_OUTPUT_INFO structure says that it
"gives information about the currently decoded audio data"
and makes no guarantees about it being constant.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:38:41 +02:00
Andreas Rheinhardt 7cd0641a99 avcodec/libmpeghdec: Align FFCodec initializers
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:38:37 +02:00
Andreas Rheinhardt 0ec21ea8d0 avcodec/libmpeghdec: Remove always-false check
The pointer to the decoder is always set after init has been
called successfully.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:38:32 +02:00
Andreas Rheinhardt f46bd4add2 avcodec/libmpeghdec: Don't use too big buffer
The channel count is fixed, so we don't need to allocate
space to hold samples for nonexisting channels. This also
means that the maximum channel count is no longer hardcoded
in the macro.
Also switch to decoder_buffer_size to be samples-based.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:37:55 +02:00
Andreas Rheinhardt 60b88e75e4 avcodec/libmpeghdec: Inline constant
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:37:51 +02:00
Andreas Rheinhardt a98f75d22c avcodec/libmpeghdec: Don't set AVCodec.sample_fmts
It is mostly pointless for decoders (only useful for those
codecs for which a floating-point and a fixed-point decoder
exist).

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:37:30 +02:00
Andreas Rheinhardt 839042b0c0 avcodec/libmpeghdec: Remove private class
This decoder doesn't have any options.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:37:24 +02:00
Andreas Rheinhardt b8f341ff05 avcodec/libmpeghdec: Remove redundant manual close calls
This decoder has the INIT_CLEANUP flag set.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-26 05:36:42 +02:00
James Almer 6d8732f397 avformat/movenc: clear subsample information on fragment flush
Don't keep around information from a previous traf atom.

Fixes issue #20492.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-25 23:18:08 -03:00
Kacper Michajłow fa72f9a292 forgejo/workflows: include size and mtime in cache hash
In case some file has been updated. Generally fate samples shouldn't be
replaced to preserve compatibility with older revisions, but before
merge it may happen that files is replaced.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-25 21:51:03 +02:00
Kacper Michajłow f40766da45 configure: suppress C4267 warnings from MSVC
Suppresses implicit integer conversion narrowing warnings:
warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data

Those implicit conversions are abundant in ffmpeg's code base.
Additionally equivalent warnings are not enabled for GCC/Clang by
default, so they are mostly left unfixed.

Suppress reports about them to reduce noise in MSVC build log.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-25 18:02:44 +00:00
Leo Izen 2c8835dd72 avcodec/libjxldec: submit frame after file is complete
This commit causes the libjxl decoder wrapper to hold onto the decoded
frame until the trailing metadata after the frame is possibly complete
before it submits the frame. This allows EXIF and other metadata boxes
that occur after the frame is fully rendered to be attached to it as
side data.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-09-25 12:40:57 -04:00
Vittorio Palmisano 9970dc32bf avfilter/af_whisper: fix srt index
The srt index should be incremented for each segment.
2025-09-25 11:34:10 +00:00
Niklas Haas 96065d1261 avcodec/aom_film_grain: fix AVCOL_*_NB range check
These should also exclude the _NB values themselves.
2025-09-25 11:08:37 +00:00
Lynne 0599d508c9 prores_raw: use MKBETAG for the frame header tag
Equivalent, but more explicit. All values in the header are big endian.
2025-09-25 19:14:12 +09:00
Lynne bc4d03c530 prores_raw: set profile based on the codec tag
This is the same as what the parser does.
2025-09-25 19:14:08 +09:00
Andreas Rheinhardt cb5dbb30ca avcodec/tiff_common: Remove unused ff_tadd_*_metadata() funcs
Unused since ad77345a5d.

Reviewed-by: Leo Izen <leo.izen@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-25 06:47:30 +02:00
Andreas Rheinhardt 371931250a avcodec/ohdec: Check mutex/conditions initialization
Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-25 05:29:58 +02:00
Andreas Rheinhardt 748fa0a9bb avcodec/ohdec: Switch to RefStruct API for internal refcounting
It avoids allocations and corresponding error conditions.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-25 05:29:26 +02:00
Andreas Rheinhardt 320133aafc avcodec/ohdec: Release decoder on allocation failure
Normally, the OH_AVCodec is wrapped inside an AVBuffer
to be freed in its free callback; yet when creating
the AVBuffer fails, the decoder is never destroyed.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-25 05:28:16 +02:00
Marvin Scholz 5cb6d2221a avformat/http: Handle IPv6 Zone ID in hostname
When using a literal IPv6 address as hostname, it can contain a Zone ID
especially in the case of link-local addresses. Sending this to the
server in the Host header is not useful to the server and in some cases
servers refuse such requests.

To prevent any such issues, strip the Zone ID from the address if it's
an IPv6 address. This also removes it for the Cookies lookup.

Based on a patch by: Daniel N Pettersson <danielnp@axis.com>
2025-09-24 12:03:13 +00:00
Stadelmann, Daniel 56c14f2311 avcodec/libmpeghdec: add MPEG-H 3DA Fraunhofer IIS mpeghdec decoder
Adds a wrapper around the Fraunhofer IIS MPEG-H 3D Audio mpeghdec [1]
decoder shared library.

[1] https://github.com/Fraunhofer-IIS/mpeghdec

Signed-off-by: Stadelmann, Daniel <daniel.stadelmann@iis.fraunhofer.de>
2025-09-24 08:25:42 +02:00
rcombs e5f82ab868 Revert "lavc/libsvtav1: set packet durations"
This reverts commit 5c9b2027bc.

This doesn't actually work the way it'd appeared to in testing;
the output was based on frame *encode latency*.
2025-09-23 20:22:33 -07:00
Andreas Rheinhardt 17d5759bd9 avcodec/x86/apv_dsp: Don't export arrays unnecessarily
The const here is unnecessary, because everything inside
SECTION_RODATA is automatically const and using it exports
these objects from the object file because const is a macro
in x86inc.asm.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-24 01:21:32 +00:00
Vittorio Palmisano f18b1e2389 avfilter/af_whisper: fix int64 printf format
Use PRId64 for printing int64_t values in the SRT output.
2025-09-23 23:35:58 +00:00
Andreas Rheinhardt 7c78a63476 avcodec/mpegaudiodec_float: Don't set AVCodec.sample_fmts directly
It is deprecated and doing so gives warnings from Clang.
Use CODEC_SAMPLEFMTS instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-23 22:16:02 +00:00
Andreas Rheinhardt cf30a3757f configure: Add missing dependencies for AHX decoder
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-23 22:16:02 +00:00
Marvin Scholz e63e040f0c avformat/rtsp: fix leading space in RTSP reason
When parsing the RTSP message reason, the whole remainder
after parsing the status code was used, which would lead to
a leading space in the parsed reason string.
2025-09-23 21:33:37 +00:00
Marvin Scholz 2ed47ab725 avformat/rtsp: do not log invalid values
When reading fails the first time, ch would be uninitialized and
printed in the log message. Instead check for an error early and
log it properly.
2025-09-23 21:33:37 +00:00
Niklas Haas 899e497122 avfilter/vf_libplacebo: force premultiplied blending for linear texture
Blending onto independent alpha framebuffers is not possible under the
constraints of the supported blend operators. While we could handle
blending premul-onto-premul, this would break if the base layer is YUV,
since premultiplied alpha does not survive the (nonlinear) YUV conversion.

Fortunately, blending independent-onto-premul is just as easy, and works in
all cases. So just force this mode when using a linear intermediate blend
texture, which is always RGBA.
2025-09-23 18:50:03 +00:00
Niklas Haas 6f08ab6c4c avfilter/vf_libplacebo: use temporary params struct for per-pass params
Instead of directly mutating `opts->params`. Avoids any possible leak of
overriden params between invocations of this function, as well as the later
`pl_render_image` during the linear output pass.
2025-09-23 18:50:03 +00:00
rcombs 5c9b2027bc lavc/libsvtav1: set packet durations 2025-09-23 14:32:47 +00:00
Derek Buitenhuis ae03b629db avformat/mov: Merge tts after building index for old-style uncompressed PCM
This was a regression introduced in 292c1df7c1.

Since we don't know the length of the stts data until after building the
index, since we're generating it, we need to merge any ctts data after,
since otherwise tts_count is set to 0, and no packets will be output.

We can't remove the merge entirely, because uncompressed PCM with
a ctts atom is technically valid (e.g. a constant CTS offset).

This fixes old-style uncompressed PCM demuxing.

Fixes #11490.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2025-09-23 14:39:13 +01:00
Krzysztof Pyrkosz 03c054d43c avcodec/aarch64/vvc: Implement dmvr_v_8
A72
dmvr_v_8_12x20_neon:                                   207.0 ( 4.15x)
dmvr_v_8_20x12_neon:                                   170.4 ( 4.37x)
dmvr_v_8_20x20_neon:                                   273.4 ( 4.58x)

A53
dmvr_v_8_12x20_neon:                                   450.6 ( 4.21x)
dmvr_v_8_20x12_neon:                                   342.8 ( 3.70x)
dmvr_v_8_20x20_neon:                                   550.9 ( 3.79x)
2025-09-23 11:20:20 +00:00
Krzysztof Pyrkosz 56a638d836 avcodec/aarch64/vvc: Unroll vvc_bdof_grad_filter_8x_neon
Before and after:
A53:
apply_bdof_8_16x8_neon:                               2733.1 ( 4.88x)
apply_bdof_8_16x16_neon:                              5458.6 ( 4.86x)
apply_bdof_10_16x8_neon:                              2789.8 ( 4.64x)
apply_bdof_10_16x16_neon:                             5523.8 ( 4.68x)
apply_bdof_12_16x8_neon:                              2792.8 ( 4.58x)
apply_bdof_12_16x16_neon:                             5519.5 ( 4.63x)

apply_bdof_8_16x8_neon:                               2571.8 ( 5.12x)
apply_bdof_8_16x16_neon:                              5173.3 ( 5.12x)
apply_bdof_10_16x8_neon:                              2635.1 ( 4.87x)
apply_bdof_10_16x16_neon:                             5243.0 ( 4.89x)
apply_bdof_12_16x8_neon:                              2613.0 ( 4.89x)
apply_bdof_12_16x16_neon:                             5231.7 ( 4.90x)

A78:
apply_bdof_8_16x8_neon:                                565.3 ( 8.43x)
apply_bdof_8_16x16_neon:                              1109.5 ( 8.60x)
apply_bdof_10_16x8_neon:                               568.2 ( 7.92x)
apply_bdof_10_16x16_neon:                             1114.1 ( 8.08x)
apply_bdof_12_16x8_neon:                               570.2 ( 7.87x)
apply_bdof_12_16x16_neon:                             1116.3 ( 8.03x)

apply_bdof_8_16x8_neon:                                541.4 ( 8.81x)
apply_bdof_8_16x16_neon:                              1065.9 ( 8.97x)
apply_bdof_10_16x8_neon:                               543.2 ( 8.32x)
apply_bdof_10_16x16_neon:                             1071.5 ( 8.39x)
apply_bdof_12_16x8_neon:                               544.2 ( 8.25x)
apply_bdof_12_16x16_neon:                             1074.1 ( 8.37x)
2025-09-23 11:20:11 +00:00
Paul B Mahol e5ac70042e avformat/aiff: add support for ADPCM N64 decoder
(cherry picked from commit 0fdf549a890f276243ba62f194e0ec08b10df60f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-22 23:46:29 +00:00
Paul B Mahol 00eef74336 avformat/adxdec: add AHX support
(cherry picked from commit b40bb6ad1e5739dd7927f3be5c2a06fb8aeef0cb)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-22 23:46:29 +00:00
Michael Niedermayer 745cb6f8c7 configure: Put modules added from almpeg under --enable-gpl as suggested by several members of the GA
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-22 23:46:29 +00:00
asivery 97bfb606e3 avformat/aeadec, avcodec/atrac1: Fix 8 and 4-channel ATRAC1 support
Signed-off-by: asivery <asivery@protonmail.com>
(cherry picked from commit 81cdf42222961c2959f1ede2d86fea0d1dcbbfcb)
2025-09-22 23:46:29 +00:00
Paul B Mahol e0638cee0a avcodec/adpcm: improve decooding output for 4-bit ADPCM IMA WAV
(cherry picked from commit f11422f1a6251e2b3c42b4044efbc722b863778d)
2025-09-22 23:46:29 +00:00
Paul B Mahol 066432ebcf avcodec: add ADPCM IMA Escape audio decoder
(cherry picked from commit 4a663e78c4421da226e7d480d6767de803ee2122)
2025-09-22 23:46:29 +00:00
Paul B Mahol 5d6c9a15eb avcodec: add ADPCM Circus decoder
(cherry picked from commit cdd3d794c7e01e4d6f485e7b975a4b9107d3f2fd)
2025-09-22 23:46:29 +00:00
Paul B Mahol f6dfb20302 avcodec: add ADPCM PSXC audio decoder
(cherry picked from commit a4055b5cc6d77c26867948e24de6bdfd5c0e6a3b)
2025-09-22 23:46:29 +00:00
Paul B Mahol a4f778890b avcodec/adpcm: fix non-4bit adpcm ima wav decoding
(cherry picked from commit f4e05abeded46515bd7b4248fc7d65df82d9af2a)
2025-09-22 23:46:29 +00:00
Paul B Mahol 30fc5b1baa avcodec: add ADPCM IMA Magix decoder
(cherry picked from commit 2ec3ad2122484ce2c84f6ba055c5ebc1661c5b14)
2025-09-22 23:46:29 +00:00
Paul B Mahol 58c0711fca avcodec: add ADPCM IMA HVQM2 decoder
(cherry picked from commit 480e36592d5fc27a47e378d62570824613f26b7b)
2025-09-22 23:46:29 +00:00
Paul B Mahol 1943b31cdd avcodec/adpcm: fix overflow in mono ADPCM IMA HVQM4
(cherry picked from commit 6a9b0f7272a0725abbe6f887f766fb5f1f119a66)
2025-09-22 23:46:29 +00:00
Paul B Mahol 5fc9c79f53 avcodec: add ADPCM Silicon Graphics N64 decoder
(cherry picked from commit 13484237fdf19c9d927b8a64b81d00100a4178c3)
2025-09-22 23:46:29 +00:00
Paul B Mahol 648b5d017d avcodec: add ADPCM IMA PDA decoder
(cherry picked from commit ab9f7513d55cfd87d1a1ce22d02abffbfb9bb296)
2025-09-22 23:46:29 +00:00
Paul B Mahol 424dbb03ae avcodec: add ADPCM IMA HVQM4 decoder
Signed-off-by: Paul B Mahol <onemda@gmail.com>
(cherry picked from commit bae3cecfa6f1fbc765d95d84ef4a377aedbca8bb)
2025-09-22 23:46:29 +00:00
Paul B Mahol e95171fbff avcodec: add AHX parser
(cherry picked from commit ddcb47c4c512bf49b22cc6b2d07fade0f96377e3)
2025-09-22 23:46:29 +00:00
Paul B Mahol b2e821310b avcodec: add AHX decoder
(cherry picked from commit 039dc23d185214b8b0ef2bbccae197ceb5ad42a2)
2025-09-22 23:46:29 +00:00
Michael Niedermayer b1cbc7c8ff configure: strip non numeric trailer from gcc version
Fixes: ../configure: 7820: [: Illegal number: 13-win32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-22 21:41:42 +00:00
Andreas Rheinhardt b815431126 Revert "avformat/tls_openssl: add av_assert0() for tls_shared"
This reverts commits fd55c4b5f7
(for tls_openssl.c) and c74181a04b
(for tls_gnutls.c).

It is impossible for a pointer to a member of a structure
to be NULL: If the containing structure exists, the member
exists and can't have a NULL address; if the containing
structure does not exist, then getting a pointer to the
substructure via &c->tls_shared would already be undefined
behavior.

Reviewed-by: Kacper Michajłow <kasper93@gmail.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-22 22:02:03 +02:00
Andreas Rheinhardt db6cd6c6bf avformat/tls_openssl: Don't call functions inside FFMIN
It may call the function multiple times.

Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-22 21:58:00 +02:00
Brad Smith ced4a6ebc9 libavutil/arm: Rename the HWCAP defines
Rename the HWCAP defines to use the same naming scheme as AArch64 and PPC.

Signed-off-by: Brad Smith <brad@comstyle.com>
2025-09-22 07:28:21 -04:00
Brad Smith cdae5c3639 libavutil/arm: Make use of elf_aux_info() on FreeBSD/OpenBSD
- FreBSD/OpenBSD have elf_aux_info() on arm
- Wrap AT_HWCAP as the value is different for BSD vs Linux (16 vs 25)

Signed-off-by: Brad Smith <brad@comstyle.com>
2025-09-22 07:16:24 -04:00
Andreas Rheinhardt c9168717bf avcodec/h274: Make H274FilmGrainDatabase a shared object
Right now, the private contexts of every decoder supporting
H.274 film grain synthesis (namely H.264, HEVC and VVC)
contain a H274FilmGrainDatabase; said structure is very large
700442B before this commit) and takes up the overwhelming
majority of said contexts: Removing it reduces sizeof(H264Context)
by 92.88%, sizeof(HEVCContext) by 97.78% and sizeof(VVCContext)
by 99.86%. This is especially important for H.264 and HEVC
when using frame-threading.

The content of said film grain database does not depend on
any input parameter; it is shareable between all its users and
could be hardcoded in the binary (but isn't, because it is so huge).

This commit adds a database with static storage duration to h274.c
and uses it instead of the elements in the private contexts above.
It is still lazily initialized as-needed; a mutex is used
for the necessary synchronization. An alternative would be to use
an AV_ONCE to initialize the whole database either in the decoders'
init function (which would be wasteful given that most videos
don't use film grain synthesis) or in ff_h274_apply_film_grain().

Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-22 04:54:22 +02:00
zhanghongyuan b5e0d9f648 fftools/opt_common: add separator line to show_filters output
Add a separator line to show_filters() function output to maintain
consistent formatting with other show functions like show_codecs,
show_formats_devices, etc. This provides uniform formatting across
all command-line output functions for better readability and
parsing by external tools.
2025-09-22 02:47:40 +00:00
Krzysztof Pyrkosz f1a155d975 avcodec/aarch64/vvc: Optimize dmvr_hv_10
Before and after on A53:
dmvr_hv_10_12x20_neon:                                1838.2 ( 3.02x)
dmvr_hv_10_20x12_neon:                                1330.2 ( 1.83x)
dmvr_hv_10_20x20_neon:                                2148.2 ( 1.85x)
dmvr_hv_12_12x20_neon:                                1839.2 ( 3.02x)
dmvr_hv_12_20x12_neon:                                1330.6 ( 1.83x)
dmvr_hv_12_20x20_neon:                                2147.2 ( 1.85x)

dmvr_hv_10_12x20_neon:                                1755.0 ( 3.17x)
dmvr_hv_10_20x12_neon:                                1165.8 ( 2.09x)
dmvr_hv_10_20x20_neon:                                1876.1 ( 2.12x)
dmvr_hv_12_12x20_neon:                                1754.4 ( 3.17x)
dmvr_hv_12_20x12_neon:                                1167.8 ( 2.09x)
dmvr_hv_12_20x20_neon:                                1878.8 ( 2.12x)
2025-09-21 19:39:27 +00:00
Niklas Haas 0bd5a7d371 avfilter/vf_colordetect: only report detected properties on EOF
Instead of reporting them also when the filtergraph is suddenly destroyed
mid-stream, e.g. during the `ffmpeg` tool's early init.
2025-09-21 13:28:58 +02:00
Niklas Haas 843920d5d6 avfilter/x86/vf_idetdsp: add AVX2 and AVX512 implementations
The only thing that changes slightly is the horizontal sum at the end.
2025-09-21 11:02:41 +00:00
Niklas Haas 4c067d0778 avfilter/x86/vf_idetdsp: generalize 8-bit macro
This is mostly compatible with AVX as well, so turn it into a macro.
2025-09-21 11:02:41 +00:00
Niklas Haas 00e05bcd68 tests/checkasm: add vf_idet checkasm 2025-09-21 11:02:41 +00:00
Niklas Haas 326abf359f avfilter/vf_idetdsp: use consistent uint8_t pointer type
Even for 16-bit DSP functions. Instead, cast the pointer inside the
function.
2025-09-21 11:02:41 +00:00
Niklas Haas 60dbcc5321 avfilter/vf_idetdsp: pass actual bit depth
More informative and IMO cleaner; some implementations may want to
differentiate by exact bit depth or support 32 bit down the line.
2025-09-21 11:02:41 +00:00
Niklas Haas 56bb187ca9 avfilter/vf_idet: correctly update dsp function on format change
Currently, this never updates on change from high bit depth to low bit depth.
2025-09-21 11:02:41 +00:00
Niklas Haas 2b67137daa avfilter/vf_idet: correctly reset pixdesc on format change 2025-09-21 11:02:41 +00:00
Niklas Haas 5830743363 avfilter/vf_idet: separate DSP parts
To avoid pulling in the entire libavfilter when using the DSP functions
from checkasm.

The rest of the struct is not needed outside vf_idet.c and was moved there.
2025-09-21 11:02:41 +00:00
Niklas Haas 367febc491 avfilter/vf_idet: expose DSP init function internally
For checkasm.
2025-09-21 11:02:41 +00:00
Zhao Zhili e02e6d54b0 tests/fate/demux: add hxvs test case 2025-09-21 17:42:19 +08:00
Zhao Zhili dcddb2bf08 avformat: add hxvs demuxer 2025-09-21 17:42:19 +08:00
Brad Smith db0b86a4ad avformat/udp: fix warning about unused varible
libavformat/udp.c:283:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Brad Smith <brad@comstyle.com>
2025-09-20 22:59:50 -04:00
Michael Niedermayer 55e71768cf avformat/dhav: Fix off by length of read element error
Fixes: out of array read
Fixes: BIGSLEEP-445383648
Fixes: crash_input_1/2/3.dhav

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-21 00:49:44 +00:00
Lynne 8d65da767b lavf: fix demuxing of FLAC files with id3v2 tags
Due to the recent id3v2 refactor, FLAC was left out due to
earlier code not checking for id3v2 presence on FLAC.
Without the id3v2 data parsed, detection of FLAC and therefore
demuxing fails.

Fixes 9d037c54f2
2025-09-20 22:46:39 +09:00
Lynne 99285cba21 lavf/id3v2: report incorrect BOM value on error 2025-09-20 22:46:35 +09:00
Henrik Gramner 82b5a0faba vp9: Remove 8bpc AVX asm for inverse transforms
There's very little performance difference vs SSE2/SSSE3 and most
systems will use the AVX2 implementations anyway.

This reduces code size and compilation time by a significant amount.
2025-09-19 23:12:59 +00:00
Henrik Gramner 0b5d46ee1c vp9: Add 8bpc AVX2 asm for inverse transforms 2025-09-19 23:12:59 +00:00
Andreas Rheinhardt 49b5c17e09 avformat/mccdec: Constify data
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:31:10 +02:00
Andreas Rheinhardt cce1af5413 avformat/mccenc: Hardcode codec names
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:31:05 +02:00
Andreas Rheinhardt f65875c082 avformat/mccdec: Avoid relocations
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:31:02 +02:00
Andreas Rheinhardt e965fe9057 avformat/mccenc: Avoid relocations
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:59 +02:00
Andreas Rheinhardt 28f0b7a237 avformat/mccenc: Add newlines to logmessages
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:53 +02:00
Andreas Rheinhardt 3c79219e93 avformat/mccenc: Check version-timecode compatibility earlier
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:33 +02:00
Andreas Rheinhardt 159330016c avformat/mccenc: Deduplicate strings
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:28 +02:00
Andreas Rheinhardt d81a971b35 avformat/mccenc: Constify read-only data
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:24 +02:00
Andreas Rheinhardt 62dd3e1e7d avformat/mccenc: Remove redundant setting of time base
It has already been done in init.

Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:20 +02:00
Andreas Rheinhardt 0cd78bddc4 avformat/mccenc: Fix assert check
Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:30:17 +02:00
Andreas Rheinhardt a34a85ed54 avformat/mccenc: Remove redundant check
This has already been checked in init.

Reviewed-by: Jacob Lifshay <programmerjake@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-20 00:29:41 +02:00
Marton Balint 82a09aef05 avformat/urldecode: factorize core url decoding from ff_urldecode
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint 23cf2c5f01 avformat/urldecode: fix decoding last char if it was percent encoded
The length check was too strict and if the end of the string was a percent
encoded sequence it did not decode correctly.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint b0314dc76e avformat/rtpproto: use proper return error codes in rtp_open
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint 3a29702cb6 avformat/rtpproto: add some URL options as AVOption aliases
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint f2be0e68ef avformat/tls: move AVClass to TLSShared
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint b2184a9741 avformat/tls: use AV_OPT_TYPE_BOOL for some AVOptions
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint 7d1e22b7ea avformat/tls: add some URL options as AVOption aliases
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint ca8cba4eac avformat/udp: factorize warning unsupported options for builds without PTHREAD_CANCEL
Also fix 'circular_buffer_size' parameter name in the message and the
'fifo_size' option description.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Marton Balint 3e7314fe30 avformat/udp: add DSCP as a normal AVOption
Previously this was an URL-only option.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-19 09:59:26 +02:00
Kacper Michajłow 1ce3f9fdab forgejo/workflows: run fate-build
It's not included in make fate target.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-18 16:53:05 +00:00
Jack Lau c74181a04b avformat/tls_gnutls: add av_assert0() for tls_shared
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-18 12:34:15 +00:00
Jack Lau df7532b21d avformat/tls_gnutls: add initial dtls support
Set GNUTLS_DATAGRAM flag when is_dtls is true.
Set mtu when it's specified.
Modify the read/write function could use udp socket.

There are more patches to make dtls really work.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-18 12:34:15 +00:00
Michael Niedermayer 647138334a avcodec/exif: check count in exif_decode_tag()
Fixes: out of array access
Fixes: integer overflow
Fixes: poc_heap_bof

Found-by: *2ourc3 (Salim LARGO)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-18 11:06:16 +00:00
Michael Niedermayer 88e04205b3 avcodec/exif: Do not leave uninitialized pointers on errors in exif_clone_entry()
No testcase, but this looks like it could free garbage pointers

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-18 11:06:16 +00:00
Michael Niedermayer 742b0d4675 avcodec/exif: Use av_fast_mallocz() in av_exif_clone_ifd()
using fast realloc leaves the entries uninitialized and frees garbage pointers on
errors

Fixes: bug_triggering_file

Found-by: *2ourc3, 5pider
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-18 11:06:16 +00:00
Kacper Michajłow c373636f55 avfilter/vsrc_gfxcapture: fix string format specifier
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-18 03:55:54 +02:00
Timo Rothenpieler 61835e1d8b avfilter/vsrc_gfxcapture: keep cbdata object alive
Depending on the threading backend the stdlib uses, creating a
mutex/condvar can be quite expensive.
So keep this object alive in the ctx, on which we synchronize via the
uninit mutex anyway.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler c4e537793b avfilter/vsrc_gfxcapture: fix leaking all callback handlers
Fixes #20537
2025-09-18 01:04:59 +00:00
Timo Rothenpieler 1849068c65 avfilter/vsrc_gfxcapture: use free threaded capture frame pool
Apparently, using a normal frame pool in a multithreaded environment
leads to strange resource leaks on shutdown, which vanish when using a
free threaded pool.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler 4879c9f4e2 avfilter/vsrc_gfxcapture: stop capture session before initializing capture thread shutdown
It might have things going on in the background that still need cleaned
up, and this gives it a chance to enqueue them on the dispatch queue.
2025-09-18 01:04:59 +00:00
Timo Rothenpieler 23d9412ff9 avfilter/vsrc_gfxcapture: fix re-using ret variable from outside of lambda scope 2025-09-18 01:04:59 +00:00
Timo Rothenpieler 983fed34f8 avfilter/vsrc_gfxcapture: don't pass pointer to ComPtr
While it does appear to work fine, with all the operator overloads, it
at least has potential for surprises, so pass it by reference instead.
2025-09-18 01:04:59 +00:00
Andreas Rheinhardt 8accbbdf9a avcodec/vvc/data: Mark tables as hidden
This allows compilers to optimize accesses like
ff_vvc_diag_scan_x[2][2][x] by baking the offset derived
from [2][2] into the relocation (so that it is performed
at link-time).

Reviewed-by: Wu Jianhua <toqsxw@outlook.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-17 22:48:39 +02:00
Timo Rothenpieler efd484cb2d avutil/hwcontext_d3d11va: remove D3D11_BIND_RENDER_TARGET restriction for array textures
This was added in 4f78711f9c, with the
commit message claiming that it's a Microsoft restriction that array
textures with ArraySize > 2 cannot be created with
D3D11_BIND_RENDER_TARGET.

I was unable to find any documentation or other references on that, and
a quick test also found it to not be the case. So this patch removes
that restriction.

This enables frame sources, like the d3d11 capture filters, to output
frames in an array texture, which is neccesary to pass those frames as
input to some hardware encoders.
2025-09-17 14:50:41 +00:00
Timo Rothenpieler 00ddb408c5 avfilter/vsrc_ddagrab: support rendering mouse cursor onto array textures 2025-09-17 14:50:41 +00:00
Cameron Gutman a0936b9769 avcodec/vaapi_encode: skip AVBR if HRD parameters are set
AVBR does not use VAEncMiscParameterTypeHRD, so attempting to set
rc_buffer_size and bit_rate together will cause the rc_buffer_size
to be ignored if the VAAPI driver supports AVBR. We should prefer
regular VBR for that case.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-09-17 06:40:16 +00:00
James Almer c6297b689f tests/fate/image: add Exif rotation metadata tests
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-17 02:17:09 +00:00
James Almer ca72b2d712 avcodec/tiffenc: support writing Orientation tag
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-17 02:17:09 +00:00
James Almer 796b3ba63b tests/fate/prores: add a probe test
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-16 15:42:03 -03:00
James Almer e0ddb4ac82 tests/fate-run: pass threads argument to ffprobe
Ensures it honors the THREADS variable if set to anything other than 1, which will be
useful to detect bugs.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-16 15:42:03 -03:00
James Almer fdb5f709b7 avcodec/h2645_sei: add missing ambient_viewing_environment copy in ff_h2645_sei_ctx_replace()
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-16 15:42:03 -03:00
James Almer 26f4230082 avcodec/decode: sync initial_pict_type and intra_only_flag with thread worker's avctx
Regression since 5acbdd2264, which removed
setting both values from PerThreadContext.
Given the pthread code calls ff_decode_receive_frame_internal() on the frame,
any value set before it will be overwritten, so instead sync each thread's
DecodeContext and let ff_decode_receive_frame_internal() handle these values.

Fixes issue #20534.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-16 15:41:50 -03:00
Andreas Rheinhardt f47b270b41 avfilter/vf_colordetect: Move ff_color_detect_dsp_init() out of .c file
Otherwise checkasm pulls in vf_colordetect.o and then all of
libavfilter.

Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:23:52 +02:00
Andreas Rheinhardt fe0a313299 avfilter/vf_colordetect: Avoid sequentially consistent atomics
Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:23:45 +02:00
Andreas Rheinhardt a35c91dc14 avfilter/vf_colordetect: Rename header to vf_colordetectdsp.h
It is more in line with our naming conventions.

Reviewed-by: Martin Storsjö <martin@martin.st>
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-16 18:22:24 +02:00
Timo Rothenpieler b8256b82f5 avfilter/vsrc_gfxcapture: remove needless use of atomics 2025-09-16 15:52:11 +00:00
Timo Rothenpieler 61378d6b91 avfilter/vsrc_gfxcapture: fix possible missed wakeup race in capture loop 2025-09-16 15:52:11 +00:00
Jan Ekström af35a13f6d avformat/movenc: add support for fragmented TTML muxing
Attempts to base the fragmentation timing on other streams
as most receivers expect media fragments to be more or less
aligned.

Currently does not support fragmentation on subtitle track
only, as the subtitle packet queue timings would have to be
checked in addition to the current fragmentation timing logic.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2025-09-16 16:29:48 +03:00
Jan Ekström 8dcc65a0fc avcodec/packet: add functionality to prepend to AVPacketLists
Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2025-09-16 16:28:12 +03:00
Jan Ekström 5c222d7ade tests/fate-run: add support for specifying the final encode muxer in transcode
This allows for direct dumping of the packets' contents (useful for
text based formats), while getting the timestamps/sizes etc from
ffprobe.

If used via TRANSCODE, the actually utilized muxer should be added
within the last argument as an additional dependency, as that is not
done automatically.

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2025-09-16 15:17:12 +03:00
renjianguang 9e4ff4732c swresample/swresample: Delete unused code
The uch option has been removed

Signed-off-by: renjianguang <renjianguang@xiaomi.com>
2025-09-16 11:27:39 +00:00
Zhao Zhili 07ea3b1787 avformat/flvenc: fix event_flags check
AVFormatContext.event_flags is checked against AVSTREAM_EVENT_FLAG,
which belongs to AVStream.event_flags. There is no real issue since
these two flags have the same value.
2025-09-16 02:52:20 +00:00
James Almer 57a29f2e7d avcodec/x86/pngdsp: add missing emms at the end of add_png_paeth_prediction
Fixes unpredictable behavior with floats.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-15 22:18:52 -03:00
Andreas Rheinhardt 162e5a1121 swresample/rematrix_template: Constify get_mix_any_func
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt fe06d5533f swresample/x86/rematrix_init: Avoid allocation for native_simd_one
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt 853229d140 swresample/rematrix: Avoid allocation for native_one
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt c48add609a swresample/swresample_internal: Use union for float, int matrix
Saves 16KiB from SwrContext.
(FATE would also pass if one made the double matrix part of
the union, too, but I don't know whether this is truely correct,
because swri_rematrix() accesses the double matrix (to check whether
it is equal to 1.0) even when one of the other matrices is in use.)

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt f33e62a8b4 avcodec/mjpegdec: Move reference dimension check to mxpegdec.c
Only the mxpeg sets reference at all.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt b5cfabf0f5 avcodec/mjpegdec: Avoid using HpelDSPContext
It is quite big and we only need one function from it.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt 124c856d38 avcodec/mjpegdec: Move initializing HpelDSPContext to mxpegdec.c
Only the mxpeg decoder uses it (and the reference/bitmask feature
of ff_mjpeg_decode_sos()). So only initialize it for mxpeg which
allows to remove the mjpeg->hpeldsp dependency.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt b11c8b76df avcodec/mjpegdec: Avoid mixing return value and error code, avoid branch
mjpeg_decode_dc() currently has a special return value (0xfffff)
for the case of invalid data; this value does not overlap with
the ordinary return values, yet the compiler can't prove this
(at least on x86 where an asm version of NEG_USR32 is used
inside get_xbits()), so the non-error return value has to be checked
for being the special value even if mjpeg_decode_dc() is inlined.

This commit avoids this by separating error code and ordinary return
value. It also means that the ljpeg functions return the proper
error code and not -1 in case of invalid data.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt 3b1673db6a avcodec/mjpegdec: Avoid superfluous secondary error message
Up until now, a DC error in decode_block() or decode_dc_progressive()
would lead to a warning from mjpeg_decode_dc() and a (less verbose)
error from the caller. Upgrade the former to an error status (all
callers treat is an error) and remove the latter.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt a6c899bc6b avcodec/mjpegdec: Remove pointless information from logmessage
There is no reason to add the address of an element of
MJpegDecodeContext (which makes logmessage nonreproducible).
Also avoid always printing a zero.

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:22 +02:00
Andreas Rheinhardt ac64c52b96 avcodec/encode: Remove redundant av_image_check_size2()
The dimensions have already been checked during init.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt a2e4ba4df6 avcodec/encode: Remove dead code
Can be readded if needed (likely never).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt 9a130a57cd avcodec/encode: Ignore coded_{width,height}
It is supposed to be unused by encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt b3ac02eb83 avcodec/encode: Simplify pixel format validity check
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt ed9c8e98cc avcodec/av1dec,libdav1d,wbmpdec: Avoid direct access to GetByteContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt 8872c0c39d avformat/takdec: Don't truncate return value
This is unlikely to matter for real files.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt 057afba13d avformat/tta: Avoid seek when reading header
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt bd80640cae avformat/oggdec: Don't skip over data whose checksum is used
The behavior of the ffio_*_checksum feature is not well defined
when using avio_skip(). The code in oggdec.c relied on the skipped
data (four bytes) to be checksummed, which is mostly true
because short_seek_threshold is 32768 by default, so that
avio_seek() will normally read data instead of calling the
underlying seek function. Yet this has two problems:

a) It relies on implementation details of avio_seek().
b) There is an exception, namely if the AVIO_FLAG_DIRECT is set.
In this case the underlying seek function (if set) is always
called and the data is skipped, leading to CRC errors.

So don't skip the data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Andreas Rheinhardt 987c955cd7 avformat/aviobuf: Keep checksum_ptr consistent in avio_seek()
Otherwise it might be > buf_ptr in which case ffio_get_checksum()
could segfault (s->buf_ptr - s->checksum_ptr would be negative
which would be converted to something very big when converted
to unsigned for the update_checksum callback).

Fixes ticket #11233.

Reported-by: Du4t
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-15 17:52:21 +02:00
Marvin Scholz 994bc08325 configure: also initialize objcflags_filter early
Fixes an issue uncovered since 0ce413af9c
where flags were properly separated but without the objcflags_filter
being initialized, if add_objcflags is called early as part of
add_allcflags, it would lead to the append() function using an empty
filter and trying to call the flag instead, leading to errors like:

./configure: line 976: -fsanitize=address: command not found
./configure: line 976: -fno-omit-frame-pointer: command not found
2025-09-15 15:50:11 +00:00
Drew Dunne 76471fb143 vf_colorspace: Add an option to clamp trc LUT output
Add a new flag to the vf_colorspace filter which provides the user an
option to clamp the linear and delinear transfer characteristics LUT
values to the [0, 1] represented range. This helps constrain the
potential value range when converting between colorspaces.

Certain colors when going through the conversion can result in out of
gamut colors after the rotation. The colorspace filter allows that with
the extended range. The added clamping just keeps the colors within the
[0, 1) range rather than using that extended range. I'm not enough of a
color scientist to say which is correct, but there are certain
situations where we would prefer to keep the colors in gamut.

The example I have is:

A solid color image of 8-bit YUV: Y=157, U=164, V=98.

Specify the input as:

Input range: MPEG
In color matrix: BT470BG
In color primaries: BT470M
In color transfer characteristics: Gamma 28

Output as:
Out color range: JPEG
Out color matrix: BT.709
Out color primaries: BT.709
Out color transfer characteristics: BT.709

During the calculation you get:

Input YUV:                             y=157,      u=164,      v-98
Post-yuv2rgb BT.470BG:                 r=0.456055, g=0.684152, b=0.928606
Post-apply gamma28 linear LUT:         r=0.110979, g=0.345494, b=0.812709
Post-color rotation BT.470M to BT.709: r=-0.04161, g=0.384626, b=0.852400
Post-apply Rec.709 delinear LUT:       r=-0.16382, g=0.615932, b=0.923793
Post-rgb2yuv Rec.709 matrix:           y=120,      u=190,      v=25

Where with this change, the delinear LUT output would be clamped to 0,
so the result would be:
r=0.000000, g=0.612390, b=0.918807 and a final output of
y=129, u=185, v=46

As for the long and av_clip64, this was just because lrint returned a
long, so I left it as that and then used av_clip64 to the [0,1) range to
avoid overflow. But re-reading, it looks like av_clip_int16 would
downcast that long to int anyway so the possibility of overflow already
existed there. I've put it back to int just to match the existing
behavior.
2025-09-15 14:39:09 +00:00
Timo Rothenpieler 189d0b83b2 configure: pass CFLAGS to ObjC tests again
It was mistakenly removed in 0ce413af9c.

This matches how the Makefiles actually compile ObjC code, and
unlike C++, this seems to actually be benign and various existing
setups rely on that behaviour.
2025-09-15 14:37:43 +02:00
Timo Rothenpieler f85da32e3a configure: make --extra-objcflags show the right default flags 2025-09-15 14:17:49 +02:00
Martin Storsjö 424d844534 configure: Make -Werror=partial-availability apply to all languages
This was missed in 0ce413af9c.

This fixes proper detection of Objective C APIs (that are missing)
if targeting older macOS versions, such as the check for
AVCaptureSession.
2025-09-15 14:17:52 +03:00
Jack Lau 16b8a7805b avformat/whip: enable RTCP NACK for whip
Refer to RFC 4585 4.2,
Add SDP "a=rtcp-fb" so the peer can request rtx
through sending NACKs.

Add basic parsing for NACK packet.
Decrypt into a newly allocated buffer (do not
overwrite whip->buf) so multiple NACKs in a
bundled packet can be parsed in a loop while
keeping whip->buf available for sending rtx

Broken or wrong NACk are logged and skipped.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-15 06:40:11 +00:00
Timo Rothenpieler faba1501d5 avfilter/vsrc_gfxcapture: switch to std::thread
Combining C++ with our w32pthreads does not work out.
The C++ standard lib headers might include pthread.h, which will then
define clashing types with our w32pthread header.

To solve this, switch to using C++ native std::thread.
2025-09-14 21:46:40 +02:00
Timo Rothenpieler 570949822b avfilter/vsrc_gfxcapture: MapWindowPoints can return 0 and still succeed 2025-09-14 20:46:29 +02:00
Timo Rothenpieler d74d3080ff avfilter/vsrc_gfxcapture: make checkheaders happy 2025-09-14 20:33:24 +02:00
Zhao Zhili 9e3c07f2df avcodec/rkmppdec: fix return EAGAIN during flushing
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-14 21:35:54 +08:00
Zhao Zhili 0773343ed7 avcodec/rkmppdec: fix input queue overflow
The strategy to count free slots isn't reliable. The value of
INPUT_MAX_PACKETS is a hardcoded value, and MPP_DEC_GET_STREAM_COUNT
doesn't always work as expected. When freeslots is nonzero, the mpp
decoder still returns MPP_ERR_BUFFER_FULL. Before this patch, all
packets are dropped once went into MPP_ERR_BUFFER_FULL state.

Don't drop packet and return error in MPP_ERR_BUFFER_FULL state.
Receive frame to allow the decoder's state machine to resume.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-14 21:35:54 +08:00
Timo Rothenpieler 6e63b978d3 doc/filters: fix missed reference to outdated option name 2025-09-14 15:33:31 +02:00
Timo Rothenpieler 36e374efb0 avfilter: add gfxcapture, Windows.Graphics.Capture based window/monitor capture 2025-09-14 11:45:11 +00:00
Timo Rothenpieler 7856f57533 compat/w32pthreads: fix compatibility with C++ 2025-09-14 11:45:11 +00:00
Timo Rothenpieler 5146b2fb8b configure: don't use MinGW ANSI stdio when using UCRT
MinGWs ANSI stdio is quite slow, and when using UCRT, its extra features
are not needed.
The only troublesome part with ucrt printf is that is disagrees about
the size of "long double", but FFmpeg does not use that anywhere, let
alone prints it.
2025-09-14 11:45:11 +00:00
Timo Rothenpieler 9c8a6ac85c configure: fix naming of some C++/cxx functions being mislabeled as cpp 2025-09-14 11:45:11 +00:00
Timo Rothenpieler 0ce413af9c configure: properly split C/CXX and CPP flags
Right now, CFLAGS like -std=c17 leak onto the C++ compilers commandline,
leading to tons of warnings and even some errors.

Undefining __STRICT_ANSI__ causes strong warnings from the stdlib
headers. So only set it for C.
2025-09-14 11:45:11 +00:00
Timo Rothenpieler 0362cb3806 build: link with CXX when -lstdc++ on linker commandline 2025-09-14 11:45:11 +00:00
Andreas Rheinhardt bdb81d9347 avcodec/rkmppdec: Close decoder generically on init failure
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-14 10:47:57 +00:00
Andreas Rheinhardt b02f1129eb swresample/resample, soxr_resample: Use designated initializers
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 21:25:40 +00:00
Timo Rothenpieler 4c80cda08a forgejo: make aarch64 asm linter part of pre-commit
Needed some minor semantical changes to the shell wrapper, since
pre-commit expects it to exit with an error when applying fixes.
2025-09-13 20:58:29 +00:00
Martin Storsjö edd1b93e53 forgejo: Check the aarch64 assembly indentation as part of the lint job
Alternatively, this could be a separate job, potentially keyed
to only run on PRs that touch files matching */aarch64/*. But
as this runs very quickly, it's probably less clutter to just
bundle it here.
2025-09-13 20:58:29 +00:00
Martin Storsjö a3ce337926 tools: Add scripts for indenting and checking aarch64 assembly
The same also applies for arm assembly, but there are more known
deviations within that.

Add a script which checks all files, except for a few known files
that deviate, for various reasons.
2025-09-13 20:58:29 +00:00
Andreas Rheinhardt 0ba0cf94db avcodec/bsf/noise: Avoid allocation for string
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 20:45:42 +00:00
Andreas Rheinhardt 9ae42d42e6 avcodec/dvdsubdec: Don't return value != 0 on init success
Currently, any nonnegative return value from an init function
is just treated as success and otherwise ignored; while it is
not explicitly forbidden to return something else than 0 (there
is no documentation whatsoever), the assumption is that
they return zero on success. So change dvdsubdec.c accordingly.

Also change dvdsub_parse_extradata() to return zero on success.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 20:37:03 +00:00
Andreas Rheinhardt 1df63acdc4 avcodec: Add av_cold to flush,init,close functions missing it
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 20:37:03 +00:00
Andreas Rheinhardt bc545bae3b tests/checkasm/sw_ops: Avoid 1 << 32
It is UB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-13 21:27:27 +02:00
Kacper Michajłow 1294ab5db1 swscale/ops_tmpl_int: remove unused arguments from wrap read decl
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-13 19:12:44 +02:00
Kacper Michajłow 66faef3dbe swscale/ops_chain: add type removed ff_sws_op_chain_free_cb
to avoid pointer casting and UB of calling function with different
pointer type.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-09-13 18:14:02 +02:00
Andreas Rheinhardt a4fd3f27f4 swscale/x86/ops: Fix leak
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 22:42:30 +02:00
Andreas Rheinhardt c74ee4ceff swscale/ops_chain: Free correct pointer on error
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 22:41:24 +02:00
Andreas Rheinhardt 6384254db2 avcodec/mpegaudiodec_template: Avoid write-only stores
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:39:27 +02:00
Andreas Rheinhardt 8728271097 avcodec/mpegaudiodec_template: Mark flush functions as av_cold
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:39:22 +02:00
Andreas Rheinhardt f611459e6f avcodec/mpegaudiodec_template: Allocate sub-contexts jointly
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:39:16 +02:00
Andreas Rheinhardt 84f4b9fc1f avcodec/mpegaudiodec_template: Don't modify AVCodecContext.priv_data
Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:38:48 +02:00
Andreas Rheinhardt 87cb7c871b avcodec/pcm_tablegen: Fix hardcoded-tables if alaw,mulaw,vidc codecs disabled
Since ae448e00af the various
tableinit functions are not compiled unconditionally any more,
so that pcm_tablegen.c (which creates the hardcoded tables)
needs to be updated.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 21:37:42 +02:00
Andreas Rheinhardt f49de7018a avcodec/Makefile: Add adpcm_vima->adpcm.o dependency
Forgotten in 9141fe9653.

Reviewed-by: Peter Ross <pross@xvid.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-12 17:11:26 +02:00
James Almer 799c133273 avutil/tests/aes_ctr: extend the test to cover payloads smaller than a block
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-11 18:32:24 -03:00
James Almer 335ba4a649 avutil/aes_ctr: reintroduce the block offset state
Wrongly removed in fe73b84879, it's required for
calls with a payload smaller than a full block.

Fixes issue #20474.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-11 18:32:23 -03:00
Zhao Zhili c1dc2e2b7c avcodec/videotoolboxenc: ensure bitrate is set in low_delay mode
VideoToolbox doesn't support automatic bitrate in low delay mode.
Check bitrate and show error message so user knows what's going
wrong.
2025-09-10 20:33:40 +08:00
Cameron Gutman d87210745e avcodec/videotoolboxenc: allow low latency RC with HEVC
It is supported only for H.264 on Intel Macs, but it can be used with
both H.264 and HEVC on Apple Silicon.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-09-10 11:55:18 +00:00
Tong Wu 4691c56238 forgejo/CODEOWNERS: add myself to d3d12va related files
Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-09-10 11:39:17 +00:00
Marvin Scholz 2a1d5dd720 fftools: use fopen_utf8 to open FFREPORT
Should fix #11240
2025-09-10 11:38:43 +00:00
Georgii Zagoruiko 4fbacb3944 avcodec/aarch64/vvc: Optimised version of classify function.
Macbook Air (M2):
    vvc_alf_classify_8x8_8_c:                                2.6 ( 1.00x)
    vvc_alf_classify_8x8_8_neon:                             1.0 ( 2.47x)
    vvc_alf_classify_8x8_10_c:                               2.7 ( 1.00x)
    vvc_alf_classify_8x8_10_neon:                            0.9 ( 2.98x)
    vvc_alf_classify_8x8_12_c:                               2.7 ( 1.00x)
    vvc_alf_classify_8x8_12_neon:                            0.9 ( 2.97x)
    vvc_alf_classify_16x16_8_c:                              7.3 ( 1.00x)
    vvc_alf_classify_16x16_8_neon:                           3.4 ( 2.12x)
    vvc_alf_classify_16x16_10_c:                             4.3 ( 1.00x)
    vvc_alf_classify_16x16_10_neon:                          2.9 ( 1.47x)
    vvc_alf_classify_16x16_12_c:                             4.3 ( 1.00x)
    vvc_alf_classify_16x16_12_neon:                          3.0 ( 1.44x)
    vvc_alf_classify_32x32_8_c:                             13.7 ( 1.00x)
    vvc_alf_classify_32x32_8_neon:                          10.7 ( 1.29x)
    vvc_alf_classify_32x32_10_c:                            12.3 ( 1.00x)
    vvc_alf_classify_32x32_10_neon:                          8.7 ( 1.42x)
    vvc_alf_classify_32x32_12_c:                            12.2 ( 1.00x)
    vvc_alf_classify_32x32_12_neon:                          8.7 ( 1.40x)
    vvc_alf_classify_64x64_8_c:                             45.8 ( 1.00x)
    vvc_alf_classify_64x64_8_neon:                          37.1 ( 1.23x)
    vvc_alf_classify_64x64_10_c:                            41.3 ( 1.00x)
    vvc_alf_classify_64x64_10_neon:                         32.8 ( 1.26x)
    vvc_alf_classify_64x64_12_c:                            41.4 ( 1.00x)
    vvc_alf_classify_64x64_12_neon:                         32.4 ( 1.28x)
    vvc_alf_classify_128x128_8_c:                          163.7 ( 1.00x)
    vvc_alf_classify_128x128_8_neon:                       138.3 ( 1.18x)
    vvc_alf_classify_128x128_10_c:                         149.1 ( 1.00x)
    vvc_alf_classify_128x128_10_neon:                      120.3 ( 1.24x)
    vvc_alf_classify_128x128_12_c:                         148.7 ( 1.00x)
    vvc_alf_classify_128x128_12_neon:                      119.4 ( 1.25x)

    RPi4 (Cortex-A72):
    vvc_alf_classify_8x8_8_c:                             1251.6 ( 1.00x)
    vvc_alf_classify_8x8_8_neon:                           700.7 ( 1.79x)
    vvc_alf_classify_8x8_10_c:                            1141.9 ( 1.00x)
    vvc_alf_classify_8x8_10_neon:                          659.7 ( 1.73x)
    vvc_alf_classify_8x8_12_c:                            1075.8 ( 1.00x)
    vvc_alf_classify_8x8_12_neon:                          658.7 ( 1.63x)
    vvc_alf_classify_16x16_8_c:                           3574.1 ( 1.00x)
    vvc_alf_classify_16x16_8_neon:                        1849.8 ( 1.93x)
    vvc_alf_classify_16x16_10_c:                          3270.0 ( 1.00x)
    vvc_alf_classify_16x16_10_neon:                       1786.1 ( 1.83x)
    vvc_alf_classify_16x16_12_c:                          3271.7 ( 1.00x)
    vvc_alf_classify_16x16_12_neon:                       1785.5 ( 1.83x)
    vvc_alf_classify_32x32_8_c:                          12451.9 ( 1.00x)
    vvc_alf_classify_32x32_8_neon:                        5984.3 ( 2.08x)
    vvc_alf_classify_32x32_10_c:                         11428.9 ( 1.00x)
    vvc_alf_classify_32x32_10_neon:                       5756.3 ( 1.99x)
    vvc_alf_classify_32x32_12_c:                         11252.8 ( 1.00x)
    vvc_alf_classify_32x32_12_neon:                       5755.7 ( 1.96x)
    vvc_alf_classify_64x64_8_c:                          47625.5 ( 1.00x)
    vvc_alf_classify_64x64_8_neon:                       21071.9 ( 2.26x)
    vvc_alf_classify_64x64_10_c:                         44576.3 ( 1.00x)
    vvc_alf_classify_64x64_10_neon:                      21544.7 ( 2.07x)
    vvc_alf_classify_64x64_12_c:                         44600.5 ( 1.00x)
    vvc_alf_classify_64x64_12_neon:                      21491.2 ( 2.08x)
    vvc_alf_classify_128x128_8_c:                       192143.3 ( 1.00x)
    vvc_alf_classify_128x128_8_neon:                     82387.6 ( 2.33x)
    vvc_alf_classify_128x128_10_c:                      177583.1 ( 1.00x)
    vvc_alf_classify_128x128_10_neon:                    81628.8 ( 2.18x)
    vvc_alf_classify_128x128_12_c:                      177582.2 ( 1.00x)
    vvc_alf_classify_128x128_12_neon:                    81625.1 ( 2.18x)
2025-09-09 22:13:04 +01:00
Krzysztof Pyrkosz de25cb4603 avcodec/aarch64/vvc: Optimize vvc_apply_bdof_block_8x
Before and after:
A53:
apply_bdof_8_8x16_neon:                               3320.5 ( 4.02x)
apply_bdof_10_8x16_neon:                              3317.8 ( 3.90x)
apply_bdof_12_8x16_neon:                              3303.6 ( 3.91x)

apply_bdof_8_8x16_neon:                               3168.1 ( 4.23x)
apply_bdof_10_8x16_neon:                              3127.8 ( 4.13x)
apply_bdof_12_8x16_neon:                              3119.3 ( 4.18x)

A72:
apply_bdof_8_8x16_neon:                               1827.4 ( 5.02x)
apply_bdof_10_8x16_neon:                              1838.5 ( 4.89x)
apply_bdof_12_8x16_neon:                              1841.1 ( 4.83x)

apply_bdof_8_8x16_neon:                               1691.6 ( 5.46x)
apply_bdof_10_8x16_neon:                              1695.9 ( 5.23x)
apply_bdof_12_8x16_neon:                              1695.4 ( 5.29x)

A78
apply_bdof_8_8x16_neon:                                648.9 ( 7.43x)
apply_bdof_10_8x16_neon:                               646.1 ( 7.04x)
apply_bdof_12_8x16_neon:                               643.8 ( 7.04x)

apply_bdof_8_8x16_neon:                                603.2 ( 7.97x)
apply_bdof_10_8x16_neon:                               604.1 ( 7.52x)
apply_bdof_12_8x16_neon:                               604.5 ( 7.52x)
2025-09-09 16:37:28 +00:00
Niklas Haas 5f39965dd6 avfilter/buffersink: remove unneeded parameter
This is a newly added field, so there's no point to try and keep backwards
compatibility with an older API - newer clients should just use the new
fields.
2025-09-09 14:52:01 +02:00
averne 5aa541c690 fate/prores: Fix missing dependency
Signed-off-by: averne <averne381@gmail.com>
2025-09-09 12:04:05 +00:00
James Almer 05b6b30ee1 fftools/ffplay: set the alphamodes buffersink array option instead of the binary one
And add the missing goto fail. This should ensure the alpha mode is set and remove
bogus warnings printed by ffplay.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-08 18:38:16 -03:00
James Almer 23b759e99e avfilter/buffersink: add missing checks for alphamodes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-08 18:38:16 -03:00
Frank Plowman e9a6b75373 lavc/cbs: Make error message more descriptive 2025-09-08 21:13:09 +00:00
dariusz-f c75439a93b Update libavformat/apvdec.c
Increase au_size limit by 4 times to fit more complex videos.

Signed-off-by: dariusz-f <dariusz-f@noreply.code.ffmpeg.org>
2025-09-08 20:59:31 +00:00
Dariusz Frankiewicz 002a940ca6 avformat/apv: fix range of au_size
Acces unit size is described in documentation as > 0 < 0xFFFFFFFF

Signed-off-by: Dariusz Frankiewicz <d.frankiewic@samsung.com>
2025-09-08 20:59:31 +00:00
Zhao Zhili 09856e4e48 doc/examples/vaapi_encode: fix invalid check on fwrite
enc_pkt->size is 0 after av_packet_unref, which makes the check invalid.

Fix regression from 3e4bfff2.

Co-Authored-by: Jin Bo <jinbo@loongson.cn>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-08 20:43:07 +00:00
Krzysztof Pyrkosz 7b21bde34c avcodec/aarch64/vvc: Implemented dmvr_h_10
A78:
dmvr_h_10_12x20_neon:                                   82.2 ( 6.49x)
dmvr_h_10_20x12_neon:                                   69.9 ( 3.66x)
dmvr_h_10_20x20_neon:                                  112.5 ( 3.74x)
dmvr_h_12_12x20_neon:                                   81.4 ( 6.51x)
dmvr_h_12_20x12_neon:                                   69.2 ( 3.74x)
dmvr_h_12_20x20_neon:                                  110.2 ( 3.85x)

A72:
dmvr_h_10_12x20_neon:                                  234.1 ( 4.67x)
dmvr_h_10_20x12_neon:                                  221.4 ( 3.48x)
dmvr_h_10_20x20_neon:                                  356.9 ( 3.59x)
dmvr_h_12_12x20_neon:                                  234.1 ( 4.67x)
dmvr_h_12_20x12_neon:                                  221.5 ( 3.53x)
dmvr_h_12_20x20_neon:                                  357.0 ( 3.64x)
2025-09-08 17:51:20 +00:00
Krzysztof Pyrkosz 189e841cfd avcodec/aarch64/vvc: Implement dmvr_h_8
A78:
dmvr_h_8_12x20_neon:                                    76.6 ( 4.31x)
dmvr_h_8_20x12_neon:                                    65.8 ( 3.49x)
dmvr_h_8_20x20_neon:                                   106.6 ( 3.62x)

A72:
dmvr_h_8_12x20_neon:                                   190.6 ( 4.40x)
dmvr_h_8_20x12_neon:                                   171.1 ( 4.31x)
dmvr_h_8_20x20_neon:                                   275.1 ( 4.50x)
2025-09-08 17:51:20 +00:00
Dmitrii Ovchinnikov 1b97966199 avutil/hwcontext_d3d12va: added resource and heap flags to DeviceContext 2025-09-08 15:44:47 +00:00
DE-AI fbbb2996d5 vc1_parser: Reset unesc_index after extracting header with complete frames
When PARSER_FLAG_COMPLETE_FRAMES is set (e.g. in Matroska),
unesc_index is not reset after the first frame, which causes
subsequent frames to inherit leftover header data.

This leads to incorrect keyframe marking and broken decoding.

See also this bug report: https://trac.ffmpeg.org/ticket/8515

Signed-off-by: DE-AI <max.christoph@pentaxmedical.com>
2025-09-08 14:03:52 +00:00
Niklas Haas 1f2de0f618 avfilter/vf_libplacebo: ensure linear tex is blittable
Required to clear textures to a background color.
2025-09-08 15:42:01 +02:00
Timo Rothenpieler f8a300c673 configure: fix CUDA compilation with SDK version 13 nvcc
Compute Capability 7.5 is now the lowest supported version.

Fixes #20454
2025-09-08 14:25:44 +02:00
Tong Wu 45db6945e9 avcodec/vaapi_encode: avoid potential overflow
The max_frame_size in byte will be filled in
VAEncMiscParameterBufferMaxFrameSize which receives size in bit.
This requires max_frame_size * 8.

Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-09-08 00:19:06 +00:00
Alan Kelly f4b044bbe3 swscale: Disable avx2 hscale 8to15 on IceLake and below due to Intel Gather Data Sampling mitigation performance loss
Intel provided a microcode update to mitigate this security
    vulnerability which has a huge negative performance impact on gather
    instructions. This means that hscale 8to15 avx2, which uses gather
    extensively, is no longer faster than SSSE3 on impacted CPUs.

    https://www.intel.com/content/www/us/en/developer/articles/technical/software-security-guidance/technical-documentation/gather-data-sampling.html

    Broadwell:
    hscale_8_to_15__fs_4_dstW_512_c:                      3379.5 ( 1.00x)
    hscale_8_to_15__fs_4_dstW_512_sse2:                    615.7 ( 5.49x)
    hscale_8_to_15__fs_4_dstW_512_ssse3:                   613.4 ( 5.51x)
    hscale_8_to_15__fs_4_dstW_512_avx2:                    495.7 ( 6.82x)

    Skylake:
    hscale_8_to_15__fs_4_dstW_512_c:                      3411.4 ( 1.00x)
    hscale_8_to_15__fs_4_dstW_512_sse2:                    591.0 ( 5.77x)
    hscale_8_to_15__fs_4_dstW_512_ssse3:                   591.5 ( 5.77x)
    hscale_8_to_15__fs_4_dstW_512_avx2:                   1386.2 ( 2.46x)

    Cascade Lake:
    hscale_8_to_15__fs_4_dstW_512_c:                      3231.3 ( 1.00x)
    hscale_8_to_15__fs_4_dstW_512_sse2:                    517.9 ( 6.24x)
    hscale_8_to_15__fs_4_dstW_512_ssse3:                   521.6 ( 6.19x)
    hscale_8_to_15__fs_4_dstW_512_avx2:                   1775.0 ( 1.82x)

    Sapphire Rapids:
    hscale_8_to_15__fs_4_dstW_512_c:                      1840.0 ( 1.00x)
    hscale_8_to_15__fs_4_dstW_512_sse2:                    287.9 ( 6.39x)
    hscale_8_to_15__fs_4_dstW_512_ssse3:                   293.8 ( 6.26x)
    hscale_8_to_15__fs_4_dstW_512_avx2:                    219.2 ( 8.40x)
2025-09-06 20:57:48 +00:00
Leo Izen 1dcb0c6c3e avcodec/libjxldec: consume input on error
libjxl consumes no input if it returns an error, so this loops over
and over while it spits out the same error many times. If we got an
error from libjxl and consumed no input, then we instead consume the
whole packet.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-09-06 15:51:41 -04:00
Leo Izen 74e61981b5 avcodec/decode: treat orientation 1 as valid displaymatrix
Since 9dc79241d9 we now always pop the
orientation off of the IFD and use a display matrix instead. This means
we should not produce a warning and refuse if the orientation field
indicates a default orientation (i.e. 1).

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reported-by: Ramiro Polla <ramiro.polla@gmail.com>
2025-09-06 13:15:24 -04:00
Zhao Zhili 742474bc24 avformat/mov: fix unused variable entry in parse_exif_item 2025-09-06 15:11:48 +00:00
Zhao Zhili 1ca2c68278 avcodec/pcm: fix some unused variables/functions warning
v is unused when ALAW/MULAW/VIDC are disabled.
2025-09-06 15:11:48 +00:00
Zhao Zhili ca1ab8815c avcodec/pcm: use stricter conditional expressions for compilation 2025-09-06 15:11:48 +00:00
Andreas Rheinhardt 893250a734 avfilter/Makefile: Add dependencies for premultiply_dynamic filter
Reviewed-by: Timo Rothenpieler <timo@rothenpieler.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-06 16:06:31 +02:00
Jack Lau adc66f30ee configure: remove openssl version check for whip
This version check for whip is unnecessary.
Since several rencet patches to the configure
have already added version checks for OpenSSL.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-06 11:27:54 +00:00
Marton Balint 7321e4b950 avformat/img2dec: support arbitrary path lengths
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 8703dd74bd avformat/img2dec: remove path limits from find_image_range
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 69d9c074ef avformat/img2dec: do not use av_get_frame_filename result buffer if the call fails
We have no way of knowing if the string was fully processed or got truncated
because of a parse error so it is better to use the original path if finding an
image sequence fails.

We do this by explicitly falling back to the PT_NONE mode if the provided
filename is not a valid pattern but the file exists or if the IO context is
already open.

This also means that filenames no longer need to be escaped even in sequence
mode if an invalid sequence (a sequence without %d) is provided, so a command
line such as ffmpeg -f image2 -i "100%.jpg" will just work, but "100%%.jpg"
will no longer work.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 8c1301cf9d avformat/webm_chunk: support for arbitrary path lengths
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 35ceef40ad avformat/segment: support arbitrary path lengths
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 4b8be1991c avformat/utils: support arbitrary path lengths for av_filename_number_test
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
Marton Balint 9458a6f8ec avformat/utils: add AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION flag
Signed-off-by: Marton Balint <cus@passwd.hu>
2025-09-05 21:05:13 +02:00
caifan3 7a1c737c35 libavcodec/v4l2_buffers: avoid redefinition of USEC_PER_SEC macro
The macro USEC_PER_SEC is already defined in system headers on some platforms,such as Nuttx nuttx/clock.h.
Check if it's already defined before defining it to avoid compiler warnings.

Signed-off-by: caifan3 <caifan3@xiaomi.com>
2025-09-05 17:21:30 +00:00
Dmitrii Ovchinnikov 6891314db1 MAINTAINERS: Update the entries for AMF
MAINTAINERS: Update the entries for AMF

Alphabetized the records
2025-09-05 17:52:46 +02:00
Dmitrii Ovchinnikov 8450d87ea5 forgejo/CODEOWNERS: add myself for relevant files 2025-09-05 17:52:46 +02:00
Martin Storsjö f6bcd661f0 configure: Improve the check for schannel DTLS constants
This amends 307983b292 to fix
building with older versions of mingw-w64.

The previously checked constant, SP_PROT_DTLS1_X_CLIENT, was
added in mingw-w64 in df36f5deda23192d0ee99ffd661ea36df924e667
in 2020, and is included in released versions since v8.0.0.

The new checked constant SECPKG_ATTR_DTLS_MTU was added in
mingw-w64 in 0792283787cca8fc27dd38671107c791c87f4db3 in 2021,
and first appeared in mingw-w64 v9.0.0.

This fixes building with mingw-w64 v8, which is the version bundled
in Ubuntu 22.04.
2025-09-05 12:20:11 +00:00
Zhao Zhili fc45127bcc avcodec/videotoolboxenc: support global_quality without qscale 2025-09-05 09:20:36 +00:00
Zhao Zhili 73750489a6 avcodec/videotoolboxenc: fix the loss of precision when calculating quality 2025-09-05 09:20:36 +00:00
Krzysztof Pyrkosz fb4407797e Replace uxtl with umull in dmvr_hv_8
Before and after on A78:
dmvr_hv_8_12x20_neon:                                  205.3 ( 5.21x)
dmvr_hv_8_20x12_neon:                                  171.8 ( 3.15x)
dmvr_hv_8_20x20_neon:                                  282.7 ( 3.11x)

dmvr_hv_8_12x20_neon:                                  172.7 ( 5.58x)
dmvr_hv_8_20x12_neon:                                  133.3 ( 3.36x)
dmvr_hv_8_20x20_neon:                                  214.6 ( 3.40x)
2025-09-05 07:20:15 +00:00
Jack Lau 85b5d4adf2 avformat/tls_gnutls: cleanup the pointer name
Pure cleanup, no functional changes
Unify local pointer names to `TLSContext *c` and `TLSShared *s` to
reduce confusion from inconsistent names (e.g. p, s, c)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:31:07 +00:00
Jack Lau 3c7315c345 avformat/whip: simplify the udp read in whip_write_packet
Reduce nested if statements to make the code structure clearer

Add logic to check if EOF is received from UDP socket.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:29:39 +00:00
Jack Lau 785a4e0d6c avformat/whip: fix potential 8bit overflow for profile_idc
The profile contains profile_idc and constraint_set*_flag,
throws away high 8 bit flags and then we get profile_idc.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:28:55 +00:00
Jack Lau 6c2768bf8c avformat/whip: fix 8 bits overflow and map constraint_set bits for H264
profile_iop is an 8 bits field. Previous code copied
AVCodecParameters::profile (which can contain bits
beyond 8 bits) into profile_iop, producing overflow
and wrong values.

This patch maps the constrained flags into the proper
profile_iop bits (constraint_set1 / 3)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:28:55 +00:00
Jack Lau 39a63e3d07 avformat/whip: make time measure more precise
Use av_gettime_relative() replace av_gettime() to get
better measure

Changed the display precision from showing only integers
to showing two decimal places (in milliseconds)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:28:24 +00:00
Jack Lau b41f8207c4 avformat/whip: fix SDP ICE candidates parsing
fix issue #20407

Refer to RFC 5245 15.1,
the foundation may be any string up to 32 chars.
The old code could misread foundations as transport("udp").
This patch fully parse all these attr to avoid parsing error.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 04:27:51 +00:00
Jack Lau 7fd967c2c1 avformat/whip: add PRIORITY and ICE_CONTROLLING for STUN binding request
fix issue #20402

See RFC 8445 7.1,
The PRIORITY and ICE-CONTROLLED or ICE-CONTROLLING must be included
in a Binding request.

FFmpeg is always ICE Controlling role so we use ICE-CONTROLLING attr.

Co-author-by: Sergio Garcia Murillo <sergio.garcia.murillo@gmail.com>
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-09-05 01:21:28 +00:00
Niklas Haas 8ff34b29c7 fate/filter-audio: update acrossfade to test multiple inputs 2025-09-04 23:12:34 +00:00
Niklas Haas dfc3256da1 avfilter/af_afade: support multiple inputs
Instead of just 2 files, generalize this filter to support crossfading
arbitrarily many files. This makes the filter essentially operate similar
to the `concat` filter, chaining multiple files one after another.

Aside from just adding more input pads, this requires rewriting the
activate function. Instead of a finite state machine, we keep track of the
currently active input index; and advance it only once the current input is
fully exhausted.

This results in arguably simpler logic overall.
2025-09-04 23:12:34 +00:00
Niklas Haas 81c1004891 avfilter/af_afade: shorten crossfade on too short inputs
This behavior is currently completely broken, leading to an abrupt end of the
first audio stream. I want to generalize this filter to multiple inputs, but
having too short input files will always represent a significant problem.

I considered a few approaches for how to handle this more gracefully, but
most of them come with their own problems; in particular when a short input
is sandwiched between two longer ones; or when there is a sequence of short
inputs. In the end, it's simplest to just shorten the crossfade window.

I also considered (and tested) padding the input with silence, but this also
has its own aesthetic implications and strange edge cases.

See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20388
2025-09-04 23:12:34 +00:00
Niklas Haas 2e0885a091 avfilter/af_afade: don't leak memory on error
This first frame was never cleaned up if the second input fails.
2025-09-04 23:12:34 +00:00
Niklas Haas 386264ae16 avfilter/af_afade: generalize pass_crossfade() signature
Prerequisite to an upcoming refactor.
2025-09-04 23:12:34 +00:00
Andreas Rheinhardt 2451e06f19 all: Use "" instead of <> to include internal headers
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 22:20:58 +02:00
Andreas Rheinhardt 7dc4c4f6f5 swscale/ops: Fix linking with x86 assembly disabled
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 22:14:39 +02:00
Ramiro Polla 6696a9b8bd avcodec/mjpegdec: ignore APPx stubs unless AV_EF_EXPLODE is set
Consider APPx fields that are too short to contain an id field (32-bit)
as stubs, and ignore them if AV_EF_EXPLODE is not set.

This has been seen in the MJPEG output from some webcams (such as the
Logitech C270 and C920) and the JPEG images embedded in DNG images
from the Pentax K-1 camera.
2025-09-04 15:28:41 +00:00
Ramiro Polla e207520b82 avcodec/mjpegdec: fix skipping of bytes for unknown APPx markers
The loop to skip the remaining bytes was off by one for all markers
except for Adob.

This patch uses post-decrement instead of pre-decrement in the while
loop to make the len value easier to understand, and updates the len
value to reflect this change for the Adob marker.
2025-09-04 15:28:41 +00:00
Andrey Semashev 9ee7796c54 avcodec/librsvgdec: fix compilation with librsvg 2.50.3
This fixes compilation with librsvg 2.50.3: error: viewport undeclared

This was a regression since commit
86ed68420d.

Fixes #10722.

Reviewed-by: Leo Izen <leo.izen@gmail.com>
2025-09-04 07:01:13 -04:00
Andreas Rheinhardt 2611874a50 avcodec/cbrt_tablegen: Deduplicate common code
Namely the part that creates a temporary LUT.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 10:15:09 +02:00
Andreas Rheinhardt 9bacefc41e avcodec/cbrt_tablegen: Avoid LUT only used once
This can be done by reusing the destination array to store
a temporary LUT (with only half the amount of elements, but
double the element size). This relies on certain assumptions
about sizes, but they are always fulfilled for systems supported
by us (sizeof(double) == 8 is needed/guaranteed since commit
3383a53e7d). Furthermore,
sizeof(uint32_t) is always >= four because CHAR_BIT is eight
(in fact, sizeof(uint32_t) is four, because the exact width
types don't have any padding).

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 10:15:03 +02:00
Andreas Rheinhardt cd337c46d5 avcodec/cbrt_tablegen: Reduce size of LUT only used once
ff_cbrt_tableinit{,_fixed}() uses a LUT of doubles of the same size
as the actual LUT to be initialized (8192 elems). Said LUT is only
used to initialize another LUT, but because it is static, the dirty
memory (64KiB) is not released. It is also too large to be put on
the stack.

This commit mitigates this: We only use a LUT for the powers of
odd values, thereby halving its size. The generated LUT stays unchanged.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 10:14:53 +02:00
Andreas Rheinhardt 77e5e61f1a avcodec/cbrt_tablegen: Remove always-false branch
Each ff_cbrt_tableinit*() is called at most once, making this
check always-false.

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-04 10:12:25 +02:00
Cameron Gutman 37f02603b1 avutil/hwcontext_drm: fix mapping when dst format is unset
av_hwframe_map() is documented to work with a blank dst frame, but
hwcontext_drm currently fails if dst->format == AV_PIX_FMT_NONE.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-09-03 20:21:51 -05:00
Wu Jianhua 858aa6176b avutil/version: bump minor after recent change
See c2ce387385

Signed-off-by: Wu Jianhua <toqsxw@outlook.com>
2025-09-03 22:34:40 +00:00
Andreas Rheinhardt 79058e7014 avformat/demux: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 21:10:21 +00:00
Andreas Rheinhardt e6c03711aa avformat/demux: Avoid always-true branch
Since 9d037c54f2 id3v2_extra_meta
can only be != NULL if the input format wants ID3v2 tags to be
read generically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 21:10:21 +00:00
Andreas Rheinhardt e918e202e0 avformat/avformat: Make AVFMT_FLAG_ID3V2_AUTO private
This flag governs whether avformat_open_input() reads
ID3v2 tags generically; some demuxers without this flag
read these tags themselves in a non-generic way,
e.g. oma. This makes this flag an implementation detail
that should not be exposed to the user, i.e. an internal flag.

Given that 9d037c54f2
did not bump version and added no APIchanges entry
I deemded it inappropriate to bump version or add
an APIchanges entry for the removal of AVFMT_FLAG_ID3V2_AUTO.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 21:10:21 +00:00
Martin Storsjö a3360c0eaf swscale: Don't pass a concrete SwsOpPriv as parameter
This fixes the following compiler error, if compiling with MSVC
for ARM (32 bit):

    src/libswscale/ops_chain.c(48): error C2719: 'priv': formal parameter with requested alignment of 16 won't be aligned

This change shouldn't affect the performance of this operation
(which in itself probably isn't relevant); instead of copying the
contents of the SwsOpPriv struct from the stack as parameter,
it gets copied straight from the caller function's stack frame
instead.

Separately from this issue, MSVC 17.8 and 17.9 end up in an
internal compiler error when compiling libswscale/ops.c, but
older and newer versions do compile it successfully.
2025-09-03 20:18:03 +00:00
nilfm 9d037c54f2 avformat/demux: avoid unconditional ID3v2 tag consumption
ID3v2 headers are now only parsed for formats that explicitly support them,
avoiding premature data consumption that broke demuxing in other formats.

Introduces AVFMT_FLAG_ID3V2_AUTO and applies it to mp3, aac, tta, and wav.

Signed-off-by: nilfm <nil.fons@gmail.com>
2025-09-03 10:44:02 -07:00
Andreas Rheinhardt cd21fa41c7 avformat/aviobuf: Don't pretend to support avio_context_free(NULL)
It makes no sense to ever call it that way given that
avio_context_free() accepts a pointer to a pointer to an AVIOContext.
Other double-pointer-free functions like av_freep() also do it
that way (and therefore avio_context_free(NULL) still crashes
even with 870cfed231).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 15:51:51 +02:00
Andreas Rheinhardt 66e40840d1 avcodec/pcm_tablegen: Fix CONFIG_HARDCODED_TABLES
Broken in ae448e00af.
Notice that config_components.h is safe to include,
as it is valid for both the host and the target
(in contrast to config.h).

Reviewed-by: Zhao Zhili <quinkblack@foxmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-09-03 14:13:37 +02:00
Araz Iusubov c2ce387385 avcodec/d3d12va_encode: texture array support for HEVC
This patch adds support for the texture array feature
used by AMD boards in the D3D12 HEVC encoder.
In texture array mode, a single texture array is shared for all
reference and reconstructed pictures using different subresources.
The implementation ensures compatibility
and has been successfully tested on AMD, Intel, and NVIDIA GPUs.
2025-09-03 11:56:06 +02:00
Zhao Zhili 6ce02bcc3a avcodec/aarch64/vvc: Optimize apply_bdof
Before this patch, prof_grad_filter calculate
gh[0], gh[1], gv[0], gv[1] and save them to stack.

derive_bdof_vx_vy load them from stack and calculate
gh[0] + gh[1], gv[0] + gv[1].

apply_bdof_min_block load them from stack and calculate
gh[0] - gh[1], gv[0] - gv[1]

This patch add bdof_grad_filter, which calculate gh[0] + gh[1],
gh[0] - gh[1], gv[0] + gv[1], gv[0] - gv[1], and save them to
stack, so derive_bdof_vx_vy and apply_bdof_min_block can use the
results directly.

prof_grad_filter is kept for reuse by other functions in the future.

Benchmark on rpi5 with gcc 12
                               Before               After
--------------------------------------------------------------------
apply_bdof_8_8x16_c:       |   7431.4 ( 1.00x)   |   7371.7 ( 1.00x)
apply_bdof_8_8x16_neon:    |   1175.4 ( 6.32x)   |   1036.3 ( 7.11x)
apply_bdof_8_16x8_c:       |   7182.2 ( 1.00x)   |   7201.1 ( 1.00x)
apply_bdof_8_16x8_neon:    |   1021.7 ( 7.03x)   |    879.9 ( 8.18x)
apply_bdof_8_16x16_c:      |  14577.1 ( 1.00x)   |  14589.3 ( 1.00x)
apply_bdof_8_16x16_neon:   |   2012.8 ( 7.24x)   |   1743.3 ( 8.37x)
apply_bdof_10_8x16_c:      |   7292.4 ( 1.00x)   |   7308.5 ( 1.00x)
apply_bdof_10_8x16_neon:   |   1156.3 ( 6.31x)   |   1045.3 ( 6.99x)
apply_bdof_10_16x8_c:      |   7112.4 ( 1.00x)   |   7214.4 ( 1.00x)
apply_bdof_10_16x8_neon:   |   1007.6 ( 7.06x)   |    904.8 ( 7.97x)
apply_bdof_10_16x16_c:     |  14363.3 ( 1.00x)   |  14476.4 ( 1.00x)
apply_bdof_10_16x16_neon:  |   1986.9 ( 7.23x)   |   1783.1 ( 8.12x)
apply_bdof_12_8x16_c:      |   7433.3 ( 1.00x)   |   7374.7 ( 1.00x)
apply_bdof_12_8x16_neon:   |   1155.9 ( 6.43x)   |   1040.8 ( 7.09x)
apply_bdof_12_16x8_c:      |   7171.1 ( 1.00x)   |   7376.3 ( 1.00x)
apply_bdof_12_16x8_neon:   |   1010.8 ( 7.09x)   |    899.4 ( 8.20x)
apply_bdof_12_16x16_c:     |  14515.5 ( 1.00x)   |  14731.5 ( 1.00x)
apply_bdof_12_16x16_neon:  |   1988.4 ( 7.30x)   |   1785.2 ( 8.25x)
2025-09-03 06:55:37 +00:00
Zhao Zhili 2e92417603 avcodec/aarch64/vvc: Optimize derive_bdof_vx_vy
Implement line tricks and pixel tricks. See comments in inter.S
for details.

Benchmark on rpi5 with gcc 12
                               Before             After
-----------------------------------------------------------------
apply_bdof_8_8x16_c:       |   7375.5 ( 1.00x) |  7473.8 ( 1.00x)
apply_bdof_8_8x16_neon:    |   1875.1 ( 3.93x) |  1135.8 ( 6.58x)
apply_bdof_8_16x8_c:       |   7273.9 ( 1.00x) |  7204.0 ( 1.00x)
apply_bdof_8_16x8_neon:    |   1738.2 ( 4.18x) |  1013.0 ( 7.11x)
apply_bdof_8_16x16_c:      |  14744.9 ( 1.00x) | 14712.6 ( 1.00x)
apply_bdof_8_16x16_neon:   |   3446.7 ( 4.28x) |  1997.7 ( 7.36x)
apply_bdof_10_8x16_c:      |   7352.4 ( 1.00x) |  7485.7 ( 1.00x)
apply_bdof_10_8x16_neon:   |   1861.0 ( 3.95x) |  1134.1 ( 6.60x)
apply_bdof_10_16x8_c:      |   7330.5 ( 1.00x) |  7232.8 ( 1.00x)
apply_bdof_10_16x8_neon:   |   1747.2 ( 4.20x) |  1002.6 ( 7.21x)
apply_bdof_10_16x16_c:     |  14522.4 ( 1.00x) | 14664.8 ( 1.00x)
apply_bdof_10_16x16_neon:  |   3490.5 ( 4.16x) |  1978.4 ( 7.41x)
apply_bdof_12_8x16_c:      |   7389.0 ( 1.00x) |  7380.1 ( 1.00x)
apply_bdof_12_8x16_neon:   |   1861.3 ( 3.97x) |  1134.0 ( 6.51x)
apply_bdof_12_16x8_c:      |   7283.1 ( 1.00x) |  7336.9 ( 1.00x)
apply_bdof_12_16x8_neon:   |   1749.1 ( 4.16x) |  1002.3 ( 7.32x)
apply_bdof_12_16x16_c:     |  14580.7 ( 1.00x) | 14502.7 ( 1.00x)
apply_bdof_12_16x16_neon:  |   3472.9 ( 4.20x) |  1978.3 ( 7.33x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-03 06:55:37 +00:00
damitha 3800421e7c add clamping for escpase coeff 2025-09-03 06:48:02 +00:00
Niklas Haas a700f0f72d avfilter/vf_zscale: simplify and fix alpha handling
There's no reason to use a completely separate graph just to process the
alpha plane in isolation - zimg supports native alpha handling as part of the
main image.

Fixes several issues with this filter when adding or removing alpha planes,
and also adds support for scaling premultiplied alpha (which reduces artefacts
near the image borders).
2025-09-02 17:06:25 +02:00
Niklas Haas c7adeb75ac avfilter/vf_scale: require straight alpha for alpha blending
Fortunately, we only care if this flag is set - otherwise, this filter is
alpha mode agnostic (since it is purely scaling, etc).

That said, there is an argument to be made that we should prefer premul
alpha when scaling, because scaling in straight alpha will leak garbage
pixels; but I think that would be a too backwards-incompatible change to
be worth thinking about at this time.
2025-09-02 17:06:25 +02:00
Niklas Haas 446a25b70f avfilter: add alpha_mode consistency assertion 2025-09-02 17:06:25 +02:00
Niklas Haas 39631c99d4 avfilter/drawutils: add alpha mode support
This allows drawing colors onto images with premultiplied alpha, by first
premultiplying the specified RGBA values.
2025-09-02 17:06:25 +02:00
Niklas Haas a90e8f1c1d avfilter: use ff_draw_init_from_link() where possible 2025-09-02 17:06:25 +02:00
Niklas Haas eddbdc8b7c avfilter/drawutils: add ff_draw_init_from_link()
The overwhelming majority of references to ff_draw_init2() just set the
colorspace properties from a filter link. This wrapper allows us to update
all such referencen automatically.
2025-09-02 17:06:25 +02:00
Niklas Haas d05484757a avfilter/vf_fade: set correct alpha mode requirement
Fading to black in non-alpha mode works for either straight or premultiplied
alpha, but fading to a color does not.
2025-09-02 17:06:25 +02:00
Niklas Haas ba8aa0e7b3 avfilter/x86/vf_overlay: simplify function signature
No reason to pass all the variables again, if we're already passing the
context.
2025-09-02 17:06:25 +02:00
Niklas Haas 59bb51a8f2 avfilter/vf_overlay: support premultiplied base layers
Conceptually, these are pretty simple to handle, since they are basically
equivalent to the case of alpha being absent, since the only thing the
destination alpha plane is used for is unpremultiplyng straight alpha.

For planar formats, the total number of cases doesn't change in principle,
since before this patch we have:

- alpha present, overlay straight
- alpha present, overlay premultiplied
- alpha absent, overlay straight
- alpha absent, overlay premultiplied

And now we have:

- main straight, overlay straight
- main straight, overlay premultiplied
- main premultiplied, overlay straight
- main premultiplied, overlay premultiplied

That said, we do gain some cases now that we used to (incorrectly) ignore,
like premultiplied yuva420p10.

Notably, we can skip defining separate functions for the case of main alpha
being absent, since that can be a single cheap branch inside the function
itself, on whether or not to also process the alpha plane. Otherwise, as long
as we treat "alpha absent" as "main premultiplied", the per-plane logic will
skip touching the nonexistent alpha plane.

The only format that actually needs extra cases is packed rgb, but that's only
two additional cases in total.

Also arguably simplifies the assignment logic massively.
2025-09-02 17:06:25 +02:00
Niklas Haas 6d6bbdaab0 avfilter/vf_overlay: rename variables for clarity
`is_straight`, `alpha_mode` etc. are more consistently named to refer to
either the main image, or the overlay.
2025-09-02 17:06:25 +02:00
Niklas Haas 6f3eddbedd avfilter/vf_overlay: configure alpha mode on the link
And use the link-tagged value instead of the hard-coded parameter.
2025-09-02 17:06:25 +02:00
Niklas Haas 1c8ca56a88 avfilter/vf_libplacebo: add an alpha_mode setting
Chooses the desired output alpha mode. Note that this depends on
an upstream version of libplacebo new enough to respect the corresponding
AVFrame field in pl_map_avframe_ex.
2025-09-02 17:06:25 +02:00
Niklas Haas dc02514f6b avfilter/vf_setparams: add alpha_mode parameter 2025-09-02 17:06:25 +02:00
Niklas Haas e6ab7fe582 avfilter/vf_scale: set correct alpha mode after format change
While vf_scale cannot directly convert between premultiplied and straight
alpha, the effective tagging can still change as a result of a change in
the pixel format (i.e. adding or removing an alpha channel).
2025-09-02 17:06:25 +02:00
Niklas Haas a3d518a57c avfilter/vf_extractplanes: require straight alpha input 2025-09-02 17:06:25 +02:00
Niklas Haas ab1bc440f7 avfilter/vf_alphamerge: configure correct alpha mode 2025-09-02 17:06:25 +02:00
Niklas Haas 2032820e90 fftools/ffprobe: add AVFrame.alpha_mode support 2025-09-02 17:06:25 +02:00
Niklas Haas 4f99026c9f fftools/ffplay: add alpha_mode support
SDL seems to hard-code straight alpha compositing.
2025-09-02 17:06:25 +02:00
Niklas Haas f07573f496 fftools/ffmpeg: add alpha_mode support
The implementation exactly mirrors the existing plumbing for color_ranges
and color_spaces.
2025-09-02 17:06:25 +02:00
Niklas Haas 2e2ca4e740 avfilter/vf_showinfo: print alpha mode when relevant 2025-09-02 17:06:25 +02:00
Niklas Haas 2b1ef029eb avfilter/vf_format: add alpha_modes parameter 2025-09-02 17:06:25 +02:00
Niklas Haas de297ae2fc avfilter/buffersrc: add alpha_mode parameter 2025-09-02 17:06:25 +02:00
Niklas Haas 0fbd90d78f avfilter/buffersink: add support for alpha modes 2025-09-02 17:06:25 +02:00
Niklas Haas 65580592c9 avcodec/jpegxl: parse and signal correct alpha mode
This header bit ("alpha_associated") was incorrectly ignored.
2025-09-02 17:06:25 +02:00
Niklas Haas 51572ff08a avcodec/libjxlenc: also attach extra channel info
Works around a bug where older versions of libjxl don't correctly forward
the alpha channel information to the extra channel info.
2025-09-02 17:06:25 +02:00
Niklas Haas a88cc0a53e avcodec/libjxl: set correct alpha mode
JPEG XL supports both premultiplied and straight alpha, and the basic info
struct contains signalling for this. Forward the correct tagging on decode
and encode.
2025-09-02 17:06:25 +02:00
Niklas Haas 702a5ac29b avcodec/exr: set correct alpha mode
OpenEXR always uses premultiplied alpha, as per the spec.

cf. https://openexr.com/en/latest/TechnicalIntroduction.html

> By convention, all color channels are premultiplied by alpha, so that
> `foreground + (1-alpha) x background` performs a correct “over” operation.
> (See Premultiplied vs. Un-Premultiplied Color Channels)
>
> In the visual effects industry premultiplied color channels are the norm,
> and application software packages typically use internal image
> representations that are also premultiplied.
2025-09-02 17:06:25 +02:00
Niklas Haas d6ce720765 avcodec/png: set correct alpha mode
PNG always uses straight alpha.

cf. https://www.w3.org/TR/PNG-Rationale.html

> Although each form of alpha storage has its advantages, we did not want to
> require all PNG viewers to handle both forms. We standardized on non-
> premultiplied alpha as being the lossless and more general case.
2025-09-02 17:06:25 +02:00
Niklas Haas 02d531ca05 avcodec/encode: enforce alpha mode compatibility at encode time
Error out if trying to encode frames with an incompatible alpha mode.
2025-09-02 17:06:25 +02:00
Niklas Haas ecebf9c693 avcodec/avcodec: add AVCodecContext.alpha_mode
Following in the footsteps of the previous commit, this commit adds the
new fields to AVCodecContext so we can start properly setting it on codecs,
as well as limiting the list of supported options to detect a format mismatch
during encode.

This commit also sets up the necessary infrastructure to start using the
newly added field in all codecs.
2025-09-02 17:06:24 +02:00
Niklas Haas fb3a4f6180 avfilter/formats: use vf_premultiply_dynamic for alpha mode autoconversion 2025-09-02 17:06:09 +02:00
Niklas Haas c39a67e64f avfilter/vf_premultiply: add dynamic variant of this filter
We need a filter that can premultiply and unpremultiply the alpha channel
dynamically, on demand, in response to the negotiated alpha mode, analogous
to how vf_scale operates. Introduce a new filter "vf_premultiply_dynamic"
that accomplishes this.
2025-09-02 17:06:09 +02:00
Niklas Haas 6bac13d20a avfilter/vf_premultiply: signal correct alpha mode
Set the output link according to the chosen direction, and the input link
to its opposite (unless the input is not in-place, in which case there is no
alpha channel).

Also update the alpha mode on the output frame, since it may differ.
2025-09-02 17:06:09 +02:00
Niklas Haas eea99a77ed avfilter: add link negotiation for AVAlphaMode 2025-09-02 17:06:08 +02:00
Niklas Haas 8b375b2ffd avfilter/avfiltergraph: allow different conversion filters per merger
Instead of hard-coding the assumption that all video properties are handled
by vf_scale, generalize the struct slightly to allow different conversion
filters for each property being merged. The avfiltergraph code creates a list
of conversion filters needed and inserts all of them at once.

Because a conversion filter might itself e.g. not support all formats,
it's possible that we need to go through the whole process of negotiating
formats multiple times, and keep adding conversion filters until all of them
are settled. Do this by simply jumping back to the beginning of the loop
to ensure that the `convertor_count` field remains contiguous.
2025-09-02 17:05:51 +02:00
Niklas Haas dbcdcaede8 avfilter/formats: fix param name on ff_set_common_color_spaces*
Purely cosmetic.
2025-09-02 17:05:51 +02:00
Niklas Haas 22929bd044 avutil/frame: add AVFrame.alpha_mode
FFmpeg currently handles alpha in a quasi-arbitrary way. Some filters/codecs
assume alpha is premultiplied, others assume it is independent. If there is
to be any hope for order in this chaos, we need to start by defining an enum
for the possible range of values.
2025-09-02 17:05:50 +02:00
Nicolas Gaullier f24474dcfc avcodec/aac_ac3_parser: do not override the profile set by the decoder
Parsing the ADTS header is not enough to detect HE-AAC v1/v2.

Regression since 64bb91fd3b.

Fixes #11600

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 16:05:46 +02:00
Nicolas Gaullier 593b426902 avcodec/aac_ac3_parser: simplify
Use ff_adts_header_parse_buf() wrapper to simplify as GetBitContext is
no longer needed (it was introduced for USAC).

Partially reverts 64bb91fd3b.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 16:05:46 +02:00
Nicolas Gaullier 9bd10fa32c avcodec/aac_ac3_parser: remove unused USAC/ADTS code
ff_adts_header_parse() parse the object_type from a 2 bits field.
See also 696ea1c223.

Partially reverts 64bb91fd3b.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 16:05:46 +02:00
Maryla Ustarroz-Calonge 5e210f0552 avcodec/libaom: Add test for HDR10+ metadata support
Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 16:05:45 +02:00
Maryla Ustarroz-Calonge a282500087 avcodec/libaom: Add HDR10+ metadata support
Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 15:56:56 +02:00
Patrick Wang d7173e982e fftools/ffmpeg: fix gracefully shutdown
d119ae2fd8 removed the loop-breaking condition
received_sigterm.
Thus, signals no longer gracefully shutdown ffmpeg.

Fixes: #10834

Signed-off-by: Patrick Wang <mail6543210@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 15:56:27 +02:00
Zsolt Vadasz 173988aa0c libavfilter/vf_minterpolate: Use local variable in array
Signed-off-by: Zsolt Vadasz <zsolt_vadasz@protonmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 15:56:23 +02:00
Zsolt Vadasz 5d7e4b7496 libavfilter/vf_minterpolate: Hoist hot loop in set_frame_data
Signed-off-by: Zsolt Vadasz <zsolt_vadasz@protonmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-09-02 15:56:02 +02:00
Niklas Haas 5d3538b8dc .forgejo/CODEOWNERS: add myself for various files 2025-09-02 13:17:02 +00:00
Martin Storsjö 5a893c1806 checkasm: sw_ops: Avoid division by zero
If we're invoked with range == UINT_MAX, we end up doing
"rnd() % (UINT_MAX + 1)", which is equal to "rnd() % 0". On
arm (on all platforms) and on MSVC i386, this ends up crashing
at runtime.

This fixes the crash.
2025-09-02 14:28:56 +03:00
Zhao Zhili a0e00bed88 swscale/ops: fix build with msvc
x86/ops.c(500): error C2099: initializer is not a constant
2025-09-02 10:28:56 +00:00
Niklas Haas ef856ef93e avfilter/vf_libplacebo: also output a frame during input gaps
In constant FPS mode, it's possible for there no be *no* input active at
the current timestamp, even though there would be active inputs later in
the timeline (nb_active > 0). This would previously hit the AVERROR_BUG case.

With this change, we can instead output an empty frame.
2025-09-02 09:55:31 +00:00
Niklas Haas 68c083c43f avfilter/vf_libplacebo: refactor status handling
Instead of having a single s->status field to track the most recently
EOF'd stream, track the number of active streams directly and only query
the most recent status at the end.

The reason this worked before is because we implicitly relied on the
assumption that `ok` would always be true until all streams are EOF, but
because it's possible to have gaps in the timeline when mixing multiple
streams, this is not always the case in principle.

In practice, this fixes a bug where the filter would early-exit (EOF)
too soon, when any input reached EOF and there is a gap in the timeline.
2025-09-02 09:55:31 +00:00
Niklas Haas fc5a6a3b39 avfilter/vf_libplacebo: allow rendering empty frames
When using libplacebo to composite multiple streams with complex PTS
values, it's possible for there to be a "hole" in the output stream; in
particular in constant FPS mode. This commit refactors output_frame() to
allow it to handle the case of there being no active input.
2025-09-02 09:55:31 +00:00
James Almer 1069d457c6 configure: report if unstable is enabled
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 22:37:17 -03:00
James Almer eed5843392 configure: fix logic for the unstable option
A --enable-* option should not have a condition where it's enabled by some
other mean, as is the case here if swscale is enabled.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 22:31:07 -03:00
Niklas Haas 4ec2bffe62 configure: allow disabling experimental swscale code
In theory we can also expand this to disable e.g. experimental codecs.
2025-09-01 19:28:36 +02:00
Niklas Haas cc42bc1f4b swscale/graph: allow experimental use of new format handler
The humor originally contained in this commit message has been
redacted to comply with the strict FFmpeg code quality standards.
2025-09-01 19:28:36 +02:00
Niklas Haas f8f7935a97 swscale/format: add new format decode/encode logic
This patch adds format handling code for the new operations. This entails
fully decoding a format to standardized RGB, and the inverse.

Handling it this way means we can always guarantee that a conversion path
exists from A to B without having to explicitly cover logic for each path;
and choosing RGB instead of YUV as the intermediate (as was done in swscale
v1) is more flexible with regards to enabling further operations such as
primaries conversions, linear scaling, etc.

In the case of YUV->YUV transform, the redundant matrix multiplication will
be canceled out anyways.
2025-09-01 19:28:36 +02:00
Niklas Haas 5e6ffa0376 tests/checkasm: add checkasm tests for swscale ops
Because of the lack of an external ABI on low-level kernels, we cannot
directly test internal functions. Instead, we construct a minimal op chain
consisting of a read, the op to be tested, and a write.

The bigger complication arises from the fact that the backend may generate
arbitrary internal state that needs to be passed back to the implementation,
which means we cannot directly call `func_ref` on the generated chain. To get
around this, always compile the op chain twice - once using the backend to be
tested, and once using the reference C backend.

The actual entry point may also just be a shared wrapper, so we need to
be very careful to run checkasm_check_func() on a pseudo-pointer that will
actually be unique for each combination of backend and active CPU flags.
2025-09-01 19:28:36 +02:00
Niklas Haas 982d3a98d0 swscale/x86: add SIMD backend
This covers most 8-bit and 16-bit ops, and some 32-bit ops. It also covers all
floating point operations. While this is not yet 100% coverage, it's good
enough for the vast majority of formats out there.

Of special note is the packed shuffle fast path, which uses pshufb at vector
sizes up to AVX512.
2025-09-01 19:28:36 +02:00
Niklas Haas a151b426f9 swscale/ops_memcpy: add 'memcpy' backend for plane->plane copies
Provides a generic fast path for any operation list that can be decomposed
into a series of memcpy and memset operations.

25% faster than the x86 backend for yuv444p -> yuva444p
33% faster than the x86 backend for gray -> yuvj444p
2025-09-01 19:28:36 +02:00
Niklas Haas 5aef513fb4 swscale/ops_backend: add reference backend basend on C templates
This will serve as a reference for the SIMD backends to come. That said,
with auto-vectorization enabled, the performance of this is not atrocious.
It easily beats the old C code and sometimes even the old SIMD.

In theory, we can dramatically speed it up by using GCC vectors instead of
arrays, but the performance gains from this are too dependent on exact GCC
versions and flags, so it practice it's not a substitute for a SIMD
implementation.
2025-09-01 19:28:36 +02:00
Niklas Haas 99d73064f5 swscale/ops_chain: add internal abstraction for kernel linking
See doc/swscale-v2.txt for design details.
2025-09-01 19:28:36 +02:00
Niklas Haas 696f3be322 swscale/optimizer: add packed shuffle solver
This can turn any compatible sequence of operations into a single packed
shuffle, including packed swizzling, grayscale->RGB conversion, endianness
swapping, RGB bit depth conversions, rgb24->rgb0 alpha clearing and more.
2025-09-01 19:28:36 +02:00
Niklas Haas db2bc11a97 swscale/ops: add dispatch layer
This handles the low-level execution of an op list, and integration into
the SwsGraph infrastructure. To handle frames with insufficient padding in
the stride (or a width smaller than one block size), we use a fallback loop
that pads the last column of pixels using `memcpy` into an appropriately
sized buffer.
2025-09-01 19:28:36 +02:00
Niklas Haas d3ca0e300d swscale/ops_internal: add internal ops backend API
This adds an internal API for ops backends, which are responsible for
compiling op lists into executable functions.
2025-09-01 19:28:36 +02:00
Niklas Haas ea9ca3ff35 swscale/optimizer: add high-level ops optimizer
This is responsible for taking a "naive" ops list and optimizing it
as much as possible. Also includes a small analyzer that generates component
metadata for use by the optimizer.
2025-09-01 19:28:36 +02:00
Niklas Haas 16e191c8ef swscale/ops: introduce new low level framework
See docs/swscale-v2.txt for an in-depth introduction to the new approach.

This commit merely introduces the ops definitions and boilerplate functions.
The subsequent commits will flesh out the underlying implementation.
2025-09-01 19:28:36 +02:00
Niklas Haas ce0938da8c swscale: add SWS_UNSTABLE flag
Give users and developers a way to opt in to the new format conversion code,
and more code from the swscale rewrite in general, even while development is
still ongoing.
2025-09-01 19:28:35 +02:00
Niklas Haas 8406c56b0c tests/checkasm: generalize DEF_CHECKASM_CHECK_FUNC to floats
We split the standard macro into its body (implementation) and declaration,
and use a macro argument in place of the raw `memcmp` call, with the major
difference that we now take the number of pixels to compare instead of the
number of bytes (to match the signature of float_near_ulp_array).
2025-09-01 19:27:53 +02:00
Niklas Haas faf62cbdf5 tests/checkasm: increase number of runs in between measurements
Sometimes, when measuring very small functions, rdtsc is not accurate enough
to get a reliable measurement. This increases the number of runs inside the
inner loop from 4 to 32, which should help a lot. Less important when using
the more precise linux-perf API, but still useful.

There should be no user-visible change since the number of runs is adjusted
to keep the total time spent measuring the same.
2025-09-01 19:27:53 +02:00
Niklas Haas 5a28f392b9 tests/swscale: avoid binary literals
These are C23-only.
2025-09-01 19:27:53 +02:00
Niklas Haas 322f606fa8 swscale/format: add ff_fmt_clear()
Reset an SwsFormat to its fully unset/invalid state.
2025-09-01 19:27:53 +02:00
Niklas Haas 041a318299 swscale/format: rename legacy format conversion table 2025-09-01 19:27:53 +02:00
Niklas Haas c18676aae4 swscale/graph: pass per-pass image pointers to setup()
This behavior had no real justification and was just incredibly confusing,
since the in/out pointers passet to setup() did not match those passed to
run(), all for what is arguably an exception anyways (the palette setup).
2025-09-01 19:27:53 +02:00
Zhao Zhili eb14d45824 avfilter/vf_colordetect: add aarch64 asm
| rpi5 gcc 12  | m1 clang -fno-vectorize | m1 clang
---------------------------------------------------------------------------
alpha_8_full_c:        | 32159.2 ( 1.00x) | 135.8 ( 1.00x) |  26.4 ( 1.00x)
alpha_8_full_neon:     |  1266.0 (25.40x) |   8.0 (17.03x) |   8.4 ( 3.15x)
alpha_8_limited_c:     | 37561.9 ( 1.00x) | 169.1 ( 1.00x) |  47.7 ( 1.00x)
alpha_8_limited_neon:  |  3967.0 ( 9.47x) |  12.5 (13.53x) |  13.3 ( 3.59x)
alpha_16_full_c:       | 15867.9 ( 1.00x) |  64.5 ( 1.00x) |  13.7 ( 1.00x)
alpha_16_full_neon:    |  1256.9 (12.62x) |   7.9 ( 8.15x) |   8.3 ( 1.64x)
alpha_16_limited_c:    | 16723.7 ( 1.00x) |  88.7 ( 1.00x) | 103.3 ( 1.00x)
alpha_16_limited_neon: |  4031.3 ( 4.15x) |  12.5 ( 7.08x) |  13.2 ( 7.86x)
range_8_c:             | 21819.7 ( 1.00x) | 120.0 ( 1.00x) |   9.4 ( 1.00x)
range_8_neon:          |  1148.3 (19.00x) |   4.3 (27.60x) |   4.8 ( 1.97x)
range_16_c:            | 10757.1 ( 1.00x) |  45.7 ( 1.00x) |   7.9 ( 1.00x)
range_16_neon:         |  1141.5 ( 9.42x) |   4.4 (10.38x) |   4.6 ( 1.72x)
2025-09-01 15:35:16 +00:00
Zhao Zhili 6450e01446 checkasm/vf_colordetect: test non-aligned width 2025-09-01 15:35:16 +00:00
Niklas Haas f07c12d806 avfilter/x86/vf_colordetect: fix alpha detect tail handling
This wrapping logic still considered any nonzero return from the ASM function
to be the overall result, but this is not true since the addition of
FF_ALPHA_TRANSPARENT.

Fix it by only early returning if FF_ALPHA_STRAIGHT is detected.

Fixes: 9b8b78a815
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20301#issuecomment-4802
2025-09-01 15:33:43 +00:00
James Almer 9dc79241d9 avcodec/decode: always extract display matrix from Exif in frames
Should help ensure no conflicting values are propagated.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:08:04 -03:00
James Almer 6a15183e6a avcodec/decode: parse Exif packet side data before passing it to frames
Extract Orientation and export it as a display matrix if present, and set the
frame's metadata with the remaining Exif entries.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:59 -03:00
James Almer fa1938c574 avcodec/decode: use ff_frame_new_side_data() to export Exif side data
Otherwise, the user requested priority of packet side data will be ignored.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:41 -03:00
James Almer 75bd5056a4 avcodec/decode: use av_exif_get_tag_id() where useful
Removes dependency on exif_internal.h

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:41 -03:00
James Almer 310be1c5a4 avformat/mov: export Exif metadata from HEIF streams
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:35 -03:00
James Almer 74e430202d avformat/mov: make items referencing items generic
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:14 -03:00
James Almer 6a115e2066 avformat/mov: reduce code duplication when setting tile group properties
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:14 -03:00
James Almer 11d9d7b8f3 avformat/dump: print side data type names generically
Based on vf_showinfo behavior.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:14 -03:00
James Almer e62f9a071b ffprobe: print EXIF packet side data size
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:14 -03:00
James Almer 4ffd621523 avcodec/packet: add an Exif side data type
Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 12:07:07 -03:00
James Almer 45dcfb2d60 avcodec/version_major: remove unnecessary define for an internal function
It being avpriv and not public, it can be removed in the next bump regardless of when it
happens.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-09-01 11:00:44 -03:00
Henrik Gramner a66a260ae9 vp9: Add 8bpc intra prediction AVX2 asm 2025-09-01 13:54:52 +00:00
Zhao Zhili 9a34ddc345 avformat/movenc: remove mvex from final mp4 in hybrid_fragmented mode
In hybrid_fragmented mode, the first moov at start should contain
mvex tag, since it's fmp4. When writing the moov at the second time,
it's not fmp4 any more, so mvex should be skipped.
2025-09-01 12:41:38 +00:00
Cameron Gutman 126671e730 avcodec/mfenc: add AVLowLatencyMode support
Set CODECAPI_AVLowLatencyMode when AV_CODEC_FLAG_LOW_DELAY is enabled on
the AVCodecContext. AVLowLatencyMode can acheive lower latency encoding
that may not be accessible using eAVScenarioInfo options alone.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-09-01 12:40:36 +00:00
Zhao Zhili f2414fb1aa .forgejo/CODEOWNERS: add myself for various files
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-09-01 11:14:30 +00:00
Martin Storsjö 3ea6c2fe25 aacencdsp: Improve consistency with assembly, for x87 math
Currently, the aacencdsp checkasm tests fails for many seeds,
if the C code has been built with x87 math. This happens because
the excess precision of x87 math can make it end up rounding
to a different integer, and the checkasm tests checks that the
output integers match exactly between C and assembly.

One such failing case is "tests/checkasm/checkasm --test=aacencdsp
41" when compiled with GCC. When compiled with Clang, the test
seed 21 produces a failure.

To avoid the issue, we need to limit the precision of intermediates
to their nominal float range, matching the assembly implementations.

This can be achieved when compiling with GCC, by just adding a single
cast.

To observe the effect of this cast, compile the following
snippet,

    int cast(float a, float b) {
        return (int)
    #ifdef CAST
            (float)
    #endif
            (a + b);
    }

with "gcc -m32 -std=c17 -O2", with/without -DCAST. For x86_64
cases (without the "-m32"), the cast doesn't make any difference
on the generated code.

This cast would seem to not have any effect, as a binary expression
with float inputs also would have the type float.

However, if compiling with GCC with -fexcess-precision=standard,
the cast forces limiting the precision according to the language
standard here - according to the GCC docs [1]:

> When compiling C or C++, if -fexcess-precision=standard is
> specified then excess precision follows the rules specified in
> ISO C99 or C++; in particular, both casts and assignments cause
> values to be rounded to their semantic types (whereas -ffloat-store
> only affects assignments). This option is enabled by default for
> C or C++ if a strict conformance option such as -std=c99 or
> -std=c++17 is used.

Ffmpeg's configure scripts enables -std=c17 by default.

This only helps with GCC though - the cast doesn't make any
difference for Clang. (Although, upstream Clang seems to default
to SSE math, while Ubuntu provided Clang defaults to x87 math.)
Limiting the precision with Clang would require casting to volatile
float for both intermediates here - and that does have a code
generation effect on all architectures.

[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
2025-09-01 09:22:39 +00:00
Timo Rothenpieler 883162d5b4 forgejo/workflows: make autolabel workflow always use token from secrets
Using the built-in token seems to only partially work.
And in the latest Forgejo release the issue forcing the use of the
built-in token was fixed with:

https://codeberg.org/forgejo/forgejo/pulls/9025
2025-09-01 03:02:51 +02:00
Cameron Gutman b2910ec92e avcodec/mfenc: fix memory leak with D3D11 input surfaces
Fixes: d56522c6eb ("avcodec/mfenc: add support for D3D11 input surfaces")
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-08-31 14:36:20 -05:00
YiboFang ae448e00af avcodec/pcm: use compile-time guards for PCM table init
Change the PCM table init to use compile-time #if instead of a runtime
`if (CONFIG_...)`. This makes sure code for disabled encoders never gets
built, without depending on compiler dead-code elimination.

Signed-off-by: YiboFang <fangyibo@xiaomi.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-08-31 21:40:29 +08:00
Gyan Doshi f317b6c052 lavc/codec_desc: add lossless flags for hevc and av1
Both codecs support a lossless mode akin to H.264/AVC
2025-08-31 16:48:03 +05:30
Tong Wu 9893d66add avcodec/d3d12va_encode: add max_frame_size option
Add the max_frame_size option to support setting max frame size in
bytes. Max frame size is the maximum cap in the bitrate algorithm per
each encoded frame.

Signed-off-by: Tong Wu <wutong1208@outlook.com>
2025-08-31 10:46:11 +00:00
Marton Balint 2296a9c1bc avutil/bprint: fix av_bprint_strftime with %p format string reporting truncated output
strftime returns 0 in case of an empty output (e.g. %p format string with some
locales), there is no way to distinguish this from a buffer-too-small error
condition. So we must use some heuristics to handle this case, and not consume
INT_MAX RAM and falsely report a truncated output.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-31 09:37:59 +02:00
Marton Balint 50e94aadb2 avutil/bprint: make av_bprintf use av_vbprintf
No reason to duplicate the code.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-31 09:37:59 +02:00
Peter Ross 16d32a1c1d libavcodec/dpxenc: map AVCodecContext color transfer and color primaries fields 2025-08-31 07:05:36 +00:00
Peter Ross 6d7daaab0a avcodec/dpx: move enum DPX_TRC and DPX_COL_SPEC to dpx.h 2025-08-31 07:05:36 +00:00
Marton Balint 7a774829f9 avutil/opt: also print option names on parse error
It is more user-friendly to print which option caused the parse error.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-30 18:46:15 +00:00
Vittorio Palmisano 73d411c399 avfilter/af_whisper: fix srt file format
The SRT file format requires commas in the time string, not periods.
2025-08-30 14:30:51 +00:00
Leo Izen 3a0e324ab9 .forge/CODEOWNERS: add myself to EXIF code
Now that the major EXIF overhaul has been merged, I should be suggested
to review patches that modify it.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-30 08:34:34 -04:00
James Almer 2fffa01ddb avcodec/x86/vp9dsp_init: remove preprocessor checks for some prototypes
Fixes compilation with --disable-avx512icl

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-29 14:02:49 -03:00
Nicolas Gaullier 7252f6c0bf avcodec/version: update the codec_ids
The counters should be incremented for each new codec.
Catch-up to be in sync with codec_id.h again.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2025-08-29 17:32:52 +02:00
Niklas Haas 4ede75b5f4 swscale/graph: fix double-free when legacy pass fails initializing
If this function returns an error after ff_sws_graph_add_pass() has been
called, and the pass->free callback is therefore already set up to free the
context, the graph will end up freed twice: once by the pass->free callback
(during ff_sws_graph_free()), and once before that by failure path of the
caller (e.g. add_legacy_sws_pass(), or init_legacy_subpass() itself for
cascaded contexts.)

The solution is to redefine the ownership of SwsGraph to pass clearly from
the caller of add_legacy_sws_pass() to init_legacy_subpass(), which can then
deal with appropriately freeing the context conditional on whether or not the
pass was already registered in the pass list.

Reported-by: 김영민 <kunshim@naver.com>
Signed-off-by: Niklas Haas <git@haasn.dev>
2025-08-29 13:22:03 +00:00
Daniil Cherednik 0828a3b636 avcodec/atrac3: fix inconsistent band num calculation
'decode_spectrum' reads 5 bits from bitstream to get
number of encoded subbands – so 31 means all 32
subbands are encoded. This value also is used to
determinate the number of used band in the hybrid
filterbank.

'subband_tab' array contains 33 values of MDCT spec
line positions started from 0 line and used to map
subband number in to the range of mdct lines.

Since the subband_num returned by decode_spectrum
actually is number – 1 and subband_tab started from 0
we need to add 1 to make num_bands calculation correct.
2025-08-29 12:29:52 +00:00
Timo Rothenpieler e3f01682d7 forgejo/labeler: react to 'labeled' action as well 2025-08-29 01:12:20 +02:00
Henrik Gramner 10a061ba99 vp9: Add AVX-512ICL asm for 8bpc subpel mc 2025-08-28 12:45:52 +00:00
Michael Niedermayer 76645e096f avcodec/exif: also copy zero termination for AV_TIFF_STRING
Fixes: out of array read
Fixes: 441131173/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_DEC_fuzzer-6700429212975104

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-27 15:46:35 +00:00
Leo Izen 041651841a avcodec/libjxlenc: fix leaked EXIF ifd
We're missing a call to av_exif_free here. We leak the internal heap-
allocated objects when &ifd goes out of scope.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-27 05:28:31 -04:00
Leo Izen a8d6b87a44 avcodec/libjxldec: fix leaked EXIF ifd
We're missing a call to av_exif_free here. We leak the internal heap-
allocated objects when &ifd goes out of scope.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-27 05:26:03 -04:00
Levi Zim c2d17c4db8 avutil/riscv: avoid redefinition of _GNU_SOURCE
Add #ifndef to avoid potential redefinition of _GNU_SOURCE macro.

Signed-off-by: Levi Zim <rsworktech@outlook.com>
2025-08-26 15:08:52 +00:00
James Almer 70a6ad6c74 fftools/ffmpeg_demux: ensure the display_rotation option is honored
If requested, it should have priotity over any coded value.
Fixes ticket #11649.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-26 11:44:09 -03:00
Raphaël Zumer ae14930176 avcodec/webp: simplify special-case handling when building Huffman reader
Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
2025-08-26 14:42:47 +00:00
Raphaël Zumer d1a7a20cb1 avcodec/webp: fix incorrectly returning AVERROR_INVALIDDATA when building Huffman reader
This corrects an error in commit c33f16d.

Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
2025-08-26 14:42:47 +00:00
Marton Balint a8097d32ae avformat/img2dec: remove deprecated glob_sequence pattern type
"glob_sequence" was deprecated since 2012. This also changes the default pattern
to "sequence", because "glob_sequence" was also the default.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-26 14:41:44 +00:00
Jack Lau 4811518143 avformat/whip: set the first sequence number for video and audio
simply whip->audio_first_seq + 1 for video could be
faster than generating a new one.

this patch will make whip be able to get the first
rtp seq easily and compute something sequence-based
(e.g. NACK and RTX handling)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-26 02:36:06 +00:00
James Almer db2af6fd42 configure: support linking to base profile libxev{d,e}
Addresses issue #20328.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-25 18:47:56 +00:00
James Almer fa23202cc7 configure: bump LCEVCdec minimum required version to 4.0.0
The project introduced API breaking changes to some of their public functions,
and given the library is relatively new, just bump the minimum supported
version instead of adding ifdeffery to the source files.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-25 10:43:23 -03:00
yangsen5 6c07a4f558 avformat/file: add pkt_size option
The min_packet_size/max_packet_size were hardcoded to 256KB for
performance. The new option makes it possible to configure a
smaller packet size on embedded devices with limited memory
resources.

Signed-off-by: yangsen5 <1441923451@qq.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-08-25 18:15:17 +08:00
Robert Nagy 1b62f9d3ae avfilter/vf_scale: add more color_matrix aliases
Add more color_matrix aliases to make vf_scale consistent with e.g. vf_setparams aliases.
2025-08-25 08:12:37 +00:00
Muiz Yusuff 2ffc138e8a mov demuxer: use int64_t for next_ts
d1b96c3808 fixes some hevc seeking issues
but will int overflow when timestamp is >int_max.
2025-08-25 02:25:50 +00:00
James Almer 7df9fae4f7 Changelog: move the latest entries to the correct section
They are not in 8.0

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-24 23:23:48 -03:00
Leo Izen ef9fe0fe0b avcodec/exif: avoid allocation failure on empty EXIF metadata
An EXIF IFD with 0 entries is legal, but does not contain metadata. We
should not attempt to allocate a struct with size zero in this case, as
this causes an allocation failure. Instead, we just leave the struct
empty.

Fixes: #20305.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-24 20:20:10 +00:00
Leo Izen 2398fddf6e avcodec/exif: avoid writing native-endian EXIF buffers
Currently there's platform-dependent behavior where if no endianness
is requested, it writes the buffers in native-endian. This breaks FATE
tests on big-endian architecture. This commit changes the default to
little-endian buffers upon writing.

Fixes: #20291.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-24 20:20:10 +00:00
James Almer 2298d4d072 doc/APIchanges: add 8.0 cut line
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-24 12:08:27 -03:00
Damiano Galassi b2f5bc7fd3 movenc: ensure chapters track extradata is not null and populated
fix a regression introduced in 4eca8df,
writing chapters failed if chapters where
not available before mov_write_header().
2025-08-24 13:31:53 +00:00
James Almer 368b5e0ffc avcodec/exif: make the get and remove helpers take a flags argument as input
This makes the functions extensible, as future behavior change flags can be
introduced.

This is strictly speaking not an API break. Only if a user was setting
recursive to anything other than 1 it would now behave differently, but given
these functions have been in the tree for only a few days, the chances for that
are practically zero.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-24 12:34:15 +00:00
Jack Lau b3ea558492 avformat/whip: fix ssrc might be same
use audio_ssrc + 1 for video_ssrc to avoid ssrc collision

See RFC 3550 Section 8,
The SSRC identifier carried in the RTP header and in various fields
of RTCP packets is a random 32 bit number that is required to be
globally unique within an RTP session.

simply + 1 also can get an unique ssrc, and faster than generating
new unique ssrc.

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-23 17:20:32 +08:00
Frank Plowman 673f28b6cb lavc/Makefile: Make exif.o compulsory
av_exif_* functions are part of libavcodec's public API since
ad77345a5d, so the EXIF objects can't
be disabled.

Fixes compilation with --disable-everything.
2025-08-22 22:44:07 +00:00
Timo Rothenpieler 0f873fc07a forgejo/workflows: use built-in token for autolabeler whenever possible 2025-08-22 21:07:33 +02:00
iddq 4e9a184d5c avformat/tcp: add option for enabling TCP keepalive 2025-08-22 18:20:08 +00:00
Peter Ross f62d878911 .forgejo/CODEOWNERS: add myself for various files 2025-08-22 08:01:26 +00:00
James Almer 5ed1d72792 avcodec/decode: remove Exif Orientation tag after adding it as display matrix
Don't replace it with a conflicting value.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-21 22:48:16 +00:00
James Almer 5a9e5d8031 avcodec/exif: use ff_frame_new_side_data() to export display matrix
Otherwise, the user requested priority of packet side data will be ignored.
For this, move the relevant functions to decode.c, as they need access to an
AVCodecContext.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-21 22:48:16 +00:00
Manuel Lauss d311382c38 avcodec/sanm: fix issues with FTCH offset hack
Just add an extra x/y offset parameter pair to process_frame_obj(),
and store the size of the data to FTCH in a separate context member.
The only valid sizes for FTCH are 6 and 12, reject any other.
Finally, if a FOBJ uses codecs37 and above, enforce it to be subversion 2,
to use the simpler STOR/FTCH method.

Fixes BIGSLEEP-440183164/process_ftch.anim

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-21 21:02:40 +00:00
Michael Niedermayer c41a70b6bb avcodec/sanm: Eliminate reference into reallocated frame
AFAIK the original decoder uses the frame buffers in very strange ways
our implementation seems to mimic that and that results in the
bitstream input to point into a frame buffer while code then
parses that and potentially reallocates the frame buffer
leaving pointers hanging into dealllocated space

This simply uses a temporary buffer

Fixes: Writing into freed buffers
Fixes: BIGSLEEP-440183164/old_codec21.anim
Fixes: BIGSLEEP-440183164/old_codec4.anim

Found-by: Google Big Sleep

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-21 21:02:40 +00:00
Michael Niedermayer d4e28917af avcodec/sanm: Replace impossible bitstream check by assert
the space left and size have already been cross checked by the caller

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-21 21:02:40 +00:00
Leo Izen 7caa2a65d9 avcodec/exif: fix some coverity errors
This commit fixes some memory and security issues due to improper
sanitizing and checks.

Fixes:
 - CID 1665100..1665107

Signed-off-by: Leo Izen <leo.izen@gmail.com>
Reportedy-by: James Almer <jamrial@gmail.com>
2025-08-21 15:40:45 -04:00
Manuel Lauss d4eb01f281 avcodec/sanm: handle xpal cmd 0
It's like cmd 2. Fixes the Rebel Assault 1 Intro Video "C1BLOCK.ANM"
crossfade from planet view to space view and subsequent wrong colors.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-08-21 16:24:26 +00:00
Niklas Haas 6825f6f1e2 avfilter/vf_libplacebo: add bwdif option
See-Also: https://code.videolan.org/videolan/libplacebo/-/merge_requests/737
2025-08-21 15:34:03 +00:00
Timo Rothenpieler 5bd866b6ed forgejo/workflows: cat config.log on configure failure 2025-08-21 15:08:50 +00:00
Timo Rothenpieler 8591227e1f forgejo/workflows: also run 32bit fate tests 2025-08-21 15:08:50 +00:00
Niklas Haas 8e0de5d811 avfilter/setpts: also preserve duration when not stripping fps
It makes sense to treat the presence of a frame duration and the presence
of frame rate metadata identically - because both convey effectively the same
amount of information.

In f121d95 and fa110c3 respectively, this information was stripped by default,
originally to work-around bugs when changing the PTS information of a stream
being fed to some encoders. (See https://trac.ffmpeg.org/ticket/10886)

Later, commit 959b799c restored the ability to preserve the frame rate
medatata via the `strip_fps` option, but this option did not extend to also
include the frame duration.

This commit resolves the scenario by making `frame_rate` and `duration`
handled in a consistent manner, so that the frame rate information is
generally preserved unless explicitly stripped by the user.

While it does regress the exact invocation presented in the trac ticket unless
using `strip_fps=yes`, I consider this an acceptable trade-off, especially in
light of the fact that the `fps` filter also exists and is arguably the better
tool for the task at hand.
2025-08-21 14:55:12 +02:00
Zhao Zhili 2796ce20d9 avfilter/vf_colordetect: Reorder to avoid null pointer check
Follow the general practice to assign the C implementation to DSP,
then the SIMD-optimized version.
2025-08-21 11:01:35 +08:00
Ronald S. Bultje 4d7c609be3 .forgejo/CODEOWNERS: add myself for vp8, vp9, wmavoice and csp. 2025-08-20 19:50:01 +00:00
Jacob Lifshay b9695c45c3 forgejo/CODEOWNERS: add myself
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-20 18:17:14 +00:00
Niklas Haas 67c15cf541 avutil/hwcontext_vulkan: add debug option to avoid host ptr imports
In some environments, these are prohibitively slow. Add a debug option
to prefer memcpy instead of importing host pointers.
2025-08-20 15:05:41 +00:00
Niklas Haas a7efcbd0e3 avutil/hwcontext_vulkan: check driver ID instead of hard-coded vendor check 2025-08-20 15:05:41 +00:00
Niklas Haas 78beb4f5f4 avutil/hwcontext_vulkan: don't re-query driver props in qf setup
This is already queried when the device is selected, so there's no need
to re-query the exact same struct.
2025-08-20 15:05:41 +00:00
Niklas Haas 881224b213 avutil/hwcontext_vulkan: also re-query dprops in device_init()
This can be unset if using an externally provided device, as in this case
device_create() never gets called.
2025-08-20 15:05:41 +00:00
James Almer d151d3aecb avcodec/exif: don't expose a private function in an installed header
And it doesn't need an entry in APIChanges, given it's not public API.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-20 10:44:12 -03:00
Lynne 451e6bed43 lavfi/bwdif_vulkan: fix typo in temp_diff assignment
Thanks to Niklas Haas for pointing this out.
2025-08-20 22:06:21 +09:00
Zhao Zhili b8856c5fc5 avcodec/hevc: Fix invalid null pointer check
c5287178b4 added a null pointer check, but checked the wrong
variable. &s->cur_frame->f->data[c_idx] cannot be null.
2025-08-20 11:52:32 +00:00
Manuel Lauss 990edfee5b libavcodec/vima: reindent
Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-08-20 11:20:14 +02:00
Manuel Lauss 9141fe9653 avcodec/vima: IMA4 subtag support
Support decoding of the IMA4 ADPCM QT scheme used in some LucasArts
SANM files.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-08-20 11:20:14 +02:00
Manuel Lauss 1e95f1b269 avcodec/adpcm: export ff_adpcm_ima_qt_expand_nibble
For use in the LucasArts VIMA decoder, where it is used as a subvariant.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-08-20 11:20:11 +02:00
Leo Izen 4c3f94f265 doc/APIChanges: document EXIF API additions
Many of these additions are in separate commits in one set, so in the
interest of clarity, the API changes are all documented in one commmit
here.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:32:06 -04:00
Leo Izen fe496b0308 avcodec/libjxlenc: apply displaymatrix side data orientation to output
If the output is tagged with AV_FRAME_DATA_DISPLAYMATRIX we will read
it and apply it to the output file.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 535a07d14e avcodec/exif: add ff_exif_sanitize_ifd
This commit takes some of the sanitize code used by ff_exif_get_buffer
and exposes it as an ff_ API, so encoders who wish to modify the
sanitized IFD before calling av_exif_write can do so.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 8132ee046d avcodec/libjxldec: read EXIF metadata from container JPEG XL files
libjxl provides the ability to get EXIF metadata from an ISO18181-2
JPEG XL container file. This commit enables reading it and attaching
it to an AVFrame using the new EXIF API.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 5d4f873ff3 fftools/ffprobe: print EXIF side data size
We don't need to print the tags here because they're added as dict
elements to AVFrame->metadata and are printed elsewhere with ffprobe
-show_frames.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 1e816ebefe avcodec/tiff: decode TIFF non-image-data tags into EXIF metadata struct
This commit will cause TIFF files to store their tags in the EXIF
struct so tags such as orientation can be transfered to other formats
(such as PNG) in a way that doesn't corrupt the IFD.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 93a8091015 avcodec/exif: add av_exif_get_entry
Add an API function to retrieve am AVExifEntry struct with a given TIFF
tag ID from the AVExifMetadata ifd struct.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 303f60684f avcodec/exif: add av_exif_remove_entry
Add an API function that allows popping an exif entry out of the struct
entirely rather than requiring it be replaced with a default value.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:48 -04:00
Leo Izen 5caaadee79 avcodec/exif: add orientation ID and matrix conversion routines
Takes existing code that makes display matricies work with EXIF
orientation tags and expose the conversion as a public API.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen d3190a64c3 avcodec/pngenc: support writing EXIF profiles
Add support to write EXIF profiles using the new EXIF framework, namely
ff_exif_get_buffer, and writing them into eXIf chunks.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen 44af382979 avcodec/pngdec: support reading EXIF profiles
Add support to parse eXIf chunks using the new EXIF framework, as well
as EXIF profiles in zTXt and tEXt with Raw profile type exif.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen f5ad1c910c avcodec/exif: add ff_exif_get_buffer
Add a function to allow encoders to get a self-contained EXIF
buffer to write into an EXIF chunk.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen e3aa1154aa avcodec/exif: remove ff_exif_decode_ifd
This function is no longer called and its functionality
can be accessed using the new API in exif.h as well as the
various internal attach functions in exif_internal.h.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen c6cc2115f4 avcodec/webp: use new EXIF parse API
Switch over to the new API to parse EXIF metadata.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen 52dba25661 avcodec/mjpegdec: use new EXIF parse API
Switch over to the new API to parse EXIF metadata.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen bfb17d2630 avcodec/exif: add deprecation guards for old avpriv_
Add FF_API_OLD_EXIF deprecation guard based on lavc version < 62 in
order to allow removing the avpriv_ next major version bump.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:47 -04:00
Leo Izen ba2ea285e0 avformat/avidec: use new EXIF metadata API instead of avpriv_
This commit switches avidec to use the new metadata API exposed by
the previous commit instead of relying on the existing avipriv_ function
exposed by lavc.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:46 -04:00
Leo Izen ad77345a5d avcodec/exif: add EXIF parser and struct API
This commit adds a structure to contain parsed EXIF metadata, as well
as code to read and write that struct from/to binary EXIF buffers. Some
internal functions have been moved to exif_internal.h. Code to read
from this new struct and write to an AVDictionary **dict has been added
as well in order to preserve interoperability with existing callers.
The only codec changes so far as of this commit are to call these
interop functions, but in future commits there will be codec changes to
use the new parsing routines instead.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:46 -04:00
Leo Izen bb90b262d6 avutil/side_data: add EXIF side data type
This commit adds support for the additional side data type
AV_FRAME_DATA_EXIF, which contains a buffer of an EXIF metadata
payload.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:46 -04:00
Leo Izen a99fff4e2d avcodec/tiff_common: rename TIFF enum constants
This makes the enum TiffTypes public by moving it to the public header
exif.h and renaming it to AVTiffDataType, as well as adding an AV_
prefix in front of each of the entry names. This allows callers to use
enum AVTiffDataType without pulling in all of tiff_common.h, as that
header is not public.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-19 11:26:40 -04:00
vytskalt a6b5a382dd hwcontext_vulkan: transfer EXCLUSIVE images to correct queue families 2025-08-19 14:34:17 +00:00
Lynne c05fc27dd3 aacdec_usac: use RefStruct to track unfinished extension buffers
Extensions in AAC USAC can be stored across multiple frames (mainly to keep CBR compliance).
This means that we need to reallocate a buffer when new data is received, accumulate the bitstream data,
and so on until the end of extension flag is signalled and the extension can be decoded.

This is made more complicated by the way in which the AAC channel layout switching is performed.
After decades of evolution, our AAC decoder evolved to double-buffer its entire configuration.
All changes are buffered, verified, and applied, on a per-frame basis if required, in often
random order.

Since we allocate the extension data on heap, this means that if configuration is applied,
in order to avoid double-freeing, we have to keep track of what we've allocated.

It should be noted that extensions which are spread in multiple frames are generally rare,
so an optimization to introduce av_refstruct_realloc() wouldn't generally be useful across the codebase.
Therefore, a copy is good enough for now.

Thanks to Michael Niedermayer for additional fixing.

Fixes: double free
Fixes: 393523547/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_LATM_fuzzer-6740617236905984

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
2025-08-19 14:32:21 +00:00
Michael Niedermayer cdee519d40 avcodec/dxv: Check coded_height, to avoid invalid av_clip()
Fixes: assertion failure
Fixes: 438961582/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5850827739955200

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-19 11:25:39 -03:00
Michael Niedermayer 0a5046c099 avcode: Use av_fast_realloc() in ff_lzf_uncompress()
Fixes: 438961582/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5850827739955200
Fixes: mixed up realloc() functions

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Co-Authored-by: James Almer <jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-19 11:25:39 -03:00
Benjamin Cheng 7bfaa6d662 vulkan_vp9: Read segment and lf data from cbs
The previous change 26a2a76346 broke Vulkan decoding because the lf and
segmentation values contained within VP9RawFrameHeader can no longer be
updated.

Read the propogated values from the CBS instead.
2025-08-19 10:07:01 -04:00
Michael Niedermayer fcf180d9ea avcodec/aac/aacdec: dont allow ff_aac_output_configure() allocating a new frame if it has no frame
Fixes: null pointer dereference
Fixes: crash_test.mp4

Found-by: Intel PSIRT
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-19 12:58:38 +00:00
Levi Zim 163518ffab avutil/riscv: add fallthrough comment to switch
This fixes the following warning:

libavutil/riscv/cpu.c:85:9: warning: label at end of compound statement is a C23 extension [-Wc23-extensions]

Signed-off-by: Levi Zim <rsworktech@outlook.com>
2025-08-19 11:29:18 +08:00
Michael Niedermayer 0243cf89b1 avformat/lrcdec: Fix fate-sub-lrc-ms-remux on x86-32
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-18 22:02:47 +00:00
Michael Niedermayer ca20d42cd7 swscale/swscale_internal: Use more precisse gamma
Avoids failure of xyz12 fate tests on mingw and linux x86-32

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-18 19:12:46 +00:00
Niklas Haas 9b8b78a815 avfilter/vf_colordetect: detect fully opaque alpha planes
It can be useful to know if the alpha plane consists of fully opaque
pixels or not, in which case it can e.g. safely be stripped.

This only requires a very minor modification to the AVX2 routines, adding
an extra AND on the read alpha value with the reference alpha value, and a
single extra cheap test per line.

detect_alpha_8_full_c:                                2849.1 ( 1.00x)
detect_alpha_8_full_avx2:                              260.3 (10.95x)
detect_alpha_8_full_avx512icl:                         130.2 (21.87x)
detect_alpha_8_limited_c:                             8349.2 ( 1.00x)
detect_alpha_8_limited_avx2:                           756.6 (11.04x)
detect_alpha_8_limited_avx512icl:                      364.2 (22.93x)
detect_alpha_16_full_c:                               1652.8 ( 1.00x)
detect_alpha_16_full_avx2:                             236.5 ( 6.99x)
detect_alpha_16_full_avx512icl:                        134.6 (12.28x)
detect_alpha_16_limited_c:                            5263.1 ( 1.00x)
detect_alpha_16_limited_avx2:                          797.4 ( 6.60x)
detect_alpha_16_limited_avx512icl:                     400.3 (13.15x)
2025-08-18 18:50:00 +00:00
Niklas Haas ae3c5ac2c1 avfilter/vf_colordetect: remove extra safety margin on premul check
This safety margin was motivated by the fact that vf_premultiply sometimes
produces such illegally high values, but this has since been fixed by
603334a043, so there's no more reason to have this safety margin, at
least for our own code. (Of course, other sources may also produce such
broken files, but we shouldn't work around that - garbage in, garbage out.)

See-Also: 603334a043
2025-08-18 18:50:00 +00:00
Niklas Haas c96ccd78fc avfilter/vf_colordetect: rename p, q, k variables for clarity
Purely cosmetic.

Motivated in part because I want to depend on the assumption that P
represents the maximum alpha channel value.
2025-08-18 18:50:00 +00:00
Niklas Haas 2968f30a15 tests/checkasm/vf_colordetect: also test opaque alpha base case
Preemptively adding a check for a following commit.
2025-08-18 18:50:00 +00:00
Niklas Haas 34ad857d2b avfilter/vf_colordetect: slightly change detect_alpha() signature
Basically cosmetic.

I want to expand this to detect more than a single property about the alpha
channel at the same time; so we first need a way for this function to
return a more complex result.

Move the enum AlphaMode to the header and formally generalize the return
signature a bit to allow returning more than just one value.
2025-08-18 18:50:00 +00:00
Andreas Hartmann 11a89bfe7b ffmpeg_opt: Parse regular options in ffpreset files
instead of only AV-specific options. The previous code assumed that any
option not defining the codec in an `ffpreset` file is an AVOption. This
for example prevented the use of options defined in `OptionDef[]`, like
`-pix_fmt`, as part of preset files, requiring users to type these out
every time.

Closes: #1530
Signed-off-by: Andreas Hartmann <hartan@7x.de>
2025-08-18 13:54:30 +00:00
Zane van Iperen d5c8f2268f .forgejo/CODEOWNERS: add myself to relevant files
To formats I've written in lavf, and adpcm-related things in lavc.

Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
2025-08-18 09:51:41 -04:00
Manuel Lauss 0226b6fb2c avcodec/sanm: bl16: fix artifacts in larger videos
The DOS/Windows decoder precomputes a table of linear offsets of
all motion vectors given the current image width.
For larger widths (>=762), the pairs starting at indices 1 and 254
of motion_vectors[] will overflow the int16_t, changing the sign.

Playing back the 800x600 "jonesopn_8.snm" video of "Indiana Jones and
the Infernal Machine" reveals a lot of artifacts and a lot of
"Ignoring invalid motion vector (149, -41)->(136, 0), block size = 8"
messages, hinting at the wrong direction of the motion vectors.

Fix this by doing the calculation that the DOS/Windows players do,
let the value overflow and reextract the "new" mvec x/y components.
2025-08-18 09:11:09 +00:00
Valerii Zapodovnikov 8426622bb9 avformat/avio: clarify that AVSEEK_FORCE has no effect
avio_seek() never supported SEEK_END and returned AVERROR(EINVAL) when
specified, so the later check "(whence != SEEK_END || force)" was always true.

This also means that AVSEEK_FORCE had no effect since 7a6fe01f99, that is 15
years ago. Rather than changing behaviour, let's document instead that the flag
has no effect.

Also fixed other commit 41ed7ab45f which confused ORing / passing AVSEEK_FORCE
and AVSEEK_SIZE in the docs.

Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
2025-08-17 20:47:11 +00:00
Michael Niedermayer 134fbfd1dc avcodec/sanm: Check w,h,left,top
The setup code fow w,h,left,top is complex, the code using it also falls in
at least 2 different classes, one using left/top the other not.

To ensure no out of array access happens we add this clear check.

Fixes: out of array access
Fixes: 439261995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5383455572819968

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-17 15:39:33 +02:00
James Almer a2cfaf1b91 avformat/mov: pass stream index to sanity_checks on HEIF images
Instead of item_id. Same behavior as with standard video tracks.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-16 21:59:18 -03:00
James Almer a28e01a6c1 avformat/mov: don't use an allocated array for sample_size with HEIF images
The array is only ever needed for streams where each sample entry may have a
different value. Given that for non animated HEIF there's a single value that
applies to the image, use the field defined for that.

Fixes: NULL pointer dereference
Fixes: 437528618/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6537287645331456

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-16 21:59:18 -03:00
Gyan Doshi 7df9271272 avfilter/whisper: correct option formatting 2025-08-17 00:58:03 +00:00
Zhao Zhili 1d06e8ddcd avfilter/af_whisper: fix broken output for multibyte character
text + 1 can break a multibyte character, e.g., Chinese in UTF-8.
There is no space at the beginning in this case.
2025-08-16 13:58:14 +00:00
Leo Izen 30e6956920 .forgejo/CODEOWNERS: add myself to JPEG XL and PNG
Add myself to JPEG XL and PNG decoders/encoders/parsers/etc. as a
suggested reviewer. I'm the maintainer of the JXL files and I know the
PNG code very well.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-16 05:07:19 -04:00
Jack Lau 37507c6a78 avformat/whip: remove DTLSState enum
This patch aims to simplify the dtls handshake process
since dtls handshake use force block mode

We can just use the return code instead of DTLSState enum

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-16 06:25:04 +00:00
Michael Niedermayer 50affd2b09 avcodec/rv60dec: clear pu_info
pu_info is read uninitialized on damaged input and at that point the following codepath is dependant
on the uninitialized data. In one of these pathes out of array accesses happen.
None of this is replicatable

Less uninitialized data also should result in more reproducable reports

Fixes: Use of uninitialized memory
Fixes: 418335931/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RV60_fuzzer-5103986067963904

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-16 00:24:52 +00:00
Kacper Michajłow 61d0050924 avformat/tls_openssl: simplify fingerprint generation
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow 4676f97928 avformat/tls_openssl: clean keys serialization
It was unnecessary convoluted, remove not needed memory allocations,
snprintf.

Also fixes posibility to call snprinft with NULL as %s input.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow 113c9c6cf3 configure: require at least OpenSSL 1.1.1 (LTS)
Commit f256487cd8 bumped requirement to
1.1.0 for OPENSSL_init_ssl.

Bump this again to 1.1.1, because it was an LTS version. Although it has
no mainline support anymore, it still has paid/premium support. 1.1.0 has
no support at all.

Motivated for use of BIO_read_ex() for next commits.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow 3a8b3dfeca avformat/tls_openssl: use ascii - (0x2D) instead of 0x2010 hyphen
Too much AI is bad for you...

Fixes: 167e343bbe
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-16 00:15:30 +00:00
Kacper Michajłow 1f4fed5cc3 w32pthreads: add support for setting thread name
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-15 19:54:01 +00:00
Kacper Michajłow 5ff2500514 avcodec/x86/Makefile: add missing x86/proresdsp.o for prores raw 2025-08-15 20:45:20 +02:00
wangbin 6e48050568 configure: fix -L flags for lld-link 2025-08-15 18:20:33 +00:00
Michael Niedermayer 2a22972db3 avcodec/utvideodec: Clear plane_start array
in pack mode the array is passed into decode_plane() without being initialized or used

Fixes: use of uninitialized memory
Fixes: 438780119/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_UTVIDEO_DEC_fuzzer-5464037027807232

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-15 18:00:11 +02:00
Oliver Chang c9e93df4ee avcodec/prores_raw: Fix heap buffer overflow
When dimensions differ from context, those were updated using
ff_set_dimensions, however this overwrote the aligned coded_width and
coded_height that were set before, leading to a buffer overflow when
writing the frame data.

Fixes: OssFuzz 438771336
Fixes: Heap-buffer-overflow

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Marvin Scholz <epirat07@gmail.com>
Reviewed-by: Marvin Scholz <epirat07@gmail.com>
2025-08-15 15:06:58 +00:00
David Rosca ac5303a5b9 hw_base_encode: Support refs option to limit number of references
Set default value to 0 to keep the old behavior of using maximum number
of references.
2025-08-15 13:55:51 +00:00
Michael Niedermayer 7d606ef0cc .forgejo/CODEOWNERS: remove reference to secret apparently uncommited code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-15 00:51:23 +02:00
Kacper Michajłow 47c6af7d29 avutil/avassert: always implement av_assume with av_unreachable
One of the design goals of this macro is the ability to support static
inline predicate functions. Which is emitting warning in clang that a
function may have side-effects and the condition will be ignored. MSVC
doesn't emit warning, but also ignore predicate in such cases.

Instead of using assume builtins, implement it using unreachable. Which
solves this case for MSVC and Clang.

This reverts ea56fe60ac, but also extends
it to MSVC, which is affected in the similar way.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 19:42:13 +00:00
Kacper Michajłow 3ab9eebba7 avcodec/Makefile: add missing dependency for prores raw decoder (again)
proresdata.o is also needed, missed in a9e7b5aa07

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 18:06:49 +02:00
Pavel Koshevoy a7c8c4ee1c lavc/mfenc: set output packet duration
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-14 11:13:09 -03:00
Leo Izen 1532caaab0 RELEASE: update to 8.0 2025-08-14 08:42:29 -04:00
devjeonghwan 243b392d83 avformat/apngdec: allow other chunks between fcTL and fdAT/IDAT 2025-08-14 08:05:21 -04:00
Kacper Michajłow a9e7b5aa07 avcodec/Makefile: add missing dependency for prores raw decoder
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 04:43:16 +02:00
Michael Niedermayer cdbb5f1b93 fftools/ffmpeg_mux_init: Use 64bit for score computation in map_auto_video()
Fixes: signed integer overflow: 10 * 1952737655 cannot be represented in type 'int'
Fixes: PoC_avi_demux

Found-by: 2ourc3 (Salim LARGO)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-14 00:36:29 +00:00
Kacper Michajłow 589b934417 compat/getopt: constify opts
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 00:08:10 +00:00
Kacper Michajłow d3375101fe avcodec/vp8: remove set, but never used variable
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 00:08:10 +00:00
Kacper Michajłow 218ef98ea3 avcodec/j2kenc: remove set, but never used variable
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 00:08:10 +00:00
Kacper Michajłow c5093f59c8 avcodec/x86/vc1dsp: add missing header for HAVE_6REGS
x86/vc1dsp_init.c already includes asm.h before, so this is mostly
cosmetic change and only to clean checkheaders warning.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-14 00:08:10 +00:00
softworkz 1ad97b82f3 fftools/resources: Update .gitignore
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-08-13 17:39:49 +00:00
softworkz a125f5db03 ffbuild/commonmak: Consolidate pattern rules for compression
This commit simplifies and consolidates all the rules around
ptx and resource file compression.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-08-13 17:39:49 +00:00
softworkz f52d9dd869 fftools/resources: Fix double-build by disabling .d file generation
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-08-13 17:39:49 +00:00
James Almer 230fafe68a tests/fate/cbs: add a test for gray apv
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-13 11:42:50 -03:00
James Almer 64b6cfe7fb tests/fate/cbs: move redundant_pps tests to the proper location
cbs.mak is meant to contain tests strictly for the CBS framework, not for any
bsf that happens to use it under the hood.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-13 11:36:22 -03:00
Kacper Michajłow 8eca3fa619 configure: use proper Windows-style static library naming
On Windows, static libraries are typically named with a .lib extension.
An exception to this is MinGW targets, which are treated as a distinct
target-os.

Using Windows-style naming allows `clang` to be used as the linker
driver, instead of invoking link or lld-link directly. The latter
approach requires manually specifying standard libraries when compiling
with `clang` rather than `clang-cl`, and manually specifying standard
libraries may be error-prone or incomplete.

Using Windows-style naming allows Clang to be used as the linker driver,
instead of invoking link or lld-link directly. The latter approach
requires manually specifying standard libraries, which may be
error-prone or incomplete.

This change also improves support for LTO and sanitizer builds, where
it's significantly easier to let the compiler driver manage the
necessary linker flags.

It fixes issues where Clang is asked to link `-lavcodec`, which gets
passed to the linker as avcodec.lib, resulting in an error like:
lld-link: error: could not open 'avcodec.lib': no such file or directory
This happens because `libavcodec.a` was unexpectedly generated, not
`avcodec.lib` expected by tooling.

Additionally, using `clang` (not `clang-cl`) is simplified, as it does
not use autolinking like MSVC/clang-cl does. Now `--ld=clang` can be
used to add all the required libraries. Previously, building with
`clang` was only possible by using `--ld=lld-link` and manually
specifying system dependencies in `extra-ldflags`.

Note that those changes doesn't affect mingw build. MSVC builds will
produce .lib static libraries now, but the linking process itself is not
affected, because filenames are passed directly.

To summarize in Windows non-mingw builds:
Static builds now produce `lib/avcodec.lib` instead of `lib/libavcodec.a`.
Shared builds remain unchanged, producing `bin/avcodec.lib` together with
`bin/avcodec-62.dll`.

This also removes setting LD_LIB from Win32/64 target as there is one
type of .lib in practice. We cannot build both shared and static at the
same time as noted by the next line.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-13 13:17:53 +00:00
Jiasheng Jiang b8d5f65b9e libavfilter/dnn/dnn_backend_tf: Remove redundant av_freep() to avoid double free
Remove redundant av_freep() to avoid double free since task will be freed in dnn_free_model_tf() after the success of ff_queue_push_back().

Fixes: af052f9066 ("lavfi/dnn: fix mem leak in TF backend error handle")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
2025-08-13 19:50:26 +08:00
Michael Niedermayer fd31df4306 tools: Split the list of source plugins out of "merge-all-source-plugins" 2025-08-13 11:50:52 +00:00
Michael Niedermayer b5b306ca31 tools/merge-all-source-plugins: Fix merge_internal() return code
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 11:50:52 +00:00
Michael Niedermayer 373bd80b16 avcodec/dxv: Use av_fast_realloc() for op_data
makes things consistent

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Michael Niedermayer 4e5f25c0a5 avcodec/dxv: Clear ctex
same issue as with tex

Fixes: 431665305/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5339599339847680
Fixes: use of uninitialized memory

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Michael Niedermayer 6a8c41dcac avcodec/dxv: Check that we initialize op_data
Fixes: 431665305/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-5339599339847680
Fixes: use of uninitialized memory

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Michael Niedermayer 4a0b793737 avcodec/dxv: Use av_fast_realloc() and clear all new space
The code writing in the buffer has a wide range of error checks
which simply leave it partly uninitialized.

Initializing it on allocation ensures no sensitive data leaks and that
bugs are more reliably reproduceable

Fixes: use of uninitialized memory
Fixes: 435225510/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DXV_DEC_fuzzer-4521918634196992

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Michael Niedermayer d5bdb0b705 avcodec/sanm: Check mv in codec48_block()
Fixes: out of array read
Fixes: 436943287/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SANM_fuzzer-5011037029203968

This issue did oddly enough, not replicate

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 10:12:07 +00:00
Andy Nguyen 870cfed231 avformat/aviobuf: Free white/black list in avio_context_free()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-13 09:46:36 +00:00
Marton Balint b61e510e75 swscale/swscale_unscaled: use 8 line alignment for planarCopyWrapper with dithering
Dithering relies on a 8 line dithering table and the code always uses it from
the beginning. So in order to make dithering independent from height of the
slices used we must enforce a 8 line alignment.

Fixes issue #20071.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-08-12 21:56:09 +00:00
James Almer 3ef2ea890b avcodec/apv_decode: set decoder as skip frame fill param capable
No need to decode potentially huge frames just to get stream params.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-12 19:59:21 +00:00
James Almer 084b67f6e3 avcodec/apv: port to the receive_frame() API
You can technically feed the decoder a single packet with more than one AU in
it, even if a demuxer is unlikely to ever export such a thing.
Given the parser does no packetization to ensure we get a single AU, in order
to not discard any frame beyond the first, the decoupled input/output API
should be used.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-12 19:59:21 +00:00
James Almer 4b39d776c3 avcodec/cbs_apv: store derived tile information in a per frame basis
If a single fragment contains more than one frame unit, the tile information stored
in the private context will only correspond to one of them.

Fixes: crash (out of array access)
Fixes: 435489659/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-6194885205229568

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2025-08-12 19:59:21 +00:00
Michael Niedermayer 0469d68acb avcodec/exr: Check for pixel type consistency in DWA
Fixes: out of array access
Fixes: BIGSLEEP-436511754/testcase.exr

Found-by: Google Big Sleep
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-12 12:21:09 +02:00
Dale Curtis 069201c535 avcodec/h264_refs: Make ff_h264_build_ref_list stricter with AV_EF_EXPLODE
Don't silently skip errors when AV_EF_EXPLODE is specified.

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-12 11:38:45 +02:00
Dash Santosh 6f9e8a599d checkasm/swscale: fix whitespace issues 2025-08-12 09:05:00 +00:00
Dash Santosh ca2a88c1b3 swscale/output: Implement yuv2nv12cx neon assembly
yuv2nv12cX_2_512_accurate_c:                          3540.1 ( 1.00x)
yuv2nv12cX_2_512_accurate_neon:                        408.0 ( 8.68x)
yuv2nv12cX_2_512_approximate_c:                       3521.4 ( 1.00x)
yuv2nv12cX_2_512_approximate_neon:                     409.2 ( 8.61x)
yuv2nv12cX_4_512_accurate_c:                          4740.0 ( 1.00x)
yuv2nv12cX_4_512_accurate_neon:                        604.4 ( 7.84x)
yuv2nv12cX_4_512_approximate_c:                       4681.9 ( 1.00x)
yuv2nv12cX_4_512_approximate_neon:                     603.3 ( 7.76x)
yuv2nv12cX_8_512_accurate_c:                          7273.1 ( 1.00x)
yuv2nv12cX_8_512_accurate_neon:                       1012.2 ( 7.19x)
yuv2nv12cX_8_512_approximate_c:                       7223.0 ( 1.00x)
yuv2nv12cX_8_512_approximate_neon:                    1015.8 ( 7.11x)
yuv2nv12cX_16_512_accurate_c:                        13762.0 ( 1.00x)
yuv2nv12cX_16_512_accurate_neon:                      1761.4 ( 7.81x)
yuv2nv12cX_16_512_approximate_c:                     13884.0 ( 1.00x)
yuv2nv12cX_16_512_approximate_neon:                   1766.8 ( 7.86x)

Benchmarked on:
Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) CPU
3417 Mhz, 12 Core(s), 12 Logical Processor(s)
2025-08-12 09:05:00 +00:00
Logaprakash Ramajayam 49477972b7 swscale/aarch64/output: Implement neon assembly for yuv2planeX_10_c_template()
yuv2yuvX_8_2_0_512_accurate_c:                        2213.4 ( 1.00x)
yuv2yuvX_8_2_0_512_accurate_neon:                      147.5 (15.01x)
yuv2yuvX_8_2_0_512_approximate_c:                     2203.9 ( 1.00x)
yuv2yuvX_8_2_0_512_approximate_neon:                   154.1 (14.30x)
yuv2yuvX_8_2_16_512_accurate_c:                       2147.2 ( 1.00x)
yuv2yuvX_8_2_16_512_accurate_neon:                     150.8 (14.24x)
yuv2yuvX_8_2_16_512_approximate_c:                    2149.7 ( 1.00x)
yuv2yuvX_8_2_16_512_approximate_neon:                  146.8 (14.64x)
yuv2yuvX_8_2_32_512_accurate_c:                       2078.9 ( 1.00x)
yuv2yuvX_8_2_32_512_accurate_neon:                     139.0 (14.95x)
yuv2yuvX_8_2_32_512_approximate_c:                    2083.7 ( 1.00x)
yuv2yuvX_8_2_32_512_approximate_neon:                  140.5 (14.84x)
yuv2yuvX_8_2_48_512_accurate_c:                       2010.7 ( 1.00x)
yuv2yuvX_8_2_48_512_accurate_neon:                     138.2 (14.55x)
yuv2yuvX_8_2_48_512_approximate_c:                    2012.6 ( 1.00x)
yuv2yuvX_8_2_48_512_approximate_neon:                  141.2 (14.26x)
yuv2yuvX_10LE_16_0_512_accurate_c:                    7874.1 ( 1.00x)
yuv2yuvX_10LE_16_0_512_accurate_neon:                  831.6 ( 9.47x)
yuv2yuvX_10LE_16_0_512_approximate_c:                 7918.1 ( 1.00x)
yuv2yuvX_10LE_16_0_512_approximate_neon:               836.1 ( 9.47x)
yuv2yuvX_10LE_16_16_512_accurate_c:                   7630.9 ( 1.00x)
yuv2yuvX_10LE_16_16_512_accurate_neon:                 804.5 ( 9.49x)
yuv2yuvX_10LE_16_16_512_approximate_c:                7724.7 ( 1.00x)
yuv2yuvX_10LE_16_16_512_approximate_neon:              808.6 ( 9.55x)
yuv2yuvX_10LE_16_32_512_accurate_c:                   7436.4 ( 1.00x)
yuv2yuvX_10LE_16_32_512_accurate_neon:                 780.4 ( 9.53x)
yuv2yuvX_10LE_16_32_512_approximate_c:                7366.7 ( 1.00x)
yuv2yuvX_10LE_16_32_512_approximate_neon:              780.5 ( 9.44x)
yuv2yuvX_10LE_16_48_512_accurate_c:                   7099.9 ( 1.00x)
yuv2yuvX_10LE_16_48_512_accurate_neon:                 761.0 ( 9.33x)
yuv2yuvX_10LE_16_48_512_approximate_c:                7097.6 ( 1.00x)
yuv2yuvX_10LE_16_48_512_approximate_neon:              754.6 ( 9.41x)

Benchmarked on:
Snapdragon(R) X Elite - X1E80100 - Qualcomm(R) Oryon(TM) CPU
3417 Mhz, 12 Core(s), 12 Logical Processor(s)
2025-08-12 09:05:00 +00:00
Niklas Haas 5929d46f7b avfilter/vf_vignette: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas ec3c9ecaa7 avfilter/vf_tonemap: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas a75f673713 avfilter/vf_selectivecolor: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 2cdf4f08b4 avfilter/vf_scdet_vulkan: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 7751f261de avfilter/vf_scdet: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas dee56511b0 avfilter/vf_scale_vulkan: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas bd59c6651b avfilter/vf_photosensitivity: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 663a37f7f9 avfilter/vf_libvmaf: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas a45113c28a avfilter/vf_libplacebo: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas ea72804295 avfilter/vf_gblur_vulkan: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas d1d64c804e avfilter/vf_freezedetect: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas d276875c90 avfilter/vf_drawtext: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 029f501a95 avfilter/vf_drawbox: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 86387038f8 avfilter/vf_delogo: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas b02d6fc556 avfilter/vf_dctdnoiz: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas d84a21a023 avfilter/vf_curves: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 8c51a8b954 avfilter/vf_blackdetect_vulkan: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 0b7827cd10 avfilter/vf_blackdetect: log with correct filter ID
If we use the private BlackDetectContext for logging, the filter ID does
not get printed alongside the filter name. Using the parent AVFilterContext
makes this consistent with other filters.
2025-08-12 09:01:39 +00:00
Niklas Haas a47ebee7df avfilter/f_bench: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 0913576225 avfilter/avf_aphasemeter: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 96f860853e avfilter/asrc_sine: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas dcd378ad04 avfilter/asrc_sinc: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas d360c212af avfilter/asrc_hilbert: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 2e8d3548e1 avfilter/asrc_afirsrc: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 4cc71fb806 avfilter/af_silencedetect: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Niklas Haas 892c439525 avfilter/af_lv2: use AVFilterContext when logging 2025-08-12 09:01:39 +00:00
Niklas Haas fb8f52d66c avfilter/af_afftdn: use AVFilterContext for logging 2025-08-12 09:01:39 +00:00
Ramiro Polla 5733e08c97 avcodec/mjpegdec: decode only SOF fields when finding stream info
When called from avformat_find_stream_info(), we are only interested in
decoding SOF fields.

This patch makes the decoder skip all other fields (including SOI, SOS,
and EOI). This also prevents the decoder from incorrectly printing the
warning "EOI missing, emulating" (which is the case since 2ae82788).

Fixes: #20119
2025-08-11 21:23:38 +00:00
Niklas Haas f610b55525 avfilter/vf_libplacebo: fix possible segfault when frame mixing
pl_frame_mix_current() will return NULL if all frames are in the future,
but when libplacebo is using a frame mixer with a radius greater than 1,
future frames are expected to already be partially renderered. Instead, use
pl_frame_mix_nearest(), which is guaranteed to give us a valid frame for any
nonempty frame mix.

Fixes: 3091bca3ed
2025-08-11 21:21:55 +00:00
Martin Storsjö 13139d6d83 fate: Fix the sub-mcc tests on Windows in eastern time zones
Previously, these tests failed when running on Windows, if the
system is configured with a time zone east of Greenwich, i.e.
with a positive GMT offset.

The muxer converts the creation_date given by the user using
av_parse_time to unix time, as a time_t. The creation_date is
interpreted as a local time, i.e. according to the current time
zone. (This time_t value is then converted back to a broken out
local time form with localtime_r.)

The given reference date/time, "1970-01-01T00:00:00", is the
origin point for unix time, corresponding to time_t zero. However
when interpreted as local time, this doesn't map to exactly zero.
Time zones east of Greenwich reached this time a number of hours
before the point of zero time_t - so the corresponding time_t
value essentially is minus the GMT offset, in seconds.

Windows mktime returns an error, returning (time_t)-1, when given
such a "struct tm", while e.g. glibc mktime happily returns a
negative time_t. av_parse_time doesn't check the return value of
mktime for potential errors.

This is observable with the following test snippet:

    struct tm tm = { 0 };
    tm.tm_year = 70;
    tm.tm_isdst = -1;
    tm.tm_mday = 1;
    tm.tm_hour = 0;
    time_t t = mktime(&tm);
    printf("%d-%02d-%02d %02d:%02d:%02d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
    printf("t %d\n", (int)t);

By varying the value of tm_hour and the system time zone, one
can observe that Windows mktime returns -1 for all time_t values
that would have been negative.

This range limit is also documented by Microsoft in detail at
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/mktime-mktime32-mktime64.

To avoid the issue, pick a different, arbitrary reference time,
which should have a nonnegative time_t for all time zones.
2025-08-11 23:14:35 +03:00
Kacper Michajłow 9b94b652db doc/examples/decode_filter_video: use av_usleep
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 5a768e8dd0 doc/examples/decode_filter_audio: remove unused unistd.h include
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 1a1377c53d avfilter/stack_internal: fix checkheaders test
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 48b941d543 tools/fourcc2pixfmt: fix getopt return value type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 082e2b26d4 tools/graph2dot: fix getopt return value type
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 01cfb01c9c avutil/tests/pca: comment out unused code
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow eec391993e avcodec/prores_raw: add missing includes
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow a6380c35d6 avfilter/vf_blackdetect: add missing config.h include
For ARCH_X86.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow b7a3c426ea avcodec/vulkan_encode_av1: use CODEC_PIXFMTS to define pix_fmts
Fixes deprecation warnings.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow ac6db22e37 avcodec/d3d12va_encode: fix label followed by a declaration warning
Fixes: d3d12va_encode.c: warning: label followed by a declaration is a
       C23 extension

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 98c4b9dbbd swscale/input: don't generate unused functions
Fixes: input.c:1271:1: warning: unused function 'planar_rgb16_s12_to_a'
Fixes: input.c:1272:1: warning: unused function 'planar_rgb16_s10_to_a'

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 0798f58abe avcodec/mpeg4videodec: add av_unreachable for unexpected startcode
Fixes: mpeg4videodec.c:3679:22: warning: variable 'name' is used
       uninitialized whenever 'if' condition is false
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 19:29:53 +00:00
Kacper Michajłow 2287a19abb avcodec/libvorbisdec: avoid overflow when assinging sample rate from long to int
Fixes: 416134551/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBVORBIS_DEC_fuzzer-6096101407260672
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow 286a3892a8 avcodec/g728dec: init missing sample rate
Fixes: BAD BUILD: fuzzing /tmp/not-out/tmp0d_svy0e/ffmpeg_AV_CODEC_ID_G728_DEC_fuzzer with afl-fuzz failed
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow c2f7dae70d avcodec/g726: init missing sample rate
Fixes: 416134551/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_G726_DEC_fuzzer-5695764455292928
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow db05b656b8 avformat/lrcdec: use av_sscanf to avoid possible locale issues
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow c74bc74398 avformat/lrcdec: limit input timestamp range to avoid overflows
Fixes: clusterfuzz-testcase-ffmpeg_dem_LRC_fuzzer-5226140131459072
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 20:31:09 +02:00
Kacper Michajłow e6635ada64 avfilter/vf_colordetect: optimize C functions a bit
They are used to process tail, so it's still good to have them faster.
Even if AVX version are used.

GCC 14.2.0 | x86_64 (default config) | Before:

detect_alpha_8_full_c:                                3803.0 ( 1.00x)
detect_alpha_8_full_avx2:                              166.4 (22.86x)
detect_alpha_8_full_avx512icl:                         144.2 (26.37x)
detect_alpha_8_limited_c:                            10454.4 ( 1.00x)
detect_alpha_8_limited_avx2:                           616.5 (16.96x)
detect_alpha_8_limited_avx512icl:                      509.4 (20.52x)
detect_alpha_16_full_c:                               1903.0 ( 1.00x)
detect_alpha_16_full_avx2:                             172.4 (11.04x)
detect_alpha_16_full_avx512icl:                        163.4 (11.65x)
detect_alpha_16_limited_c:                            3703.6 ( 1.00x)
detect_alpha_16_limited_avx2:                          644.4 ( 5.75x)
detect_alpha_16_limited_avx512icl:                     558.0 ( 6.64x)
detect_range_8_c:                                     5855.9 ( 1.00x)
detect_range_8_avx2:                                   150.4 (38.94x)
detect_range_8_avx512icl:                              146.7 (39.91x)
detect_range_16_c:                                    2702.2 ( 1.00x)
detect_range_16_avx2:                                  256.7 (10.53x)
detect_range_16_avx512icl:                             116.8 (23.13x)

GCC 14.2.0 | x86_64 (default config) | After:

detect_alpha_8_full_c:                                 376.3 ( 1.00x)
detect_alpha_8_full_avx2:                              169.2 ( 2.22x)
detect_alpha_8_full_avx512icl:                         134.6 ( 2.80x)
detect_alpha_8_limited_c:                             6024.1 ( 1.00x)
detect_alpha_8_limited_avx2:                           641.8 ( 9.39x)
detect_alpha_8_limited_avx512icl:                      493.0 (12.22x)
detect_alpha_16_full_c:                                436.4 ( 1.00x)
detect_alpha_16_full_avx2:                             156.3 ( 2.79x)
detect_alpha_16_full_avx512icl:                        151.8 ( 2.87x)
detect_alpha_16_limited_c:                            3679.9 ( 1.00x)
detect_alpha_16_limited_avx2:                          642.0 ( 5.73x)
detect_alpha_16_limited_avx512icl:                     555.2 ( 6.63x)
detect_range_8_c:                                      655.2 ( 1.00x)
detect_range_8_avx2:                                   153.9 ( 4.26x)
detect_range_8_avx512icl:                              147.4 ( 4.45x)
detect_range_16_c:                                     743.3 ( 1.00x)
detect_range_16_avx2:                                  258.6 ( 2.87x)
detect_range_16_avx512icl:                             107.7 ( 6.90x)

Clang 19.1.7 | x86_64 (default config) | Before:

detect_alpha_8_full_c:                                7013.4 ( 1.00x)
detect_alpha_8_full_avx2:                              141.8 (49.46x)
detect_alpha_8_full_avx512icl:                         133.8 (52.40x)
detect_alpha_8_limited_c:                             7038.8 ( 1.00x)
detect_alpha_8_limited_avx2:                           605.0 (11.63x)
detect_alpha_8_limited_avx512icl:                      506.5 (13.90x)
detect_alpha_16_full_c:                               1799.5 ( 1.00x)
detect_alpha_16_full_avx2:                             143.0 (12.59x)
detect_alpha_16_full_avx512icl:                        127.5 (14.12x)
detect_alpha_16_limited_c:                            3499.6 ( 1.00x)
detect_alpha_16_limited_avx2:                          633.6 ( 5.52x)
detect_alpha_16_limited_avx512icl:                     551.9 ( 6.34x)
detect_range_8_c:                                     5253.6 ( 1.00x)
detect_range_8_avx2:                                   125.0 (42.01x)
detect_range_8_avx512icl:                              123.2 (42.65x)
detect_range_16_c:                                    3055.2 ( 1.00x)
detect_range_16_avx2:                                  230.0 (13.28x)
detect_range_16_avx512icl:                              95.9 (31.86x)

Clang 19.1.7 | x86_64 (default config) | After:

detect_alpha_8_full_c:                                 323.3 ( 1.00x)
detect_alpha_8_full_avx2:                              149.7 ( 2.16x)
detect_alpha_8_full_avx512icl:                         127.7 ( 2.53x)
detect_alpha_8_limited_c:                             5075.9 ( 1.00x)
detect_alpha_8_limited_avx2:                           625.4 ( 8.12x)
detect_alpha_8_limited_avx512icl:                      493.0 (10.30x)
detect_alpha_16_full_c:                                421.0 ( 1.00x)
detect_alpha_16_full_avx2:                             238.8 ( 1.76x)
detect_alpha_16_full_avx512icl:                        126.0 ( 3.34x)
detect_alpha_16_limited_c:                            3516.8 ( 1.00x)
detect_alpha_16_limited_avx2:                          624.7 ( 5.63x)
detect_alpha_16_limited_avx512icl:                     544.7 ( 6.46x)
detect_range_8_c:                                      609.1 ( 1.00x)
detect_range_8_avx2:                                   239.4 ( 2.54x)
detect_range_8_avx512icl:                               89.0 ( 6.84x)
detect_range_16_c:                                     463.9 ( 1.00x)
detect_range_16_avx2:                                  127.4 ( 3.64x)
detect_range_16_avx512icl:                              86.4 ( 5.37x)

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 17:39:23 +00:00
Lynne 85e8e59001 Revert "doc/developer: Basic documentation for Source Plugins"
This reverts commit 67320e0627.

We do not want random forks or features.
2025-08-11 19:53:28 +09:00
Michael Niedermayer 67320e0627 doc/developer: Basic documentation for Source Plugins
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-11 12:33:16 +02:00
Michael Niedermayer 3542260376 avcodec/scpr3: Clear clr
clr is passing into decode_run_p() its not used when not set
but this possibly triggers msan (it doesnt locally)

Fixes?: use of uninintialized memory
Fixes?: 436997807/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SCPR_fuzzer-6253316466606080

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-11 11:54:31 +02:00
Michael Niedermayer 9686fdd729 avcodec/ilbcdec: Clear cbvec when used with create_augmented_vector()
Fixes: use of uninitialized memory
Fixes: 42538134/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>
2025-08-11 11:54:31 +02:00
Niklas Haas e29a99a975 fftools/ffmpeg_enc: don't ignore user selected chroma location
This code always ignored the user-provided enc_ctx->chroma_sample_location
in favor of the location tagged on the frame. This leads to a very (IMHO)
unexpected outcome where -chroma_sample_location works differently from the
related options like -colorspace and -color_range, the latter of which
override the frame properties as a consequence of being configured on the
filter graph output.

The discrepancy comes from the fact that the chroma sample location does not
itself participate in filter graph negotiation.

Solve the situation by only overriding the enc_ctx option if it was left
unspecified by the user, and otherwise printing a warning if the requested
parameter does not match the frame parameter.
2025-08-11 09:38:38 +02:00
Kacper Michajłow 3bf8bf965f avformat/mov: clear old name from infe
heif_items are reused and to avoid leaking memory or using stale name,
clear it first.

Fixes: 432505829/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6654363487764480
Found-by: OSS-Fuzz
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-08-11 01:25:05 +00:00
Leo Izen cd83161ff6 avcodec/vp9: fix leaked cbs fragment AVBufferRef
When this function returns, the fragment is never reset, so
current_frag->data_ref is never unref-ed, which ends up leaking it.
We call ff_cbs_fragment_reset to release the reference on its buffer.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2025-08-10 13:23:33 -04:00
Maryla Ustarroz-Calonge via ffmpeg-devel 6711c6a89b ffprobe: add -codec:<media_spec> option and -c:<media_spec> variant
opt_codec() is mostly copied over from ffplay.c.

This is useful when different decoders have different capabilities,
or to test a specific decoder.

Signed-off-by: Maryla Ustarroz-Calonge <maryla@google.com>
2025-08-10 10:19:57 +02:00
Gyan Doshi 9895c4222c doc/filters: correct psnr option name (#20199)
Correct doc entry from stats_add_max to output_max
2025-08-10 11:02:22 +05:30
Michael Niedermayer cfce595572 avcodec/apv_decode: make apv_format_table consistent with the code and check it
Fixes: writing in a null pointer
Fixes: 435278398/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APV_fuzzer-4566392923029504

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-08-10 02:29:09 +00:00
Martin Storsjö 8e4c904c8e checkasm: ac3dsp: Increase the float tolerance for sum_square_butterfly_float
Accept up to 13 ULP difference.

This fixes running "checkasm --test=ac3dsp 3044836819" on ARM.

Depending on how the SIMD implementations aggregate numbers,
larger/smaller values might not end up accumulated in exactly
the same way; the current NEON implementation for ARM aggregates
into vectors of 2 elements. If it would aggregate into vectors
of 4 elements instead, like the AArch64 version does, this particular
case would end up with a smaller difference.
2025-08-10 02:27:44 +00:00
Martin Storsjö 0400e05a1a checkasm: ac3dsp: Fix function name typos for sum_square_butterfly 2025-08-10 02:27:44 +00:00
winlin a72cc49e8a avformat/tls_openssl: fix X509 cert serial number might be negative
See RFC5280 4.1.2.2

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-10 02:26:16 +00:00
nyanmisaka 49f4ef9e79 lavu/log: fix color for AV_CLASS_CATEGORY_HWDEVICE on non-Win32
AV_CLASS_CATEGORY_HWDEVICE was introduced in the past but
no corresponding colors were added for non-Win32 platforms.

Fixes bf1579c ("avutil/log,hwcontext: Add AV_CLASS_CATEGORY_HWDEVICE")

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
2025-08-10 02:24:56 +00:00
Jacob Lifshay f6c4a64ee0 tests/fate/subtitles: add test for smpte436m_to_eia608 bsf
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-10 01:21:44 +00:00
Jacob Lifshay 925fad499d lavc/bsf/smpte436m_to_eia608: fix memory leak -- forgot to free input av_packet
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-10 01:21:44 +00:00
Jacob Lifshay f0a53917e3 lavc/bsf/eia608_to_smpte436m: fix memory leak -- forgot to free input av_packet
reported in https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20024#issuecomment-2405

Reported-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-10 01:21:44 +00:00
Jacob Lifshay 1d76302eb6 tests/fate/subtitles: fix mcc test input file paths
they use tests/ref/fate/sub-mcc-remux as input,
so prefix them with $(SRC_PATH) so building works
when not in the source directory.

Fixes: #20183
Reported-by: Sean McGovern <gseanmcg@gmail.com>
Signed-off-by: Jacob Lifshay <programmerjake@gmail.com>
2025-08-10 01:21:44 +00:00
Timo Rothenpieler 274e00ea84 forgejo/autolabeler: clean up logic a bit and prevent self-looping
The loop-protection only takes effect for the automatic token, not for
ffmpeg-devels PAT.
2025-08-10 01:50:46 +02:00
Mark Thompson 26a2a76346 cbs_vp9: Fix VP9 passthrough
Don't overwrite the bitstream values when updating the top-level loop
filter and segmentation state, instead do the update separately at the
end of the frame parsing.

This also reverts the change to the passthrough tests which made them
have output not matching the input.
2025-08-09 22:46:08 +00:00
Mark Thompson 19473362fc hwcontext_vulkan: Fix build 2025-08-09 22:46:08 +00:00
Mark Thompson 4a42e5a1e2 hwcontext_vulkan: Fix build with older Vulkan headers 2025-08-09 22:46:08 +00:00
Leon Grutters 777408d149 doc/community.texi: fix spelling error
Fixes: 262d41c804 ("all: fix typos found by codespell")
Signed-off-by: Leon Grutters <gruttersleonbot2@gmail.com>
2025-08-09 22:01:42 +00:00
Jack Lau 037fc47f35 doc/protocols: add doc for dtls
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau dc9f676b99 avformat/tls: add new option use_srtp to control whether enable it
The SRTP profile string "SRTP_AES128_CM_SHA1_80" is only used when
use_srtp is enabled. Move its declaration inside the "if (s->use_srtp)"
block to limit scope

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau fd55c4b5f7 avformat/tls_openssl: add av_assert0() for tls_shared
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau d7bc024476 avformat/tls_openssl: simplify the external_sock check
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Jack Lau 553fa9e3df avformat/tls_openssl: cleanup the pointer name of TLSContext and TLSShared
Pure cleanup, no functional changes
Unify local pointer names to `TLSContext *c` and `TLSShared *s` to
reduce confusion from inconsistent names (e.g. p, ctx, s, c)

Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-08-09 23:18:57 +02:00
Timo Rothenpieler e992464f0f forgejo/autolabeler: add some logic to also auto-remove the "New" label 2025-08-09 23:18:57 +02:00
2205 changed files with 99223 additions and 36080 deletions
+152 -8
View File
@@ -12,48 +12,170 @@
# =======
libavcodec/.*aac.* @lynne
libavcodec/.*ac3.* @lynne
libavcodec/.*adpcm.* @zane @pross
libavcodec/anm.* @pross
libavcodec/amf.* @OvchinnikovDmitrii @ArazIusubov
libavcodec/ansi.* @pross
libavcodec/aom_film_grain.* @haasn
libavcodec/.*atrac9.* @lynne
libavcodec/bink.* @pross
libavcodec/bintext.* @pross
libavcodec/.*bitpacked.* @lynne
libavcodec/.*d3d12va.* @jianhuaw
libavcodec/.*d3d12va.* @jianhuaw @tong1wu @younengxiao
libavcodec/.*dirac.* @lynne
libavcodec/.*dovi_rpu.* @haasn
libavcodec/dpx.* @pross
libavcodec/dsd.* @pross
libavcodec/eacmv.* @pross
libavcodec/eaidct.* @pross
libavcodec/eamad.* @pross
libavcodec/eat.* @pross
libavcodec/.*exif.* @Traneptora
libavcodec/.*ffv1.* @lynne @michaelni
libavcodec/g728.* @pross
libavcodec/gem.* @pross
libavcodec/golomb.* @michaelni
libavcodec/.*h266.* @frankplow @NuoMi @jianhuaw
libavcodec/h26x/.* @frankplow @NuoMi @jianhuaw
libavcodec/.*jpegxl.* @lynne
libavcodec/.*jxl.* @lynne
libavcodec/.*h274.* @haasn
libavcodec/iff.* @pross
libavcodec/.*jpegxl.* @lynne @Traneptora
libavcodec/jpeg2000htdec.* @cae
libavcodec/jv.* @pross
libavcodec/.*jxl.* @lynne @Traneptora
libavcodec/.*lcms2.* @haasn
libavcodec/lead.* @pross
libavcodec/mediacodec* @quink
libavcodec/mjpeg* @michaelni
libavcodec/mmvideo.* @pross
libavcodec/msp2.* @pross
libavcodec/mvc.* @pross
libavcodec/oh* @quink
libavcodec/.*opus.* @lynne
libavcodec/pictor.* @pross
libavcodec/.*png.* @Traneptora
libavcodec/.*prores.* @lynne
libavcodec/rangecoder.* @michaelni
libavcodec/ratecontrol.* @michaelni
libavcodec/rv60.* @pross
libavcodec/sgirle.* @pross
libavcodec/.*siren.* @lynne
libavcodec/smpte_436m.* @programmerjake
libavcodec/svq1.* @pross
libavcodec/svq3.* @pross
libavcodec/.*vc2.* @lynne
libavcodec/videotoolbox.* @ePirat
libavcodec/vp3.* @pross
libavcodec/vp4.* @pross
libavcodec/vp5.* @pross
libavcodec/vp6.* @pross
libavcodec/vp8.* @rbultje @pross
libavcodec/vp9.* @rbultje
libavcodec/vpx.* @rbultje @pross
libavcodec/vqc.* @pross
libavcodec/.*vvc.* @frankplow @NuoMi @jianhuaw
libavcodec/wmavoice.* @rbultje
libavcodec/wbmp.* @pross
# bitstream filters
libavcodec/bsf/eia608_to_smpte436m.* @programmerjake
libavcodec/bsf/smpte436m_to_eia608.* @programmerjake
# architecture-specific
libavcodec/aarch64/.* @lynne @mstorsjo
libavcodec/arm/.* @mstorsjo
libavcodec/ppc/.* @sean_mcg
libavcodec/riscv/.* @Courmisch
libavcodec/wasm/hevc/.* @quink
libavcodec/x86/.* @lynne
libavcodec/x86/vp8.* @rbultje
libavcodec/x86/vp9.* @rbultje
libavcodec/x86/vpx.* @rbultje
# avfilter
# =======
libavfilter/aarch64/.* @mstorsjo
libavfilter/af_loudnorm.* @kylophone
libavfilter/af_whisper.* @vpalmisano
libavfilter/.*_amf* @OvchinnikovDmitrii @ArazIusubov
libavfilter/avfiltergraph.* @haasn
libavfilter/colorspace.* @rbultje
libavfilter/formats.* @haasn
libavfilter/.*f_ebur128.* @haasn
libavfilter/vf_blackdetect.* @haasn
libavfilter/vf_colordetect.* @haasn
libavfilter/vf_colorspace.* @rbultje
libavfilter/.*drawvg.* @ayosec
libavfilter/vf_find_rect.* @michaelni
libavfilter/vf_icc.* @haasn
libavfilter/vf_libplacebo.* @haasn
libavfilter/vf_libvmaf.* @kylophone
libavfilter/vf_premultiply.* @haasn
libavfilter/vf_scale.* @haasn
libavfilter/vf_scale_vt.* @quink
libavfilter/vf_thumbnail.* @haasn
libavfilter/vf_transpose_vt.* @quink
libavfilter/vf_yadif.* @michaelni
libavfilter/vsrc_mandelbrot.* @michaelni
libavfilter/aarch64/.* @mstorsjo
libavfilter/riscv/.* @Courmisch
libavfilter/x86/colorspace.* @rbultje
libavfilter/x86/scene_sad.* @haasn
# avformat
# =======
libavformat/alp.* @zane
libavformat/amv.* @zane
libavformat/anm.* @pross
libavformat/apm.* @zane
libavformat/argo_.* @zane
libavformat/bink.* @pross
libavformat/bintext.* @pross
libavformat/caf.* @pross
libavformat/cine.* @pross
libavformat/dsf.* @pross
libavformat/eacdata.* @pross
libavformat/electronicarts.* @pross
libavformat/.*exif.* @Traneptora
libavformat/filmstrip.* @pross
libavformat/frm.* @pross
libavformat/iamf.* @jamrial
libavformat/icecast.c @ePirat
libavformat/ico.* @pross
libavformat/iff.* @pross
libavformat/.*jpegxl.* @Traneptora
libavformat/jv.* @pross
libavformat/.*jxl.* @Traneptora
libavformat/kvag.* @zane
libavformat/mccdec.* @programmerjake
libavformat/mccenc.* @programmerjake
libavformat/mlv.* @pross
libavformat/mm.* @pross
libavformat/msp.* @pross
libavformat/mv.* @pross
libavformat/pp_bnk.* @zane
libavformat/rm.* @pross
libavformat/sauce.* @pross
libavformat/scd.* @zane
libavformat/tty.* @pross
libavformat/whip.c @JackLau
libavformat/wsd.* @pross
libavformat/wtv.* @pross
# avutil
# ======
libavutil/.*_amf* @OvchinnikovDmitrii @ArazIusubov
libavutil/.*crc.* @lynne @michaelni
libavutil/.*d3d12va.* @jianhuaw
libavutil/.*d3d12va.* @jianhuaw @tong1wu @younengxiao
libavutil/csp.* @rbultje @haasn
libavutil/eval.* @michaelni
libavutil/film_grain.* @haasn
libavutil/dovi_meta.* @haasn
libavutil/hwcontext_oh.* @quink
libavutil/hwcontext_mediacodec.* @quink
libavutil/hwcontext_videotoolbox.* @ePirat
libavutil/iamf.* @jamrial
libavutil/integer.* @michaelni
libavutil/kiss99.* @michaelni
libavutil/lfg.* @michaelni
libavutil/lls.* @michaelni
libavutil/md5.* @michaelni
@@ -70,6 +192,7 @@ libavutil/tx.* @lynne
libavutil/aarch64/.* @lynne @mstorsjo
libavutil/arm/.* @mstorsjo
libavutil/ppc/.* @sean_mcg
libavutil/riscv/.* @Courmisch
libavutil/x86/.* @lynne
# swresample
@@ -83,6 +206,13 @@ libswresample/.* @michaelni
libswscale/aarch64/.* @mstorsjo
libswscale/arm/.* @mstorsjo
libswscale/ppc/.* @sean_mcg
libswscale/riscv/.* @Courmisch
libswscale/.* @haasn
# tools
# =====
fftools/ffplay_renderer.* @haasn
tools/target_dec_fuzzer.c @michaelni
# doc
# ===
@@ -90,5 +220,19 @@ doc/.* @GyanD
# Frameworks
# ==========
.*d3d12va.* @jianhuaw
.*vulkan.* @lynne
.*d3d12va.* @jianhuaw @tong1wu @younengxiao
.*vulkan.* @lynne @haasn
# tests
# =====
tests/checkasm/riscv/.* @Courmisch
tests/ref/.*drawvg.* @ayosec
tests/ref/fate/sub-mcc.* @programmerjake
# Forgejo
# =======
.forgejo/CODEOWNERS @michaelni
# /
# =
MAINTAINERS @michaelni
+45 -7
View File
@@ -1,6 +1,7 @@
module.exports = async ({github, context}) => {
const title = (context.payload.pull_request?.title || context.payload.issue?.title || '').toLowerCase();
const labels = [];
const issueNumber = context.payload.pull_request?.number || context.payload.issue?.number;
const kwmap = {
'avcodec': 'avcodec',
@@ -10,18 +11,55 @@ module.exports = async ({github, context}) => {
'avutil': 'avutil',
'swresample': 'swresample',
'swscale': 'swscale',
'fftools': 'CLI'
'fftools': 'CLI',
'vulkan': 'vulkan'
};
if (context.payload.action === 'opened') {
async function isOrgMember(username) {
try {
const response = await github.rest.orgs.checkMembershipForUser({
org: context.repo.owner,
username: username
});
return response.status === 204;
} catch (error) {
return false;
}
}
if (context.payload.action === 'closed' ||
(context.payload.action !== 'opened' && (
context.payload.action === 'assigned' ||
context.payload.action === 'label_updated' ||
context.payload.action === 'labeled' ||
context.payload.comment) &&
await isOrgMember(context.payload.sender.login))
) {
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
// this should say 'new', but forgejo deviates from GitHub API here and expects the ID
name: '41'
});
console.log('Removed "new" label');
} catch (error) {
if (error.status !== 404 && error.status !== 410) {
console.log('Could not remove "new" label');
}
}
} else if (context.payload.action === 'opened') {
labels.push('new');
console.log('Detected label: new');
}
for (const [kw, label] of Object.entries(kwmap)) {
if (title.includes(kw)) {
labels.push(label);
console.log('Detected label: ' + label);
if ((context.payload.action === 'opened' || context.payload.action === 'edited') && context.eventName !== 'issue_comment') {
for (const [kw, label] of Object.entries(kwmap)) {
if (title.includes(kw)) {
labels.push(label);
console.log('Detected label: ' + label);
}
}
}
@@ -29,7 +67,7 @@ module.exports = async ({github, context}) => {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request?.number || context.payload.issue?.number,
issue_number: issueNumber,
labels: labels,
});
}
+12 -8
View File
@@ -1,31 +1,35 @@
avcodec:
- changed-files:
- any-glob-to-any-file: libavcodec/**
- any-glob-to-any-file: 'libavcodec/**'
avdevice:
- changed-files:
- any-glob-to-any-file: libavdevice/**
- any-glob-to-any-file: 'libavdevice/**'
avfilter:
- changed-files:
- any-glob-to-any-file: libavfilter/**
- any-glob-to-any-file: 'libavfilter/**'
avformat:
- changed-files:
- any-glob-to-any-file: libavformat/**
- any-glob-to-any-file: 'libavformat/**'
avutil:
- changed-files:
- any-glob-to-any-file: libavutil/**
- any-glob-to-any-file: 'libavutil/**'
swresample:
- changed-files:
- any-glob-to-any-file: libswresample/**
- any-glob-to-any-file: 'libswresample/**'
swscale:
- changed-files:
- any-glob-to-any-file: libswscale/**
- any-glob-to-any-file: 'libswscale/**'
CLI:
- changed-files:
- any-glob-to-any-file: fftools/**
- any-glob-to-any-file: 'fftools/**'
vulkan:
- changed-files:
- any-glob-to-any-file: '**/*vulkan*'
+8
View File
@@ -18,6 +18,14 @@ repos:
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: local
hooks:
- id: aarch64-asm-indent
name: fix aarch64 assembly indentation
files: ^.*/aarch64/.*\.S$
language: script
entry: ./tools/check_arm_indent.sh --apply
pass_filenames: false
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
+11 -5
View File
@@ -1,23 +1,29 @@
name: Autolabel
on:
pull_request_target:
types: [opened, edited, synchronize]
types: [opened, edited, synchronize, closed, assigned, labeled, unlabeled]
issues:
types: [opened, edited]
types: [opened, edited, closed, assigned, labeled, unlabeled]
issue_comment:
types: [created]
jobs:
pr_labeler:
name: Labeler
runs-on: utilities
if: ${{ github.event.sender.login != 'ffmpeg-devel' }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Label by file-changes
uses: https://github.com/actions/labeler@v5
uses: actions/labeler@v6
if: ${{ forge.event_name == 'pull_request_target' }}
with:
configuration-path: .forgejo/labeler/labeler.yml
repo-token: ${{ secrets.AUTOLABELER_TOKEN }}
- name: Label by title-match
uses: https://github.com/actions/github-script@v7
uses: actions/github-script@v8
with:
script: |
const script = require('.forgejo/labeler/labeler.js')
+8 -2
View File
@@ -1,15 +1,21 @@
name: Lint
on:
push:
branches:
- master
pull_request:
concurrency:
cancel-in-progress: ${{ forge.event_name == 'pull_request' }}
jobs:
lint:
name: Pre-Commit
runs-on: utilities
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Install pre-commit CI
id: install
run: |
@@ -18,7 +24,7 @@ jobs:
~/pre-commit/bin/pip install pre-commit
echo "envhash=$({ python3 --version && cat .forgejo/pre-commit/config.yaml; } | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT
- name: Cache
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ steps.install.outputs.envhash }}
+70 -11
View File
@@ -1,26 +1,47 @@
name: Test
on:
push:
branches:
- master
pull_request:
concurrency:
cancel-in-progress: ${{ forge.event_name == 'pull_request' }}
jobs:
run_fate:
name: Fate (${{ matrix.runner }}, ${{ matrix.shared }}, ${{ matrix.bits }} bit)
strategy:
fail-fast: false
matrix:
runner: [linux-amd64,linux-aarch64]
runner: [linux-aarch64]
shared: ['static']
bits: ['64']
include:
- runner: linux-amd64
shared: 'static'
bits: '32'
- runner: linux-amd64
shared: 'shared'
bits: '64'
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Configure
run: ./configure --enable-gpl --enable-nonfree --enable-memory-poisoning --assert-level=2
run: |
./configure --enable-gpl --enable-nonfree --enable-memory-poisoning --assert-level=2 \
$([ "${{ matrix.bits }}" != "32" ] || echo --arch=x86_32 --extra-cflags=-m32 --extra-cxxflags=-m32 --extra-ldflags=-m32) \
$([ "${{ matrix.shared }}" != "shared" ] || echo --enable-shared --disable-static) \
|| CFGRES=$?
cat ffbuild/config.log
exit ${CFGRES:-0}
- name: Build
run: make -j$(nproc)
- name: Restore Cached Fate-Suite
id: cache
uses: actions/cache/restore@v4
uses: actions/cache/restore@v5
with:
path: fate-suite
key: fate-suite
@@ -30,30 +51,68 @@ jobs:
id: fate
run: |
make fate-rsync SAMPLES=$PWD/fate-suite
echo "hash=$(find fate-suite -type f | sort | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT
echo "hash=$(find fate-suite -type f -printf "%P %s %T@\n" | sort | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT
- name: Cache Fate-Suite
uses: actions/cache/save@v4
uses: actions/cache/save@v5
if: ${{ format('fate-suite-{0}', steps.fate.outputs.hash) != steps.cache.outputs.cache-matched-key }}
with:
path: fate-suite
key: fate-suite-${{ steps.fate.outputs.hash }}
- name: Run Fate
run: make fate SAMPLES=$PWD/fate-suite -j$(nproc)
compile_only:
run: |
LD_LIBRARY_PATH="$(printf "%s:" "$PWD"/lib*)$PWD" make fate fate-build SAMPLES="$PWD/fate-suite" -j$(nproc) || FATERES=$?
find . -name "*.err" -exec printf '::group::%s\n' {} \; -exec cat {} \; -exec printf '::endgroup::\n' \;
exit ${FATERES:-0}
run_fate_full:
name: Fate (Full, ${{ matrix.target_exec }})
strategy:
fail-fast: false
matrix:
image: ["ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest"]
image: ['ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest']
target_exec: ['wine']
runs-on: linux-amd64
container: ${{ matrix.image }}
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Configure
run: |
./configure --pkg-config-flags="--static" $FFBUILD_TARGET_FLAGS $FF_CONFIGURE \
--cc="$CC" --cxx="$CXX" --ar="$AR" --ranlib="$RANLIB" --nm="$NM" \
--extra-cflags="$FF_CFLAGS" --extra-cxxflags="$FF_CXXFLAGS" \
--extra-libs="$FF_LIBS" --extra-ldflags="$FF_LDFLAGS" --extra-ldexeflags="$FF_LDEXEFLAGS"
--extra-libs="$FF_LIBS" --extra-ldflags="$FF_LDFLAGS" --extra-ldexeflags="$FF_LDEXEFLAGS" \
--enable-memory-poisoning --assert-level=2 --target-exec="${{ matrix.target_exec }}" \
--enable-hardcoded-tables \
|| CFGRES=$?
cat ffbuild/config.log
exit ${CFGRES:-0}
- name: Build
run: make -j$(nproc)
- name: Restore Cached Fate-Suite
id: cache
uses: actions/cache/restore@v5
with:
path: fate-suite
key: fate-suite
restore-keys: |
fate-suite-
- name: Sync Fate-Suite
id: fate
run: |
make fate-rsync SAMPLES=$PWD/fate-suite
echo "hash=$(find fate-suite -type f -printf "%P %s %T@\n" | sort | sha256sum | cut -d' ' -f1)" >> $FORGEJO_OUTPUT
- name: Cache Fate-Suite
uses: actions/cache/save@v5
if: ${{ format('fate-suite-{0}', steps.fate.outputs.hash) != steps.cache.outputs.cache-matched-key }}
with:
path: fate-suite
key: fate-suite-${{ steps.fate.outputs.hash }}
- name: Run Fate
run: |
if [[ "${{ matrix.target_exec }}" == "wine" ]]; then
export WINEDEBUG=-all
export FREI0R_PATH="$(winepath -w "$FREI0R_PATH")"
fi
LD_LIBRARY_PATH="$(printf "%s:" "$PWD"/lib*)$PWD" make fate fate-build SAMPLES="$PWD/fate-suite" -j$(nproc) || FATERES=$?
find . -name "*.err" -exec printf '::group::%s\n' {} \; -exec cat {} \; -exec printf '::endgroup::\n' \;
exit ${FATERES:-0}
+4
View File
@@ -23,6 +23,9 @@
*.metal.air
*.metallib
*.metallib.c
*.spv
*.spv.c
*.spv.gz
*.ptx
*.ptx.c
*.ptx.gz
@@ -36,6 +39,7 @@
/ffprobe
/config.asm
/config.h
/config_components.asm
/config_components.h
/coverage.info
/lcov/
+1 -1
View File
@@ -1,4 +1,4 @@
# Note to Github users
Patches should be submitted to the [ffmpeg-devel mailing list](https://ffmpeg.org/mailman/listinfo/ffmpeg-devel) using `git format-patch` or `git send-email`. Github pull requests should be avoided because they are not part of our review process and **will be ignored**.
Patches should be submitted to [Forgejo](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls) or the [ffmpeg-devel mailing list](https://ffmpeg.org/mailman/listinfo/ffmpeg-devel) using `git format-patch` or `git send-email`. Github pull requests should be avoided because they are not part of our review process and **will be ignored**.
See [https://ffmpeg.org/developer.html#Contributing](https://ffmpeg.org/developer.html#Contributing) for more information.
+34
View File
@@ -4,10 +4,42 @@ releases are sorted from youngest to oldest.
version <next>:
version 8.1:
- ffprobe -codec option
- EXIF Metadata Parsing
- gfxcapture: Windows.Graphics.Capture based window/monitor capture
- hxvs demuxer for HXVS/HXVT IP camera format
- MPEG-H 3D Audio decoding via mpeghdec
- D3D12 H.264 encoder
- drawvg filter via libcairo
- ffmpeg CLI tiled HEIF support
- D3D12 AV1 encoder
- ProRes Vulkan hwaccel
- DPX Vulkan hwaccel
- Rockchip H.264/HEVC hardware encoder
- Add vf_scale_d3d12 filter
- JPEG-XS parser
- JPEG-XS decoder and encoder through libsvtjpegxs
- JPEG-XS raw bitstream muxer and demuxer
- IAMF Projection mode Ambisonic Audio Elements muxing and demuxing
- Add vf_mestimate_d3d12 filter
- xHE-AAC Mps212 decoding support (experimental)
- Remove the old HLS protocol handler
- Vulkan compute codec optimizations
- swscale Vulkan support
- LCEVC metadata bitstream filter
- Add vf_deinterlace_d3d12 filter
- ffprobe: only show refs field in stream section when reading frames
- ProRes Vulkan encoder
- LCEVC parser
- LCEVC enhancement layer exporting in MPEG-TS
version 8.0:
- Whisper filter
- Drop support for OpenSSL < 1.1.0
- Enable TLS peer certificate verification by default (on next major version bump)
- Drop support for OpenSSL < 1.1.1
- yasm support dropped, users need to use nasm
- VVC VAAPI decoder
- RealVideo 6.0 decoder
@@ -36,6 +68,8 @@ version 8.0:
- AV1 Vulkan encoder
- ProRes RAW decoder
- ProRes RAW Vulkan hwaccel
- ffprobe -codec option
- HDR10+ metadata passthrough when decoding/encoding with libaom-av1
version 7.1:
+6 -3
View File
@@ -152,7 +152,7 @@ Codecs:
adpcm.c Zane van Iperen
alacenc.c Jaikrishnan Menon
alsdec.c Thilo Borgmann, Umair Khan
amfenc* Dmitrii Ovchinnikov
amfdec*,amfenc* [2] Dmitrii Ovchinnikov, Araz Iusubov
aptx.c Aurelien Jacobs
ass* Aurelien Jacobs
asv* Michael Niedermayer
@@ -211,7 +211,7 @@ Codecs:
libkvazaar.c Arttu Ylä-Outinen
libopenh264enc.c Martin Storsjo, Linjie Fu
libopenjpegenc.c Michael Bradshaw
libtheoraenc.c David Conrad
libtheoraenc.c [0]
libvorbis.c David Conrad
libvpx* James Zern
libxavs.c Stefan Gehrer
@@ -278,6 +278,7 @@ Codecs:
xface Stefano Sabatini
Hardware acceleration:
amf* [2] Dmitrii Ovchinnikov, Araz Iusubov
dxva2* Hendrik Leppkes, Laurent Aimar, Steve Lhomme
d3d11va* Steve Lhomme
d3d12va* Wu Jianhua
@@ -482,6 +483,7 @@ Muxers/Demuxers:
webm dash (matroskaenc.c) Vignesh Venkatasubramanian
webvtt* Matthew J Heaney
westwood.c Mike Melanson
whip.c [2] Jack Lau
wtv.c Peter Ross
Protocols:
@@ -521,7 +523,7 @@ LoongArch [2] Shiyou Yin
Darwin (macOS, iOS) [2] Marvin Scholz
Mac OS X / PowerPC [0]
Amiga / PowerPC Colin Ward
Linux / PowerPC [1] Lauri Kasanen
Linux / PowerPC [2] Sean McGovern (CC <gseanmcg@gmail.com>), Lauri Kasanen
RISC-V [2] Rémi Denis-Courmont
Windows MinGW Alex Beregszaszi, Ramiro Polla
Windows Cygwin Victor Paesa
@@ -617,6 +619,7 @@ Reinhard Tartler 9300 5DC2 7E87 6C37 ED7B CA9A 9808 3544 9453 48A4
Reynaldo H. Verdejo Pinochet 6E27 CD34 170C C78E 4D4F 5F40 C18E 077F 3114 452A
Robert Swain EE7A 56EA 4A81 A7B5 2001 A521 67FA 362D A2FC 3E71
Sascha Sommer 38A0 F88B 868E 9D3A 97D4 D6A0 E823 706F 1E07 0D3C
Sean McGovern (Sean_McG) 6D03 BC60 3A33 E615 6E2E 06AD 8C06 8175 6F59 8684
Stefano Sabatini 0D0B AD6B 5330 BBAD D3D6 6A0C 719C 2839 FC43 2D5F
Steinar H. Gunderson C2E9 004F F028 C18E 4EAD DB83 7F61 7561 7797 8F76
Stephan Hilb 4F38 0B3A 5F39 B99B F505 E562 8D5C 5554 4E17 8863
+16 -13
View File
@@ -11,6 +11,8 @@ vpath %.asm $(SRC_PATH)
vpath %.rc $(SRC_PATH)
vpath %.v $(SRC_PATH)
vpath %.texi $(SRC_PATH)
vpath %.glsl $(SRC_PATH)
vpath %.spv $(SRC_PATH)
vpath %.cu $(SRC_PATH)
vpath %.ptx $(SRC_PATH)
vpath %.metal $(SRC_PATH)
@@ -53,31 +55,31 @@ FF_DEP_LIBS := $(DEP_LIBS)
FF_STATIC_DEP_LIBS := $(STATIC_DEP_LIBS)
$(TOOLS): %$(EXESUF): %.o
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter-out $(FF_DEP_LIBS), $^) $(EXTRALIBS-$(*F)) $(EXTRALIBS) $(ELIBS)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter-out $(FF_DEP_LIBS), $^) $(EXTRALIBS-$(*F)) $(EXTRALIBS) $(ELIBS))
target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
target_enc_%_fuzzer$(EXESUF): target_enc_%_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_bsf_%_fuzzer$(EXESUF): tools/target_bsf_%_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
target_dem_%_fuzzer$(EXESUF): target_dem_%_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_dem_fuzzer$(EXESUF): tools/target_dem_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_io_dem_fuzzer$(EXESUF): tools/target_io_dem_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_sws_fuzzer$(EXESUF): tools/target_sws_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/target_swr_fuzzer$(EXESUF): tools/target_swr_fuzzer.o $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH))
tools/enum_options$(EXESUF): ELIBS = $(FF_EXTRALIBS)
tools/enum_options$(EXESUF): $(FF_DEP_LIBS)
@@ -107,10 +109,11 @@ ffbuild/.config: $(CONFIGURABLE_COMPONENTS)
SUBDIR_VARS := CLEANFILES FFLIBS HOSTPROGS TESTPROGS TOOLS \
HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS \
ARMV5TE-OBJS ARMV6-OBJS ARMV8-OBJS VFP-OBJS NEON-OBJS \
ALTIVEC-OBJS VSX-OBJS MMX-OBJS X86ASM-OBJS \
ALTIVEC-OBJS VSX-OBJS X86ASM-OBJS \
MIPSFPU-OBJS MIPSDSPR2-OBJS MIPSDSP-OBJS MSA-OBJS \
MMI-OBJS LSX-OBJS LASX-OBJS RV-OBJS RVV-OBJS RVVB-OBJS \
OBJS SHLIBOBJS STLIBOBJS HOSTOBJS TESTOBJS SIMD128-OBJS
OBJS SHLIBOBJS STLIBOBJS HOSTOBJS TESTOBJS SIMD128-OBJS \
SVE-OBJS SVE2-OBJS SME-OBJS SME2-OBJS
define RESET
$(1) :=
@@ -144,7 +147,7 @@ else
endif
%$(PROGSSUF)_g$(EXESUF): $(FF_DEP_LIBS)
$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS)
$(call LINK,$(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(OBJS-$*) $(FF_EXTRALIBS))
VERSION_SH = $(SRC_PATH)/ffbuild/version.sh
ifeq ($(VERSION_TRACKING),yes)
@@ -184,7 +187,7 @@ clean::
$(RM) -rf coverage.info coverage.info.in lcov
distclean:: clean
$(RM) .version config.asm config.h config_components.h mapfile \
$(RM) .version config.asm config.h config_components.* mapfile \
ffbuild/.config ffbuild/config.* libavutil/avconfig.h \
version.h libavutil/ffversion.h libavcodec/codec_names.h \
libavcodec/bsf_list.c libavformat/protocol_list.c \
+1 -1
View File
@@ -1 +1 @@
7.1.git
8.0.git
+114
View File
@@ -0,0 +1,114 @@
/*
* Android Binder handler
*
* Copyright (c) 2025 Dmitrii Okunev
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if defined(__ANDROID__)
#include <dlfcn.h>
#include <stdint.h>
#include <stdlib.h>
#include "libavutil/log.h"
#include "binder.h"
#define THREAD_POOL_SIZE 1
static void *dlopen_libbinder_ndk(void)
{
/*
* libbinder_ndk.so often does not contain the functions we need, so making
* this dependency optional, thus using dlopen/dlsym instead of linking.
*
* See also: https://source.android.com/docs/core/architecture/aidl/aidl-backends
*/
void *h = dlopen("libbinder_ndk.so", RTLD_NOW | RTLD_LOCAL);
if (h != NULL)
return h;
av_log(NULL, AV_LOG_WARNING,
"android/binder: unable to load libbinder_ndk.so: '%s'; skipping binder threadpool init (MediaCodec likely won't work)\n",
dlerror());
return NULL;
}
static void android_binder_threadpool_init(void)
{
typedef int (*set_thread_pool_max_fn)(uint32_t);
typedef void (*start_thread_pool_fn)(void);
set_thread_pool_max_fn set_thread_pool_max = NULL;
start_thread_pool_fn start_thread_pool = NULL;
void *h = dlopen_libbinder_ndk();
if (h == NULL)
return;
unsigned thead_pool_size = THREAD_POOL_SIZE;
set_thread_pool_max =
(set_thread_pool_max_fn) dlsym(h,
"ABinderProcess_setThreadPoolMaxThreadCount");
start_thread_pool =
(start_thread_pool_fn) dlsym(h, "ABinderProcess_startThreadPool");
if (start_thread_pool == NULL) {
av_log(NULL, AV_LOG_WARNING,
"android/binder: ABinderProcess_startThreadPool not found; skipping threadpool init (MediaCodec likely won't work)\n");
return;
}
if (set_thread_pool_max != NULL) {
int ok = set_thread_pool_max(thead_pool_size);
av_log(NULL, AV_LOG_DEBUG,
"android/binder: ABinderProcess_setThreadPoolMaxThreadCount(%u) => %s\n",
thead_pool_size, ok ? "ok" : "fail");
} else {
av_log(NULL, AV_LOG_DEBUG,
"android/binder: ABinderProcess_setThreadPoolMaxThreadCount is unavailable; using the library default\n");
}
start_thread_pool();
av_log(NULL, AV_LOG_DEBUG,
"android/binder: ABinderProcess_startThreadPool() called\n");
}
void android_binder_threadpool_init_if_required(void)
{
#if __ANDROID_API__ >= 24
if (android_get_device_api_level() < 35) {
// the issue with the thread pool was introduced in Android 15 (API 35)
av_log(NULL, AV_LOG_DEBUG,
"android/binder: API<35, thus no need to initialize a thread pool\n");
return;
}
android_binder_threadpool_init();
#else
// android_get_device_api_level was introduced in API 24, so we cannot use it
// to detect the API level in API<24. For simplicity we just assume
// libbinder_ndk.so on the system running this code would have API level < 35;
av_log(NULL, AV_LOG_DEBUG,
"android/binder: is built with API<24, assuming this is not Android 15+\n");
#endif
}
#endif /* __ANDROID__ */
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com)
* Android Binder handler
*
* Copyright (c) 2025 Dmitrii Okunev
*
* This file is part of FFmpeg.
*
@@ -18,16 +20,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/attributes.h"
#include "libavutil/mips/cpu.h"
#include "libavcodec/mpegvideoenc.h"
#include "mpegvideo_mips.h"
#ifndef COMPAT_ANDROID_BINDER_H
#define COMPAT_ANDROID_BINDER_H
av_cold void ff_mpvenc_dct_init_mips(MPVEncContext *s)
{
int cpu_flags = av_get_cpu_flags();
/**
* Initialize Android Binder thread pool.
*/
void android_binder_threadpool_init_if_required(void);
if (have_mmi(cpu_flags)) {
s->denoise_dct = ff_denoise_dct_mmi;
}
}
#endif // COMPAT_ANDROID_BINDER_H
+1 -1
View File
@@ -38,7 +38,7 @@ static int optind = 1;
static int optopt;
static char *optarg;
static int getopt(int argc, char *argv[], char *opts)
static int getopt(int argc, char *argv[], const char *opts)
{
static int sp = 1;
int c;
+41 -6
View File
@@ -44,8 +44,9 @@
#include "libavutil/internal.h"
#include "libavutil/mem.h"
#include "libavutil/time.h"
#include "libavutil/wchar_filename.h"
typedef struct pthread_t {
typedef struct w32pthread_t {
void *handle;
void *(*func)(void* arg);
void *arg;
@@ -71,7 +72,7 @@ typedef CONDITION_VARIABLE pthread_cond_t;
#define THREADFUNC_RETTYPE unsigned
#endif
static av_unused THREADFUNC_RETTYPE
av_unused static THREADFUNC_RETTYPE
__stdcall attribute_align_arg win32thread_worker(void *arg)
{
pthread_t h = (pthread_t)arg;
@@ -79,12 +80,12 @@ __stdcall attribute_align_arg win32thread_worker(void *arg)
return 0;
}
static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
av_unused static int pthread_create(pthread_t *thread, const void *unused_attr,
void *(*start_routine)(void*), void *arg)
{
pthread_t ret;
ret = av_mallocz(sizeof(*ret));
ret = (pthread_t)av_mallocz(sizeof(*ret));
if (!ret)
return EAGAIN;
@@ -108,7 +109,7 @@ static av_unused int pthread_create(pthread_t *thread, const void *unused_attr,
return 0;
}
static av_unused int pthread_join(pthread_t thread, void **value_ptr)
av_unused static int pthread_join(pthread_t thread, void **value_ptr)
{
DWORD ret = WaitForSingleObject(thread->handle, INFINITE);
if (ret != WAIT_OBJECT_0) {
@@ -148,7 +149,7 @@ static inline int pthread_mutex_unlock(pthread_mutex_t *m)
typedef INIT_ONCE pthread_once_t;
#define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT
static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
av_unused static int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
{
BOOL pending = FALSE;
InitOnceBeginInitialize(once_control, 0, &pending, NULL);
@@ -209,4 +210,38 @@ static inline int pthread_setcancelstate(int state, int *oldstate)
return 0;
}
static inline int win32_thread_setname(const char *name)
{
#if !HAVE_UWP
typedef HRESULT (WINAPI *SetThreadDescriptionFn)(HANDLE, PCWSTR);
// Although SetThreadDescription lives in kernel32.dll, on Windows Server 2016,
// Windows 10 LTSB 2016 and Windows 10 version 1607, it was only available in
// kernelbase.dll. So, load it from there for maximum coverage.
HMODULE kernelbase = GetModuleHandleW(L"kernelbase.dll");
if (!kernelbase)
return AVERROR(ENOSYS);
SetThreadDescriptionFn pSetThreadDescription =
(SetThreadDescriptionFn)GetProcAddress(kernelbase, "SetThreadDescription");
if (!pSetThreadDescription)
return AVERROR(ENOSYS);
wchar_t *wname;
if (utf8towchar(name, &wname) < 0)
return AVERROR(ENOMEM);
HRESULT hr = pSetThreadDescription(GetCurrentThread(), wname);
av_free(wname);
return SUCCEEDED(hr) ? 0 : AVERROR(EINVAL);
#else
// UWP is not supported because we cannot use LoadLibrary/GetProcAddress to
// detect the availability of the SetThreadDescription API. There is a small
// gap in Windows builds 1507-1607 where it was not available. UWP allows
// querying the availability of APIs with QueryOptionalDelayLoadedAPI, but it
// requires /DELAYLOAD:kernel32.dll during linking, and we cannot enforce that.
return AVERROR(ENOSYS);
#endif
}
#endif /* COMPAT_W32PTHREADS_H */
+20 -5
View File
@@ -48,7 +48,13 @@ trap 'rm -f -- $libname' EXIT
if [ -n "$AR" ]; then
$AR rcs ${libname} $@ >/dev/null
else
lib.exe -out:${libname} $@ >/dev/null
machine_flag=""
case "$LDFLAGS" in
*"machine:arm64ec"*)
machine_flag="-machine:arm64ec"
;;
esac
lib.exe ${machine_flag} -out:${libname} $@ >/dev/null
fi
if [ $? != 0 ]; then
echo "Could not create temporary library." >&2
@@ -106,12 +112,21 @@ if [ -n "$NM" ]; then
grep -v : |
grep -v ^$ |
cut -d' ' -f3 |
sed -e "s/^${prefix}//")
sed -e "s/^${prefix}//" -e "s/^#//" |
grep -v '\$entry_thunk' |
grep -v '\$exit_thunk')
else
dump=$(dumpbin.exe -linkermember:1 ${libname} |
sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e "s/ \{1,\}${prefix}/ /" -e 's/ \{1,\}/ /g' |
member=1
case "$LDFLAGS" in
*"machine:arm64ec"*)
member=32
;;
esac
dump=$(dumpbin.exe -linkermember:${member} ${libname} |
sed -e '/public symbols/,$!d' -e '/^ \{1,\}Summary/,$d' -e 's/^[[:space:]]*[0-9A-Fa-f]\{1,\}[[:space:]]\{1,\}//' -e "s/^${prefix}//" -e 's/^#//' |
tail -n +2 |
cut -d' ' -f3)
grep -v '\$entry_thunk' |
grep -v '\$exit_thunk')
fi
rm ${libname}
Vendored
+541 -243
View File
File diff suppressed because it is too large Load Diff
+136
View File
@@ -2,6 +2,142 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
2026-03-07 - c23d56b173a - lavc 62.26.100 - codec_desc.h
Add AV_CODEC_PROP_ENHANCEMENT.
2026-03-07 - f37cfb370f8 - lavc 62.25.100 - avcodec.h
Deprecate AVCodecContext.intra_dc_precision.
2026-02-26 - 26d6ac56c10 - lsws 9.4.100 - swscale.h
Add sws_test_hw_format().
2026-02-19 - ca011ee7547 - lavf 62.10.100 - avformat.h
Add demuxer command API consisting of:
- Add avformat_send_command().
- Add avformat_receive_command_reply().
- Add enum AVFormatCommandID.
2026-02-13 - 66766bb1c76 - lavu 60.25.100 - avassert.h
Deprecate av_assert0_fpu() and av_assert2_fpu() without replacement.
2026-02-09 - f2b13f783ac - lavf 62.9.100 - avformat.h
Add AVFormatContext.name.
2026-01-26 - 714152dd9a0 - lavu 60.24.100 - hwcontext_d3d11va.h
Add BindFlags and MiscFlags to AVD3D11VADeviceContext
2026-01-04 - 0645c484537 - lavu 60.23.100 - cpu.h
Add AV_CPU_FLAG_ARM_CRC.
2026-01-04 - e382772e4a1 - lavu 60.22.100 - cpu.h
Add AV_CPU_FLAG_CLMUL.
2025-12-29 - a6e5fa3fbb5 - lavu 60.21.100 - iamf.h
Add nb_demixing_matrix to AVIAMFLayer
2025-12-13 - b8ee68cffe - lavc 62.23.100 - codec_id.h
Add AV_CODEC_ID_JPEGXS.
2025-12-12 - c9b5e145b71 - lavf 62.7.100 - avformat.h
Add av_mime_codec_str
2025-12-08 - 212eb8413a6 - lavu 60.20.100 - hwcontext_vulkan.h
Add av_vk_get_optional_instance_extensions().
Add av_vk_get_optional_device_extensions().
2025-12-07 - 00caeba050d - lavc 62.22.101 - avcodec.h
Add avcodec_receive_frame_flags().
Add AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS.
2025-11-26 - 623669a02cd - lavfi 11.10.100 - buffersrc.h
Add av_buffersrc_get_status().
2025-11-18 - 140b4f28c30 - lavu 60.19.100 - hwcontext_amf.h
avutil/hwcontext_amf: add lock and unlock for AVAMFDeviceContext.
2025-11-16 - 643e2e10f98 - lavu 60.18.100 - cpu.h
Deprecate AV_CPU_FLAG_FORCE without replacement.
2025-11-01 - 8a322c956f3 - lavc 62.19.100 - avcodec.h
Schedule AVCodecParser and av_parser_init() to use enum AVCodecID
for codec ids on the next major version bump.
2025-11-01 - e0b0ca81112 - lavc 62.18.100 - avcodec.h
Deprecate AVCodecParser fields priv_data_size, parser_init,
parser_parse, parser_close, and split with no replacement.
2025-10-30 - 6879c8ee5dd - lavc 62.17.100 - packet.h
Add av_packet_side_data_from_frame() and av_packet_side_data_to_frame().
2025-10-28 - 71c7b9156bd - lavu 60.16.100 - pixfmt.h
Add AVCOL_TRC_EXT_BASE, AVCOL_TRC_V_LOG,
AVCOL_PRI_EXT_BASE and AVCOL_PRI_V_GAMUT.
2025-10-24 - 00e43619cd3 - lavu 60.14.100 - csp.h
Add av_csp_approximate_eotf_gamma().
2025-08-xx - xxxxxxxxxx - lavf 62.6.100 - oggparsevorbis.h oggparseopus.h oggparseflac.h
Drop header packets from secondary chained ogg/{flac, opus, vorbis} streams
from demuxer output.
2025-09-08 - 1b97966199f - lavu 60.13.100 - hwcontext_d3d12va.h
Add resource_flags and heap_flags to AVD3D12VADeviceContext
Add heap_flags to AVD3D12VAFramesContext
2025-09-05 - 9458a6f8ec2 - lavf 62.5.100 - avformat.h
Add AV_FRAME_FILENAME_FLAGS_IGNORE_TRUNCATION
2025-09-03 - c2ce3873859 - lavu 60.12.100 - hwcontext_d3d12va.h
Add support for texture array mode AVD3D12VAFrame.subresource_index,
AVD3D12VAFramesContext.texture_array
Add enum AVD3D12VAFrameFlags to define the behaviours of frame allocation.
Renanme AVD3D12VAFramesContext.flags to AVD3D12VAFramesContext.resource_flags.
Add flags to AVD3D12VAFramesContext
Add flags to AVD3D12VAFrame
2025-09-02 - de297ae2fca - lavfi 11.8.100 - buffersrc.h
Add AVBufferSrcParameters.alpha_mode.
2025-09-02 - 0fbd90d78f8 - lavfi 11.7.100 - buffersink.h
Add av_buffersink_get_alpha_mode().
2025-09-02 - ecebf9c6935 - lavc 62.15.100 - avcodec.h codec_par.h
Add AVCodecContext.alpha_mode, AVCodecParameters.alpha_mode, and
AV_CODEC_CONFIG_ALPHA_MODE.
2025-09-02 - eea99a77eda - lavfi 11.6.100 - avfilter.h
Add AVFilterLink.alpha_mode.
2025-09-02 - 22929bd044c - lavu 60.11.100 - frame.h pixfmt.h
Add AVAlphaMode, AVFrame.alpha_mode, av_alpha_mode_name() and
av_alpha_mode_from_name().
2025-09-01 - ce0938da8cd - lsws 9.3.100 - swscale.h
Add SWS_UNSTABLE flag.
2025-09-01 - 4ffd621523e - lavc 62.14.100 - packet.h
Add AV_PKT_DATA_EXIF
2025-08-24 - 368b5e0ffc2 - lavc 62.13.101 - exif.h
Add AV_EXIF_FLAG_RECURSIVE
2025-08-19 - ad77345a5d1..fe496b0308f - lavc 62.13.100 - exif.h
Add:
- enum AVTiffDataType, enum AVExifHeaderMode
- struct AVExifMetadata, struct AVExifEntry
- av_exif_get_tag_name, av_exif_get_tag_id,
av_exif_set_entry, av_exif_get_entry,
av_exif_remove_entry, av_exif_parse_buffer,
av_exif_write, av_exif_free,
av_exif_ifd_to_dict, av_exif_clone_ifd,
av_exif_matrix_to_orientation,
av_exif_orientation_to_matrix,
2025-08-19 - bb90b262d6d - lavu 60.10.100 - frame.h
Add AV_FRAME_DATA_EXIF.
-------- 8< --------- FFmpeg 8.0 was cut here -------- 8< ---------
2025-07-29 - 1c85a3832af - lavc 62.10.100 - smpte_436m.h
Add a new public header smpte_436m.h with API for
manipulating AV_CODEC_ID_SMPTE_436M_ANC data.
+1 -1
View File
@@ -295,7 +295,7 @@ MARKDOWN_SUPPORT = YES
# When enabled doxygen tries to link words that correspond to documented
# classes, or namespaces to their corresponding documentation. Such a link can
# be prevented in individual cases by by putting a % sign in front of the word
# be prevented in individual cases by putting a % sign in front of the word
# or globally by setting AUTOLINK_SUPPORT to NO.
# The default value is: YES.
+1
View File
@@ -28,6 +28,7 @@ HTMLPAGES = $(AVPROGS-yes:%=doc/%.html) $(AVPROGS-yes:%=doc/%-all.html) $(COMP
doc/mailing-list-faq.html \
doc/nut.html \
doc/platform.html \
doc/drawvg-reference.html \
$(SRC_PATH)/doc/bootstrap.min.css \
$(SRC_PATH)/doc/style.min.css \
$(SRC_PATH)/doc/default.css \
+3 -1
View File
@@ -913,6 +913,8 @@ Set expressions for PTS, DTS or both.
Set expression for duration.
@item time_base
Set output time base.
@item prescale
Set whether to convert time fields to user-set output time base before evaluation of expressions. Defaults to 0.
@end table
The expressions are evaluated through the eval API and can contain the following
@@ -973,7 +975,7 @@ The next input PTS.
The next input duration.
@item TB
The timebase of stream packet belongs.
The timebase in which time fields are denominated. The user-set output timebase if prescale is enabled, else the input timebase.
@item TB_OUT
The output timebase.
+8
View File
@@ -913,6 +913,14 @@ Possible values:
@end table
@item alpha_mode @var{integer} (@emph{decoding/encoding,video})
Possible values:
@table @samp
@item premultiplied
@item straight
@end table
@item log_level_offset @var{integer}
Set the log level offset.
+1 -1
View File
@@ -123,7 +123,7 @@ Internally, the TC should take decisions with a majority, or using ranked-choice
Each TC member must vote on such decision according to what is, in their view, best for the project.
If a TC member feels they are affected by a conflict of interest with regards to the case, they should announce it and recurse themselves from the TC
If a TC member feels they are affected by a conflict of interest with regards to the case, they should announce it and recuse themselves from the TC
discussion and vote.
A conflict of interest is presumed to occur when a TC member has a personal interest (e.g. financial) in a specific outcome of the case.
+9 -10
View File
@@ -119,16 +119,6 @@ The following options are supported by the libdav1d wrapper.
@table @option
@item framethreads
Set amount of frame threads to use during decoding. The default value is 0 (autodetect).
This option is deprecated for libdav1d >= 1.0 and will be removed in the future. Use the
option @code{max_frame_delay} and the global option @code{threads} instead.
@item tilethreads
Set amount of tile threads to use during decoding. The default value is 0 (autodetect).
This option is deprecated for libdav1d >= 1.0 and will be removed in the future. Use the
global option @code{threads} instead.
@item max_frame_delay
Set max amount of frames the decoder may buffer internally. The default value is 0
(autodetect).
@@ -356,6 +346,15 @@ value is 0 (disabled).
@end table
@section libmpeghdec
libmpeghdec decoder wrapper.
libmpeghdec allows libmpeghdec to decode the MPEG-H 3D audio codec.
Requires the presence of the libmpeghdec headers and library during
configuration. You need to explicitly configure the build with
@code{--enable-libmpeghdec --enable-nonfree}.
@section libopencore-amrnb
libopencore-amrnb decoder wrapper.
+23 -24
View File
@@ -281,7 +281,11 @@ This demuxer accepts the following option:
@table @option
@item cenc_decryption_key
16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
Default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
@item cenc_decryption_keys
Dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption
(CENC/AES-128 CTR; ISO/IEC 23001-7).
@end table
@@ -664,30 +668,9 @@ Select a glob wildcard pattern type.
The pattern is interpreted like a @code{glob()} pattern. This is only
selectable if libavformat was compiled with globbing support.
@item glob_sequence @emph{(deprecated, will be removed)}
Select a mixed glob wildcard/sequence pattern.
If your version of libavformat was compiled with globbing support, and
the provided pattern contains at least one glob meta character among
@code{%*?[]@{@}} that is preceded by an unescaped "%", the pattern is
interpreted like a @code{glob()} pattern, otherwise it is interpreted
like a sequence pattern.
All glob special characters @code{%*?[]@{@}} must be prefixed
with "%". To escape a literal "%" you shall use "%%".
For example the pattern @code{foo-%*.jpeg} will match all the
filenames prefixed by "foo-" and terminating with ".jpeg", and
@code{foo-%?%?%?.jpeg} will match all the filenames prefixed with
"foo-", followed by a sequence of three characters, and terminating
with ".jpeg".
This pattern type is deprecated in favor of @var{glob} and
@var{sequence}.
@end table
Default value is @var{glob_sequence}.
Default value is @var{sequence}.
@item pixel_format
Set the pixel format of the images to read. If not specified the pixel
format is guessed from the first image file in the sequence.
@@ -961,7 +944,11 @@ Fixed key used for handling Audible AAX/AAX+ files. It has been pre-set so shoul
specify.
@item decryption_key
16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
Default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
@item decryption_keys
Dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption
(CENC/AES-128 CTR; ISO/IEC 23001-7).
@item max_stts_delta
Very high sample deltas written in a trak's stts box may occasionally be intended but usually they are written in
@@ -1056,6 +1043,11 @@ Set input video frame rate. Default value is 25.
@item pixel_format
Set the input video pixel format. Default value is @code{yuv420p}.
@item stride
Set frame line size in bytes, only required if there are extra padding.
For multiplane formats, @option{stride} is a list of line size for each
plane.
@item video_size
Set the input video size. This value must be specified explicitly.
@end table
@@ -1068,6 +1060,13 @@ the command:
ffplay -f rawvideo -pixel_format rgb24 -video_size 320x240 -framerate 10 input.raw
@end example
Read a rawvideo with @command{ffplay}, assuming a pixel format of @code{yuv420p},
a video size of @code{1080x1920}, has 8 bytes of padding in each line of Y plane,
and 4 bytes of padding with UV plane,
@example
ffplay -f rawvideo -pixel_format yuv420p -video_size 1080x1920 -stride 1088,544,544 input.raw
@end example
@anchor{rcwtdec}
@section rcwt
+6 -1
View File
@@ -45,6 +45,7 @@ maintained and developed.
@end itemize
All proposed code changes should be submitted for review to
@url{https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls, Forgejo} or
@url{mailto:ffmpeg-devel@@ffmpeg.org, the development mailing list}, as
described in more detail in the @ref{Submitting patches} chapter. The code
should comply with the @ref{Development Policy} and follow the @ref{Coding Rules}.
@@ -366,6 +367,9 @@ symbols. If in doubt, just avoid names starting with @code{_} altogether.
@item
Casts should be used only when necessary. Unneeded parentheses
should also be avoided if they don't make the code easier to understand.
@item
Where applicable, SI units shall be used. For example timeouts should use seconds as the fundamental unit not micro seconds.
That means a bare value like @samp{1.0} must mean 1 second, @samp{50m} means 50 milliseconds. For weight, gram shall be used.
@end itemize
@anchor{Development Policy}
@@ -722,7 +726,8 @@ and has no lrint()')
Also please if you send several patches, send each patch as a separate mail,
do not attach several unrelated patches to the same mail.
Patches should be posted to the
Patches should be posted to
@uref{https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls, Forgejo} or the
@uref{https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-devel, ffmpeg-devel}
mailing list. Use @code{git send-email} when possible since it will properly
send patches without requiring extra care. If you cannot, then send patches
File diff suppressed because it is too large Load Diff
+134 -2
View File
@@ -1996,6 +1996,49 @@ by ":". See the SVT-AV1 encoder user guide for a list of accepted parameters.
@end table
@section libsvtjpegxs
SVT-JPEG-XS encoder wrapper.
Requires the presence of the SVT-JPEG-XS headers and library during configuration.
You need to explicitly configure the build with @code{--enable-libsvtjpegxs}.
@subsection Options
@table @option
@item decomp_v
Set vertical decomposition level
@item decomp_h
Set horizontal decomposition level
@item quantization
Set the quantization algorithm.
@table @samp
@item deadzone
@item uniform
@end table
@item coding-signs
Enable Signs handling strategy
@table @samp
@item disable
@item fast
@item full
@end table
@item coding-sigf
Enable Significance coding
@item coding-vpred
Enable Vertical Prediction coding
@table @samp
@item disable
@item no_residuals
@item no_coeffs
@end table
@end table
@section libjxl
libjxl JPEG XL encoder wrapper.
@@ -3040,6 +3083,10 @@ Quantizer curve compression factor
Normally, when forcing a I-frame type, the encoder can select any type
of I-frame. This option forces it to choose an IDR-frame.
@item x265-stats
Specify the file name for 2-pass stats. This is set automatically when using
the @option{-passlogfile} option.
@item udu_sei @var{boolean}
Import user data unregistered SEI if available into output. Default is 0 (off).
@@ -3413,12 +3460,97 @@ Maximum quantization parameter for B frame.
@section MediaFoundation
This provides wrappers to encoders (both audio and video) in the
MediaFoundation framework. It can access both SW and HW encoders.
The following wrappers for encoders in the MediaFoundation framework are
available:
@itemize
@item h264_mf
@item hevc_mf
@item av1_mf
@end itemize
These support both software and hardware encoding.
Video encoders can take input in either of nv12 or yuv420p form
(some encoders support both, some support only either - in practice,
nv12 is the safer choice, especially among HW encoders).
Hardware-accelerated encoding requires D3D11, including hardware
scaling capabilities through the scale_d3d11 filter.
To list all available options for the MediaFoundation encoders, use:
@command{ffmpeg -h encoder=<encoder>} e.g. @command{ffmpeg -h encoder=h264_mf}
@subsection Options
@table @option
@item rate_control
Select rate control mode. Available modes:
@table @samp
@item default
Default mode
@item cbr
CBR mode
@item pc_vbr
Peak constrained VBR mode
@item u_vbr
Unconstrained VBR mode
@item quality
Quality mode
@item ld_vbr
Low delay VBR mode (requires Windows 8+)
@item g_vbr
Global VBR mode (requires Windows 8+)
@item gld_vbr
Global low delay VBR mode (requires Windows 8+)
@end table
@item scenario
Select usage scenario. Available scenarios:
@table @samp
@item default
Default scenario
@item display_remoting
Display remoting scenario
@item video_conference
Video conference scenario
@item archive
Archive scenario
@item live_streaming
Live streaming scenario
@item camera_record
Camera record scenario
@item display_remoting_with_feature_map
Display remoting with feature map scenario
@end table
@item quality
Set encoding quality (0-100). -1 means default quality.
@item hw_encoding
Force hardware encoding (0-1). Default is 0 (disabled).
@end table
@subsection Examples
Hardware encoding:
@example
ffmpeg -i input.mp4 -c:v h264_mf -hw_encoding 1 output.mp4
@end example
Hardware-accelerated decoding with hardware encoding:
@example
ffmpeg -hwaccel d3d11va -i input.mp4 -c:v h264_mf -hw_encoding 1 output.mp4
@end example
Hardware-accelerated decoding, HW scaling and encoding with quality setting:
@example
ffmpeg -hwaccel d3d11va -hwaccel_output_format d3d11 -i input.mp4 -vf scale_d3d11=1920:1080 -c:v hevc_mf -hw_encoding 1 -quality 80 output.mp4
@end example
@section Microsoft RLE
Microsoft RLE aka MSRLE encoder.
-2
View File
@@ -30,8 +30,6 @@
* file to be played with ffplay.
*/
#include <unistd.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/buffersink.h>
+2 -3
View File
@@ -27,8 +27,6 @@
* @example decode_filter_video.c
*/
#define _XOPEN_SOURCE 600 /* for usleep */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -38,6 +36,7 @@
#include <libavfilter/buffersrc.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavutil/time.h>
const char *filter_descr = "scale=78:24,transpose=cclock";
/* other way:
@@ -195,7 +194,7 @@ static void display_frame(const AVFrame *frame, AVRational time_base)
delay = av_rescale_q(frame->pts - last_pts,
time_base, AV_TIME_BASE_Q);
if (delay > 0 && delay < 1000000)
usleep(delay);
av_usleep(delay);
}
last_pts = frame->pts;
}
+1
View File
@@ -109,6 +109,7 @@ static int open_codec_context(AVFormatContext *fmt_ctx, enum AVMediaType type)
ret = avcodec_parameters_to_context(dec_ctx, st->codecpar);
if (ret < 0) {
fprintf(stderr, "Failed to copy codec parameters to codec context\n");
avcodec_free_context(&dec_ctx);
return ret;
}
+3 -1
View File
@@ -215,8 +215,10 @@ int main(int argc, char *argv[])
return AVERROR(ENOMEM);
video = input_ctx->streams[video_stream];
if (avcodec_parameters_to_context(decoder_ctx, video->codecpar) < 0)
if (avcodec_parameters_to_context(decoder_ctx, video->codecpar) < 0) {
avcodec_free_context(&decoder_ctx);
return -1;
}
decoder_ctx->get_format = get_hw_format;
+4
View File
@@ -351,6 +351,10 @@ int main(int argc, char **argv)
}
setting_number = (argc - 5) / 2;
dynamic_setting = av_malloc(setting_number * sizeof(*dynamic_setting));
if (!dynamic_setting) {
ret = AVERROR(ENOMEM);
goto end;
}
current_setting_number = 0;
for (int i = 0; i < setting_number; i++) {
dynamic_setting[i].frame_number = atoi(argv[i*2 + 5]);
+1 -1
View File
@@ -88,7 +88,7 @@ static int encode_write(AVCodecContext *avctx, AVFrame *frame, FILE *fout)
enc_pkt->stream_index = 0;
ret = fwrite(enc_pkt->data, enc_pkt->size, 1, fout);
av_packet_unref(enc_pkt);
if (ret != enc_pkt->size) {
if (!ret) {
ret = AVERROR(errno);
break;
}
+38 -18
View File
@@ -42,41 +42,60 @@ targets and variables.
@chapter Using FATE from your FFmpeg source directory
If you want to run FATE on your machine you need to have the samples
in place. You can get the samples via the build target fate-rsync.
Use this command from the top-level source directory:
If you want to run FATE on your machine, FFmpeg needs to be configured first.
You may specify the location of samples during configuration by adding the
argument @code{--samples=/path/to/fate-suite}.
@example
make fate-rsync SAMPLES=fate-suite/
make fate SAMPLES=fate-suite/
./configure --enable-somelib --samples=/path/to/fate-suite
@end example
The above commands set the samples location by passing a makefile
variable via command line. It is also possible to set the samples
location at source configuration time by invoking configure with
@option{--samples=<path to the samples directory>}. Afterwards you can
invoke the makefile targets without setting the @var{SAMPLES} makefile
variable. This is illustrated by the following commands:
After successful configuration, you need to add and/or update the samples in place:
@example
./configure --samples=fate-suite/
make fate-rsync
@end example
Now you are ready to run FATE:
@example
make fate
@end example
See @ref{makefile variables} for a list of arguments that can be added.
If you did not set the samples path during configuration, or if you wish to
override it just before starting FATE, you can do so in one of three ways.
Either by setting a make variable:
@example
make fate-rsync SAMPLES=/path/to/fate-suite
make fate SAMPLES=/path/to/fate-suite
@end example
or by setting an environment variable for the current session:
@example
export FATE_SAMPLES=/path/to/fate-suite
make fate-rsync
make fate
@end example
Yet another way to tell FATE about the location of the sample
directory is by making sure the environment variable FATE_SAMPLES
contains the path to your samples directory. This can be achieved
by e.g. putting that variable in your shell profile or by setting
it in your interactive session.
or in isolation for a single command by prepending it:
@example
FATE_SAMPLES=fate-suite/ make fate
FATE_SAMPLES=/path/to/fate-suite make fate-rsync
FATE_SAMPLES=/path/to/fate-suite make fate
@end example
This variable can also be set in your shell profile to make it permanent.
@float NOTE
Do not put a '~' character in the samples path to indicate a home
directory. Because of shell nuances, this will cause FATE to fail.
Also, on Windows the path has to be relative to the build path
which in this case is the FFmpeg source directory.
@end float
Beware that some assertions are disabled by default, so mind setting
@@ -220,6 +239,7 @@ Run the FATE test suite (requires the fate-suite dataset).
@end table
@section Makefile variables
@anchor{makefile variables}
@table @env
@item V
+7
View File
@@ -6,21 +6,28 @@ workdir= # directory in which to do all the work
#fate_recv="ssh -T fate@fate.ffmpeg.org" # command to submit report
comment= # optional description
build_only= # set to "yes" for a compile-only instance that skips tests
skip_clean= # set to "yes" to preserve build/install directories
ignore_tests=
# the following are optional and map to configure options
arch=
cpu=
toolchain=
cross_prefix=
ar=
as=
cc=
cxx=
ld=
nm=
target_os=
sysroot=
target_exec=
target_path=
target_samples=
extra_cflags=
extra_cxxflags=
extra_objcflags=
extra_ldflags=
extra_libs=
extra_conf= # extra configure options not covered above
+9
View File
@@ -1665,6 +1665,7 @@ Force video tag/fourcc. This is an alias for @code{-tag:v}.
@item -force_key_frames[:@var{stream_specifier}] @var{time}[,@var{time}...] (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] expr:@var{expr} (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] source (@emph{output,per-stream})
@item -force_key_frames[:@var{stream_specifier}] scd_metadata (@emph{output,per-stream})
@var{force_key_frames} can take arguments of the following form:
@@ -1728,6 +1729,14 @@ the current frame being encoded is marked as a key frame in its source.
In cases where this particular source frame has to be dropped,
enforce the next available frame to become a key frame instead.
@item scd_metadata
If the argument is @code{scd_metadata}, ffmpeg will force a key frame if
the current frame contains a metadata entry with the key @code{lavfi.scd.time}.
The metadata can be added by filters like @code{scdet} and @code{scdet_vulkan}.
Avoid inserting filters that duplicate frames after @code{scdet}, as this can
cause duplicate metadata for multiple frames and repeated insertion of key
frames.
@end table
Note that forcing too many keyframes is very harmful for the lookahead
+10 -4
View File
@@ -208,6 +208,14 @@ Vulkan configuration using a list of @var{key}=@var{value} pairs separated by
Use HW accelerated decoding. Enable this option will enable vulkan renderer
automatically.
@item -video_bg @var{pattern}
Set the video background pattern used for transparent videos. For solid color
patterns you can use the color name or color code as specified in the
@ref{color syntax,,Color section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
You can also use the special @code{tiles} keyword for a checker board style
pattern. This is also the default. The @code{none} pattern does rendering
without alpha blending effectively ignoring alpha channel.
@end table
@section While playing
@@ -251,15 +259,13 @@ Pause if the stream is not already paused, step to the next video
frame, and pause.
@item left/right
Seek backward/forward 10 seconds.
Seek backward/forward by 10 seconds or a custom interval if -seek_interval is set.
@item down/up
Seek backward/forward 1 minute.
@item page down/page up
Seek to the previous/next chapter.
or if there are no chapters
Seek backward/forward 10 minutes.
Seek to previous/next chapter or backward/forward 10 minutes if no chapters.
@item right mouse click
Seek to percentage in file corresponding to fraction of width.
+13 -1
View File
@@ -117,7 +117,8 @@ ffprobe -show_packets -select_streams v:1 INPUT
@end example
@item -show_data
Show payload data, as a hexadecimal and ASCII dump. Coupled with
Show payload data, as a hexadecimal and ASCII dump (other formats can be
selected using @option{-data_dump_format}). Coupled with
@option{-show_packets}, it will dump the packets' data. Coupled with
@option{-show_streams}, it will dump the codec extradata.
@@ -127,6 +128,11 @@ The dump is printed as the "data" field. It may contain newlines.
Show a hash of payload data, for packets with @option{-show_packets} and for
codec extradata with @option{-show_streams}.
@item -data_dump_format @var{format}
Select a format used for the data dumps enabled with the @option{-show_data}
option. The default is @code{xxd} which is a hexdump format compatible with the
well-known @command{xxd} program. @code{base64} is also supported.
@item -show_error
Show information about the error found when trying to probe the input.
@@ -368,6 +374,12 @@ Read @var{input_url}.
Write output to @var{output_url}. If not specified, the output is sent
to stdout.
@item -c:@var{media_specifier} @var{codec_name}
@itemx -codec:@var{media_specifier} @var{codec_name}
Force a specific decoder implementation for the stream identified by
@var{media_specifier}, which can assume the values @code{a} (audio),
@code{v} (video), @code{s} (subtitle), and @code{d} (data).
@end table
@c man end
+1
View File
@@ -276,6 +276,7 @@
<xsd:attribute name="extradata" type="xsd:string" />
<xsd:attribute name="extradata_size" type="xsd:int" />
<xsd:attribute name="extradata_hash" type="xsd:string" />
<xsd:attribute name="mime_codec_string" type="xsd:string" />
<!-- video attributes -->
<xsd:attribute name="width" type="xsd:int"/>
+1 -1
View File
@@ -98,7 +98,7 @@ These options are shared amongst the ff* tools.
@table @option
@item -L
@item -L, -license
Show license.
@item -h, -?, -help, --help [@var{arg}]
+754 -103
View File
File diff suppressed because it is too large Load Diff
+21
View File
@@ -250,6 +250,14 @@ Go to @url{http://sourceforge.net/projects/opencore-amr/} and follow the
instructions for installing the library.
Then pass @code{--enable-libfdk-aac} to configure to enable it.
@subsection Fraunhofer MPEG-H 3D Audio decoder library
FFmpeg can make use of the Fraunhofer MPEG-H decoder library for MPEG-H 3DA decoding.
Go to @url{https://github.com/Fraunhofer-IIS/mpeghdec} and follow the
instructions for installing the library.
Then pass @code{--enable-libmpeghdec --enable-nonfree} to configure to enable it.
@subsection LC3 library
FFmpeg can make use of the Google LC3 library for LC3 decoding & encoding.
@@ -295,6 +303,15 @@ Go to @url{https://gitlab.com/AOMediaCodec/SVT-AV1/} and follow the instructions
for installing the library. Then pass @code{--enable-libsvtav1} to configure to
enable it.
@section SVT-JPEG-XS
FFmpeg can make use of the Scalable Video Technology for JPEG-XS library for JPEG-XS
decoding and encoding.
Go to @url{https://github.com/OpenVisualCloud/SVT-JPEG-XS} and follow the instructions
for installing the library. Then pass @code{--enable-libsvtjpegxs} to configure to
enable it.
@section TwoLAME
FFmpeg can make use of the TwoLAME library for MP2 encoding.
@@ -811,6 +828,8 @@ following image formats are supported:
@tab Progressive JPEG is not supported.
@item JPEG 2000 @tab X @tab X
@item JPEG-LS @tab X @tab X
@item JPEG-XS @tab E @tab E
@tab Supported through external library libsvtjpegxs
@item LJPEG @tab X @tab
@tab Lossless JPEG
@item Media 100 @tab @tab X
@@ -1344,6 +1363,8 @@ following image formats are supported:
@item MP3 (MPEG audio layer 3) @tab E @tab IX
@tab encoding supported through external library LAME, ADU MP3 and MP3onMP4 also supported
@item MPEG-4 Audio Lossless Coding (ALS) @tab @tab X
@item MPEG-H 3D Audio @tab @tab E
@tab decoding supported through external library libmpeghdec
@item MobiClip FastAudio @tab @tab X
@item Musepack SV7 @tab @tab X
@item Musepack SV8 @tab @tab X
+1
View File
@@ -4,3 +4,4 @@ ffmpeg-formats mono ./ffmpeg-formats.html
ffmpeg-resampler mono ./ffmpeg-resampler.html
ffmpeg-scaler mono ./ffmpeg-scaler.html
ffmpeg-utils mono ./ffmpeg-utils.html
drawvg-reference mono ./drawvg-reference.html
+20
View File
@@ -24,6 +24,26 @@ Our Main server is hosted at telepoint.bg
for more details see: https://www.ffmpeg.org/#thanks_sponsor_0001
Nothing runs on our main server directly, instead several VMs run on it.
Main server security:
---------------------
Telepoint is one of the largest Bulgarian DC providers with multiple sibling companies offering
Internet, SDH, DWDM, peering exchange and hosting. They have multiple DC buildings in Sofia and
FFmpeg is hosted in XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. The building is locked down and accessible
only with personal key cards that are registered. People who are granted access to a rack have
to go through the access center with their ID to get logged and receive a one-time access card
that can open the service elevator and only the hall where the destination rack is. All racks are
locked, once access is granted to someone they will get a key for the rack for the duration of
their visit. There are security cameras everywhere and personnel in the access center 24/7. As for
software security, our BIOS and IPMI are protected by password and encrypted connection, and
the machines can be accessed only by root administrators with their SSH keys. They're using
a Ubuntu LTS release and get regular security updates as they are released. We also get
notified by email for various security related events (e.g. failed sudo).
Side note - Telepoint provides the rack and physical infrastructure, their sibling company called
Telehouse which is an ISP provides the connectivity, they are directly connected with
over 15 tier-1 service providers and have over 100 PoPs (points of presence)
in various cities. You can see more on www.telehouse.bg
ffmpeg.org VM:
--------------
+1 -1
View File
@@ -341,7 +341,7 @@ recommended.
Avoid sending the same message to multiple mailing lists.
@item
Please follow our @url{https://ffmpeg.org/community.html#Code-of-conduct, Code of Conduct}.
Please follow our @url{https://ffmpeg.org/community.html#Code-of-Conduct, Code of Conduct}.
@end itemize
@chapter Help
+17 -1
View File
@@ -3953,7 +3953,23 @@ Default value is 5000.
@item pkt_size @var{integer}
Set the maximum size, in bytes, of RTP packets that send out.
Default value is 1500.
Default value is 1200.
@item ts_buffer_size @var{integer}
Set the buffer size, in bytes, of underlying protocol.
Default value is -1(auto). The UDP auto selects a reasonable value.
@item whip_flags @var{flags}
Possible values:
@table @samp
@item dtls_active
The muxer will try to set dtls active role and send the first client hello.
@end table
@item rtp_history @var{integer}
Set the number of RTP history items to store.
Default value is 512.
@item authorization @var{string}
The optional Bearer token for WHIP Authorization.
+1 -1
View File
@@ -5,7 +5,7 @@ What to optimize:
-----------------
If you plan to do non-x86 architecture specific optimizations (SIMD normally),
then take a look in the x86/ directory, as most important functions are
already optimized for MMX.
already optimized for x86.
If you want to do x86 optimizations then you can either try to fine-tune the
stuff in the x86 directory or find some other functions in the C source to
+16
View File
@@ -330,4 +330,20 @@ and for a build with shared libraries
./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
@end example
@section ARM64EC
FFmpeg does not intend to support the Windows ARM64EC build configuration;
patches for changing the individual libraries for the purposes of ARM64EC will
not be accepted.
It may still be possible to build FFmpeg in this build configuration;
such a build may seem to work to some extent. Such a build may have some
amounts of ABI inconsistencies though - which we are not willing to fix.
(Changing aarch64 assembly code to strictly support ARM64EC would require
ifdeffing/changing essentially all such assembly code, and would be a
huge maintenance burden. Additionally, changing the library ABI
surfaces to fix ABI inconsistencies could require extensive and intrusive
changes.)
@bye
+184 -46
View File
@@ -352,6 +352,17 @@ means auto (seekable for normal files, non-seekable for named pipes).
Many demuxers handle seekable and non-seekable resources differently,
overriding this might speed up opening certain files at the cost of losing some
features (e.g. accurate seeking).
@item pkt_size
Set the maximum packet size used for file I/O. A smaller value may reduce
memory usage. A higher value may increase throughput especially with networked
filesystems.
For reading, if explicitly set, it overrides the default internal buffer size
(32 KB) and limits the maximum amount of data read per operation.
For writing, this sets the size of each write operation. The default is 256 KB
for regular files, 32 KB otherwise.
@end table
@section ftp
@@ -406,26 +417,6 @@ Gophers protocol.
The Gopher protocol with TLS encapsulation.
@section hls
Read Apple HTTP Live Streaming compliant segmented stream as
a uniform one. The M3U8 playlists describing the segments can be
remote HTTP resources or local files, accessed using the standard
file protocol.
The nested protocol is declared by specifying
"+@var{proto}" after the hls URI scheme name, where @var{proto}
is either "file" or "http".
@example
hls+http://host/path/to/remote/resource.m3u8
hls+file://path/to/local/resource.m3u8
@end example
Using this protocol is discouraged - the hls demuxer should work
just as well (if not, please report the issues) and is more complete.
To use the hls demuxer instead, simply use the direct URLs to the
m3u8 files.
@section http
HTTP (Hyper Text Transfer Protocol).
@@ -462,6 +453,28 @@ Set the Referer header. Include 'Referer: URL' header in HTTP request.
@item multiple_requests
Use persistent connections if set to 1, default is 0.
@item request_size
Limit the size of requests made. This is useful for some pathological servers
that throttle unbounded range requests, as well as when expecting to seek
frequently. Disabled (set to 0) by default.
Note that if enabling this option, it's strongly recommended to also enable
the @option{multiple_requests} option, as well as setting
@option{short_seek_size} to the same value or higher. Doing so allows FFmpeg
to reuse a single HTTP connection wherever possible.
@item initial_request_size
Limit the size of initial requests. Similar to @code{request_size}, but only
used during initial format parsing. Useful for formats like MXF or MOV that
require frequent seeks during header parsing. Lasts until the demuxer makes a
read request larger than this size (without a seek in between), after which
the implementation will continue using requests as usual. Disabled (set to 0)
by default.
Note that if enabling this option, it's strongly recommended to also enable
the @option{multiple_requests} option, as well as setting
@option{short_seek_size} to the same value or higher.
@item post_data
Set custom HTTP post data.
@@ -986,6 +999,11 @@ Set TCP_NODELAY to disable Nagle's algorithm. Default value is 0.
@emph{Remark: Writing to the socket is currently not optimized to minimize system calls and reduces the efficiency / effect of TCP_NODELAY.}
@item tcp_keepalive=@var{1|0}
Enable the TCP keepalive mechanism to detect dead peers and help maintain long-lived idle connections. Default value is 0.
Only the basic keepalive option (SO_KEEPALIVE) can be enabled or disabled. Platform-specific tuning parameters such as TCP_KEEPIDLE, TCP_KEEPINTVL, or TCP_KEEPCNT are not configurable and will use the operating system's default values.
@end table
For example to read with @command{ffplay} a multimedia resource named
@@ -1157,9 +1175,13 @@ rtp://@var{hostname}[:@var{port}][?@var{options}]
@var{port} specifies the RTP port to use.
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}.
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
The following URL options are supported:
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@table @option
@@ -1169,10 +1191,12 @@ Set the TTL (Time-To-Live) value (for multicast only).
@item rtcpport=@var{n}
Set the remote RTCP port to @var{n}.
@item localrtpport=@var{n}
@item localport, local_rtpport, localrtpport=@var{n}
Set the local RTP port to @var{n}.
@item localrtcpport=@var{n}'
Using the localport option name is deprecated and should not be used.
@item local_rtcpport, localrtcpport=@var{n}'
Set the local RTCP port to @var{n}.
@item pkt_size=@var{n}
@@ -1195,12 +1219,6 @@ List disallowed (blocked) source IP addresses.
Send packets to the source address of the latest received packet (if
set to 1) or to a default remote address (if set to 0).
@item localport=@var{n}
Set the local RTP port to @var{n}.
This is a deprecated option. Instead, @option{localrtpport} should be
used.
@item localaddr=@var{addr}
Local IP address of a network interface used for sending packets or joining
multicast groups.
@@ -1534,7 +1552,15 @@ The accepted URL syntax is:
sctp://@var{host}:@var{port}[?@var{options}]
@end example
The protocol accepts the following options:
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@table @option
@item listen
If set to any value, listen for an incoming connection. Outgoing connection is done by default.
@@ -1553,18 +1579,13 @@ srt://@var{hostname}:@var{port}[?@var{options}]
@end example
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}.
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
or
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
@example
@var{options} srt://@var{hostname}:@var{port}
@end example
@var{options} contains a list of '-@var{key} @var{val}'
options.
This protocol accepts the following options.
The list of supported options follows.
@table @option
@item connect_timeout=@var{milliseconds}
@@ -1917,7 +1938,11 @@ tcp://@var{hostname}:@var{port}[?@var{options}]
@end example
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}.
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@@ -1972,8 +1997,14 @@ The required syntax for a TLS/SSL url is:
tls://@var{hostname}:@var{port}[?@var{options}]
@end example
The following parameters can be set via command line options
(or in code via @code{AVOption}s):
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
The list of supported options follows.
@table @option
@@ -1984,7 +2015,7 @@ need to be specified for verification to work, but not all libraries and
setups have defaults built in.
The file must be in OpenSSL PEM format.
@item tls_verify=@var{1|0}
@item tls_verify, verify=@var{1|0}
If enabled, try to verify the peer that we are communicating with.
Note, if using OpenSSL, this currently only makes sure that the
peer certificate is signed by one of the root certificates in the CA
@@ -2028,6 +2059,94 @@ To play back a stream from the TLS/SSL server using @command{ffplay}:
ffplay tls://@var{hostname}:@var{port}
@end example
@section dtls
Datagram Transport Layer Security (DTLS)
The required syntax for a DTLS URL is:
@example
dtls://@var{hostname}:@var{port}[?@var{options}]
@end example
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
DTLS shares most options with TLS, but operates over UDP instead of TCP.
The list of supported options follows.
@table @option
@item ca_file, cafile=@var{filename}
A file containing certificate authority (CA) root certificates to treat
as trusted. If the linked TLS library contains a default this might not
need to be specified for verification to work, but not all libraries and
setups have defaults built in.
The file must be in OpenSSL PEM format.
@item tls_verify, verify=@var{1|0}
If enabled, try to verify the peer that we are communicating with.
Note, if using OpenSSL, this currently only makes sure that the
peer certificate is signed by one of the root certificates in the CA
database, but it does not validate that the certificate actually
matches the host name we are trying to connect to.
This is disabled by default since it requires a CA database to be
provided by the caller in many cases.
@item cert_file, cert=@var{filename}
A file containing a certificate to use in the handshake with the peer.
(When operating as server, in listen mode, this is more often required
by the peer, while client certificates only are mandated in certain
setups.)
@item key_file, key=@var{filename}
A file containing the private key for the certificate.
@item cert_pem=@var{string}
Certificate PEM string
@item key_pem=@var{string}
Private key PEM string
@item listen=@var{1|0}
If enabled, listen for connections on the provided port, and assume
the server role in the handshake instead of the client role.
@item mtu=@var{size}
Set the Maximum Transmission Unit (MTU) for DTLS packets.
@item use_srtp=@var{1|0}
Enable the use_srtp DTLS extension.
This is used in WebRTC applications to establish SRTP encryption keys
through the DTLS handshake. Default is disabled.
@item external_sock=@var{1|0}
Use an external socket instead of creating a new one.
This option only makes sense to pass when interacting with the code via
API, enabling this from CLI will cause immediate failure.
Default is disabled.
@end table
Example command lines:
To create a DTLS server:
@example
ffmpeg -listen 1 -i dtls://@var{hostname}:@var{port} @var{output}
@end example
To create a DTLS client and send data to server:
@example
ffmpeg -i @var{input} -f @var{format} dtls://@var{hostname}:@var{port}
@end example
@section udp
User Datagram Protocol.
@@ -2037,7 +2156,12 @@ The required syntax for an UDP URL is:
udp://@var{hostname}:@var{port}[?@var{options}]
@end example
@var{options} contains a list of &-separated options of the form @var{key}=@var{val}.
@var{options} contains a list of &-separated options of the form
@var{key}=@var{val}. Standard percent-encoding (and using the plus sign for
space) can be used to escape keys and values.
Options can also can be specified via command line options (or in code via
@code{AVOption}s).
In case threading is enabled on the system, a circular buffer is used
to store the incoming data, which allows one to reduce loss of data due to
@@ -2076,6 +2200,9 @@ Explicitly allow or disallow reusing UDP sockets.
@item ttl=@var{ttl}
Set the time to live value (for multicast only).
@item dscp=@var{dscp}
Set the 6-bit DSCP field for outgoing packets.
@item connect=@var{1|0}
Initialize the UDP socket with @code{connect()}. In this case, the
destination address can't be changed with ff_udp_set_remote_url later.
@@ -2157,6 +2284,17 @@ The following parameters can be set via command line options
Timeout in ms.
@item listen
Create the Unix socket in listening mode.
@item type
Select socket type.
@table @samp
@item stream Corresponds to SOCK_STREAM (reliable stream-oriented)
@item datagram Corresponds to SOCK_DGRAM (unreliable packet-oriented)
@item seqpacket Corresponds to SOCK_SEQPACKET (reliable packet-oriented)
@end table
@item pkt_size
Maximum packet size for packet-oriented sockets (SOCK_DGRAM and
SOCK_SEQPACKET). If greater than zero, this value is used as
@code{max_packet_size}. Ignored for SOCK_STREAM. Default is @code{0}.
@end table
@section zmq
+4
View File
@@ -68,6 +68,10 @@ Select full chroma input.
@item bitexact
Enable bitexact output.
@item unstable
Allow the use of experimental new code. May subtly affect the output or even
produce wrong results. For testing only.
@end table
@item srcw @var{(API only)}
+1 -1
View File
@@ -62,7 +62,7 @@ This overall approach has a considerable number of benefits:
multiple levels of complicated, interwoven format handling code that is
legacy swscale.
2. Because most of the brains lives inside the the powerful optimizer, we get
2. Because most of the brains lives inside the powerful optimizer, we get
fast paths "for free" for any suitable format conversion, rather than having
to enumerate them one by one. SIMD code itself can be written in a very
general way and does need to be tied to specific pixel formats - subsequent
+2 -1
View File
@@ -5,6 +5,8 @@ OBJS-$(HAVE_VFP) += $(VFP-OBJS) $(VFP-OBJS-yes)
OBJS-$(HAVE_NEON) += $(NEON-OBJS) $(NEON-OBJS-yes)
OBJS-$(HAVE_SVE) += $(SVE-OBJS) $(SVE-OBJS-yes)
OBJS-$(HAVE_SVE2) += $(SVE2-OBJS) $(SVE2-OBJS-yes)
OBJS-$(HAVE_SME) += $(SME-OBJS) $(SME-OBJS-yes)
OBJS-$(HAVE_SME2) += $(SME2-OBJS) $(SME2-OBJS-yes)
OBJS-$(HAVE_MIPSFPU) += $(MIPSFPU-OBJS) $(MIPSFPU-OBJS-yes)
OBJS-$(HAVE_MIPSDSP) += $(MIPSDSP-OBJS) $(MIPSDSP-OBJS-yes)
@@ -23,5 +25,4 @@ OBJS-$(HAVE_RV_ZVBB) += $(RVVB-OBJS) $(RVVB-OBJS-yes)
OBJS-$(HAVE_SIMD128) += $(SIMD128-OBJS) $(SIMD128-OBJS-yes)
OBJS-$(HAVE_MMX) += $(MMX-OBJS) $(MMX-OBJS-yes)
OBJS-$(HAVE_X86ASM) += $(X86ASM-OBJS) $(X86ASM-OBJS-yes)
+49 -35
View File
@@ -12,14 +12,23 @@ endif
ifndef SUBDIR
LINK = $(LD) $(1)
ifeq ($(LD),$(CC))
ifneq ($(CXX),)
LDXX := $(CXX)
LINK = $(if $(filter -lstdc++,$(1)),$(LDXX) $(filter-out -lstdc++,$(1)),$(LD) $(1))
endif
endif
BIN2CEXE = ffbuild/bin2c$(HOSTEXESUF)
BIN2C = $(BIN2CEXE)
ifndef V
Q = @
ECHO = printf "$(1)\t%s\n" $(2)
BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD STRIP CP WINDRES NVCC BIN2C METALCC METALLIB
SILENT = DEPCC DEPHOSTCC DEPAS DEPX86ASM RANLIB RM
BRIEF = CC CXX OBJCC HOSTCC HOSTLD AS X86ASM AR LD LDXX STRIP CP WINDRES GLSLC NVCC BIN2C METALCC METALLIB
SILENT = DEPCC DEPCXX DEPHOSTCC DEPAS DEPX86ASM RANLIB RM
MSG = $@
M = @$(call ECHO,$(TAG),$@);
@@ -42,7 +51,7 @@ OBJCCFLAGS = $(CPPFLAGS) $(CFLAGS) $(OBJCFLAGS)
ASFLAGS := $(CPPFLAGS) $(ASFLAGS)
# Use PREPEND here so that later (target-dependent) additions to CPPFLAGS
# end up in CXXFLAGS.
$(call PREPEND,CXXFLAGS, CPPFLAGS CFLAGS)
$(call PREPEND,CXXFLAGS, CPPFLAGS)
X86ASMFLAGS += $(IFLAGS:%=%/) -I$(<D)/ -Pconfig.asm
HOSTCCFLAGS = $(IFLAGS) $(HOSTCPPFLAGS) $(HOSTCFLAGS)
@@ -59,6 +68,7 @@ COMPILE_S = $(call COMPILE,AS)
COMPILE_M = $(call COMPILE,OBJCC)
COMPILE_X86ASM = $(call COMPILE,X86ASM)
COMPILE_HOSTC = $(call COMPILE,HOSTCC)
COMPILE_GLSLC = $(call COMPILE,GLSLC)
COMPILE_NVCC = $(call COMPILE,NVCC)
COMPILE_MMI = $(call COMPILE,CC,MMIFLAGS)
COMPILE_MSA = $(call COMPILE,CC,MSAFLAGS)
@@ -115,6 +125,26 @@ COMPILE_LASX = $(call COMPILE,CC,LASXFLAGS)
$(BIN2CEXE): ffbuild/bin2c_host.o
$(HOSTLD) $(HOSTLDFLAGS) $(HOSTLD_O) $^ $(HOSTEXTRALIBS)
RUN_BIN2C = $(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
RUN_GZIP = $(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
RUN_MINIFY = $(M)sed 's!/\\*.*\\*/!!g' $< | tr '\n' ' ' | tr -s ' ' | sed 's/^ //; s/ $$//' > $@
%.gz: TAG = GZIP
%.min: TAG = MINIFY
%.spv: %.glsl
$(COMPILE_GLSLC)
ifdef CONFIG_SHADER_COMPRESSION
%.spv.gz: %.spv
$(RUN_GZIP)
%.spv.c: %.spv.gz $(BIN2CEXE)
$(RUN_BIN2C)
else
%.spv.c: %.spv $(BIN2CEXE)
$(RUN_BIN2C)
endif
%.metal.air: %.metal
$(METALCC) $< -o $@
@@ -122,61 +152,46 @@ $(BIN2CEXE): ffbuild/bin2c_host.o
$(METALLIB) --split-module-without-linking $< -o $@
%.metallib.c: %.metallib $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
%.ptx: %.cu $(SRC_PATH)/compat/cuda/cuda_runtime.h
$(COMPILE_NVCC)
ifdef CONFIG_PTX_COMPRESSION
%.ptx.gz: TAG = GZIP
ifdef CONFIG_SHADER_COMPRESSION
%.ptx.gz: %.ptx
$(M)gzip -nc9 $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) >$@
$(RUN_GZIP)
%.ptx.c: %.ptx.gz $(BIN2CEXE)
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
else
%.ptx.c: %.ptx $(BIN2CEXE)
$(BIN2C) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
endif
# 1) Preprocess CSS to a minified version
%.css.min: TAG = SED
%.css.min: %.css
$(M)sed 's!/\\*.*\\*/!!g' $< \
| tr '\n' ' ' \
| tr -s ' ' \
| sed 's/^ //; s/ $$//' \
> $@
$(RUN_MINIFY)
ifdef CONFIG_RESOURCE_COMPRESSION
# 2) Gzip the minified CSS
%.css.min.gz: TAG = GZIP
%.css.min.gz: %.css.min
$(M)gzip -nc9 $< > $@
$(RUN_GZIP)
# 3) Convert the gzipped CSS to a .c array
%.css.c: %.css.min.gz $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
# 4) Gzip the HTML file (no minification needed)
%.html.gz: TAG = GZIP
%.html.gz: %.html
$(M)gzip -nc9 $< > $@
$(RUN_GZIP)
# 5) Convert the gzipped HTML to a .c array
%.html.c: %.html.gz $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
else # NO COMPRESSION
# 2) Convert the minified CSS to a .c array
%.css.c: %.css.min $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
# 3) Convert the plain HTML to a .c array
%.html.c: %.html $(BIN2CEXE)
$(BIN2C) $< $@ $(subst .,_,$(basename $(notdir $@)))
$(RUN_BIN2C)
endif
clean::
@@ -228,12 +243,11 @@ ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)
SKIPHEADERS += $(ARCH_HEADERS:%=$(ARCH)/%) $(SKIPHEADERS-)
SKIPHEADERS := $(SKIPHEADERS:%=$(SUBDIR)%)
HOBJS = $(filter-out $(SKIPHEADERS:.h=.h.o),$(ALLHEADERS:.h=.h.o))
SPVOBJS = $(filter %.spv.o,$(OBJS))
PTXOBJS = $(filter %.ptx.o,$(OBJS))
RESOURCEOBJS = $(filter %.css.o %.html.o,$(OBJS))
$(HOBJS): CCFLAGS += $(CFLAGS_HEADERS)
checkheaders: $(HOBJS)
.SECONDARY: $(HOBJS:.o=.c) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) $(PTXOBJS:.o=) $(RESOURCEOBJS:.o=.c) $(RESOURCEOBJS:%.css.o=%.css.min) $(RESOURCEOBJS:%.css.o=%.css.min.gz) $(RESOURCEOBJS:%.html.o=%.html.gz) $(RESOURCEOBJS:.o=)
.SECONDARY: $(HOBJS:.o=.c) $(SPVOBJS:.o=.c) $(SPVOBJS:.o=.gz) $(SPVOBJS:.o=) $(PTXOBJS:.o=.c) $(PTXOBJS:.o=.gz) $(PTXOBJS:.o=)
alltools: $(TOOLS)
$(HOSTOBJS): %.o: %.c
@@ -252,7 +266,7 @@ $(TOOLOBJS): | tools
OUTDIRS := $(OUTDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SHLIBOBJS) $(STLIBOBJS) $(TESTOBJS))
CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx *.ptx.gz *.ptx.c *.ver *.version *.html.gz *.html.c *.css.gz *.css.c *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
CLEANSUFFIXES = *.d *.gcda *.gcno *.h.c *.ho *.map *.o *.objs *.pc *.ptx *.ptx.gz *.ptx.c *.spv *.spv.gz *.spv.c *.ver *.version *.html.gz *.html.c *.css.min.gz *.css.min *.css.c *$(DEFAULT_X86ASMD).asm *~ *.ilk *.pdb
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
define RULES
@@ -262,4 +276,4 @@ endef
$(eval $(RULES))
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SHLIBOBJS:.o=.d) $(STLIBOBJS:.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d)
-include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d) $(SHLIBOBJS:.o=.d) $(STLIBOBJS:.o=.d) $(SPVOBJS:.spv.o=.d)) $(OBJS:.o=$(DEFAULT_X86ASMD).d)
+7 -3
View File
@@ -55,8 +55,12 @@ $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
$(LIBOBJS): CPPFLAGS += -DBUILDING_$(NAME)
$(NAME)LINK_EXE_ARGS = $(LDFLAGS) $(LDEXEFLAGS)
$(NAME)LINK_SO_ARGS = $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS)
$(NAME)LINK_EXTRA = $(FFEXTRALIBS)
$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
$$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(EXTRALIBS-$$(*F)) $$(ELIBS)
$$(call LINK,$$(call $(NAME)LINK_EXE_ARGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $$(call $(NAME)LINK_EXTRA) $$(EXTRALIBS-$$(*F)) $$(ELIBS))
$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h $(SUBDIR)version_major.h | $(SUBDIR)
$$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$^ > $$@
@@ -74,9 +78,9 @@ $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SHLIBOBJS) $(SUBDIR)lib$(NAME).ver
$(SLIB_CREATE_DEF_CMD)
ifeq ($(RESPONSE_FILES),yes)
$(Q)echo $$(filter %.o,$$^) > $$@.objs
$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) @$$@.objs $(FFEXTRALIBS)
$$(call LINK,$$(call $(NAME)LINK_SO_ARGS) $$(LD_O) @$$@.objs $$(call $(NAME)LINK_EXTRA))
else
$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDSOFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
$$(call LINK,$$(call $(NAME)LINK_SO_ARGS) $$(LD_O) $$(filter %.o,$$^) $$(call $(NAME)LINK_EXTRA))
endif
$(SLIB_EXTRA_CMD)
-$(RM) $$@.objs
+2
View File
@@ -36,6 +36,7 @@ OBJS-ffmpeg += \
fftools/textformat/tw_buffer.o \
fftools/textformat/tw_stdout.o \
$(OBJS-resman) \
$(RESOBJS) \
OBJS-ffprobe += \
fftools/textformat/avtextformat.o \
@@ -50,6 +51,7 @@ OBJS-ffprobe += \
fftools/textformat/tw_buffer.o \
fftools/textformat/tw_stdout.o \
OBJS-ffmpeg += $(COMPAT_OBJS:%=compat/%)
OBJS-ffplay += fftools/ffplay_renderer.o
define DOFFTOOL
+100 -5
View File
@@ -263,7 +263,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
return AVERROR(EINVAL);
}
arg_allocated = file_read(arg);
arg_allocated = read_file_to_string(arg);
if (!arg_allocated) {
av_log(NULL, AV_LOG_FATAL,
"Error reading the value for option '%s' from file: %s\n",
@@ -275,7 +275,7 @@ static int write_option(void *optctx, const OptionDef *po, const char *opt,
}
if (po->flags & OPT_FLAG_SPEC) {
char *p = strchr(opt, ':');
const char *p = strchr(opt, ':');
char *str;
sol = dst;
@@ -962,8 +962,7 @@ FILE *get_preset_file(char *filename, size_t filename_size,
datadir, desired_size, sizeof *datadir);
if (new_datadir) {
datadir = new_datadir;
datadir[datadir_len] = 0;
strncat(datadir, "/ffpresets", desired_size - 1 - datadir_len);
strcpy(datadir + datadir_len, "/ffpresets");
base[2] = datadir;
}
}
@@ -1350,6 +1349,77 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
return ret;
}
unsigned stream_group_specifier_match(const StreamSpecifier *ss,
const AVFormatContext *s, const AVStreamGroup *stg,
void *logctx)
{
int start_stream_group = 0, nb_stream_groups;
int nb_matched = 0;
if (ss->idx >= 0)
return 0;
switch (ss->stream_list) {
case STREAM_LIST_STREAM_ID:
case STREAM_LIST_ALL:
case STREAM_LIST_PROGRAM:
return 0;
case STREAM_LIST_GROUP_ID:
// <n-th> stream with given ID makes no sense and should be impossible to request
av_assert0(ss->idx < 0);
// return early if we know for sure the stream does not match
if (stg->id != ss->list_id)
return 0;
start_stream_group = stg->index;
nb_stream_groups = stg->index + 1;
break;
case STREAM_LIST_GROUP_IDX:
start_stream_group = ss->list_id >= 0 ? 0 : stg->index;
nb_stream_groups = stg->index + 1;
break;
default: av_assert0(0);
}
for (int i = start_stream_group; i < nb_stream_groups; i++) {
const AVStreamGroup *candidate = s->stream_groups[i];
if (ss->meta_key) {
const AVDictionaryEntry *tag = av_dict_get(candidate->metadata,
ss->meta_key, NULL, 0);
if (!tag)
continue;
if (ss->meta_val && strcmp(tag->value, ss->meta_val))
continue;
}
if (ss->usable_only) {
switch (candidate->type) {
case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
const AVStreamGroupTileGrid *tg = candidate->params.tile_grid;
if (!tg->coded_width || !tg->coded_height || !tg->nb_tiles ||
!tg->width || !tg->height || !tg->nb_tiles)
continue;
break;
}
default:
continue;
}
}
if (ss->disposition &&
(candidate->disposition & ss->disposition) != ss->disposition)
continue;
if (stg == candidate)
return ss->list_id < 0 || ss->list_id == nb_matched;
nb_matched++;
}
return 0;
}
int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id,
AVFormatContext *s, AVStream *st, const AVCodec *codec,
AVDictionary **dst, AVDictionary **opts_used)
@@ -1498,7 +1568,7 @@ double get_rotation(const int32_t *displaymatrix)
}
/* read file contents into a string */
char *file_read(const char *filename)
char *read_file_to_string(const char *filename)
{
AVIOContext *pb = NULL;
int ret = avio_open(&pb, filename, AVIO_FLAG_READ);
@@ -1542,3 +1612,28 @@ int check_avoptions(AVDictionary *m)
return 0;
}
void dump_dictionary(void *ctx, const AVDictionary *m,
const char *name, const char *indent,
int log_level)
{
const AVDictionaryEntry *tag = NULL;
if (!m)
return;
av_log(ctx, log_level, "%s%s:\n", indent, name);
while ((tag = av_dict_iterate(m, tag))) {
const char *p = tag->value;
av_log(ctx, log_level, "%s %-16s: ", indent, tag->key);
while (*p) {
size_t len = strcspn(p, "\x8\xa\xb\xc\xd");
av_log(ctx, log_level, "%.*s", (int)(FFMIN(255, len)), p);
p += len;
if (*p == 0xd) av_log(ctx, log_level, " ");
if (*p == 0xa) av_log(ctx, log_level, "\n%s %-16s: ", indent, "");
if (*p) p++;
}
av_log(ctx, log_level, "\n");
}
}
+13 -1
View File
@@ -158,6 +158,10 @@ unsigned stream_specifier_match(const StreamSpecifier *ss,
const AVFormatContext *s, const AVStream *st,
void *logctx);
unsigned stream_group_specifier_match(const StreamSpecifier *ss,
const AVFormatContext *s, const AVStreamGroup *stg,
void *logctx);
void stream_specifier_uninit(StreamSpecifier *ss);
typedef struct SpecifierOpt {
@@ -535,7 +539,7 @@ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
double get_rotation(const int32_t *displaymatrix);
/* read file contents into a string */
char *file_read(const char *filename);
char *read_file_to_string(const char *filename);
/* Remove keys in dictionary b from dictionary a */
void remove_avoptions(AVDictionary **a, AVDictionary *b);
@@ -545,4 +549,12 @@ int check_avoptions(AVDictionary *m);
int cmdutils_isalnum(char c);
/**
* This does the same as libavformat/dump.c corresponding function
* and should probably be kept in sync when the other one changes.
*/
void dump_dictionary(void *ctx, const AVDictionary *m,
const char *name, const char *indent,
int log_level);
#endif /* FFTOOLS_CMDUTILS_H */
+25 -4
View File
@@ -78,6 +78,9 @@
#include "libavdevice/avdevice.h"
#include "cmdutils.h"
#if CONFIG_MEDIACODEC
#include "compat/android/binder.h"
#endif
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "ffmpeg_utils.h"
@@ -250,7 +253,7 @@ void term_init(void)
/* read a key without blocking */
static int read_key(void)
{
unsigned char ch;
unsigned char ch = -1;
#if HAVE_TERMIOS_H
int n = 1;
struct timeval tv;
@@ -297,7 +300,7 @@ static int read_key(void)
if(kbhit())
return(getch());
#endif
return -1;
return ch;
}
static int decode_interrupt_cb(void *ctx)
@@ -400,6 +403,7 @@ static void frame_data_free(void *opaque, uint8_t *data)
{
FrameData *fd = (FrameData *)data;
av_frame_side_data_free(&fd->side_data, &fd->nb_side_data);
avcodec_parameters_free(&fd->par_enc);
av_free(data);
@@ -429,6 +433,8 @@ static int frame_data_ensure(AVBufferRef **dst, int writable)
memcpy(fd, fd_src, sizeof(*fd));
fd->par_enc = NULL;
fd->side_data = NULL;
fd->nb_side_data = 0;
if (fd_src->par_enc) {
int ret = 0;
@@ -444,6 +450,16 @@ static int frame_data_ensure(AVBufferRef **dst, int writable)
}
}
if (fd_src->nb_side_data) {
int ret = clone_side_data(&fd->side_data, &fd->nb_side_data,
fd_src->side_data, fd_src->nb_side_data, 0);
if (ret < 0) {
av_buffer_unref(dst);
av_buffer_unref(&src);
return ret;
}
}
av_buffer_unref(&src);
} else {
fd->dec.frame_num = UINT64_MAX;
@@ -806,8 +822,6 @@ static int check_keyboard_interaction(int64_t cur_time)
{
int i, key;
static int64_t last_time;
if (received_nb_signals)
return AVERROR_EXIT;
/* read_key() returns 0 on EOF */
if (cur_time - last_time >= 100000) {
key = read_key();
@@ -891,6 +905,9 @@ static int transcode(Scheduler *sch)
while (!sch_wait(sch, stats_period, &transcode_ts)) {
int64_t cur_time= av_gettime_relative();
if (received_nb_signals)
break;
/* if 'q' pressed, exits */
if (stdin_interaction)
if (check_keyboard_interaction(cur_time) < 0)
@@ -1005,6 +1022,10 @@ int main(int argc, char **argv)
goto finish;
}
#if CONFIG_MEDIACODEC
android_binder_threadpool_init_if_required();
#endif
current_time = ti = get_benchmark_time_stamps();
ret = transcode(sch);
if (ret >= 0 && do_benchmark) {
+59 -5
View File
@@ -136,6 +136,7 @@ typedef struct StreamMap {
int disabled; /* 1 is this mapping is disabled by a negative map */
int file_index;
int stream_index;
int group_index;
char *linklabel; /* name of an output link, for mapping lavfi outputs */
ViewSpecifier vs;
@@ -257,6 +258,8 @@ typedef struct OptionsContext {
SpecifierOptList enc_stats_pre_fmt;
SpecifierOptList enc_stats_post_fmt;
SpecifierOptList mux_stats_fmt;
int depth;
} OptionsContext;
enum IFilterFlags {
@@ -299,6 +302,8 @@ enum OFilterFlags {
// produce 24-bit audio
OFILTER_FLAG_AUDIO_24BIT = (1 << 1),
OFILTER_FLAG_AUTOSCALE = (1 << 2),
OFILTER_FLAG_AUTOROTATE = (1 << 3),
OFILTER_FLAG_CROP = (1 << 4),
};
typedef struct OutputFilterOptions {
@@ -330,6 +335,12 @@ typedef struct OutputFilterOptions {
int height;
enum AVColorSpace color_space;
enum AVColorRange color_range;
enum AVAlphaMode alpha_mode;
unsigned crop_top;
unsigned crop_bottom;
unsigned crop_left;
unsigned crop_right;
enum VideoSyncMethod vsync_method;
AVRational frame_rate;
@@ -338,12 +349,19 @@ typedef struct OutputFilterOptions {
int sample_rate;
AVChannelLayout ch_layout;
const int *formats;
union {
const enum AVPixelFormat *pix_fmts;
const enum AVSampleFormat *sample_fmts;
};
const int *sample_rates;
const AVChannelLayout *ch_layouts;
const AVRational *frame_rates;
const enum AVColorSpace *color_spaces;
const enum AVColorRange *color_ranges;
const enum AVAlphaMode *alpha_modes;
AVFrameSideData **side_data;
int nb_side_data;
// for simple filtergraphs only, view specifier passed
// along to the decoder
@@ -400,6 +418,11 @@ typedef struct FilterGraph {
OutputFilter **outputs;
int nb_outputs;
// true when the filtergraph is created internally for
// purposes like stream group merging. Meant to be freed
// if unbound.
int is_internal;
const char *graph_desc;
struct AVBPrint graph_print_buf;
} FilterGraph;
@@ -489,6 +512,18 @@ typedef struct InputStream {
int nb_filters;
} InputStream;
typedef struct InputStreamGroup {
const AVClass *class;
/* parent source */
struct InputFile *file;
int index;
FilterGraph *fg;
AVStreamGroup *stg;
} InputStreamGroup;
typedef struct InputFile {
const AVClass *class;
@@ -510,6 +545,10 @@ typedef struct InputFile {
* if new streams appear dynamically during demuxing */
InputStream **streams;
int nb_streams;
/* stream groups that ffmpeg is aware of; */
InputStreamGroup **stream_groups;
int nb_stream_groups;
} InputFile;
enum forced_keyframes_const {
@@ -568,6 +607,8 @@ enum {
#if FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP
KF_FORCE_SOURCE_NO_DROP = 2,
#endif
// force keyframe if lavfi.scd.time metadata is set
KF_FORCE_SCD_METADATA = 3,
};
typedef struct KeyframeForceCtx {
@@ -696,6 +737,9 @@ typedef struct FrameData {
int64_t wallclock[LATENCY_PROBE_NB];
AVCodecParameters *par_enc;
AVFrameSideData **side_data;
int nb_side_data;
} FrameData;
extern InputFile **input_files;
@@ -769,12 +813,12 @@ int check_avoptions_used(const AVDictionary *opts, const AVDictionary *opts_used
int assert_file_overwrite(const char *filename);
int find_codec(void *logctx, const char *name,
enum AVMediaType type, int encoder, const AVCodec **codec);
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
int parse_and_set_vsync(const char *arg, enum VideoSyncMethod *vsync_var, int file_idx, int st_idx, int is_global);
int filtergraph_is_simple(const FilterGraph *fg);
int fg_create_simple(FilterGraph **pfg,
InputStream *ist,
char *graph_desc,
char **graph_desc,
Scheduler *sch, unsigned sched_idx_enc,
const OutputFilterOptions *opts);
int fg_finalise_bindings(void);
@@ -797,10 +841,11 @@ int ofilter_bind_enc(OutputFilter *ofilter,
/**
* Create a new filtergraph in the global filtergraph list.
*
* @param graph_desc Graph description; an av_malloc()ed string, filtergraph
* @param graph_desc Pointer to graph description; an av_malloc()ed string, filtergraph
* takes ownership of it.
*/
int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch);
int fg_create(FilterGraph **pfg, char **graph_desc, Scheduler *sch,
const OutputFilterOptions *opts);
void fg_free(FilterGraph **pfg);
@@ -927,6 +972,15 @@ void opt_match_per_stream_int64(void *logctx, const SpecifierOptList *sol,
void opt_match_per_stream_dbl(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStream *st, double *out);
void opt_match_per_stream_group_str(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg, const char **out);
void opt_match_per_stream_group_int(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg, int *out);
void opt_match_per_stream_group_int64(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg, int64_t *out);
void opt_match_per_stream_group_dbl(void *logctx, const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg, double *out);
int view_specifier_parse(const char **pspec, ViewSpecifier *vs);
int muxer_thread(void *arg);
+7 -2
View File
@@ -744,11 +744,14 @@ static int packet_decode(DecoderPriv *dp, AVPacket *pkt, AVFrame *frame)
while (1) {
FrameData *fd;
unsigned outputs_mask = 1;
unsigned flags = 0;
if (!dp->dec.frames_decoded)
flags |= AV_CODEC_RECEIVE_FRAME_FLAG_SYNCHRONOUS;
av_frame_unref(frame);
update_benchmark(NULL);
ret = avcodec_receive_frame(dec, frame);
ret = avcodec_receive_frame_flags(dec, frame, flags);
update_benchmark("decode_%s %s", type_desc, dp->parent_name);
if (ret == AVERROR(EAGAIN)) {
@@ -1007,7 +1010,7 @@ static int decoder_thread(void *arg)
ret = 0;
err_rate = (dp->dec.frames_decoded || dp->dec.decode_errors) ?
dp->dec.decode_errors / (dp->dec.frames_decoded + dp->dec.decode_errors) : 0.f;
(float)dp->dec.decode_errors / (dp->dec.frames_decoded + dp->dec.decode_errors) : 0.f;
if (err_rate > max_error_rate) {
av_log(dp, AV_LOG_FATAL, "Decode error rate %g exceeds maximum %g\n",
err_rate, max_error_rate);
@@ -1018,6 +1021,7 @@ static int decoder_thread(void *arg)
finish:
dec_thread_uninit(&dt);
avcodec_free_context(&dp->dec_ctx);
return ret;
}
@@ -1635,6 +1639,7 @@ static int dec_open(DecoderPriv *dp, AVDictionary **dec_opts,
param_out->sample_aspect_ratio = dp->dec_ctx->sample_aspect_ratio;
param_out->colorspace = dp->dec_ctx->colorspace;
param_out->color_range = dp->dec_ctx->color_range;
param_out->alpha_mode = dp->dec_ctx->alpha_mode;
}
av_frame_side_data_free(&param_out->side_data, &param_out->nb_side_data);
+243 -3
View File
@@ -67,6 +67,7 @@ typedef struct DemuxStream {
int reinit_filters;
int autorotate;
int apply_cropping;
int force_display_matrix;
int drop_changed;
@@ -103,6 +104,13 @@ typedef struct DemuxStream {
int64_t lag;
} DemuxStream;
typedef struct DemuxStreamGroup {
InputStreamGroup istg;
// name used for logging
char log_name[32];
} DemuxStreamGroup;
typedef struct Demuxer {
InputFile f;
@@ -517,7 +525,10 @@ static void readrate_sleep(Demuxer *d)
pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE);
now = av_gettime_relative();
wc_elapsed = now - d->wallclock_start;
max_pts = stream_ts_offset + initial_burst + wc_elapsed * d->readrate;
if (pts <= stream_ts_offset + initial_burst) continue;
max_pts = stream_ts_offset + initial_burst + (int64_t)(wc_elapsed * d->readrate);
lag = FFMAX(max_pts - pts, 0);
if ( (!ds->lag && lag > 0.3 * AV_TIME_BASE) || ( lag > ds->lag + 0.3 * AV_TIME_BASE) ) {
ds->lag = lag;
@@ -531,7 +542,7 @@ static void readrate_sleep(Demuxer *d)
ds->lag = ds->resume_wc = ds->resume_pts = 0;
if (ds->resume_wc) {
elapsed = now - ds->resume_wc;
limit_pts = ds->resume_pts + elapsed * d->readrate_catchup;
limit_pts = ds->resume_pts + (int64_t)(elapsed * d->readrate_catchup);
} else {
elapsed = wc_elapsed;
limit_pts = max_pts;
@@ -885,6 +896,16 @@ static void ist_free(InputStream **pist)
av_freep(pist);
}
static void istg_free(InputStreamGroup **pistg)
{
InputStreamGroup *istg = *pistg;
if (!istg)
return;
av_freep(pistg);
}
void ifile_close(InputFile **pf)
{
InputFile *f = *pf;
@@ -900,6 +921,10 @@ void ifile_close(InputFile **pf)
ist_free(&f->streams[i]);
av_freep(&f->streams);
for (int i = 0; i < f->nb_stream_groups; i++)
istg_free(&f->stream_groups[i]);
av_freep(&f->stream_groups);
avformat_close_input(&f->ctx);
av_packet_free(&d->pkt_heartbeat);
@@ -1183,6 +1208,7 @@ static int add_display_matrix_to_stream(const OptionsContext *o,
AVFormatContext *ctx, InputStream *ist)
{
AVStream *st = ist->st;
DemuxStream *ds = ds_from_ist(ist);
AVPacketSideData *sd;
double rotation = DBL_MAX;
int hflip = -1, vflip = -1;
@@ -1217,6 +1243,8 @@ static int add_display_matrix_to_stream(const OptionsContext *o,
hflip_set ? hflip : 0,
vflip_set ? vflip : 0);
ds->force_display_matrix = 1;
return 0;
}
@@ -1455,6 +1483,15 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
av_dict_set_int(&ds->decoder_opts, "apply_cropping",
ds->apply_cropping && ds->apply_cropping != CROP_CONTAINER, 0);
if (ds->force_display_matrix) {
char buf[32];
if (av_dict_get(ds->decoder_opts, "side_data_prefer_packet", NULL, 0))
buf[0] = ',';
else
buf[0] = '\0';
av_strlcat(buf, "displaymatrix", sizeof(buf));
av_dict_set(&ds->decoder_opts, "side_data_prefer_packet", buf, AV_DICT_APPEND);
}
/* Attached pics are sparse, therefore we would not want to delay their decoding
* till EOF. */
if (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC)
@@ -1573,6 +1610,194 @@ static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st, AVDictiona
return 0;
}
static const char *input_stream_group_item_name(void *obj)
{
const DemuxStreamGroup *dsg = obj;
return dsg->log_name;
}
static const AVClass input_stream_group_class = {
.class_name = "InputStreamGroup",
.version = LIBAVUTIL_VERSION_INT,
.item_name = input_stream_group_item_name,
.category = AV_CLASS_CATEGORY_DEMUXER,
};
static DemuxStreamGroup *demux_stream_group_alloc(Demuxer *d, AVStreamGroup *stg)
{
InputFile *f = &d->f;
DemuxStreamGroup *dsg;
dsg = allocate_array_elem(&f->stream_groups, sizeof(*dsg), &f->nb_stream_groups);
if (!dsg)
return NULL;
dsg->istg.stg = stg;
dsg->istg.file = f;
dsg->istg.index = stg->index;
dsg->istg.class = &input_stream_group_class;
snprintf(dsg->log_name, sizeof(dsg->log_name), "istg#%d:%d/%s",
d->f.index, stg->index, avformat_stream_group_name(stg->type));
return dsg;
}
static int istg_parse_tile_grid(const OptionsContext *o, Demuxer *d, InputStreamGroup *istg)
{
InputFile *f = &d->f;
AVFormatContext *ic = d->f.ctx;
AVStreamGroup *stg = istg->stg;
const AVStreamGroupTileGrid *tg = stg->params.tile_grid;
OutputFilterOptions opts;
AVBPrint bp;
char *graph_str;
int autorotate = 1;
const char *apply_cropping = NULL;
int ret;
if (tg->nb_tiles == 1)
return 0;
memset(&opts, 0, sizeof(opts));
opt_match_per_stream_group_int(istg, &o->autorotate, ic, stg, &autorotate);
if (autorotate)
opts.flags |= OFILTER_FLAG_AUTOROTATE;
opts.flags |= OFILTER_FLAG_CROP;
opt_match_per_stream_group_str(istg, &o->apply_cropping, ic, stg, &apply_cropping);
if (apply_cropping) {
char *p;
int crop = strtol(apply_cropping, &p, 0);
if (*p)
return AVERROR(EINVAL);
if (!crop)
opts.flags &= ~OFILTER_FLAG_CROP;
}
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
for (int i = 0; i < tg->nb_tiles; i++)
av_bprintf(&bp, "[%d:g:%d:%d]", f->index, stg->index, tg->offsets[i].idx);
av_bprintf(&bp, "xstack=inputs=%d:layout=", tg->nb_tiles);
for (int i = 0; i < tg->nb_tiles - 1; i++)
av_bprintf(&bp, "%d_%d|", tg->offsets[i].horizontal,
tg->offsets[i].vertical);
av_bprintf(&bp, "%d_%d:fill=0x%02X%02X%02X@0x%02X", tg->offsets[tg->nb_tiles - 1].horizontal,
tg->offsets[tg->nb_tiles - 1].vertical,
tg->background[0], tg->background[1],
tg->background[2], tg->background[3]);
av_bprintf(&bp, "[%d:g:%d]", f->index, stg->index);
ret = av_bprint_finalize(&bp, &graph_str);
if (ret < 0)
return ret;
if (tg->coded_width != tg->width || tg->coded_height != tg->height) {
opts.crop_top = tg->vertical_offset;
opts.crop_bottom = tg->coded_height - tg->height - tg->vertical_offset;
opts.crop_left = tg->horizontal_offset;
opts.crop_right = tg->coded_width - tg->width - tg->horizontal_offset;
}
for (int i = 0; i < tg->nb_coded_side_data; i++) {
const AVPacketSideData *sd = &tg->coded_side_data[i];
ret = av_packet_side_data_to_frame(&opts.side_data, &opts.nb_side_data, sd, 0);
if (ret < 0 && ret != AVERROR(EINVAL))
goto fail;
}
ret = fg_create(NULL, &graph_str, d->sch, &opts);
if (ret < 0)
goto fail;
istg->fg = filtergraphs[nb_filtergraphs-1];
istg->fg->is_internal = 1;
ret = 0;
fail:
if (ret < 0)
av_freep(&graph_str);
return ret;
}
static int istg_add(const OptionsContext *o, Demuxer *d, AVStreamGroup *stg)
{
DemuxStreamGroup *dsg;
InputStreamGroup *istg;
int ret;
dsg = demux_stream_group_alloc(d, stg);
if (!dsg)
return AVERROR(ENOMEM);
istg = &dsg->istg;
switch (stg->type) {
case AV_STREAM_GROUP_PARAMS_TILE_GRID:
ret = istg_parse_tile_grid(o, d, istg);
if (ret < 0)
return ret;
break;
default:
break;
}
return 0;
}
static int is_windows_reserved_device_name(const char *f)
{
#if HAVE_DOS_PATHS
for (const char *p = f; p && *p; ) {
char stem[6], *s;
av_strlcpy(stem, p, sizeof(stem));
if ((s = strchr(stem, '.')))
*s = 0;
if ((s = strpbrk(stem, "123456789")))
*s = '1';
if( !av_strcasecmp(stem, "AUX") ||
!av_strcasecmp(stem, "CON") ||
!av_strcasecmp(stem, "NUL") ||
!av_strcasecmp(stem, "PRN") ||
!av_strcasecmp(stem, "COM1") ||
!av_strcasecmp(stem, "LPT1")
)
return 1;
p = strchr(p, '/');
if (p)
p++;
}
#endif
return 0;
}
static int safe_filename(const char *f, int allow_subdir)
{
const char *start = f;
if (!*f || is_windows_reserved_device_name(f))
return 0;
for (; *f; f++) {
/* A-Za-z0-9_- */
if (!((unsigned)((*f | 32) - 'a') < 26 ||
(unsigned)(*f - '0') < 10 || *f == '_' || *f == '-')) {
if (f == start)
return 0;
else if (allow_subdir && *f == '/')
start = f + 1;
else if (*f != '.')
return 0;
}
}
return 1;
}
static int dump_attachment(InputStream *ist, const char *filename)
{
AVStream *st = ist->st;
@@ -1584,8 +1809,13 @@ static int dump_attachment(InputStream *ist, const char *filename)
av_log(ist, AV_LOG_WARNING, "No extradata to dump.\n");
return 0;
}
if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0)))
if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) {
filename = e->value;
if (!safe_filename(filename, 0)) {
av_log(ist, AV_LOG_ERROR, "Filename %s is unsafe\n", filename);
return AVERROR(EINVAL);
}
}
if (!*filename) {
av_log(ist, AV_LOG_FATAL, "No filename specified and no 'filename' tag");
return AVERROR(EINVAL);
@@ -1704,6 +1934,7 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
ic = avformat_alloc_context();
if (!ic)
return AVERROR(ENOMEM);
ic->name = av_strdup(d->log_name);
if (o->audio_sample_rate.nb_opt) {
av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate.opt[o->audio_sample_rate.nb_opt - 1].u.i, 0);
}
@@ -1792,6 +2023,8 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
av_strlcat(d->log_name, "/", sizeof(d->log_name));
av_strlcat(d->log_name, ic->iformat->name, sizeof(d->log_name));
av_freep(&ic->name);
ic->name = av_strdup(d->log_name);
if (scan_all_pmts_set)
av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
@@ -1941,6 +2174,13 @@ int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
}
}
/* Add all the stream groups from the given input file to the demuxer */
for (int i = 0; i < ic->nb_stream_groups; i++) {
ret = istg_add(o, d, ic->stream_groups[i]);
if (ret < 0)
return ret;
}
/* dump the file content */
av_dump_format(ic, f->index, filename, 0);
+25 -15
View File
@@ -205,19 +205,10 @@ int enc_open(void *opaque, const AVFrame *frame)
av_assert0(frame->opaque_ref);
fd = (FrameData*)frame->opaque_ref->data;
for (int i = 0; i < frame->nb_side_data; i++) {
const AVSideDataDescriptor *desc = av_frame_side_data_desc(frame->side_data[i]->type);
if (!(desc->props & AV_SIDE_DATA_PROP_GLOBAL))
continue;
ret = av_frame_side_data_clone(&enc_ctx->decoded_side_data,
&enc_ctx->nb_decoded_side_data,
frame->side_data[i],
AV_FRAME_SIDE_DATA_FLAG_UNIQUE);
if (ret < 0)
return ret;
}
ret = clone_side_data(&enc_ctx->decoded_side_data, &enc_ctx->nb_decoded_side_data,
fd->side_data, fd->nb_side_data, AV_FRAME_SIDE_DATA_FLAG_UNIQUE);
if (ret < 0)
return ret;
}
if (ist)
@@ -266,11 +257,27 @@ int enc_open(void *opaque, const AVFrame *frame)
enc_ctx->bits_per_raw_sample = FFMIN(fd->bits_per_raw_sample,
av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
/**
* The video color properties should always be in sync with the user-
* requested values, since we forward them to the filter graph.
*/
enc_ctx->color_range = frame->color_range;
enc_ctx->color_primaries = frame->color_primaries;
enc_ctx->color_trc = frame->color_trc;
enc_ctx->colorspace = frame->colorspace;
enc_ctx->chroma_sample_location = frame->chroma_location;
enc_ctx->alpha_mode = frame->alpha_mode;
/* Video properties which are not part of filter graph negotiation */
if (enc_ctx->chroma_sample_location == AVCHROMA_LOC_UNSPECIFIED) {
enc_ctx->chroma_sample_location = frame->chroma_location;
} else if (enc_ctx->chroma_sample_location != frame->chroma_location &&
frame->chroma_location != AVCHROMA_LOC_UNSPECIFIED) {
av_log(e, AV_LOG_WARNING,
"Requested chroma sample location '%s' does not match the "
"frame tagged sample location '%s'; result may be incorrect.\n",
av_chroma_location_name(enc_ctx->chroma_sample_location),
av_chroma_location_name(frame->chroma_location));
}
if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) ||
(frame->flags & AV_FRAME_FLAG_INTERLACED)
@@ -721,7 +728,7 @@ static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame,
}
}
av_assert0(0);
av_unreachable("encode_frame() loop should return");
}
static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf,
@@ -761,6 +768,9 @@ static enum AVPictureType forced_kf_apply(void *logctx, KeyframeForceCtx *kf,
}
} else if (kf->type == KF_FORCE_SOURCE && (frame->flags & AV_FRAME_FLAG_KEY)) {
goto force_keyframe;
} else if (kf->type == KF_FORCE_SCD_METADATA &&
av_dict_get(frame->metadata, "lavfi.scd.time", NULL, 0)) {
goto force_keyframe;
}
return AV_PICTURE_TYPE_NONE;
+307 -64
View File
@@ -40,9 +40,6 @@
#include "libavutil/time.h"
#include "libavutil/timestamp.h"
// FIXME private header, used for mid_pred()
#include "libavcodec/mathops.h"
typedef struct FilterGraphPriv {
FilterGraph fg;
@@ -109,6 +106,9 @@ typedef struct InputFilterPriv {
// used to hold submitted input
AVFrame *frame;
// For inputs bound to a filtergraph output
OutputFilter *ofilter_src;
// source data type: AVMEDIA_TYPE_SUBTITLE for sub2video,
// same as type otherwise
enum AVMediaType type_src;
@@ -125,6 +125,7 @@ typedef struct InputFilterPriv {
AVRational sample_aspect_ratio;
enum AVColorSpace color_space;
enum AVColorRange color_range;
enum AVAlphaMode alpha_mode;
int sample_rate;
AVChannelLayout ch_layout;
@@ -189,6 +190,8 @@ typedef struct OutputFilterPriv {
void *log_parent;
char log_name[32];
int needed;
/* desired output stream properties */
int format;
int width, height;
@@ -196,6 +199,12 @@ typedef struct OutputFilterPriv {
AVChannelLayout ch_layout;
enum AVColorSpace color_space;
enum AVColorRange color_range;
enum AVAlphaMode alpha_mode;
unsigned crop_top;
unsigned crop_bottom;
unsigned crop_left;
unsigned crop_right;
AVFrameSideData **side_data;
int nb_side_data;
@@ -214,11 +223,17 @@ typedef struct OutputFilterPriv {
// those are only set if no format is specified and the encoder gives us multiple options
// They point directly to the relevant lists of the encoder.
const int *formats;
union {
const enum AVPixelFormat *pix_fmts;
const enum AVSampleFormat *sample_fmts;
};
const AVChannelLayout *ch_layouts;
const int *sample_rates;
const enum AVColorSpace *color_spaces;
const enum AVColorRange *color_ranges;
const enum AVAlphaMode *alpha_modes;
int32_t displaymatrix[9];
AVRational enc_timebase;
int64_t trim_start_us;
@@ -268,6 +283,7 @@ static int sub2video_get_blank_frame(InputFilterPriv *ifp)
frame->format = ifp->format;
frame->colorspace = ifp->color_space;
frame->color_range = ifp->color_range;
frame->alpha_mode = ifp->alpha_mode;
ret = av_frame_get_buffer(frame, 0);
if (ret < 0)
@@ -386,10 +402,10 @@ static void choose_ ## name (OutputFilterPriv *ofp, AVBPrint *bprint) \
av_bprint_chars(bprint, ':', 1); \
}
DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, formats,
DEF_CHOOSE_FORMAT(pix_fmts, enum AVPixelFormat, format, pix_fmts,
AV_PIX_FMT_NONE, "%s", av_get_pix_fmt_name)
DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats,
DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, sample_fmts,
AV_SAMPLE_FMT_NONE, "%s", av_get_sample_fmt_name)
DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0,
@@ -401,6 +417,9 @@ DEF_CHOOSE_FORMAT(color_spaces, enum AVColorSpace, color_space, color_spaces,
DEF_CHOOSE_FORMAT(color_ranges, enum AVColorRange, color_range, color_ranges,
AVCOL_RANGE_UNSPECIFIED, "%s", av_color_range_name);
DEF_CHOOSE_FORMAT(alpha_modes, enum AVAlphaMode, alpha_mode, alpha_modes,
AVALPHA_MODE_UNSPECIFIED, "%s", av_alpha_mode_name);
static void choose_channel_layouts(OutputFilterPriv *ofp, AVBPrint *bprint)
{
if (av_channel_layout_check(&ofp->ch_layout)) {
@@ -500,7 +519,7 @@ static int filter_opt_apply(void *logctx, AVFilterContext *f,
ret = av_opt_set_bin(f, key, data, len, AV_OPT_SEARCH_CHILDREN);
av_freep(&data);
} else {
char *data = file_read(val);
char *data = read_file_to_string(val);
if (!data) {
ret = AVERROR(EIO);
goto err_load;
@@ -650,6 +669,7 @@ static OutputFilter *ofilter_alloc(FilterGraph *fg, enum AVMediaType type)
ofp->format = -1;
ofp->color_space = AVCOL_SPC_UNSPECIFIED;
ofp->color_range = AVCOL_RANGE_UNSPECIFIED;
ofp->alpha_mode = AVALPHA_MODE_UNSPECIFIED;
ofilter->index = fg->nb_outputs - 1;
snprintf(ofp->log_name, sizeof(ofp->log_name), "%co%d",
@@ -802,10 +822,10 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
av_assert0(!opts->enc ||
ofilter->type == opts->enc->type);
ofilter->bound = 1;
ofp->needed = ofilter->bound = 1;
av_freep(&ofilter->linklabel);
ofp->flags = opts->flags;
ofp->flags |= opts->flags;
ofp->ts_offset = opts->ts_offset;
ofp->enc_timebase = opts->output_tb;
@@ -842,7 +862,7 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
if (opts->format != AV_PIX_FMT_NONE) {
ofp->format = opts->format;
} else
ofp->formats = opts->formats;
ofp->pix_fmts = opts->pix_fmts;
if (opts->color_space != AVCOL_SPC_UNSPECIFIED)
ofp->color_space = opts->color_space;
@@ -854,6 +874,11 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
else
ofp->color_ranges = opts->color_ranges;
if (opts->alpha_mode != AVALPHA_MODE_UNSPECIFIED)
ofp->alpha_mode = opts->alpha_mode;
else
ofp->alpha_modes = opts->alpha_modes;
fgp->disable_conversions |= !!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT);
ofp->fps.last_frame = av_frame_alloc();
@@ -876,7 +901,7 @@ int ofilter_bind_enc(OutputFilter *ofilter, unsigned sched_idx_enc,
if (opts->format != AV_SAMPLE_FMT_NONE) {
ofp->format = opts->format;
} else {
ofp->formats = opts->formats;
ofp->sample_fmts = opts->sample_fmts;
}
if (opts->sample_rate) {
ofp->sample_rate = opts->sample_rate;
@@ -908,13 +933,15 @@ static int ofilter_bind_ifilter(OutputFilter *ofilter, InputFilterPriv *ifp,
av_assert0(!ofilter->bound);
av_assert0(ofilter->type == ifp->ifilter.type);
ofilter->bound = 1;
ofp->needed = ofilter->bound = 1;
av_freep(&ofilter->linklabel);
ofilter->output_name = av_strdup(opts->name);
if (!ofilter->output_name)
return AVERROR(EINVAL);
ifp->ofilter_src = ofilter;
av_strlcatf(ofp->log_name, sizeof(ofp->log_name), "->%s", ofilter->output_name);
return 0;
@@ -977,6 +1004,7 @@ static InputFilter *ifilter_alloc(FilterGraph *fg)
ifp->format = -1;
ifp->color_space = AVCOL_SPC_UNSPECIFIED;
ifp->color_range = AVCOL_RANGE_UNSPECIFIED;
ifp->alpha_mode = AVALPHA_MODE_UNSPECIFIED;
ifp->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
if (!ifp->frame_queue)
@@ -1057,7 +1085,8 @@ static const AVClass fg_class = {
.category = AV_CLASS_CATEGORY_FILTER,
};
int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
int fg_create(FilterGraph **pfg, char **graph_desc, Scheduler *sch,
const OutputFilterOptions *opts)
{
FilterGraphPriv *fgp;
FilterGraph *fg;
@@ -1068,7 +1097,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
fgp = av_mallocz(sizeof(*fgp));
if (!fgp) {
av_freep(&graph_desc);
av_freep(graph_desc);
return AVERROR(ENOMEM);
}
fg = &fgp->fg;
@@ -1079,7 +1108,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
} else {
ret = av_dynarray_add_nofree(&filtergraphs, &nb_filtergraphs, fgp);
if (ret < 0) {
av_freep(&graph_desc);
av_freep(graph_desc);
av_freep(&fgp);
return ret;
}
@@ -1088,11 +1117,13 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
}
fg->class = &fg_class;
fg->graph_desc = graph_desc;
fg->graph_desc = *graph_desc;
fgp->disable_conversions = !auto_conversion_filters;
fgp->nb_threads = -1;
fgp->sch = sch;
*graph_desc = NULL;
snprintf(fgp->log_name, sizeof(fgp->log_name), "fc#%d", fg->index);
fgp->frame = av_frame_alloc();
@@ -1154,11 +1185,13 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
const enum AVMediaType type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
cur->pad_idx);
OutputFilter *const ofilter = ofilter_alloc(fg, type);
OutputFilterPriv *ofp;
if (!ofilter) {
ret = AVERROR(ENOMEM);
goto fail;
}
ofp = ofp_from_ofilter(ofilter);
ofilter->linklabel = cur->name;
cur->name = NULL;
@@ -1168,6 +1201,25 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch)
ret = AVERROR(ENOMEM);
goto fail;
}
// opts should only be needed in this function to fill fields from filtergraphs
// whose output is meant to be treated as if it was stream, e.g. merged HEIF
// tile groups.
if (opts) {
ofp->flags = opts->flags;
ofp->side_data = opts->side_data;
ofp->nb_side_data = opts->nb_side_data;
ofp->crop_top = opts->crop_top;
ofp->crop_bottom = opts->crop_bottom;
ofp->crop_left = opts->crop_left;
ofp->crop_right = opts->crop_right;
const AVFrameSideData *sd = av_frame_side_data_get(ofp->side_data, ofp->nb_side_data,
AV_FRAME_DATA_DISPLAYMATRIX);
if (sd)
memcpy(ofp->displaymatrix, sd->data, sizeof(ofp->displaymatrix));
}
}
if (!fg->nb_outputs) {
@@ -1195,7 +1247,7 @@ fail:
int fg_create_simple(FilterGraph **pfg,
InputStream *ist,
char *graph_desc,
char **graph_desc,
Scheduler *sch, unsigned sched_idx_enc,
const OutputFilterOptions *opts)
{
@@ -1204,7 +1256,7 @@ int fg_create_simple(FilterGraph **pfg,
FilterGraphPriv *fgp;
int ret;
ret = fg_create(pfg, graph_desc, sch);
ret = fg_create(pfg, graph_desc, sch, NULL);
if (ret < 0)
return ret;
fg = *pfg;
@@ -1220,7 +1272,7 @@ int fg_create_simple(FilterGraph **pfg,
"to have exactly 1 input and 1 output. "
"However, it had %d input(s) and %d output(s). Please adjust, "
"or use a complex filtergraph (-filter_complex) instead.\n",
graph_desc, fg->nb_inputs, fg->nb_outputs);
*graph_desc, fg->nb_inputs, fg->nb_outputs);
return AVERROR(EINVAL);
}
if (fg->outputs[0]->type != type) {
@@ -1245,7 +1297,7 @@ int fg_create_simple(FilterGraph **pfg,
return 0;
}
static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter, int commit)
{
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
InputStream *ist = NULL;
@@ -1296,15 +1348,20 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
if (!ofilter->bound && ofilter->linklabel &&
!strcmp(ofilter->linklabel, ifilter->linklabel)) {
av_log(fg, AV_LOG_VERBOSE,
"Binding input with label '%s' to filtergraph output %d:%d\n",
ifilter->linklabel, i, j);
if (commit) {
av_log(fg, AV_LOG_VERBOSE,
"Binding input with label '%s' to filtergraph output %d:%d\n",
ifilter->linklabel, i, j);
ret = ifilter_bind_fg(ifp, fg_src, j);
if (ret < 0)
av_log(fg, AV_LOG_ERROR, "Error binding filtergraph input %s\n",
ifilter->linklabel);
return ret;
ret = ifilter_bind_fg(ifp, fg_src, j);
if (ret < 0) {
av_log(fg, AV_LOG_ERROR, "Error binding filtergraph input %s\n",
ifilter->linklabel);
return ret;
}
} else
ofp_from_ofilter(ofilter)->needed = 1;
return 0;
}
}
}
@@ -1352,10 +1409,38 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
}
ist = input_files[file_idx]->streams[st->index];
av_log(fg, AV_LOG_VERBOSE,
"Binding input with label '%s' to input stream %d:%d\n",
ifilter->linklabel, ist->file->index, ist->index);
if (commit)
av_log(fg, AV_LOG_VERBOSE,
"Binding input with label '%s' to input stream %d:%d\n",
ifilter->linklabel, ist->file->index, ist->index);
} else {
// try finding an unbound filtergraph output
for (int i = 0; i < nb_filtergraphs; i++) {
FilterGraph *fg_src = filtergraphs[i];
if (fg == fg_src)
continue;
for (int j = 0; j < fg_src->nb_outputs; j++) {
OutputFilter *ofilter = fg_src->outputs[j];
if (!ofilter->bound) {
if (commit) {
av_log(fg, AV_LOG_VERBOSE,
"Binding unlabeled filtergraph input to filtergraph output %d:%d\n", i, j);
ret = ifilter_bind_fg(ifp, fg_src, j);
if (ret < 0) {
av_log(fg, AV_LOG_ERROR, "Error binding filtergraph input %d:%d\n", i, j);
return ret;
}
} else
ofp_from_ofilter(ofilter)->needed = 1;
return 0;
}
}
}
ist = ist_find_unused(type);
if (!ist) {
av_log(fg, AV_LOG_FATAL,
@@ -1365,24 +1450,27 @@ static int fg_complex_bind_input(FilterGraph *fg, InputFilter *ifilter)
return AVERROR(EINVAL);
}
av_log(fg, AV_LOG_VERBOSE,
"Binding unlabeled input %d to input stream %d:%d\n",
ifilter->index, ist->file->index, ist->index);
if (commit)
av_log(fg, AV_LOG_VERBOSE,
"Binding unlabeled input %d to input stream %d:%d\n",
ifilter->index, ist->file->index, ist->index);
}
av_assert0(ist);
ret = ifilter_bind_ist(ifilter, ist, &vs);
if (ret < 0) {
av_log(fg, AV_LOG_ERROR,
"Error binding an input stream to complex filtergraph input %s.\n",
ifilter->name);
return ret;
if (commit) {
ret = ifilter_bind_ist(ifilter, ist, &vs);
if (ret < 0) {
av_log(fg, AV_LOG_ERROR,
"Error binding an input stream to complex filtergraph input %s.\n",
ifilter->name);
return ret;
}
}
return 0;
}
static int bind_inputs(FilterGraph *fg)
static int bind_inputs(FilterGraph *fg, int commit)
{
// bind filtergraph inputs to input streams or other filtergraphs
for (int i = 0; i < fg->nb_inputs; i++) {
@@ -1392,7 +1480,7 @@ static int bind_inputs(FilterGraph *fg)
if (ifp->bound)
continue;
ret = fg_complex_bind_input(fg, &ifp->ifilter);
ret = fg_complex_bind_input(fg, &ifp->ifilter, commit);
if (ret < 0)
return ret;
}
@@ -1405,27 +1493,49 @@ int fg_finalise_bindings(void)
int ret;
for (int i = 0; i < nb_filtergraphs; i++) {
ret = bind_inputs(filtergraphs[i]);
ret = bind_inputs(filtergraphs[i], 0);
if (ret < 0)
return ret;
}
// check that all outputs were bound
for (int i = 0; i < nb_filtergraphs; i++) {
for (int i = nb_filtergraphs - 1; i >= 0; i--) {
FilterGraph *fg = filtergraphs[i];
FilterGraphPriv *fgp = fgp_from_fg(filtergraphs[i]);
for (int j = 0; j < fg->nb_outputs; j++) {
OutputFilter *output = fg->outputs[j];
if (!output->bound) {
av_log(fg, AV_LOG_FATAL,
"Filter '%s' has output %d (%s) unconnected\n",
if (!ofp_from_ofilter(output)->needed) {
if (!fg->is_internal) {
av_log(fg, AV_LOG_FATAL,
"Filter '%s' has output %d (%s) unconnected\n",
output->name, j,
output->linklabel ? (const char *)output->linklabel : "unlabeled");
return AVERROR(EINVAL);
}
av_log(fg, AV_LOG_DEBUG,
"Internal filter '%s' has output %d (%s) unconnected. Removing graph\n",
output->name, j,
output->linklabel ? (const char *)output->linklabel : "unlabeled");
return AVERROR(EINVAL);
sch_remove_filtergraph(fgp->sch, fgp->sch_idx);
fg_free(&filtergraphs[i]);
nb_filtergraphs--;
if (nb_filtergraphs > 0)
memmove(&filtergraphs[i],
&filtergraphs[i + 1],
(nb_filtergraphs - i) * sizeof(*filtergraphs));
break;
}
}
}
for (int i = 0; i < nb_filtergraphs; i++) {
ret = bind_inputs(filtergraphs[i], 1);
if (ret < 0)
return ret;
}
return 0;
}
@@ -1524,6 +1634,53 @@ static int configure_output_video_filter(FilterGraphPriv *fgp, AVFilterGraph *gr
if (ret < 0)
return ret;
if (ofp->flags & OFILTER_FLAG_CROP) {
char crop_buf[64];
snprintf(crop_buf, sizeof(crop_buf), "w=iw-%u-%u:h=ih-%u-%u:x=%u:y=%u",
ofp->crop_left, ofp->crop_right,
ofp->crop_top, ofp->crop_bottom,
ofp->crop_left, ofp->crop_top);
ret = insert_filter(&last_filter, &pad_idx, "crop", crop_buf);
if (ret < 0)
return ret;
}
if (ofp->flags & OFILTER_FLAG_AUTOROTATE) {
int32_t *displaymatrix = ofp->displaymatrix;
double theta;
theta = get_rotation(displaymatrix);
if (fabs(theta - 90) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "transpose",
displaymatrix[3] > 0 ? "cclock_flip" : "clock");
} else if (fabs(theta - 180) < 1.0) {
if (displaymatrix[0] < 0) {
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
if (ret < 0)
return ret;
}
if (displaymatrix[4] < 0) {
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
}
} else if (fabs(theta - 270) < 1.0) {
ret = insert_filter(&last_filter, &pad_idx, "transpose",
displaymatrix[3] < 0 ? "clock_flip" : "cclock");
} else if (fabs(theta) > 1.0) {
char rotate_buf[64];
snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
} else if (fabs(theta) < 1.0) {
if (displaymatrix && displaymatrix[4] < 0) {
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
}
}
if (ret < 0)
return ret;
av_frame_side_data_remove(&ofp->side_data, &ofp->nb_side_data, AV_FRAME_DATA_DISPLAYMATRIX);
}
if ((ofp->width || ofp->height) && (ofp->flags & OFILTER_FLAG_AUTOSCALE)) {
char args[255];
AVFilterContext *filter;
@@ -1548,11 +1705,12 @@ static int configure_output_video_filter(FilterGraphPriv *fgp, AVFilterGraph *gr
}
av_assert0(!(ofp->flags & OFILTER_FLAG_DISABLE_CONVERT) ||
ofp->format != AV_PIX_FMT_NONE || !ofp->formats);
ofp->format != AV_PIX_FMT_NONE || !ofp->pix_fmts);
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
choose_pix_fmts(ofp, &bprint);
choose_color_spaces(ofp, &bprint);
choose_color_ranges(ofp, &bprint);
choose_alpha_modes(ofp, &bprint);
if (!av_bprint_is_complete(&bprint))
return AVERROR(ENOMEM);
@@ -1723,6 +1881,7 @@ static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
ifp->sample_aspect_ratio : (AVRational){ 0, 1 };
par->color_space = ifp->color_space;
par->color_range = ifp->color_range;
par->alpha_mode = ifp->alpha_mode;
par->hw_frames_ctx = ifp->hw_frames_ctx;
par->side_data = ifp->side_data;
par->nb_side_data = ifp->nb_side_data;
@@ -2000,6 +2159,7 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
ofp->height = av_buffersink_get_h(sink);
ofp->color_space = av_buffersink_get_colorspace(sink);
ofp->color_range = av_buffersink_get_color_range(sink);
ofp->alpha_mode = av_buffersink_get_alpha_mode(sink);
// If the timing parameters are not locked yet, get the tentative values
// here but don't lock them. They will only be used if no output frames
@@ -2018,12 +2178,11 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt)
ret = av_buffersink_get_ch_layout(sink, &ofp->ch_layout);
if (ret < 0)
goto fail;
av_frame_side_data_free(&ofp->side_data, &ofp->nb_side_data);
sd = av_buffersink_get_side_data(sink, &nb_sd);
if (nb_sd)
for (int j = 0; j < nb_sd; j++) {
ret = av_frame_side_data_clone(&ofp->side_data, &ofp->nb_side_data,
sd[j], 0);
sd[j], AV_FRAME_SIDE_DATA_FLAG_REPLACE);
if (ret < 0) {
av_frame_side_data_free(&ofp->side_data, &ofp->nb_side_data);
goto fail;
@@ -2096,6 +2255,7 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
ifp->sample_aspect_ratio = frame->sample_aspect_ratio;
ifp->color_space = frame->colorspace;
ifp->color_range = frame->color_range;
ifp->alpha_mode = frame->alpha_mode;
ifp->sample_rate = frame->sample_rate;
ret = av_channel_layout_copy(&ifp->ch_layout, &frame->ch_layout);
@@ -2106,7 +2266,8 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
for (int i = 0; i < frame->nb_side_data; i++) {
const AVSideDataDescriptor *desc = av_frame_side_data_desc(frame->side_data[i]->type);
if (!(desc->props & AV_SIDE_DATA_PROP_GLOBAL))
if (!(desc->props & AV_SIDE_DATA_PROP_GLOBAL) ||
frame->side_data[i]->type == AV_FRAME_DATA_DISPLAYMATRIX)
continue;
ret = av_frame_side_data_clone(&ifp->side_data,
@@ -2137,6 +2298,27 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
return 0;
}
static int ifilter_parameters_from_ofilter(InputFilter *ifilter, OutputFilter *ofilter)
{
const OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
if (!ifp->opts.framerate.num) {
ifp->opts.framerate = ofp->fps.framerate;
if (ifp->opts.framerate.num > 0 && ifp->opts.framerate.den > 0)
ifp->opts.flags |= IFILTER_FLAG_CFR;
}
for (int i = 0; i < ofp->nb_side_data; i++) {
int ret = av_frame_side_data_clone(&ifp->side_data, &ifp->nb_side_data,
ofp->side_data[i], AV_FRAME_SIDE_DATA_FLAG_REPLACE);
if (ret < 0)
return ret;
}
return 0;
}
int filtergraph_is_simple(const FilterGraph *fg)
{
const FilterGraphPriv *fgp = cfgp_from_cfg(fg);
@@ -2307,6 +2489,23 @@ early_exit:
return float_pts;
}
static int64_t median3(int64_t a, int64_t b, int64_t c)
{
int64_t max2, min2, m;
if (a >= b) {
max2 = a;
min2 = b;
} else {
max2 = b;
min2 = a;
}
m = (c >= max2) ? max2 : c;
return (m >= min2) ? m : min2;
}
/* Convert frame timestamps to the encoder timebase and decide how many times
* should this (and possibly previous) frame be repeated in order to conform to
* desired target framerate (if any).
@@ -2319,9 +2518,9 @@ static void video_sync_process(OutputFilterPriv *ofp, AVFrame *frame,
double delta0, delta, sync_ipts, duration;
if (!frame) {
*nb_frames_prev = *nb_frames = mid_pred(fps->frames_prev_hist[0],
fps->frames_prev_hist[1],
fps->frames_prev_hist[2]);
*nb_frames_prev = *nb_frames = median3(fps->frames_prev_hist[0],
fps->frames_prev_hist[1],
fps->frames_prev_hist[2]);
if (!*nb_frames && fps->last_dropped) {
atomic_fetch_add(&ofilter->nb_frames_drop, 1);
@@ -2434,6 +2633,16 @@ finish:
fps->dropped_keyframe |= fps->last_dropped && (frame->flags & AV_FRAME_FLAG_KEY);
}
static void close_input(InputFilterPriv *ifp)
{
FilterGraphPriv *fgp = fgp_from_fg(ifp->ifilter.graph);
if (!ifp->eof) {
sch_filter_receive_finish(fgp->sch, fgp->sch_idx, ifp->ifilter.index);
ifp->eof = 1;
}
}
static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt)
{
FilterGraphPriv *fgp = fgp_from_fg(ofp->ofilter.graph);
@@ -2458,16 +2667,17 @@ static int close_output(OutputFilterPriv *ofp, FilterGraphThread *fgt)
if (ret < 0)
return ret;
}
av_frame_side_data_free(&frame->side_data, &frame->nb_side_data);
ret = clone_side_data(&frame->side_data, &frame->nb_side_data,
ofp->side_data, ofp->nb_side_data, 0);
if (ret < 0)
return ret;
fd = frame_data(frame);
if (!fd)
return AVERROR(ENOMEM);
av_frame_side_data_free(&fd->side_data, &fd->nb_side_data);
ret = clone_side_data(&fd->side_data, &fd->nb_side_data,
ofp->side_data, ofp->nb_side_data, 0);
if (ret < 0)
return ret;
fd->frame_rate_filter = ofp->fps.framerate;
av_assert0(!frame->buf[0]);
@@ -2622,6 +2832,14 @@ static int fg_output_step(OutputFilterPriv *ofp, FilterGraphThread *fgt,
return AVERROR(ENOMEM);
}
av_frame_side_data_free(&fd->side_data, &fd->nb_side_data);
if (!fgt->got_frame) {
ret = clone_side_data(&fd->side_data, &fd->nb_side_data,
ofp->side_data, ofp->nb_side_data, 0);
if (ret < 0)
return ret;
}
fd->wallclock[LATENCY_PROBE_FILTER_POST] = av_gettime_relative();
// only use bits_per_raw_sample passed through from the decoder
@@ -2809,6 +3027,7 @@ static int send_eof(FilterGraphThread *fgt, InputFilter *ifilter,
ifp->sample_aspect_ratio = ifp->opts.fallback->sample_aspect_ratio;
ifp->color_space = ifp->opts.fallback->colorspace;
ifp->color_range = ifp->opts.fallback->color_range;
ifp->alpha_mode = ifp->opts.fallback->alpha_mode;
ifp->time_base = ifp->opts.fallback->time_base;
ret = av_channel_layout_copy(&ifp->ch_layout,
@@ -2859,6 +3078,7 @@ static const char *unknown_if_null(const char *str)
static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
InputFilter *ifilter, AVFrame *frame)
{
FilterGraphPriv *fgp = fgp_from_fg(fg);
InputFilterPriv *ifp = ifp_from_ifilter(ifilter);
FrameData *fd;
AVFrameSideData *sd;
@@ -2877,7 +3097,8 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
ifp->width != frame->width ||
ifp->height != frame->height ||
ifp->color_space != frame->colorspace ||
ifp->color_range != frame->color_range)
ifp->color_range != frame->color_range ||
ifp->alpha_mode != frame->alpha_mode)
need_reinit |= VIDEO_CHANGED;
break;
}
@@ -2914,6 +3135,14 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
ret = ifilter_parameters_from_frame(ifilter, frame);
if (ret < 0)
return ret;
/* Inputs bound to a filtergraph output will have some fields unset.
* Handle them here */
if (ifp->ofilter_src) {
ret = ifilter_parameters_from_ofilter(ifilter, ifp->ofilter_src);
if (ret < 0)
return ret;
}
}
/* (re)init the graph if possible, otherwise buffer the frame and return */
@@ -2951,9 +3180,11 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
const char *pixel_format_name = av_get_pix_fmt_name(frame->format);
const char *color_space_name = av_color_space_name(frame->colorspace);
const char *color_range_name = av_color_range_name(frame->color_range);
av_bprintf(&reason, "video parameters changed to %s(%s, %s), %dx%d, ",
const char *alpha_mode = av_alpha_mode_name(frame->alpha_mode);
av_bprintf(&reason, "video parameters changed to %s(%s, %s), %dx%d, %s alpha,",
unknown_if_null(pixel_format_name), unknown_if_null(color_range_name),
unknown_if_null(color_space_name), frame->width, frame->height);
unknown_if_null(color_space_name), frame->width, frame->height,
unknown_if_null(alpha_mode));
}
if (need_reinit & MATRIX_CHANGED)
av_bprintf(&reason, "display matrix changed, ");
@@ -2964,6 +3195,11 @@ static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
if (reason.len > 1)
reason.str[reason.len - 2] = '\0'; // remove last comma
av_log(fg, AV_LOG_INFO, "Reconfiguring filter graph%s%s\n", reason.len ? " because " : "", reason.str);
} else {
/* Choke all input to avoid buffering excessive frames while the
* initial filter graph is being configured, and before we have a
* preferred input */
sch_filter_choke_inputs(fgp->sch, fgp->sch_idx);
}
ret = configure_filtergraph(fg, fgt);
@@ -3134,7 +3370,7 @@ static int filter_thread(void *arg)
if (ret == AVERROR_EOF) {
av_log(fg, AV_LOG_VERBOSE, "Input %u no longer accepts new data\n",
input_idx);
sch_filter_receive_finish(fgp->sch, fgp->sch_idx, input_idx);
close_input(ifp);
continue;
}
if (ret < 0)
@@ -3153,6 +3389,13 @@ read_frames:
av_err2str(ret));
goto finish;
}
// ensure all inputs no longer accepting data are closed
for (int i = 0; fgt.graph && i < fg->nb_inputs; i++) {
InputFilterPriv *ifp = ifp_from_ifilter(fg->inputs[i]);
if (av_buffersrc_get_status(ifp->ifilter.filter))
close_input(ifp);
}
}
for (unsigned i = 0; i < fg->nb_outputs; i++) {
+86 -18
View File
@@ -453,7 +453,7 @@ static int ost_get_filters(const OptionsContext *o, AVFormatContext *oc,
}
if (filters_script)
*dst = file_read(filters_script);
*dst = read_file_to_string(filters_script);
else
#endif
if (filters)
@@ -482,9 +482,9 @@ static int parse_matrix_coeffs(void *logctx, uint16_t *dest, const char *str)
return 0;
}
static int fmt_in_list(const int *formats, int format)
static int pixfmt_in_list(const enum AVPixelFormat *formats, enum AVPixelFormat format)
{
for (; *formats != -1; formats++)
for (; *formats != AV_PIX_FMT_NONE; formats++)
if (*formats == format)
return 1;
return 0;
@@ -544,7 +544,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name)
* endianness by av_get_pix_fmt();
* the following code handles the case when the native endianness is not
* supported by the encoder, but the other one is */
if (fmts && !fmt_in_list(fmts, fmt)) {
if (fmts && !pixfmt_in_list(fmts, fmt)) {
const char *name_canonical = av_get_pix_fmt_name(fmt);
int len = strlen(name_canonical);
@@ -557,7 +557,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name)
snprintf(name_other, sizeof(name_other), "%s%ce",
name, name_canonical[len - 2] == 'l' ? 'b' : 'l');
fmt_other = av_get_pix_fmt(name_other);
if (fmt_other != AV_PIX_FMT_NONE && fmt_in_list(fmts, fmt_other)) {
if (fmt_other != AV_PIX_FMT_NONE && pixfmt_in_list(fmts, fmt_other)) {
av_log(ost, AV_LOG_VERBOSE, "Mapping pixel format %s->%s\n",
name, name_other);
fmt = fmt_other;
@@ -565,7 +565,7 @@ static enum AVPixelFormat pix_fmt_parse(OutputStream *ost, const char *name)
}
}
if (fmts && !fmt_in_list(fmts, fmt))
if (fmts && !pixfmt_in_list(fmts, fmt))
fmt = choose_pixel_fmt(ost->enc->enc_ctx, fmt);
return fmt;
@@ -730,9 +730,14 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
AV_OPT_SEARCH_CHILDREN) > 0)
av_opt_set(video_enc, "stats", logfilename,
AV_OPT_SEARCH_CHILDREN);
} else if (!strcmp(video_enc->codec->name, "libx265")) {
if (av_opt_is_set_to_default_by_name(video_enc, "x265-stats",
AV_OPT_SEARCH_CHILDREN) > 0)
av_opt_set(video_enc, "x265-stats", logfilename,
AV_OPT_SEARCH_CHILDREN);
} else {
if (video_enc->flags & AV_CODEC_FLAG_PASS2) {
char *logbuffer = file_read(logfilename);
char *logbuffer = read_file_to_string(logfilename);
if (!logbuffer) {
av_log(ost, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n",
@@ -917,6 +922,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
.height = enc_ctx->height,
.color_space = enc_ctx->colorspace,
.color_range = enc_ctx->color_range,
.alpha_mode = enc_ctx->alpha_mode,
.vsync_method = vsync_method,
.frame_rate = ms->frame_rate,
.max_frame_rate = ms->max_frame_rate,
@@ -943,7 +949,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
if (!keep_pix_fmt) {
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_PIX_FORMAT, 0,
(const void **) &opts.formats, NULL);
(const void **) &opts.pix_fmts, NULL);
if (ret < 0)
return ret;
}
@@ -964,10 +970,15 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
(const void **) &opts.color_ranges, NULL);
if (ret < 0)
return ret;
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_ALPHA_MODE, 0,
(const void **) &opts.alpha_modes, NULL);
if (ret < 0)
return ret;
} else {
ret = avcodec_get_supported_config(enc_ctx, NULL,
AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
(const void **) &opts.formats, NULL);
(const void **) &opts.sample_fmts, NULL);
if (ret < 0)
return ret;
ret = avcodec_get_supported_config(enc_ctx, NULL,
@@ -997,7 +1008,7 @@ ost_bind_filter(const Muxer *mux, MuxStream *ms, OutputFilter *ofilter,
ost->filter = ofilter;
ret = ofilter_bind_enc(ofilter, ms->sch_idx_enc, &opts);
} else {
ret = fg_create_simple(&ost->fg_simple, ost->ist, filters,
ret = fg_create_simple(&ost->fg_simple, ost->ist, &filters,
mux->sch, ms->sch_idx_enc, &opts);
if (ret >= 0)
ost->filter = ost->fg_simple->outputs[0];
@@ -1592,8 +1603,9 @@ fail:
static int map_auto_video(Muxer *mux, const OptionsContext *o)
{
AVFormatContext *oc = mux->fc;
InputStreamGroup *best_istg = NULL;
InputStream *best_ist = NULL;
int best_score = 0;
int64_t best_score = 0;
int qcr;
/* video: highest resolution */
@@ -1603,17 +1615,52 @@ static int map_auto_video(Muxer *mux, const OptionsContext *o)
qcr = avformat_query_codec(oc->oformat, oc->oformat->video_codec, 0);
for (int j = 0; j < nb_input_files; j++) {
InputFile *ifile = input_files[j];
InputStreamGroup *file_best_istg = NULL;
InputStream *file_best_ist = NULL;
int file_best_score = 0;
for (int i = 0; i < ifile->nb_streams; i++) {
InputStream *ist = ifile->streams[i];
int score;
int64_t file_best_score = 0;
for (int i = 0; i < ifile->nb_stream_groups; i++) {
InputStreamGroup *istg = ifile->stream_groups[i];
int64_t score = 0;
if (ist->user_set_discard == AVDISCARD_ALL ||
ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
if (!istg->fg)
continue;
score = ist->st->codecpar->width * ist->st->codecpar->height
for (int j = 0; j < istg->stg->nb_streams; j++) {
AVStream *st = istg->stg->streams[j];
if (st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS) {
score = 100000000;
break;
}
}
switch (istg->stg->type) {
case AV_STREAM_GROUP_PARAMS_TILE_GRID: {
const AVStreamGroupTileGrid *tg = istg->stg->params.tile_grid;
score += tg->width * (int64_t)tg->height
+ 5000000*!!(istg->stg->disposition & AV_DISPOSITION_DEFAULT);
break;
}
default:
continue;
}
if (score > file_best_score) {
file_best_score = score;
file_best_istg = istg;
}
}
for (int i = 0; i < ifile->nb_streams; i++) {
InputStream *ist = ifile->streams[i];
const AVCodecDescriptor *desc = avcodec_descriptor_get(ist->st->codecpar->codec_id);
int64_t score;
if (ist->user_set_discard == AVDISCARD_ALL ||
ist->st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
(desc && (desc->props & AV_CODEC_PROP_ENHANCEMENT)))
continue;
score = ist->st->codecpar->width * (int64_t)ist->st->codecpar->height
+ 100000000 * !!(ist->st->event_flags & AVSTREAM_EVENT_FLAG_NEW_PACKETS)
+ 5000000*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT);
if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
@@ -1624,6 +1671,15 @@ static int map_auto_video(Muxer *mux, const OptionsContext *o)
continue;
file_best_score = score;
file_best_ist = ist;
file_best_istg = NULL;
}
}
if (file_best_istg) {
file_best_score -= 5000000*!!(file_best_istg->stg->disposition & AV_DISPOSITION_DEFAULT);
if (file_best_score > best_score) {
best_score = file_best_score;
best_istg = file_best_istg;
best_ist = NULL;
}
}
if (file_best_ist) {
@@ -1633,9 +1689,19 @@ static int map_auto_video(Muxer *mux, const OptionsContext *o)
if (file_best_score > best_score) {
best_score = file_best_score;
best_ist = file_best_ist;
best_istg = NULL;
}
}
}
if (best_istg) {
FilterGraph *fg = best_istg->fg;
OutputFilter *ofilter = fg->outputs[0];
av_assert0(fg->nb_outputs == 1);
av_log(mux, AV_LOG_VERBOSE, "Creating output stream from stream group derived complex filtergraph %d.\n", fg->index);
return ost_add(mux, o, AVMEDIA_TYPE_VIDEO, NULL, ofilter, NULL, NULL);
}
if (best_ist)
return ost_add(mux, o, AVMEDIA_TYPE_VIDEO, best_ist, NULL, NULL, NULL);
@@ -3220,6 +3286,8 @@ static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
"-force_key_frames is deprecated, use just 'source'\n");
ost->kf.type = KF_FORCE_SOURCE;
#endif
} else if (!strcmp(forced_keyframes, "scd_metadata")) {
ost->kf.type = KF_FORCE_SCD_METADATA;
} else {
int ret = parse_forced_key_frames(ost, &ost->kf, mux, forced_keyframes);
if (ret < 0)
+102 -4
View File
@@ -242,6 +242,70 @@ OPT_MATCH_PER_STREAM(int, int, OPT_TYPE_INT, i);
OPT_MATCH_PER_STREAM(int64, int64_t, OPT_TYPE_INT64, i64);
OPT_MATCH_PER_STREAM(dbl, double, OPT_TYPE_DOUBLE, dbl);
static unsigned opt_match_per_stream_group(void *logctx, enum OptionType type,
const SpecifierOptList *sol,
AVFormatContext *fc, AVStreamGroup *stg)
{
int matches = 0, match_idx = -1;
av_assert0((type == sol->type) || !sol->nb_opt);
for (int i = 0; i < sol->nb_opt; i++) {
const StreamSpecifier *ss = &sol->opt[i].stream_spec;
if (stream_group_specifier_match(ss, fc, stg, logctx)) {
match_idx = i;
matches++;
}
}
if (matches > 1 && sol->opt_canon) {
const SpecifierOpt *so = &sol->opt[match_idx];
const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";
char namestr[128] = "";
char optval_buf[32];
const char *optval = optval_buf;
snprintf(namestr, sizeof(namestr), "-%s", sol->opt_canon->name);
if (sol->opt_canon->flags & OPT_HAS_ALT) {
const char * const *names_alt = sol->opt_canon->u1.names_alt;
for (int i = 0; names_alt[i]; i++)
av_strlcatf(namestr, sizeof(namestr), "/-%s", names_alt[i]);
}
switch (sol->type) {
case OPT_TYPE_STRING: optval = so->u.str; break;
case OPT_TYPE_INT: snprintf(optval_buf, sizeof(optval_buf), "%d", so->u.i); break;
case OPT_TYPE_INT64: snprintf(optval_buf, sizeof(optval_buf), "%"PRId64, so->u.i64); break;
case OPT_TYPE_FLOAT: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.f); break;
case OPT_TYPE_DOUBLE: snprintf(optval_buf, sizeof(optval_buf), "%f", so->u.dbl); break;
default: av_assert0(0);
}
av_log(logctx, AV_LOG_WARNING, "Multiple %s options specified for "
"stream group %d, only the last option '-%s%s%s %s' will be used.\n",
namestr, stg->index, sol->opt_canon->name, spec[0] ? ":" : "",
spec, optval);
}
return match_idx + 1;
}
#define OPT_MATCH_PER_STREAM_GROUP(name, type, opt_type, m) \
void opt_match_per_stream_group_ ## name(void *logctx, const SpecifierOptList *sol, \
AVFormatContext *fc, AVStreamGroup *stg, type *out) \
{ \
unsigned ret = opt_match_per_stream_group(logctx, opt_type, sol, fc, stg); \
if (ret > 0) \
*out = sol->opt[ret - 1].u.m; \
}
OPT_MATCH_PER_STREAM_GROUP(str, const char *, OPT_TYPE_STRING, str);
OPT_MATCH_PER_STREAM_GROUP(int, int, OPT_TYPE_INT, i);
OPT_MATCH_PER_STREAM_GROUP(int64, int64_t, OPT_TYPE_INT64, i64);
OPT_MATCH_PER_STREAM_GROUP(dbl, double, OPT_TYPE_DOUBLE, dbl);
int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
{
const char *spec = *pspec;
@@ -295,7 +359,7 @@ int view_specifier_parse(const char **pspec, ViewSpecifier *vs)
return 0;
}
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
int parse_and_set_vsync(const char *arg, enum VideoSyncMethod *vsync_var, int file_idx, int st_idx, int is_global)
{
if (!av_strcasecmp(arg, "cfr")) *vsync_var = VSYNC_CFR;
else if (!av_strcasecmp(arg, "vfr")) *vsync_var = VSYNC_VFR;
@@ -504,8 +568,10 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
}
if (arg[0] == '[') {
ViewSpecifier vs;
/* this mapping refers to lavfi output */
const char *c = arg + 1;
char *endptr;
ret = GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
if (ret < 0)
@@ -518,6 +584,27 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
ret = AVERROR(EINVAL);
goto fail;
}
arg++;
m->group_index = -1;
file_idx = strtol(arg, &endptr, 0);
if (file_idx >= nb_input_files || file_idx < 0)
goto end;
arg = endptr;
ret = stream_specifier_parse(&ss, *arg == ':' ? arg + 1 : arg, 1, NULL);
if (ret < 0)
goto end;
arg = ss.remainder ? ss.remainder : "";
ret = view_specifier_parse(&arg, &vs);
if (ret < 0 || (*arg && strcmp(arg, "]")))
goto end;
m->file_index = file_idx;
m->stream_index = ss.idx;
m->group_index = ss.stream_list == STREAM_LIST_GROUP_IDX ? ss.list_id : -1;
} else {
ViewSpecifier vs;
char *endptr;
@@ -583,6 +670,7 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
m->file_index = file_idx;
m->stream_index = i;
m->group_index = ss.stream_list == STREAM_LIST_GROUP_IDX ? ss.list_id : -1;
m->vs = vs;
}
}
@@ -602,6 +690,7 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
goto fail;
}
}
end:
ret = 0;
fail:
stream_specifier_uninit(&ss);
@@ -1021,6 +1110,12 @@ static int opt_preset(void *optctx, const char *opt, const char *arg)
char filename[1000], line[1000], tmp_line[1000];
const char *codec_name = NULL;
int ret = 0;
int depth = o->depth;
if (depth > 2) {
av_log(NULL, AV_LOG_ERROR, "too deep recursion\n");
return AVERROR(EINVAL);
}
codec_name = opt_match_per_type_str(&o->codec_names, *opt);
@@ -1032,6 +1127,7 @@ static int opt_preset(void *optctx, const char *opt, const char *arg)
return AVERROR(ENOENT);
}
o->depth ++;
while (fgets(line, sizeof(line), f)) {
char *key = tmp_line, *value, *endptr;
@@ -1050,7 +1146,8 @@ static int opt_preset(void *optctx, const char *opt, const char *arg)
else if (!strcmp(key, "vcodec")) opt_video_codec (o, key, value);
else if (!strcmp(key, "scodec")) opt_subtitle_codec(o, key, value);
else if (!strcmp(key, "dcodec")) opt_data_codec (o, key, value);
else if (opt_default_new(o, key, value) < 0) {
else if ((parse_option(o, key, value, options) < 0) &&
(opt_default_new(o, key, value) < 0)) {
av_log(NULL, AV_LOG_FATAL, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
filename, line, key, value);
ret = AVERROR(EINVAL);
@@ -1059,6 +1156,7 @@ static int opt_preset(void *optctx, const char *opt, const char *arg)
}
fail:
o->depth = depth;
fclose(f);
return ret;
@@ -1188,7 +1286,7 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char *
char *graph_desc;
int ret;
graph_desc = file_read(arg);
graph_desc = read_file_to_string(arg);
if (!graph_desc)
return AVERROR(EINVAL);
@@ -1406,7 +1504,7 @@ int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
/* create complex filtergraphs */
for (int i = 0; i < go.nb_filtergraphs; i++) {
ret = fg_create(NULL, go.filtergraphs[i], sch);
ret = fg_create(NULL, &go.filtergraphs[i], sch, NULL);
go.filtergraphs[i] = NULL;
if (ret < 0)
goto fail;
+205 -60
View File
@@ -189,7 +189,6 @@ typedef struct PreMuxQueue {
typedef struct SchMuxStream {
SchedulerNode src;
SchedulerNode src_sched;
unsigned *sub_heartbeat_dst;
unsigned nb_sub_heartbeat_dst;
@@ -235,7 +234,6 @@ typedef struct SchMux {
typedef struct SchFilterIn {
SchedulerNode src;
SchedulerNode src_sched;
int send_finished;
int receive_finished;
} SchFilterIn;
@@ -249,7 +247,7 @@ typedef struct SchFilterGraph {
SchFilterIn *inputs;
unsigned nb_inputs;
atomic_uint nb_inputs_finished_send;
unsigned nb_inputs_finished_send;
unsigned nb_inputs_finished_receive;
SchFilterOut *outputs;
@@ -389,7 +387,7 @@ static int queue_alloc(ThreadQueue **ptq, unsigned nb_streams, unsigned queue_si
// for frames held in queues inside the ffmpeg utility. If this
// can ever dynamically change then the corresponding decode
// code needs to be updated as well.
av_assert0(queue_size == DEFAULT_FRAME_THREAD_QUEUE_SIZE);
av_assert0(queue_size <= DEFAULT_FRAME_THREAD_QUEUE_SIZE);
}
tq = tq_alloc(nb_streams, queue_size,
@@ -407,6 +405,9 @@ static int task_start(SchTask *task)
{
int ret;
if (!task->parent)
return 0;
av_log(task->func_arg, AV_LOG_VERBOSE, "Starting thread...\n");
av_assert0(!task->thread_running);
@@ -456,6 +457,23 @@ static int64_t trailing_dts(const Scheduler *sch, int count_finished)
return min_dts == INT64_MAX ? AV_NOPTS_VALUE : min_dts;
}
void sch_remove_filtergraph(Scheduler *sch, int idx)
{
SchFilterGraph *fg = &sch->filters[idx];
av_assert0(!fg->task.thread_running);
memset(&fg->task, 0, sizeof(fg->task));
tq_free(&fg->queue);
av_freep(&fg->inputs);
fg->nb_inputs = 0;
av_freep(&fg->outputs);
fg->nb_outputs = 0;
fg->task_exited = 1;
}
void sch_free(Scheduler **psch)
{
Scheduler *sch = *psch;
@@ -1264,28 +1282,110 @@ int sch_mux_sub_heartbeat_add(Scheduler *sch, unsigned mux_idx, unsigned stream_
return 0;
}
static void unchoke_for_stream(Scheduler *sch, SchedulerNode src);
// Unchoke any filter graphs that are downstream of this node, to prevent it
// from getting stuck trying to push data to a full queue
static void unchoke_downstream(Scheduler *sch, SchedulerNode *dst)
{
SchFilterGraph *fg;
SchDec *dec;
SchEnc *enc;
switch (dst->type) {
case SCH_NODE_TYPE_DEC:
dec = &sch->dec[dst->idx];
for (int i = 0; i < dec->nb_outputs; i++)
unchoke_downstream(sch, dec->outputs[i].dst);
break;
case SCH_NODE_TYPE_ENC:
enc = &sch->enc[dst->idx];
for (int i = 0; i < enc->nb_dst; i++)
unchoke_downstream(sch, &enc->dst[i]);
break;
case SCH_NODE_TYPE_MUX:
// muxers are never choked
break;
case SCH_NODE_TYPE_FILTER_IN:
fg = &sch->filters[dst->idx];
if (fg->best_input == fg->nb_inputs) {
fg->waiter.choked_next = 0;
} else {
// ensure that this filter graph is not stuck waiting for
// input from a different upstream demuxer
unchoke_for_stream(sch, fg->inputs[fg->best_input].src);
}
break;
default:
av_unreachable("Invalid destination node type?");
break;
}
}
static void unchoke_for_stream(Scheduler *sch, SchedulerNode src)
{
while (1) {
SchFilterGraph *fg;
// fed directly by a demuxer (i.e. not through a filtergraph)
if (src.type == SCH_NODE_TYPE_DEMUX) {
sch->demux[src.idx].waiter.choked_next = 0;
SchDemux *demux;
switch (src.type) {
case SCH_NODE_TYPE_DEMUX:
// fed directly by a demuxer (i.e. not through a filtergraph)
demux = &sch->demux[src.idx];
if (demux->waiter.choked_next == 0)
return; // prevent infinite loop
demux->waiter.choked_next = 0;
for (int i = 0; i < demux->nb_streams; i++)
unchoke_downstream(sch, demux->streams[i].dst);
return;
case SCH_NODE_TYPE_DEC:
src = sch->dec[src.idx].src;
continue;
case SCH_NODE_TYPE_ENC:
src = sch->enc[src.idx].src;
continue;
case SCH_NODE_TYPE_FILTER_OUT:
fg = &sch->filters[src.idx];
// the filtergraph contains internal sources and
// requested to be scheduled directly
if (fg->best_input == fg->nb_inputs) {
fg->waiter.choked_next = 0;
return;
}
src = fg->inputs[fg->best_input].src;
continue;
default:
av_unreachable("Invalid source node type?");
return;
}
}
}
av_assert0(src.type == SCH_NODE_TYPE_FILTER_OUT);
fg = &sch->filters[src.idx];
static void choke_demux(const Scheduler *sch, int demux_id, int choked)
{
av_assert1(demux_id < sch->nb_demux);
SchDemux *demux = &sch->demux[demux_id];
// the filtergraph contains internal sources and
// requested to be scheduled directly
if (fg->best_input == fg->nb_inputs) {
fg->waiter.choked_next = 0;
return;
for (int i = 0; i < demux->nb_streams; i++) {
SchedulerNode *dst = demux->streams[i].dst;
SchFilterGraph *fg;
switch (dst->type) {
case SCH_NODE_TYPE_DEC:
tq_choke(sch->dec[dst->idx].queue, choked);
break;
case SCH_NODE_TYPE_ENC:
tq_choke(sch->enc[dst->idx].queue, choked);
break;
case SCH_NODE_TYPE_MUX:
break;
case SCH_NODE_TYPE_FILTER_IN:
fg = &sch->filters[dst->idx];
if (fg->nb_inputs == 1)
tq_choke(fg->queue, choked);
break;
default:
av_unreachable("Invalid destination node type?");
break;
}
src = fg->inputs[fg->best_input].src_sched;
}
}
@@ -1328,11 +1428,23 @@ static void schedule_update_locked(Scheduler *sch)
continue;
// resolve the source to unchoke
unchoke_for_stream(sch, ms->src_sched);
unchoke_for_stream(sch, ms->src);
have_unchoked = 1;
}
}
// also unchoke any sources feeding into closed filter graph inputs, so
// that they can observe the downstream EOF
for (unsigned i = 0; i < sch->nb_filters; i++) {
SchFilterGraph *fg = &sch->filters[i];
for (unsigned j = 0; j < fg->nb_inputs; j++) {
SchFilterIn *fi = &fg->inputs[j];
if (fi->receive_finished && !fi->send_finished)
unchoke_for_stream(sch, fi->src);
}
}
// make sure to unchoke at least one source, if still available
for (unsigned type = 0; !have_unchoked && type < 2; type++)
for (unsigned i = 0; i < (type ? sch->nb_filters : sch->nb_demux); i++) {
@@ -1345,13 +1457,16 @@ static void schedule_update_locked(Scheduler *sch)
}
}
for (unsigned type = 0; type < 2; type++)
for (unsigned type = 0; type < 2; type++) {
for (unsigned i = 0; i < (type ? sch->nb_filters : sch->nb_demux); i++) {
SchWaiter *w = type ? &sch->filters[i].waiter : &sch->demux[i].waiter;
if (w->choked_prev != w->choked_next)
if (w->choked_prev != w->choked_next) {
waiter_set(w, w->choked_next);
if (!type)
choke_demux(sch, i, w->choked_next);
}
}
}
}
@@ -1361,6 +1476,27 @@ enum {
CYCLE_NODE_DONE,
};
// Finds the filtergraph or muxer upstream of a scheduler node
static SchedulerNode src_filtergraph(const Scheduler *sch, SchedulerNode src)
{
while (1) {
switch (src.type) {
case SCH_NODE_TYPE_DEMUX:
case SCH_NODE_TYPE_FILTER_OUT:
return src;
case SCH_NODE_TYPE_DEC:
src = sch->dec[src.idx].src;
continue;
case SCH_NODE_TYPE_ENC:
src = sch->enc[src.idx].src;
continue;
default:
av_unreachable("Invalid source node type?");
return (SchedulerNode) {0};
}
}
}
static int
check_acyclic_for_output(const Scheduler *sch, SchedulerNode src,
uint8_t *filters_visited, SchedulerNode *filters_stack)
@@ -1377,22 +1513,23 @@ check_acyclic_for_output(const Scheduler *sch, SchedulerNode src,
// descend into every input, depth first
if (src.idx_stream < fg->nb_inputs) {
const SchFilterIn *fi = &fg->inputs[src.idx_stream++];
SchedulerNode node = src_filtergraph(sch, fi->src);
// connected to demuxer, no cycles possible
if (fi->src_sched.type == SCH_NODE_TYPE_DEMUX)
if (node.type == SCH_NODE_TYPE_DEMUX)
continue;
// otherwise connected to another filtergraph
av_assert0(fi->src_sched.type == SCH_NODE_TYPE_FILTER_OUT);
av_assert0(node.type == SCH_NODE_TYPE_FILTER_OUT);
// found a cycle
if (filters_visited[fi->src_sched.idx] == CYCLE_NODE_STARTED)
if (filters_visited[node.idx] == CYCLE_NODE_STARTED)
return AVERROR(EINVAL);
// place current position on stack and descend
av_assert0(nb_filters_stack < sch->nb_filters);
filters_stack[nb_filters_stack++] = src;
src = (SchedulerNode){ .idx = fi->src_sched.idx, .idx_stream = 0 };
src = (SchedulerNode){ .idx = node.idx, .idx_stream = 0 };
continue;
}
@@ -1514,22 +1651,7 @@ static int start_prepare(Scheduler *sch)
for (unsigned j = 0; j < mux->nb_streams; j++) {
SchMuxStream *ms = &mux->streams[j];
switch (ms->src.type) {
case SCH_NODE_TYPE_ENC: {
SchEnc *enc = &sch->enc[ms->src.idx];
if (enc->src.type == SCH_NODE_TYPE_DEC) {
ms->src_sched = sch->dec[enc->src.idx].src;
av_assert0(ms->src_sched.type == SCH_NODE_TYPE_DEMUX);
} else {
ms->src_sched = enc->src;
av_assert0(ms->src_sched.type == SCH_NODE_TYPE_FILTER_OUT);
}
break;
}
case SCH_NODE_TYPE_DEMUX:
ms->src_sched = ms->src;
break;
default:
if (!ms->src.type) {
av_log(mux, AV_LOG_ERROR,
"Muxer stream #%u not connected to a source\n", j);
return AVERROR(EINVAL);
@@ -1547,26 +1669,12 @@ static int start_prepare(Scheduler *sch)
for (unsigned j = 0; j < fg->nb_inputs; j++) {
SchFilterIn *fi = &fg->inputs[j];
SchDec *dec;
if (!fi->src.type) {
av_log(fg, AV_LOG_ERROR,
"Filtergraph input %u not connected to a source\n", j);
return AVERROR(EINVAL);
}
if (fi->src.type == SCH_NODE_TYPE_FILTER_OUT)
fi->src_sched = fi->src;
else {
av_assert0(fi->src.type == SCH_NODE_TYPE_DEC);
dec = &sch->dec[fi->src.idx];
switch (dec->src.type) {
case SCH_NODE_TYPE_DEMUX: fi->src_sched = dec->src; break;
case SCH_NODE_TYPE_ENC: fi->src_sched = sch->enc[dec->src.idx].src; break;
default: av_assert0(0);
}
}
}
for (unsigned j = 0; j < fg->nb_outputs; j++) {
@@ -2189,14 +2297,20 @@ static int send_to_filter(Scheduler *sch, SchFilterGraph *fg,
if (frame)
return tq_send(fg->queue, in_idx, frame);
pthread_mutex_lock(&sch->schedule_lock);
if (!fg->inputs[in_idx].send_finished) {
fg->inputs[in_idx].send_finished = 1;
tq_send_finish(fg->queue, in_idx);
// close the control stream when all actual inputs are done
if (atomic_fetch_add(&fg->nb_inputs_finished_send, 1) == fg->nb_inputs - 1)
if (++fg->nb_inputs_finished_send == fg->nb_inputs)
tq_send_finish(fg->queue, fg->nb_inputs);
schedule_update_locked(sch);
}
pthread_mutex_unlock(&sch->schedule_lock);
return 0;
}
@@ -2447,6 +2561,8 @@ void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx)
av_assert0(in_idx < fg->nb_inputs);
fi = &fg->inputs[in_idx];
pthread_mutex_lock(&sch->schedule_lock);
if (!fi->receive_finished) {
fi->receive_finished = 1;
tq_receive_finish(fg->queue, in_idx);
@@ -2454,13 +2570,18 @@ void sch_filter_receive_finish(Scheduler *sch, unsigned fg_idx, unsigned in_idx)
// close the control stream when all actual inputs are done
if (++fg->nb_inputs_finished_receive == fg->nb_inputs)
tq_receive_finish(fg->queue, fg->nb_inputs);
schedule_update_locked(sch);
}
pthread_mutex_unlock(&sch->schedule_lock);
}
int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame *frame)
{
SchFilterGraph *fg;
SchedulerNode dst;
int ret;
av_assert0(fg_idx < sch->nb_filters);
fg = &sch->filters[fg_idx];
@@ -2468,9 +2589,16 @@ int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx, AVFrame *
av_assert0(out_idx < fg->nb_outputs);
dst = fg->outputs[out_idx].dst;
return (dst.type == SCH_NODE_TYPE_ENC) ?
send_to_enc (sch, &sch->enc[dst.idx], frame) :
send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, frame);
if (dst.type == SCH_NODE_TYPE_ENC) {
ret = send_to_enc(sch, &sch->enc[dst.idx], frame);
if (ret == AVERROR_EOF)
send_to_enc(sch, &sch->enc[dst.idx], NULL);
} else {
ret = send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, frame);
if (ret == AVERROR_EOF)
send_to_filter(sch, &sch->filters[dst.idx], dst.idx_stream, NULL);
}
return ret;
}
static int filter_done(Scheduler *sch, unsigned fg_idx)
@@ -2512,6 +2640,18 @@ int sch_filter_command(Scheduler *sch, unsigned fg_idx, AVFrame *frame)
return send_to_filter(sch, fg, fg->nb_inputs, frame);
}
void sch_filter_choke_inputs(Scheduler *sch, unsigned fg_idx)
{
SchFilterGraph *fg;
av_assert0(fg_idx < sch->nb_filters);
fg = &sch->filters[fg_idx];
pthread_mutex_lock(&sch->schedule_lock);
fg->best_input = fg->nb_inputs;
schedule_update_locked(sch);
pthread_mutex_unlock(&sch->schedule_lock);
}
static int task_cleanup(Scheduler *sch, SchedulerNode node)
{
switch (node.type) {
@@ -2520,7 +2660,7 @@ static int task_cleanup(Scheduler *sch, SchedulerNode node)
case SCH_NODE_TYPE_DEC: return dec_done (sch, node.idx);
case SCH_NODE_TYPE_ENC: return enc_done (sch, node.idx);
case SCH_NODE_TYPE_FILTER_IN: return filter_done(sch, node.idx);
default: av_assert0(0);
default: av_unreachable("Invalid node type?");
}
}
@@ -2561,6 +2701,9 @@ static int task_stop(Scheduler *sch, SchTask *task)
int ret;
void *thread_ret;
if (!task->parent)
return 0;
if (!task->thread_running)
return task_cleanup(sch, task->node);
@@ -2585,6 +2728,8 @@ int sch_stop(Scheduler *sch, int64_t *finish_ts)
for (unsigned i = 0; i < (type ? sch->nb_demux : sch->nb_filters); i++) {
SchWaiter *w = type ? &sch->demux[i].waiter : &sch->filters[i].waiter;
waiter_set(w, 1);
if (type)
choke_demux(sch, i, 0); // unfreeze to allow draining
}
for (unsigned i = 0; i < sch->nb_demux; i++) {
+10 -1
View File
@@ -205,6 +205,8 @@ int sch_add_dec_output(Scheduler *sch, unsigned dec_idx);
int sch_add_filtergraph(Scheduler *sch, unsigned nb_inputs, unsigned nb_outputs,
SchThreadFunc func, void *ctx);
void sch_remove_filtergraph(Scheduler *sch, int idx);
/**
* Add a muxer to the scheduler.
*
@@ -257,7 +259,7 @@ int sch_add_mux(Scheduler *sch, SchThreadFunc func, int (*init)(void *),
/**
* Default size of a frame thread queue.
*/
#define DEFAULT_FRAME_THREAD_QUEUE_SIZE 8
#define DEFAULT_FRAME_THREAD_QUEUE_SIZE 2
/**
* Add a muxed stream for a previously added muxer.
@@ -443,6 +445,13 @@ int sch_filter_send(Scheduler *sch, unsigned fg_idx, unsigned out_idx,
int sch_filter_command(Scheduler *sch, unsigned fg_idx, struct AVFrame *frame);
/**
* Called by filtergraph tasks to choke all filter inputs, preventing them from
* receiving more frames until woken up again by the scheduler. Used during
* initial graph configuration to avoid unnecessary buffering.
*/
void sch_filter_choke_inputs(Scheduler *sch, unsigned fg_idx);
/**
* Called by encoder tasks to obtain frames for encoding. Will wait for a frame
* to become available and return it in frame.
+91 -10
View File
@@ -37,6 +37,7 @@
#include "libavutil/pixdesc.h"
#include "libavutil/dict.h"
#include "libavutil/fifo.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/time.h"
#include "libavutil/bprint.h"
@@ -267,6 +268,7 @@ typedef struct VideoState {
AVComplexFloat *rdft_data;
int xpos;
double last_vis_time;
RenderParams render_params;
SDL_Texture *vis_texture;
SDL_Texture *sub_texture;
SDL_Texture *vid_texture;
@@ -350,6 +352,7 @@ static int find_stream_info = 1;
static int filter_nbthreads = 0;
static int enable_vulkan = 0;
static char *vulkan_params = NULL;
static char *video_background = NULL;
static const char *hwaccel = NULL;
/* current context */
@@ -942,6 +945,11 @@ static enum AVColorSpace sdl_supported_color_spaces[] = {
AVCOL_SPC_SMPTE170M,
};
static enum AVAlphaMode sdl_supported_alpha_modes[] = {
AVALPHA_MODE_UNSPECIFIED,
AVALPHA_MODE_STRAIGHT,
};
static void set_sdl_yuv_conversion_mode(AVFrame *frame)
{
#if SDL_VERSION_ATLEAST(2,0,8)
@@ -958,15 +966,52 @@ static void set_sdl_yuv_conversion_mode(AVFrame *frame)
#endif
}
static void draw_video_background(VideoState *is)
{
const int tile_size = VIDEO_BACKGROUND_TILE_SIZE;
SDL_Rect *rect = &is->render_params.target_rect;
SDL_BlendMode blendMode;
if (!SDL_GetTextureBlendMode(is->vid_texture, &blendMode) && blendMode == SDL_BLENDMODE_BLEND) {
switch (is->render_params.video_background_type) {
case VIDEO_BACKGROUND_TILES:
SDL_SetRenderDrawColor(renderer, 237, 237, 237, 255);
fill_rectangle(rect->x, rect->y, rect->w, rect->h);
SDL_SetRenderDrawColor(renderer, 222, 222, 222, 255);
for (int x = 0; x < rect->w; x += tile_size * 2)
fill_rectangle(rect->x + x, rect->y, FFMIN(tile_size, rect->w - x), rect->h);
for (int y = 0; y < rect->h; y += tile_size * 2)
fill_rectangle(rect->x, rect->y + y, rect->w, FFMIN(tile_size, rect->h - y));
SDL_SetRenderDrawColor(renderer, 237, 237, 237, 255);
for (int y = 0; y < rect->h; y += tile_size * 2) {
int h = FFMIN(tile_size, rect->h - y);
for (int x = 0; x < rect->w; x += tile_size * 2)
fill_rectangle(x + rect->x, y + rect->y, FFMIN(tile_size, rect->w - x), h);
}
break;
case VIDEO_BACKGROUND_COLOR: {
const uint8_t *c = is->render_params.video_background_color;
SDL_SetRenderDrawColor(renderer, c[0], c[1], c[2], c[3]);
fill_rectangle(rect->x, rect->y, rect->w, rect->h);
break;
}
case VIDEO_BACKGROUND_NONE:
SDL_SetTextureBlendMode(is->vid_texture, SDL_BLENDMODE_NONE);
break;
}
}
}
static void video_image_display(VideoState *is)
{
Frame *vp;
Frame *sp = NULL;
SDL_Rect rect;
SDL_Rect *rect = &is->render_params.target_rect;
vp = frame_queue_peek_last(&is->pictq);
calculate_display_rect(rect, is->xleft, is->ytop, is->width, is->height, vp->width, vp->height, vp->sar);
if (vk_renderer) {
vk_renderer_display(vk_renderer, vp->frame);
vk_renderer_display(vk_renderer, vp->frame, &is->render_params);
return;
}
@@ -1015,7 +1060,6 @@ static void video_image_display(VideoState *is)
}
}
calculate_display_rect(&rect, is->xleft, is->ytop, is->width, is->height, vp->width, vp->height, vp->sar);
set_sdl_yuv_conversion_mode(vp->frame);
if (!vp->uploaded) {
@@ -1027,15 +1071,16 @@ static void video_image_display(VideoState *is)
vp->flip_v = vp->frame->linesize[0] < 0;
}
SDL_RenderCopyEx(renderer, is->vid_texture, NULL, &rect, 0, NULL, vp->flip_v ? SDL_FLIP_VERTICAL : 0);
draw_video_background(is);
SDL_RenderCopyEx(renderer, is->vid_texture, NULL, rect, 0, NULL, vp->flip_v ? SDL_FLIP_VERTICAL : 0);
set_sdl_yuv_conversion_mode(NULL);
if (sp) {
#if USE_ONEPASS_SUBTITLE_RENDER
SDL_RenderCopy(renderer, is->sub_texture, NULL, &rect);
SDL_RenderCopy(renderer, is->sub_texture, NULL, rect);
#else
int i;
double xratio = (double)rect.w / (double)sp->width;
double yratio = (double)rect.h / (double)sp->height;
double xratio = (double)rect->w / (double)sp->width;
double yratio = (double)rect->h / (double)sp->height;
for (i = 0; i < sp->sub.num_rects; i++) {
SDL_Rect *sub_rect = (SDL_Rect*)sp->sub.rects[i];
SDL_Rect target = {.x = rect.x + sub_rect->x * xratio,
@@ -1906,6 +1951,7 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
par->sample_aspect_ratio = codecpar->sample_aspect_ratio;
par->color_space = frame->colorspace;
par->color_range = frame->color_range;
par->alpha_mode = frame->alpha_mode;
par->frame_rate = fr;
par->hw_frames_ctx = frame->hw_frames_ctx;
ret = av_buffersrc_parameters_set(filt_src, par);
@@ -1932,6 +1978,11 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
AV_OPT_TYPE_INT, sdl_supported_color_spaces)) < 0)
goto fail;
if ((ret = av_opt_set_array(filt_out, "alphamodes", AV_OPT_SEARCH_CHILDREN,
0, FF_ARRAY_ELEMS(sdl_supported_alpha_modes),
AV_OPT_TYPE_INT, sdl_supported_alpha_modes)) < 0)
goto fail;
ret = avfilter_init_dict(filt_out, NULL);
if (ret < 0)
goto fail;
@@ -2832,6 +2883,7 @@ static int read_thread(void *arg)
int st_index[AVMEDIA_TYPE_NB];
AVPacket *pkt = NULL;
int64_t stream_start_time;
char metadata_description[96];
int pkt_in_play_range = 0;
const AVDictionaryEntry *t;
SDL_mutex *wait_mutex = SDL_CreateMutex();
@@ -2939,8 +2991,10 @@ static int read_thread(void *arg)
is->realtime = is_realtime(ic);
if (show_status)
if (show_status) {
fprintf(stderr, "\x1b[2K\r");
av_dump_format(ic, 0, is->filename, 0);
}
for (i = 0; i < ic->nb_streams; i++) {
AVStream *st = ic->streams[i];
@@ -2949,6 +3003,9 @@ static int read_thread(void *arg)
if (type >= 0 && wanted_stream_spec[type] && st_index[type] == -1)
if (avformat_match_stream_specifier(ic, st, wanted_stream_spec[type]) > 0)
st_index[type] = i;
// Clear all pre-existing metadata update flags to avoid printing
// initial metadata as update.
st->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
}
for (i = 0; i < AVMEDIA_TYPE_NB; i++) {
if (wanted_stream_spec[i] && st_index[i] == -1) {
@@ -3117,6 +3174,19 @@ static int read_thread(void *arg)
} else {
is->eof = 0;
}
if (show_status && ic->streams[pkt->stream_index]->event_flags &
AVSTREAM_EVENT_FLAG_METADATA_UPDATED) {
fprintf(stderr, "\x1b[2K\r");
snprintf(metadata_description,
sizeof(metadata_description),
"\r New metadata for stream %d",
pkt->stream_index);
dump_dictionary(NULL, ic->streams[pkt->stream_index]->metadata,
metadata_description, " ", AV_LOG_INFO);
}
ic->streams[pkt->stream_index]->event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
/* check if packet is in play range specified by user, then queue, otherwise discard */
stream_start_time = ic->streams[pkt->stream_index]->start_time;
pkt_ts = pkt->pts == AV_NOPTS_VALUE ? pkt->dts : pkt->pts;
@@ -3198,6 +3268,16 @@ static VideoState *stream_open(const char *filename,
av_log(NULL, AV_LOG_WARNING, "-volume=%d < 0, setting to 0\n", startup_volume);
if (startup_volume > 100)
av_log(NULL, AV_LOG_WARNING, "-volume=%d > 100, setting to 100\n", startup_volume);
if (video_background) {
if (!strcmp(video_background, "none")) {
is->render_params.video_background_type = VIDEO_BACKGROUND_NONE;
} else if (strcmp(video_background, "tiles")) {
if (av_parse_color(is->render_params.video_background_color, video_background, -1, NULL) >= 0)
is->render_params.video_background_type = VIDEO_BACKGROUND_COLOR;
else
goto fail;
}
}
startup_volume = av_clip(startup_volume, 0, 100);
startup_volume = av_clip(SDL_MIX_MAXVOLUME * startup_volume / 100, 0, SDL_MIX_MAXVOLUME);
is->audio_volume = startup_volume;
@@ -3711,6 +3791,7 @@ static const OptionDef options[] = {
{ "filter_threads", OPT_TYPE_INT, OPT_EXPERT, { &filter_nbthreads }, "number of filter threads per graph" },
{ "enable_vulkan", OPT_TYPE_BOOL, 0, { &enable_vulkan }, "enable vulkan renderer" },
{ "vulkan_params", OPT_TYPE_STRING, OPT_EXPERT, { &vulkan_params }, "vulkan configuration using a list of key=value pairs separated by ':'" },
{ "video_bg", OPT_TYPE_STRING, OPT_EXPERT, { &video_background }, "set video background for transparent videos" },
{ "hwaccel", OPT_TYPE_STRING, OPT_EXPERT, { &hwaccel }, "use HW accelerated decoding" },
{ NULL, },
};
@@ -3745,9 +3826,9 @@ void show_help_default(const char *opt, const char *arg)
"c cycle program\n"
"w cycle video filters or show modes\n"
"s activate frame-step mode\n"
"left/right seek backward/forward 10 seconds or to custom interval if -seek_interval is set\n"
"left/right seek backward/forward by 10 seconds or a custom interval if -seek_interval is set\n"
"down/up seek backward/forward 1 minute\n"
"page down/page up seek backward/forward 10 minutes\n"
"page down/page up seek to previous/next chapter or backward/forward 10 minutes if no chapters\n"
"right mouse click seek to percentage in file corresponding to fraction of width\n"
"left double-click toggle full screen\n"
);
+35 -38
View File
@@ -53,7 +53,7 @@ struct VkRenderer {
int (*get_hw_dev)(VkRenderer *renderer, AVBufferRef **dev);
int (*display)(VkRenderer *renderer, AVFrame *frame);
int (*display)(VkRenderer *renderer, AVFrame *frame, RenderParams *params);
int (*resize)(VkRenderer *renderer, int width, int height);
@@ -104,36 +104,6 @@ static void vk_log_cb(void *log_priv, enum pl_log_level level,
av_log(log_priv, level_map[level], "%s\n", msg);
}
// Should keep sync with optional_device_exts inside hwcontext_vulkan.c
static const char *optional_device_exts[] = {
/* Misc or required by other extensions */
VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME,
VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME,
VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME,
VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME,
VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME,
VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME,
VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME,
/* Imports/exports */
VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME,
VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME,
VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME,
#ifdef _WIN32
VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME,
VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME,
#endif
/* Video encoding/decoding */
VK_KHR_VIDEO_QUEUE_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME,
VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME,
"VK_MESA_video_decode_av1",
};
static inline int enable_debug(const AVDictionary *opt)
{
AVDictionaryEntry *entry = av_dict_get(opt, "debug", NULL, 0);
@@ -374,6 +344,8 @@ static int create_vk_by_placebo(VkRenderer *renderer,
int decode_index;
int decode_count;
int ret;
const char **dev_exts;
int num_dev_exts;
ctx->get_proc_addr = SDL_Vulkan_GetVkGetInstanceProcAddr();
@@ -388,16 +360,21 @@ static int create_vk_by_placebo(VkRenderer *renderer,
}
ctx->inst = ctx->placebo_instance->instance;
dev_exts = av_vk_get_optional_device_extensions(&num_dev_exts);
if (!dev_exts)
return AVERROR(ENOMEM);
ctx->placebo_vulkan = pl_vulkan_create(ctx->vk_log, pl_vulkan_params(
.instance = ctx->placebo_instance->instance,
.get_proc_addr = ctx->placebo_instance->get_proc_addr,
.surface = ctx->vk_surface,
.allow_software = false,
.opt_extensions = optional_device_exts,
.num_opt_extensions = FF_ARRAY_ELEMS(optional_device_exts),
.opt_extensions = dev_exts,
.num_opt_extensions = num_dev_exts,
.extra_queues = VK_QUEUE_VIDEO_DECODE_BIT_KHR,
.device_name = select_device(opt),
));
av_free(dev_exts);
if (!ctx->placebo_vulkan)
return AVERROR_EXTERNAL;
ctx->hw_device_ref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VULKAN);
@@ -725,11 +702,13 @@ static int convert_frame(VkRenderer *renderer, AVFrame *frame)
return ret;
}
static int display(VkRenderer *renderer, AVFrame *frame)
static int display(VkRenderer *renderer, AVFrame *frame, RenderParams *params)
{
SDL_Rect *rect = &params->target_rect;
struct pl_swapchain_frame swap_frame = {0};
struct pl_frame pl_frame = {0};
struct pl_frame target = {0};
struct pl_render_params pl_params = pl_render_default_params;
RendererContext *ctx = (RendererContext *) renderer;
int ret = 0;
struct pl_color_space hint = {0};
@@ -754,8 +733,26 @@ static int display(VkRenderer *renderer, AVFrame *frame)
}
pl_frame_from_swapchain(&target, &swap_frame);
if (!pl_render_image(ctx->renderer, &pl_frame, &target,
&pl_render_default_params)) {
target.crop = (pl_rect2df){.x0 = rect->x, .x1 = rect->x + rect->w,
.y0 = rect->y, .y1 = rect->y + rect->h};
switch (params->video_background_type) {
case VIDEO_BACKGROUND_TILES:
pl_params.background = PL_CLEAR_TILES;
pl_params.tile_size = VIDEO_BACKGROUND_TILE_SIZE * 2;
break;
case VIDEO_BACKGROUND_COLOR:
pl_params.background = PL_CLEAR_COLOR;
for (int i = 0; i < 3; i++)
pl_params.background_color[i] = params->video_background_color[i] / 255.0;
pl_params.background_transparency = (255 - params->video_background_color[3]) / 255.0;
break;
case VIDEO_BACKGROUND_NONE:
pl_frame.repr.alpha = PL_ALPHA_NONE;
break;
}
if (!pl_render_image(ctx->renderer, &pl_frame, &target, &pl_params)) {
av_log(NULL, AV_LOG_ERROR, "pl_render_image failed\n");
ret = AVERROR_EXTERNAL;
goto out;
@@ -858,9 +855,9 @@ int vk_renderer_get_hw_dev(VkRenderer *renderer, AVBufferRef **dev)
return renderer->get_hw_dev(renderer, dev);
}
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame)
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame, RenderParams *render_params)
{
return renderer->display(renderer, frame);
return renderer->display(renderer, frame, render_params);
}
int vk_renderer_resize(VkRenderer *renderer, int width, int height)
+15 -1
View File
@@ -25,6 +25,20 @@
typedef struct VkRenderer VkRenderer;
#define VIDEO_BACKGROUND_TILE_SIZE 64
enum VideoBackgroundType {
VIDEO_BACKGROUND_TILES,
VIDEO_BACKGROUND_COLOR,
VIDEO_BACKGROUND_NONE,
};
typedef struct RenderParams {
SDL_Rect target_rect;
uint8_t video_background_color[4];
enum VideoBackgroundType video_background_type;
} RenderParams;
VkRenderer *vk_get_renderer(void);
int vk_renderer_create(VkRenderer *renderer, SDL_Window *window,
@@ -32,7 +46,7 @@ int vk_renderer_create(VkRenderer *renderer, SDL_Window *window,
int vk_renderer_get_hw_dev(VkRenderer *renderer, AVBufferRef **dev);
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame);
int vk_renderer_display(VkRenderer *renderer, AVFrame *frame, RenderParams *params);
int vk_renderer_resize(VkRenderer *renderer, int width, int height);
+211 -24
View File
@@ -36,6 +36,7 @@
#include "libavutil/ambient_viewing_environment.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/avutil.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/display.h"
@@ -130,6 +131,11 @@ static int use_byte_value_binary_prefix = 0;
static int use_value_sexagesimal_format = 0;
static int show_private_data = 1;
static const char *audio_codec_name = NULL;
static const char *data_codec_name = NULL;
static const char *subtitle_codec_name = NULL;
static const char *video_codec_name = NULL;
#define SHOW_OPTIONAL_FIELDS_AUTO -1
#define SHOW_OPTIONAL_FIELDS_NEVER 0
#define SHOW_OPTIONAL_FIELDS_ALWAYS 1
@@ -138,6 +144,7 @@ static int show_optional_fields = SHOW_OPTIONAL_FIELDS_AUTO;
static char *output_format;
static char *stream_specifier;
static char *show_data_hash;
static char *data_dump_format;
typedef struct ReadInterval {
int id; ///< identifier
@@ -246,7 +253,7 @@ static const char *get_stream_group_type(const void *data)
return av_x_if_null(avformat_stream_group_name(stg->type), "unknown");
}
static struct AVTextFormatSection sections[] = {
static const AVTextFormatSection sections[] = {
[SECTION_ID_CHAPTERS] = { SECTION_ID_CHAPTERS, "chapters", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_CHAPTER, -1 } },
[SECTION_ID_CHAPTER] = { SECTION_ID_CHAPTER, "chapter", 0, { SECTION_ID_CHAPTER_TAGS, -1 } },
[SECTION_ID_CHAPTER_TAGS] = { SECTION_ID_CHAPTER_TAGS, "tags", AV_TEXTFORMAT_SECTION_FLAG_HAS_VARIABLE_FIELDS, { -1 }, .element_name = "tag", .unique_name = "chapter_tags" },
@@ -318,6 +325,13 @@ static struct AVTextFormatSection sections[] = {
[SECTION_ID_SUBTITLE] = { SECTION_ID_SUBTITLE, "subtitle", 0, { -1 } },
};
typedef struct EntrySelection {
int show_all_entries;
AVDictionary *entries_to_show;
} EntrySelection;
static EntrySelection selected_entries[FF_ARRAY_ELEMS(sections)] = { 0 };
static const OptionDef *options;
/* FFprobe context */
@@ -352,6 +366,14 @@ typedef struct LogBuffer {
static LogBuffer *log_buffer;
static int log_buffer_size;
static int is_key_selected_callback(AVTextFormatContext *tctx, const char *key)
{
const AVTextFormatSection *section = tctx->section[tctx->level];
const EntrySelection *selection = &selected_entries[section - sections];
return selection->show_all_entries || av_dict_get(selection->entries_to_show, key, NULL, 0);
}
static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
{
AVClass* avc = ptr ? *(AVClass **) ptr : NULL;
@@ -431,6 +453,30 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
#define print_duration_ts(k, v) avtext_print_ts(tfc, k, v, 1)
#define print_val(k, v, u) avtext_print_unit_integer(tfc, k, v, u)
static void print_integers(AVTextFormatContext *tfc, const char *key,
const void *data, int size, const char *format,
int columns, int bytes, int offset_add)
{
AVBPrint bp;
unsigned offset = 0;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC);
av_bprint_chars(&bp, '\n', 1);
while (size) {
av_bprintf(&bp, "%08x: ", offset);
for (int i = 0, l = FFMIN(size, columns); i < l; i++) {
if (bytes == 1) av_bprintf(&bp, format, *(const uint8_t*)data);
else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
data = (const char*)data + bytes;
size--;
}
av_bprint_chars(&bp, '\n', 1);
offset += offset_add;
}
avtext_print_string(tfc, key, bp.str, 0);
}
#define REALLOCZ_ARRAY_STREAM(ptr, cur_n, new_n) \
{ \
ret = av_reallocp_array(&(ptr), (new_n), sizeof(*(ptr))); \
@@ -462,7 +508,7 @@ static void print_displaymatrix(AVTextFormatContext *tfc, const int32_t matrix[9
double rotation = av_display_rotation_get(matrix);
if (isnan(rotation))
rotation = 0;
avtext_print_integers(tfc, "displaymatrix", (void*)matrix, 9, " %11d", 3, 4, 1);
print_integers(tfc, "displaymatrix", matrix, 9, " %11d", 3, 4, 1);
print_int("rotation", rotation);
}
@@ -1057,6 +1103,12 @@ static void print_pkt_side_data(AVTextFormatContext *tfc,
print_int("crop_right", AV_RL32(sd->data + 12));
} else if (sd->type == AV_PKT_DATA_AFD && sd->size > 0) {
print_int("active_format", *sd->data);
} else if (sd->type == AV_PKT_DATA_EXIF) {
print_int("size", sd->size);
} else if (sd->type == AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL && sd->size >= 8) {
print_int("block_additional_id", AV_RB64(sd->data));
if (do_show_data)
avtext_print_data(tfc, "block_additional_data", sd->data + 8, sd->size - 8);
}
}
@@ -1148,6 +1200,16 @@ static void print_chroma_location(AVTextFormatContext *tfc, enum AVChromaLocatio
}
}
static void print_alpha_mode(AVTextFormatContext *tfc, enum AVAlphaMode alpha_mode)
{
const char *val = av_alpha_mode_name(alpha_mode);
if (!val || alpha_mode == AVALPHA_MODE_UNSPECIFIED) {
print_str_opt("alpha_mode", "unspecified");
} else {
print_str("alpha_mode", val);
}
}
static void clear_log(int need_lock)
{
int i;
@@ -1336,6 +1398,8 @@ static void print_frame_side_data(AVTextFormatContext *tfc,
print_film_grain_params(tfc, fgp);
} else if (sd->type == AV_FRAME_DATA_VIEW_ID) {
print_int("view_id", *(int*)sd->data);
} else if (sd->type == AV_FRAME_DATA_EXIF) {
print_int("size", sd->size);
}
avtext_print_section_footer(tfc);
}
@@ -1400,6 +1464,7 @@ static void show_frame(AVTextFormatContext *tfc, AVFrame *frame, AVStream *strea
print_primaries(tfc, frame->color_primaries);
print_color_trc(tfc, frame->color_trc);
print_chroma_location(tfc, frame->chroma_location);
print_alpha_mode(tfc, frame->alpha_mode);
break;
case AVMEDIA_TYPE_AUDIO:
@@ -1755,6 +1820,10 @@ static int show_stream(AVTextFormatContext *tfc, AVFormatContext *fmt_ctx, int s
print_str("codec_tag_string", av_fourcc2str(par->codec_tag));
print_fmt("codec_tag", "0x%04"PRIx32, par->codec_tag);
av_bprint_clear(&pbuf);
if (!av_mime_codec_str(par, stream->avg_frame_rate, &pbuf))
print_str("mime_codec_string", pbuf.str);
switch (par->codec_type) {
case AVMEDIA_TYPE_VIDEO:
print_int("width", par->width);
@@ -1803,7 +1872,7 @@ static int show_stream(AVTextFormatContext *tfc, AVFormatContext *fmt_ctx, int s
else
print_str_opt("field_order", "unknown");
if (dec_ctx)
if (dec_ctx && do_read_frames)
print_int("refs", dec_ctx->refs);
break;
@@ -2053,6 +2122,10 @@ static void print_iamf_param_definition(AVTextFormatContext *tfc, const char *na
static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVStreamGroup *stg,
const AVIAMFAudioElement *audio_element)
{
AVBPrint pbuf;
av_bprint_init(&pbuf, 1, AV_BPRINT_SIZE_UNLIMITED);
avtext_print_section_header(tfc, stg, SECTION_ID_STREAM_GROUP_COMPONENT);
print_int("nb_layers", audio_element->nb_layers);
print_int("audio_element_type", audio_element->audio_element_type);
@@ -2067,8 +2140,12 @@ static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVSt
if (audio_element->audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_CHANNEL) {
print_int("output_gain_flags", layer->output_gain_flags);
print_q("output_gain", layer->output_gain, '/');
} else if (audio_element->audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE)
} else if (audio_element->audio_element_type == AV_IAMF_AUDIO_ELEMENT_TYPE_SCENE) {
print_int("ambisonics_mode", layer->ambisonics_mode);
if (layer->ambisonics_mode == AV_IAMF_AMBISONICS_MODE_PROJECTION)
print_list_fmt("demixing_matrix", "%d/%d", layer->nb_demixing_matrix, 1, layer->demixing_matrix[idx].num,
layer->demixing_matrix[idx].den);
}
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENT
}
if (audio_element->demixing_info)
@@ -2079,6 +2156,8 @@ static void print_iamf_audio_element_params(AVTextFormatContext *tfc, const AVSt
SECTION_ID_STREAM_GROUP_SUBCOMPONENT);
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_SUBCOMPONENTS
avtext_print_section_footer(tfc); // SECTION_ID_STREAM_GROUP_COMPONENT
av_bprint_finalize(&pbuf, NULL);
}
static void print_iamf_submix_params(AVTextFormatContext *tfc, const AVIAMFSubmix *submix)
@@ -2284,6 +2363,65 @@ static void show_error(AVTextFormatContext *tfc, int err)
avtext_print_section_footer(tfc);
}
static int get_decoder_by_name(const char *codec_name, const AVCodec **codec)
{
if (codec_name == NULL)
return 0;
*codec = avcodec_find_decoder_by_name(codec_name);
if (*codec == NULL) {
av_log(NULL, AV_LOG_ERROR,
"No codec could be found with name '%s'\n", codec_name);
return AVERROR(EINVAL);
}
return 0;
}
static int set_decoders(AVFormatContext *fmt_ctx)
{
int ret;
#define GET_DECODER(type_) \
ret = get_decoder_by_name(type_##_codec_name, &fmt_ctx->type_##_codec); \
if (ret < 0) return ret;
GET_DECODER(audio);
GET_DECODER(data);
GET_DECODER(subtitle);
GET_DECODER(video);
return 0;
}
static const AVCodec *get_decoder_for_stream(AVFormatContext *fmt_ctx, AVStream *stream)
{
const AVCodec *codec = NULL;
switch (stream->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO: codec = fmt_ctx->video_codec; break;
case AVMEDIA_TYPE_AUDIO: codec = fmt_ctx->audio_codec; break;
case AVMEDIA_TYPE_SUBTITLE: codec = fmt_ctx->subtitle_codec; break;
case AVMEDIA_TYPE_DATA: codec = fmt_ctx->data_codec; break;
}
if (codec != NULL)
return codec;
if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
av_log(NULL, AV_LOG_WARNING,
"Failed to probe codec for input stream %d\n", stream->index);
return NULL;
}
codec = avcodec_find_decoder(stream->codecpar->codec_id);
if (codec == NULL) {
av_log(NULL, AV_LOG_WARNING,
"Unsupported codec with id %d for input stream %d\n",
stream->codecpar->codec_id, stream->index);
return NULL;
}
return codec;
}
static int open_input_file(InputFile *ifile, const char *filename,
const char *print_filename)
{
@@ -2296,6 +2434,9 @@ static int open_input_file(InputFile *ifile, const char *filename,
if (!fmt_ctx)
return AVERROR(ENOMEM);
err = set_decoders(fmt_ctx);
if (err < 0)
return err;
if (!av_dict_get(format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
av_dict_set(&format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
scan_all_pmts_set = 1;
@@ -2350,20 +2491,10 @@ static int open_input_file(InputFile *ifile, const char *filename,
ist->st = stream;
if (stream->codecpar->codec_id == AV_CODEC_ID_PROBE) {
av_log(NULL, AV_LOG_WARNING,
"Failed to probe codec for input stream %d\n",
stream->index);
codec = get_decoder_for_stream(fmt_ctx, stream);
if (!codec)
continue;
}
codec = avcodec_find_decoder(stream->codecpar->codec_id);
if (!codec) {
av_log(NULL, AV_LOG_WARNING,
"Unsupported codec with id %d for input stream %d\n",
stream->codecpar->codec_id, stream->index);
continue;
}
{
AVDictionary *opts;
@@ -2510,6 +2641,10 @@ end:
av_freep(&selected_streams);
av_freep(&streams_with_closed_captions);
av_freep(&streams_with_film_grain);
av_freep(&audio_codec_name);
av_freep(&data_codec_name);
av_freep(&subtitle_codec_name);
av_freep(&video_codec_name);
return ret;
}
@@ -2646,14 +2781,15 @@ static int opt_format(void *optctx, const char *opt, const char *arg)
static inline void mark_section_show_entries(SectionID section_id,
int show_all_entries, AVDictionary *entries)
{
struct AVTextFormatSection *section = &sections[section_id];
EntrySelection *selection = &selected_entries[section_id];
section->show_all_entries = show_all_entries;
selection->show_all_entries = show_all_entries;
if (show_all_entries) {
const AVTextFormatSection *section = &sections[section_id];
for (const int *id = section->children_ids; *id != -1; id++)
mark_section_show_entries(*id, show_all_entries, entries);
} else {
av_dict_copy(&section->entries_to_show, entries, 0);
av_dict_copy(&selection->entries_to_show, entries, 0);
}
}
@@ -2964,6 +3100,36 @@ static int opt_sections(void *optctx, const char *opt, const char *arg)
return 0;
}
static int opt_codec(void *optctx, const char *opt, const char *arg)
{
const char *spec = strchr(opt, ':');
const char **name;
if (!spec) {
av_log(NULL, AV_LOG_ERROR,
"No media specifier was specified for '%s' in option '%s'. Use -%s:<media_spec> "
"where <media_spec> can be one of: 'a' (audio), 'v' (video), 's' (subtitle), 'd' (data)\n",
arg, opt, opt);
return AVERROR(EINVAL);
}
spec++;
switch (spec[0]) {
case 'a' : name = &audio_codec_name; break;
case 'd' : name = &data_codec_name; break;
case 's' : name = &subtitle_codec_name; break;
case 'v' : name = &video_codec_name; break;
default:
av_log(NULL, AV_LOG_ERROR,
"Invalid media specifier '%s' in option '%s'. "
"Must be one of: 'a' (audio), 'v' (video), 's' (subtitle), 'd' (data)\n", spec, opt);
return AVERROR(EINVAL);
}
av_freep(name);
*name = av_strdup(arg);
return *name ? 0 : AVERROR(ENOMEM);
}
static int opt_show_versions(void *optctx, const char *opt, const char *arg)
{
mark_section_show_entries(SECTION_ID_PROGRAM_VERSION, 1, NULL);
@@ -3007,6 +3173,7 @@ static const OptionDef real_options[] = {
{ "of", OPT_TYPE_STRING, 0, { &output_format }, "alias for -output_format", "format" },
{ "select_streams", OPT_TYPE_STRING, 0, { &stream_specifier }, "select the specified streams", "stream_specifier" },
{ "sections", OPT_TYPE_FUNC, OPT_EXIT, {.func_arg = opt_sections}, "print sections structure and section information, and exit" },
{ "data_dump_format", OPT_TYPE_STRING, 0, { &data_dump_format }, "set data dump format (available formats are: xxd, base64)" },
{ "show_data", OPT_TYPE_BOOL, 0, { &do_show_data }, "show packets data" },
{ "show_data_hash", OPT_TYPE_STRING, 0, { &show_data_hash }, "show packets data hash" },
{ "show_error", OPT_TYPE_FUNC, 0, { .func_arg = &opt_show_error }, "show probing error" },
@@ -3039,14 +3206,19 @@ static const OptionDef real_options[] = {
{ "print_filename", OPT_TYPE_FUNC, OPT_FUNC_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
{ "find_stream_info", OPT_TYPE_BOOL, OPT_INPUT | OPT_EXPERT, { &find_stream_info },
"read and decode the streams to fill missing information with heuristics" },
{ "c", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_codec}, "force decoder", "decoder_name" },
{ "codec", OPT_TYPE_FUNC, OPT_FUNC_ARG, { .func_arg = opt_codec}, "alias for -c (force decoder)", "decoder_name" },
{ NULL, },
};
static inline int check_section_show_entries(int section_id)
{
struct AVTextFormatSection *section = &sections[section_id];
if (sections[section_id].show_all_entries || sections[section_id].entries_to_show)
const EntrySelection *selection = &selected_entries[section_id];
if (selection->show_all_entries || selection->entries_to_show)
return 1;
const AVTextFormatSection *section = &sections[section_id];
for (const int *id = section->children_ids; *id != -1; id++)
if (check_section_show_entries(*id))
return 1;
@@ -3065,7 +3237,8 @@ int main(int argc, char **argv)
AVTextWriterContext *wctx;
char *buf;
char *f_name = NULL, *f_args = NULL;
int ret, input_ret, i;
int ret, input_ret;
AVTextFormatDataDump data_dump_format_id;
init_dynload();
@@ -3150,6 +3323,18 @@ int main(int argc, char **argv)
goto end;
}
if (data_dump_format) {
if (!strcmp(data_dump_format, "xxd")) {
data_dump_format_id = AV_TEXTFORMAT_DATADUMP_XXD;
} else if (!strcmp(data_dump_format, "base64")) {
data_dump_format_id = AV_TEXTFORMAT_DATADUMP_BASE64;
} else {
av_log(NULL, AV_LOG_ERROR, "Unknown data dump format with name '%s'\n", data_dump_format);
ret = AVERROR(EINVAL);
goto end;
}
}
if (output_filename) {
ret = avtextwriter_create_file(&wctx, output_filename);
} else
@@ -3159,11 +3344,13 @@ int main(int argc, char **argv)
goto end;
AVTextFormatOptions tf_options = {
.is_key_selected = is_key_selected_callback,
.show_optional_fields = show_optional_fields,
.show_value_unit = show_value_unit,
.use_value_prefix = use_value_prefix,
.use_byte_value_binary_prefix = use_byte_value_binary_prefix,
.use_value_sexagesimal_format = use_value_sexagesimal_format,
.data_dump_format = data_dump_format_id,
};
if ((ret = avtext_context_open(&tctx, f, wctx, f_args, sections, FF_ARRAY_ELEMS(sections), tf_options, show_data_hash)) >= 0) {
@@ -3215,8 +3402,8 @@ end:
av_freep(&read_intervals);
uninit_opts();
for (i = 0; i < FF_ARRAY_ELEMS(sections); i++)
av_dict_free(&(sections[i].entries_to_show));
for (size_t i = 0; i < FF_ARRAY_ELEMS(selected_entries); ++i)
av_dict_free(&selected_entries[i].entries_to_show);
avformat_network_deinit();
+8 -28
View File
@@ -74,7 +74,7 @@ typedef enum {
SECTION_ID_ENCODER,
} SectionID;
static struct AVTextFormatSection sections[] = {
static const AVTextFormatSection sections[] = {
[SECTION_ID_ROOT] = { SECTION_ID_ROOT, "root", AV_TEXTFORMAT_SECTION_FLAG_IS_WRAPPER, { SECTION_ID_FILTERGRAPHS, SECTION_ID_INPUTFILES, SECTION_ID_OUTPUTFILES, SECTION_ID_DECODERS, SECTION_ID_ENCODERS, SECTION_ID_STREAMLINKS, -1 } },
[SECTION_ID_FILTERGRAPHS] = { SECTION_ID_FILTERGRAPHS, "graphs", AV_TEXTFORMAT_SECTION_FLAG_IS_ARRAY, { SECTION_ID_FILTERGRAPH, -1 } },
@@ -271,7 +271,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink *link)
}
if (link->w && link->h) {
if (tfc->show_value_unit) {
if (tfc->opts.show_value_unit) {
print_fmt("size", "%dx%d", link->w, link->h);
} else {
print_int("width", link->w);
@@ -292,7 +292,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink *link)
////print_str("format", av_x_if_null(av_get_subtitle_fmt_name(link->format), "?"));
if (link->w && link->h) {
if (tfc->show_value_unit) {
if (tfc->opts.show_value_unit) {
print_fmt("size", "%dx%d", link->w, link->h);
} else {
print_int("width", link->w);
@@ -306,7 +306,7 @@ static void print_link(GraphPrintContext *gpc, AVFilterLink *link)
av_channel_layout_describe(&link->ch_layout, layout_string, sizeof(layout_string));
print_str("channel_layout", layout_string);
print_val("channels", link->ch_layout.nb_channels, "ch");
if (tfc->show_value_unit)
if (tfc->opts.show_value_unit)
print_fmt("sample_rate", "%d.1 kHz", link->sample_rate / 1000);
else
print_val("sample_rate", link->sample_rate, "Hz");
@@ -470,12 +470,6 @@ static void print_filter(GraphPrintContext *gpc, const AVFilterContext *filter,
avtext_print_section_footer(tfc); // SECTION_ID_FILTER
}
static void init_sections(void)
{
for (unsigned i = 0; i < FF_ARRAY_ELEMS(sections); i++)
sections[i].show_all_entries = 1;
}
static void print_filtergraph_single(GraphPrintContext *gpc, FilterGraph *fg, AVFilterGraph *graph)
{
AVTextFormatContext *tfc = gpc->tfc;
@@ -876,7 +870,6 @@ static int init_graphprint(GraphPrintContext **pgpc, AVBPrint *target_buf)
GraphPrintContext *gpc = NULL;
int ret;
init_sections();
*pgpc = NULL;
av_bprint_init(target_buf, 0, AV_BPRINT_SIZE_UNLIMITED);
@@ -919,8 +912,8 @@ static int init_graphprint(GraphPrintContext **pgpc, AVBPrint *target_buf)
gpc->id_prefix_num = atomic_fetch_add(&prefix_num, 1);
gpc->is_diagram = !!(tfc->formatter->flags & AV_TEXTFORMAT_FLAG_IS_DIAGRAM_FORMATTER);
if (gpc->is_diagram) {
tfc->show_value_unit = 1;
tfc->show_optional_fields = -1;
tfc->opts.show_value_unit = 1;
tfc->opts.show_optional_fields = -1;
gpc->opt_flags = AV_TEXTFORMAT_PRINT_STRING_OPTIONAL;
gpc->skip_buffer_filters = 1;
////} else {
@@ -953,16 +946,13 @@ fail:
int print_filtergraph(FilterGraph *fg, AVFilterGraph *graph)
{
av_assert2(fg);
GraphPrintContext *gpc = NULL;
AVTextFormatContext *tfc;
AVBPrint *target_buf = &fg->graph_print_buf;
int ret;
if (!fg) {
av_log(NULL, AV_LOG_ERROR, "Invalid filter graph provided\n");
return AVERROR(EINVAL);
}
if (target_buf->len)
av_bprint_finalize(target_buf, NULL);
@@ -970,11 +960,6 @@ int print_filtergraph(FilterGraph *fg, AVFilterGraph *graph)
if (ret)
return ret;
if (!gpc) {
av_log(NULL, AV_LOG_ERROR, "Failed to initialize graph print context\n");
return AVERROR(ENOMEM);
}
tfc = gpc->tfc;
// Due to the threading model each graph needs to print itself into a buffer
@@ -1011,11 +996,6 @@ static int print_filtergraphs_priv(FilterGraph **graphs, int nb_graphs, InputFil
if (ret)
goto cleanup;
if (!gpc) {
ret = AVERROR(ENOMEM);
goto cleanup;
}
tfc = gpc->tfc;
avtext_print_section_header(tfc, NULL, SECTION_ID_ROOT);
+5 -3
View File
@@ -23,6 +23,7 @@
#include <stdio.h>
#include "cmdutils.h"
#include "fopen_utf8.h"
#include "opt_common.h"
#include "libavutil/avassert.h"
@@ -808,7 +809,8 @@ int show_filters(void *optctx, const char *opt, const char *arg)
" A = Audio input/output\n"
" V = Video input/output\n"
" N = Dynamic number and/or type of input/output\n"
" | = Source or sink filter\n");
" | = Source or sink filter\n"
" ------\n");
while ((filter = av_filter_iterate(&opaque))) {
descr_cur = descr;
for (i = 0; i < 2; i++) {
@@ -990,7 +992,7 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg)
#endif
while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
enum AVPixelFormat av_unused pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
av_unused enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
printf("%c%c%c%c%c %-16s %d %3d %d",
sws_isSupportedInput (pix_fmt) ? 'I' : '.',
sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
@@ -1204,7 +1206,7 @@ int init_report(const char *env, FILE **file)
if (!envlevel)
report_file_level = FFMAX(report_file_level, prog_loglevel);
report_file = fopen(filename.str, "w");
report_file = fopen_utf8(filename.str, "w");
if (!report_file) {
int ret = AVERROR(errno);
av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
+3 -2
View File
@@ -41,9 +41,9 @@ int show_sources(void *optctx, const char *opt, const char *arg);
#if CONFIG_AVDEVICE
#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \
{ "sources" , OPT_TYPE_FUNC, OPT_EXIT | OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = show_sources }, \
{ "sources" , OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT, { .func_arg = show_sources }, \
"list sources of the input device", "device" }, \
{ "sinks" , OPT_TYPE_FUNC, OPT_EXIT | OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = show_sinks }, \
{ "sinks" , OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT, { .func_arg = show_sinks }, \
"list sinks of the output device", "device" }, \
#else
@@ -198,6 +198,7 @@ int opt_cpucount(void *optctx, const char *opt, const char *arg);
#define CMDUTILS_COMMON_OPTIONS \
{ "L", OPT_TYPE_FUNC, OPT_EXIT, { .func_arg = show_license }, "show license" }, \
{ "license", OPT_TYPE_FUNC, OPT_EXIT, { .func_arg = show_license }, "show license" }, \
{ "h", OPT_TYPE_FUNC, OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
{ "?", OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT, { .func_arg = show_help }, "show help", "topic" }, \
{ "help", OPT_TYPE_FUNC, OPT_EXIT | OPT_EXPERT, { .func_arg = show_help }, "show help", "topic" }, \
+2 -3
View File
@@ -1,6 +1,5 @@
*.html.c
*.css.c
*.html.gz
*.css.gz
*.min
*.min.gz
*.css.min
*.css.min.gz
+9 -3
View File
@@ -4,10 +4,16 @@ clean::
vpath %.html $(SRC_PATH)
vpath %.css $(SRC_PATH)
# Uncomment to prevent deletion during build
#.PRECIOUS: %.css.c %.css.min %.css.gz %.css.min.gz %.html.gz %.html.c
OBJS-resman += \
fftools/resources/resman.o \
RESOBJS += \
fftools/resources/graph.html.o \
fftools/resources/graph.css.o \
$(RESOBJS): CCDEP =
$(RESOBJS): CC_DEPFLAGS =
.SECONDARY: $(RESOBJS:.o=.gz) $(RESOBJS:.o=.c) $(RESOBJS:%.css.o=%.css.min) $(RESOBJS:%.css.o=%.css.min.gz) $(RESOBJS:%.html.o=%.html.gz) $(RESOBJS:.o=)
+60 -68
View File
@@ -26,6 +26,7 @@
#include "libavutil/mem.h"
#include "libavutil/avassert.h"
#include "libavutil/base64.h"
#include "libavutil/bprint.h"
#include "libavutil/error.h"
#include "libavutil/hash.h"
@@ -147,11 +148,7 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
goto fail;
}
tctx->show_value_unit = options.show_value_unit;
tctx->use_value_prefix = options.use_value_prefix;
tctx->use_byte_value_binary_prefix = options.use_byte_value_binary_prefix;
tctx->use_value_sexagesimal_format = options.use_value_sexagesimal_format;
tctx->show_optional_fields = options.show_optional_fields;
tctx->opts = options;
if (nb_sections > SECTION_MAX_NB_SECTIONS) {
av_log(tctx, AV_LOG_ERROR, "The number of section definitions (%d) is larger than the maximum allowed (%d)\n", nb_sections, SECTION_MAX_NB_SECTIONS);
@@ -289,23 +286,19 @@ void avtext_print_section_footer(AVTextFormatContext *tctx)
void avtext_print_integer(AVTextFormatContext *tctx, const char *key, int64_t val, int flags)
{
const AVTextFormatSection *section;
av_assert0(tctx);
if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
return;
if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
&& (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
&& !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))
return;
av_assert0(key && tctx->level >= 0 && tctx->level < SECTION_MAX_NB_LEVELS);
section = tctx->section[tctx->level];
if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {
if (!tctx->opts.is_key_selected || tctx->opts.is_key_selected(tctx, key)) {
tctx->formatter->print_integer(tctx, key, val);
tctx->nb_item[tctx->level]++;
}
@@ -391,7 +384,7 @@ static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_si
vali = uv.val.i;
}
if (uv.unit == unit_second_str && tctx->use_value_sexagesimal_format) {
if (uv.unit == unit_second_str && tctx->opts.use_value_sexagesimal_format) {
double secs;
int hours, mins;
secs = vald;
@@ -403,10 +396,10 @@ static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_si
} else {
const char *prefix_string = "";
if (tctx->use_value_prefix && vald > 1) {
if (tctx->opts.use_value_prefix && vald > 1) {
int64_t index;
if (uv.unit == unit_byte_str && tctx->use_byte_value_binary_prefix) {
if (uv.unit == unit_byte_str && tctx->opts.use_byte_value_binary_prefix) {
index = (int64_t)(log2(vald) / 10);
index = av_clip64(index, 0, FF_ARRAY_ELEMS(si_prefixes) - 1);
vald /= si_prefixes[index].bin_val;
@@ -420,13 +413,13 @@ static char *value_string(const AVTextFormatContext *tctx, char *buf, int buf_si
vali = (int64_t)vald;
}
if (show_float || (tctx->use_value_prefix && vald != (int64_t)vald))
if (show_float || (tctx->opts.use_value_prefix && vald != (int64_t)vald))
snprintf(buf, buf_size, "%f", vald);
else
snprintf(buf, buf_size, "%"PRId64, vali);
av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || tctx->show_value_unit ? " " : "",
prefix_string, tctx->show_value_unit ? uv.unit : "");
av_strlcatf(buf, buf_size, "%s%s%s", *prefix_string || tctx->opts.show_value_unit ? " " : "",
prefix_string, tctx->opts.show_value_unit ? uv.unit : "");
}
return buf;
@@ -452,15 +445,15 @@ int avtext_print_string(AVTextFormatContext *tctx, const char *key, const char *
section = tctx->section[tctx->level];
if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER)
return 0;
if (tctx->show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
if (tctx->opts.show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
&& (flags & AV_TEXTFORMAT_PRINT_STRING_OPTIONAL)
&& !(tctx->formatter->flags & AV_TEXTFORMAT_FLAG_SUPPORTS_OPTIONAL_FIELDS))
return 0;
if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {
if (!tctx->opts.is_key_selected || tctx->opts.is_key_selected(tctx, key)) {
if (flags & AV_TEXTFORMAT_PRINT_STRING_VALIDATE) {
char *key1 = NULL, *val1 = NULL;
ret = validate_string(tctx, &key1, key);
@@ -516,30 +509,57 @@ void avtext_print_ts(AVTextFormatContext *tctx, const char *key, int64_t ts, int
avtext_print_integer(tctx, key, ts, 0);
}
static void print_data_xxd(AVBPrint *bp, const uint8_t *data, int size)
{
unsigned offset = 0;
int i;
av_bprintf(bp, "\n");
while (size) {
av_bprintf(bp, "%08x: ", offset);
int l = FFMIN(size, 16);
for (i = 0; i < l; i++) {
av_bprintf(bp, "%02x", data[i]);
if (i & 1)
av_bprintf(bp, " ");
}
av_bprint_chars(bp, ' ', 41 - 2 * i - i / 2);
for (i = 0; i < l; i++)
av_bprint_chars(bp, data[i] - 32U < 95 ? data[i] : '.', 1);
av_bprintf(bp, "\n");
offset += l;
data += l;
size -= l;
}
}
static void print_data_base64(AVBPrint *bp, const uint8_t *data, int size)
{
char buf[AV_BASE64_SIZE(60)];
av_bprintf(bp, "\n");
while (size) {
int l = FFMIN(size, 60);
av_base64_encode(buf, sizeof(buf), data, l);
av_bprintf(bp, "%s\n", buf);
data += l;
size -= l;
}
}
void avtext_print_data(AVTextFormatContext *tctx, const char *key,
const uint8_t *data, int size)
{
AVBPrint bp;
unsigned offset = 0;
int i;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprintf(&bp, "\n");
while (size) {
av_bprintf(&bp, "%08x: ", offset);
int l = FFMIN(size, 16);
for (i = 0; i < l; i++) {
av_bprintf(&bp, "%02x", data[i]);
if (i & 1)
av_bprintf(&bp, " ");
}
av_bprint_chars(&bp, ' ', 41 - 2 * i - i / 2);
for (i = 0; i < l; i++)
av_bprint_chars(&bp, data[i] - 32U < 95 ? data[i] : '.', 1);
av_bprintf(&bp, "\n");
offset += l;
data += l;
size -= l;
switch (tctx->opts.data_dump_format) {
case AV_TEXTFORMAT_DATADUMP_XXD:
print_data_xxd(&bp, data, size);
break;
case AV_TEXTFORMAT_DATADUMP_BASE64:
print_data_base64(&bp, data, size);
break;
default:
av_unreachable("Invalid data dump type");
}
avtext_print_string(tctx, key, bp.str, 0);
av_bprint_finalize(&bp, NULL);
@@ -561,34 +581,6 @@ void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key,
avtext_print_string(tctx, key, buf, 0);
}
void avtext_print_integers(AVTextFormatContext *tctx, const char *key,
uint8_t *data, int size, const char *format,
int columns, int bytes, int offset_add)
{
AVBPrint bp;
unsigned offset = 0;
if (!key || !data || !format || columns <= 0 || bytes <= 0)
return;
av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprintf(&bp, "\n");
while (size) {
av_bprintf(&bp, "%08x: ", offset);
for (int i = 0, l = FFMIN(size, columns); i < l; i++) {
if (bytes == 1) av_bprintf(&bp, format, *data);
else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data));
else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data));
data += bytes;
size--;
}
av_bprintf(&bp, "\n");
offset += offset_add;
}
avtext_print_string(tctx, key, bp.str, 0);
av_bprint_finalize(&bp, NULL);
}
static const char *writercontext_get_writer_name(void *p)
{
AVTextWriterContext *wctx = p;
+24 -18
View File
@@ -57,9 +57,7 @@ typedef struct AVTextFormatSection {
const int children_ids[SECTION_MAX_NB_CHILDREN + 1]; ///< list of children section IDS, terminated by -1
const char *element_name; ///< name of the contained element, if provided
const char *unique_name; ///< unique section name, in case the name is ambiguous
AVDictionary *entries_to_show;
const char *(*get_type)(const void *data); ///< function returning a type if defined, must be defined when SECTION_FLAG_HAS_TYPE is defined
int show_all_entries;
const char *id_key; ///< name of the key to be used as the id
const char *src_id_key; ///< name of the key to be used as the source id for diagram connections
const char *dest_id_key; ///< name of the key to be used as the target id for diagram connections
@@ -91,6 +89,11 @@ typedef enum {
AV_TEXTFORMAT_LINKTYPE_MANYTOMANY = AV_TEXTFORMAT_LINKTYPE_NONDIR,
} AVTextFormatLinkType;
typedef enum {
AV_TEXTFORMAT_DATADUMP_XXD,
AV_TEXTFORMAT_DATADUMP_BASE64,
} AVTextFormatDataDump;
typedef struct AVTextFormatter {
const AVClass *priv_class; ///< private class of the formatter, if any
int priv_size; ///< private size for the formatter context
@@ -109,6 +112,24 @@ typedef struct AVTextFormatter {
#define SECTION_MAX_NB_LEVELS 12
#define SECTION_MAX_NB_SECTIONS 100
typedef struct AVTextFormatOptions {
/**
* Callback to discard certain elements based upon the key used.
* It is called before any element with a key is printed.
* If this callback is unset, all elements are printed.
*
* @retval 1 if the element is supposed to be printed
* @retval 0 if the element is supposed to be discarded
*/
int (*is_key_selected)(struct AVTextFormatContext *tctx, const char *key);
int show_optional_fields;
int show_value_unit;
int use_value_prefix;
int use_byte_value_binary_prefix;
int use_value_sexagesimal_format;
AVTextFormatDataDump data_dump_format;
} AVTextFormatOptions;
struct AVTextFormatContext {
const AVClass *class; ///< class of the formatter
const AVTextFormatter *formatter; ///< the AVTextFormatter of which this is an instance
@@ -131,11 +152,7 @@ struct AVTextFormatContext {
AVBPrint section_pbuf[SECTION_MAX_NB_LEVELS]; ///< generic print buffer dedicated to each section,
/// used by various formatters
int show_optional_fields;
int show_value_unit;
int use_value_prefix;
int use_byte_value_binary_prefix;
int use_value_sexagesimal_format;
AVTextFormatOptions opts;
struct AVHashContext *hash;
@@ -144,14 +161,6 @@ struct AVTextFormatContext {
unsigned int string_validation_utf8_flags;
};
typedef struct AVTextFormatOptions {
int show_optional_fields;
int show_value_unit;
int use_value_prefix;
int use_byte_value_binary_prefix;
int use_value_sexagesimal_format;
} AVTextFormatOptions;
#define AV_TEXTFORMAT_PRINT_STRING_OPTIONAL 1
#define AV_TEXTFORMAT_PRINT_STRING_VALIDATE 2
@@ -181,9 +190,6 @@ void avtext_print_data(AVTextFormatContext *tctx, const char *key, const uint8_t
void avtext_print_data_hash(AVTextFormatContext *tctx, const char *key, const uint8_t *data, int size);
void avtext_print_integers(AVTextFormatContext *tctx, const char *key, uint8_t *data, int size,
const char *format, int columns, int bytes, int offset_add);
const AVTextFormatter *avtext_get_formatter_by_name(const char *name);
extern const AVTextFormatter avtextformatter_default;
+20 -17
View File
@@ -27,10 +27,9 @@
#include "avtextformat.h"
#include "tf_internal.h"
#include "tf_mermaid.h"
#include <libavutil/mem.h>
#include <libavutil/avassert.h>
#include <libavutil/bprint.h>
#include <libavutil/opt.h>
#include "libavutil/bprint.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
static const char *init_directive = ""
@@ -241,6 +240,20 @@ static void set_str(const char **dst, const char *src)
*dst = av_strdup(src);
}
static void mermaid_subgraph_complete_start(MermaidContext *mmc, AVTextFormatContext *tfc, int level) {
struct section_data parent_sec_data = mmc->section_data[level];
AVBPrint *parent_buf = &tfc->section_pbuf[level];
if (parent_sec_data.subgraph_start_incomplete) {
if (parent_buf->len > 0)
writer_printf(tfc, "%s", parent_buf->str);
writer_put_str(tfc, "</div>\"]\n");
mmc->section_data[level].subgraph_start_incomplete = 0;
}
}
#define MM_INDENT() writer_printf(tfc, "%*c", mmc->indent_level * 2, ' ')
static void mermaid_print_section_header(AVTextFormatContext *tfc, const void *data)
@@ -297,19 +310,7 @@ static void mermaid_print_section_header(AVTextFormatContext *tfc, const void *d
}
if (parent_section && parent_section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_SUBGRAPH) {
struct section_data parent_sec_data = mmc->section_data[tfc->level - 1];
AVBPrint *parent_buf = &tfc->section_pbuf[tfc->level - 1];
if (parent_sec_data.subgraph_start_incomplete) {
if (parent_buf->len > 0)
writer_printf(tfc, "%s", parent_buf->str);
writer_put_str(tfc, "</div>\"]\n");
mmc->section_data[tfc->level - 1].subgraph_start_incomplete = 0;
}
mermaid_subgraph_complete_start(mmc, tfc, tfc->level - 1);
}
av_freep(&mmc->section_data[tfc->level].section_id);
@@ -455,6 +456,8 @@ static void mermaid_print_section_footer(AVTextFormatContext *tfc)
} else if ((section->flags & AV_TEXTFORMAT_SECTION_FLAG_IS_SUBGRAPH)) {
mermaid_subgraph_complete_start(mmc, tfc, tfc->level);
MM_INDENT();
writer_put_str(tfc, "end\n");
+2 -2
View File
@@ -64,8 +64,8 @@ static av_cold int xml_init(AVTextFormatContext *wctx)
return AVERROR(EINVAL); \
}
////CHECK_COMPLIANCE(show_private_data, "private");
CHECK_COMPLIANCE(wctx->show_value_unit, "unit");
CHECK_COMPLIANCE(wctx->use_value_prefix, "prefix");
CHECK_COMPLIANCE(wctx->opts.show_value_unit, "unit");
CHECK_COMPLIANCE(wctx->opts.use_value_prefix, "prefix");
}
return 0;
+17
View File
@@ -38,6 +38,7 @@ enum {
};
struct ThreadQueue {
int choked;
int *finished;
unsigned int nb_streams;
@@ -157,6 +158,9 @@ static int receive_locked(ThreadQueue *tq, int *stream_idx,
{
unsigned int nb_finished = 0;
if (tq->choked)
return AVERROR(EAGAIN);
while (av_container_fifo_read(tq->fifo, data, 0) >= 0) {
unsigned idx;
int ret;
@@ -230,6 +234,7 @@ void tq_send_finish(ThreadQueue *tq, unsigned int stream_idx)
* next time the consumer thread tries to read this stream it will get
* an EOF and recv-finished flag will be set */
tq->finished[stream_idx] |= FINISHED_SEND;
tq->choked = 0;
pthread_cond_broadcast(&tq->cond);
pthread_mutex_unlock(&tq->lock);
@@ -249,3 +254,15 @@ void tq_receive_finish(ThreadQueue *tq, unsigned int stream_idx)
pthread_mutex_unlock(&tq->lock);
}
void tq_choke(ThreadQueue *tq, int choked)
{
pthread_mutex_lock(&tq->lock);
int prev_choked = tq->choked;
tq->choked = choked;
if (choked != prev_choked)
pthread_cond_broadcast(&tq->cond);
pthread_mutex_unlock(&tq->lock);
}
+9
View File
@@ -58,6 +58,15 @@ int tq_send(ThreadQueue *tq, unsigned int stream_idx, void *data);
*/
void tq_send_finish(ThreadQueue *tq, unsigned int stream_idx);
/**
* Prevent further reads from the thread queue until it is unchoked. Threads
* attempting to read from the queue will block, similar to when the queue is
* empty.
*
* @param choked 1 to choke, 0 to unchoke
*/
void tq_choke(ThreadQueue *tq, int choked);
/**
* Read the next item from the queue.
*
-2
View File
@@ -198,7 +198,6 @@ const FFCodec ff_eightsvx_fib_decoder = {
FF_CODEC_DECODE_CB(eightsvx_decode_frame),
.close = eightsvx_decode_close,
.p.capabilities = AV_CODEC_CAP_DR1,
CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_U8P),
};
#endif
#if CONFIG_EIGHTSVX_EXP_DECODER
@@ -212,6 +211,5 @@ const FFCodec ff_eightsvx_exp_decoder = {
FF_CODEC_DECODE_CB(eightsvx_decode_frame),
.close = eightsvx_decode_close,
.p.capabilities = AV_CODEC_CAP_DR1,
CODEC_SAMPLEFMTS(AV_SAMPLE_FMT_U8P),
};
#endif
+51 -26
View File
@@ -15,6 +15,7 @@ HEADERS = ac3_parser.h \
dirac.h \
dv_profile.h \
dxva2.h \
exif.h \
jni.h \
mediacodec.h \
packet.h \
@@ -42,10 +43,10 @@ OBJS = ac3_parser.o \
dirac.o \
dv_profile.o \
encode.o \
exif.o \
get_buffer.o \
imgconvert.o \
jni.o \
lcevcdec.o \
mathtables.o \
mediacodec.o \
mpeg12framerate.o \
@@ -56,6 +57,7 @@ OBJS = ac3_parser.o \
qsv_api.o \
raw.o \
threadprogress.o \
tiff_common.o \
utils.o \
version.o \
vlc.o \
@@ -86,9 +88,10 @@ OBJS-$(CONFIG_CABAC) += cabac.o
OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o
OBJS-$(CONFIG_CBS_APV) += cbs_apv.o
OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
OBJS-$(CONFIG_CBS_H264) += cbs_h2645.o cbs_sei.o h2645_parse.o
OBJS-$(CONFIG_CBS_H265) += cbs_h2645.o cbs_sei.o h2645_parse.o
OBJS-$(CONFIG_CBS_H266) += cbs_h2645.o cbs_sei.o h2645_parse.o
OBJS-$(CONFIG_CBS_H264) += cbs_h264.o cbs_h2645.o cbs_sei.o h2645_parse.o
OBJS-$(CONFIG_CBS_H265) += cbs_h265.o cbs_h2645.o cbs_sei.o h2645_parse.o
OBJS-$(CONFIG_CBS_H266) += cbs_h266.o cbs_h2645.o cbs_sei.o h2645_parse.o
OBJS-$(CONFIG_CBS_LCEVC) += cbs_lcevc.o cbs_h2645.o cbs_sei.o h2645_parse.o
OBJS-$(CONFIG_CBS_JPEG) += cbs_jpeg.o
OBJS-$(CONFIG_CBS_MPEG2) += cbs_mpeg2.o
OBJS-$(CONFIG_CBS_VP8) += cbs_vp8.o vp8data.o
@@ -100,7 +103,6 @@ OBJS-$(CONFIG_DOVI_RPUDEC) += dovi_rpu.o dovi_rpudec.o
OBJS-$(CONFIG_DOVI_RPUENC) += dovi_rpu.o dovi_rpuenc.o
OBJS-$(CONFIG_ERROR_RESILIENCE) += error_resilience.o
OBJS-$(CONFIG_EVCPARSE) += evc_parse.o evc_ps.o
OBJS-$(CONFIG_EXIF) += exif.o tiff_common.o
OBJS-$(CONFIG_FAANDCT) += faandct.o
OBJS-$(CONFIG_FAANIDCT) += faanidct.o
OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o jfdctfst.o jfdctint.o
@@ -128,6 +130,7 @@ OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o
OBJS-$(CONFIG_JNI) += ffjni.o jni.o
OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o
OBJS-$(CONFIG_LCMS2) += fflcms2.o
OBJS-$(CONFIG_LIBLCEVC_DEC) += lcevcdec.o
OBJS-$(CONFIG_LLAUDDSP) += lossless_audiodsp.o
OBJS-$(CONFIG_LLVIDDSP) += lossless_videodsp.o
OBJS-$(CONFIG_LLVIDENCDSP) += lossless_videoencdsp.o
@@ -156,7 +159,7 @@ OBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideo_enc.o mpeg12data.o \
motion_est.o ratecontrol.o
OBJS-$(CONFIG_MPEGVIDEOENCDSP) += mpegvideoencdsp.o
OBJS-$(CONFIG_MSMPEG4DEC) += msmpeg4dec.o msmpeg4.o msmpeg4data.o \
msmpeg4_vc1_data.o
msmpeg4_vc1_data.o mpeg4videodec.o
OBJS-$(CONFIG_MSMPEG4ENC) += msmpeg4enc.o msmpeg4.o msmpeg4data.o \
msmpeg4_vc1_data.o
OBJS-$(CONFIG_MSS34DSP) += mss34dsp.o jpegquanttables.o
@@ -180,7 +183,6 @@ OBJS-$(CONFIG_AV1_AMF_DECODER) += amfdec.o
OBJS-$(CONFIG_VC1DSP) += vc1dsp.o
OBJS-$(CONFIG_VIDEODSP) += videodsp.o
OBJS-$(CONFIG_VP3DSP) += vp3dsp.o
OBJS-$(CONFIG_VP56DSP) += vp56dsp.o
OBJS-$(CONFIG_VP8DSP) += vp8dsp.o
OBJS-$(CONFIG_V4L2_M2M) += v4l2_m2m.o v4l2_context.o v4l2_buffers.o v4l2_fmt.o
OBJS-$(CONFIG_WMA_FREQS) += wma_freqs.o
@@ -193,11 +195,13 @@ OBJS-$(CONFIG_A64MULTI5_ENCODER) += a64multienc.o elbg.o
OBJS-$(CONFIG_AAC_DECODER) += aactab.o \
aacsbr.o aacps_common.o aacps_float.o \
kbdwin.o \
sbrdsp.o aacpsdsp_float.o cbrt_data.o
sbrdsp.o aacpsdsp_float.o cbrt_data.o \
$(if $(!CONFIG_HARDCODED_TABLES), cbrt_tablegen_common.o)
OBJS-$(CONFIG_AAC_FIXED_DECODER) += aactab.o \
aacsbr_fixed.o aacps_common.o aacps_fixed.o \
kbdwin.o \
sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o
sbrdsp_fixed.o aacpsdsp_fixed.o cbrt_data_fixed.o \
$(if $(!CONFIG_HARDCODED_TABLES), cbrt_tablegen_common.o)
OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o aacenctab.o \
aacpsy.o aactab.o \
aacenc_is.o \
@@ -217,6 +221,7 @@ OBJS-$(CONFIG_AC3_FIXED_ENCODER) += ac3enc_fixed.o ac3enc.o ac3tab.o ac3.o
OBJS-$(CONFIG_AC3_MF_ENCODER) += mfenc.o mf_utils.o
OBJS-$(CONFIG_ACELP_KELVIN_DECODER) += g729dec.o lsp.o celp_filters.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o g729postfilter.o
OBJS-$(CONFIG_AGM_DECODER) += agm.o jpegquanttables.o
OBJS-$(CONFIG_AHX_DECODER) += mpegaudiodec_float.o
OBJS-$(CONFIG_AIC_DECODER) += aic.o
OBJS-$(CONFIG_ALAC_DECODER) += alac.o alac_data.o alacdsp.o
OBJS-$(CONFIG_ALAC_ENCODER) += alacenc.o alac_data.o
@@ -269,6 +274,7 @@ OBJS-$(CONFIG_AURA_DECODER) += cyuv.o
OBJS-$(CONFIG_AURA2_DECODER) += aura.o
OBJS-$(CONFIG_AV1_DECODER) += av1dec.o av1_parse.o
OBJS-$(CONFIG_AV1_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_AV1_D3D12VA_ENCODER) += d3d12va_encode_av1.o av1_levels.o
OBJS-$(CONFIG_AV1_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_AV1_MEDIACODEC_ENCODER) += mediacodecenc.o
OBJS-$(CONFIG_AV1_NVENC_ENCODER) += nvenc_av1.o nvenc.o
@@ -427,6 +433,8 @@ OBJS-$(CONFIG_H264_DECODER) += h264dec.o h264_cabac.o h264_cavlc.o \
OBJS-$(CONFIG_H264_AMF_ENCODER) += amfenc_h264.o
OBJS-$(CONFIG_H264_AMF_DECODER) += amfdec.o
OBJS-$(CONFIG_H264_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_H264_D3D12VA_ENCODER) += d3d12va_encode_h264.o h264_levels.o \
h2645data.o hw_base_encode_h264.o
OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_H264_MEDIACODEC_ENCODER) += mediacodecenc.o
OBJS-$(CONFIG_H264_MF_ENCODER) += mfenc.o mf_utils.o
@@ -438,6 +446,7 @@ OBJS-$(CONFIG_H264_OMX_ENCODER) += omx.o
OBJS-$(CONFIG_H264_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_H264_QSV_ENCODER) += qsvenc_h264.o
OBJS-$(CONFIG_H264_RKMPP_DECODER) += rkmppdec.o
OBJS-$(CONFIG_H264_RKMPP_ENCODER) += rkmppenc.o
OBJS-$(CONFIG_H264_VAAPI_ENCODER) += vaapi_encode_h264.o h264_levels.o \
h2645data.o hw_base_encode_h264.o
OBJS-$(CONFIG_H264_VULKAN_ENCODER) += vulkan_encode.o vulkan_encode_h264.o \
@@ -467,6 +476,7 @@ OBJS-$(CONFIG_HEVC_OH_ENCODER) += ohcodec.o ohenc.o
OBJS-$(CONFIG_HEVC_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_HEVC_QSV_ENCODER) += qsvenc_hevc.o hevc/ps_enc.o
OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o
OBJS-$(CONFIG_HEVC_RKMPP_ENCODER) += rkmppenc.o
OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o h265_profile_level.o \
h2645data.o hw_base_encode_h265.o
OBJS-$(CONFIG_HEVC_VULKAN_ENCODER) += vulkan_encode.o vulkan_encode_h265.o \
@@ -559,19 +569,20 @@ OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o
OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o
OBJS-$(CONFIG_MPEGVIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG1VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o
OBJS-$(CONFIG_MPEG1_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_MPEG1_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_MPEG2_MMAL_DECODER) += mmaldec.o
OBJS-$(CONFIG_MPEG2_QSV_DECODER) += qsvdec.o
OBJS-$(CONFIG_MPEG2_QSV_ENCODER) += qsvenc_mpeg2.o
OBJS-$(CONFIG_MPEG2VIDEO_DECODER) += mpeg12dec.o mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12.o
OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o
OBJS-$(CONFIG_MPEG2_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_MPEG2_MEDIACODEC_DECODER) += mediacodecdec.o
OBJS-$(CONFIG_MPEG2_VAAPI_ENCODER) += vaapi_encode_mpeg2.o
OBJS-$(CONFIG_MPEG2_V4L2M2M_DECODER) += v4l2_m2m_dec.o
OBJS-$(CONFIG_MPEG4_DECODER) += mpeg4videodsp.o xvididct.o
OBJS-$(CONFIG_MPEG4_DECODER) += mpeg4videodec.o mpeg4videodsp.o \
xvididct.o
OBJS-$(CONFIG_MPEG4_ENCODER) += mpeg4videoenc.o
OBJS-$(CONFIG_MPEG4_CUVID_DECODER) += cuviddec.o
OBJS-$(CONFIG_MPEG4_MEDIACODEC_DECODER) += mediacodecdec.o
@@ -636,8 +647,9 @@ OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o
OBJS-$(CONFIG_PRORES_DECODER) += proresdec.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o proresdata.o
OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o proresdata.o
OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o
OBJS-$(CONFIG_PRORES_RAW_DECODER) += prores_raw.o
OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o proresenc_kostya_common.o
OBJS-$(CONFIG_PRORES_KS_VULKAN_ENCODER) += proresenc_kostya_vulkan.o proresdata.o proresenc_kostya_common.o
OBJS-$(CONFIG_PRORES_RAW_DECODER) += prores_raw.o proresdsp.o proresdata.o
OBJS-$(CONFIG_PRORES_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o
OBJS-$(CONFIG_PROSUMER_DECODER) += prosumer.o
OBJS-$(CONFIG_PSD_DECODER) += psd.o
@@ -795,7 +807,8 @@ OBJS-$(CONFIG_VORBIS_DECODER) += vorbisdec.o vorbisdsp.o vorbis.o \
OBJS-$(CONFIG_VORBIS_ENCODER) += vorbisenc.o vorbis.o \
vorbis_data.o
OBJS-$(CONFIG_VP3_DECODER) += vp3.o jpegquanttables.o
OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vpx_rac.o
OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o \
vp5dsp.o vpx_rac.o
OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o \
vp6dsp.o vpx_rac.o
OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp8data.o vpx_rac.o
@@ -843,8 +856,8 @@ OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o wma_common.o aactab.o
OBJS-$(CONFIG_WMAVOICE_DECODER) += wmavoice.o \
celp_filters.o \
acelp_vectors.o acelp_filters.o
OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o wmv2data.o
OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o wmv2data.o
OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2data.o
OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2data.o
OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o
OBJS-$(CONFIG_WRAPPED_AVFRAME_DECODER) += wrapped_avframe.o
OBJS-$(CONFIG_WRAPPED_AVFRAME_ENCODER) += wrapped_avframe.o
@@ -953,6 +966,7 @@ OBJS-$(CONFIG_ADPCM_AGM_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_AICA_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_ARGO_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_ARGO_ENCODER) += adpcm.o adpcm_data.o adpcmenc.o
OBJS-$(CONFIG_ADPCM_CIRCUS_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_CT_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_DTK_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_EA_DECODER) += adpcm.o adpcm_data.o
@@ -981,9 +995,14 @@ OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_EA_SEAD_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_ESCAPE_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_HVQM2_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_HVQM4_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_ISS_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_MAGIX_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_MOFLEX_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_MTF_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_PDA_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_OKI_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER) += adpcmenc.o adpcm_data.o
@@ -999,7 +1018,9 @@ OBJS-$(CONFIG_ADPCM_IMA_XBOX_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_MS_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_MS_ENCODER) += adpcmenc.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_MTAF_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_N64_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_PSX_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_PSXC_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_SANYO_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_SBPRO_2_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_SBPRO_3_DECODER) += adpcm.o adpcm_data.o
@@ -1008,7 +1029,7 @@ OBJS-$(CONFIG_ADPCM_SWF_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_SWF_ENCODER) += adpcmenc.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_THP_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_THP_LE_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_VIMA_DECODER) += vima.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_VIMA_DECODER) += vima.o adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_XA_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_XMD_DECODER) += adpcm.o adpcm_data.o
OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o adpcm_data.o
@@ -1033,6 +1054,7 @@ OBJS-$(CONFIG_AV1_VAAPI_HWACCEL) += vaapi_av1.o
OBJS-$(CONFIG_AV1_VDPAU_HWACCEL) += vdpau_av1.o
OBJS-$(CONFIG_AV1_VIDEOTOOLBOX_HWACCEL) += videotoolbox_av1.o
OBJS-$(CONFIG_AV1_VULKAN_HWACCEL) += vulkan_decode.o vulkan_av1.o
OBJS-$(CONFIG_DPX_VULKAN_HWACCEL) += vulkan_decode.o vulkan_dpx.o
OBJS-$(CONFIG_FFV1_VULKAN_HWACCEL) += vulkan_decode.o ffv1_vulkan.o vulkan_ffv1.o
OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o
OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
@@ -1090,6 +1112,7 @@ OBJS-$(CONFIG_VP9_VULKAN_HWACCEL) += vulkan_decode.o vulkan_vp9.o
OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o
OBJS-$(CONFIG_VVC_VAAPI_HWACCEL) += vaapi_vvc.o
OBJS-$(CONFIG_PRORES_RAW_VULKAN_HWACCEL) += vulkan_decode.o vulkan_prores_raw.o
OBJS-$(CONFIG_PRORES_VULKAN_HWACCEL) += vulkan_decode.o vulkan_prores.o
# Objects duplicated from other libraries for shared builds
SHLIBOBJS += log2_tab.o reverse.o
@@ -1167,6 +1190,7 @@ OBJS-$(CONFIG_LIBKVAZAAR_ENCODER) += libkvazaar.o
OBJS-$(CONFIG_LIBLC3_ENCODER) += liblc3enc.o
OBJS-$(CONFIG_LIBLC3_DECODER) += liblc3dec.o
OBJS-$(CONFIG_LIBMP3LAME_ENCODER) += libmp3lame.o
OBJS-$(CONFIG_LIBMPEGHDEC_DECODER) += libmpeghdec.o
OBJS-$(CONFIG_LIBOAPV_ENCODER) += liboapvenc.o
OBJS-$(CONFIG_LIBOPENCORE_AMRNB_DECODER) += libopencore-amr.o
OBJS-$(CONFIG_LIBOPENCORE_AMRNB_ENCODER) += libopencore-amr.o
@@ -1184,6 +1208,8 @@ OBJS-$(CONFIG_LIBSHINE_ENCODER) += libshine.o
OBJS-$(CONFIG_LIBSPEEX_DECODER) += libspeexdec.o
OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o
OBJS-$(CONFIG_LIBSVTAV1_ENCODER) += libsvtav1.o
OBJS-$(CONFIG_LIBSVTJPEGXS_DECODER) += libsvtjpegxsdec.o
OBJS-$(CONFIG_LIBSVTJPEGXS_ENCODER) += libsvtjpegxsenc.o
OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o
OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
OBJS-$(CONFIG_LIBUAVS3D_DECODER) += libuavs3d.o
@@ -1214,6 +1240,7 @@ OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o
OBJS-$(CONFIG_AC3_PARSER) += aac_ac3_parser.o ac3tab.o \
ac3_channel_layout_tab.o
OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o
OBJS-$(CONFIG_AHX_PARSER) += ahx_parser.o
OBJS-$(CONFIG_AMR_PARSER) += amr_parser.o
OBJS-$(CONFIG_APV_PARSER) += apv_parser.o
OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o av1_parse.o
@@ -1249,20 +1276,22 @@ OBJS-$(CONFIG_HDR_PARSER) += hdr_parser.o
OBJS-$(CONFIG_IPU_PARSER) += ipu_parser.o
OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
OBJS-$(CONFIG_JPEGXL_PARSER) += jpegxl_parser.o jpegxl_parse.o
OBJS-$(CONFIG_JPEGXS_PARSER) += jpegxs_parser.o
OBJS-$(CONFIG_LCEVC_PARSER) += lcevc_parser.o
OBJS-$(CONFIG_MISC4_PARSER) += misc4_parser.o
OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o
OBJS-$(CONFIG_MLP_PARSER) += mlp_parse.o mlp_parser.o mlp.o
OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \
mpeg4videodec.o mpeg4video.o \
ituh263dec.o h263dec.o h263data.o
ituh263dec.o h263data.o
OBJS-$(CONFIG_MPEGAUDIO_PARSER) += mpegaudio_parser.o
OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o \
mpeg12.o mpeg12data.o
OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o mpeg12data.o
OBJS-$(CONFIG_OPUS_PARSER) += vorbis_data.o
OBJS-$(CONFIG_PNG_PARSER) += png_parser.o
OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o
OBJS-$(CONFIG_PRORES_RAW_PARSER) += prores_raw_parser.o
OBJS-$(CONFIG_QOI_PARSER) += qoi_parser.o
OBJS-$(CONFIG_PRORES_PARSER) += prores_parser.o
OBJS-$(CONFIG_RV34_PARSER) += rv34_parser.o
OBJS-$(CONFIG_SBC_PARSER) += sbc_parser.o
OBJS-$(CONFIG_SIPR_PARSER) += sipr_parser.o
@@ -1294,10 +1323,6 @@ OBJS-$(HAVE_THREADS) += pthread.o pthread_slice.o pthread_fram
OBJS-$(CONFIG_FRAME_THREAD_ENCODER) += frame_thread_encoder.o
# vulkan libs
OBJS-$(CONFIG_LIBGLSLANG) += vulkan_glslang.o
OBJS-$(CONFIG_LIBSHADERC) += vulkan_shaderc.o
# Windows resource file
SHLIBOBJS-$(HAVE_GNU_WINDRES) += avcodecres.o
@@ -1332,7 +1357,7 @@ SKIPHEADERS-$(CONFIG_QSVENC) += qsvenc.h
SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_decode.h vaapi_hevc.h vaapi_encode.h
SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h
SKIPHEADERS-$(CONFIG_VULKAN) += ffv1_vulkan.h vulkan_video.h \
SKIPHEADERS-$(CONFIG_VULKAN) += ffv1_vulkan.h prores_vulkan.h vulkan_video.h \
vulkan_encode.h vulkan_decode.h
SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h
SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
+4
View File
@@ -36,6 +36,10 @@
#define TNS_MAX_ORDER 20
#define MAX_LTP_LONG_SFB 40
#define MPS_MAX_PARAM_SETS 9
#define MPS_MAX_PARAM_BANDS 28
#define MPS_MAX_TIME_SLOTS 16 /* 64 in non-AAC MPEG Surround */
enum RawDataBlockType {
TYPE_SCE,
TYPE_CPE,
+2 -1
View File
@@ -3,6 +3,7 @@ clean::
OBJS-$(CONFIG_AAC_DECODER) += aac/aacdec.o aac/aacdec_tab.o \
aac/aacdec_float.o aac/aacdec_usac.o \
aac/aacdec_ac.o aac/aacdec_lpd.o
aac/aacdec_ac.o aac/aacdec_lpd.o \
aac/aacdec_usac_mps212.o
OBJS-$(CONFIG_AAC_FIXED_DECODER) += aac/aacdec.o aac/aacdec_tab.o \
aac/aacdec_fixed.o
+34 -3
View File
@@ -62,6 +62,7 @@
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "libavutil/version.h"
#include "libavutil/refstruct.h"
/*
* supported tools
@@ -163,6 +164,12 @@ static av_cold int che_configure(AACDecContext *ac,
}
} else {
if (ac->che[type][id]) {
for (int i = 0; i < FF_ARRAY_ELEMS(ac->tag_che_map); i++) {
for (int j = 0; j < MAX_ELEM_ID; j++) {
if (ac->tag_che_map[i][j] == ac->che[type][id])
ac->tag_che_map[i][j] = NULL;
}
}
ac->proc.sbr_ctx_close(ac->che[type][id]);
}
av_freep(&ac->che[type][id]);
@@ -421,6 +428,26 @@ static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
return layout;
}
static void copy_oc(OutputConfiguration *dst, OutputConfiguration *src)
{
int i;
for (i = 0; i < src->usac.nb_elems; i++) {
AACUsacElemConfig *src_e = &src->usac.elems[i];
AACUsacElemConfig *dst_e = &dst->usac.elems[i];
/* dst_e->ext.pl_buf is guaranteed to be set to src_e->ext.pl_buf
* upon this function's return */
av_refstruct_replace(&dst_e->ext.pl_buf, src_e->ext.pl_buf);
}
/* Unref all additional buffers to close leaks */
for (; i < dst->usac.nb_elems; i++)
av_refstruct_unref(&dst->usac.elems[i].ext.pl_buf);
/* Set all other properties */
*dst = *src;
}
/**
* Save current output configuration if and only if it has been locked.
*/
@@ -429,7 +456,7 @@ static int push_output_configuration(AACDecContext *ac)
int pushed = 0;
if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) {
ac->oc[0] = ac->oc[1];
copy_oc(&ac->oc[0], &ac->oc[1]);
pushed = 1;
}
ac->oc[1].status = OC_NONE;
@@ -443,7 +470,8 @@ static int push_output_configuration(AACDecContext *ac)
static void pop_output_configuration(AACDecContext *ac)
{
if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) {
ac->oc[1] = ac->oc[0];
copy_oc(&ac->oc[1], &ac->oc[0]);
ac->avctx->ch_layout = ac->oc[1].ch_layout;
ff_aac_output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags,
ac->oc[1].status, 0);
@@ -466,6 +494,9 @@ int ff_aac_output_configure(AACDecContext *ac,
uint8_t id_map[TYPE_END][MAX_ELEM_ID] = {{ 0 }};
uint8_t type_counts[TYPE_END] = { 0 };
if (get_new_frame && !ac->frame)
return AVERROR_INVALIDDATA;
if (ac->oc[1].layout_map != layout_map) {
memcpy(ac->oc[1].layout_map, layout_map, tags * sizeof(layout_map[0]));
ac->oc[1].layout_map_tags = tags;
@@ -1107,7 +1138,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
AACUSACConfig *usac = &oc->usac;
for (int j = 0; j < usac->nb_elems; j++) {
AACUsacElemConfig *ec = &usac->elems[j];
av_freep(&ec->ext.pl_data);
av_refstruct_unref(&ec->ext.pl_buf);
}
av_channel_layout_uninit(&ac->oc[i].ch_layout);
+33 -2
View File
@@ -43,6 +43,7 @@
#include "libavcodec/mpeg4audio.h"
#include "aacdec_ac.h"
#include "aacdec_usac_mps212.h"
typedef struct AACDecContext AACDecContext;
@@ -229,6 +230,33 @@ typedef struct SingleChannelElement {
};
} SingleChannelElement;
typedef struct AACUsacMPSData {
/* Framing */
int framing_type;
int nb_param_sets;
int param_sets[MPS_MAX_PARAM_SETS];
/* OTT */
AACMPSLosslessData ott[MPS_ELE_NB];
int ott_idx[MPS_ELE_NB][MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS];
bool opd_smoothing_mode;
/* SMG */
int smooth_mode[MPS_MAX_PARAM_SETS];
int smooth_time[MPS_MAX_PARAM_SETS];
int freq_res_stride_smg[MPS_MAX_PARAM_SETS];
bool smg_data[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS];
/* TSD */
bool tsd_enable;
bool temp_shape_enable;
bool temp_shape_enable_ch[2];
int16_t temp_shape_data[MPS_MAX_TIME_SLOTS];
int tsd_num_tr_slots;
int tsd_phase_data[64];
} AACUsacMPSData;
typedef struct AACUsacStereo {
uint8_t common_window;
uint8_t common_tw;
@@ -244,6 +272,8 @@ typedef struct AACUsacStereo {
uint8_t pred_used[128];
AACUsacMPSData mps;
INTFLOAT_ALIGNED_UNION(32, alpha_q_re, 1024);
INTFLOAT_ALIGNED_UNION(32, alpha_q_im, 1024);
INTFLOAT_ALIGNED_UNION(32, prev_alpha_q_re, 1024);
@@ -332,6 +362,7 @@ typedef struct AACUsacElemConfig {
uint8_t high_rate_mode : 1; /* bsHighRateMode */
uint8_t phase_coding : 1; /* bsPhaseCoding */
uint8_t otts_bands_phase_present; /* bsOttBandsPhasePresent */
uint8_t otts_bands_phase; /* bsOttBandsPhase */
uint8_t residual_coding; /* bsResidualCoding */
uint8_t residual_bands; /* bsResidualBands */
@@ -344,7 +375,7 @@ typedef struct AACUsacElemConfig {
uint8_t payload_frag;
uint32_t default_len;
uint32_t pl_data_offset;
uint8_t *pl_data;
uint8_t *pl_buf;
} ext;
} AACUsacElemConfig;
@@ -353,7 +384,7 @@ typedef struct AACUSACConfig {
uint16_t core_frame_len;
uint16_t stream_identifier;
AACUsacElemConfig elems[64];
AACUsacElemConfig elems[MAX_ELEM_ID];
int nb_elems;
struct {
+491 -14
View File
@@ -258,17 +258,499 @@ static const int8_t sbr_vlc_offsets[10] = {
-60, -60, -24, -24, -31, -31, -12, -12, -31, -12
};
const VLCElem *ff_aac_sbr_vlc[10];
static av_cold void aacdec_common_init(void)
static av_cold void init_sbr_tables(void)
{
static VLCElem vlc_buf[(304 + 270 + 550 + 300 + 328 +
294 + 306 + 268 + 510 + 366 + 462) +
(1098 + 1092 + 768 + 1026 + 1058 +
static VLCElem vlc_buf[(1098 + 1092 + 768 + 1026 + 1058 +
1052 + 544 + 544 + 592 + 512)];
VLCInitState state = VLC_INIT_STATE(vlc_buf);
const uint8_t (*tab)[2] = sbr_huffman_tab;
// SBR VLC table initialization
for (int i = 0; i < FF_ARRAY_ELEMS(ff_aac_sbr_vlc); i++) {
ff_aac_sbr_vlc[i] =
ff_vlc_init_tables_from_lengths(&state, 9, sbr_huffman_nb_codes[i],
&tab[0][1], 2,
&tab[0][0], 2, 1,
sbr_vlc_offsets[i], 0);
tab += sbr_huffman_nb_codes[i];
}
}
const int16_t ff_aac_hcod_firstband_CLD[30][2] = {
{ 2, 1 }, { 4, 3 }, { 6, 5 }, { 8, 7 }, { 10, 9 },
{ 12, 11 }, { 14, 13 }, { -8, 15 }, { -9, 16 }, { -10, 17 },
{ -18, 18 }, { -17, -19 }, { -16, 19 }, { -11, -20 }, { -15, -21 },
{ -7, 20 }, { -22, 21 }, { -12, -14 }, { -13, -23 }, { 23, 22 },
{ -24, -31 }, { -6, 24 }, { -25, -26 }, { 26, 25 }, { -5, -27 },
{ -28, 27 }, { -4, 28 }, { -29, 29 }, { -1, -30 }, { -2, -3 },
};
const int16_t ff_aac_hcod1D_CLD[2 /* DT/DF */][30][2] = {
{ { -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, 4 }, { -5, 5 },
{ -6, 6 }, { -7, 7 }, { 9, 8 }, { -8, 10 }, { -9, 11 },
{ -10, 12 }, { -11, 13 }, { -12, 14 }, { -13, 15 }, { -14, 16 },
{ -15, 17 }, { -16, 18 }, { -17, 19 }, { -18, 20 }, { -19, -20 },
{ -21, 21 }, { -22, 22 }, { -23, 23 }, { 25, 24 }, { -24, 26 },
{ -25, 27 }, { 29, 28 }, { -26, -31 }, { -29, -30 }, { -27, -28 }, },
{ { -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, 4 }, { -5, 5 },
{ -6, 6 }, { -7, 7 }, { -8, 8 }, { -9, 9 }, { -10, 10 },
{ -11, 11 }, { -12, 12 }, { -13, 13 }, { 15, 14 }, { -14, 16 },
{ -15, 17 }, { -16, 18 }, { -17, 19 }, { -18, 20 }, { -19, 21 },
{ -20, -21 }, { -23, 22 }, { -22, 23 }, { -24, 24 }, { -25, 25 },
{ 27, 26 }, { 29, 28 }, { -30, -31 }, { -28, -29 }, { -26, -27 }, },
};
const int16_t ff_aac_hcod2D_CLD_03[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][15][2] = {
{ { { -1, 1 }, { -52, 2 }, { 4, 3 }, { -2, 5 }, { -17, 6 },
{ -18, 7 }, { -36, -51 }, { 9, 8 }, { -35, 10 }, { -34, 11 },
{ -19, -33 }, { -3, 12 }, { -20, 13 }, { -50, 14 }, { -4, -49 }, },
{ { -1, 1 }, { -52, 2 }, { -17, 3 }, { 5, 4 }, { -36, 6 },
{ -33, 7 }, { -2, -18 }, { -20, 8 }, { 10, 9 }, { -34, -49 },
{ -51, 11 }, { -35, 12 }, { -19, 13 }, { -3, 14 }, { -4, -50 }, }, },
{ { { -1, 1 }, { -52, 2 }, { -17, 3 }, { 5, 4 }, { -2, -36 },
{ -18, 6 }, { 8, 7 }, { -51, 9 }, { -33, 10 }, { -34, 11 },
{ -20, -35 }, { -19, 12 }, { -3, 13 }, { -49, 14 }, { -4, -50 }, },
{ { 2, 1 }, { -1, -52 }, { 4, 3 }, { -2, 5 }, { -51, 6 },
{ -17, -18 }, { 8, 7 }, { 10, 9 }, { -3, -36 }, { -19, 11 },
{ -35, -50 }, { -34, 12 }, { -4, 13 }, { -33, 14 }, { -20, -49 }, }, },
};
const int16_t ff_aac_hcod2D_CLD_05[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][35][2] = {
{ { { 2, 1 }, { -86, 3 }, { 5, 4 }, { -1, 6 }, { 8, 7 },
{ -17, -18 }, { -2, 9 }, { -70, 10 }, { -85, 11 }, { 13, 12 },
{ -69, 14 }, { -34, 15 }, { 17, 16 }, { -19, 18 }, { -33, -35 },
{ -54, 19 }, { -53, 20 }, { -3, 21 }, { -68, 22 }, { -84, 23 },
{ -50, 24 }, { -52, 25 }, { -51, 26 }, { -20, -36 }, { -49, 27 },
{ -38, 28 }, { -37, 29 }, { -4, -83 }, { -67, 30 }, { -66, 31 },
{ -21, 32 }, { -22, -65 }, { -5, 33 }, { -82, 34 }, { -6, -81 }, },
{ { 2, 1 }, { 4, 3 }, { -86, 5 }, { -1, 6 }, { -17, 7 },
{ -70, 8 }, { 10, 9 }, { -18, 11 }, { -33, 12 }, { -54, 13 },
{ -2, 14 }, { -34, 15 }, { -38, 16 }, { -49, 17 }, { -85, 18 },
{ -50, 19 }, { -69, 20 }, { -53, -65 }, { -22, 21 }, { -66, 22 },
{ -19, 23 }, { -37, 24 }, { -35, -81 }, { -3, 25 }, { -51, 26 },
{ -68, -84 }, { -52, 27 }, { 29, 28 }, { -20, 30 }, { -4, -36 },
{ -83, 31 }, { -67, 32 }, { -21, 33 }, { -5, 34 }, { -6, -82 }, }, },
{ { { 2, 1 }, { -86, 3 }, { -1, 4 }, { -17, 5 }, { 7, 6 },
{ -70, 8 }, { -2, -18 }, { 10, 9 }, { 12, 11 }, { -85, 13 },
{ -33, 14 }, { -34, -54 }, { 16, 15 }, { -69, 17 }, { 19, 18 },
{ -50, -53 }, { -19, 20 }, { -38, 21 }, { -35, -49 }, { -3, 22 },
{ 24, 23 }, { -68, 25 }, { -84, 26 }, { -65, 27 }, { -51, -66 },
{ -22, -37 }, { -52, 28 }, { -20, 29 }, { -36, 30 }, { -81, 31 },
{ -4, -83 }, { -67, 32 }, { -21, 33 }, { -5, 34 }, { -6, -82 }, },
{ { 2, 1 }, { 4, 3 }, { -86, 5 }, { 7, 6 }, { 9, 8 },
{ -1, -2 }, { -85, 10 }, { -18, 11 }, { -17, 12 }, { 14, 13 },
{ -70, 15 }, { 17, 16 }, { -19, -69 }, { -84, 18 }, { -3, 19 },
{ 21, 20 }, { -34, -68 }, { -20, 22 }, { -35, 23 }, { -83, 24 },
{ -33, 25 }, { -4, 26 }, { -53, 27 }, { -54, -67 }, { -36, 28 },
{ -21, -52 }, { -82, 29 }, { -5, -50 }, { -51, 30 }, { -38, 31 },
{ -37, -49 }, { -6, 32 }, { -66, 33 }, { -65, 34 }, { -22, -81 }, }, },
};
const int16_t ff_aac_hcod2D_CLD_07[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][63][2] = {
{ { { 2, 1 }, { 4, 3 }, {-120, 5 }, { 7, 6 }, { 9, 8 },
{ -1, 10 }, { -18, 11 }, { -17, 12 }, { -2,-104 }, {-119, 13 },
{ 15, 14 }, {-103, 16 }, { 18, 17 }, { -34, 19 }, { -19, 20 },
{ 22, 21 }, { -35, 23 }, { -33, 24 }, { -88, 25 }, { -87, 26 },
{ 28, 27 }, { -3,-102 }, { -86, 29 }, { -52,-118 }, { 31, 30 },
{ -50, 32 }, { -51, 33 }, { -70, 34 }, { -36, 35 }, { -85, 36 },
{ -20, 37 }, { 39, 38 }, { -69, -71 }, { -72, 40 }, { -49, -67 },
{ 42, 41 }, { -68, 43 }, { -4,-101 }, { -53,-117 }, { -37, 44 },
{ -66, 45 }, { -55, 46 }, { 48, 47 }, { -54, 49 }, { -21, 50 },
{ -84,-100 }, { -56, -65 }, { 52, 51 }, { -82, -83 }, { 54, 53 },
{ -5,-116 }, { -22, 55 }, { -38, 56 }, { -39, -40 }, { 58, 57 },
{ -81,-115 }, { -98, -99 }, { -6, 59 }, { -23, 60 }, { -24, 61 },
{ -7, -97 }, {-114, 62 }, { -8,-113 }, },
{ { 2, 1 }, { 4, 3 }, { 6, 5 }, {-120, 7 }, { -17, 8 },
{ -1,-104 }, { 10, 9 }, { 12, 11 }, { -18, 13 }, { -33, -88 },
{ 15, 14 }, { 17, 16 }, { -2, 18 }, { -34, 19 }, { -72, 20 },
{ -49, 21 }, {-119, 22 }, { -50, 23 }, {-103, 24 }, { -56, 25 },
{ -65, 26 }, { 28, 27 }, { -40, -87 }, { -66, 29 }, { -82, 30 },
{ 32, 31 }, { -19, -81 }, { -71, 33 }, { -97, 34 }, { -35, -55 },
{ -24, 35 }, { 37, 36 }, { -3, -98 }, { -51, 38 }, { -67, 39 },
{ -39,-118 }, {-113, 40 }, {-102, 41 }, { -86, 42 }, { -70, -83 },
{ 44, 43 }, { -20, -54 }, { -52, 45 }, { -36, 46 }, { -4, 47 },
{ -68, 48 }, { -85, 49 }, {-101,-117 }, { -69, 50 }, { 52, 51 },
{ -21, -37 }, { -53, 53 }, { 55, 54 }, { -5,-100 }, {-116, 56 },
{ -84, 57 }, { -38, 58 }, { -22, -99 }, {-115, 59 }, { -6, 60 },
{ -23, 61 }, { -7, 62 }, {-114, 0 }, }, },
{ { { 2, 1 }, {-120, 3 }, { -1, 4 }, { 6, 5 }, { -17, 7 },
{-104, 8 }, { -18, 9 }, { -2, 10 }, { 12, 11 }, { 14, 13 },
{-119, 15 }, { -33, 16 }, { -34, -88 }, {-103, 17 }, { 19, 18 },
{ 21, 20 }, { 23, 22 }, { 25, 24 }, { -19, -72 }, { -50, 26 },
{ -49, 27 }, { -87, 28 }, { 30, 29 }, { 32, 31 }, { -3, -35 },
{ 34, 33 }, { -56, 35 }, { -65, -66 }, { -40, 36 }, { -82,-118 },
{ -71, 37 }, { -55, 38 }, { -67,-102 }, { -51, 39 }, { -70, 40 },
{ 42, 41 }, { -81, 43 }, { -86, 44 }, { -52, -97 }, { -98, 45 },
{ -24, -39 }, { -20, 46 }, { -54, -83 }, { -36, 47 }, { -85, 48 },
{ -68, 49 }, { -4, 50 }, { -69,-113 }, {-117, 51 }, { -37,-101 },
{ -53, 52 }, { -21, 53 }, { 55, 54 }, { -84,-100 }, { -5, 56 },
{-116, 57 }, { -22, 58 }, { -38,-115 }, { 60, 59 }, { -6, -99 },
{ -23, 61 }, {-114, 62 }, { -7, -8 }, },
{ { 2, 1 }, { 4, 3 }, {-120, 5 }, { 7, 6 }, { 9, 8 },
{ 11, 10 }, { -1, 12 }, { -18,-119 }, { -2, 13 }, { 15, 14 },
{ -17, 16 }, {-104, 17 }, { 19, 18 }, { -19, 20 }, {-103, 21 },
{-118, 22 }, { 24, 23 }, { -3, 25 }, { 27, 26 }, { -34, 28 },
{-102, 29 }, { -20, 30 }, { -35, 31 }, { 33, 32 }, {-117, 34 },
{ -33, 35 }, { -88, 36 }, { -4, 37 }, { -87, 38 }, { 40, 39 },
{ -36,-101 }, { -86, 41 }, { -21, -37 }, { -85,-100 }, { -52, 42 },
{ -22, 43 }, {-116, 44 }, { -50 , 45 }, { 47, 46 }, { -5, -51 },
{-115, 48 }, { -70, 49 }, { -84, 50 }, { -38, -49 }, { -72, -99 },
{ -53, 51 }, { -69, -71 }, { -23, 52 }, { -6, -67 }, {-114, 53 },
{ -7, 54 }, { -66, -68 }, { -55, 55 }, { 57, 56 }, { -54, -65 },
{ -8, -56 }, { -82, -83 }, { 59, 58 }, { -39, -40 }, { -81, 60 },
{ -98, 61 }, { -97, 62 }, { -24,-113 }, }, },
};
const int16_t ff_aac_hcod2D_CLD_09[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][99][2] = {
{ { { 2, 1 }, { 4, 3 }, {-154, 5 }, { 7, 6 }, { 9, 8 },
{ 11, 10 }, { -1, 12 }, { -18, 13 }, { -17, 14 }, { -2,-138 },
{ 16, 15 }, {-153, 17 }, {-137, 18 }, { 20, 19 }, { 22, 21 },
{ -34, 23 }, { -19, 24 }, { -35, 25 }, { 27, 26 }, { 29, 28 },
{-121, 30 }, {-120, 31 }, {-136, 32 }, { -33,-122 }, { 34, 33 },
{-152, 35 }, { -3, 36 }, { -51, 37 }, { -52, 38 }, { -69, 39 },
{ -36, 40 }, { -50, 41 }, { 43, 42 }, { -20, 44 }, {-104, 45 },
{-103, 46 }, { -87, 47 }, {-119, 48 }, {-105, 49 }, { -86, 50 },
{-102, 51 }, {-106, 52 }, { -49,-135 }, { -68, 53 }, { 55, 54 },
{ -53, 56 }, { -67,-151 }, { -4, 57 }, { -84, 58 }, { -85, 59 },
{ -66, 60 }, { -37, 61 }, { -70, 62 }, { -54, -88 }, { -21, 63 },
{ 65, 64 }, { -89, 66 }, {-118, 67 }, { -72, 68 }, { -90, 69 },
{ -71, 70 }, { -65,-134 }, {-150, 71 }, { -83, 72 }, { -5, 73 },
{-101,-117 }, { -82, 74 }, { 76, 75 }, { -99, 77 }, { -38, 78 },
{-100, 79 }, { -22, 80 }, { -73, 81 }, { -39, -74 }, { 83, 82 },
{ -55, -81 }, { -57, 84 }, {-133,-149 }, { -56, 85 }, { -6, 86 },
{ -98, 87 }, {-132, 88 }, { -23, 89 }, {-114, 90 }, {-116, 91 },
{ -58,-115 }, { -24, 92 }, { -97,-148 }, { -40, -41 }, { -7, -42 },
{-147, 93 }, { 95, 94 }, {-131, 96 }, { -8,-130 }, { -25,-113 },
{ -9, 97 }, { -26,-129 }, {-146, 98 }, { -10,-145 }, },
{ { 2, 1 }, { 4, 3 }, { 6, 5 }, {-154, 7 }, { 9, 8 },
{ -17, 10 }, {-138, 11 }, { -1, 12 }, { 14, 13 }, { 16, 15 },
{ -33,-122 }, { -18, 17 }, { 19, 18 }, { -34, 20 }, { -2, 21 },
{-106, 22 }, { -49, 23 }, { 25, 24 }, { -50, 26 }, {-153, 27 },
{ -90, 28 }, {-137, 29 }, { -65, 30 }, { 32, 31 }, { -66, 33 },
{-121, 34 }, { -74, 35 }, { -81, 36 }, { 38, 37 }, { -42, 39 },
{ -82, 40 }, {-105, 41 }, { -19,-114 }, { -58, 42 }, { -35, 43 },
{ -97, 44 }, { 46, 45 }, {-129, 47 }, { -26, -89 }, { -57, -98 },
{ -51, 48 }, { -3, 49 }, {-113, 50 }, {-130, 51 }, {-152, 52 },
{ -67, -73 }, { -99,-136 }, {-145, 53 }, {-120, 54 }, { -41, 55 },
{ -83, 56 }, { -72, 57 }, {-104, 58 }, {-115, 59 }, { -20, 60 },
{ 62, 61 }, { -36, -88 }, { -84, 63 }, { -52, -56 }, { 65, 64 },
{ -4, -87 }, { -68, 66 }, {-151, 67 }, {-100,-135 }, { 69, 68 },
{ -69,-119 }, {-103, 70 }, { -71, 71 }, { 73, 72 }, { -21, 74 },
{ -85, 75 }, { -37, -53 }, { -86, 76 }, { 78, 77 }, {-102,-150 },
{ -5, 79 }, {-134, 80 }, {-118, 81 }, { -54,-117 }, { 83, 82 },
{ -38, -70 }, { -22, 84 }, { -6, 85 }, { 87, 86 }, { -55, 88 },
{-101, 89 }, {-133,-149 }, { -24, -39 }, { 91, 90 }, {-132, 92 },
{ -23, 93 }, { -7, 94 }, {-147,-148 }, {-116,-131 }, { -25, 95 },
{ -40, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
{ { { 2, 1 }, {-154, 3 }, { 5, 4 }, { -1, 6 }, { 8, 7 },
{ -17, 9 }, {-138, 10 }, { -18, 11 }, { -2, 12 }, { 14, 13 },
{ 16, 15 }, {-153, 17 }, { -34, 18 }, { -33,-122 }, { 20, 19 },
{ 22, 21 }, {-137, 23 }, { 25, 24 }, { 27, 26 }, {-106, 28 },
{ 30, 29 }, { -50, 31 }, { -19, 32 }, { -49,-121 }, { 34, 33 },
{ 36, 35 }, { -35, 37 }, { -90, 38 }, { -66, 39 }, { -3, 40 },
{ 42, 41 }, { -65, 43 }, {-105, 44 }, { 46, 45 }, { -74, 47 },
{ -51, 48 }, { -82,-152 }, {-136, 49 }, { -81, 50 }, { -42, -89 },
{-114, 51 }, { 53, 52 }, { -57, -58 }, {-120, 54 }, { -98, 55 },
{ -67, 56 }, { -97, 57 }, { 59, 58 }, { -99, 60 }, { -73,-104 },
{ -72, 61 }, {-113, 62 }, { -20, -83 }, { -84,-130 }, { -36, 63 },
{ -26, 64 }, { -41, 65 }, { -52,-129 }, { -87, -88 }, { 67, 66 },
{-115, 68 }, { -68, 69 }, { -56, -69 }, { -4,-100 }, {-151, 70 },
{-135, 71 }, {-103,-119 }, { 73, 72 }, { -71,-145 }, {-102, 74 },
{ 76, 75 }, { -53, -85 }, { -37, 77 }, { -21, -86 }, { 79, 78 },
{ -5, 80 }, { -54,-134 }, {-150, 81 }, {-118, 82 }, { -70, 83 },
{-117, 84 }, { -22, -38 }, {-101, 85 }, { -55, 86 }, {-149, 87 },
{ -39, 88 }, {-133, 89 }, { -6, 90 }, {-116, 91 }, { -24, 92 },
{ -7,-132 }, { -23, 93 }, { -40, 94 }, {-131,-148 }, { -25, 95 },
{-147, 96 }, {-146, 97 }, { -8, 0 }, { 0, 0 }, },
{ { 2, 1 }, { 4, 3 }, { 6, 5 }, {-154, 7 }, { 9, 8 },
{ 11, 10 }, { 13, 12 }, { 15, 14 }, { -18, 16 }, {-153, 17 },
{ -1, -2 }, { 19, 18 }, {-138, 20 }, { -17, 21 }, { 23, 22 },
{ 25, 24 }, { -19,-137 }, { 27, 26 }, {-152, 28 }, { 30, 29 },
{ -3, -34 }, { 32, 31 }, { 34, 33 }, { 36, 35 }, {-136, 37 },
{ -35, 38 }, { -20, 39 }, {-122, 40 }, {-151, 41 }, { -33, 42 },
{-121, 43 }, { 45, 44 }, { 47, 46 }, { -4, 48 }, { -36,-120 },
{-135, 49 }, { 51, 50 }, { -21, 52 }, { 54, 53 }, { 56, 55 },
{ -50,-150 }, { 58, 57 }, { -51, 59 }, { 61, 60 }, {-119, 62 },
{ -52, 63 }, { -5, 64 }, { -37, 65 }, {-117,-134 }, { -39, -54 },
{ -22, 66 }, {-106, 67 }, { -69,-102 }, {-132, 68 }, {-105, 69 },
{ -49, 70 }, {-149, 71 }, { -24,-104 }, { 73, 72 }, { -53, 74 },
{ -38,-118 }, {-103, 75 }, { -6, 76 }, { -66, -87 }, {-133,-147 },
{ -23, 77 }, { -67, 78 }, { -68, -86 }, { -70,-101 }, { -40,-148 },
{-116, 79 }, { -55, 80 }, { -84,-131 }, { 82, 81 }, { -89, -90 },
{ -7, -25 }, { -85, -88 }, { -65, 83 }, { -72,-146 }, { 85, 84 },
{ -9, -71 }, { -83, 86 }, { -82, 87 }, { -8, 88 }, {-100, 89 },
{ -74, -99 }, { -73, 90 }, { -10, -81 }, { -56, 91 }, { -57, -98 },
{ 93, 92 }, { -58,-114 }, { -97,-115 }, { 95, 94 }, { -41, 96 },
{ -42, 97 }, { -26,-129 }, {-113, 98 }, {-130,-145 }, },
},
};
const int16_t ff_aac_hcod_firstband_ICC[7][2] = {
{ 2, 1 }, { -5, 3 }, { -4, -6 }, { -3, 4 }, { -2, 5 },
{ -1, 6 }, { -7, -8 },
};
const int16_t ff_aac_hcod1D_ICC[7][2] = {
{ -1, 1 }, { -2, 2 }, { -3, 3 }, { -4, 4 }, { -5, 5 },
{ -6, 6 }, { -7, -8 },
};
const int16_t ff_aac_hcod2D_ICC_01[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][3][2] = {
{ { { -1, 1 }, { -18, 2 }, { -2, -17 }, },
{ { -1, 1 }, { -18, 2 }, { -2, -17 }, }, },
{ { { -1, 1 }, { -18, 2 }, { -2, -17 }, },
{ { -1, 1 }, { -18, 2 }, { -2, -17 }, }, },
};
const int16_t ff_aac_hcod2D_ICC_03[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][15][2] = {
{ { { -52, 1 }, { -1, 2 }, { 4, 3 }, { -2, 5 }, { -17, -18 },
{ -51, 6 }, { -36, 7 }, { 9, 8 }, { -35, 10 }, { -3, 11 },
{ -19, -34 }, { -33, 12 }, { -50, 13 }, { -20, 14 }, { -4, -49 }, },
{ { 2, 1 }, { -1, -52 }, { -17, 3 }, { 5, 4 }, { -36, 6 },
{ -2, 7 }, { -18, -33 }, { 9, 8 }, { -20, 10 }, { -34, -51 },
{ -49, 11 }, { -35, 12 }, { -19, 13 }, { -3, 14 }, { -4, -50 }, }, },
{ { { -52, 1 }, { -1, 2 }, { 4, 3 }, { -2, -17 }, { -18, 5 },
{ -36, 6 }, { -51, 7 }, { 9, 8 }, { -33, 10 }, { -34, 11 },
{ -35, 12 }, { -19, -20 }, { -3, 13 }, { -49, 14 }, { -4, -50 }, },
{ { 2, 1 }, { -1, -52 }, { -2, 3 }, { 5, 4 }, { -51, 6 },
{ -18, 7 }, { -17, 8 }, { -3, 9 }, { -36, 10 }, { -19, -50 },
{ -35, 11 }, { -4, 12 }, { -34, 13 }, { -33, 14 }, { -20, -49 }, },},
};
const int16_t ff_aac_hcod2D_ICC_05[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][35][2] = {
{ { { 2, 1 }, { -86, 3 }, { -1, 4 }, { 6, 5 }, { -18, 7 },
{ -2, -17 }, { 9, 8 }, { -70, 10 }, { -69, -85 }, { -35, 11 },
{ 13, 12 }, { -34, 14 }, { -19, 15 }, { -53, 16 }, { -68, 17 },
{ -33, 18 }, { -3, -52 }, { 20, 19 }, { -54, 21 }, { -84, 22 },
{ -50, 23 }, { -20, -51 }, { -36, 24 }, { 26, 25 }, { -83, 27 },
{ -4, -38 }, { -49, 28 }, { -37, 29 }, { -67, 30 }, { -5, 31 },
{ -21, 32 }, { -65, -66 }, { -82, 33 }, { -22, 34 }, { -6, -81 }, },
{ { 2, 1 }, { -86, 3 }, { -1, 4 }, { -17, 5 }, { 7, 6 },
{ -70, 8 }, { -33, 9 }, { -18, 10 }, { -2, 11 }, { -54, 12 },
{ -49, 13 }, { -38, 14 }, { -34, -65 }, { -85, 15 }, { -50, 16 },
{ -69, 17 }, { -22, 18 }, { -53, 19 }, { 21, 20 }, { -19, -81 },
{ -66, 22 }, { -3, -35 }, { 24, 23 }, { -37, 25 }, { -68, -84 },
{ -51, 26 }, { 28, 27 }, { -20, -52 }, { 30, 29 }, { -4, -36 },
{ -83, 31 }, { -67, 32 }, { -82, 33 }, { -21, 34 }, { -5, -6 }, }, },
{ { { -1, 1 }, { -86, 2 }, { 4, 3 }, { -17, 5 }, { -2, 6 },
{ -18, 7 }, { -70, 8 }, { -85, 9 }, { 11, 10 }, { 13, 12 },
{ -33, 14 }, { 16, 15 }, { -34, -54 }, { -69, 17 }, { -38, 18 },
{ -50, 19 }, { -35, -53 }, { -49, 20 }, { -19, 21 }, { -3, 22 },
{ -65, 23 }, { -68, 24 }, { -22, 25 }, { -81, -84 }, { -66, 26 },
{ -37, 27 }, { -20, -51 }, { 29, 28 }, { -52, 30 }, { -4, -83 },
{ -36, 31 }, { -67, 32 }, { -5, 33 }, { -82, 34 }, { -21, 0 }, },
{ { 2, 1 }, { -86, 3 }, { -1, 4 }, { 6, 5 }, { -2, 7 },
{ -85, 8 }, { -18, 9 }, { 11, 10 }, { -17, 12 }, { 14, 13 },
{ -70, 15 }, { -3, -19 }, { -69, 16 }, { -84, 17 }, { -68, 18 },
{ -20, -35 }, { -34, -83 }, { 20, 19 }, { -4, 21 }, { -33, 22 },
{ -5, 23 }, { -53, 24 }, { -36, -52 }, { -67, 25 }, { -21, -82 },
{ -54, 26 }, { -6, 27 }, { -51, 28 }, { -50, 29 }, { -49, 30 },
{ -37, 31 }, { -38, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
};
const int16_t ff_aac_hcod2D_ICC_07[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][63][2] = {
{ { { 2, 1 }, { -1,-120 }, { 4, 3 }, { 6, 5 }, { -18, 7 },
{ 9, 8 }, { -17, 10 }, { -2, 11 }, {-103, 12 }, { -52, 13 },
{ -35,-104 }, {-119, 14 }, { 16, 15 }, { -69, -86 }, { 18, 17 },
{ -34, 19 }, { -19, 20 }, { 22, 21 }, { -70, 23 }, { -87, 24 },
{-102, 25 }, { -85, 26 }, { -33, 27 }, { -36, 28 }, { -3, 29 },
{ -88, 30 }, { -51, 31 }, {-118, 32 }, { 34, 33 }, { -68, 35 },
{ -53, 36 }, { -67, 37 }, { -20, 38 }, {-101, 39 }, { -50, 40 },
{ 42, 41 }, { -37, 43 }, {-116, 44 }, {-117, 45 }, { -49, 46 },
{ -21,-100 }, { 48, 47 }, { -55, -71 }, { -4, 49 }, { -22, -84 },
{-115, 50 }, { -66, -82 }, { -72, 51 }, { -5, -6 }, { -54, 52 },
{ -38, 53 }, { -83, 54 }, { -40, 55 }, { -39, 56 }, { -99, 57 },
{ -23, -56 }, { -7, 58 }, { -65, -97 }, { -8, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, },
{ { 2, 1 }, { 4, 3 }, { -1,-120 }, { 6, 5 }, { 8, 7 },
{ -18, 9 }, { -2, 10 }, { 12, 11 }, { 14, 13 }, { -17,-119 },
{ 16, 15 }, {-103, 17 }, {-104, 18 }, { -52, 19 }, { 21, 20 },
{ -69, 22 }, { 24, 23 }, { -3, -35 }, { -19, 25 }, { -34, -85 },
{ 27, 26 }, { -86, 28 }, {-118, 29 }, { -37, 30 }, { 32, 31 },
{-102, 33 }, { -20, -22 }, { -4,-117 }, { -87, 34 }, {-100, 35 },
{ -33, -36 }, { 37, 36 }, { -70, -88 }, {-101, 38 }, { -5, 39 },
{ -51, -53 }, { -50, 40 }, {-115, 41 }, { -21, 42 }, {-116, 43 },
{ -38, 44 }, { -23, -84 }, { -49, -99 }, { 46, 45 }, { -6,-114 },
{ -7, -72 }, { -71, 47 }, { -8, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
{ { { -1, 1 }, {-120, 2 }, { 4, 3 }, { -17, 5 }, { -2, 6 },
{ 8, 7 }, { -18, 9 }, {-104, 10 }, { 12, 11 }, { 14, 13 },
{ 16, 15 }, {-119, 17 }, { -81, 18 }, { 20, 19 }, { -33, 21 },
{ -88, 22 }, {-103, 23 }, { -34, 24 }, { -56, 25 }, { -72, 26 },
{ -49, 27 }, { -82, 28 }, { -50, 29 }, { -65, 30 }, { -55, -87 },
{ -19, 31 }, { -67, 32 }, { -35, -40 }, { 34, 33 }, { -52, -71 },
{ -66, 35 }, { -70, 36 }, { 38, 37 }, { -51, -97 }, { -86,-102 },
{ -3, 39 }, {-118, 40 }, { 42, 41 }, { -24, -85 }, { -54, 43 },
{ -39, 44 }, { -98,-113 }, { -36, -37 }, { -20, -69 }, { -4, 45 },
{ -5, 46 }, { -21, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, },
{ { 2, 1 }, { 4, 3 }, { -1,-120 }, { 6, 5 }, { 8, 7 },
{ -18, 9 }, { -2, 10 }, { 12, 11 }, { 14, 13 }, { -17,-119 },
{ 16, 15 }, {-103, 17 }, {-104, 18 }, { -52, 19 }, { 21, 20 },
{ -69, 22 }, { 24, 23 }, { -3, -35 }, { -19, 25 }, { -34, -85 },
{ 27, 26 }, { -86, 28 }, {-118, 29 }, { -37, 30 }, { 32, 31 },
{-102, 33 }, { -20, -22 }, { -4,-117 }, { -87, 34 }, {-100, 35 },
{ -33, -36 }, { 37, 36 }, { -70, -88 }, {-101, 38 }, { -5, 39 },
{ -51, -53 }, { -50, 40 }, {-115, 41 }, { -21, 42 }, {-116, 43 },
{ -38, 44 }, { -23, -84 }, { -49, -99 }, { 46, 45 }, { -6,-114 },
{ -7, -72 }, { -71, 47 }, { -8, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
};
const int16_t ff_aac_hcod_firstband_IPD[7][2] = {
{ -1, 1 }, { -8, 2 }, { -2, 3 }, { 5, 4 }, { -7, 6 },
{ -3, -5 }, { -4, -6 },
};
const int16_t ff_aac_hcod1D_IPD[2 /* DT, DF */ ][7][2] = {
{ { -1, 1 }, { -2, 2 }, { -8, 3 }, { -3, 4 }, { -7, 5 },
{ -4, 6 }, { -5, -6 }, }, /* DT */
{ { -1, 1 }, { -8, 2 }, { -2, 3 }, { 5, 4 }, { -3, -7 },
{ -6, 6 }, { -4, -5 }, }, /* DF */
};
const int16_t ff_aac_hcod2D_IPD_01[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][3][2] = {
{ { { -1, 1 }, { -18, 2 }, { -17, 0 }, },
{ { -1, 1 }, { -18, 2 }, { -17, 0 }, }, },
{ { { -1, 1 }, { -18, 2 }, { -17, 0 }, },
{ { -1, 1 }, { -18, 2 }, { -17, 0 }, }, },
};
const int16_t ff_aac_hcod2D_IPD_03[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][15][2] = {
{ { { -1, 1 }, { 3, 2 }, { -18, 4 }, { -52, 5 }, { -34, -36 },
{ -35, 6 }, { -17, 7 }, { -33, 8 }, { -20, 9 }, { -49, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, },
{ { -1, 1 }, { -36, 2 }, { -18, 3 }, { -35, 4 }, { -52, 5 },
{ 7, 6 }, { -34, 8 }, { -33, -49 }, { -20, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
{ { { -1, 1 }, { 3, 2 }, { -18, 4 }, { -52, 5 }, { -34, -36 },
{ -35, 6 }, { -17, 7 }, { -33, 8 }, { -20, 9 }, { -49, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, },
{ { -1, 1 }, { -36, 2 }, { -18, 3 }, { -35, 4 }, { -52, 5 },
{ 7, 6 }, { -34, 8 }, { -33, -49 }, { -20, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
};
const int16_t ff_aac_hcod2D_IPD_05[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][35][2] = {
{ { { -1, 1 }, { 3, 2 }, { -52, 4 }, { -86, 5 }, { -35, 6 },
{ -53, 7 }, { -70, 8 }, { -17, 9 }, { -37, 10 }, { 12, 11 },
{ -38, -66 }, { -18, 13 }, { -51, 14 }, { 16, 15 }, { -34, -69 },
{ 18, 17 }, { -54, -65 }, { -50, 19 }, { -33, -49 }, { -22, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, },
{ { -1, 1 }, { 3, 2 }, { 5, 4 }, { -86, 6 }, { -66, 7 },
{ 9, 8 }, { 11, 10 }, { -18, 12 }, { -51, 13 }, { -37, -52 },
{ -69, 14 }, { -38, 15 }, { -53, 16 }, { -35, 17 }, { -50, -70 },
{ -22, -49 }, { -33, 18 }, { -17, 19 }, { -34, -65 }, { -81, 20 },
{ -54, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
{ { { -1, 1 }, { 3, 2 }, { -52, 4 }, { -86, 5 }, { -35, 6 },
{ -53, 7 }, { -70, 8 }, { -17, 9 }, { -37, 10 }, { 12, 11 },
{ -38, -66 }, { -18, 13 }, { -51, 14 }, { 16, 15 }, { -34, -69 },
{ 18, 17 }, { -54, -65 }, { -50, 19 }, { -33, -49 }, { -22, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, },
{ { -1, 1 }, { 3, 2 }, { 5, 4 }, { -86, 6 }, { -66, 7 },
{ 9, 8 }, { 11, 10 }, { -18, 12 }, { -51, 13 }, { -37, -52 },
{ -69, 14 }, { -38, 15 }, { -53, 16 }, { -35, 17 }, { -50, -70 },
{ -22, -49 }, { -33, 18 }, { -17, 19 }, { -34, -65 }, { -81, 20 },
{ -54, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
};
const int16_t ff_aac_hcod2D_IPD_07[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][63][2] = {
{ { { -1, 1 }, { -69, 2 }, { 4, 3 }, {-120, 5 }, { 7, 6 },
{-113, 8 }, { -68, 9 }, { 11, 10 }, { -17, 12 }, { -52, 13 },
{ -24, 14 }, { -18, 15 }, { 17, 16 }, {-104, 18 }, { 20, 19 },
{ -54, -70 }, { 22, 21 }, { 24, 23 }, { -86, -97 }, {-103, 25 },
{ -83, 26 }, { -35, 27 }, { -34, -98 }, { -40, 28 }, { -39, -67 },
{ 30, 29 }, { -33, -51 }, { -87, 31 }, { -88, 32 }, { -82, 33 },
{ -55, -81 }, { -56, -71 }, { -72, 34 }, { -50, -66 }, { -65, 35 },
{ -49, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, },
{ { 2, 1 }, { 4, 3 }, { -1, 5 }, { -69, 6 }, {-120, 7 },
{ -68, 8 }, { 10, 9 }, { 12, 11 }, { 14, 13 }, { -52, -54 },
{ -18, 15 }, { -70, 16 }, { -67, 17 }, { 19, 18 }, { -17, 20 },
{-113, 21 }, { 23, 22 }, { -83, 24 }, { -24, 25 }, {-103,-104 },
{ -51, -55 }, { 27, 26 }, { -71, 28 }, { -86, 29 }, { -35, 30 },
{ -66, 31 }, { -39, -50 }, { -82, -98 }, { -72, 32 }, { -56, -87 },
{ -34, 33 }, { -33, -88 }, { -40, -97 }, { -65, 34 }, { -49, 35 },
{ -81, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
{ { { -1, 1 }, { -69, 2 }, { 4, 3 }, {-120, 5 }, { 7, 6 },
{-113, 8 }, { -68, 9 }, { 11, 10 }, { -17, 12 }, { -52, 13 },
{ -24, 14 }, { -18, 15 }, { 17, 16 }, {-104, 18 }, { 20, 19 },
{ -54, -70 }, { 22, 21 }, { 24, 23 }, { -86, -97 }, {-103, 25 },
{ -83, 26 }, { -35, 27 }, { -34, -98 }, { -40, 28 }, { -39, -67 },
{ 30, 29 }, { -33, -51 }, { -87, 31 }, { -88, 32 }, { -82, 33 },
{ -55, -81 }, { -56, -71 }, { -72, 34 }, { -50, -66 }, { -65, 35 },
{ -49, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, },
{ { 2, 1 }, { 4, 3 }, { -1, 5 }, { -69, 6 }, {-120, 7 },
{ -68, 8 }, { 10, 9 }, { 12, 11 }, { 14, 13 }, { -52, -54 },
{ -18, 15 }, { -70, 16 }, { -67, 17 }, { 19, 18 }, { -17, 20 },
{-113, 21 }, { 23, 22 }, { -83, 24 }, { -24, 25 }, {-103,-104 },
{ -51, -55 }, { 27, 26 }, { -71, 28 }, { -86, 29 }, { -35, 30 },
{ -66, 31 }, { -39, -50 }, { -82, -98 }, { -72, 32 }, { -56, -87 },
{ -34, 33 }, { -33, -88 }, { -40, -97 }, { -65, 34 }, { -49, 35 },
{ -81, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 }, { 0, 0 }, }, },
};
const int16_t ff_aac_hcod_lav_idx[3][2] = {
{ -1, 1 }, { -2, 2 }, { -3, -4 },
};
const int16_t ff_aac_hcod2D_reshape[39][2] = {
{ 2, 1 }, { 4, 3 }, { 6, 5 }, { -33, 7 }, { -17, 8 },
{ -49, 9 }, { -34, 10 }, { 12, 11 }, { -18, -35 }, { -50, 13 },
{ 15, 14 }, { -40, 16 }, { -36, 17 }, { -19, 18 }, { -1, -37 },
{ -51, 19 }, { 21, 20 }, { -38, -65 }, { -2, -39 }, { -20, 22 },
{ -52, 23 }, { 25, 24 }, { -21, 26 }, { -66, 27 }, { -53, 28 },
{ -3, 29 }, { 31, 30 }, { -22, 32 }, { -54, 33 }, { -4, 34 },
{ -56, 35 }, { -24, -67 }, { -23, -55 }, { -8, -72 }, { -5, 36 },
{ -68, 37 }, { -6, 38 }, { -7, -69 }, { -70, -71 },
};
const uint8_t ff_aac_lav_tab_XXX[3][4] = {
{ 3, 5, 7, 9 }, { 1, 3, 5, 7 }, { 7, 1, 3, 5 }
};
static av_cold void init_base_tables(void)
{
static VLCElem vlc_buf[(304 + 270 + 550 + 300 + 328 +
294 + 306 + 268 + 510 + 366 + 462)];
VLCInitState state = VLC_INIT_STATE(vlc_buf);
for (unsigned i = 0; i < 11; i++) {
#define TAB_WRAP_SIZE(name) name[i], sizeof(name[i][0]), sizeof(name[i][0])
ff_vlc_spectral[i] =
@@ -287,17 +769,12 @@ static av_cold void aacdec_common_init(void)
ff_aac_scalefactor_code,
sizeof(ff_aac_scalefactor_code[0]),
sizeof(ff_aac_scalefactor_code[0]), 0);
}
// SBR VLC table initialization
for (int i = 0; i < FF_ARRAY_ELEMS(ff_aac_sbr_vlc); i++) {
ff_aac_sbr_vlc[i] =
ff_vlc_init_tables_from_lengths(&state, 9, sbr_huffman_nb_codes[i],
&tab[0][1], 2,
&tab[0][0], 2, 1,
sbr_vlc_offsets[i], 0);
tab += sbr_huffman_nb_codes[i];
}
static av_cold void aacdec_common_init(void)
{
init_base_tables();
init_sbr_tables();
ff_ps_init_common();
}
+27
View File
@@ -50,6 +50,33 @@ extern const uint8_t ff_aac_channel_layout_map[16][16][3];
extern const int16_t ff_aac_channel_map[3][4][6];
extern const AVChannelLayout ff_aac_ch_layout[];
extern const int16_t ff_aac_hcod_firstband_CLD[30][2];
extern const int16_t ff_aac_hcod1D_CLD[2 /* DT_/DF_ */][30][2];
extern const int16_t ff_aac_hcod2D_CLD_03[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][15][2];
extern const int16_t ff_aac_hcod2D_CLD_05[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][35][2];
extern const int16_t ff_aac_hcod2D_CLD_07[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][63][2];
extern const int16_t ff_aac_hcod2D_CLD_09[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][99][2];
extern const int16_t ff_aac_hcod_firstband_ICC[7][2];
extern const int16_t ff_aac_hcod1D_ICC[7][2];
extern const int16_t ff_aac_hcod2D_ICC_01[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][3][2];
extern const int16_t ff_aac_hcod2D_ICC_03[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][15][2];
extern const int16_t ff_aac_hcod2D_ICC_05[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][35][2];
extern const int16_t ff_aac_hcod2D_ICC_07[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][63][2];
extern const int16_t ff_aac_hcod_firstband_IPD[7][2];
extern const int16_t ff_aac_hcod1D_IPD[2 /* DF, DT */ ][7][2];
extern const int16_t ff_aac_hcod2D_IPD_01[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][3][2];
extern const int16_t ff_aac_hcod2D_IPD_03[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][15][2];
extern const int16_t ff_aac_hcod2D_IPD_05[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][35][2];
extern const int16_t ff_aac_hcod2D_IPD_07[2 /* _TP/_FP */ ][2 /* DT_/DF_ */ ][63][2];
extern const int16_t ff_aac_hcod_lav_idx[3][2];
extern const int16_t ff_aac_hcod2D_reshape[39][2];
extern const uint8_t ff_aac_lav_tab_XXX[3][4];
FF_VISIBILITY_POP_HIDDEN
#endif /* AVCODEC_AAC_AACDEC_TAB_H */
+190 -17
View File
@@ -24,12 +24,15 @@
#include "aacdec_ac.h"
#include "libavcodec/aacsbr.h"
#include "libavcodec/aactab.h"
#include "libavutil/mem.h"
#include "libavcodec/mpeg4audio.h"
#include "libavcodec/unary.h"
#include "libavutil/mem.h"
#include "libavutil/refstruct.h"
#include "aacdec_usac_mps212.h"
/* Number of scalefactor bands per complex prediction band, equal to 2. */
#define SFB_PER_PRED_BAND 2
@@ -218,12 +221,15 @@ static int decode_usac_element_pair(AACDecContext *ac,
e->mps.high_rate_mode = get_bits1(gb); /* bsHighRateMode */
e->mps.phase_coding = get_bits1(gb); /* bsPhaseCoding */
if (get_bits1(gb)) /* bsOttBandsPhasePresent */
e->mps.otts_bands_phase_present = get_bits1(gb);
if (e->mps.otts_bands_phase_present) /* bsOttBandsPhasePresent */
e->mps.otts_bands_phase = get_bits(gb, 5); /* bsOttBandsPhase */
e->mps.residual_coding = e->stereo_config_index >= 2; /* bsResidualCoding */
if (e->mps.residual_coding) {
e->mps.residual_bands = get_bits(gb, 5); /* bsResidualBands */
e->mps.otts_bands_phase = FFMAX(e->mps.otts_bands_phase,
e->mps.residual_bands);
e->mps.pseudo_lr = get_bits1(gb); /* bsPseudoLr */
}
if (e->mps.temp_shape_config == 2)
@@ -314,7 +320,7 @@ int ff_aac_usac_reset_state(AACDecContext *ac, OutputConfiguration *oc)
ff_aac_sbr_config_usac(ac, che, e);
for (int j = 0; j < ch; j++) {
SingleChannelElement *sce = &che->ch[ch];
SingleChannelElement *sce = &che->ch[j];
AACUsacElemData *ue = &sce->ue;
memset(ue, 0, sizeof(*ue));
@@ -1342,6 +1348,164 @@ static void spectrum_decode(AACDecContext *ac, AACUSACConfig *usac,
}
}
static const uint8_t mps_fr_nb_bands[8] = {
255 /* Reserved */, 28, 20, 14, 10, 7, 5, 4,
};
static const uint8_t mps_fr_stride_smg[4] = {
1, 2, 5, 28,
};
static void decode_tsd(GetBitContext *gb, int *data,
int nb_tr_slots, int nb_slots)
{
int nb_bits = av_log2(nb_slots / (nb_tr_slots + 1));
int s = get_bits(gb, nb_bits);
for (int k = 0; k < nb_slots; k++)
data[k]=0;
int p = nb_tr_slots + 1;
for (int k = nb_slots - 1; k >= 0; k--) {
if (p > k) {
for (; k >= 0; k--)
data[k] = 1;
break;
}
int64_t c = k - p + 1;
for (int h = 2; h <= p; h++) {
c *= k - p + h;
c /= h;
}
if (s >= (int)c) { /* c is long long for up to 32 slots */
s -= c;
data[k] = 1;
p--;
if (!p)
break;
}
}
}
static int parse_mps212(AACDecContext *ac, AACUSACConfig *usac,
AACUsacMPSData *mps, AACUsacElemConfig *ec,
GetBitContext *gb, int frame_indep_flag)
{
int err;
int nb_bands = mps_fr_nb_bands[ec->mps.freq_res];
/* Framing info */
mps->framing_type = 0;
mps->nb_param_sets = 2;
if (ec->mps.high_rate_mode) {
mps->framing_type = get_bits1(gb);
mps->nb_param_sets = get_bits(gb, 3) + 1;
}
int param_slot_bits = usac->core_sbr_frame_len_idx == 4 ? 6 : 5;
int nb_time_slots = usac->core_sbr_frame_len_idx == 4 ? 64 : 32;
if (mps->framing_type)
for (int i = 0; i < mps->nb_param_sets; i++)
mps->param_sets[i] = get_bits(gb, param_slot_bits);
int indep = frame_indep_flag;
if (!frame_indep_flag)
indep = get_bits1(gb);
int extend_frame = mps->param_sets[mps->nb_param_sets - 1] !=
(nb_time_slots - 1);
/* CLD */
err = ff_aac_ec_data_dec(gb, &mps->ott[MPS_CLD], MPS_CLD,
0, 0, nb_bands,
indep, indep, mps->nb_param_sets);
if (err < 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Error parsing OTT CLD data!\n");
return err;
}
ff_aac_map_index_data(&mps->ott[MPS_CLD], MPS_CLD, mps->ott_idx[MPS_CLD],
0, 0, nb_bands, mps->nb_param_sets,
mps->param_sets, extend_frame);
/* ICC */
err = ff_aac_ec_data_dec(gb, &mps->ott[MPS_ICC], MPS_ICC, 0, 0, nb_bands,
indep, indep, mps->nb_param_sets);
if (err < 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Error parsing OTT ICC data!\n");
return err;
}
ff_aac_map_index_data(&mps->ott[MPS_ICC], MPS_ICC, mps->ott_idx[MPS_ICC],
0, 0, nb_bands, mps->nb_param_sets,
mps->param_sets, extend_frame);
/* IPD */
if (ec->mps.phase_coding) {
if (get_bits1(gb)) {
mps->opd_smoothing_mode = get_bits1(gb);
err = ff_aac_ec_data_dec(gb, &mps->ott[MPS_IPD], MPS_IPD, 0, 0,
ec->mps.otts_bands_phase,
indep, indep, mps->nb_param_sets);
ff_aac_map_index_data(&mps->ott[MPS_IPD], MPS_IPD, mps->ott_idx[MPS_IPD],
0, 0, nb_bands, mps->nb_param_sets,
mps->param_sets, extend_frame);
if (err < 0) {
av_log(ac->avctx, AV_LOG_ERROR, "Error parsing OTT IPD data!\n");
return err;
}
}
}
/* SMG data */
memset(mps->smooth_mode, 0, sizeof(mps->smooth_mode));
if (ec->mps.high_rate_mode) {
for (int i = 0; i < mps->nb_param_sets; i++) {
mps->smooth_mode[i] = get_bits(gb, 2);
if (mps->smooth_mode[i] >= 2)
mps->smooth_time[i] = get_bits(gb, 2);
if (mps->smooth_mode[i] >= 3) {
mps->freq_res_stride_smg[i] = get_bits(gb, 2);
int nb_data_bands = (nb_bands - 1);
nb_data_bands /= (mps_fr_stride_smg[mps->freq_res_stride_smg[i]] + 1);
for (int j = 0; j < nb_data_bands; j++)
mps->smg_data[i][j] = get_bits1(gb);
}
}
}
/* Temp shape data */
mps->tsd_enable = 0;
if (ec->mps.temp_shape_config == 3) {
mps->tsd_enable = get_bits1(gb);
} else if (ec->mps.temp_shape_config) {
mps->temp_shape_enable = get_bits1(gb);
if (mps->temp_shape_enable) {
for (int i = 0; i < 2; i++)
mps->temp_shape_enable_ch[i] = get_bits1(gb);
if (ec->mps.temp_shape_config == 2) {
err = ff_aac_huff_dec_reshape(gb, mps->temp_shape_data, 16);
if (err < 0) {
av_log(ac->avctx, AV_LOG_ERROR,
"Error parsing TSD reshape data!\n");
return err;
}
}
}
}
/* TSD data */
if (mps->tsd_enable) {
mps->tsd_num_tr_slots = get_bits(gb, param_slot_bits - 1);
int tsd_pos[64];
decode_tsd(gb, tsd_pos, mps->tsd_num_tr_slots, nb_time_slots);
for (int i = 0; i < nb_time_slots; i++) {
mps->tsd_phase_data[i] = 0;
if (tsd_pos[i])
mps->tsd_phase_data[i] = get_bits(gb, 3);
}
}
return 0;
}
static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac,
AACUsacElemConfig *ec, ChannelElement *che,
GetBitContext *gb, int indep_flag, int nb_channels)
@@ -1463,7 +1627,8 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac,
if (get_bits1(gb)) { /* fac_data_present */
const uint16_t len_8 = usac->core_frame_len / 8;
const uint16_t len_16 = usac->core_frame_len / 16;
const uint16_t fac_len = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ? len_16 : len_8;
const uint16_t fac_len = ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE ?
len_16 : len_8;
ret = ff_aac_parse_fac_data(ue, gb, 1, fac_len);
if (ret < 0)
return ret;
@@ -1482,8 +1647,9 @@ static int decode_usac_core_coder(AACDecContext *ac, AACUSACConfig *usac,
}
if (ec->stereo_config_index) {
avpriv_report_missing_feature(ac->avctx, "AAC USAC Mps212");
return AVERROR_PATCHWELCOME;
ret = parse_mps212(ac, usac, &us->mps, ec, gb, indep_flag);
if (ret < 0)
return ret;
}
spectrum_decode(ac, usac, che, core_nb_channels);
@@ -1574,7 +1740,6 @@ static int parse_audio_preroll(AACDecContext *ac, GetBitContext *gb)
static int parse_ext_ele(AACDecContext *ac, AACUsacElemConfig *e,
GetBitContext *gb)
{
uint8_t *tmp;
uint8_t pl_frag_start = 1;
uint8_t pl_frag_end = 1;
uint32_t len;
@@ -1601,18 +1766,26 @@ static int parse_ext_ele(AACDecContext *ac, AACUsacElemConfig *e,
if (pl_frag_start)
e->ext.pl_data_offset = 0;
/* If an extension starts and ends this packet, we can directly use it */
/* If an extension starts and ends this packet, we can directly use it below.
* Otherwise, we have to copy it to a buffer and accumulate it. */
if (!(pl_frag_start && pl_frag_end)) {
tmp = av_realloc(e->ext.pl_data, e->ext.pl_data_offset + len);
if (!tmp) {
av_free(e->ext.pl_data);
/* Reallocate the data */
uint8_t *tmp_buf = av_refstruct_alloc_ext(e->ext.pl_data_offset + len,
AV_REFSTRUCT_FLAG_NO_ZEROING,
NULL, NULL);
if (!tmp_buf)
return AVERROR(ENOMEM);
}
e->ext.pl_data = tmp;
/* Copy the data over only if we had saved data to begin with */
if (e->ext.pl_buf)
memcpy(tmp_buf, e->ext.pl_buf, e->ext.pl_data_offset);
av_refstruct_unref(&e->ext.pl_buf);
e->ext.pl_buf = tmp_buf;
/* Readout data to a buffer */
for (int i = 0; i < len; i++)
e->ext.pl_data[e->ext.pl_data_offset + i] = get_bits(gb, 8);
e->ext.pl_buf[e->ext.pl_data_offset + i] = get_bits(gb, 8);
}
e->ext.pl_data_offset += len;
@@ -1624,7 +1797,7 @@ static int parse_ext_ele(AACDecContext *ac, AACUsacElemConfig *e,
GetBitContext *gb2 = gb;
GetBitContext gbc;
if (!(pl_frag_start && pl_frag_end)) {
ret = init_get_bits8(&gbc, e->ext.pl_data, pl_len);
ret = init_get_bits8(&gbc, e->ext.pl_buf, pl_len);
if (ret < 0)
return ret;
@@ -1642,7 +1815,7 @@ static int parse_ext_ele(AACDecContext *ac, AACUsacElemConfig *e,
/* This should never happen */
av_assert0(0);
}
av_freep(&e->ext.pl_data);
av_refstruct_unref(&e->ext.pl_buf);
if (ret < 0)
return ret;
+919
View File
@@ -0,0 +1,919 @@
/*
* Copyright (c) 2025 Lynne <dev@lynne.ee>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "aacdec_tab.h"
#include "libavcodec/get_bits.h"
#include "libavutil/macros.h"
#include "libavutil/avassert.h"
#include "aacdec_usac_mps212.h"
static int huff_dec_1D(GetBitContext *gb, const int16_t (*tab)[2])
{
int idx = 0;
do {
/* Overreads are not possible here, the array forms a closed set */
idx = tab[idx][get_bits1(gb)];
} while (idx > 0);
return idx;
}
static int huff_dec_2D(GetBitContext *gb, const int16_t (*tab)[2], int16_t ret[2])
{
int idx = huff_dec_1D(gb, tab);
if (!idx) { /* Escape */
ret[0] = 0;
ret[1] = 1;
return 1;
}
idx = -(idx + 1);
ret[0] = idx >> 4;
ret[1] = idx & 0xf;
return 0;
}
static int huff_data_1d(GetBitContext *gb, int16_t *data, int data_bands,
enum AACMPSDataType data_type, int diff_freq, int p0_flag)
{
const int16_t (*hcod_first_band)[2];
const int16_t (*hcod1D)[2];
switch (data_type) {
case MPS_CLD:
hcod_first_band = ff_aac_hcod_firstband_CLD;
hcod1D = ff_aac_hcod1D_CLD[diff_freq];
break;
case MPS_ICC:
hcod_first_band = ff_aac_hcod_firstband_ICC;
hcod1D = ff_aac_hcod1D_ICC;
break;
case MPS_IPD:
hcod_first_band = ff_aac_hcod_firstband_IPD;
hcod1D = ff_aac_hcod1D_IPD[diff_freq];
if (data_bands == 1)
hcod1D = ff_aac_hcod1D_IPD[!diff_freq];
break;
default:
av_unreachable("Invalid data type");
}
if (p0_flag)
data[0] = -(huff_dec_1D(gb, hcod_first_band) + 1);
for (int off = diff_freq; off < data_bands; off++) {
int16_t val = -(huff_dec_1D(gb, hcod1D) + 1);
if (val && data_type != MPS_IPD)
val = get_bits1(gb) ? -val : val;
data[off] = val;
}
return 0;
}
static void symmetry_data(GetBitContext *gb, int16_t data[2],
uint8_t lav, enum AACMPSDataType data_type)
{
int16_t sum = data[0] + data[1];
int16_t diff = data[0] - data[1];
if (sum > lav) {
data[0] = -sum + (2*lav + 1);
data[1] = -diff;
} else {
data[0] = sum;
data[1] = diff;
}
if ((data_type != MPS_IPD) && (data[0] + data[1])) {
int sym = get_bits1(gb) ? -1 : 1;
data[0] *= sym;
data[1] *= sym;
}
if (data[0] - data[1]) {
if (get_bits1(gb))
FFSWAP(int16_t, data[0], data[1]);
}
}
/* NB: NOT a standard integer log2! */
static int mps_log2(int s) {
if (s)
s--;
int v = 0;
while (s) {
s >>= 1;
v++;
}
return v;
}
static void pcm_decode(GetBitContext *gb, int16_t *data0, int16_t *data1,
int16_t offset, int nb_pcm_data_bands,
int nb_quant_steps, int nb_levels)
{
int max_group_len;
switch (nb_levels) {
case 3: max_group_len = 5; break;
case 7: max_group_len = 6; break;
case 11: max_group_len = 2; break;
case 13: max_group_len = 4; break;
case 19: max_group_len = 4; break;
case 25: max_group_len = 3; break;
case 51: max_group_len = 4; break;
case 4: case 8: case 15: case 16: case 26: case 31:
max_group_len = 1;
break;
default:
return;
};
av_assert1(data0 || data1);
int pcm_chunk_size[7] = { 0 };
int tmp = 1;
for (int i = 1; i <= max_group_len; i++) {
tmp *= nb_levels;
pcm_chunk_size[i] = mps_log2(tmp);
}
for (int i = 0; i < nb_pcm_data_bands; i+= max_group_len) {
int group_len = FFMIN(max_group_len, nb_pcm_data_bands - i);
int pcm = get_bits(gb, pcm_chunk_size[group_len]);
for (int j = 0; j < group_len; j++) {
int idx = i + (group_len - 1) - j;
int val = pcm % nb_levels;
if (data0 && data1) {
if (idx % 2)
data1[idx / 2] = val - offset;
else
data0[idx / 2] = val - offset;
} else if (!data1) {
data0[idx] = val - offset;
} else if (!data0) {
data1[idx] = val - offset;
}
pcm = (pcm - val) / nb_levels;
}
}
}
static void huff_data_2d(GetBitContext *gb, int16_t *part0_data[2], int16_t (*data)[2],
int data_bands, int stride, enum AACMPSDataType data_type,
int diff_freq, int freq_pair)
{
int16_t lav_idx = huff_dec_1D(gb, ff_aac_hcod_lav_idx);
uint8_t lav = ff_aac_lav_tab_XXX[data_type][-(lav_idx + 1)];
const int16_t (*hcod1D)[2];
const int16_t (*hcod2D)[2];
switch (data_type) {
case MPS_CLD:
hcod1D = ff_aac_hcod_firstband_CLD;
switch (lav) {
case 3: hcod2D = ff_aac_hcod2D_CLD_03[freq_pair][diff_freq]; break;
case 5: hcod2D = ff_aac_hcod2D_CLD_05[freq_pair][diff_freq]; break;
case 7: hcod2D = ff_aac_hcod2D_CLD_07[freq_pair][diff_freq]; break;
case 9: hcod2D = ff_aac_hcod2D_CLD_09[freq_pair][diff_freq]; break;
}
break;
case MPS_ICC:
hcod1D = ff_aac_hcod_firstband_ICC;
switch (lav) {
case 1: hcod2D = ff_aac_hcod2D_ICC_01[freq_pair][diff_freq]; break;
case 3: hcod2D = ff_aac_hcod2D_ICC_03[freq_pair][diff_freq]; break;
case 5: hcod2D = ff_aac_hcod2D_ICC_05[freq_pair][diff_freq]; break;
case 7: hcod2D = ff_aac_hcod2D_ICC_07[freq_pair][diff_freq]; break;
}
break;
case MPS_IPD:
hcod1D = ff_aac_hcod_firstband_IPD;
switch (lav) {
case 1: hcod2D = ff_aac_hcod2D_IPD_01[freq_pair][diff_freq]; break;
case 3: hcod2D = ff_aac_hcod2D_IPD_03[freq_pair][diff_freq]; break;
case 5: hcod2D = ff_aac_hcod2D_IPD_05[freq_pair][diff_freq]; break;
case 7: hcod2D = ff_aac_hcod2D_IPD_07[freq_pair][diff_freq]; break;
}
break;
default:
av_unreachable("Invalid data type");
}
if (part0_data[0])
part0_data[0][0] = -(huff_dec_1D(gb, hcod1D) + 1);
if (part0_data[1])
part0_data[1][0] = -(huff_dec_1D(gb, hcod1D) + 1);
int i = 0;
int esc_cnt = 0;
int16_t esc_data[2][28];
int esc_idx[28];
for (; i < data_bands; i += stride) {
if (huff_dec_2D(gb, hcod2D, data[i]))
esc_idx[esc_cnt++] = i; /* Escape */
else
symmetry_data(gb, data[i], lav, data_type);
}
if (esc_cnt) {
pcm_decode(gb, esc_data[0], esc_data[1],
0, 2*esc_cnt, 0, (2*lav + 1));
for (i = 0; i < esc_cnt; i++) {
data[esc_idx[i]][0] = esc_data[0][i] - lav;
data[esc_idx[i]][0] = esc_data[0][i] - lav;
}
}
}
static int huff_decode(GetBitContext *gb, int16_t *data[2],
enum AACMPSDataType data_type, int diff_freq[2],
int num_val, int *time_pair)
{
int16_t pair_vec[28][2];
int num_val_ch[2] = { num_val, num_val };
int16_t *p0_data[2][2] = { 0 };
int df_rest_flag[2] = { 0, 0 };
/* Coding scheme */
int dim = get_bits1(gb);
if (dim) { /* 2D */
*time_pair = 0;
if (data[0] && data[1])
*time_pair = get_bits1(gb);
if (*time_pair) {
if (diff_freq[0] || diff_freq[1]) {
p0_data[0][0] = data[0];
p0_data[0][1] = data[1];
data[0] += 1;
data[1] += 1;
num_val_ch[0] -= 1;
}
int diff_mode = 1;
if (!diff_freq[0] || !diff_freq[1])
diff_mode = 0; // time
huff_data_2d(gb, p0_data[0], pair_vec, num_val_ch[0], 1, data_type,
diff_mode, 0);
for (int i = 0; i < num_val_ch[0]; i++) {
data[0][i] = pair_vec[i][0];
data[1][i] = pair_vec[i][1];
}
} else {
if (data[0]) {
if (diff_freq[0]) {
p0_data[0][0] = data[0];
p0_data[0][1] = NULL;
num_val_ch[0] -= 1;
data[0]++;
}
df_rest_flag[0] = num_val_ch[0] % 2;
if (df_rest_flag[0])
num_val_ch[0] -= 1;
if (num_val_ch[0] < 0)
return AVERROR(EINVAL);
}
if (data[1]) {
if (diff_freq[1]) {
p0_data[1][0] = NULL;
p0_data[1][1] = data[1];
num_val_ch[1] -= 1;
data[1]++;
}
df_rest_flag[1] = num_val_ch[1] % 2;
if (df_rest_flag[1])
num_val_ch[1] -= 1;
if (num_val_ch[1] < 0)
return AVERROR(EINVAL);
}
if (data[0]) {
huff_data_2d(gb, p0_data[0], pair_vec, num_val_ch[0], 2, data_type,
diff_freq[0], 1);
if (df_rest_flag[0])
huff_data_1d(gb, data[0] + num_val_ch[0], 1,
data_type, !diff_freq[0], 0);
}
if (data[1]) {
huff_data_2d(gb, p0_data[1], pair_vec + 1, num_val_ch[1], 2, data_type,
diff_freq[1], 1);
if (df_rest_flag[1])
huff_data_1d(gb, data[1] + num_val_ch[1], 1,
data_type, !diff_freq[1], 0);
}
}
} else { /* 1D */
if (data[0])
huff_data_1d(gb, data[0], num_val, data_type, diff_freq[0], diff_freq[0]);
if (data[1])
huff_data_1d(gb, data[1], num_val, data_type, diff_freq[1], diff_freq[1]);
}
return 0;
}
static void diff_freq_decode(const int16_t *diff, int16_t *out, int nb_val)
{
int i = 0;
out[0] = diff[0];
for (i = 1; i < nb_val; i++)
out[i] = out[i - 1] + diff[i];
}
static void diff_time_decode_backwards(const int16_t *prev, const int16_t *diff,
int16_t *out, const int mixed_diff_type,
const int nb_val)
{
if (mixed_diff_type)
out[0] = diff[0];
for (int i = mixed_diff_type; i < nb_val; i++)
out[i] = prev[i] + diff[i];
}
static void diff_time_decode_forwards(const int16_t *prev, const int16_t *diff,
int16_t *out, const int mixed_diff_type,
const int nb_val)
{
if (mixed_diff_type)
out[0] = diff[0];
for (int i = mixed_diff_type; i < nb_val; i++)
out[i] = prev[i] - diff[i];
}
static void attach_lsb(GetBitContext *gb, int16_t *data_msb,
int offset, int nb_lsb, int nb_val,
int16_t *data)
{
for (int i = 0; i < nb_val; i++) {
int msb = data_msb[i];
if (nb_lsb > 0) {
uint32_t lsb = get_bits(gb, nb_lsb);
data[i] = ((msb << nb_lsb) | lsb) - offset;
} else {
data[i] = msb - offset;
}
}
}
static int ec_pair_dec(GetBitContext *gb,
int16_t set1[MPS_MAX_PARAM_BANDS],
int16_t set2[MPS_MAX_PARAM_BANDS], int16_t *last,
enum AACMPSDataType data_type, int start_band, int nb_bands,
int pair, int coarse,
int diff_time_back)
{
int attach_lsb_flag = 0;
int quant_levels = 0;
int quant_offset = 0;
switch (data_type) {
case MPS_CLD:
if (coarse) {
attach_lsb_flag = 0;
quant_levels = 15;
quant_offset = 7;
} else {
attach_lsb_flag = 0;
quant_levels = 31;
quant_offset = 15;
}
break;
case MPS_ICC:
if (coarse) {
attach_lsb_flag = 0;
quant_levels = 4;
quant_offset = 0;
} else {
attach_lsb_flag = 0;
quant_levels = 8;
quant_offset = 0;
}
break;
case MPS_IPD:
if (!coarse) {
attach_lsb_flag = 1;
quant_levels = 16;
quant_offset = 0;
} else {
attach_lsb_flag = 0;
quant_levels = 8;
quant_offset = 0;
}
break;
}
int16_t last_msb[28] = { 0 };
int16_t data_pair[2][28] = { 0 };
int16_t data_diff[2][28] = { 0 };
int16_t *p_data[2];
int pcm_coding = get_bits1(gb);
if (pcm_coding) { /* bsPcmCoding */
int nb_pcm_vals;
if (pair) {
p_data[0] = data_pair[0];
p_data[1] = data_pair[1];
nb_pcm_vals = 2 * nb_bands;
} else {
p_data[0] = data_pair[0];
p_data[1] = NULL;
nb_pcm_vals = nb_bands;
}
int nb_quant_steps;
switch (data_type) {
case MPS_CLD: nb_quant_steps = coarse ? 15 : 31; break;
case MPS_ICC: nb_quant_steps = coarse ? 4 : 8; break;
case MPS_IPD: nb_quant_steps = coarse ? 8 : 16; break;
}
pcm_decode(gb, p_data[0], p_data[1], quant_offset, nb_pcm_vals,
nb_quant_steps, quant_levels);
memcpy(&set1[start_band], data_pair[0], 2*nb_bands);
if (pair)
memcpy(&set2[start_band], data_pair[1], 2*nb_bands);
return 0;
}
if (pair) {
p_data[0] = data_pair[0];
p_data[1] = data_pair[1];
} else {
p_data[0] = data_pair[0];
p_data[1] = NULL;
}
int diff_freq[2] = { 1, 1 };
int backwards = 1;
if (pair || diff_time_back)
diff_freq[0] = !get_bits1(gb);
if (pair && (diff_freq[0] || diff_time_back))
diff_freq[1] = !get_bits1(gb);
int time_pair;
huff_decode(gb, p_data, data_type, diff_freq,
nb_bands, &time_pair);
/* Differential decoding */
if (!diff_freq[0] || !diff_freq[1]) {
if (0 /* 1 if SAOC */) {
backwards = 1;
} else {
if (pair) {
if (!diff_freq[0] && !diff_time_back)
backwards = 0;
else if (!diff_freq[1])
backwards = 1;
else
backwards = !get_bits1(gb);
} else {
backwards = 1;
}
}
}
int mixed_time_pair = (diff_freq[0] != diff_freq[1]) && time_pair;
if (backwards) {
if (diff_freq[0]) {
diff_freq_decode(data_diff[0], data_pair[0], nb_bands);
} else {
for (int i = 0; i < nb_bands; i++) {
last_msb[i] = last[i + start_band] + quant_offset;
if (attach_lsb_flag) {
last_msb[i] >>= 1;
}
}
diff_time_decode_backwards(last_msb, data_diff[0], data_pair[0],
mixed_time_pair, nb_bands);
}
if (diff_freq[1])
diff_freq_decode(data_diff[1], data_pair[1], nb_bands);
else
diff_time_decode_backwards(data_pair[0], data_diff[1],
data_pair[1], mixed_time_pair, nb_bands);
} else {
diff_freq_decode(data_diff[1], data_pair[1], nb_bands);
if (diff_freq[0])
diff_freq_decode(data_diff[0], data_pair[0], nb_bands);
else
diff_time_decode_forwards(data_pair[1], data_diff[0], data_pair[0],
mixed_time_pair, nb_bands);
}
/* Decode LSBs */
attach_lsb(gb, p_data[0], quant_offset, attach_lsb_flag,
nb_bands, p_data[0]);
if (pair)
attach_lsb(gb, p_data[1], quant_offset, attach_lsb_flag,
nb_bands, p_data[1]);
memcpy(&set1[start_band], data_pair[0], 2*nb_bands);
if (pair)
memcpy(&set2[start_band], data_pair[1], 2*nb_bands);
return 0;
}
static void coarse_to_fine(int16_t *data, enum AACMPSDataType data_type,
int start_band, int end_band)
{
for (int i = start_band; i < end_band; i++)
data[i] *= 2;
if (data_type == MPS_CLD) {
for (int i = start_band; i < end_band; i++) {
if (data[i] == -14)
data[i] = -15;
else if (data[i] == 14)
data[i] = 15;
}
}
}
static void fine_to_coarse(int16_t *data, enum AACMPSDataType data_type,
int start_band, int end_band)
{
for (int i = start_band; i < end_band; i++) {
if (data_type == MPS_CLD)
data[i] /= 2;
else
data[i] >>= 1;
}
}
static int get_freq_strides(int16_t *freq_strides, int band_stride,
int start_band, int end_band)
{
int data_bands = (end_band - start_band - 1) / band_stride + 1;
freq_strides[0] = start_band;
for (int i = 1; i <= data_bands; i++)
freq_strides[i] = freq_strides[i - 1] + band_stride;
int offs = 0;
while (freq_strides[data_bands] > end_band) {
if (offs < data_bands)
offs++;
for (int i = offs; i <= data_bands; i++) {
freq_strides[i]--;
}
}
for (int i = 0; i <= data_bands; i++)
freq_strides[i] = av_clip_uintp2(freq_strides[i], 2);
return data_bands;
}
static const int stride_table[4] = { 1, 2, 5, 28 };
int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld,
enum AACMPSDataType data_type,
int default_val,
int start_band, int end_band, int frame_indep_flag,
int indep_flag, int nb_param_sets)
{
for (int i = 0; i < nb_param_sets; i++) {
ld->data_mode[i] = get_bits(gb, 2);
/* Error checking */
if ((indep_flag && !i && (ld->data_mode[i] == 1 || ld->data_mode[i] == 2)) ||
((i == (nb_param_sets - 1) && (ld->data_mode[i] == 2)))) {
return AVERROR(EINVAL);
}
}
int set_idx = 0;
int data_pair = 0;
bool old_coarse = ld->quant_coarse_prev;
for (int i = 0; i < nb_param_sets; i++) {
if (!ld->data_mode[i]) {
for (int j = start_band; j < end_band; j++)
ld->last_data[j] = default_val;
old_coarse = 0;
}
if (ld->data_mode[i] != 3) {
continue;
} else if (data_pair) {
data_pair = 0;
continue;
}
data_pair = get_bits1(gb);
ld->coarse_quant[set_idx] = get_bits1(gb);
ld->freq_res[set_idx] = get_bits(gb, 2);
if (ld->coarse_quant[set_idx] != old_coarse) {
if (old_coarse)
coarse_to_fine(ld->last_data, data_type, start_band, end_band);
else
fine_to_coarse(ld->last_data, data_type, start_band, end_band);
}
int data_bands = get_freq_strides(ld->freq_res,
stride_table[ld->freq_res[set_idx]],
start_band, end_band);
if (set_idx + data_pair > MPS_MAX_PARAM_SETS)
return AVERROR(EINVAL);
for (int j = 0; j < data_bands; j++)
ld->last_data[start_band + j] = ld->last_data[ld->freq_res[j]];
int err = ec_pair_dec(gb,
ld->data[set_idx + 0], ld->data[set_idx + 1],
ld->last_data, data_type, start_band, end_band - start_band,
data_pair, ld->coarse_quant[set_idx],
!(indep_flag && (i == 0)) || (set_idx > 0));
if (err < 0)
return err;
if (data_type == MPS_IPD) {
const int mask = ld->coarse_quant[set_idx] ? 0x7 : 0xF;
for (int j = 0; j < data_bands; j++)
for (int k = ld->freq_res[j + 0]; k < ld->freq_res[j + 1]; k++)
ld->last_data[k] = ld->data[set_idx + data_pair][start_band + j] & mask;
} else {
for (int j = 0; j < data_bands; j++)
for (int k = ld->freq_res[j + 0]; k < ld->freq_res[j + 1]; k++)
ld->last_data[k] = ld->data[set_idx + data_pair][start_band + j];
}
old_coarse = ld->coarse_quant[set_idx];
if (data_pair) {
ld->coarse_quant[set_idx + 1] = ld->coarse_quant[set_idx];
ld->freq_res[set_idx + 1] = ld->freq_res[set_idx];
}
set_idx += data_pair + 1;
}
ld->quant_coarse_prev = old_coarse;
return 0;
}
int ff_aac_huff_dec_reshape(GetBitContext *gb, int16_t *out_data,
int nb_val)
{
int val, len;
int val_received = 0;
int16_t rl_data[2] = { 0 };
while (val_received < nb_val) {
huff_dec_2D(gb, ff_aac_hcod2D_reshape, rl_data);
val = rl_data[0];
len = rl_data[1] + 1;
if (val_received + len > nb_val)
return AVERROR(EINVAL);
for (int i = val_received; i < val_received + len; i++)
out_data[i] = val;
val_received += len;
}
return 0;
}
static void create_mapping(int map[MPS_MAX_PARAM_BANDS + 1],
int start_band, int stop_band, int stride)
{
int diff[MPS_MAX_PARAM_BANDS + 1];
int src_bands = stop_band - start_band;
int dst_bands = (src_bands - 1) / stride + 1;
if (dst_bands < 1)
dst_bands = 1;
int bands_achived = dst_bands * stride;
int bands_diff = src_bands - bands_achived;
for (int i = 0; i < dst_bands; i++)
diff[i] = stride;
int incr, k;
if (bands_diff > 0) {
incr = -1;
k = dst_bands - 1;
} else {
incr = 1;
k = 0;
}
while (bands_diff != 0) {
diff[k] = diff[k] - incr;
k = k + incr;
bands_diff = bands_diff + incr;
if (k >= dst_bands) {
if (bands_diff > 0) {
k = dst_bands - 1;
} else if (bands_diff < 0) {
k = 0;
}
}
}
map[0] = start_band;
for (int i = 0; i < dst_bands; i++)
map[i + 1] = map[i] + diff[i];
}
static void map_freq(int16_t *dst, const int16_t *src,
int *map, int nb_bands)
{
for (int i = 0; i < nb_bands; i++) {
int value = src[i + map[0]];
int start_band = map[i];
int stop_band = map[i + 1];
for (int j = start_band; j < stop_band; j++) {
dst[j] = value;
}
}
}
static int deq_idx(int value, enum AACMPSDataType data_type)
{
int idx = -1;
switch (data_type) {
case MPS_CLD:
if (((value + 15) >= 0) && ((value + 15) < 31))
idx = (value + 15);
break;
case MPS_ICC:
if ((value >= 0) && (value < 8))
idx = value;
break;
case MPS_IPD:
/* (+/-)15 * MAX_PARAMETER_BANDS for differential coding in frequency
* domain (according to rbl) */
if ((value >= -420) && (value <= 420))
idx = (value & 0xf);
break;
}
return idx;
}
int ff_aac_map_index_data(AACMPSLosslessData *ld,
enum AACMPSDataType data_type,
int dst_idx[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS],
int default_value, int start_band, int stop_band,
int nb_param_sets, const int *param_set_idx,
int extend_frame)
{
if (nb_param_sets > MPS_MAX_PARAM_SETS)
return AVERROR(EINVAL);
int data_mode_3_idx[MPS_MAX_PARAM_SETS] = { 0 };
int nb_data_mode_3 = 0;
for (int i = 0; i < nb_param_sets; i++) {
if (ld->data_mode[i] == 3) {
data_mode_3_idx[nb_data_mode_3] = i;
nb_data_mode_3++;
}
}
int set_idx = 0;
/* Prepare data */
int interpolate[MPS_MAX_PARAM_SETS] = { 0 };
int16_t tmp_idx_data[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS] = { 0 };
for (int i = 0; i < nb_param_sets; i++) {
if (ld->data_mode[i] == 0) {
ld->coarse_quant_no[i] = 0;
for (int band = start_band; band < stop_band; band++)
tmp_idx_data[i][band] = default_value;
for (int band = start_band; band < stop_band; band++)
ld->last_data[band] = tmp_idx_data[i][band];
ld->quant_coarse_prev = 0;
}
if (ld->data_mode[i] == 1) {
for (int band = start_band; band < stop_band; band++)
tmp_idx_data[i][band] = ld->last_data[band];
ld->coarse_quant_no[i] = ld->quant_coarse_prev;
}
if (ld->data_mode[i] == 2) {
for (int band = start_band; band < stop_band; band++)
tmp_idx_data[i][band] = ld->last_data[band];
ld->coarse_quant_no[i] = ld->quant_coarse_prev;
interpolate[i] = 1;
} else {
interpolate[i] = 0;
}
if (ld->data_mode[i] == 3) {
int stride;
int parmSlot = data_mode_3_idx[set_idx];
stride = stride_table[ld->freq_res[set_idx]];
int dataBands = (stop_band - start_band - 1) / stride + 1;
int tmp[MPS_MAX_PARAM_BANDS + 1];
create_mapping(tmp, start_band, stop_band, stride);
map_freq(tmp_idx_data[parmSlot], ld->data[set_idx],
tmp, dataBands);
for (int band = start_band; band < stop_band; band++)
ld->last_data[band] = tmp_idx_data[parmSlot][band];
ld->quant_coarse_prev = ld->coarse_quant[set_idx];
ld->coarse_quant_no[i] = ld->coarse_quant[set_idx];
set_idx++;
}
}
/* Map all coarse data to fine */
for (int i = 0; i < nb_param_sets; i++) {
if (ld->coarse_quant_no[i] == 1) {
coarse_to_fine(tmp_idx_data[i], data_type, start_band,
stop_band - start_band);
ld->coarse_quant_no[i] = 0;
}
}
/* Interpolate */
int i1 = 0;
for (int i = 0; i < nb_param_sets; i++) {
if (interpolate[i] != 1) {
i1 = i;
} else {
int xi, i2, x1, x2;
for (i2 = i; i2 < nb_param_sets; i2++)
if (interpolate[i2] != 1)
break;
if (i2 >= nb_param_sets)
return AVERROR(EINVAL);
x1 = param_set_idx[i1];
xi = param_set_idx[i];
x2 = param_set_idx[i2];
for (int band = start_band; band < stop_band; band++) {
int yi, y1, y2;
y1 = tmp_idx_data[i1][band];
y2 = tmp_idx_data[i2][band];
if (x1 != x2) {
yi = y1 + (xi - x1) * (y2 - y1) / (x2 - x1);
} else {
yi = y1 /*+ (xi-x1)*(y2-y1)/1e-12*/;
}
tmp_idx_data[i][band] = yi;
}
}
}
/* Dequantize data and apply factorCLD if necessary */
for (int ps = 0; ps < nb_param_sets; ps++) {
/* Dequantize data */
for (int band = start_band; band < stop_band; band++) {
dst_idx[ps][band] = deq_idx(tmp_idx_data[ps][band],
data_type);
if (dst_idx[ps][band] == -1)
dst_idx[ps][band] = default_value;
}
}
if (extend_frame) {
if (data_type == MPS_IPD)
ld->coarse_quant[nb_param_sets] = ld->coarse_quant[nb_param_sets - 1];
for (int band = start_band; band < stop_band; band++)
dst_idx[nb_param_sets][band] = dst_idx[nb_param_sets - 1][band];
}
return 0;
}
+65
View File
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2025 Lynne <dev@lynne.ee>
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_AAC_AACDEC_USAC_MPS212_H
#define AVCODEC_AAC_AACDEC_USAC_MPS212_H
#include <stdbool.h>
#include "libavcodec/get_bits.h"
#include "libavcodec/aac.h"
enum AACMPSDataType {
MPS_CLD = 0,
MPS_ICC,
MPS_IPD,
MPS_ELE_NB,
};
typedef struct AACMPSLosslessData {
int16_t data[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS];
int16_t last_data[MPS_MAX_PARAM_BANDS];
int16_t data_mode[MPS_MAX_PARAM_SETS];
bool coarse_quant[MPS_MAX_PARAM_SETS];
int16_t freq_res[MPS_MAX_PARAM_SETS];
int16_t coarse_quant_no[MPS_MAX_PARAM_SETS];
bool quant_coarse_prev;
} AACMPSLosslessData;
int ff_aac_ec_data_dec(GetBitContext *gb, AACMPSLosslessData *ld,
enum AACMPSDataType data_type,
int default_val,
int start_band, int end_band, int frame_indep_flag,
int indep_flag, int nb_param_sets);
int ff_aac_map_index_data(AACMPSLosslessData *ld,
enum AACMPSDataType data_type,
int dst_idx[MPS_MAX_PARAM_SETS][MPS_MAX_PARAM_BANDS],
int default_value, int start_band, int stop_band,
int nb_param_sets, const int *param_set_idx,
int extend_frame);
int ff_aac_huff_dec_reshape(GetBitContext *gb, int16_t *out_data,
int nb_val);
#endif /* AVCODEC_AAC_AACDEC_USAC_MPS212_H */
+5 -5
View File
@@ -147,15 +147,15 @@ get_next:
} else {
#if CONFIG_AAC_PARSER
AACADTSHeaderInfo hdr;
GetBitContext gb;
init_get_bits8(&gb, buf, buf_size);
if (buf_size < AV_AAC_ADTS_HEADER_SIZE ||
ff_adts_header_parse(&gb, &hdr) < 0)
ff_adts_header_parse_buf(buf, &hdr) < 0)
return i;
avctx->profile = hdr.object_type - 1;
s1->key_frame = (avctx->profile == AV_PROFILE_AAC_USAC) ? get_bits1(&gb) : 1;
if (avctx->profile == AV_PROFILE_UNKNOWN)
avctx->profile = hdr.object_type - 1;
/* ADTS does not support USAC */
s1->key_frame = 1;
bit_rate = hdr.bit_rate;
#endif
}
+6 -5
View File
@@ -24,6 +24,7 @@
#include "aac_ac3_parser.h"
#include "adts_header.h"
#include "adts_parser.h"
#include "parser_internal.h"
#include "libavutil/intreadwrite.h"
static int aac_sync(uint64_t state, int *need_next_header, int *new_frame_start)
@@ -51,10 +52,10 @@ static av_cold int aac_parse_init(AVCodecParserContext *s1)
}
const AVCodecParser ff_aac_parser = {
.codec_ids = { AV_CODEC_ID_AAC },
const FFCodecParser ff_aac_parser = {
PARSER_CODEC_LIST(AV_CODEC_ID_AAC),
.priv_data_size = sizeof(AACAC3ParseContext),
.parser_init = aac_parse_init,
.parser_parse = ff_aac_ac3_parse,
.parser_close = ff_parse_close,
.init = aac_parse_init,
.parse = ff_aac_ac3_parse,
.close = ff_parse_close,
};
+1 -1
View File
@@ -173,7 +173,7 @@ static av_always_inline float quantize_and_encode_band_cost_template(
if (BT_ESC) {
for (int j = 0; j < 2; j++) {
if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 64.0f) {
int coef = av_clip_uintp2(quant(fabsf(in[i+j]), Q, ROUNDING), 13);
int coef = av_clip(quant(fabsf(in[i+j]), Q, ROUNDING), 16, (1 << 13) - 1);
int len = av_log2(coef);
put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2);
+2 -2
View File
@@ -50,7 +50,7 @@ static inline void quantize_bands(int *out, const float *in, const float *scaled
{
for (int i = 0; i < size; i++) {
float qc = scaled[i] * Q34;
int tmp = (int)FFMIN(qc + rounding, (float)maxval);
int tmp = (int)FFMIN((float)(qc + rounding), (float)maxval);
if (is_signed && in[i] < 0.0f) {
tmp = -tmp;
}
@@ -65,7 +65,7 @@ static inline void ff_aacenc_dsp_init(AACEncDSPContext *s)
#if ARCH_RISCV
ff_aacenc_dsp_init_riscv(s);
#elif ARCH_X86
#elif ARCH_X86 && HAVE_X86ASM
ff_aacenc_dsp_init_x86(s);
#elif ARCH_AARCH64
ff_aacenc_dsp_init_aarch64(s);

Some files were not shown because too many files have changed in this diff Show More