Browse code

Remove reimplementation of get_unary. Based on a patch by Alex Beregszaszi.

Originally committed as revision 10279 to svn://svn.ffmpeg.org/ffmpeg/trunk

Vitor Sessak authored on 2007/09/02 06:03:17
Showing 2 changed files
... ...
@@ -55,6 +55,7 @@
55 55
 #include "avcodec.h"
56 56
 #include "bitstream.h"
57 57
 #include "bytestream.h"
58
+#include "unary.h"
58 59
 
59 60
 #define ALAC_EXTRADATA_SIZE 36
60 61
 #define MAX_CHANNELS 2
... ...
@@ -159,14 +160,12 @@ static void bastardized_rice_decompress(ALACContext *alac,
159 159
     int sign_modifier = 0;
160 160
 
161 161
     for (output_count = 0; output_count < output_size; output_count++) {
162
-        int32_t x = 0;
162
+        int32_t x;
163 163
         int32_t x_modified;
164 164
         int32_t final_val;
165 165
 
166 166
         /* read x - number of 1s before 0 represent the rice */
167
-        while (x <= 8 && get_bits1(&alac->gb)) {
168
-            x++;
169
-        }
167
+        x = get_unary_0_9(&alac->gb);
170 168
 
171 169
         if (x > 8) { /* RICE THRESHOLD */
172 170
             /* use alternative encoding */
... ...
@@ -227,10 +226,7 @@ static void bastardized_rice_decompress(ALACContext *alac,
227 227
 
228 228
             sign_modifier = 1;
229 229
 
230
-            x = 0;
231
-            while (x <= 8 && get_bits1(&alac->gb)) {
232
-                x++;
233
-            }
230
+            x = get_unary_0_9(&alac->gb);
234 231
 
235 232
             if (x > 8) {
236 233
                 block_size = get_bits(&alac->gb, 16);
... ...
@@ -48,4 +48,9 @@ static inline int get_unary_0_33(GetBitContext *gb)
48 48
     return get_unary(gb, 0, 33);
49 49
 }
50 50
 
51
+static inline int get_unary_0_9(GetBitContext *gb)
52
+{
53
+    return get_unary(gb, 0, 9);
54
+}
55
+
51 56
 #endif /* AVCODEC_UNARY_H */