aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2011-09-07 19:14:37 -0700
committerMichael Niedermayer <michaelni@gmx.at>2011-09-08 05:53:54 +0200
commit1da43f7e9927af8b0dede710adf68d3cc762df64 (patch)
tree9204921abbbf2a85590db1775dbb3c141482080f
parent3dc14b4628a0f6d0fac3d3e7fc0f7929f6b7ca65 (diff)
downloadffmpeg-1da43f7e9927af8b0dede710adf68d3cc762df64.tar.gz
libvpxenc: add 'crf' private option
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/libvpxenc.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 6db20e736c..01749a29ba 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -70,6 +70,7 @@ typedef struct VP8EncoderContext {
int arnr_type;
int rc_lookahead;
+ int crf;
} VP8Context;
#define V AV_OPT_FLAG_VIDEO_PARAM
@@ -89,8 +90,10 @@ static const AVOption options[]={
{"arnr_type", "altref noise reduction filter type", offsetof(VP8Context, arnr_type), FF_OPT_TYPE_INT, {.dbl = 3}, 1, 3, V|E},
#if FF_API_X264_GLOBAL_OPTS
{"rc_lookahead", "Number of frames to look ahead for alternate reference frame selection", offsetof(VP8Context, rc_lookahead), FF_OPT_TYPE_INT, {.dbl = -1}, -1, 25, V|E},
+{"crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), FF_OPT_TYPE_INT, {.dbl = -1}, -1, 63, V|E},
#else
{"rc_lookahead", "Number of frames to look ahead for alternate reference frame selection", offsetof(VP8Context, rc_lookahead), FF_OPT_TYPE_INT, {.dbl = 25}, 0, 25, V|E},
+{"crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 63, V|E},
#endif
{NULL}
};
@@ -286,7 +289,11 @@ static av_cold int vp8_init(AVCodecContext *avctx)
if (avctx->rc_min_rate == avctx->rc_max_rate &&
avctx->rc_min_rate == avctx->bit_rate)
enccfg.rc_end_usage = VPX_CBR;
- else if (avctx->crf)
+#if FF_API_X264_GLOBAL_OPTS
+ else if (avctx->crf || ctx->crf > 0)
+#else
+ else if (ctx->crf)
+#endif
enccfg.rc_end_usage = VPX_CQ;
enccfg.rc_target_bitrate = av_rescale_rnd(avctx->bit_rate, 1, 1000,
AV_ROUND_NEAR_INF);
@@ -368,7 +375,13 @@ static av_cold int vp8_init(AVCodecContext *avctx)
codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS, av_log2(avctx->slices));
codecctl_int(avctx, VP8E_SET_STATIC_THRESHOLD, avctx->mb_threshold);
+#if FF_API_X264_GLOBAL_OPTS
codecctl_int(avctx, VP8E_SET_CQ_LEVEL, (int)avctx->crf);
+ if (ctx->crf >= 0)
+ codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf);
+#else
+ codecctl_int(avctx, VP8E_SET_CQ_LEVEL, ctx->crf);
+#endif
codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF, !!(ctx->flags & VP8F_AUTO_ALT_REF));
codecctl_int(avctx, VP8E_SET_ARNR_MAXFRAMES, ctx->arnr_max_frames);
codecctl_int(avctx, VP8E_SET_ARNR_STRENGTH, ctx->arnr_strength);