summaryrefslogtreecommitdiff
path: root/apps/codecs/libatrac
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2010-02-16 01:47:22 +0000
committerMohamed Tarek <mt@rockbox.org>2010-02-16 01:47:22 +0000
commit2e314093c8b9f594f0baa1a253125e6d87452eae (patch)
tree028870139ae1d63d49d01e5d583eaf0f4fa11a9e /apps/codecs/libatrac
parent419e8aad783de1207d500c63854c29d0b1e343e8 (diff)
downloadrockbox-2e314093c8b9f594f0baa1a253125e6d87452eae.tar.gz
rockbox-2e314093c8b9f594f0baa1a253125e6d87452eae.zip
"Detach" ATRAC3 from RM. Since ATRAC3 isn't really specific to RM, it must not be obligatory to initialize the decoder through RMContext.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24682 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/libatrac')
-rw-r--r--apps/codecs/libatrac/atrac3.c36
-rw-r--r--apps/codecs/libatrac/atrac3.h7
2 files changed, 23 insertions, 20 deletions
diff --git a/apps/codecs/libatrac/atrac3.c b/apps/codecs/libatrac/atrac3.c
index 3c6ecc9197..2f4d44b6af 100644
--- a/apps/codecs/libatrac/atrac3.c
+++ b/apps/codecs/libatrac/atrac3.c
@@ -1074,17 +1074,17 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, int off)
1074 * @param rmctx pointer to the AVCodecContext 1074 * @param rmctx pointer to the AVCodecContext
1075 */ 1075 */
1076 1076
1077int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q, 1077int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q,
1078 int *data_size, const uint8_t *buf, int buf_size) { 1078 int *data_size, const uint8_t *buf, int buf_size) {
1079 int result = 0, off = 0; 1079 int result = 0, off = 0;
1080 const uint8_t* databuf; 1080 const uint8_t* databuf;
1081 1081
1082 if (buf_size < rmctx->block_align) 1082 if (buf_size < block_align)
1083 return buf_size; 1083 return buf_size;
1084 1084
1085 /* Check if we need to descramble and what buffer to pass on. */ 1085 /* Check if we need to descramble and what buffer to pass on. */
1086 if (q->scrambled_stream) { 1086 if (q->scrambled_stream) {
1087 off = decode_bytes(buf, q->decoded_bytes_buffer, rmctx->block_align); 1087 off = decode_bytes(buf, q->decoded_bytes_buffer, block_align);
1088 databuf = q->decoded_bytes_buffer; 1088 databuf = q->decoded_bytes_buffer;
1089 } else { 1089 } else {
1090 databuf = buf; 1090 databuf = buf;
@@ -1102,7 +1102,7 @@ int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q,
1102 else 1102 else
1103 *data_size = 2048 * sizeof(int32_t); 1103 *data_size = 2048 * sizeof(int32_t);
1104 1104
1105 return rmctx->block_align; 1105 return block_align;
1106} 1106}
1107 1107
1108 1108
@@ -1111,23 +1111,23 @@ int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q,
1111 * 1111 *
1112 * @param rmctx pointer to the RMContext 1112 * @param rmctx pointer to the RMContext
1113 */ 1113 */
1114 1114int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
1115int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
1116{ 1115{
1117 int i; 1116 int i;
1118 uint8_t *edata_ptr = rmctx->codec_extradata; 1117 uint8_t *edata_ptr = (uint8_t*)&id3->id3v2buf;
1119 static VLC_TYPE atrac3_vlc_table[4096][2]; 1118 static VLC_TYPE atrac3_vlc_table[4096][2];
1120 static int vlcs_initialized = 0; 1119 static int vlcs_initialized = 0;
1121 1120
1122 /* Take data from the AVCodecContext (RM container). */ 1121 /* Take data from the RM container. */
1123 q->sample_rate = rmctx->sample_rate; 1122 q->sample_rate = id3->frequency;
1124 q->channels = rmctx->nb_channels; 1123 q->channels = id3->channels;
1125 q->bit_rate = rmctx->bit_rate; 1124 q->bit_rate = id3->bitrate * 1000;
1126 q->bits_per_frame = rmctx->block_align * 8; 1125 q->bits_per_frame = id3->bytesperframe * 8;
1127 q->bytes_per_frame = rmctx->block_align; 1126 q->bytes_per_frame = id3->bytesperframe;
1128 1127
1129 /* Take care of the codec-specific extradata. */ 1128 /* Take care of the codec-specific extradata. */
1130 if (rmctx->extradata_size == 14) { 1129
1130 if (id3->extradata_size == 14) {
1131 /* Parse the extradata, WAV format */ 1131 /* Parse the extradata, WAV format */
1132 DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */ 1132 DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */
1133 q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]); 1133 q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]);
@@ -1152,7 +1152,7 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
1152 return -1; 1152 return -1;
1153 } 1153 }
1154 1154
1155 } else if (rmctx->extradata_size == 10) { 1155 } else if (id3->extradata_size == 10) {
1156 /* Parse the extradata, RM format. */ 1156 /* Parse the extradata, RM format. */
1157 q->atrac3version = rm_get_uint32be(&edata_ptr[0]); 1157 q->atrac3version = rm_get_uint32be(&edata_ptr[0]);
1158 q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]); 1158 q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]);
@@ -1163,7 +1163,7 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
1163 q->scrambled_stream = 1; 1163 q->scrambled_stream = 1;
1164 1164
1165 } else { 1165 } else {
1166 DEBUGF("Unknown extradata size %d.\n",rmctx->extradata_size); 1166 DEBUGF("Unknown extradata size %d.\n",id3->extradata_size);
1167 } 1167 }
1168 /* Check the extradata. */ 1168 /* Check the extradata. */
1169 1169
@@ -1191,13 +1191,13 @@ int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx)
1191 return -1; 1191 return -1;
1192 } 1192 }
1193 1193
1194 if (rmctx->nb_channels <= 0 || rmctx->nb_channels > 2 /*|| ((rmctx->channels * 1024) != q->samples_per_frame)*/) { 1194 if (id3->channels <= 0 || id3->channels > 2 ) {
1195 DEBUGF("Channel configuration error!\n"); 1195 DEBUGF("Channel configuration error!\n");
1196 return -1; 1196 return -1;
1197 } 1197 }
1198 1198
1199 1199
1200 if(rmctx->block_align >= UINT16_MAX/2) 1200 if(id3->bytesperframe >= UINT16_MAX/2)
1201 return -1; 1201 return -1;
1202 1202
1203 1203
diff --git a/apps/codecs/libatrac/atrac3.h b/apps/codecs/libatrac/atrac3.h
index 5bed9c60bf..0e31821279 100644
--- a/apps/codecs/libatrac/atrac3.h
+++ b/apps/codecs/libatrac/atrac3.h
@@ -1,5 +1,8 @@
1#include "ffmpeg_bitstream.h" 1#include "ffmpeg_bitstream.h"
2#include "../librm/rm.h" 2#include "../librm/rm.h"
3#ifdef ROCKBOX
4#include "codeclib.h"
5#endif
3 6
4#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250) 7#if (CONFIG_CPU == PP5022) || (CONFIG_CPU == PP5024) || (CONFIG_CPU == MCF5250)
5/* PP5022/24 and MCF5250 have larger IRAM */ 8/* PP5022/24 and MCF5250 have larger IRAM */
@@ -82,8 +85,8 @@ typedef struct {
82 //@} 85 //@}
83} ATRAC3Context; 86} ATRAC3Context;
84 87
85int atrac3_decode_init(ATRAC3Context *q, RMContext *rmctx); 88int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3);
86 89
87int atrac3_decode_frame(RMContext *rmctx, ATRAC3Context *q, 90int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q,
88 int *data_size, const uint8_t *buf, int buf_size); 91 int *data_size, const uint8_t *buf, int buf_size);
89 92