Mercurial > libavcodec.hg
comparison bitstream.h @ 5605:d92fa6e5fc8c libavcodec
move get_unary() to its own file
author | aurel |
---|---|
date | Sun, 26 Aug 2007 22:33:48 +0000 |
parents | 28dcc5cd79d2 |
children | 1d83e9c34641 |
comparison
equal
deleted
inserted
replaced
5604:8691652d9dce | 5605:d92fa6e5fc8c |
---|---|
948 return 0; | 948 return 0; |
949 else | 949 else |
950 return get_bits1(gb) + 1; | 950 return get_bits1(gb) + 1; |
951 } | 951 } |
952 | 952 |
953 /** | |
954 * Get unary code of limited length | |
955 * @todo FIXME Slow and ugly | |
956 * @param gb GetBitContext | |
957 * @param[in] stop The bitstop value (unary code of 1's or 0's) | |
958 * @param[in] len Maximum length | |
959 * @return Unary length/index | |
960 */ | |
961 static int get_unary(GetBitContext *gb, int stop, int len) | |
962 { | |
963 #if 1 | |
964 int i; | |
965 | |
966 for(i = 0; i < len && get_bits1(gb) != stop; i++); | |
967 return i; | |
968 /* int i = 0, tmp = !stop; | |
969 | |
970 while (i != len && tmp != stop) | |
971 { | |
972 tmp = get_bits(gb, 1); | |
973 i++; | |
974 } | |
975 if (i == len && tmp != stop) return len+1; | |
976 return i;*/ | |
977 #else | |
978 unsigned int buf; | |
979 int log; | |
980 | |
981 OPEN_READER(re, gb); | |
982 UPDATE_CACHE(re, gb); | |
983 buf=GET_CACHE(re, gb); //Still not sure | |
984 if (stop) buf = ~buf; | |
985 | |
986 log= av_log2(-buf); //FIXME: -? | |
987 if (log < limit){ | |
988 LAST_SKIP_BITS(re, gb, log+1); | |
989 CLOSE_READER(re, gb); | |
990 return log; | |
991 } | |
992 | |
993 LAST_SKIP_BITS(re, gb, limit); | |
994 CLOSE_READER(re, gb); | |
995 return limit; | |
996 #endif | |
997 } | |
998 | |
999 #endif /* BITSTREAM_H */ | 953 #endif /* BITSTREAM_H */ |