comparison wavpack.c @ 5510:37bf17e052fb libavcodec

use get_unary from bitstream.h
author alex
date Wed, 08 Aug 2007 22:36:12 +0000
parents bba203d5c5e7
children 33a32de3c1bc
comparison
equal deleted inserted replaced
5509:9fce88cf7f94 5510:37bf17e052fb
112 val >>= 8; 112 val >>= 8;
113 res = (val > 9) ? (res << (val - 9)) : (res >> (9 - val)); 113 res = (val > 9) ? (res << (val - 9)) : (res >> (9 - val));
114 return neg ? -res : res; 114 return neg ? -res : res;
115 } 115 }
116 116
117 static inline int get_unary(GetBitContext *gb){
118 int r=0;
119 while(get_bits1(gb) && r<33)r++;
120 return r;
121 }
122
123 // macros for manipulating median values 117 // macros for manipulating median values
124 #define GET_MED(n) ((median[n] >> 4) + 1) 118 #define GET_MED(n) ((median[n] >> 4) + 1)
125 #define DEC_MED(n) median[n] -= ((median[n] + (128>>n) - 2) / (128>>n)) * 2 119 #define DEC_MED(n) median[n] -= ((median[n] + (128>>n) - 2) / (128>>n)) * 2
126 #define INC_MED(n) median[n] += ((median[n] + (128>>n)) / (128>>n)) * 5 120 #define INC_MED(n) median[n] += ((median[n] + (128>>n)) / (128>>n)) * 5
127 121
163 if(ctx->zeroes){ 157 if(ctx->zeroes){
164 ctx->zeroes--; 158 ctx->zeroes--;
165 if(ctx->zeroes) 159 if(ctx->zeroes)
166 return 0; 160 return 0;
167 }else{ 161 }else{
168 t = get_unary(gb); 162 t = get_unary(gb, 0, 33);
169 if(t >= 2) t = get_bits(gb, t - 1) | (1 << (t-1)); 163 if(t >= 2) t = get_bits(gb, t - 1) | (1 << (t-1));
170 ctx->zeroes = t; 164 ctx->zeroes = t;
171 if(ctx->zeroes){ 165 if(ctx->zeroes){
172 memset(ctx->median, 0, sizeof(ctx->median)); 166 memset(ctx->median, 0, sizeof(ctx->median));
173 return 0; 167 return 0;
182 176
183 if(ctx->zero){ 177 if(ctx->zero){
184 t = 0; 178 t = 0;
185 ctx->zero = 0; 179 ctx->zero = 0;
186 }else{ 180 }else{
187 t = get_unary(gb); 181 t = get_unary(gb, 0, 33);
188 if(get_bits_count(gb) >= ctx->data_size){ 182 if(get_bits_count(gb) >= ctx->data_size){
189 *last = 1; 183 *last = 1;
190 return 0; 184 return 0;
191 } 185 }
192 if(t == 16) { 186 if(t == 16) {
193 t2 = get_unary(gb); 187 t2 = get_unary(gb, 0, 33);
194 if(t2 < 2) t += t2; 188 if(t2 < 2) t += t2;
195 else t += get_bits(gb, t2 - 1) | (1 << (t2 - 1)); 189 else t += get_bits(gb, t2 - 1) | (1 << (t2 - 1));
196 } 190 }
197 191
198 if(ctx->one){ 192 if(ctx->one){