Revision 971e878d libavcodec/bitstream.h

View differences:

libavcodec/bitstream.h
969 969
        return get_bits1(gb) + 1;
970 970
}
971 971

  
972
/**
973
 * Get unary code of limited length
974
 * @todo FIXME Slow and ugly
975
 * @param gb GetBitContext
976
 * @param[in] stop The bitstop value (unary code of 1's or 0's)
977
 * @param[in] len Maximum length
978
 * @return Unary length/index
979
 */
980
static int get_unary(GetBitContext *gb, int stop, int len)
981
{
982
#if 1
983
    int i;
984

  
985
    for(i = 0; i < len && get_bits1(gb) != stop; i++);
986
    return i;
987
/*  int i = 0, tmp = !stop;
988

  
989
  while (i != len && tmp != stop)
990
  {
991
    tmp = get_bits(gb, 1);
992
    i++;
993
  }
994
  if (i == len && tmp != stop) return len+1;
995
  return i;*/
996
#else
997
  unsigned int buf;
998
  int log;
999

  
1000
  OPEN_READER(re, gb);
1001
  UPDATE_CACHE(re, gb);
1002
  buf=GET_CACHE(re, gb); //Still not sure
1003
  if (stop) buf = ~buf;
1004

  
1005
  log= av_log2(-buf); //FIXME: -?
1006
  if (log < limit){
1007
    LAST_SKIP_BITS(re, gb, log+1);
1008
    CLOSE_READER(re, gb);
1009
    return log;
1010
  }
1011

  
1012
  LAST_SKIP_BITS(re, gb, limit);
1013
  CLOSE_READER(re, gb);
1014
  return limit;
1015
#endif
1016
}
1017

  
972 1018
#endif /* BITSTREAM_H */

Also available in: Unified diff