aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAlex Converse <alex.converse@gmail.com>2016-11-18 13:56:32 -0800
committerAlex Converse <alex.converse@gmail.com>2016-11-28 12:02:43 -0800
commit8899057d914af32e08042b3e6f25da563485644b (patch)
tree3d9660ee95829ff50ab8725e83860c73f3469983 /libavcodec
parentafb84857bf539d7cd58c99ff5983df1b4740d9d2 (diff)
downloadffmpeg-8899057d914af32e08042b3e6f25da563485644b.tar.gz
libvpxenc: Report encoded VP9 level
Report the actual level of the encoded output if a level is targeted or the level is passively tracked with a target of 0.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/libvpxenc.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 51f423a2a5..13251996c5 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -137,6 +137,7 @@ static const char *const ctlidstr[] = {
#endif
#if VPX_ENCODER_ABI_VERSION >= 12
[VP9E_SET_TARGET_LEVEL] = "VP9E_SET_TARGET_LEVEL",
+ [VP9E_GET_LEVEL] = "VP9E_GET_LEVEL",
#endif
#endif
};
@@ -264,10 +265,41 @@ static av_cold int codecctl_int(AVCodecContext *avctx,
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);