[x264-devel] [PATCH 14/29] param: Modify default qp parameters to maximum allowable

Vittorio Giovara vittorio.giovara at gmail.com
Mon Feb 13 17:41:56 CET 2017


On Fri, Feb 10, 2017 at 4:42 PM, Henrik Gramner <henrik at gramner.com> wrote:
> On Fri, Feb 10, 2017 at 10:18 PM, Vittorio Giovara
> <vittorio.giovara at gmail.com> wrote:
>> -    param->rc.i_qp_constant = 23 + QP_BD_OFFSET;
>> +    param->rc.i_qp_constant = INT_MAX;
>
> This would be perhaps be better off with an invalid default (-1?) in
> combination with an explicit check added in validate_parameters to
> force anyone using constant qp to explicitly set a value.

ok, I squashed this diff below to the current patch

--------->8----------
diff --git a/common/param.c b/common/param.c
index 1c35d5e..f905aee 100644
--- a/common/param.c
+++ b/common/param.c
@@ -95,7 +95,7 @@ void x264_param_default( x264_param_t *param )
     param->rc.i_vbv_max_bitrate = 0;
     param->rc.i_vbv_buffer_size = 0;
     param->rc.f_vbv_buffer_init = 0.9;
-    param->rc.i_qp_constant = INT_MAX;
+    param->rc.i_qp_constant = -1;
     param->rc.f_rf_constant = 23;
     param->rc.i_qp_min = 0;
     param->rc.i_qp_max = INT_MAX;
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 935f137..826af06 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -828,7 +828,7 @@ static int validate_parameters( x264_t *h, int b_open )

     h->param.rc.f_rf_constant = x264_clip3f(
h->param.rc.f_rf_constant, -QP_BD_OFFSET, 51 );
     h->param.rc.f_rf_constant_max = x264_clip3f(
h->param.rc.f_rf_constant_max, -QP_BD_OFFSET, 51 );
-    h->param.rc.i_qp_constant = x264_clip3(
h->param.rc.i_qp_constant, 0, QP_MAX );
+    h->param.rc.i_qp_constant = x264_clip3(
h->param.rc.i_qp_constant, -1, QP_MAX );
     h->param.analyse.i_subpel_refine = x264_clip3(
h->param.analyse.i_subpel_refine, 0, 11 );
     h->param.rc.f_ip_factor = X264_MAX( h->param.rc.f_ip_factor, 0.01f );
     h->param.rc.f_pb_factor = X264_MAX( h->param.rc.f_pb_factor, 0.01f );
@@ -865,6 +865,13 @@ static int validate_parameters( x264_t *h, int b_open )
         float qp_p = h->param.rc.i_qp_constant;
         float qp_i = qp_p - 6*log2f( h->param.rc.f_ip_factor );
         float qp_b = qp_p + 6*log2f( h->param.rc.f_pb_factor );
+
+        if( qp_p == -1 )
+        {
+            x264_log( h, X264_LOG_ERROR, "qp not specified\n" );
+            return -1;
+        }
+
         h->param.rc.i_qp_min = x264_clip3( (int)(X264_MIN3( qp_p,
qp_i, qp_b )), 0, QP_MAX );
         h->param.rc.i_qp_max = x264_clip3( (int)(X264_MAX3( qp_p,
qp_i, qp_b ) + .999), 0, QP_MAX );
         h->param.rc.i_aq_mode = 0;



-- 
Vittorio


More information about the x264-devel mailing list