diff options
author | Mohamed Tarek <mt@rockbox.org> | 2009-08-15 14:52:28 +0000 |
---|---|---|
committer | Mohamed Tarek <mt@rockbox.org> | 2009-08-15 14:52:28 +0000 |
commit | bd4fc82b3b97b2b3ba60af02e4cedc6b9ee26b7b (patch) | |
tree | 02cf7dd55cc91259c78ca5c1b3ecb85615239553 | |
parent | 0fe4417da85fc2189b45b712d3a6a7e842300f4c (diff) | |
download | rockbox-bd4fc82b3b97b2b3ba60af02e4cedc6b9ee26b7b.tar.gz rockbox-bd4fc82b3b97b2b3ba60af02e4cedc6b9ee26b7b.zip |
Fix handling of unaligned input buffers in libatrac.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22322 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/libatrac/atrac3.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c index c1648681f5..e134998dfd 100644 --- a/apps/codecs/libatrac/atrac3.c +++ b/apps/codecs/libatrac/atrac3.c | |||
@@ -178,11 +178,6 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ | |||
178 | for (i = 0; i < bytes/4; i++) | 178 | for (i = 0; i < bytes/4; i++) |
179 | obuf[i] = c ^ buf[i]; | 179 | obuf[i] = c ^ buf[i]; |
180 | 180 | ||
181 | if (off) { | ||
182 | DEBUGF("Offset of %d not handled, post sample on ffmpeg-dev.\n",off); | ||
183 | return off; | ||
184 | } | ||
185 | |||
186 | return off; | 181 | return off; |
187 | } | 182 | } |
188 | 183 | ||
@@ -698,7 +693,7 @@ static int decodeChannelSoundUnit (GetBitContext *gb, channel_unit *pSnd, int32_ | |||
698 | * @param databuf the input data | 693 | * @param databuf the input data |
699 | */ | 694 | */ |
700 | 695 | ||
701 | static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf) | 696 | static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, int off) |
702 | { | 697 | { |
703 | int result, i; | 698 | int result, i; |
704 | int32_t *p1, *p2, *p3, *p4; | 699 | int32_t *p1, *p2, *p3, *p4; |
@@ -766,7 +761,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf) | |||
766 | for (i=0 ; i<q->channels ; i++) { | 761 | for (i=0 ; i<q->channels ; i++) { |
767 | 762 | ||
768 | /* Set the bitstream reader at the start of a channel sound unit. */ | 763 | /* Set the bitstream reader at the start of a channel sound unit. */ |
769 | init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels), (q->bits_per_frame)/q->channels); | 764 | init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels)+off, (q->bits_per_frame)/q->channels); |
770 | 765 | ||
771 | result = decodeChannelSoundUnit(&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode); | 766 | result = decodeChannelSoundUnit(&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode); |
772 | if (result != 0) | 767 | if (result != 0) |
@@ -799,7 +794,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf) | |||
799 | int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q, | 794 | int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q, |
800 | void *data, int *data_size, | 795 | void *data, int *data_size, |
801 | const uint8_t *buf, int buf_size) { | 796 | const uint8_t *buf, int buf_size) { |
802 | int result = 0, i; | 797 | int result = 0, off = 0, i; |
803 | const uint8_t* databuf; | 798 | const uint8_t* databuf; |
804 | int16_t* samples = data; | 799 | int16_t* samples = data; |
805 | 800 | ||
@@ -808,13 +803,13 @@ int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q, | |||
808 | 803 | ||
809 | /* Check if we need to descramble and what buffer to pass on. */ | 804 | /* Check if we need to descramble and what buffer to pass on. */ |
810 | if (q->scrambled_stream) { | 805 | if (q->scrambled_stream) { |
811 | decode_bytes(buf, q->decoded_bytes_buffer, rmctx->block_align); | 806 | off = decode_bytes(buf, q->decoded_bytes_buffer, rmctx->block_align); |
812 | databuf = q->decoded_bytes_buffer; | 807 | databuf = q->decoded_bytes_buffer; |
813 | } else { | 808 | } else { |
814 | databuf = buf; | 809 | databuf = buf; |
815 | } | 810 | } |
816 | 811 | ||
817 | result = decodeFrame(q, databuf); | 812 | result = decodeFrame(q, databuf, off); |
818 | 813 | ||
819 | if (result != 0) { | 814 | if (result != 0) { |
820 | DEBUGF("Frame decoding error!\n"); | 815 | DEBUGF("Frame decoding error!\n"); |