comparison vp56.h @ 12029:934968bd410d libavcodec

renormalize VP5/6/7/8 range coder without loop
author stefang
date Wed, 30 Jun 2010 22:05:29 +0000
parents f2007d7c3f1d
children 5578dcdf030c
comparison
equal deleted inserted replaced
12028:2caea98f5711 12029:934968bd410d
26 26
27 #include "vp56data.h" 27 #include "vp56data.h"
28 #include "dsputil.h" 28 #include "dsputil.h"
29 #include "get_bits.h" 29 #include "get_bits.h"
30 #include "bytestream.h" 30 #include "bytestream.h"
31 #include "cabac.h"
31 #include "vp56dsp.h" 32 #include "vp56dsp.h"
32 33
33 typedef struct vp56_context VP56Context; 34 typedef struct vp56_context VP56Context;
34 typedef struct vp56_mv VP56mv; 35 typedef struct vp56_mv VP56mv;
35 36
193 static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) 194 static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
194 { 195 {
195 unsigned int low = 1 + (((c->high - 1) * prob) >> 8); 196 unsigned int low = 1 + (((c->high - 1) * prob) >> 8);
196 unsigned int low_shift = low << 8; 197 unsigned int low_shift = low << 8;
197 int bit = c->code_word >= low_shift; 198 int bit = c->code_word >= low_shift;
199 int shift;
198 200
199 if (bit) { 201 if (bit) {
200 c->high -= low; 202 c->high -= low;
201 c->code_word -= low_shift; 203 c->code_word -= low_shift;
202 } else { 204 } else {
203 c->high = low; 205 c->high = low;
204 } 206 }
205 207
206 /* normalize */ 208 /* normalize */
207 while (c->high < 128) { 209 shift = ff_h264_norm_shift[c->high] - 1;
208 c->high <<= 1; 210 c->high <<= shift;
209 c->code_word <<= 1; 211 c->code_word <<= shift;
210 if (--c->bits == 0 && c->buffer < c->end) { 212 c->bits -= shift;
211 c->bits = 8; 213 if(c->bits <= 0 && c->buffer < c->end) {
212 c->code_word |= *c->buffer++; 214 c->code_word |= *c->buffer++ << -c->bits;
213 } 215 c->bits += 8;
214 } 216 }
215 return bit; 217 return bit;
216 } 218 }
217 219
218 static inline int vp56_rac_get(VP56RangeCoder *c) 220 static inline int vp56_rac_get(VP56RangeCoder *c)