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

119320 Commits

Author SHA1 Message Date
522fc389e8 avcodec/ffv1dec: replace literal 65535 by what it is
should make the code easier to understand

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:13 +01:00
5ca14b23f1 avcodec/ffv1dec: compute end instead of hardcoding it and test for fltmap correctly
A step toward supporting remap for integer formats less than 16 bit

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
3813559660 avcodec/ffv1enc: remap table size is 1<<bits_per_raw_sample not fixed 65536
not a bugfix as this path was only used for float16 but it makes sense
to allow using this for integers too

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
e619b0d817 avcodec/ffv1enc: remap mode 2 is for floats only
(you could use it for others but it makes no sense)

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-25 11:24:12 +01:00
8b2372cac7 ffmpeg-filter: check for initialized graph
Don't drop frame if graph hasn't been initialized yet!
2025-03-25 01:06:03 +05:30
044664ac3b avcodec/ffv1enc: remove mixed declarations and code
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 16:34:24 -03:00
a4cf0979a4 avcodec/ffv1enc: update missing Unit accesses inside av_assert2
Fixes compilation with assert-level=2.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 16:32:47 -03:00
702239bc50 avcodec/ffv1enc: reduce stack usage
Fixes failures in some systems since 171060d5dc.
This can be further improved by only allocating the arrays when needed.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 13:55:56 -03:00
fee5b0a383 fftools/ffmpeg_filter: ensure ifp is set before dereferencing it
Fixes segfaults since cbbc927a67.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 10:10:19 -03:00
5dcf566f69 avcodec/ffv1: Implement 2D RLE for remap
ATM this performs as well or better as any other algorithm tried.
Its simple for the decoder.
On the encoder side complexity depends on how parameters are
chosen. But with a fixed mul_count of 1 and basic heuristic
it performs as well as any more complex choice i tried so far.

The encoder code here is flexible and allows mul_count > 1
and also can easily be used to exactly test various parameters.

With mul_count=512 we can gain another 6% in remap table size
for fixed point in float data. (this is not implemented in this
patch though)

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:59 +01:00
0538b4c569 avcodec/ffv1dec: remove unused var 2025-03-24 13:46:58 +01:00
e19496fe71 avcodec/ffv1enc: remap allows using rice golomb with more bits
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:58 +01:00
171060d5dc avcodec/ffv1: 32-bit float sample support
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:58 +01:00
62c7d08947 avcodec/ffv1: Fix remap ordering
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-03-24 13:46:57 +01:00
cbbc927a67 ffmpeg: add per-stream input option drop_changed
This is a replacement in ffmpeg for the deprecated avcodec flag AV_CODEC_FLAG_DROPCHANGED.

This option is meant to be used when the filtergraph should not be
reinited upon input parameter changes as that leads to loss of state
in the filtergraph potentially leading to broken or aborted output,
e.g. inserting of silence with first_pts specified in aresample.

Generally useful to avoid corrupted yet decodable packets in live
streaming inputs.

This option when enabled takes precedence over reinit_filters
2025-03-24 16:18:17 +05:30
323cb8c61e ffmpeg_demux: set default for readrate_catchup to be 5% faster
The existing default value is the same as the primary readrate.
This maintains the flow rate as best as possible but does not
reduce the lag. This new value allows catchup to gradually happen
without overwhelming the receiver.

Addresses a concern brought up in #11469
2025-03-24 16:17:47 +05:30
6fb1bbd73c avfilter/scale: remove duplicate block
Added in bb80445813
2025-03-24 16:17:13 +05:30
51b61ec35d avcodec/libuavs3d: pixel format should be native endian
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:54:46 +08:00
2a189d44b5 avcodec/avs3_parser: pixel format should be native endian
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:54:40 +08:00
1731eba20d avformat/mov: generalize sgpd_sync index lookup
The function has a nal_unit_type parameter but unused before.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:53:41 +08:00
c6214b0d69 avcodec/vt: Don't restart decoder when confronted with ReferenceMissingErr
Otherwise the decoder may enter an loop of repeated state resets.
This can happen for streams with CRA but no IDR.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2025-03-24 14:53:27 +08:00
26f2f03e0d swscale/x86/rgb2rgb: optimize AVX2 version of uyvytoyuv422
Currently the AVX2 version of uyvytoyuv422 in the SIMD loop does the following:
4 vinsertq to have interleaving of the vector lanes during load from memory.
4 vperm2i128 inside 4 RSHIFT_COPY calls to achieve the desired layout.

This patch replaces the above 8 instructions with 2 vpermq and
2 vpermd with a vector register similar to AVX512ICL version.

Observed the following numbers on various microarchitectures:

On AMD Zen3 laptop:
Before:
uyvytoyuv422_c:                                      51979.7 ( 1.00x)
uyvytoyuv422_sse2:                                    5410.5 ( 9.61x)
uyvytoyuv422_avx:                                     4642.7 (11.20x)
uyvytoyuv422_avx2:                                    4249.0 (12.23x)

After:
uyvytoyuv422_c:                                      51659.8 ( 1.00x)
uyvytoyuv422_sse2:                                    5420.8 ( 9.53x)
uyvytoyuv422_avx:                                     4651.2 (11.11x)
uyvytoyuv422_avx2:                                    3953.8 (13.07x)

On Intel Macbook Pro 2019:
Before:
uyvytoyuv422_c:                                     185014.4 ( 1.00x)
uyvytoyuv422_sse2:                                   22800.4 ( 8.11x)
uyvytoyuv422_avx:                                    19796.9 ( 9.35x)
uyvytoyuv422_avx2:                                   13141.9 (14.08x)

After:
uyvytoyuv422_c:                                     185093.4 ( 1.00x)
uyvytoyuv422_sse2:                                   22795.4 ( 8.12x)
uyvytoyuv422_avx:                                    19791.9 ( 9.35x)
uyvytoyuv422_avx2:                                   12043.1 (15.37x)

On AMD Zen4 desktop:
Before:
uyvytoyuv422_c:                                      29105.0 ( 1.00x)
uyvytoyuv422_sse2:                                    3888.0 ( 7.49x)
uyvytoyuv422_avx:                                     3374.2 ( 8.63x)
uyvytoyuv422_avx2:                                    2649.8 (10.98x)
uyvytoyuv422_avx512icl:                               1615.0 (18.02x)

After:
uyvytoyuv422_c:                                      29093.4 ( 1.00x)
uyvytoyuv422_sse2:                                    3874.4 ( 7.51x)
uyvytoyuv422_avx:                                     3371.6 ( 8.63x)
uyvytoyuv422_avx2:                                    2174.6 (13.38x)
uyvytoyuv422_avx512icl:                               1625.1 (17.90x)

Signed-off-by: Shreesh Adiga <16567adigashreesh@gmail.com>
2025-03-23 15:25:48 +00:00
fc44ccd981 configure: Add EXR decoder->bswapdsp dependency
Needed on BE systems.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-23 14:14:43 +01:00
9f0970ee35 tests/checkasm/videodsp: Don't use declare_func_emms
It allows the callee to clobber the MMX state,
yet since 1e3dc705df this is no longer
done. So use the stricter declare_func instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-22 03:45:03 +01:00
c94143350f avutil/libm: Only include intfloat.h when needed
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-22 03:35:28 +01:00
079110238a avcodec/amfenc: add smart access video option
This commit adds option for enabling SmartAccess Video (SAV)
in AMF encoders. SAV is an AMD hardware-specific feature which
enables the parallelization of encode and decode streams across
multiple Video Codec Engine (VCN) hardware instances.
2025-03-21 17:36:23 +01:00
5b460bde8b libavutil/hwcontext_amf: add format validation in transfer_data functions 2025-03-21 17:36:13 +01:00
e5d62e20c8 avdevice/sdl2: Suppress macro redefinition warning
SDL2's headers #define HAVE_PTHREAD_SETNAME_NP (to one here);
we also have a config define which leads the compiler to
warn about this when the values are distinct (as they are here).
Suppress this warning by including config.h before SDL.h.
The latter will then redefine our define which doesn't matter
and which does not lead to warnings because compilers don't warn
about system headers by default (depending upon -Wsystem-headers).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-21 04:30:09 +01:00
94fd222235 avcodec/mathtables: Fix inaccurate macro name
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-21 04:30:09 +01:00
65154ba994 swscale/tests/swscale: Fix potential buffer overflow
The field width in a %s directive gives the amount of characters
to read from the input and not the size of the receiving buffer;
the latter must be of course also have space for the trailing \0
which has been forgotten here. The commit adds it (and fixes a
-Wfortify-source warning from Clang).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-21 04:30:09 +01:00
dff498fddf avutil/csp: Improve enum range comparisons
The underlying integer type of an enumeration is
implementation-defined (see C11, 6.7.2.2 (4)); GCC defaults
to unsigned if there are no negative values like for all enums
from pixfmt.h except enum AVPixelFormat.

This means that tests like "if (csp >= AVCOL_SPC_NB)" for
invalid colorspaces need not work as expected (namely if
enum AVColorSpace is signed). It also means that testing
for such an enum variable to be >= 0 may be tautologically
true. Clang emits a -Wtautological-unsigned-enum-zero-compare
warning for this.

Fix both of these issues by casting to unsigned.
Also do the same in libswscale/format.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-21 04:30:09 +01:00
0ce405afb8 avfilter/vf_zscale: add support for grayscale formats
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-20 14:02:29 -03:00
c3522716ff avfilter/vf_zscale: add support for half precision float RGB formats
Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-20 14:02:29 -03:00
76f09ab647 avcodec/webvttdec: update documentation
The previous link lead to a 404 page as that page doesn't exist anymore.

Signed-off-by: Leon Grutters <gruttersleonbot2@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-20 09:52:24 +01:00
b857bf942c avcodec/hevc/hevcdec: Simplify access to luma plane
It is always set and does not use subsampling.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-20 07:10:17 +01:00
4505257372 avcodec/proresenc_kostya: Don't cast const away needlessly
The parameter passed here is unused, so just pass NULL.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-20 07:10:17 +01:00
d76ae08048 avcodec/svq1enc: Don't add to NULL
It is undefined behavior. Pass a dummy buffer instead.
Fixes "runtime error: applying non-zero offset 1024 to null pointer".
affected the SVQ1 vsynth FATE tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-20 07:10:17 +01:00
02c16b48c5 avcodec/snow: Don't add to NULL
It is undefined behavior.
Fixes "runtime error: applying non-zero offset 8 to null pointer".
Fixes the Snow vsynth FATE-tests.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-20 07:10:17 +01:00
fbcc943b22 avcodec/h261enc: Don't use (size_t)-1
Fixes "runtime error: addition of unsigned offset to 0x765a09523a90
overflowed to 0x765a09523a8e". This fixes all H.261 tests when run
under UBsan.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-20 07:10:17 +01:00
950ad969fb avcodec/sanm: codec20 decoder
codec20 is raw uncompressed image data.

It exists in Rebel Assault 1 as a special format for STOR/FTCH
and is used again in the Full Throttle Remaster from 2017.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 21:02:56 +01:00
fd6bfaab55 avcodec/sanm: ignore codec45
Codec45 is used in some RA2 videos on top of codec37.

It consists of 2 tables (768 and 32768 bytes), and datapackets
like codec2 (delta-x, delta-y) with a pixel counter instead of a color value.
It then reads the 4 surrounding pixels, looks up 3 separate values
for each in table1, adds them together to form an index into
table2 for a new pixel value, in a row.

The data coming in gets the x/y coordinates out of the visible
area very quickly (2-3 iterations); I don't see any visual
difference between the ffmpeg-produced frames and ones captured
with dosbox from rebel assault 2, which leads me to believe this
codec never worked as intended.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 21:02:54 +01:00
b48bd23321 avcodec/sanm: implement STOR/FTCH for ANIMv1
Handle STOR/FTCH the same way the RA1 game engine does:
On STOR, save the next following FOBJ (not the decoded image)
in a buffer; decode it on FTCH.
The RA1 codecs and the fobj handler now take an explicit
GetByteContext in order to be able to replay stored data.

Used extensively by Rebel Assault 1 for e.g. backgrounds and
the cockpit overlay.

For ANIMv2 keep the current system to store the decoded image, as
replaying a FOBJ would not work with codecs37/47/48 due to sequence
violations.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 21:02:39 +01:00
8a04526080 avcodec/sanm: codec37: reimplement comp4
Compression 4 code 0 means copy from delta buffer without mv,
AND start of a skip run.  This gets rid of the extra case and column
index manipulation and implements this as it is implemented in the
original game exe, i.e. as a special case for after mv copy.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 20:58:47 +01:00
fb951b26fd avcodec/sanm: codec4/5/33/34 decoder
This codec works on 4x4 pixel tiles, which can be generated and read
from the datastream.  They're both identical, codec5 misses a tile
index to skip the current tile.
Codecs33/34 are the same as 4/5 but with a different tileset generator.
Used only in Rebel Assault 1.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 20:58:47 +01:00
e1fd6bc8b4 avcodec/sanm: codec21 decoder
similar to codec23, this one alternatingly skips and writes bytes.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 20:58:47 +01:00
77b5a0c134 avcodec/sanm: codec23 decoder
This codec alternatingly skips and changes existing pixels.
A second 16bit parameter in the FOBJ header indicates how to do
the pixel changes: either by specifying a LUT in the codec datastream
or by adding a constant value to the pixel.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 20:58:47 +01:00
968ffbe64a avcodec/sanm: codec2 decoder
this codec consists of 4 byte packets: 2bytes delta-x, 1 byte delta-y
and 1 byte color to put at that spot.
Used in Rebel Assault 1 only.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 20:58:47 +01:00
aa2f2befaa avcodec/sanm: fix codec3
codec3 is codec1 which writes zero values instead of skipping them.
This fixes a lot of RA1 videos.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 20:58:46 +01:00
fd9b92b216 avcodec/sanm: better ANIMv1 engine support
- clear the front buffer with color 0 on the first FOBJ.
  Fixes a lot of Rebel Assault 1 videos and Rebel Assault 2 space
  scenes (e.g. 08PLAY.SAN which consists only of codec1/2/21 objects
  which only ever touch parts of the buffer).
- for ANIMv1 (Rebel Assault 1): set palette index 0 to all zeroes.
  This fixes a lot of stray colors in e.g L1HANGAR.ANM, L2INTRO.ANM,
  space scenes.
- Esp in RA1, there are a lot of FRME objects which don't contain
  any video data (prebuffering some audio only). Account for that.
- In RA1 L2PLAY.ANM there are a few unaligned FOBJs, handle this
  in a generic way.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 20:58:46 +01:00
93b0ca26ac avcodec/sanm: better frame size detection for old codecs
The size of the video frame (FOBJ) of the old codecs (ANIMv0/1/2) can
very reliably be determined:
- ANIMv0/1 (=Rebel Assault 1) uses a 384x242 internal buffer for
  everything.  The codec parameters only describe the size and offset
  of the specific FOBJ on that buffer.
- ANIMv2 titles usually use one of the fullscreen codecs (37/47/48)
  as first FOBJ, and their dimensions can generally be trusted.
- RA2 uses 424x260 as internal buffer, use that if encountered:
  08PLAY.SAN does not use codec37 so we need to guess using the
  codec coordinates.
- ignore sizes smaller than 2x2 or larger than 800x600.
- some game videos have an initial fobj with either 1x1 or -1x-1
  pixels in size, ignore them with a warning (Full Throttle
  and the Rebel Assault 2 xxRETRY.SAN videos).

Once a known/valid dimension set has been discovered, use it and
don't change it for subsequent FOBJs, rather clamp the large frame
to the determined dimensions.

Tested with RA1, RA2, Full Throttle, Dig, Outlaws, SotE and MotS
videos.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
2025-03-19 20:58:46 +01:00