diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 59a5b1faeed041a06b71d17fcea1f92c2c869f2d..37e373f1ef1e809386f94ced8dee555a88048a35 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -6164,14 +6164,14 @@ static int decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n
             if( coeff_abs >= 15 ) {
                 int j = 0;
                 while( get_cabac_bypass( &h->cabac ) ) {
-                    coeff_abs += 1 << j;
                     j++;
                 }
 
+                coeff_abs=1;
                 while( j-- ) {
-                    if( get_cabac_bypass( &h->cabac ) )
-                        coeff_abs += 1 << j ;
+                    coeff_abs += coeff_abs + get_cabac_bypass( &h->cabac );
                 }
+                coeff_abs+= 14;
             }
 
             if( !qmul ) {