aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/xan.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-04-17 19:48:54 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2009-04-17 19:48:54 +0000
commitbe50938073df1cce26146384ee9316002921063a (patch)
tree4ce274bd4ba6862149c1229c01b1d6d6a23c7c7b /libavcodec/xan.c
parenta4873f7d9dbf1c77508361e699b431812f6a0ca7 (diff)
downloadffmpeg-be50938073df1cce26146384ee9316002921063a.tar.gz
Simplify xan_huffman_decode by using get_bits
Originally committed as revision 18595 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/xan.c')
-rw-r--r--libavcodec/xan.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
index 8a7ad240ad..99feba0495 100644
--- a/libavcodec/xan.c
+++ b/libavcodec/xan.c
@@ -36,6 +36,8 @@
#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "bytestream.h"
+#define ALT_BITSTREAM_READER_LE
+#include "get_bits.h"
// for av_memcpy_backptr
#include "libavutil/lzo.h"
@@ -93,16 +95,13 @@ static int xan_huffman_decode(unsigned char *dest, const unsigned char *src,
unsigned char ival = byte + 0x16;
const unsigned char * ptr = src + byte*2;
unsigned char val = ival;
- int counter = 0;
unsigned char *dest_end = dest + dest_len;
+ GetBitContext gb;
- unsigned char bits = *ptr++;
+ init_get_bits(&gb, ptr, 0); // FIXME: no src size available
while ( val != 0x16 ) {
- if ( (1 << counter) & bits )
- val = src[byte + val - 0x17];
- else
- val = src[val - 0x17];
+ val = src[val - 0x17 + get_bits1(&gb) * byte];
if ( val < 0x16 ) {
if (dest + 1 > dest_end)
@@ -110,11 +109,6 @@ static int xan_huffman_decode(unsigned char *dest, const unsigned char *src,
*dest++ = val;
val = ival;
}
-
- if (counter++ == 7) {
- counter = 0;
- bits = *ptr++;
- }
}
return 0;