summaryrefslogtreecommitdiff
path: root/apps/codecs/libatrac
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2009-08-14 17:36:57 +0000
committerMohamed Tarek <mt@rockbox.org>2009-08-14 17:36:57 +0000
commit685628cf18f815b1ccc80a84590037960b2b4ec1 (patch)
treeef3f78abb2ff114dda2cc1ce0381194fb7c3288d /apps/codecs/libatrac
parent4f26112b1b50b644c3c3245906c996c16bb0c616 (diff)
downloadrockbox-685628cf18f815b1ccc80a84590037960b2b4ec1.zip
rockbox-685628cf18f815b1ccc80a84590037960b2b4ec1.tar.gz
rockbox-685628cf18f815b1ccc80a84590037960b2b4ec1.tar.bz2
rockbox-685628cf18f815b1ccc80a84590037960b2b4ec1.tar.xz
Support for playback of atrac3 audio in rm, in sim.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22311 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libatrac')
-rw-r--r--apps/codecs/libatrac/SOURCES3
-rw-r--r--apps/codecs/libatrac/atrac3.c25
-rw-r--r--apps/codecs/libatrac/atrac3data.h2
-rw-r--r--apps/codecs/libatrac/libatrac.make18
4 files changed, 37 insertions, 11 deletions
diff --git a/apps/codecs/libatrac/SOURCES b/apps/codecs/libatrac/SOURCES
new file mode 100644
index 0000000..9db9ac3
--- /dev/null
+++ b/apps/codecs/libatrac/SOURCES
@@ -0,0 +1,3 @@
+atrac3.c
+fixp_math.c
+bitstream.c
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c
index 9e61db1..7f2cb57 100644
--- a/apps/codecs/libatrac/atrac3.c
+++ b/apps/codecs/libatrac/atrac3.c
@@ -45,7 +45,10 @@
#define JOINT_STEREO 0x12
#define STEREO 0x2
-#define AVERROR(...) -1
+#ifdef ROCKBOX
+#undef DEBUGF
+#define DEBUGF(...)
+#endif /* ROCKBOX */
/* FFMAX/MIN/SWAP and av_clip were taken from libavutil/common.h */
#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
@@ -76,7 +79,7 @@ static channel_unit channel_units[2];
*/
static void iqmf (int32_t *inlo, int32_t *inhi, unsigned int nIn, int32_t *pOut, int32_t *delayBuf, int32_t *temp)
{
- int i, j;
+ unsigned int i, j;
int32_t *p1, *p3;
memcpy(temp, delayBuf, 46*sizeof(int32_t));
@@ -163,7 +166,7 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){
const uint32_t* buf;
uint32_t* obuf = (uint32_t*) out;
-#ifdef TEST
+#if ((defined(TEST) || defined(SIMULATOR)) && !defined(CPU_ARM))
off = 0; //no check for memory alignment of inbuffer
#else
off = (intptr_t)inbuffer & 3;
@@ -175,14 +178,16 @@ static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){
for (i = 0; i < bytes/4; i++)
obuf[i] = c ^ buf[i];
- if (off)
+ if (off) {
DEBUGF("Offset of %d not handled, post sample on ffmpeg-dev.\n",off);
+ return off;
+ }
return off;
}
-static void init_atrac3_transforms(ATRAC3Context *q) {
+static void init_atrac3_transforms() {
int32_t s;
int i;
@@ -630,7 +635,7 @@ static void channelWeighting (int32_t *su1, int32_t *su2, int *p3)
*/
-static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_unit *pSnd, int32_t *pOut, int channelNum, int codingMode)
+static int decodeChannelSoundUnit (GetBitContext *gb, channel_unit *pSnd, int32_t *pOut, int channelNum, int codingMode)
{
int band, result=0, numSubbands, lastTonal, numBands;
if (codingMode == JOINT_STEREO && channelNum == 1) {
@@ -705,7 +710,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
/* decode Sound Unit 1 */
init_get_bits(&q->gb,databuf,q->bits_per_frame);
- result = decodeChannelSoundUnit(q,&q->gb, q->pUnits, q->outSamples, 0, JOINT_STEREO);
+ result = decodeChannelSoundUnit(&q->gb, q->pUnits, q->outSamples, 0, JOINT_STEREO);
if (result != 0)
return (result);
@@ -746,7 +751,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
}
/* Decode Sound Unit 2. */
- result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[1], &q->outSamples[1024], 1, JOINT_STEREO);
+ result = decodeChannelSoundUnit(&q->gb, &q->pUnits[1], &q->outSamples[1024], 1, JOINT_STEREO);
if (result != 0)
return (result);
@@ -763,7 +768,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf)
/* Set the bitstream reader at the start of a channel sound unit. */
init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels), (q->bits_per_frame)/q->channels);
- result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode);
+ result = decodeChannelSoundUnit(&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode);
if (result != 0)
return (result);
}
@@ -943,7 +948,7 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
}
- init_atrac3_transforms(q);
+ init_atrac3_transforms();
/* init the joint-stereo decoding data */
q->weighting_delay[0] = 0;
diff --git a/apps/codecs/libatrac/atrac3data.h b/apps/codecs/libatrac/atrac3data.h
index e71dc35..8e7fe97 100644
--- a/apps/codecs/libatrac/atrac3data.h
+++ b/apps/codecs/libatrac/atrac3data.h
@@ -28,7 +28,7 @@
#ifndef AVCODEC_ATRAC3DATA_H
#define AVCODEC_ATRAC3DATA_H
-#include <stdint.h>
+#include <inttypes.h>
/* VLC tables */
diff --git a/apps/codecs/libatrac/libatrac.make b/apps/codecs/libatrac/libatrac.make
new file mode 100644
index 0000000..01606e1
--- /dev/null
+++ b/apps/codecs/libatrac/libatrac.make
@@ -0,0 +1,18 @@
+# __________ __ ___.
+# Open \______ \ ____ ____ | | _\_ |__ _______ ___
+# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+# \/ \/ \/ \/ \/
+# $Id: libatrac.make 20151 2009-03-01 09:04:15Z amiconn $
+#
+
+# libatrac
+ATRACLIB := $(CODECDIR)/libatrac.a
+ATRACLIB_SRC := $(call preprocess, $(APPSDIR)/codecs/libatrac/SOURCES)
+ATRACLIB_OBJ := $(call c2obj, $(ATRACLIB_SRC))
+OTHER_SRC += $(ATRACLIB_SRC)
+
+$(ATRACLIB): $(ATRACLIB_OBJ)
+ $(SILENT)$(shell rm -f $@)
+ $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null