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

120170 Commits

Author SHA1 Message Date
b2be342ab6 avcodec/h263dec: Remove redundant block parameter from decode_mb
With the exception of mpeg4_decode_studio_mb(), all decode_mb
functions implicitly presumed that the block provided as
argument coincides with MpegEncContext.block (they zeroed the latter
and then used the former to decode the block); mpeg4_decode_studio_mb()
meanwhile did not use the provided block at all (it uses blocks of
int32_t). So remove said parameter.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
584d50c5f3 avcodec/h263dec: Add H263DecContext
This is in preparation for moving the fields only used
by H.263-based decoders from MPVContext to H263DecContext.
For now only the decode_mb function pointer has been moved
(to be able to switch said callback to use an H263DecContext*).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:23 +02:00
3f5c2043cc avcodec/mpegvideo: Move dct_precision to Mpeg4DecContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
758c8dffc9 avcodec/{h263,mpeg4video}dec: Pass MPVContext*, not Mpeg4DecContext*
The code in h263dec.c is not supposed to know that the MPEG-4
decoder uses an Mpeg4DecContext as private context at all
(said context is only exposed in a header so that hardware
accelerations can access it and for the parser to use).
Passing an MPVContext* directly also allows to remove
the indirection via AVCodecContext.priv_data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
91e9578025 avcodec/mpeg4videodec: Avoid unnecessary indirections
This basically reverts d4967c04e0.
Said commit was based on the false premise that it would
be an aliasing violation to upcast a pointer to structure
to a pointer to a bigger structure containing the original
structure as its first element, but this is just not true.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
273de7f60c avcodec/mpegvideo: Move unrestricted_mv to MotionEstContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
05510dac6b avcodec/mpegvideo: Move flipflop_rounding to {MSMPEG4Dec,MPVEnc}Context
Forgotten in 9964212545.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
ee81e28469 avcodec/mpeg12dec: Deduplicate variables
This situation was created in merge commit
71d008ebe4.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
94cfbf0238 avcodec/vc1: Don't use MpegEncContext.block
Instead add the necessary blocks directly to VC1Context
(only six are needed, not 12 as ff_mpv_common_init()
currently allocates).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
fe2dbb12b0 avcodec/vc1: Stop using MpegEncContext.gb
Add a GetBitContext to VC1Context instead. This is in preparation
for removing MpegEncContext.gb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
aa4a5b1e33 avcodec/intrax8: Don't pretend to need more than one int16_t[64]
Intrax8 needs only a single block.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
25e4baeed4 avcodec/rv34: Don't use MpegEncContext.block
These decoders only need a single 4x4 block; put it in RV34DecContext.
This is in preparation for removing MpegEncContext.block.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
0e6d59871f avcodec/rv34: Don't use MpegEncContext.gb
This is in preparation for removing MpegEncContext.gb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
86ee71f4e9 avcodec/mpeg12dec: Remove unused function parameter
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
b38f23663e avcodec/mpeg12dec: Put GetBitContext on the stack where advantageous
This is in preparation for no longer using MpegEncContext.gb.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
21c88b29f7 avcodec/h261dec: Don't use MpegEncContext.block
Instead put it into H261DecContext. This is in preparation
for removing MpegEncContext.block.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
80ed868296 avcodec/h261dec: Stop using MpegEncContext.gb
This is in preparation for removing said field from MpegEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
fabbe79170 avcodec/mpegvideodec: Remove size expectation from ff_mpv_reconstruct_mb
In the common case of decoding 420 content, only six blocks are used
and it makes perfect sense for the caller to only have that many.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
4fc874ef08 avcodec/mpeg_er: Don't use MpegEncContext.block
It is unused (because unquantizing/the idct has been disabled)
apart from FF_DEBUG_DCT_COEFF debug code which makes no sense
when this function is called via error resilience. So pass a NULL
as block when calling ff_mpv_reconstruct_mb() from mpeg_er_decode_mb()
and disable the debug code in this scenario.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
8cff637cf0 avcodec/mpegvideo_dec: Reindent after the previous commit
Also use dedicated variables for the accesses.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
261d8eb5dd avcodec/mpegvideo_dec: Factor debugging dct coefficients out
This allows to hint to the compiler that the branch is likely
not taken by marking the factored out function as av_cold.
It is also in preparation for further commits.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
0723fcce51 avcodec/mpegvideo: Add MPVContext typedef
MpegEncContext is also used for decoding, so it is a misnomer.
This commit therefore adds MPVContext as typedef for it in order
to gradually switch the code to the new name (in line with
MPVEncContext).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
3b87a480fe avcodec/mpegvideoenc: Allocate blocks as part of MPVEncContext
This avoids mpegvideo.c having to deal with the fact that
the encoders use two sets of blocks and is in preparation
for not allocating blocks at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
1c258b5581 avcodec/ituh263dec: Only initialize ff_h263_rl_inter when needed
The H.263 decoder itself does not need max_run/max_level
of this RLTable, only the MPEG-4 decoder does.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
8a3566498e avcodec/ituh263enc: Simplify creating LUT
Only very few combinations (2x102) of 16384 correspond to
valid codes; so just initialize all codes via memset
and then set the few valid codes explicitly instead of initializing
everything in the same way.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
ba79fff6d5 avcodec/rl: Avoid branch in index lookup
This uses the same logic as the MPEG-1/2 and SpeedHQ encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
baccb96fce avcodec/ituh263dec: Use correct logcontext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:34:51 +02:00
725563a731 avcodec/wmaprodec: Avoid branch for setting block_align
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:21:55 +02:00
66acbb92a3 avcodec/wma: Remove redundant nb_channels check
Already checked generically as none of the codecs here
have the AV_CODEC_CAP_CHANNEL_CONF set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:21:55 +02:00
12777f30a8 avcodec/wma,wmaprodec: Remove always-false checks
None of the codecs used here has the AV_CODEC_CAP_CHANNEL_CONF
cap set, so the sample rate is checked generically.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:21:55 +02:00
73646259a0 avcodec/avcodec: Check sample_rate generically
Check that all audio codecs except decoders with the
AV_CODEC_CAP_CHANNEL_CONF flag have a positive sample rate set.

Fixes: AVERROR_BUG return
Fixes: 413997604/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HCA_fuzzer-5188382613635072

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:21:55 +02:00
82fa6b450d avcodec/dfpwmenc: Remove write-only context member
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:18:55 +02:00
11d3af0d7f avcodec/dfpwmenc: Correctly pad input
Before this patch, the DFPWM1a encoder was marked as supporting
variable frame sizes. The DFPWM1a format converts eight bytes
of input into one output byte and so it simply padded the number
of data output by
frame->nb_samples * frame->ch_layout.nb_channels / 8 +
(frame->nb_samples % 8 > 0 ? 1 : 0)
This has several bugs:
a) The additional byte leads to eight additional input byte being
read; this can read into the frame's padding, i.e. the data can
be uninitialized.
b) The criterion for whether one should pad is wrong:
nb_samples * nb_channels should be tested for divisibility by eight.
c) The created frames can be undecodable (at least with our decoder):
Our decoder requires the number of bits per frame to divisible by
the number of channels, yet the above approach does not guarantee this.
d) The padding will be added in the middle of the stream (potentially
for every packet).

This commit fixes all of this by removing the variable frame size cap
and using AVCodecInternal.pad_samples to pad the last frame so that
nb_samples * nb_channels is always a multiple of eight.
The lavf-dfpwm FATE-test was affected by a). The frames originated from
lavfi and were part of an audio frame pool, so that the padding
contained data from an earlier (bigger) frame. Now the last frame is
properly filled with silence.

Reported-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:18:55 +02:00
e813e1e940 avcodec/fic: Postpone duplicating AVFrame buffer
This avoids duplicating the AVFrames in case of skip frames
or in case of errors.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 19:42:29 +02:00
45920251d9 avcodec/fic: Ensure skip frames have up-to-date props
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 19:42:29 +02:00
8bed944dda avcodec/fic: Don't prematurely claim to have decoded a frame
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 19:42:29 +02:00
4c69f302a9 avcodec/fic: Remove redundant logmessage
ff_reget_buffer() emits its own logmessage on error.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 19:42:28 +02:00
12ae987a6a avcodec/fic: Don't copy frame unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 19:42:28 +02:00
d6986e1fcd avcodec/fic: Avoid implicit av_frame_free()+av_frame_alloc()
Use av_frame_replace() instead. Also remove the error message:
It was highly misleading (as if av_frame_clone() duplicated
the AVFrame data buffers instead of just creating a new reference).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 19:42:28 +02:00
5d5e922088 avcodec/fic: Avoid copying cursor unnecessarily
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 19:42:28 +02:00
2845013154 tests/fate/screen: Add test for skipping cursor with FIC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 19:42:28 +02:00
2db60f90df swresample/rematrix: Constify
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 18:17:56 +02:00
589f1e5cc7 swresample/rematrix: Use correct function pointer types for calls
Calling a function via a different function pointer type is
undefined behavior (C11, 6.3.2.3 8); two pointer parameters
of different type are not equivalent in this regard, although
it happens to work in practice; the current code relies on this.

This patch brings the code in line with the spec. This fixes the
following FATE-tests when run with Clang-UBSan:
ac3-fixed-encode-2 audiomatch-afconvert-{16000,44100}-mono-he-{adts,m4a}
audiomatch-dolby-44100-mono-he-mp4 filter-metadata-avf-aphase-meter-mono
filter-pan-{downmix1,downmix2,mono2,stereo2,stereo3,stereo4,upmix1,upmix2}
lavf-dv_{pal,ntsc} matroska-encoding-delay
The error was something like
src/libswresample/rematrix.c:621:17: runtime error: call to function sum2_float through pointer to incorrect function type 'void (*)(void *, const void *, const void *, void *, int, int, int)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 18:17:56 +02:00
bdb4cd44e2 avcodec/ffv1enc: Use dummies to avoid UB pointer arithmetic
Fixes the following FATE-tests when run under Clang-UBSan:
ffmpeg-loopback-decoding, lavf-mxf_ffv1,
vsynth{1,2,3,_lena}-ffv1-v{0,2}, vsynth1-ffv{1,2,3,_lena},
vsynth{1,2,3,_lena}-ffv1-v3-yuv{420p,422p10,444p16}

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 18:17:56 +02:00
134c1d81a4 avcodec/indeo3: Constify ref_block in decode_cell_data()
Also use smaller scope while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 18:17:56 +02:00
41d86b5be5 avcodec/indeo3: Consistently use ptrdiff_t for strides
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 18:17:56 +02:00
7574c55761 avcodec/indeo3: Fix UB pointer arithmetic
Fixes the following error when running with Clang-UBSan:
src/libavcodec/indeo3.c:556:26: runtime error: applying non-zero offset 2560 to null pointer
This fixes the indeo3-2 FATE test.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 18:17:56 +02:00
11d1b71c31 doc/APIchanges: add missing entries for the recent changes
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-01 23:28:24 -03:00
5083f4ad8e avcodec/nvenc: add MV-HEVC encoding support
Added support for MV-HEVC encoding for stereoscopic videos (2 views
only). Compatible with the framepack filter when using the
AV_STEREO3D_FRAMESEQUENCE format.

Signed-off-by: Diego de Souza <ddesouza@nvidia.com>
2025-07-01 22:47:47 +02:00
9c2028b806 avcodec/hevc/hevcdec: export 3D Reference Displays side data
Signed-off-by: James Almer <jamrial@gmail.com>
2025-07-01 22:47:34 +02:00