summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2008-05-10 16:02:38 +0000
committerDiego Biurrun <diego@biurrun.de>2008-05-10 16:02:38 +0000
commit57ecbbbb1e2a85fedb8d7405654f7430db034543 (patch)
treedb4cdee21afc06bde394b72972f5723e0368515b /libavcodec
parent47eb818713c9894935cd11badb9b639c87872bbd (diff)
downloadffmpeg-streaming-57ecbbbb1e2a85fedb8d7405654f7430db034543.zip
ffmpeg-streaming-57ecbbbb1e2a85fedb8d7405654f7430db034543.tar.gz
Rewrite unpack_input() completely, patch by Vitor Sessak, vitor1001 gmail com.
Originally committed as revision 13106 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ra144.c68
1 files changed, 20 insertions, 48 deletions
diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c
index 31f34c4..5ce6235 100644
--- a/libavcodec/ra144.c
+++ b/libavcodec/ra144.c
@@ -20,6 +20,7 @@
*/
#include "avcodec.h"
+#include "bitstream.h"
#include "ra144.h"
#define DATABLOCK1 20 /* size of 14.4 input block in bytes */
@@ -293,54 +294,25 @@ static void final(Real144_internal *glob, short *i1, short *i2, void *out,
/* Decode 20-byte input */
static void unpack_input(const unsigned char *input, unsigned int *output)
{
- unsigned int outbuffer[28];
- unsigned short inbuffer[10];
- unsigned int x;
- unsigned int *ptr;
-
- /* fix endianness */
- for (x=0; x<20; x+=2)
- inbuffer[x/2] = (input[x] << 8) + input[x+1];
-
- /* unpack */
- ptr=outbuffer;
- *(ptr++) = 27;
- *(ptr++) = (inbuffer[0] >> 10) & 0x3f;
- *(ptr++) = (inbuffer[0] >> 5) & 0x1f;
- *(ptr++) = inbuffer[0] & 0x1f;
- *(ptr++) = (inbuffer[1] >> 12) & 0xf;
- *(ptr++) = (inbuffer[1] >> 8) & 0xf;
- *(ptr++) = (inbuffer[1] >> 5) & 7;
- *(ptr++) = (inbuffer[1] >> 2) & 7;
- *(ptr++) = ((inbuffer[1] << 1) & 6) | ((inbuffer[2] >> 15) & 1);
- *(ptr++) = (inbuffer[2] >> 12) & 7;
- *(ptr++) = (inbuffer[2] >> 10) & 3;
- *(ptr++) = (inbuffer[2] >> 5) & 0x1f;
- *(ptr++) = ((inbuffer[2] << 2) & 0x7c) | ((inbuffer[3] >> 14) & 3);
- *(ptr++) = (inbuffer[3] >> 6) & 0xff;
- *(ptr++) = ((inbuffer[3] << 1) & 0x7e) | ((inbuffer[4] >> 15) & 1);
- *(ptr++) = (inbuffer[4] >> 8) & 0x7f;
- *(ptr++) = (inbuffer[4] >> 1) & 0x7f;
- *(ptr++) = ((inbuffer[4] << 7) & 0x80) | ((inbuffer[5] >> 9) & 0x7f);
- *(ptr++) = (inbuffer[5] >> 2) & 0x7f;
- *(ptr++) = ((inbuffer[5] << 5) & 0x60) | ((inbuffer[6] >> 11) & 0x1f);
- *(ptr++) = (inbuffer[6] >> 4) & 0x7f;
- *(ptr++) = ((inbuffer[6] << 4) & 0xf0) | ((inbuffer[7] >> 12) & 0xf);
- *(ptr++) = (inbuffer[7] >> 5) & 0x7f;
- *(ptr++) = ((inbuffer[7] << 2) & 0x7c) | ((inbuffer[8] >> 14) & 3);
- *(ptr++) = (inbuffer[8] >> 7) & 0x7f;
- *(ptr++) = ((inbuffer[8] << 1) & 0xfe) | ((inbuffer[9] >> 15) & 1);
- *(ptr++) = (inbuffer[9] >> 8) & 0x7f;
- *(ptr++) = (inbuffer[9] >> 1) & 0x7f;
-
- *(output++) = outbuffer[11];
- for (x=1; x<11; *(output++) = outbuffer[x++]);
- ptr = outbuffer+12;
- for (x=0; x<16; x+=4) {
- *(output++) = ptr[x];
- *(output++) = ptr[x+2];
- *(output++) = ptr[x+3];
- *(output++) = ptr[x+1];
+ int i;
+ static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2};
+
+ GetBitContext gb;
+
+ init_get_bits(&gb, input, 20 * 8);
+
+ for (i=0; i<10; i++)
+ output[i+1] = get_bits(&gb, sizes[i]);
+
+ output[0] = get_bits(&gb, 5);
+
+ output += 11;
+ for (i=0; i<4; i++) {
+ output[0] = get_bits(&gb, 7);
+ output[3] = get_bits(&gb, 8);
+ output[1] = get_bits(&gb, 7);
+ output[2] = get_bits(&gb, 7);
+ output += 4;
}
}
OpenPOWER on IntegriCloud