# HG changeset patch # User darkshikari # Date 1273185498 0 # Node ID 2312dfbe92515a3dc139766479605a97a705bfde # Parent 6f5bee041560bc9af933549cfd13aa856a6eefa9 Add intra refresh and crf-max support to the libavcodec libx264 wrapper. Minor version bump. diff -r 6f5bee041560 -r 2312dfbe9251 avcodec.h --- a/avcodec.h Thu May 06 20:38:42 2010 +0000 +++ b/avcodec.h Thu May 06 22:38:18 2010 +0000 @@ -30,7 +30,7 @@ #include "libavutil/avutil.h" #define LIBAVCODEC_VERSION_MAJOR 52 -#define LIBAVCODEC_VERSION_MINOR 66 +#define LIBAVCODEC_VERSION_MINOR 67 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -597,6 +597,7 @@ #define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) #define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. #define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. +#define CODEC_FLAG2_INTRA_REFRESH 0x00200000 ///< Use periodic insertion of intra blocks instead of keyframes. /* Unsupported options : * Syntax Arithmetic coding (SAC) @@ -2646,6 +2647,15 @@ * - decoding: unused */ int rc_lookahead; + + /** + * Constant rate factor maximum + * With CRF encoding mode and VBV restrictions enabled, prevents quality from being worse + * than crf_max, even if doing so would violate VBV restrictions. + * - encoding: Set by user. + * - decoding: unused + */ + float crf_max; } AVCodecContext; /** diff -r 6f5bee041560 -r 2312dfbe9251 libx264.c --- a/libx264.c Thu May 06 20:38:42 2010 +0000 +++ b/libx264.c Thu May 06 22:38:18 2010 +0000 @@ -156,6 +156,7 @@ x4->params.p_log_private = avctx; x4->params.i_keyint_max = avctx->gop_size; + x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; x4->params.rc.i_bitrate = avctx->bit_rate / 1000; x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000; x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000; @@ -166,6 +167,7 @@ if (avctx->crf) { x4->params.rc.i_rc_method = X264_RC_CRF; x4->params.rc.f_rf_constant = avctx->crf; + x4->params.rc.f_rf_constant_max = avctx->crf_max; } else if (avctx->cqp > -1) { x4->params.rc.i_rc_method = X264_RC_CQP; x4->params.rc.i_qp_constant = avctx->cqp; diff -r 6f5bee041560 -r 2312dfbe9251 options.c --- a/options.c Thu May 06 20:38:42 2010 +0000 +++ b/options.c Thu May 06 22:38:18 2010 +0000 @@ -411,6 +411,8 @@ {"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, 1.0, 0, FLT_MAX, V|E}, {"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, 40, 0, INT_MAX, V|E}, {"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_SSIM, INT_MIN, INT_MAX, V|E, "flags2"}, +{"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_REFRESH, INT_MIN, INT_MAX, V|E, "flags2"}, +{"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, DEFAULT, 0, 51, V|E}, {NULL}, };