[x265] [PATCH] CLI: Fix wrong condition for "--strict-cbr" option

Jean CRUYPENYNCK filaton at me.com
Tue Jan 31 12:40:36 CET 2017


# HG changeset patch
# User Jean Cruypenynck <filaton at me.com>
# Date 1485860877 -3600
#      Tue Jan 31 12:07:57 2017 +0100
# Node ID 93d09ad23a514172f0d143b0a194c607963db57b
# Parent  fa52b516f5ff122c4486ed840c5bf1de3c06e974
[CLI] Fix wrong condition for "--strict-cbr" option

Checking for "--strict-cbr" should succeed if either "--bitrate" or "--vbv-bufsize" is specified.

It means that an error should be thrown if:
    param-rc->bStrictCbr && NOT (param->rc.bitrate > 0 || param->rc.vbvBufferSize > 0)
evaluates to true.

According to De Morgan's laws, it is equivalent to:
    param-rc->bStrictCbr && (NOT param->rc.bitrate > 0 && NOT param->rc.vbvBufferSize > 0)
which is in turn equivalent to:
    param-rc->bStrictCbr && (param->rc.bitrate <= 0 && param->rc.vbvBufferSize <= 0)

Currently, one must set both "--bitrate" AND "--vbv-bufsize" to use "--strict-cbr".

diff -r fa52b516f5ff -r 93d09ad23a51 source/common/param.cpp
--- a/source/common/param.cpp	Mon Jan 30 10:35:00 2017 +0530
+++ b/source/common/param.cpp	Tue Jan 31 12:07:57 2017 +0100
@@ -1269,7 +1269,7 @@
         CHECK(0 > param->noiseReductionInter || param->noiseReductionInter > 2000, "Valid noise reduction range 0 - 2000");
     CHECK(param->rc.rateControlMode == X265_RC_CQP && param->rc.bStatRead,
           "Constant QP is incompatible with 2pass");
-    CHECK(param->rc.bStrictCbr && (param->rc.bitrate <= 0 || param->rc.vbvBufferSize <=0),
+    CHECK(param->rc.bStrictCbr && (param->rc.bitrate <= 0 && param->rc.vbvBufferSize <=0),
           "Strict-cbr cannot be applied without specifying target bitrate or vbv bufsize");
     CHECK(param->analysisMode && (param->analysisMode < X265_ANALYSIS_OFF || param->analysisMode > X265_ANALYSIS_LOAD),
         "Invalid analysis mode. Analysis mode 0: OFF 1: SAVE : 2 LOAD");


More information about the x265-devel mailing list