[FFmpeg-cvslog] libx264: add 'crf_max' private option.

Anton Khirnov git at videolan.org
Wed Aug 24 20:34:18 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Aug 22 07:55:34 2011 +0200| [4ae30cac228e0987faa528e7e6305a52712b5ad9] | committer: Anton Khirnov

libx264: add 'crf_max' private option.

Deprecate corresponding global option.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ae30cac228e0987faa528e7e6305a52712b5ad9
---

 libavcodec/avcodec.h |    4 ++--
 libavcodec/libx264.c |    5 +++++
 libavcodec/options.c |    2 ++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 414b150..c0dcae5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2764,7 +2764,6 @@ typedef struct AVCodecContext {
      * - decoding: unused
      */
     attribute_deprecated int rc_lookahead;
-#endif
 
     /**
      * Constant rate factor maximum
@@ -2773,7 +2772,8 @@ typedef struct AVCodecContext {
      * - encoding: Set by user.
      * - decoding: unused
      */
-    float crf_max;
+    attribute_deprecated float crf_max;
+#endif
 
     int log_level_offset;
 
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 435f228..ebbb217 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -42,6 +42,7 @@ typedef struct X264Context {
     char *profile;
     int fastfirstpass;
     float crf;
+    float crf_max;
     int cqp;
     int aq_mode;
     float aq_strength;
@@ -294,6 +295,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
             x4->params.rc.i_rc_method   = X264_RC_CQP;
             x4->params.rc.i_qp_constant = x4->cqp;
         }
+
+        if (x4->crf_max >= 0)
+            x4->params.rc.f_rf_constant_max = x4->crf_max;
     }
 
     if (avctx->rc_buffer_size && avctx->rc_initial_buffer_occupancy &&
@@ -410,6 +414,7 @@ static const AVOption options[] = {
     { "profile",       "Set profile restrictions (cf. x264 --fullhelp) ", OFFSET(profile),       FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
     { "fastfirstpass", "Use fast settings when encoding first pass",      OFFSET(fastfirstpass), FF_OPT_TYPE_INT,    { 1 }, 0, 1, VE},
     { "crf",           "Select the quality for constant quality mode",    OFFSET(crf),           FF_OPT_TYPE_FLOAT,  {-1 }, -1, FLT_MAX, VE },
+    { "crf_max",       "In CRF mode, prevents VBV from lowering quality beyond this point.",OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE },
     { "cqp",           "Constant quantization parameter rate control method",OFFSET(cqp),        FF_OPT_TYPE_INT,    {-1 }, -1, INT_MAX, VE },
     { "aq_mode",       "AQ method",                                       OFFSET(aq_mode),       FF_OPT_TYPE_INT,    {-1 }, -1, INT_MAX, VE, "aq_mode"},
     { "none",          NULL,                              0, FF_OPT_TYPE_CONST, {X264_AQ_NONE},         INT_MIN, INT_MAX, VE, "aq_mode" },
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 6d40ef0..784d3b1 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -448,7 +448,9 @@ static const AVOption options[]={
 #endif
 {"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, {.dbl = 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, {.dbl = CODEC_FLAG2_INTRA_REFRESH }, INT_MIN, INT_MAX, V|E, "flags2"},
+#if FF_API_X264_GLOBAL_OPTS
 {"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E},
+#endif
 {"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX },
 #if FF_API_FLAC_GLOBAL_OPTS
 {"lpc_type", "deprecated, use flac-specific options", OFFSET(lpc_type), FF_OPT_TYPE_INT, {.dbl = AV_LPC_TYPE_DEFAULT }, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E},



More information about the ffmpeg-cvslog mailing list