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
774 case AV_CODEC_ID_SPEEDHQ:774 case AV_CODEC_ID_SPEEDHQ:
775 s->out_format = FMT_SPEEDHQ;775 s->out_format = FMT_SPEEDHQ;
776 s->intra_only = 1; /* force intra only for SHQ */776 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;
781 avctx->delay = 0;777 avctx->delay = 0;
782 s->low_delay = 1;778 s->low_delay = 1;
783 break;779 break;
libavcodec/speedhqenc.c+14−8
@@ -95,26 +95,26 @@ static av_cold void speedhq_init_static_data(void) · 94 unmodified lines
95 ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len);95 ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len);
96}96}
97 97
98av_cold int ff_speedhq_encode_init(MpegEncContext *s)98static av_cold int speedhq_encode_init(AVCodecContext *avctx)
99{99{
100 static AVOnce init_static_once = AV_ONCE_INIT;100 static AVOnce init_static_once = AV_ONCE_INIT;
101 MpegEncContext *const s = avctx->priv_data;
102 int ret;
101 103
102 if (s->width > 65500 || s->height > 65500) {104 if (avctx->width > 65500 || avctx->height > 65500) {
103 av_log(s->avctx, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n");105 av_log(avctx, AV_LOG_ERROR, "SpeedHQ does not support resolutions above 65500x65500\n");
104 return AVERROR(EINVAL);106 return AVERROR(EINVAL);
105 }107 }
106 108
107 // border is not implemented correctly at the moment, see ticket #10078109 // border is not implemented correctly at the moment, see ticket #10078
108 if (s->width % 16) {110 if (avctx->width % 16) {
109 av_log(s->avctx, AV_LOG_ERROR, "width must be a multiple of 16\n");111 av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 16\n");
110 return AVERROR_PATCHWELCOME;112 return AVERROR_PATCHWELCOME;
111 }113 }
112 114
113 s->min_qcoeff = -2048;115 s->min_qcoeff = -2048;
114 s->max_qcoeff = 2047;116 s->max_qcoeff = 2047;
115 117
116 ff_thread_once(&init_static_once, speedhq_init_static_data);
117
118 s->intra_ac_vlc_length =118 s->intra_ac_vlc_length =
119 s->intra_ac_vlc_last_length =119 s->intra_ac_vlc_last_length =
120 s->intra_chroma_ac_vlc_length =120 s->intra_chroma_ac_vlc_length =
@@ -123,6 +123,12 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s) · 2 unmodified lines
123 s->y_dc_scale_table =123 s->y_dc_scale_table =
124 s->c_dc_scale_table = ff_mpeg12_dc_scale_table[3];124 s->c_dc_scale_table = ff_mpeg12_dc_scale_table[3];
125 125
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
126 switch (s->avctx->pix_fmt) {132 switch (s->avctx->pix_fmt) {
127 case AV_PIX_FMT_YUV420P:133 case AV_PIX_FMT_YUV420P:
128 s->avctx->codec_tag = MKTAG('S','H','Q','0');134 s->avctx->codec_tag = MKTAG('S','H','Q','0');
@@ -280,7 +286,7 @@ const FFCodec ff_speedhq_encoder = { · 151 unmodified lines
280 .p.priv_class = &ff_mpv_enc_class,286 .p.priv_class = &ff_mpv_enc_class,
281 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,287 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE,
282 .priv_data_size = sizeof(SpeedHQEncContext),288 .priv_data_size = sizeof(SpeedHQEncContext),
283 .init = ff_mpv_encode_init,289 .init = speedhq_encode_init,
284 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),290 FF_CODEC_ENCODE_CB(ff_mpv_encode_picture),
285 .close = ff_mpv_encode_end,291 .close = ff_mpv_encode_end,
286 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,292 .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
libavcodec/speedhqenc.h+0−1
@@ -33,7 +33,6 @@ · 32 unmodified lines
33 33
34#include "mpegvideo.h"34#include "mpegvideo.h"
35 35
36int ff_speedhq_encode_init(MpegEncContext *s);
37void ff_speedhq_encode_close(MpegEncContext *s);36void ff_speedhq_encode_close(MpegEncContext *s);
38void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]);37void ff_speedhq_encode_mb(MpegEncContext *s, int16_t block[12][64]);
39 38

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