diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-04-17 19:03:43 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2009-04-17 19:03:43 +0000 |
commit | c644665f42d12bd84c414b52f2d32833b14d2196 (patch) | |
tree | ef176fc75daff874e70f6993d4076de587776062 /libavcodec/xan.c | |
parent | 455fdd2f8c7be5de2f8f75601f115eb0bb4570fd (diff) | |
download | ffmpeg-streaming-c644665f42d12bd84c414b52f2d32833b14d2196.zip ffmpeg-streaming-c644665f42d12bd84c414b52f2d32833b14d2196.tar.gz |
Some more simplifications of xan_unpack
Originally committed as revision 18588 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/xan.c')
-rw-r--r-- | libavcodec/xan.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/libavcodec/xan.c b/libavcodec/xan.c index d4fc1f7..f1e343e 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -35,6 +35,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "bytestream.h" // for av_memcpy_backptr #include "libavutil/lzo.h" @@ -128,8 +129,6 @@ static void xan_unpack(unsigned char *dest, const unsigned char *src, int dest_l { unsigned char opcode; int size; - int offset; - int byte1, byte2, byte3; unsigned char *dest_end = dest + dest_len; while (dest < dest_end) { @@ -139,33 +138,24 @@ static void xan_unpack(unsigned char *dest, const unsigned char *src, int dest_l int size2, back; if ( (opcode & 0x80) == 0 ) { - offset = *src++; - size = opcode & 3; size2 = ((opcode & 0x1c) >> 2) + 3; - back = ((opcode & 0x60) << 3) + offset + 1; + back = ((opcode & 0x60) << 3) + *src++ + 1; } else if ( (opcode & 0x40) == 0 ) { - byte1 = *src++; - byte2 = *src++; - - size = byte1 >> 6; + size = *src >> 6; size2 = (opcode & 0x3f) + 4; - back = ((byte1 & 0x3f) << 8) + byte2 + 1; + back = (bytestream_get_be16(&src) & 0x3fff) + 1; } else { - byte1 = *src++; - byte2 = *src++; - byte3 = *src++; - size = opcode & 3; - size2 = byte3 + 5 + ((opcode & 0xc) << 6); - back = ((opcode & 0x10) << 12) + 1 + (byte1 << 8) + byte2; + back = ((opcode & 0x10) << 12) + 1 + bytestream_get_be16(&src); + size2 = *src++ + 5 + ((opcode & 0xc) << 6); if (dest >= dest_end || size > dest_end - dest) return; } |