[FFmpeg-cvslog] avcodec/speedhqenc: Make speedhq_encode_init() call ff_mpv_encode_init()
Andreas Rheinhardt
git at videolan.org
Wed Mar 26 06:08:49 EET 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Mar 1 23:37:50 2025 +0100| [565e57ea87dc821dcf4a0647e28ad9976d34066e] | committer: Andreas Rheinhardt
avcodec/speedhqenc: Make speedhq_encode_init() call ff_mpv_encode_init()
Right now, ff_mpv_encode_init() is set as FFCodec.init and
calls ff_speedhq_encode_init(). The opposite is more natural
and avoids a non-static function.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=565e57ea87dc821dcf4a0647e28ad9976d34066e
---
libavcodec/mpegvideo_enc.c | 4 ----
libavcodec/speedhqenc.c | 22 ++++++++++++++--------
libavcodec/speedhqenc.h | 1 -
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 7eb381af36..1f55512674 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -774,10 +774,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
case AV_CODEC_ID_SPEEDHQ:
s->out_format = FMT_SPEEDHQ;
s->intra_only = 1; /* force intra only for SHQ */
- if (!CONFIG_SPEEDHQ_ENCODER)
- return AVERROR_ENCODER_NOT_FOUND;
- if ((ret = ff_speedhq_encode_init(s)) < 0)
- return ret;
avctx->delay = 0;
s->low_delay = 1;
break;
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index a0baa869cc..de1bc0cfca 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -95,26 +95,26 @@ static av_cold void speedhq_init_static_data(void)
ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len);
}
-av_cold int ff_speedhq_encode_init(MpegEncContext *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 (s->width > 65500 || s->height > 65500) {
- av_log(s->avctx, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n");
+ 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 (s->width % 16) {
- av_log(s->avctx, AV_LOG_ERROR, "width must be a multiple of 16\n");
+ if (avctx->width % 16) {
+ av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 16\n");
return AVERROR_PATCHWELCOME;
}
s->min_qcoeff = -2048;
s->max_qcoeff = 2047;
- ff_thread_once(&init_static_once, speedhq_init_static_data);
-
s->intra_ac_vlc_length =
s->intra_ac_vlc_last_length =
s->intra_chroma_ac_vlc_length =
@@ -123,6 +123,12 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s)
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);
+
switch (s->avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
s->avctx->codec_tag = MKTAG('S','H','Q','0');
@@ -280,7 +286,7 @@ const FFCodec ff_speedhq_encoder = {
.p.priv_class = &ff_mpv_enc_class,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
.priv_data_size = sizeof(SpeedHQEncContext),
- .init = ff_mpv_encode_init,
+ .init = speedhq_encode_init,
FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
.close = ff_mpv_encode_end,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
diff --git a/libavcodec/speedhqenc.h b/libavcodec/speedhqenc.h
index 15be9764d7..66ef7ee023 100644
--- a/libavcodec/speedhqenc.h
+++ b/libavcodec/speedhqenc.h
@@ -33,7 +33,6 @@
#include "mpegvideo.h"
-int ff_speedhq_encode_init(MpegEncContext *s);
void ff_speedhq_encode_close(MpegEncContext *s);
void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]);
More information about the ffmpeg-cvslog
mailing list