History

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.

Andreas Rheinhardt committed 1 year ago

Commit 565e57e1 parent c757f943 files · +14 −13Browse files

Unified · Split

3 files
  1. libavcodec/mpegvideo_enc.c +0 −4
  2. libavcodec/speedhqenc.c +14 −8
  3. libavcodec/speedhqenc.h +0 −1
libavcodec/mpegvideo_enc.c+0−4
@@ -774,10 +774,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 773 unmodified lines
774774 case AV_CODEC_ID_SPEEDHQ:
775775 s->out_format = FMT_SPEEDHQ;
776776 s->intra_only = 1; /* force intra only for SHQ */
777− if (!CONFIG_SPEEDHQ_ENCODER)
778− return AVERROR_ENCODER_NOT_FOUND;
779− if ((ret = ff_speedhq_encode_init(s)) < 0)
780− return ret;
781777 avctx->delay = 0;
782778 s->low_delay = 1;
783779 break;
libavcodec/speedhqenc.c+14−8
@@ -95,26 +95,26 @@ static av_cold void speedhq_init_static_data(void) · 94 unmodified lines
9595 ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len);
9696 }
9797
98−av_cold int ff_speedhq_encode_init(MpegEncContext *s)
98+static av_cold int speedhq_encode_init(AVCodecContext *avctx)
9999 {
100100 static AVOnce init_static_once = AV_ONCE_INIT;
101+ MpegEncContext *const s = avctx->priv_data;
102+ int ret;
101103
102− if (s->width > 65500 || s->height > 65500) {
103− av_log(s->avctx, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n");
104+ if (avctx->width > 65500 || avctx->height > 65500) {
105+ av_log(avctx, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n");
104106 return AVERROR(EINVAL);
105107 }
106108
107109 // border is not implemented correctly at the moment, see ticket #10078
108− if (s->width % 16) {
109− av_log(s->avctx, AV_LOG_ERROR, "width must be a multiple of 16\n");
110+ if (avctx->width % 16) {
111+ av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 16\n");
110112 return AVERROR_PATCHWELCOME;
111113 }
112114
113115 s->min_qcoeff = -2048;
114116 s->max_qcoeff = 2047;
115117
116− ff_thread_once(&init_static_once, speedhq_init_static_data);
117−
118118 s->intra_ac_vlc_length =
119119 s->intra_ac_vlc_last_length =
120120 s->intra_chroma_ac_vlc_length =
@@ -123,6 +123,12 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s) · 2 unmodified lines
123123 s->y_dc_scale_table =
124124 s->c_dc_scale_table = ff_mpeg12_dc_scale_table[3];
125125
126+ ret = ff_mpv_encode_init(avctx);
127+ if (ret < 0)
128+ return ret;
129+
130+ ff_thread_once(&init_static_once, speedhq_init_static_data);
131+
126132 switch (s->avctx->pix_fmt) {
127133 case AV_PIX_FMT_YUV420P:
128134 s->avctx->codec_tag = MKTAG('S','H','Q','0');
@@ -280,7 +286,7 @@ const FFCodec ff_speedhq_encoder = { · 151 unmodified lines
280286 .p.priv_class = &ff_mpv_enc_class,
281287 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
282288 .priv_data_size = sizeof(SpeedHQEncContext),
283− .init = ff_mpv_encode_init,
289+ .init = speedhq_encode_init,
284290 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
285291 .close = ff_mpv_encode_end,
286292 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
libavcodec/speedhqenc.h+0−1
@@ -33,7 +33,6 @@ · 32 unmodified lines
3333
3434 #include "mpegvideo.h"
3535
36−int ff_speedhq_encode_init(MpegEncContext *s);
3736 void ff_speedhq_encode_close(MpegEncContext *s);
3837 void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]);
3938

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t