From 5075398a320885d1597b143362535685a5310a63 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 3 Mar 2025 21:04:49 +0100 Subject: [PATCH 12/40] avcodec/ituh263enc: Move MPEG-4 fcode_tab to mpeg4videoenc.c Signed-off-by: Andreas Rheinhardt --- libavcodec/ituh263enc.c | 12 ------------ libavcodec/mpeg4videoenc.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 1ef4a8f88e..2152046b43 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -52,11 +52,6 @@ */ static uint8_t mv_penalty[MAX_FCODE+1][MAX_DMV*2+1]; -/** - * Minimal fcode that a motion vector component would need. - */ -static uint8_t fcode_tab[MAX_MV*2+1]; - /** * Minimal fcode that a motion vector component would need in umv. * All entries in this table are 1. @@ -762,12 +757,6 @@ static av_cold void init_mv_penalty_and_fcode(void) } } - for(f_code=MAX_FCODE; f_code>0; f_code--){ - for(mv=-(16<1 only for MPEG-4 & H.263 & H.263+ FIXME switch(s->codec_id){ case AV_CODEC_ID_MPEG4: - s->fcode_tab= fcode_tab; break; case AV_CODEC_ID_H263P: if(s->umvplus) diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 0b31576dc5..64fb96a0cf 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -37,6 +37,11 @@ #include "profiles.h" #include "version.h" +/** + * Minimal fcode that a motion vector component would need. + */ +static uint8_t fcode_tab[MAX_MV*2+1]; + /* The uni_DCtab_* tables below contain unified bits+length tables to encode DC * differences in MPEG-4. Unified in the sense that the specification specifies * this encoding in several steps. */ @@ -1255,6 +1260,11 @@ static av_cold void mpeg4_encode_init_static(void) init_uni_mpeg4_rl_tab(&ff_mpeg4_rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len); init_uni_mpeg4_rl_tab(&ff_h263_rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len); + + for (int f_code = MAX_FCODE; f_code > 0; f_code--) { + for (int mv = -(16 << f_code); mv < (16 << f_code); mv++) + fcode_tab[mv + MAX_MV] = f_code; + } } static av_cold int encode_init(AVCodecContext *avctx) @@ -1274,6 +1284,7 @@ static av_cold int encode_init(AVCodecContext *avctx) ff_thread_once(&init_static_once, mpeg4_encode_init_static); + s->fcode_tab = fcode_tab; s->min_qcoeff = -2048; s->max_qcoeff = 2047; s->intra_ac_vlc_length = uni_mpeg4_intra_rl_len; -- 2.45.2