1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-29 05:57:37 +02:00
Commit Graph

931 Commits

Author SHA1 Message Date
Andreas Rheinhardt
a2210902ff avcodec/encode: Use enum AVPictureType in ff_encode_add_stats_side_data
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-11-07 17:54:10 +00:00
Andreas Rheinhardt
abc54c25be avcodec/mpegvideo: Move loop_filter to {H263Dec,MPVEnc,VC1}Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:32 +02:00
Andreas Rheinhardt
60f51bdaac avcodec/mpegvideo: Move partitioned_frame to {H263Dec,MPVEnc}Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:32 +02:00
Andreas Rheinhardt
3c06d87c93 avcodec/mpegvideo: Move fields to {H263Dec,MPVEnc}Context when possible
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
502a6ea123 avcodec/mpegvideo: Move SLICE_* defs to h263dec.h, h261dec.c
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
2089d39735 avcodec/mpegvideo: Move mb_skip_run to {RV34Dec,MPVEnc}Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
9f42725d75 avcodec/mpegvideo: Move mb_num_left to {H263,RV34}DecContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
7db6267b30 avcodec/mpegvideo: Move fields only used by H.263 decoders to H263DecCtx
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
f1c56c08ed avcodec/mpeg12dec: Don't use MPVContext.block
Instead add the necessary blocks directly into Mpeg12SliceContext.
This allows to completely remove MPVContext.block.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
e40b0ebb2e avcodec/mpeg12dec: Move MpegEncContext.gb to Mpeg12SliceContext
It was its last user.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
3a96a3c949 avcodec/mpeg12dec: Add Mpeg12SliceContext
This is in preparation for removing the GetBitContext
from MPVContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
8a4accc24d avcodec/h263dec: Stop using MpegEncContext.gb
Add a GetBitContext to H263DecContext instead. This is in preparation
for removing MpegEncContext.gb.
Also move last_resync_gb to H263DecContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-07-03 20:35:31 +02:00
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
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
Andreas Rheinhardt
81ab1106c8 avcodec/mpegvideo: Only keep MpegEncContext.dc_val[0]
The chroma dc_val pointers are mostly unused (accesses use
dc_val[0] and block_index), so remove them.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
Andreas Rheinhardt
dba1061ba4 avcodec/mpegvideo: Only use a single ac_val pointer
The chroma pointers ac_val[1] and ac_val[2] are no longer used anywhere.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-06-21 22:08:52 +02:00
Andreas Rheinhardt
ac1e6d2171 avcodec/mpegvideo: Remove h263_plus
It is only used to indicate to ff_h263_show_pict_info()
that we are decoding H.263+; pass this information
via a function parameter instead.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 05:03:29 +02:00
Andreas Rheinhardt
ed73675832 avcodec/mpegvideo: Move mpeg_quant to {Mpeg4Dec,MPVEnc}Context
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-26 04:58:42 +02:00
Andreas Rheinhardt
505510acda avcodec/mpegvideo: Move parent to MPVEncContext
This is more type-safe and avoids having parent contexts
when unnecessary.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-16 01:37:35 +02:00
Andreas Rheinhardt
f82a75333a avcodec/mpegvideo: Move [fb]_code to Mpeg4Dec and MPVEncContext
It is only used by the MPEG-4 decoder and the encoders.
Notice that this field is a per-frame property and therefore
does not need to by synced in mpeg4_update_thread_context().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-16 01:37:35 +02:00
Andreas Rheinhardt
e5a33c898a avcodec/mpegvideo: Only keep the actually used unquantize funcs
For all encoders and all decoders except MPEG-4 the unquantize
functions to use don't change at all and therefore needn't be
kept in the context. So discard them after setting them;
for MPEG-4, the functions get assigned on a per-frame basis.

Decoders not using any unquantize functions (H.261, MPEG-1/2)
as well as decoders that only call ff_mpv_reconstruct_mb()
through error resilience (RV30/40, the VC-1 family) don't have
the remaining pointers set at all.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 04:17:00 +01:00
Andreas Rheinhardt
63864545cd avcodec/mpegvideo: Move unquantize functions into a file of their own
This is in preparation for only keeping the actually used
unquantize functions in MpegEncContext.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 04:14:49 +01:00
Andreas Rheinhardt
6e45f7f535 avcodec/mpegvideo: Move MotionEstContext to MPVEncContext
All that is necessary to do so is perform ff_me_init_pic()
on every slice.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 04:11:32 +01:00
Andreas Rheinhardt
d66e9cb0d2 avcodec/mpegvideo_enc: Move lambda, lambda2 to MPVEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 04:09:33 +01:00
Andreas Rheinhardt
a064d34a32 avcodec/mpegvideoenc: Add MPVEncContext
Many of the fields of MpegEncContext (which is also used by decoders)
are actually only used by encoders. Therefore this commit adds
a new encoder-only structure and moves all of the encoder-only
fields to it except for those which require more explicit
synchronisation between the main slice context and the other
slice contexts. This synchronisation is currently mainly provided
by ff_update_thread_context() which simply copies most of
the main slice context over the other slice contexts. Fields
which are moved to the new MPVEncContext no longer participate
in this (which is desired, because it is horrible and for the
fields b) below wasteful) which means that some fields can only
be moved when explicit synchronisation code is added in later commits.

More explicitly, this commit moves the following fields:
a) Fields not copied by ff_update_duplicate_context():
dct_error_sum and dct_count; the former does not need synchronisation,
the latter is synchronised in merge_context_after_encode().
b) Fields which do not change after initialisation (these fields
could also be put into MPVMainEncContext at the cost of
an indirection to access them): lambda_table, adaptive_quant,
{luma,chroma}_elim_threshold, new_pic, fdsp, mpvencdsp, pdsp,
{p,b_forw,b_back,b_bidir_forw,b_bidir_back,b_direct,b_field}_mv_table,
[pb]_field_select_table, mb_{type,var,mean}, mc_mb_var, {min,max}_qcoeff,
{inter,intra}_quant_bias, ac_esc_length, the *_vlc_length fields,
the q_{intra,inter,chroma_intra}_matrix{,16}, dct_offset, mb_info,
mjpeg_ctx, rtp_mode, rtp_payload_size, encode_mb, all function
pointers, mpv_flags, quantizer_noise_shaping,
frame_reconstruction_bitfield, error_rate and intra_penalty.
c) Fields which are already (re)set explicitly: The PutBitContexts
pb, tex_pb, pb2; dquant, skipdct, encoding_error, the statistics
fields {mv,i_tex,p_tex,misc,last}_bits and i_count; last_mv_dir,
esc_pos (reset when writing the header).
d) Fields which are only used by encoders not supporting slice
threading for which synchronisation doesn't matter: esc3_level_length
and the remaining mb_info fields.
e) coded_score: This field is only really used when FF_MPV_FLAG_CBP_RD
is set (which implies trellis) and even then it is only used for
non-intra blocks. For these blocks dct_quantize_trellis_c() either
sets coded_score[n] or returns a last_non_zero value of -1
in which case coded_score will be reset in encode_mb_internal().
Therefore no old values are ever used.

The MotionEstContext has not been moved yet.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 04:08:33 +01:00
Andreas Rheinhardt
6a42abe561 avcodec/mpegvideo: Move motion_est to MotionEstContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:47:22 +01:00
Andreas Rheinhardt
913322a267 avcodec/mpegvideo: Move me_pre, me_penalty_compensation to MPVMainEncCtx
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:46:49 +01:00
Andreas Rheinhardt
fa630b481c avcodec/mpegvideo: Move last-pic information to MPVMainEncContext
last_pict_type, last_non_b_pict_type and last_lambda_for
are only used by the encoder's main thread.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:44:30 +01:00
Andreas Rheinhardt
f293f95632 avcodec/mpegvideo: Support custom slice context sizes
This is in preparation for adding a special slice context for
the encoders and moving all the encoder-specific fields to it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:43:58 +01:00
Andreas Rheinhardt
1b537de8d4 avcodec/mpegvideo: Move noise_reduction to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:43:25 +01:00
Andreas Rheinhardt
7b5fb2e4ff avcodec/mpegvideo: Move encoder-only base arrays to MPVMainEncContext
Also allocate them jointly (thereby reducing the number of base
arrays considerably) and already set them on all slice contexts;
don't rely on ff_update_duplicate_context().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:40:27 +01:00
Andreas Rheinhardt
9964212545 avcodec/mpegvideo: Move MSMPEG4 fields to MSMPEG4 contexts
Several fields are not used by any generic code and can therefore
be moved to more specialized contexts.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:39:25 +01:00
Andreas Rheinhardt
6d47d569d7 avcodec/mpegvideo: Move bit_rate field to MSMP4DecContext
Also make it an int as that is all MSMP4 needs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:37:39 +01:00
Andreas Rheinhardt
bceeb35857 avcodec/mpegvideo: Move vbv_delay_pos to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:35:47 +01:00
Andreas Rheinhardt
bf4dedd6b5 avcodec/mpegvideo: Move MPVPicture arrays to MPVMainEncContext
Also avoid allocations while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:35:16 +01:00
Andreas Rheinhardt
72bf3d3c12 avcodec/mpegvideo: Move max_b_frames to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:34:44 +01:00
Andreas Rheinhardt
6e02882656 avcodec/mpegvideo: Add pointer to main context to slice contexts
It is a pointer to const to allow the slice threads to inspect
values without modifying them; also make it a simple cast
for codecs that don't support slice threading.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:34:12 +01:00
Andreas Rheinhardt
5affd0221e avcodec/mpegvideo_enc: Use func ptr for encoding macroblocks
It gets rid of a switch (with accompanying CONFIG_*_ENCODER checks);
for MJPEG, it even lets one perform the check for whether one is
really encoding or only recording the macroblock once during init.

Furthermore, the switch actually contained lots of dead code --
it is compiled three times (for different pixel formats: 420, 422, 444),
yet most encoders only support 420. The approach used here automatically
fixes this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:33:15 +01:00
Andreas Rheinhardt
7751b0cbed avcodec/mpegvideo: Move fcode_tab to MPVMainEncContext
Only used by the main encoding thread.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:31:55 +01:00
Andreas Rheinhardt
6b6b34df35 avcodec/mpegvideo: Move header_bits to MPVMainEncContext
The header is always written by the main thread, so it is
not surprising that header_bits can be moved to MPVMainEncContext
as well.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:30:07 +01:00
Andreas Rheinhardt
b038c7af0c avcodec/mpegvideo: Move macroblock-variance stats to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:29:35 +01:00
Andreas Rheinhardt
d1fd8665fb avcodec/mpegvideo: Move ratecontrol-adjacent fields to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:17:52 +01:00
Andreas Rheinhardt
b710698571 avcodec/mpegvideo: Move sequence-level properties to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:16:03 +01:00
Andreas Rheinhardt
fca1ac2cba avcodec/mpeg4videoenc: Add Mpeg4EncContext and move time_increment_bits
It is only ever used by the main encoder thread.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:15:05 +01:00
Andreas Rheinhardt
3275d788ec avcodec/mpegvideo: Move frame_skip_* fields to MPVMainEncContext
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:08:52 +01:00
Andreas Rheinhardt
4d79175b9a avcodec/mpegvideo_enc: Precalculate which frames to reconstruct
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-26 03:08:22 +01:00