Revision 5474ec2a

View differences:

libavcodec/vp56.h
191 191
    c->code_word = bytestream_get_be16(&c->buffer);
192 192
}
193 193

  
194
static av_always_inline void vp56_rac_renorm(VP56RangeCoder *c, unsigned int code_word)
194
static av_always_inline unsigned int vp56_rac_renorm(VP56RangeCoder *c)
195 195
{
196 196
    int shift = ff_h264_norm_shift[c->high] - 1;
197 197
    int bits = c->bits;
198
    unsigned int code_word = c->code_word;
198 199

  
199 200
    c->high   <<= shift;
200 201
    code_word <<= shift;
......
204 205
        bits -= 8;
205 206
    }
206 207
    c->bits = bits;
207
    c->code_word = code_word;
208
    return code_word;
208 209
}
209 210

  
210 211
static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob)
211 212
{
212 213
    /* Don't put c->high in a local variable; if we do that, gcc gets
213 214
     * the stupids and turns the code below into a branch again. */
214
    unsigned int code_word = c->code_word;
215
    unsigned int code_word = vp56_rac_renorm(c);
215 216
    unsigned int low = 1 + (((c->high - 1) * prob) >> 8);
216 217
    unsigned int low_shift = low << 8;
217 218
    int bit = code_word >= low_shift;
......
220 221
     * instead of branches -- faster, as this branch is basically
221 222
     * unpredictable. */
222 223
    c->high = bit ? c->high - low : low;
223
    code_word = bit ? code_word - low_shift : code_word;
224
    c->code_word = bit ? code_word - low_shift : code_word;
224 225

  
225
    vp56_rac_renorm(c, code_word);
226 226
    return bit;
227 227
}
228 228

  
229 229
static inline int vp56_rac_get(VP56RangeCoder *c)
230 230
{
231
    unsigned int code_word = vp56_rac_renorm(c);
231 232
    /* equiprobable */
232 233
    int low = (c->high + 1) >> 1;
233 234
    unsigned int low_shift = low << 8;
234
    int bit = c->code_word >= low_shift;
235
    int bit = code_word >= low_shift;
235 236
    if (bit) {
236
        c->high = (c->high - low) << 1;
237
        c->code_word -= low_shift;
237
        c->high   -= low;
238
        code_word -= low_shift;
238 239
    } else {
239
        c->high = low << 1;
240
        c->high = low;
240 241
    }
241 242

  
242
    /* normalize */
243
    c->code_word <<= 1;
244
    if (++c->bits == 0 && c->buffer < c->end) {
245
        c->bits = -8;
246
        c->code_word |= *c->buffer++;
247
    }
243
    c->code_word = code_word;
248 244
    return bit;
249 245
}
250 246

  

Also available in: Unified diff