From daa01271141c2acb54d11f92dae67344e72e9d5a Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 3 Mar 2025 20:53:33 +0100 Subject: [PATCH 10/40] 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. Signed-off-by: Andreas Rheinhardt --- libavcodec/h261enc.c | 3 +++ libavcodec/mpegvideo_enc.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index dabab9d80a..e33bf35a8a 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -46,6 +46,7 @@ static struct VLCLUT { uint16_t code; } vlc_lut[H261_MAX_RUN + 1][32 /* 0..2 * H261_MAX_LEN are used */]; +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 +371,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; -- 2.45.2