From 653ef25c0d328cc705144f0601da81238915e173 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Date: Sun, 2 Mar 2025 02:20:03 +0100 Subject: [PATCH 22/77] avcodec/mpegvideo_enc: Move MPEG-4 specific check to mpeg4videoenc.c Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/mpeg4videoenc.c | 9 +++++++++ libavcodec/mpegvideo_enc.c | 10 ---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index 18f97bb81d..c265316ed6 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1305,6 +1305,15 @@ static av_cold int encode_init(AVCodecContext *avctx) ff_thread_once(&init_static_once, mpeg4_encode_init_static); + if (avctx->time_base.den > (1 << 16) - 1) { + av_log(avctx, AV_LOG_ERROR, + "timebase %d/%d not supported by MPEG 4 standard, " + "the maximum admitted value for the timebase denominator " + "is %d\n", avctx->time_base.num, avctx->time_base.den, + (1 << 16) - 1); + return AVERROR(EINVAL); + } + m4->time_increment_bits = av_log2(avctx->time_base.den - 1) + 1; s->fcode_tab = fcode_tab + MAX_MV; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index ab67f5444d..0a9c18ff79 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -737,16 +737,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, "intra_quant_bias = %d inter_quant_bias = %d\n",s->intra_quant_bias,s->inter_quant_bias); - if (avctx->codec_id == AV_CODEC_ID_MPEG4 && - avctx->time_base.den > (1 << 16) - 1) { - av_log(avctx, AV_LOG_ERROR, - "timebase %d/%d not supported by MPEG 4 standard, " - "the maximum admitted value for the timebase denominator " - "is %d\n", avctx->time_base.num, avctx->time_base.den, - (1 << 16) - 1); - return AVERROR(EINVAL); - } - switch (avctx->codec->id) { #if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER case AV_CODEC_ID_MPEG2VIDEO: -- 2.45.2