From 7522f0eb03977271057f67252b0f70393fb7d00c Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Date: Mon, 3 Mar 2025 19:24:25 +0100 Subject: [PATCH 28/77] avcodec/speedhqenc: Move speedhq_encode_init() down Will avoid forward declarations later. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/speedhqenc.c | 102 ++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 2e09016935..daccd0c3bf 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -95,57 +95,6 @@ static av_cold void speedhq_init_static_data(void) ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len); } -static av_cold int speedhq_encode_init(AVCodecContext *avctx) -{ - static AVOnce init_static_once = AV_ONCE_INIT; - MpegEncContext *const s = avctx->priv_data; - int ret; - - if (avctx->width > 65500 || avctx->height > 65500) { - av_log(avctx, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n"); - return AVERROR(EINVAL); - } - - // border is not implemented correctly at the moment, see ticket #10078 - if (avctx->width % 16) { - av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 16\n"); - return AVERROR_PATCHWELCOME; - } - - switch (avctx->pix_fmt) { - case AV_PIX_FMT_YUV420P: - avctx->codec_tag = MKTAG('S','H','Q','0'); - break; - case AV_PIX_FMT_YUV422P: - avctx->codec_tag = MKTAG('S','H','Q','2'); - break; - case AV_PIX_FMT_YUV444P: - avctx->codec_tag = MKTAG('S','H','Q','4'); - break; - default: - av_assert0(0); - } - - s->min_qcoeff = -2048; - s->max_qcoeff = 2047; - - s->intra_ac_vlc_length = - s->intra_ac_vlc_last_length = - s->intra_chroma_ac_vlc_length = - s->intra_chroma_ac_vlc_last_length = uni_speedhq_ac_vlc_len; - - s->y_dc_scale_table = - s->c_dc_scale_table = ff_mpeg12_dc_scale_table[3]; - - ret = ff_mpv_encode_init(avctx); - if (ret < 0) - return ret; - - ff_thread_once(&init_static_once, speedhq_init_static_data); - - return 0; -} - void ff_speedhq_encode_picture_header(MpegEncContext *s) { SpeedHQEncContext *ctx = (SpeedHQEncContext*)s; @@ -278,6 +227,57 @@ void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]) s->i_tex_bits += get_bits_diff(s); } +static av_cold int speedhq_encode_init(AVCodecContext *avctx) +{ + static AVOnce init_static_once = AV_ONCE_INIT; + MpegEncContext *const s = avctx->priv_data; + int ret; + + if (avctx->width > 65500 || avctx->height > 65500) { + av_log(avctx, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n"); + return AVERROR(EINVAL); + } + + // border is not implemented correctly at the moment, see ticket #10078 + if (avctx->width % 16) { + av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 16\n"); + return AVERROR_PATCHWELCOME; + } + + switch (avctx->pix_fmt) { + case AV_PIX_FMT_YUV420P: + avctx->codec_tag = MKTAG('S','H','Q','0'); + break; + case AV_PIX_FMT_YUV422P: + avctx->codec_tag = MKTAG('S','H','Q','2'); + break; + case AV_PIX_FMT_YUV444P: + avctx->codec_tag = MKTAG('S','H','Q','4'); + break; + default: + av_assert0(0); + } + + s->min_qcoeff = -2048; + s->max_qcoeff = 2047; + + s->intra_ac_vlc_length = + s->intra_ac_vlc_last_length = + s->intra_chroma_ac_vlc_length = + s->intra_chroma_ac_vlc_last_length = uni_speedhq_ac_vlc_len; + + s->y_dc_scale_table = + s->c_dc_scale_table = ff_mpeg12_dc_scale_table[3]; + + ret = ff_mpv_encode_init(avctx); + if (ret < 0) + return ret; + + ff_thread_once(&init_static_once, speedhq_init_static_data); + + return 0; +} + const FFCodec ff_speedhq_encoder = { .p.name = "speedhq", CODEC_LONG_NAME("NewTek SpeedHQ"), -- 2.45.2