Revision 3b636f21 libavcodec/vp56.h

View differences:

libavcodec/vp56.h
237 237
    return bit;
238 238
}
239 239

  
240
// rounding is different than vp56_rac_get, is vp56_rac_get wrong?
241
static inline int vp8_rac_get(VP56RangeCoder *c)
242
{
243
    return vp56_rac_get_prob(c, 128);
244
}
245

  
240 246
static inline int vp56_rac_gets(VP56RangeCoder *c, int bits)
241 247
{
242 248
    int value = 0;
......
248 254
    return value;
249 255
}
250 256

  
257
static inline int vp8_rac_get_uint(VP56RangeCoder *c, int bits)
258
{
259
    int value = 0;
260

  
261
    while (bits--) {
262
        value = (value << 1) | vp8_rac_get(c);
263
    }
264

  
265
    return value;
266
}
267

  
268
// fixme: add 1 bit to all the calls to this?
269
static inline int vp8_rac_get_sint(VP56RangeCoder *c, int bits)
270
{
271
    int v;
272

  
273
    if (!vp8_rac_get(c))
274
        return 0;
275

  
276
    v = vp8_rac_get_uint(c, bits);
277

  
278
    if (vp8_rac_get(c))
279
        v = -v;
280

  
281
    return v;
282
}
283

  
284
// P(7)
251 285
static inline int vp56_rac_gets_nn(VP56RangeCoder *c, int bits)
252 286
{
253 287
    int v = vp56_rac_gets(c, 7) << 1;
254 288
    return v + !v;
255 289
}
256 290

  
291
static inline int vp8_rac_get_nn(VP56RangeCoder *c)
292
{
293
    int v = vp8_rac_get_uint(c, 7) << 1;
294
    return v + !v;
295
}
296

  
257 297
static inline int vp56_rac_get_tree(VP56RangeCoder *c,
258 298
                                    const VP56Tree *tree,
259 299
                                    const uint8_t *probs)
......
267 307
    return -tree->val;
268 308
}
269 309

  
310
/**
311
 * This is identical to vp8_rac_get_tree except for the possibility of starting
312
 * on a node other than the root node, needed for coeff decode where this is
313
 * used to save a bit after a 0 token (by disallowing EOB to immediately follow.)
314
 */
315
static inline int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2],
316
                                               const uint8_t *probs, int i)
317
{
318
    do {
319
        i = tree[i][vp56_rac_get_prob(c, probs[i])];
320
    } while (i > 0);
321

  
322
    return -i;
323
}
324

  
325
// how probabilities are associated with decisions is different I think
326
// well, the new scheme fits in the old but this way has one fewer branches per decision
327
static inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2],
328
                                   const uint8_t *probs)
329
{
330
    return vp8_rac_get_tree_with_offset(c, tree, probs, 0);
331
}
332

  
333
// DCTextra
334
static inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob)
335
{
336
    int v = 0;
337

  
338
    do {
339
        v = (v<<1) + vp56_rac_get_prob(c, *prob++);
340
    } while (*prob);
341

  
342
    return v;
343
}
344

  
270 345
#endif /* AVCODEC_VP56_H */

Also available in: Unified diff