| @@ -95,26 +95,26 @@ static av_cold void speedhq_init_static_data(void) · 94 unmodified lines |
| 95 | 95 | ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | | −av_cold int ff_speedhq_encode_init(MpegEncContext *s) |
| 98 | +static av_cold int speedhq_encode_init(AVCodecContext *avctx) |
| 99 | 99 | { |
| 100 | 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) { |
| 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"); |
| 104 | 106 | return AVERROR(EINVAL); |
| 105 | 107 | } |
| 106 | 108 | |
| 107 | 109 | // 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"); |
| 110 | 112 | return AVERROR_PATCHWELCOME; |
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | s->min_qcoeff = -2048; |
| 114 | 116 | s->max_qcoeff = 2047; |
| 115 | 117 | |
| 116 | | − ff_thread_once(&init_static_once, speedhq_init_static_data); |
| 117 | | − |
| 118 | 118 | s->intra_ac_vlc_length = |
| 119 | 119 | s->intra_ac_vlc_last_length = |
| 120 | 120 | s->intra_chroma_ac_vlc_length = |
| @@ -123,6 +123,12 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s) · 2 unmodified lines |
| 123 | 123 | s->y_dc_scale_table = |
| 124 | 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 | 132 | switch (s->avctx->pix_fmt) { |
| 127 | 133 | case AV_PIX_FMT_YUV420P: |
| 128 | 134 | s->avctx->codec_tag = MKTAG('S','H','Q','0'); |
| @@ -280,7 +286,7 @@ const FFCodec ff_speedhq_encoder = { · 151 unmodified lines |
| 280 | 286 | .p.priv_class = &ff_mpv_enc_class, |
| 281 | 287 | .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, |
| 282 | 288 | .priv_data_size = sizeof(SpeedHQEncContext), |
| 283 | | − .init = ff_mpv_encode_init, |
| 289 | + .init = speedhq_encode_init, |
| 284 | 290 | FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), |
| 285 | 291 | .close = ff_mpv_encode_end, |
| 286 | 292 | .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, |