1
0
mirror of https://git.ffmpeg.org/ffmpeg.git synced 2026-10-24 02:09:03 +03:00
Commit Graph

1871 Commits

Author SHA1 Message Date
Romain Beauxis
843e83ed2d avformat/seek: leave the pre-roll before the target of avformat_seek_file()
Demuxers and decoders declare the pre-roll an audio stream needs in
AVCodecParameters.seek_preroll, but nothing used it, so a seek landed on
the frame that holds the target and the first frame decoded there was not
reliable.

Move the target back by the largest pre-roll of the audio streams that
are not discarded, whichever stream the seek is on, as they all land
near the target, without leaving the range the caller asked for or going
before the start of the stream. A finite end of the range moves back as
much as the target, and an open end stays open. The pre-roll is rounded up so that it is never shorter
than declared. The caller still discards what it decodes before the
target, as it already had to for a seek that does not land on it. Seeks
by byte or by frame number are left alone. When the start of the stream
is unknown, the earlier target may come before the first packet, so if
the seek fails, it is done again to the target the caller asked for.

The seeks of the tests now land one frame earlier for AAC, and about
80 ms earlier for Opus in Matroska. A forward seek still lands forward,
one frame earlier. A seek on the video stream just after a keyframe now
lands on the keyframe before, to leave room for the pre-roll of AAC. A
seek through concat lands earlier, as concat and the file it reads both
move the target back. A seek close to the start of ADTS, whose start is
unknown, lands at the start instead of failing.
2026-10-23 15:38:04 +00:00
Romain Beauxis
ad74ac4cee avcodec/aac: export the seek pre-roll
AAC decoding overlaps each frame with the previous one, so the first
frame decoded after a seek is only reliable once the frame before it has
been decoded. Opus declares its pre-roll in AVCodecParameters.seek_preroll,
AAC did not.

Have the decoder export its pre-roll, as it knows the frame length: 1024
or 960 samples, half of it for LD and ELD, and 1024 or 768 for USAC.
ELD needs three frames, as its low delay filterbank uses a window four
frames long. SBR keeps the state of the frame before, in its
filterbanks, its high-frequency generator and its gain smoothing, and
codes its envelopes and noise floors relative to the frame before, so
it needs one more frame, of twice as many output samples when it
doubles the sample rate. Without it, the first 256 samples decoded
after a seek into HE-AAC differ from continuous decoding by -36.6 dB
with one frame of pre-roll, and not at all with two.

Implicit SBR is only known once found in a frame, so the pre-roll is
raised then, as it is for USAC, whose frame length depends on its SBR
ratio. Demuxers get it through the stream probing, whatever the
container. A larger pre-roll declared by the container is kept, and the
documentation of AVCodecContext.seek_preroll now says a decoder may
raise it.

The output of an AAC-LC stream decoded after a seek has an error of
-9.5 dB in the first 1024 samples, against -85 dB elsewhere, which one
frame of pre-roll removes.

The pre-roll tests now show the declared value, for AAC in every
container, 4096 samples for HE-AAC, explicit or implicit, 2048 for SBR
that does not double the sample rate, and 1536 for ELD.
2026-10-23 15:38:04 +00:00
Romain Beauxis
23c1a2dcb4 avcodec/codec_par: do not turn the container's priming into decoder delay
avcodec_parameters_to_context() copied AVCodecParameters.initial_padding
into both AVCodecContext.initial_padding and AVCodecContext.delay. Since
ff98352c3d, avcodec_open2() sets skip_samples from AVCodecContext.delay
for every decoder, so a decoder opened on a stream with container
priming, such as AAC in MP4, started out with that many samples pending
to be discarded.

The two are different things. initial_padding is the encoder priming at
the start of the stream, which the demuxer already attaches to the first
packet as skip-samples side data. delay is a property of the decoder
instance, which only decoders that know their own delay export in init.
Applying the container's value at open discards it from whatever the
first decoded packet turns out to be, so seeking before the first
decode drops real samples. For a mono 44.1 kHz AAC-LC file with 2048
priming, ffmpeg -ss 530 -t 10 -i in.m4a returned 439152 instead of
441000 samples, with the audio starting 1848 samples late.

Stop copying initial_padding into delay. Decoders that export a delay,
such as libopus, native opus, wma, lc3, ape and mpegh, set it
themselves and are unaffected, and decoding from the start of a stream
is unchanged since the side data carries the priming. The documentation
of AVCodecContext.delay now says it is discarded when the decoder is
opened, and points to seek_preroll for seeking.

The seek tests of AAC in MP4 and CAF now start at the requested time
instead of late by the container's priming.
2026-10-23 15:38:04 +00:00
James Almer
e5605b4bb4 avformat: add an split Color and Alpha channel Stream Group
Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-23 11:22:05 -03:00
Michael Niedermayer
e525b51aa0 doc/APIchanges: fill in missing things
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-10-23 06:44:02 +02:00
Michael Niedermayer
b8249f73a7 avutil/hwcontext: add av_hwframe_get_transfer_buffer()
It allocates the buffers of a software frame used for a transfer to or
from a hardware frames context out of a pool kept by that context.

Assisted-by: Claude
2026-10-21 19:32:23 +00:00
Michael Niedermayer
d1434518fb avutil/encryption_info: add av_encryption_init_info_append_side_data()
Appends to already serialized init info side data, growing it with
av_fast_realloc(), so a demuxer can collect pssh records in linear time
without depending on the side data format.
2026-10-19 17:14:29 +02:00
Tom Needham
0ec6a0872d libavcodec: Add Infinity IMM6 Decoder
Signed-off-by: Tom Needham <06needhamt@gmail.com>
2026-10-18 20:57:48 +00:00
Michael Niedermayer
dfaa3ba5f3 avformat/avio: add avio_open_dir2() with an interrupt callback
A directory listing that blocks in a protocol could not be
interrupted; avio_open_dir2() passes an interrupt callback to the
protocol like avio_open2() does.

Assisted-by: Claude
2026-10-18 03:19:28 +00:00
James Almer
2ac7367f2f avutil/gain_map: move ISO 21496-1 gain map payload parsing from libavcodec
And export both functions. This is needed for a following change that will make
use of these functions from lavf.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-12 10:39:10 -03:00
James Almer
546cf7181d avcodec/packet: add a Gain Map parameters side data type
Mirroring the frame one. Will be used by demuxers as stream or stream group
side data.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-12 10:37:15 -03:00
James Almer
184d925444 avformat: add side data fields to Stream Groups
Deprecate the Tile Grid specific ones, while keeping it in sync with the new
fields until removed.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-12 10:36:18 -03:00
Lynne
e7420679a3 lavu/raw_color_params: add Panasonic RW2 parameters
The as-shot white balance of RW2 files, as red and blue multipliers
relative to green. The files carry no camera matrix.
2026-10-08 14:21:36 +09:00
Lynne
a796d86a30 lavc: add a Panasonic RW2 codec ID 2026-10-08 14:21:32 +09:00
James Almer
7304d10462 avutil/opt: add a serialization flag to exclude options with specific flags
Useful for example for scenarios like wanting to serialize only options that
are not marked as deprecated.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-07 18:40:30 -03:00
Lynne
2983c23762 avutil: add AV_PIX_FMT_XYZP12
Planar 12-bit XYZ, the natural planar layout for DCI JPEG2000 content.
Also wire it into the Vulkan format table and shader format helpers.
2026-10-06 13:31:37 +09:00
James Almer
b2f001ae9a avformat/version: properly bump version for Gain Map stream group
The version was mistakenly reverted from 63.7.101 to 63.7.100 in commit
caa5824750.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-10-04 13:59:12 -03:00
Kacper Michajłow
30e7a93bee avfilter/buffersink: add support for chroma locations
Lets the caller read back the negotiated chroma location and constrain the
sink to a list of accepted ones.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-01 14:31:15 +00:00
Kacper Michajłow
f3d2f99263 avfilter/buffersrc: add chroma_location parameter
Lets the caller state the chroma siting of the frames it feeds in, which is
what the rest of the graph negotiates against. A tagged source constrains
the link to its own value, an untagged one places no constraint at all,
there being nothing to convert from.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-01 14:31:15 +00:00
Kacper Michajłow
c200628eac avcodec: add AV_CODEC_CONFIG_CHROMA_LOCATION
Lets an encoder state which chroma sample locations it can accept, so the
caller can convert to one.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-01 14:31:15 +00:00
Kacper Michajłow
08a654a564 avfilter: add link negotiation for AVChromaLocation
Chroma sample location is the last of the video colorimetry properties
without a negotiated link value, so nothing downstream can ask a filter for
a particular siting and no encoder can constrain the graph. Add it alongside
the existing color space, color range and alpha mode negotiation.

Merge conflicts are resolved by inserting a scale filter, the same way as
for color space and color range.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-10-01 14:31:15 +00:00
Niklas Haas
caa5824750 avformat: add AV_STREAM_GROUP_PARAMS_GAIN_MAP
To identify ISO 21496-1 gain maps.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-09-30 14:37:55 +02:00
Niklas Haas
b917a0fe1e avutil/gain_map: add AVGainMapParams and side data type
This commit just adds the public facing struct definitions and side data.
The struct follows ISO 21496-1 exactly, with a validation function to check
for representable and legal values.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-09-30 14:37:26 +02:00
James Almer
c6ea3979ef doc/APIchanges: add entries and version bump for the recent commits
Accidentally forgotten in the corresponding changes.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-09-27 20:32:38 -03:00
Kacper Michajłow
dea75789c3 avutil/file: add av_file_map_shared() and av_file_unmap_shared()
av_file_map() maps a private copy of a file by name. Code that shares a
file between processes needs the opposite, a writable mapping backed by
the file, of a descriptor it opened itself, that grows with the file.
Provide it with mmap() on POSIX and with a file mapping object on
Windows, which also extends the file to the requested size.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-09-23 16:50:45 +02:00
Jun Zhao
6e9100c648 lavc: add ASTC encoder/decoder via libastcenc
Add the ASTC codec ID and descriptor together with encoder and decoder
wrappers for Arm's astc-encoder library. Support the four ASTC profiles,
2D and 3D block footprints, LDR RGB/RGBA input, and floating-point HDR
input without clamping the decoded result to 8-bit.

Keep the ASTC image dimensions and compressed block sizes bounded by the
format and packet limits, and pass KTX-provided color profile metadata to
the decoder when no explicit profile was selected.

libastcenc is distributed under the Apache License 2.0, so the library is
only available when FFmpeg is built with --enable-version3; list it with
the other libraries that require that option.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2026-09-14 12:44:07 +00:00
yuanjia
c2bb5aa8d8 avcodec/riscv: add vector FDCT implementation
This RVV FDCT is ported from the AArch64 NEON implementation in
libavcodec/aarch64/fdctdsp_neon.S, which is based on libjpeg-turbo.
The original license notice is retained in the assembly file.

Requires RVV 1.0 with 64-bit element support (Zve64x) and VLEN >= 128.
Achieves approximately 3.29x speedup on SG2044 (VLEN=128).

Add FF_DCT_RVV to the public API, bump minor version, and add
Doxygen documentation.

Also:
- Fix include guard in riscv/fdct.h to match file path.
- Use AV_CPU_FLAG_RVV_I64 in automatic dispatch to avoid illegal
  instruction on Zve32x-only CPUs.

Signed-off-by: yuanjia <yuan.jia@sanechips.com.cn>
2026-09-11 15:59:03 +00:00
Zhao Zhili
903325e279 avcodec/mediacodec: document the ENOENT return of buffer release
053585bc91 made rendering an already released buffer return
AVERROR(ENOENT), but left the function description saying that
subsequent calls have no effect. It also omitted the API change entry.
2026-09-09 11:29:23 +08:00
Kacper Michajłow
655dc1af76 avutil/samplefmt: add AV_SAMPLE_FMT_DSD
DSD (Direct Stream Digital) is one-bit sigma-delta modulated audio,
found on Super Audio CDs and in DSF/DSDIFF files. libavcodec has
several decoders producing it internally (dsd_*, dst, wavpack DSD),
each converting to float PCM as part of decoding, which makes the
bitstream itself inaccessible to API users.

Add a dedicated sample format so raw DSD can be carried through the
pipeline, e.g. for bit-perfect pass-through to DSD capable DACs.

The format has no planar variant, altform references itself.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-09-06 00:48:24 +02:00
Michael Niedermayer
359bd3b8af avcodec: add AVCodecContext.skip_pred
Skipping prediction complements skip_idct and skip_loop_filter: with
both skip_pred and skip_idct discarding a frame, no pixel of that frame
is needed, so a decoder can drop all pixel operations and output the
frame with only its metadata valid. This allows callers to determine
timestamps, frame types and the reorder delay of a stream at a small
fraction of the cost of a full decode.
2026-09-05 01:38:48 +00:00
guy-with-a-why
74f1a4a160 avcodec: add FF_BUG_H264_DP_NNZ
9.2.1 makes an inter neighbour unavailable for the coeff_token nC
derivation under constrained intra prediction with slice data
partitioning, and step 7 then drops it from the (nA + nB + 1) >> 1
average. JM instead treats it as available with nN = 0, so it still
contributes. Every partitioned stream in the wild comes from JM or a
derivative, so the decoder has to be able to do both.

Signed-off-by: guy-with-a-why <aaron@iterationlab.io>
2026-08-31 18:13:21 +00:00
James Almer
0e45eebe49 avutil/channel_layout: remove back suffix from some layouts
The idea was for the suffix to refer to the fact they feature Top Back channels
instead of Top Side, but this distinction is unnecessary given there's no
confusion between back and side like with base level channels (Ls/Rs, Lss/Rss,
Lrs/Rsr), nor known specs where Top Side channels are used without Top Back
also being used.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-08-23 13:28:20 -03:00
James Almer
763c3356f1 avcodec/codec: rename encoder reconf codec cap
It was commited only a day ago, and the new name is more accurate, so this change should be safe.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-08-14 10:31:57 -03:00
James Almer
3776aadf4b avcodec/encode: add a function to gracefully reconfigure an encoder
In some cases there are compression and resource usage benefits from changing
certain encoder values at runtime over of closing, freeing, allocating and
initializing a whole new encoder. The most obvious case is rate control,
quality settings, and so on. As such, this commit introduces a new function
that attempts to reconfigure an opened encoder with a dictionary of options.

Private options that can be changed are flagged with the runtime AVOption flag.
Global options that can be changed, knowing that each encoder may support some
but not others and as such can't be flagged in the global AVOptions struct,
are signaled the same way through a new field in the FFCodecDefault struct.

An encoder may provide a callback function that will be called for the
reconfiguration process. Simple encoders that can work with only the AVOptions
being reset and don't require any extra steps may just let the default function
be called instead.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-08-13 11:03:51 -03:00
Romain Beauxis
e5ecfe8970 avformat/id3v2: make legacy COMM descriptor-as-key behavior opt-in
A COMM frame carries both a language and a short content descriptor, so its
only unambiguous metadata key is "comment-<descriptor>-<lang>", while the
extra export of the bare descriptor as a key silently overrides a real tag
whenever the descriptor matches a known tag name such as "album".

Restrict that legacy export to the container-level ID3v2 tag of callers that
ask for it through the new AVFMT_FLAG_LEGACY_ID3V2_COMM_KEYS flag (-fflags
+legacy_id3v2_comm_keys), which is deprecated along with
FF_API_OLD_ID3V2_COMMENT and only exists to give those callers a transition
path.
2026-08-12 12:39:44 +00:00
Kacper Michajłow
047eb18451 avcodec: add PCM DVD-Audio decoder
Decodes the LPCM variant found in DVD-Audio AOB streams. Unlike
DVD-Video LPCM it supports up to 192 kHz sample rates and splits
channels in two channel groups, which may use different quantization.
Samples are grouped in sets of 2 samples over all channels, with the
second channel group's data stored first within each set, as 16-bit
big-endian most significant parts followed by the remaining bits.

Based on information from expired US 6,580,671 patent et al.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-07-28 17:54:07 +02:00
Romain Beauxis
b0c702aec2 libavformat/id3v2: deprecate legacy COMM descriptor-as-key behavior 2026-07-18 09:59:57 -05:00
Timo Rothenpieler
ef3dcf4ea6 avutil/hwcontext_cuda: add CUarray surface pool support
Extend the internal CUDA frames context (CUDAFramesContext) to manage
block-linear CUarray surfaces alongside the existing pitched-linear
allocations.

When the frames context format is AV_PIX_FMT_CUARRAY, the caller
(e.g. NVDEC) can fill cuarray_desc and cuarray_num_surfaces before
calling av_hwframe_ctx_init(), which then allocates the CUarray
surfaces.

Also add cuda_transfer_data_from_cuarray() to support hwdownload
from CUarray frames to host memory via cuMemcpy2DAsync.

Co-authored-by: Diego de Souza <ddesouza@nvidia.com>
Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-07-14 19:45:02 +00:00
Diego de Souza
c7546ce0ea avutil/pixfmt: add AV_PIX_FMT_CUARRAY for opaque CUDA block-linear surfaces
Add a new hardware pixel format representing opaque block-linear CUDA
arrays (CUarray). This format is used by NVDEC when decoding into
opaque surfaces registered with cuvidRegisterDecodeSurfaces, and can
be consumed directly by NVENC as CUDA array input without requiring
a pitch-linear copy.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2026-07-14 19:45:02 +00:00
James Almer
7e68fdd4da avutil/frame: add a new side data type for downmix matrix
Signed-off-by: James Almer <jamrial@gmail.com>
2026-07-11 19:32:17 -03:00
James Almer
56e39bd20b avutil/downmix_info: add a new API to propagate pre-made downmix matrixes
Useful for formats where they provide the downmix matrix in the bistream rather
than scale factors for channel groups.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-07-11 19:32:17 -03:00
Vignesh Venkat
7c4e41b54c avcodec: Add itut-t35 metadata as a codec type
Signed-off-by: Vignesh Venkat <vigneshv@google.com>
2026-07-10 01:56:22 +00:00
James Almer
32a256f619 avcodec: add a graph based bitstream filtering API
Tagged experimental for now, as it may see modifications depending on
requirements.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-07-06 13:26:02 -03:00
Michael Niedermayer
b140509940 pre branch Update
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-06-26 02:26:01 +02:00
Andreas Rheinhardt
762b94e672 libs: Bump major version of all libraries
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Lynne
61693f6c35 hwcontext_vulkan: switch to VkAccessFlagBits2 2026-06-23 19:15:57 +02:00
Andreas Rheinhardt
191be14fb6 avcodec/packet: Accept const dictionaries in av_packet_pack_dictionary()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-06-23 19:15:57 +02:00
Lynne
12dc67b6fe lavu/frame: add camera raw codec side data
Required to correctly present raw video.
Codec-specific since I'd like to support ARRIRAW in the future, which
has a different format.
2026-06-10 02:38:35 +09:00
Niklas Haas
972c0cf91f swscale: add new SwsContext.backends option
This allows constraining the set of available backends. This serves as a
better replacement for the "unstable" flag, which is a bit ambiguous. Allows
users to, for example, opt into the memcpy or x86 backend, while excluding
e.g. the upcoming JIT backends.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-03 21:39:55 +00:00
Niklas Haas
9fe5758da5 avutil/hwcontext_vulkan: publicly expose queue device creation flags
These are needed for interop with e.g. libplacebo, which needs to know the
correct flags to call vkGetDeviceQueue2.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-06-02 13:32:43 +02:00