From 1a73463508298d6683658e86a5e0e5453c75e0d7 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sat, 17 May 2025 19:30:02 +0200 Subject: [PATCH 01/19] avcodec/mpegvideo_enc: Set gob_index once during init Signed-off-by: Andreas Rheinhardt --- libavcodec/ituh263enc.c | 3 +++ libavcodec/mpegvideo_enc.c | 16 +++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index b9d903a220..9a6d5dc201 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -842,6 +842,9 @@ av_cold void ff_h263_encode_init(MPVMainEncContext *const m) if (s->c.modified_quant) s->c.chroma_qscale_table = ff_h263_chroma_qscale_table; + // Only used for H.263 and H.263+ + s->c.gob_index = H263_GOB_HEIGHT(s->c.height); + // use fcodes >1 only for MPEG-4 & H.263 & H.263+ FIXME switch(s->c.codec_id){ case AV_CODEC_ID_H263P: diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 6e9533ebc9..62a3a82ff3 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3006,25 +3006,15 @@ static int encode_thread(AVCodecContext *c, void *arg){ s->c.last_dc[0] = 128 * 8 / 13; s->c.last_dc[1] = 128 * 8 / 14; s->c.last_dc[2] = 128 * 8 / 14; + } else if (CONFIG_MPEG4_ENCODER && s->c.codec_id == AV_CODEC_ID_MPEG4 && + s->c.partitioned_frame) { + ff_mpeg4_init_partitions(s); } s->c.mb_skip_run = 0; memset(s->c.last_mv, 0, sizeof(s->c.last_mv)); s->last_mv_dir = 0; - switch (s->c.codec_id) { - case AV_CODEC_ID_H263: - case AV_CODEC_ID_H263P: - case AV_CODEC_ID_FLV1: - if (CONFIG_H263_ENCODER) - s->c.gob_index = H263_GOB_HEIGHT(s->c.height); - break; - case AV_CODEC_ID_MPEG4: - if (CONFIG_MPEG4_ENCODER && s->c.partitioned_frame) - ff_mpeg4_init_partitions(s); - break; - } - s->c.resync_mb_x = 0; s->c.resync_mb_y = 0; s->c.first_slice_line = 1; -- 2.45.2