|
|
@ -269,7 +269,8 @@ static av_cold int vp8_free(AVCodecContext *avctx) |
|
|
|
#if CONFIG_LIBVPX_VP9_ENCODER |
|
|
|
#if CONFIG_LIBVPX_VP9_ENCODER |
|
|
|
static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, |
|
|
|
static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, |
|
|
|
struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *flags, |
|
|
|
struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *flags, |
|
|
|
vpx_img_fmt_t *img_fmt) { |
|
|
|
vpx_img_fmt_t *img_fmt) |
|
|
|
|
|
|
|
{ |
|
|
|
#ifdef VPX_IMG_FMT_HIGHBITDEPTH |
|
|
|
#ifdef VPX_IMG_FMT_HIGHBITDEPTH |
|
|
|
enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8; |
|
|
|
enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8; |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -422,12 +423,12 @@ static av_cold int vpx_init(AVCodecContext *avctx, |
|
|
|
#if CONFIG_LIBVPX_VP9_ENCODER |
|
|
|
#if CONFIG_LIBVPX_VP9_ENCODER |
|
|
|
|| enccfg.rc_end_usage == VPX_Q |
|
|
|
|| enccfg.rc_end_usage == VPX_Q |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (ctx->crf < enccfg.rc_min_quantizer || ctx->crf > enccfg.rc_max_quantizer) { |
|
|
|
if (ctx->crf < enccfg.rc_min_quantizer || ctx->crf > enccfg.rc_max_quantizer) { |
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
"CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n", |
|
|
|
"CQ level %d must be between minimum and maximum quantizer value (%d-%d)\n", |
|
|
|
ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer); |
|
|
|
ctx->crf, enccfg.rc_min_quantizer, enccfg.rc_max_quantizer); |
|
|
|
return AVERROR(EINVAL); |
|
|
|
return AVERROR(EINVAL); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -436,7 +437,7 @@ static av_cold int vpx_init(AVCodecContext *avctx, |
|
|
|
//0-100 (0 => CBR, 100 => VBR)
|
|
|
|
//0-100 (0 => CBR, 100 => VBR)
|
|
|
|
enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100); |
|
|
|
enccfg.rc_2pass_vbr_bias_pct = round(avctx->qcompress * 100); |
|
|
|
if (avctx->bit_rate) |
|
|
|
if (avctx->bit_rate) |
|
|
|
enccfg.rc_2pass_vbr_minsection_pct = |
|
|
|
enccfg.rc_2pass_vbr_minsection_pct = |
|
|
|
avctx->rc_min_rate * 100LL / avctx->bit_rate; |
|
|
|
avctx->rc_min_rate * 100LL / avctx->bit_rate; |
|
|
|
if (avctx->rc_max_rate) |
|
|
|
if (avctx->rc_max_rate) |
|
|
|
enccfg.rc_2pass_vbr_maxsection_pct = |
|
|
|
enccfg.rc_2pass_vbr_maxsection_pct = |
|
|
@ -490,8 +491,8 @@ static av_cold int vpx_init(AVCodecContext *avctx, |
|
|
|
/* 0-3: For non-zero values the encoder increasingly optimizes for reduced
|
|
|
|
/* 0-3: For non-zero values the encoder increasingly optimizes for reduced
|
|
|
|
complexity playback on low powered devices at the expense of encode |
|
|
|
complexity playback on low powered devices at the expense of encode |
|
|
|
quality. */ |
|
|
|
quality. */ |
|
|
|
if (avctx->profile != FF_PROFILE_UNKNOWN) |
|
|
|
if (avctx->profile != FF_PROFILE_UNKNOWN) |
|
|
|
enccfg.g_profile = avctx->profile; |
|
|
|
enccfg.g_profile = avctx->profile; |
|
|
|
|
|
|
|
|
|
|
|
enccfg.g_error_resilient = ctx->error_resilient || ctx->flags & VP8F_ERROR_RESILIENT; |
|
|
|
enccfg.g_error_resilient = ctx->error_resilient || ctx->flags & VP8F_ERROR_RESILIENT; |
|
|
|
|
|
|
|
|
|
|
@ -611,8 +612,7 @@ static inline void cx_pktcpy(struct FrameListData *dst, |
|
|
|
if (src_alpha) { |
|
|
|
if (src_alpha) { |
|
|
|
dst->buf_alpha = src_alpha->data.frame.buf; |
|
|
|
dst->buf_alpha = src_alpha->data.frame.buf; |
|
|
|
dst->sz_alpha = src_alpha->data.frame.sz; |
|
|
|
dst->sz_alpha = src_alpha->data.frame.sz; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
dst->buf_alpha = NULL; |
|
|
|
dst->buf_alpha = NULL; |
|
|
|
dst->sz_alpha = 0; |
|
|
|
dst->sz_alpha = 0; |
|
|
|
} |
|
|
|
} |
|
|
@ -703,8 +703,8 @@ static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out, |
|
|
|
/* consume all available output from the encoder before returning. buffers
|
|
|
|
/* consume all available output from the encoder before returning. buffers
|
|
|
|
are only good through the next vpx_codec call */ |
|
|
|
are only good through the next vpx_codec call */ |
|
|
|
while ((pkt = vpx_codec_get_cx_data(&ctx->encoder, &iter)) && |
|
|
|
while ((pkt = vpx_codec_get_cx_data(&ctx->encoder, &iter)) && |
|
|
|
(!ctx->is_alpha || |
|
|
|
(!ctx->is_alpha || |
|
|
|
(ctx->is_alpha && (pkt_alpha = vpx_codec_get_cx_data(&ctx->encoder_alpha, &iter_alpha))))) { |
|
|
|
(ctx->is_alpha && (pkt_alpha = vpx_codec_get_cx_data(&ctx->encoder_alpha, &iter_alpha))))) { |
|
|
|
switch (pkt->kind) { |
|
|
|
switch (pkt->kind) { |
|
|
|
case VPX_CODEC_CX_FRAME_PKT: |
|
|
|
case VPX_CODEC_CX_FRAME_PKT: |
|
|
|
if (!size) { |
|
|
|
if (!size) { |
|
|
|