ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | Mon Mar 3 20:53:33 2025 +0100| [9479ee50384a98573e25deb9d3ea922952977a9a] | committer: Andreas Rheinhardt
avcodec/mpegvideo_enc: Move default_mv_penalty to h261enc.c MPEG-1/2 and the H.263-based encoders overwrite the default later and SpeedHQ and MJPEG-based encoders are intra-only and don't need a mv_penalty table at all. So only H.261 uses this table. Also add a comment to explain why it exists and is non-const. Reviewed-by: Ramiro Polla <ramiro.po...@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9479ee50384a98573e25deb9d3ea922952977a9a --- libavcodec/h261enc.c | 6 ++++++ libavcodec/mpegvideo_enc.c | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index dabab9d80a..5253e82129 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -46,6 +46,10 @@ static struct VLCLUT { uint16_t code; } vlc_lut[H261_MAX_RUN + 1][32 /* 0..2 * H261_MAX_LEN are used */]; +// Not const despite never being initialized because doing so would +// put it into .rodata instead of .bss and bloat the binary. +// mv_penalty exists so that the motion estimation code can avoid branches. +static uint8_t mv_penalty[MAX_FCODE + 1][MAX_DMV * 2 + 1]; static uint8_t uni_h261_rl_len [64 * 128]; static uint8_t uni_h261_rl_len_last[64 * 128]; static uint8_t h261_mv_codes[64][2]; @@ -370,6 +374,8 @@ av_cold int ff_h261_encode_init(MpegEncContext *s) s->max_qcoeff = 127; s->ac_esc_length = H261_ESC_LEN; + s->me.mv_penalty = mv_penalty; + s->intra_ac_vlc_length = s->inter_ac_vlc_length = uni_h261_rl_len; s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = uni_h261_rl_len_last; ff_thread_once(&init_static_once, h261_encode_init_static); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 8c22dbb5f5..1fe69f89a6 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -93,7 +93,6 @@ static int dct_quantize_c(MpegEncContext *s, int qscale, int *overflow); static int dct_quantize_trellis_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); -static uint8_t default_mv_penalty[MAX_FCODE + 1][MAX_DMV * 2 + 1]; static uint8_t default_fcode_tab[MAX_MV * 2 + 1]; static const AVOption mpv_generic_options[] = { @@ -287,7 +286,6 @@ static void mpv_encode_defaults(MpegEncContext *s) ff_thread_once(&init_static_once, mpv_encode_init_static); - s->me.mv_penalty = default_mv_penalty; s->fcode_tab = default_fcode_tab; s->input_picture_number = 0; _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".