Commit 1c774e93 authored by Fiona Glaser's avatar Fiona Glaser
Browse files

Remove unpredictable branch in CABAC dqp

parent f3a7517c
......@@ -167,7 +167,12 @@ static void x264_cabac_qp_delta( x264_t *h, x264_cabac_t *cb )
if( i_dqp != 0 )
{
int val = i_dqp <= 0 ? (-2*i_dqp) : (2*i_dqp - 1);
/* Faster than (i_dqp <= 0 ? (-2*i_dqp) : (2*i_dqp-1)).
* If you so much as sneeze on these lines, gcc will compile this suboptimally. */
i_dqp *= 2;
int val = 1 - i_dqp;
if( val < 0 ) val = i_dqp;
val--;
/* dqp is interpreted modulo (QP_MAX_SPEC+1) */
if( val >= QP_MAX_SPEC && val != QP_MAX_SPEC+1 )
val = 2*QP_MAX_SPEC+1 - val;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment