Commit Graph

115967 Commits

Author SHA1 Message Date
Andreas Rheinhardt
3b67ab85ee avcodec/mpegvideo_enc: Only keep what is used from MECmpContext
A MECmpContext is quite big (792B here) and given
how ff_update_duplicate_context() works, it is (unfortunately)
copied quite frequently when using slice threading.
Therefore keep only what is needed from MECmpContext
and remove MECmpContext from MpegEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
eb3415912b avcodec/mpegvideo_enc: Avoid branch for sse vs nsse cmp
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
8b4f7c0663 avcodec/me_cmp: Zero MECmpContext in ff_me_cmp_init()
Not every function will be set, so zero the context
to initialize everything.

This also allows to remove an initialization in dvenc.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
10e7633cd7 avcodec/motion_est: Store remaining required me_cmp_funcs
This avoids using MpegEncContext.mecc; it already allows
to avoid touching the latter for snowenc and svq1enc.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
d163eefd47 avcodec/me_cmp, motion_est: Sanitize permissible cmp_funcs
Several of the potential choices of comparison functions
need an initialized MpegEncContext (initialized for encoding,
not only ff_mpv_common_init()) or they crash when called.
Modify ff_set_cmp() to check for this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
b1a31b32ab avcodec/me_cmp,dvenc,mpegvideo: Move ildct_cmp to its users
MECmpContext.ildct_cmp is an array of function pointers that
are not set by ff_me_cmp_init(), but that are set by users
to one of the other arrays via ff_set_cmp().

Remove these pointers from MECmpContext and add pointers
for the actually used functions to its users. (The DV encoder
already did so.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
cd2e46a350 avcodec/me_cmp, mpegvideo: Move frame_skip_cmp to MpegEncContext
MECmpContext has several arrays of function pointers that
are not set by ff_me_cmp_init(), but that are set by users
to one of the other arrays via ff_set_cmp().

One of these other users is mpegvideo_enc; it is the only user
of MECmpContext.frame_skip_cmp and it only uses one of these
function pointers at all.

This commit therefore moves this function pointer to MpegEncContext;
and removes the array from MECmpContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
182e647a64 avcodec/me_cmp, motion_est: Move me_(pre_)?_cmp etc. to MotionEstContext
MECmpContext has several arrays of function pointers that
are not set by ff_me_cmp_init(), but that are set by users
to one of the other arrays via ff_set_cmp().

One of these other users is the motion estimation API.
It uses MECmpContext.(me_pre|me|me_sub|mb)_cmp. It is
basically the only user of these arrays.

This commit therefore moves these arrays to MotionEstContext;
this has the additional advantage of making motion_est.c
more independent from MpegEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
1367ef198a avcodec/me_cmp: Constify ff_set_cmp()
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
bbd355355d avcodec/motion_est: Factor one-time initialization out of ff_init_me
The majority of the stuff performed in it needs to be done only
once; so factor it out into a function of its own to be called
in the user's init function.
Also avoid using MpegEncContext in it, to separate the two
a bit more.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
422711d1a5 avcodec/dvenc: Check for availability of interlaced dct cmp func
Not every type of comparison function implements every function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
c46711d44f avcodec/mpegvideo_enc: Check for existence of ildct cmp functions
Not all compare functions are implemented for all compare function
types. Therefore check for the existence of the used functions.
Fixes issue #10245.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
415a3c32c9 avcodec/mpegvideo_enc: Avoid excessive inlining
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
0ef8f0f965 avcodec/ituh263dec: Use VLC symbol table
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
010951239c avcodec/mpeg12dec: Use VLC symbol table
Possible by using MB_TYPE_CODEC_SPECIFIC for MB_TYPE_ZERO_MV
and due to the MB_TYPE_*_MV flags fitting into an int16_t.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
e7d6300c10 avcodec/mpeg4videodec: Use VLC symbol table
Possible now that MB_TYPE_L1 (which does not fit into
an int16_t) is no longer used).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
f161d9449a avcodec/mpegutils: Move H.264-only macros to h264dec.h
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
f5d5b80f3c avcodec/mpegutils: Don't use MB_TYPE_L[01] for mpegvideo
MB_TYPE_L[01] is based upon H.264 terminology (it stands for
list); yet the mpegvideo based decoders don't have lists
of reference frames, they have at most one forward and one
backward reference. So use terminology based upon this.

This also has a second advantage: MB_TYPE_L[01] is actually
an OR of two flags (which are set independently for H.264,
but aren't for mpegvideo). Switching to different flags
makes the flags fit into an int16_t, which will be useful
in future commits.

The only downside to this is a very small amount of code
in error_resilience.c and mpegutils.c (the only code shared
between the H.264 decoder and mpegvideo).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
07ae09bdf1 avcodec/mpegutils: Remove always-false check
SVQ3 does not call ff_print_debug_info2().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
c94d81ce00 avcodec/h261dec: Remove nonsense information from error message
The "invalid mtype index" here is always -1, because that is
the value the VLC api uses for not existent leafs in an incomplete tree.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
0876b160d6 avcodec/h261dec: Use VLC symbol table
This is possible now that MB_TYPE_CBP and MB_TYPE_QUANT
fit into an int16_t; only MB_TYPE_H261_FIL needs to
be remapped to MB_TYPE_CODEC_SPECIFIC.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
4cdd684e86 avcodec/mpegutils: Remap MB_TYPE_{GMC,SKIP,CBP,QUANT}
Do this to make MB_TYPE_{CBP,QUANT} fit into an int16_t,
so that can be used in a VLC symbol table.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
dd1e804a98 avcodec/mpegutils: Remap MB_TYPE_ACPRED, add codec-specific MB_TYPE
MB_TYPE_ACPRED is currently reused for MB_TYPE_REF0 by H.264,
so that the value fits into an uint16_t. Given that MB_TYPE_ACPRED
is not subject to any such restriction (apart from fitting into
32bits), it can be remapped to a hithereto unused bit.
The then available bit will be declared to be codec-specific
(i.e. unused by generic code), so that H.264 can use it
for MB_TYPE_REF0 and so that it can be reused later for
e.g. MB_TYPE_H261_FIL.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
5805b860fe configure: Remove obsolete mpeg4_decoder->mpeg4video_parser dependency
Obsolete since 3ceffe7839.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
18f1aca3e8 avcodec/mpegvideo_dec: Set dct_unquantize ptrs only once when possible
Everything except dct_unquantize_intra for MPEG-4 need only
be set once.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
091d006637 avcodec/mpegvideo: Set dct_unquantize earlier
Set them in ff_mpv_idct_init() so that they are already set
in ff_mpv_decode_init(). This is in preparation for avoiding
to set dct_unquantize in every ff_mpv_frame_start().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
4339d2c11c avcodec/mpegvideo: Don't pretend dct_init can fail
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
80c2d7c890 avcodec/mpegvideo_enc: Avoid branches for flipping no_rounding
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Andreas Rheinhardt
91fce67691 avcodec/vc1: Combine identical checks
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-06-20 18:58:38 +02:00
Theo Fabi
d6d14b3a15 avdevice/avfoundation: add external video devices
Video devices categorized by AVFoundation as
'AVCaptureDeviceTypeExternal(Unknown)' (like USB video streams) were not
recognized by libavdevice.

Signed-off-by: Theo Fabi <fabi.theo@gmail.com>
2024-06-20 18:52:06 +02:00
Frank Plowman
8d6014dbc6 lavc/vvc: Invalidate PPSs which refer to a changed SPS
When the SPS associated with a particular SPS ID changes, invalidate all
the PPSs which use that SPS ID.  Fixes crashes with illegal bitstreams.
This is done in the CBS, rather than in libavcodec/vvc/ps.c like the SPS
ID reuse validation, as parts of the CBS parsing process for PPSs
depend on the SPS being referred to.

Signed-off-by: Frank Plowman <post@frankplowman.com>
2024-06-20 20:33:23 +08:00
Araz Iusubov
02430680b0 libavcodec/amfenc: Update AMF encoder options
Encoder options have been updated to the current version of the AMF.

Signed-off-by: Araz Iusubov <Primeadvice@gmail.com>
2024-06-20 09:12:24 -03:00
Araz Iusubov
696bd64d01 libavcodec/amfenc: Update AMF release version 2024-06-20 09:12:24 -03:00
James Almer
53c8d417ed avformat: split off generic NAL function helpers into their own file
Signed-off-by: James Almer <jamrial@gmail.com>
2024-06-20 08:57:45 -03:00
Frank Plowman
0eacad6921 fate/vvc: add vvc-conformance-RPR_A_4
Before    After
-------------------------------------------------
make fate-vvc CPU Time (No ASM)  131.52s  134.83s
libavcodec/vvc/* Line Coverage     95.3%    96.9%
inter_template.c Line Coverage     74.3%    88.2%
inter.c Line Coverage              85.3%    99.2%

Signed-off-by: Frank Plowman <post@frankplowman.com>
2024-06-20 08:57:45 -03:00
James Almer
0ae157b360 avformat/iamf_parse: add missing padding to AAC extradata
Fixes: out of array access
Fixes: 68863/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-4833546039525376

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: James Almer <jamrial@gmail.com>
2024-06-19 10:12:57 -03:00
James Almer
4e608e90eb avformat/evc: fix writing reserved bits
They are all zeroes, not ones.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-06-19 10:12:50 -03:00
James Almer
5191339f74 avformat/evc: remove useless struct field
Signed-off-by: James Almer <jamrial@gmail.com>
2024-06-19 10:03:04 -03:00
Michael Niedermayer
4cab028bd0
avformat/mxfdec: Check container_ul->desc before use
Fixes: CID1592939 Dereference after null check

Sponsored-by: Sovereign Tech Fund
Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-19 13:24:31 +02:00
Michael Niedermayer
0da6865ce2
avfilter/qsvvpp: Remove unreachable code
Fixes: CID1598548 Logically dead code

Sponsored-by: Sovereign Tech Fund
Reviewed-by: "Xiang, Haihao" <haihao.xiang@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-19 13:23:07 +02:00
Michael Niedermayer
2b2ced61eb
avcodec/libvpxenc: Cleanup on error
This or fifo needs to be freed on errors explicitly

Fixes: memleak
Fixes: 68937/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LIBVPX_VP8_fuzzer-4830831016214528

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: James Zern <jzern@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-19 12:58:22 +02:00
Michael Niedermayer
7fab9b9761
avformat/iamf_parse: 0 layers are not allowed
Fixes: out of array access
Fixes: 68302/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-4665793796177920

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: Michael Niedermayer <michael@niedermayer.cc>
2024-06-19 12:54:46 +02:00
Michael Niedermayer
c69e6cccd7
avformat/iamf_parse: consider nb_substreams when accessing substreams array
Fixes: out of array access
Fixes: 68584/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6256656668229632

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: Michael Niedermayer <michael@niedermayer.cc>
2024-06-19 12:52:20 +02:00
Michael Niedermayer
97ecfb5a19
MAINTAINERS: Update the entries for the release maintainer for FFmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2024-06-19 12:36:02 +02:00
Ramiro Polla
75f1a8e071 swscale/aarch64: add neon {lum,chr}ConvertRange
chrRangeFromJpeg_8_c: 29.2
chrRangeFromJpeg_8_neon: 19.5
chrRangeFromJpeg_24_c: 80.5
chrRangeFromJpeg_24_neon: 34.0
chrRangeFromJpeg_128_c: 413.7
chrRangeFromJpeg_128_neon: 156.0
chrRangeFromJpeg_144_c: 471.0
chrRangeFromJpeg_144_neon: 174.2
chrRangeFromJpeg_256_c: 842.0
chrRangeFromJpeg_256_neon: 305.5
chrRangeFromJpeg_512_c: 1699.0
chrRangeFromJpeg_512_neon: 608.0
chrRangeToJpeg_8_c: 51.7
chrRangeToJpeg_8_neon: 22.7
chrRangeToJpeg_24_c: 149.7
chrRangeToJpeg_24_neon: 38.0
chrRangeToJpeg_128_c: 761.7
chrRangeToJpeg_128_neon: 176.7
chrRangeToJpeg_144_c: 866.2
chrRangeToJpeg_144_neon: 198.7
chrRangeToJpeg_256_c: 1516.5
chrRangeToJpeg_256_neon: 348.7
chrRangeToJpeg_512_c: 3067.2
chrRangeToJpeg_512_neon: 692.7
lumRangeFromJpeg_8_c: 24.0
lumRangeFromJpeg_8_neon: 17.0
lumRangeFromJpeg_24_c: 56.7
lumRangeFromJpeg_24_neon: 21.0
lumRangeFromJpeg_128_c: 294.5
lumRangeFromJpeg_128_neon: 76.7
lumRangeFromJpeg_144_c: 332.5
lumRangeFromJpeg_144_neon: 86.7
lumRangeFromJpeg_256_c: 586.0
lumRangeFromJpeg_256_neon: 152.2
lumRangeFromJpeg_512_c: 1190.0
lumRangeFromJpeg_512_neon: 298.0
lumRangeToJpeg_8_c: 31.7
lumRangeToJpeg_8_neon: 19.5
lumRangeToJpeg_24_c: 83.5
lumRangeToJpeg_24_neon: 24.2
lumRangeToJpeg_128_c: 440.5
lumRangeToJpeg_128_neon: 91.0
lumRangeToJpeg_144_c: 504.2
lumRangeToJpeg_144_neon: 101.0
lumRangeToJpeg_256_c: 879.7
lumRangeToJpeg_256_neon: 177.2
lumRangeToJpeg_512_c: 1794.2
lumRangeToJpeg_512_neon: 354.0
2024-06-18 23:12:41 +02:00
Niklas Haas
90579fbb90 avcodec/dovi_rpudec: handle errors consistently
Only flush state when we started parsing data, otherwise just error out.
Remove the 'fail' label to make this a bit less confusing to read.
2024-06-18 21:18:30 +02:00
Niklas Haas
0a5ed91e5e avcodec/dovi_rpudec: reject reserved_zero_3bits != 0
This is used by future versions of the spec to implement metadata
compression. Given that we don't yet implement that spec, validate that
this is equal to 0 for now.
2024-06-18 21:18:30 +02:00
Niklas Haas
d9f902d3a4 avcodec/dovi_rpu: guard ext blocks by dm_metadata_present
In the spec, dm_metadata_present also toggles all extension blocks, so
we need to move them inside the branch.
2024-06-18 21:18:30 +02:00
Niklas Haas
5e778cbfd5 avcodec/dovi_rpu: move ff_dovi_rpu_generate to correct section
This is not an internal use function.
2024-06-18 21:18:30 +02:00
Niklas Haas
7bf08a5b2d avcodec/dovi_rpu: simplify vdr type
Storing the color metadata alongside the data mapping is no longer
needed, so we can simplify this array's type.
2024-06-18 21:18:30 +02:00