diff options
Diffstat (limited to 'apps/codecs/libatrac')
-rw-r--r-- | apps/codecs/libatrac/SOURCES | 3 | ||||
-rw-r--r-- | apps/codecs/libatrac/atrac3.c | 25 | ||||
-rw-r--r-- | apps/codecs/libatrac/atrac3data.h | 2 | ||||
-rw-r--r-- | apps/codecs/libatrac/libatrac.make | 18 |
4 files changed, 37 insertions, 11 deletions
diff --git a/apps/codecs/libatrac/SOURCES b/apps/codecs/libatrac/SOURCES new file mode 100644 index 0000000000..9db9ac3dab --- /dev/null +++ b/apps/codecs/libatrac/SOURCES | |||
@@ -0,0 +1,3 @@ | |||
1 | atrac3.c | ||
2 | fixp_math.c | ||
3 | bitstream.c | ||
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 | */ |
77 | static void iqmf (int32_t *inlo, int32_t *inhi, unsigned int nIn, int32_t *pOut, int32_t *delayBuf, int32_t *temp) | 80 | static 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 | ||
185 | static void init_atrac3_transforms(ATRAC3Context *q) { | 190 | static 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 | ||
633 | static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_unit *pSnd, int32_t *pOut, int channelNum, int codingMode) | 638 | static 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; |
diff --git a/apps/codecs/libatrac/atrac3data.h b/apps/codecs/libatrac/atrac3data.h index e71dc35560..8e7fe97c32 100644 --- a/apps/codecs/libatrac/atrac3data.h +++ b/apps/codecs/libatrac/atrac3data.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #ifndef AVCODEC_ATRAC3DATA_H | 28 | #ifndef AVCODEC_ATRAC3DATA_H |
29 | #define AVCODEC_ATRAC3DATA_H | 29 | #define AVCODEC_ATRAC3DATA_H |
30 | 30 | ||
31 | #include <stdint.h> | 31 | #include <inttypes.h> |
32 | 32 | ||
33 | /* VLC tables */ | 33 | /* VLC tables */ |
34 | 34 | ||
diff --git a/apps/codecs/libatrac/libatrac.make b/apps/codecs/libatrac/libatrac.make new file mode 100644 index 0000000000..01606e1f15 --- /dev/null +++ b/apps/codecs/libatrac/libatrac.make | |||
@@ -0,0 +1,18 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id: libatrac.make 20151 2009-03-01 09:04:15Z amiconn $ | ||
8 | # | ||
9 | |||
10 | # libatrac | ||
11 | ATRACLIB := $(CODECDIR)/libatrac.a | ||
12 | ATRACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libatrac/SOURCES) | ||
13 | ATRACLIB_OBJ := $(call c2obj, $(ATRACLIB_SRC)) | ||
14 | OTHER_SRC += $(ATRACLIB_SRC) | ||
15 | |||
16 | $(ATRACLIB): $(ATRACLIB_OBJ) | ||
17 | $(SILENT)$(shell rm -f $@) | ||
18 | $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null | ||