1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00
Commit Graph

118771 Commits

Author SHA1 Message Date
83c1b34964 avfilter/libplacebo: strip interlaced flag when deinterlacing 2025-02-27 18:55:33 +01:00
123cccb621 avfilter/libplacebo: only mark frame fields when deinterlacing
Avoids an unnecessary copy of the frame in the frame queue when not
deinterlacing anyways.
2025-02-27 18:55:33 +01:00
794cba812e avfilter/libplacebo: add deinterlacing options
These were introduced in libplacebo API version 220. We actually already
map the field by default, but deinterlacing was never enabled unless the user
explicitly forced it using extra_ops.
2025-02-27 18:55:33 +01:00
58875417af configure: align libplacebo version check with reality
This filter already failed to compile on older versions, because of an
unconditional use of an API introduced in API version 220. Nobody noticed
this, so I conclude that it's safe to bump the required version by now.
2025-02-27 18:55:33 +01:00
e23c79ebfc avfilter/vf_libplacebo: switch to AV_OPT_TYPE_COLOR 2025-02-27 18:51:41 +01:00
e71b3ebaa5 avcodec/lcevcdec: Use proper include
External libraries are not components and so their CONFIG_ define
is in config.h.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:39:15 +01:00
deee2fb52d avcodec/proresdec: Reuse permutation
The ProresDSPContext already contains the idct_permutation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
e7ca57d857 avcodec/simple_idct: Move ProRes-only code to proresdsp.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
37cf9c5325 avcodec/simple_idct_template: Move function to its declaration
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
f1a4787f76 avcodec/proresdsp: Make put_pixels truely ptrdiff_t compatible
It currently uses an intermediate int which wouldn't work
if linesize exceeded the range of int and inhibits compiler
optimizations. Also switch to pointer arithmetic and use
smaller scope.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
802e4f4a53 avcodec/proresdec: Disable HWAccel at compile-time when possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
57d892bd7b avcodec/prores{dec,dsp}: Remove always-false checks
avctx->bits_per_raw_sample is always 10 or 12 here;
the checks have been added in preparation for making
bits_per_raw_sample user-settable via an AVOption,
but this never happened.

While just at it, also set unpack_alpha earlier
(where bits_per_raw_sample is set).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
90ed5ddf66 avcodec/proresdec: Deduplicate debug message
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
fa39f07a29 avcodec/get_bits: Remove LONG_BITSTREAM_READER
No longer used anywhere.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
8ad2daec58 avcodec/proresdec: Don't use LONG_BITSTREAM_READER
Using LONG_BITSTREAM_READER means that every get_bits() call
uses an AV_RB64() to ensure that cache always contains 32 valid bits
(as opposed to the ordinary 25 guaranteed by reading 32 bits);
yet this is unnecessary when unpacking alpha. So only use these
64bit reads where necessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
ee1408cd66 avcodec/flacdsp: Remove leftover encoding function pointers
Forgotten in 6c4595190e.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
90d9e2a26c avcodec/intrax8dsp: Copy several bytes at once
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
6f31b05389 avcodec/intrax8dsp: Constify DSP functions
Also add restrict where possible.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-27 15:30:12 +01:00
99e2af4e78 avcodec/cuviddec: correctly handle buffer size and status when deinterlacing 2025-02-26 20:56:10 +01:00
330c8f8b93 avformat: add AV1 RTP depacketizer and packetizer
Add RTP packetizer and depacketizer according to (most)
of the official AV1 RTP specification. This enables
streaming via RTSP between ffmpeg and ffmpeg and has
also been tested to work with AV1 RTSP streams via
GStreamer.

It also adds the required SDP attributes for AV1.

AV1 RTP encoding is marked as experimental due to
draft specification status, debug amount reduced
and other changes suggested by Tristan.

Added optional code for searching the sequence
header to determine the first packet for broken
AV1 encoders / parsers.

Stops depacketizing on corruption until next keyframe,
no longer prematurely issues packet on decoding if
temporal unit was not complete yet.

Change-Id: I90f5c5b9d577908a0d713606706b5654fde5f910
Signed-off-by: Chris Hodges <chrishod@axis.com>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
2025-02-26 12:32:22 -05:00
b3d73df80d aacenc: remove ANMR coder
If there's ever a rework of the AAC encoder, it won't start from here.
The codec, with all its oddities and tweaks needed to acheive good quality
has strayed far from the academic work upon which this coder was based on.
Its been 20 years since this paper was released, and no known existing
implementations, open-source or proprietary that we know of, are based on it.
2025-02-26 17:12:08 +01:00
9383533770 aacenc: remove support for AAC LTP profile
The LTP profile of AAC is... terrible.
It was an early 90's attempt at bridging the gap between speech
codecs and general purpose codecs. It did so by trying to exploit the fact
that most speech patterns are regular.

Unfortunately, it went about it the same way as AAC Main, by taking
the previous frame's samples, modifying them through an LPC filter,
transforming them back using a forward MDCT, putting the output
coefficients back into the current frame, and using delta coding.
But once again, they ignored basic mathematics and MDCT leakage.
Thankfully, because AAC LTP is meant to operate at very low bitrates,
the extreme quantization results in most leakage being irrelevant.

Unfortunately, the result is that the output sounds pretty much
terrible regardless of whether LTP is enabled or not.

This was the first attempt at trying to couple speech coding into AAC.
No, the second attempt did not succeed either.
Nnnneither did the third. Or fourth.

For the fifth one, they literally just jammed a speech codec into AAC
with USAC once they saw Opus do it.

Just drop support for encoding AAC LTP. It was always experimental
to begin with.
2025-02-26 17:12:08 +01:00
9b11fefb88 aacenc: remove support for AAC Main profile
The Main profile of AAC is... terrible.
It enables the use of delta coding across coefficients of two frames
to try to increase compression, and it enabled one more pole for TNS
filters.

What the AAC authors failed to take into account were basic
mathematics, as MDCT leakage (e.g. the spread of each frequency when
represented in a discrete spectrum) is significant in most audio codecs.
This leads to huge variations between each frame, basically rendering
prediction completely pointless.

In fact, enabling AAC-Main prediction does not, in general, even recoup
the metadata losses from signalling the profile and prediction properties
in the first place. So you lose efficiency by using AAC Main.

The rumor is that it was put in the AAC spec for patent reasons, though
patent-wise, it has about as much use as a patent for a bicycle designed
for use by snakes.

The only other thing AAC Main changes is it permits 3-pole TNS filters.
When AAC's bands are absolutely tiny, except for very high frequency bands,
where you're likely to use PNS instead.

Just get rid of it.
2025-02-26 17:12:04 +01:00
e24920375c Make mime-type award a bonus probe score
This changes the default behaviour of ffmpeg where content-type headers
on an input gives an absolut probe score (of 75) to instead give a bonus
score (of 30). This gives the probe a better chance to arrive at the
correct format by (hopefully) giving a large enough bonus to push edge
cases in the right direction (MPEG-PS vs MP3, I am looking at you) while
also not adversly punishing clearer cases (raw ADTS marked as
"audio/mpeg" for example).

This patch was regression tested against 20 million recent podcast
submissions (after content-type propagation was added to
original-storage), and 50k Juno vodcasts submissions (dito). No adverse
effects observed (but the bonus may still need tweaking if other edge
cases are detected in production).
2025-02-26 14:52:34 +01:00
5a526fdad0 avformat/mp3dec: Subtract known padding from duration
When an Info-tag is present, marking initial and trailing samples as
padding, those samples should not be included in the calculation of track
duration.

This solves a surprising user experience where converting a WAV->MP3->WAV,
ffprobe will show the duration of the mp3 as slightly longer than both the
input and the output.

As a result, the estimated duration and imprecise seek-results of some
FATE-tests have been updated.
2025-02-26 14:52:34 +01:00
da5353cf05 GOL-1361: Remove invalid CTTS sample_offset check
We checked in this places:
* In 8.6.1.3 of ISO/IEC 14496-12 about the CTTS box
* In Apples MOV spec: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-SW19
2025-02-26 14:52:34 +01:00
98d97bb33b rtmp: Set correct message stream id when writing as server
rtmp_write is used both for writing outputs as a server. The
rt->listen flag determines which mode we're running in.

Previously, when running as a server, the message stream id would
always be set to 0 for media/metadata messages. This is surprising
given that we have both responded to "createStream()" with a value
of 1 and sent a "Stream Begin 1" to the client. Furthermore, some
client libraries (Red5) seem to trip up on receiving
"@setDataFrame" on stream 0 (and may be correct to assume that
this message would be sent on stream 1).
2025-02-26 14:52:34 +01:00
95314cd7c5 avformat/flacdec: Return correct error-codes on read-failure
Forward errors from `avio_read` directly. When `avio_read` sees EOF before
expected bytes can be read, consistently return `AVERROR_INVALIDDATA`

We used to return `AVERROR(AVERROR_INVALIDDATA)` when failing to read
metadata block headers. `AVERROR_INVALIDDATA` is already negative, so
wrapping in `AVERROR` leads to double-negation.

We used to return `AVERROR(EIO)` when failing to read extended metadata.
However, many times, the IO-layer is not at fault, the input data is simply
corrupted (truncated), so we return `AVERROR_INVALIDDATA` here as well.

---

Tomas: changed to use AVERROR_EOF
2025-02-26 14:52:34 +01:00
399234ee2a libavcodec/wmadec: Return AVERROR_INVALIDDATA on decoding errors
WMA files that fail to decode due to incoherent block lengths and
frame lengths currently result in a "Operation not permitted".
After this change, they will instead result in "Invalid data found
when processing input".

Several other error cases are also changed from returning -1.

As we change the error propagation logic in wma_decode_frame and
wma_decode_superframe, previous occurrences of returning
AVERROR_INVALIDDATA are also affected by this. This includes
"total_gain overread" and a "channel exponents_initialized" check.

---

Tomas: changed some -1's to AVERROR_INVALIDDATA
2025-02-26 14:52:15 +01:00
1306e5c7d3 avformat/http: Return EIO for prematurely broken connection
Currently, a prematurely broken connection normally leads to the same
EOF, as a completed successful transfer. However, enabling reconnect
changes this logic, and leads to the return of EIO.

This patch unifies that logic, leading to the return of EIO for premature
disconnect, regardless of setting of "reconnect".
2025-02-26 14:52:15 +01:00
584c41a4ac avcodec/ffv1_parser: Rename close to ffv1_close
This fixed wasm checkasm failure

$ wasm-tools validate tests/checkasm/checkasm
error: wasisdk://v25.0/build/sysroot/wasi-libc-wasm32-wasip1-threads/libc-top-half/musl/src/stdio/__stdio_close.c:24:9 function `__stdio_close` failed to validate

Caused by:
    0: func 4581 failed to validate
    1: type mismatch: expected i32 but nothing on stack (at offset 0x43b770)

Since close is declared as static function, it's more like a bug
in wasi sdk, but we can workaround it easily.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: James Almer <jamrial@gmail.com>
2025-02-26 17:41:10 +08:00
8e6032990c fftools/ffmpeg_dec: don't try to copy side data from the decoder if it already exists in the output frame
We can't use AV_FRAME_SIDE_DATA_FLAG_REPLACE here because the side data already in the
frame should have priority over the global one, so just ensure we don't copy any if
it already exists.

Fixes ticket #11468.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-25 19:51:18 -03:00
d161604625 tests: Add fate-hevc-alpha
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-02-25 11:40:33 +08:00
a37f634383 tools: Add binaries to .gitignore
Signed-off-by: Frank Plowman <post@frankplowman.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-25 02:03:58 +01:00
4ff1d1f3d6 add tools/compare-cvelists.sh
This compares the MITRE CVE list with our webpage security list and
produces a diff, so people can investigate, fix, backport and correct
differences

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-02-24 15:39:03 +01:00
37348e1b20 fftools/ffprobe: Switch to AVMutex
This removes several #if checks. While just at it, also switch
to static mutex initialization.
This commit does not enable -show_log for builds without threads
though.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-24 15:09:54 +01:00
6232f416b1 ffmpeg_demux: add option readrate_catchup
At present, if reading from a readrate-limited input is stalled,
then upon resumption, ffmpeg will read the input without any
throttle till the average readrate matches the specified readrate.

This new option allows to set a speed limit when reading is resumed
until the average readrate matches the primary readrate.

Fixes #11469
2025-02-24 15:16:59 +05:30
a060b4d9a9 fftools: notify user of flags upon loglevel parse failure 2025-02-24 15:15:53 +05:30
5021764413 avformat/mov: (v4) fix get_eia608_packet
The problem is reproducible with "Test for Quicktime 608 CC file.mov"
from https://samples.ffmpeg.org/MPEG2/subcc/

ffmpeg -i "Test for Quicktime 608 CC file.mov" -map 0 -c copy -y remuxed.mov

See https://trac.ffmpeg.org/ticket/11470
2025-02-23 09:43:56 -07:00
d5dbcc00d8 lavc/vvc: Ensure subpictures don't overlap
This is essentially a re-implementation of
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20241005223955.54158-1-post@frankplowman.com/

That patch was not applied last time.  Instead we opted to identify
issues which could be caused by invalid subpicture layouts and remedy
those issues where they manifest, either through error detection or code
hardening.  This was primarily implemented in the set
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=13381.

This has worked to some degree, however issues with subpicture layouts
continue to crop up from the fuzzer and I've fixed a number of bugs
related to subpicture layouts since then.  I think it's best to return
to the initial plan and simply check if the subpicture layout is valid
initially.

This implementation is also lighter than the first time -- by doing a
bit more logic in pps_subpic_less_than_one_tile_slice, we are able to
store a tile_in_subpic map rather than a ctu_in_subpic map.  This
reduces the size of the map to the point it becomes possible to allocate
it on the stack.  Similar to 8bd66a8c95,
the layout is also validated in the slice map construction code, rather
than in the CBS, which avoids duplicating some logic.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-02-23 21:39:42 +08:00
93aae172ea lavc/vvc: Fix slice map construction for small subpics
In the case pps_subpic_less_than_one_tile_slice is called, the
subpicture is smaller than the tile and so there are multiple
subpictures in the tile.  Of course, then, not all the
subpictures can start in the top-left corner as the code before the
patch does.  Patch fixes this, so each subpicture starts at the
signalled location as is specified in section 6.5.1 of H.266(V3).

Signed-off-by: Frank Plowman <post@frankplowman.com>
2025-02-23 21:39:42 +08:00
87d7b8ff4b fate/demux: add a test for Theora in OGG
Signed-off-by: James Almer <jamrial@gmail.com>
2025-02-23 00:13:35 -03:00
8f2af8fda6 avcodec/mpegvideo_{dec,enc}: Reindent after the previous commit
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-23 02:01:18 +01:00
b05ec7fec9 avcodec/mpv_reconstruct_mb_template: Merge template into its users
A large part of this template is decoder-only. This makes
the complexity of the IS_ENCODER-checks not worth it.
So simply merge the template into both its users.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-23 02:01:18 +01:00
fc64b2ee5d avcodec/mpegvideo_enc: Don't reset intra buffers in mpv_reconstruct_mb()
It is not part of reconstructing the macroblock.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-23 02:01:18 +01:00
5826166836 avcodec/h263dec: Clean intra tables in decoder, not ff_mpv_reconstruct_mb
This is a more appropriate place than a function designed
to reconstruct a macroblock. It furthermore limits these checks
to the codecs that actually need it (and removes it from e.g.
RV10 and RV20 -- the latter actually uses these buffers, but
only for intra-frames, so they don't need to be cleaned
manually).

This furthermore means that ff_mpv_reconstruct_mb() and therefore
also the error-resilience code no longer needs block_index set.
This fixes a crash caused by 65d5ccb808
when ff_mpv_reconstruct_mb() is called by VC-1 code without
block_index being initialized properly (VC-1 uses and initializes
block_index itself normally).

Fixes: 69814/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VC1_fuzzer-4868081575329792
Fixes: heap-buffer-overflow

Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-23 02:01:08 +01:00
58f9e497dc avcodec/mpeg12enc: Move resetting last_dc to encoder
The MPEG-1/2 encoders are the only non-intra-only mpegvideo
encoders that want last_dc reset when encoding non-intra macroblocks.
Therefore move resetting it to mpeg12enc.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-23 01:08:45 +01:00
9a46c0160f avcodec/mpeg12dec: Move resetting last_dc to decoder
Only the MPEG-1/2, MSMPEG4V1, MPEG-4 and RV.10 decoders use last_dc
at all. Of these, RV.10 only uses it for intra frames; it does not
need these predictors reset in ff_mpv_reconstruct_mb(). MSMPEG4V1
has h263_pred set, so that last_dc is already not reset in
ff_mpv_reconstruct_mb() (instead it is reset at the beginning
of every line). MPEG-4 also has h263_pred set (and uses last_dc only
for the intra-only studio profile and needs them reset to sligthly
different values anyway).

So only the MPEG-1/2 decoders need these values reset. So move
resetting them there. This avoids resetting them unnecessarily
for FLV1, H.261, H.263I, RV.10, RV.20 and H.263(+)
(for the latter it depends upon whether h263_aic is in use).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-23 01:08:45 +01:00
ebf0d34281 avcodec/h261enc: Use LUT to write motion vector differences
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-02-23 01:08:45 +01:00
d1ed5c06e3 avcodec/libsvtav1: unbreak build with latest svtav1
SVT-AV1 made a change in their public API in 988e930c but without a
version bump or any other accessible marker, thus breaking ffmpeg build
with current versions of SVT-AV1.

They have finally bumped versions a month later, so check added.
2025-02-22 18:57:53 +05:30