Revision 2407a7c1 libavcodec/unary.h

View differences:

libavcodec/unary.h
25 25

  
26 26
/**
27 27
 * Get unary code of limited length
28
 * @todo FIXME Slow and ugly
29 28
 * @param gb GetBitContext
30 29
 * @param[in] stop The bitstop value (unary code of 1's or 0's)
31 30
 * @param[in] len Maximum length
32 31
 * @return Unary length/index
33 32
 */
34
static int get_unary(GetBitContext *gb, int stop, int len)
33
static inline int get_unary(GetBitContext *gb, int stop, int len)
35 34
{
36
#if 1
37 35
    int i;
38 36

  
39 37
    for(i = 0; i < len && get_bits1(gb) != stop; i++);
40 38
    return i;
41
/*  int i = 0, tmp = !stop;
42

  
43
  while (i != len && tmp != stop)
44
  {
45
    tmp = get_bits(gb, 1);
46
    i++;
47
  }
48
  if (i == len && tmp != stop) return len+1;
49
  return i;*/
50
#else
51
  unsigned int buf;
52
  int log;
53

  
54
  OPEN_READER(re, gb);
55
  UPDATE_CACHE(re, gb);
56
  buf=GET_CACHE(re, gb); //Still not sure
57
  if (stop) buf = ~buf;
58

  
59
  log= av_log2(-buf); //FIXME: -?
60
  if (log < limit){
61
    LAST_SKIP_BITS(re, gb, log+1);
62
    CLOSE_READER(re, gb);
63
    return log;
64
  }
65

  
66
  LAST_SKIP_BITS(re, gb, limit);
67
  CLOSE_READER(re, gb);
68
  return limit;
69
#endif
70 39
}
71 40

  
72 41
#endif /* AVCODEC_UNARY_H */

Also available in: Unified diff