summaryrefslogtreecommitdiff
path: root/apps/codecs/libatrac/atrac3.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libatrac/atrac3.c')
-rw-r--r--apps/codecs/libatrac/atrac3.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c
index 9e61db1686..7f2cb57356 100644
--- a/apps/codecs/libatrac/atrac3.c
+++ b/apps/codecs/libatrac/atrac3.c
@@ -45,7 +45,10 @@
45#define JOINT_STEREO 0x12 45#define JOINT_STEREO 0x12
46#define STEREO 0x2 46#define STEREO 0x2
47 47
48#define AVERROR(...) -1 48#ifdef ROCKBOX
49#undef DEBUGF
50#define DEBUGF(...)
51#endif /* ROCKBOX */
49 52
50/* FFMAX/MIN/SWAP and av_clip were taken from libavutil/common.h */ 53/* FFMAX/MIN/SWAP and av_clip were taken from libavutil/common.h */
51#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) 54#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
@@ -76,7 +79,7 @@ static channel_unit channel_units[2];
76 */ 79 */
77static void iqmf (int32_t *inlo, int32_t *inhi, unsigned int nIn, int32_t *pOut, int32_t *delayBuf, int32_t *temp) 80static void iqmf (int32_t *inlo, int32_t *inhi, unsigned int nIn, int32_t *pOut, int32_t *delayBuf, int32_t *temp)
78{ 81{
79 int i, j; 82 unsigned int i, j;
80 int32_t *p1, *p3; 83 int32_t *p1, *p3;
81 84
82 memcpy(temp, delayBuf, 46*sizeof(int32_t)); 85 memcpy(temp, delayBuf, 46*sizeof(int32_t));
@@ -163,7 +166,7 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){
163 const uint32_t* buf; 166 const uint32_t* buf;
164 uint32_t* obuf = (uint32_t*) out; 167 uint32_t* obuf = (uint32_t*) out;
165 168
166#ifdef TEST 169#if ((defined(TEST) || defined(SIMULATOR)) && !defined(CPU_ARM))
167 off = 0; //no check for memory alignment of inbuffer 170 off = 0; //no check for memory alignment of inbuffer
168#else 171#else
169 off = (intptr_t)inbuffer & 3; 172 off = (intptr_t)inbuffer & 3;
@@ -175,14 +178,16 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){
175 for (i = 0; i < bytes/4; i++) 178 for (i = 0; i < bytes/4; i++)
176 obuf[i] = c ^ buf[i]; 179 obuf[i] = c ^ buf[i];
177 180
178 if (off) 181 if (off) {
179 DEBUGF("Offset of %d not handled, post sample on ffmpeg-dev.\n",off); 182 DEBUGF("Offset of %d not handled, post sample on ffmpeg-dev.\n",off);
183 return off;
184 }
180 185
181 return off; 186 return off;
182} 187}
183 188
184 189
185static void init_atrac3_transforms(ATRAC3Context *q) { 190static void init_atrac3_transforms() {
186 int32_t s; 191 int32_t s;
187 int i; 192 int i;
188 193
@@ -630,7 +635,7 @@ static void channelWeighting (int32_t *su1, int32_t *su2, int *p3)
630 */ 635 */
631 636
632 637
633static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_unit *pSnd, int32_t *pOut, int channelNum, int codingMode) 638static int decodeChannelSoundUnit (GetBitContext *gb, channel_unit *pSnd, int32_t *pOut, int channelNum, int codingMode)
634{ 639{
635 int band, result=0, numSubbands, lastTonal, numBands; 640 int band, result=0, numSubbands, lastTonal, numBands;
636 if (codingMode == JOINT_STEREO && channelNum == 1) { 641 if (codingMode == JOINT_STEREO && channelNum == 1) {
@@ -705,7 +710,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
705 /* decode Sound Unit 1 */ 710 /* decode Sound Unit 1 */
706 init_get_bits(&q->gb,databuf,q->bits_per_frame); 711 init_get_bits(&q->gb,databuf,q->bits_per_frame);
707 712
708 result = decodeChannelSoundUnit(q,&q->gb, q->pUnits, q->outSamples, 0, JOINT_STEREO); 713 result = decodeChannelSoundUnit(&q->gb, q->pUnits, q->outSamples, 0, JOINT_STEREO);
709 if (result != 0) 714 if (result != 0)
710 return (result); 715 return (result);
711 716
@@ -746,7 +751,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
746 } 751 }
747 752
748 /* Decode Sound Unit 2. */ 753 /* Decode Sound Unit 2. */
749 result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[1], &q->outSamples[1024], 1, JOINT_STEREO); 754 result = decodeChannelSoundUnit(&q->gb, &q->pUnits[1], &q->outSamples[1024], 1, JOINT_STEREO);
750 if (result != 0) 755 if (result != 0)
751 return (result); 756 return (result);
752 757
@@ -763,7 +768,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
763 /* Set the bitstream reader at the start of a channel sound unit. */ 768 /* Set the bitstream reader at the start of a channel sound unit. */
764 init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels), (q->bits_per_frame)/q->channels); 769 init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels), (q->bits_per_frame)/q->channels);
765 770
766 result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode); 771 result = decodeChannelSoundUnit(&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode);
767 if (result != 0) 772 if (result != 0)
768 return (result); 773 return (result);
769 } 774 }
@@ -943,7 +948,7 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
943 948
944 } 949 }
945 950
946 init_atrac3_transforms(q); 951 init_atrac3_transforms();
947 952
948 /* init the joint-stereo decoding data */ 953 /* init the joint-stereo decoding data */
949 q->weighting_delay[0] = 0; 954 q->weighting_delay[0] = 0;