You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/speedhqenc: Move speedhq_encode_init() down
Will avoid forward declarations later. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -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"),
|
||||
|
Reference in New Issue
Block a user