changeset 5852:66317285d195 libavcodec

remove a branch from an inner loop. 1% faster flac encoding.
author lorenm
date Sat, 27 Oct 2007 13:39:19 +0000
parents dea3ac1d4c67
children 286738ef0a4e
files flacenc.c
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flacenc.c	Wed Oct 24 20:49:42 2007 +0000
+++ b/flacenc.c	Sat Oct 27 13:39:19 2007 +0000
@@ -474,16 +474,15 @@
     uint32_t all_bits;
 
     part = (1 << porder);
-    all_bits = 0;
+    all_bits = 4 * part;
 
     cnt = (n >> porder) - pred_order;
     for(i=0; i<part; i++) {
-        if(i == 1) cnt = (n >> porder);
         k = find_optimal_param(sums[i], cnt);
         rc->params[i] = k;
         all_bits += rice_encode_count(sums[i], cnt, k);
+        cnt = n >> porder;
     }
-    all_bits += (4 * part);
 
     rc->porder = porder;