int drop_threshold;
int noise_sensitivity;
int vpx_cs;
+ float level;
} VPxContext;
/** String mappings for enum vp8e_enc_control_id */
#if VPX_ENCODER_ABI_VERSION >= 11
[VP9E_SET_COLOR_RANGE] = "VP9E_SET_COLOR_RANGE",
#endif
+#if VPX_ENCODER_ABI_VERSION >= 12
+ [VP9E_SET_TARGET_LEVEL] = "VP9E_SET_TARGET_LEVEL",
+ [VP9E_GET_LEVEL] = "VP9E_GET_LEVEL",
+#endif
#endif
};
return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL);
}
+#if VPX_ENCODER_ABI_VERSION >= 12
+static av_cold int codecctl_intp(AVCodecContext *avctx,
+ enum vp8e_enc_control_id id, int *val)
+{
+ VPxContext *ctx = avctx->priv_data;
+ char buf[80];
+ int width = -30;
+ int res;
+
+ snprintf(buf, sizeof(buf), "%s:", ctlidstr[id]);
+ av_log(avctx, AV_LOG_DEBUG, " %*s%d\n", width, buf, *val);
+
+ res = vpx_codec_control(&ctx->encoder, id, val);
+ if (res != VPX_CODEC_OK) {
+ snprintf(buf, sizeof(buf), "Failed to set %s codec control",
+ ctlidstr[id]);
+ log_encoder_error(avctx, buf);
+ }
+
+ return res == VPX_CODEC_OK ? 0 : AVERROR(EINVAL);
+}
+#endif
+
static av_cold int vpx_free(AVCodecContext *avctx)
{
VPxContext *ctx = avctx->priv_data;
+#if VPX_ENCODER_ABI_VERSION >= 12
+ if (ctx->level >= 0 && !(avctx->flags & AV_CODEC_FLAG_PASS1)) {
+ int level_out = 0;
+ if (!codecctl_intp(avctx, VP9E_GET_LEVEL, &level_out))
+ av_log(avctx, AV_LOG_INFO, "Encoded level %.1f\n", level_out * 0.1);
+ }
+#endif
+
vpx_codec_destroy(&ctx->encoder);
if (ctx->is_alpha)
vpx_codec_destroy(&ctx->encoder_alpha);
if (ctx->flags & VP8F_AUTO_ALT_REF)
ctx->auto_alt_ref = 1;
if (ctx->auto_alt_ref >= 0)
- codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF, ctx->auto_alt_ref);
+ codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF,
+ avctx->codec_id == AV_CODEC_ID_VP8 ? !!ctx->auto_alt_ref : ctx->auto_alt_ref);
if (ctx->arnr_max_frames >= 0)
codecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames);
if (ctx->arnr_strength >= 0)
#endif
#if VPX_ENCODER_ABI_VERSION >= 11
set_color_range(avctx);
+#endif
+#if VPX_ENCODER_ABI_VERSION >= 12
+ codecctl_int(avctx, VP9E_SET_TARGET_LEVEL, ctx->level < 0 ? 255 : lrint(ctx->level * 10));
#endif
}
#endif
#define COMMON_OPTIONS \
{ "auto-alt-ref", "Enable use of alternate reference " \
- "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, VE}, \
+ "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 2, VE}, \
{ "lag-in-frames", "Number of frames to look ahead for " \
"alternate reference frame selection", OFFSET(lag_in_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
{ "arnr-maxframes", "altref noise reduction max frame count", OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, \
{ "variance", "Variance based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 1}, 0, 0, VE, "aq_mode" },
{ "complexity", "Complexity based Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 2}, 0, 0, VE, "aq_mode" },
{ "cyclic", "Cyclic Refresh Aq", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, VE, "aq_mode" },
+#if VPX_ENCODER_ABI_VERSION >= 12
+ {"level", "Specify level", OFFSET(level), AV_OPT_TYPE_FLOAT, {.dbl=-1}, -1, 6.2, VE},
+#endif
LEGACY_OPTIONS
{ NULL }
};