summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs')
-rw-r--r--lib/rbcodec/codecs/atrac3_oma.c11
-rw-r--r--lib/rbcodec/codecs/atrac3_rm.c3
-rw-r--r--lib/rbcodec/codecs/libatrac/atrac3.c12
-rw-r--r--lib/rbcodec/codecs/libatrac/atrac3.h2
4 files changed, 15 insertions, 13 deletions
diff --git a/lib/rbcodec/codecs/atrac3_oma.c b/lib/rbcodec/codecs/atrac3_oma.c
index d394fffdcb..2b212ad5f8 100644
--- a/lib/rbcodec/codecs/atrac3_oma.c
+++ b/lib/rbcodec/codecs/atrac3_oma.c
@@ -23,7 +23,6 @@
23 23
24#include "logf.h" 24#include "logf.h"
25#include "codeclib.h" 25#include "codeclib.h"
26#include "inttypes.h"
27#include "libatrac/atrac3.h" 26#include "libatrac/atrac3.h"
28 27
29CODEC_HEADER 28CODEC_HEADER
@@ -66,12 +65,16 @@ enum codec_status codec_run(void)
66 65
67 ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); 66 ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency);
68 ci->configure(DSP_SET_SAMPLE_DEPTH, 17); /* Remark: atrac3 uses s15.0 by default, s15.2 was hacked. */ 67 ci->configure(DSP_SET_SAMPLE_DEPTH, 17); /* Remark: atrac3 uses s15.0 by default, s15.2 was hacked. */
69 ci->configure(DSP_SET_STEREO_MODE, ci->id3->channels == 1 ? 68 const uint8_t channels = 2;
69 ci->configure(DSP_SET_STEREO_MODE, channels == 1 ?
70 STEREO_MONO : STEREO_NONINTERLEAVED); 70 STEREO_MONO : STEREO_NONINTERLEAVED);
71 71
72 ci->seek_buffer(0); 72 ci->seek_buffer(0);
73 73
74 res = atrac3_decode_init(&q, ci->id3); 74 /* fake the atrac3 extradata (wav format, makes stream copy to wav work) */
75 /* ATRAC3 expects and extra-data size of 14 bytes for wav format, and *
76 * looks for that in the id3v2buf. */
77 res = atrac3_decode_init(&q, ci->id3, channels, 14);
75 if(res < 0) { 78 if(res < 0) {
76 DEBUGF("failed to initialize OMA atrac decoder\n"); 79 DEBUGF("failed to initialize OMA atrac decoder\n");
77 return CODEC_ERROR; 80 return CODEC_ERROR;
@@ -143,7 +146,7 @@ enum codec_status codec_run(void)
143 146
144 if(datasize) 147 if(datasize)
145 ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024, 148 ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024,
146 q.samples_per_frame / ci->id3->channels); 149 q.samples_per_frame / channels);
147 150
148 elapsed += (FRAMESIZE * 8) / BITRATE; 151 elapsed += (FRAMESIZE * 8) / BITRATE;
149 ci->set_elapsed(elapsed); 152 ci->set_elapsed(elapsed);
diff --git a/lib/rbcodec/codecs/atrac3_rm.c b/lib/rbcodec/codecs/atrac3_rm.c
index af38b79fc4..b365dac926 100644
--- a/lib/rbcodec/codecs/atrac3_rm.c
+++ b/lib/rbcodec/codecs/atrac3_rm.c
@@ -22,7 +22,6 @@
22#include <string.h> 22#include <string.h>
23 23
24#include "codeclib.h" 24#include "codeclib.h"
25#include "inttypes.h"
26#include "libatrac/atrac3.h" 25#include "libatrac/atrac3.h"
27 26
28CODEC_HEADER 27CODEC_HEADER
@@ -109,7 +108,7 @@ enum codec_status codec_run(void)
109 scrambling_unit_size = h * (fs + packet_header_size); 108 scrambling_unit_size = h * (fs + packet_header_size);
110 spn = h * fs / sps; 109 spn = h * fs / sps;
111 110
112 res = atrac3_decode_init(&q, ci->id3); 111 res = atrac3_decode_init(&q, ci->id3, rmctx.nb_channels, rmctx.extradata_size);
113 if(res < 0) { 112 if(res < 0) {
114 DEBUGF("failed to initialize RM atrac decoder\n"); 113 DEBUGF("failed to initialize RM atrac decoder\n");
115 return CODEC_ERROR; 114 return CODEC_ERROR;
diff --git a/lib/rbcodec/codecs/libatrac/atrac3.c b/lib/rbcodec/codecs/libatrac/atrac3.c
index bb52dd4cf0..f0098258b3 100644
--- a/lib/rbcodec/codecs/libatrac/atrac3.c
+++ b/lib/rbcodec/codecs/libatrac/atrac3.c
@@ -1156,8 +1156,8 @@ int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q,
1156 * Atrac3 initialization 1156 * Atrac3 initialization
1157 * 1157 *
1158 * @param rmctx pointer to the RMContext 1158 * @param rmctx pointer to the RMContext
1159 */ 1159 */
1160int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3) 1160int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3, uint16_t channels, uint32_t extradata_size)
1161{ 1161{
1162 int i; 1162 int i;
1163 uint8_t *edata_ptr = (uint8_t*)&id3->id3v2buf; 1163 uint8_t *edata_ptr = (uint8_t*)&id3->id3v2buf;
@@ -1168,14 +1168,14 @@ int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
1168 1168
1169 /* Take data from the RM container. */ 1169 /* Take data from the RM container. */
1170 q->sample_rate = id3->frequency; 1170 q->sample_rate = id3->frequency;
1171 q->channels = id3->channels; 1171 q->channels = channels;
1172 q->bit_rate = id3->bitrate * 1000; 1172 q->bit_rate = id3->bitrate * 1000;
1173 q->bits_per_frame = id3->bytesperframe * 8; 1173 q->bits_per_frame = id3->bytesperframe * 8;
1174 q->bytes_per_frame = id3->bytesperframe; 1174 q->bytes_per_frame = id3->bytesperframe;
1175 1175
1176 /* Take care of the codec-specific extradata. */ 1176 /* Take care of the codec-specific extradata. */
1177 1177
1178 if (id3->extradata_size == 14) { 1178 if (extradata_size == 14) {
1179 /* Parse the extradata, WAV format */ 1179 /* Parse the extradata, WAV format */
1180 DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */ 1180 DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */
1181 q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]); 1181 q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]);
@@ -1200,7 +1200,7 @@ int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
1200 return -1; 1200 return -1;
1201 } 1201 }
1202 1202
1203 } else if (id3->extradata_size == 10) { 1203 } else if (extradata_size == 10) {
1204 /* Parse the extradata, RM format. */ 1204 /* Parse the extradata, RM format. */
1205 q->atrac3version = rm_get_uint32be(&edata_ptr[0]); 1205 q->atrac3version = rm_get_uint32be(&edata_ptr[0]);
1206 q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]); 1206 q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]);
@@ -1239,7 +1239,7 @@ int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
1239 return -1; 1239 return -1;
1240 } 1240 }
1241 1241
1242 if (id3->channels <= 0 || id3->channels > 2 ) { 1242 if (channels <= 0 || channels > 2 ) {
1243 DEBUGF("Channel configuration error!\n"); 1243 DEBUGF("Channel configuration error!\n");
1244 return -1; 1244 return -1;
1245 } 1245 }
diff --git a/lib/rbcodec/codecs/libatrac/atrac3.h b/lib/rbcodec/codecs/libatrac/atrac3.h
index 64086b6411..912924cf6c 100644
--- a/lib/rbcodec/codecs/libatrac/atrac3.h
+++ b/lib/rbcodec/codecs/libatrac/atrac3.h
@@ -107,7 +107,7 @@ typedef struct {
107 //@} 107 //@}
108} ATRAC3Context; 108} ATRAC3Context;
109 109
110int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3); 110int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3, uint16_t channels, uint32_t extradata_size);
111 111
112int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q, 112int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q,
113 int *data_size, const uint8_t *buf, int buf_size); 113 int *data_size, const uint8_t *buf, int buf_size);