diff options
Diffstat (limited to 'lib/rbcodec')
-rw-r--r-- | lib/rbcodec/codecs/atrac3_oma.c | 11 | ||||
-rw-r--r-- | lib/rbcodec/codecs/atrac3_rm.c | 3 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libatrac/atrac3.c | 12 | ||||
-rw-r--r-- | lib/rbcodec/codecs/libatrac/atrac3.h | 2 | ||||
-rw-r--r-- | lib/rbcodec/metadata/metadata.h | 4 | ||||
-rw-r--r-- | lib/rbcodec/metadata/mpc.c | 2 | ||||
-rw-r--r-- | lib/rbcodec/metadata/oma.c | 5 | ||||
-rw-r--r-- | lib/rbcodec/metadata/rm.c | 2 | ||||
-rw-r--r-- | lib/rbcodec/metadata/tta.c | 8 | ||||
-rw-r--r-- | lib/rbcodec/metadata/wave.c | 6 | ||||
-rw-r--r-- | lib/rbcodec/test/warble.c | 2 |
11 files changed, 22 insertions, 35 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 | ||
29 | CODEC_HEADER | 28 | CODEC_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 | ||
28 | CODEC_HEADER | 27 | CODEC_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 | */ |
1160 | int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3) | 1160 | int 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 | ||
110 | int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3); | 110 | int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3, uint16_t channels, uint32_t extradata_size); |
111 | 111 | ||
112 | int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q, | 112 | int 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); |
diff --git a/lib/rbcodec/metadata/metadata.h b/lib/rbcodec/metadata/metadata.h index eda1fb0d7d..b30979334a 100644 --- a/lib/rbcodec/metadata/metadata.h +++ b/lib/rbcodec/metadata/metadata.h | |||
@@ -272,10 +272,6 @@ struct mp3entry { | |||
272 | bool has_toc; /* True if there is a VBR header in the file */ | 272 | bool has_toc; /* True if there is a VBR header in the file */ |
273 | unsigned char toc[100]; /* table of contents */ | 273 | unsigned char toc[100]; /* table of contents */ |
274 | 274 | ||
275 | /* Added for ATRAC3 */ | ||
276 | unsigned int channels; /* Number of channels in the stream */ | ||
277 | unsigned int extradata_size; /* Size (in bytes) of the codec's extradata from the container */ | ||
278 | |||
279 | /* Added for AAC HE SBR */ | 275 | /* Added for AAC HE SBR */ |
280 | bool needs_upsampling_correction; /* flag used by aac codec */ | 276 | bool needs_upsampling_correction; /* flag used by aac codec */ |
281 | 277 | ||
diff --git a/lib/rbcodec/metadata/mpc.c b/lib/rbcodec/metadata/mpc.c index 3c0ee0707d..346053dd3e 100644 --- a/lib/rbcodec/metadata/mpc.c +++ b/lib/rbcodec/metadata/mpc.c | |||
@@ -163,7 +163,7 @@ bool get_musepack_metadata(int fd, struct mp3entry *id3) | |||
163 | id3->frequency = sfreqs[(sv8_header[k++] >> 5) & 0x0003]; | 163 | id3->frequency = sfreqs[(sv8_header[k++] >> 5) & 0x0003]; |
164 | 164 | ||
165 | /* Number of channels */ | 165 | /* Number of channels */ |
166 | id3->channels = (sv8_header[k++] >> 4) + 1; | 166 | //uint8_t channels = (sv8_header[k++] >> 4) + 1; |
167 | 167 | ||
168 | /* Skip to next tag: k = size -2 */ | 168 | /* Skip to next tag: k = size -2 */ |
169 | k = size - 2; | 169 | k = size - 2; |
diff --git a/lib/rbcodec/metadata/oma.c b/lib/rbcodec/metadata/oma.c index 3573d58808..3afa1aad70 100644 --- a/lib/rbcodec/metadata/oma.c +++ b/lib/rbcodec/metadata/oma.c | |||
@@ -149,10 +149,6 @@ static int oma_read_header(int fd, struct mp3entry* id3) | |||
149 | 149 | ||
150 | id3->bitrate = id3->frequency * id3->bytesperframe * 8 / (1024 * 1000); | 150 | id3->bitrate = id3->frequency * id3->bytesperframe * 8 / (1024 * 1000); |
151 | 151 | ||
152 | /* fake the atrac3 extradata (wav format, makes stream copy to wav work) */ | ||
153 | /* ATRAC3 expects and extra-data size of 14 bytes for wav format, and * | ||
154 | * looks for that in the id3v2buf. */ | ||
155 | id3->extradata_size = 14; | ||
156 | AV_WL16(&id3->id3v2buf[0], 1); // always 1 | 152 | AV_WL16(&id3->id3v2buf[0], 1); // always 1 |
157 | AV_WL32(&id3->id3v2buf[2], id3->frequency); // samples rate | 153 | AV_WL32(&id3->id3v2buf[2], id3->frequency); // samples rate |
158 | AV_WL16(&id3->id3v2buf[6], jsflag); // coding mode | 154 | AV_WL16(&id3->id3v2buf[6], jsflag); // coding mode |
@@ -160,7 +156,6 @@ static int oma_read_header(int fd, struct mp3entry* id3) | |||
160 | AV_WL16(&id3->id3v2buf[10], 1); // always 1 | 156 | AV_WL16(&id3->id3v2buf[10], 1); // always 1 |
161 | AV_WL16(&id3->id3v2buf[12], 0); // always 0 | 157 | AV_WL16(&id3->id3v2buf[12], 0); // always 0 |
162 | 158 | ||
163 | id3->channels = 2; | ||
164 | DEBUGF("sample_rate = %d\n", id3->frequency); | 159 | DEBUGF("sample_rate = %d\n", id3->frequency); |
165 | DEBUGF("frame_size = %d\n", id3->bytesperframe); | 160 | DEBUGF("frame_size = %d\n", id3->bytesperframe); |
166 | DEBUGF("stereo_coding_mode = %d\n", jsflag); | 161 | DEBUGF("stereo_coding_mode = %d\n", jsflag); |
diff --git a/lib/rbcodec/metadata/rm.c b/lib/rbcodec/metadata/rm.c index 1e33f0b0ac..16ffe17b14 100644 --- a/lib/rbcodec/metadata/rm.c +++ b/lib/rbcodec/metadata/rm.c | |||
@@ -502,8 +502,6 @@ bool get_rm_metadata(int fd, struct mp3entry* id3) | |||
502 | break; | 502 | break; |
503 | } | 503 | } |
504 | 504 | ||
505 | id3->channels = rmctx->nb_channels; | ||
506 | id3->extradata_size = rmctx->extradata_size; | ||
507 | id3->bitrate = (rmctx->bit_rate + 500) / 1000; | 505 | id3->bitrate = (rmctx->bit_rate + 500) / 1000; |
508 | id3->frequency = rmctx->sample_rate; | 506 | id3->frequency = rmctx->sample_rate; |
509 | id3->length = rmctx->duration; | 507 | id3->length = rmctx->duration; |
diff --git a/lib/rbcodec/metadata/tta.c b/lib/rbcodec/metadata/tta.c index 5f99c4776e..a481d8dd21 100644 --- a/lib/rbcodec/metadata/tta.c +++ b/lib/rbcodec/metadata/tta.c | |||
@@ -93,21 +93,21 @@ bool get_tta_metadata(int fd, struct mp3entry* id3) | |||
93 | 93 | ||
94 | /* skip check CRC */ | 94 | /* skip check CRC */ |
95 | 95 | ||
96 | id3->channels = (GET_HEADER(ttahdr, NUM_CHANNELS)); | 96 | unsigned short channels = (GET_HEADER(ttahdr, NUM_CHANNELS)); |
97 | id3->frequency = (GET_HEADER(ttahdr, SAMPLE_RATE)); | 97 | id3->frequency = (GET_HEADER(ttahdr, SAMPLE_RATE)); |
98 | id3->length = ((GET_HEADER(ttahdr, DATA_LENGTH)) / id3->frequency) * 1000LL; | 98 | id3->length = ((GET_HEADER(ttahdr, DATA_LENGTH)) / id3->frequency) * 1000LL; |
99 | bps = (GET_HEADER(ttahdr, BITS_PER_SAMPLE)); | 99 | bps = (GET_HEADER(ttahdr, BITS_PER_SAMPLE)); |
100 | 100 | ||
101 | datasize = id3->filesize - id3->first_frame_offset; | 101 | datasize = id3->filesize - id3->first_frame_offset; |
102 | origsize = (GET_HEADER(ttahdr, DATA_LENGTH)) * ((bps + 7) / 8) * id3->channels; | 102 | origsize = (GET_HEADER(ttahdr, DATA_LENGTH)) * ((bps + 7) / 8) * channels; |
103 | 103 | ||
104 | id3->bitrate = (int) ((uint64_t) datasize * id3->frequency * id3->channels * bps | 104 | id3->bitrate = (int) ((uint64_t) datasize * id3->frequency * channels * bps |
105 | / (origsize * 1000LL)); | 105 | / (origsize * 1000LL)); |
106 | 106 | ||
107 | /* output header info (for debug) */ | 107 | /* output header info (for debug) */ |
108 | DEBUGF("TTA header info ----\n"); | 108 | DEBUGF("TTA header info ----\n"); |
109 | DEBUGF("id: %x\n", (unsigned int)(GET_HEADER(ttahdr, ID))); | 109 | DEBUGF("id: %x\n", (unsigned int)(GET_HEADER(ttahdr, ID))); |
110 | DEBUGF("channels: %d\n", id3->channels); | 110 | DEBUGF("channels: %d\n", channels); |
111 | DEBUGF("frequency: %ld\n", id3->frequency); | 111 | DEBUGF("frequency: %ld\n", id3->frequency); |
112 | DEBUGF("length: %ld\n", id3->length); | 112 | DEBUGF("length: %ld\n", id3->length); |
113 | DEBUGF("bitrate: %d\n", id3->bitrate); | 113 | DEBUGF("bitrate: %d\n", id3->bitrate); |
diff --git a/lib/rbcodec/metadata/wave.c b/lib/rbcodec/metadata/wave.c index 3fb051dd3c..2c918d1357 100644 --- a/lib/rbcodec/metadata/wave.c +++ b/lib/rbcodec/metadata/wave.c | |||
@@ -160,7 +160,7 @@ static void set_totalsamples(struct wave_fmt *fmt, struct mp3entry* id3) | |||
160 | fmt->samplesperblock = 1; | 160 | fmt->samplesperblock = 1; |
161 | break; | 161 | break; |
162 | case WAVE_FORMAT_YAMAHA_ADPCM: | 162 | case WAVE_FORMAT_YAMAHA_ADPCM: |
163 | if (id3->channels != 0) | 163 | if (fmt->channels != 0) |
164 | { | 164 | { |
165 | fmt->samplesperblock = | 165 | fmt->samplesperblock = |
166 | (fmt->blockalign == ((id3->frequency / 60) + 4) * fmt->channels)? | 166 | (fmt->blockalign == ((id3->frequency / 60) + 4) * fmt->channels)? |
@@ -172,7 +172,7 @@ static void set_totalsamples(struct wave_fmt *fmt, struct mp3entry* id3) | |||
172 | fmt->samplesperblock = 2; | 172 | fmt->samplesperblock = 2; |
173 | break; | 173 | break; |
174 | case WAVE_FORMAT_SWF_ADPCM: | 174 | case WAVE_FORMAT_SWF_ADPCM: |
175 | if (fmt->bitspersample != 0 && id3->channels != 0) | 175 | if (fmt->bitspersample != 0 && fmt->channels != 0) |
176 | { | 176 | { |
177 | fmt->samplesperblock | 177 | fmt->samplesperblock |
178 | = (((fmt->blockalign << 3) - 2) / fmt->channels - 22) | 178 | = (((fmt->blockalign << 3) - 2) / fmt->channels - 22) |
@@ -226,8 +226,6 @@ static void parse_riff_format(unsigned char* buf, int fmtsize, struct wave_fmt * | |||
226 | if(id3->bitrate == 66 || id3->bitrate == 94) | 226 | if(id3->bitrate == 66 || id3->bitrate == 94) |
227 | jsflag = 1; | 227 | jsflag = 1; |
228 | 228 | ||
229 | id3->extradata_size = 14; | ||
230 | id3->channels = 2; | ||
231 | id3->codectype = AFMT_OMA_ATRAC3; | 229 | id3->codectype = AFMT_OMA_ATRAC3; |
232 | id3->bytesperframe = fmt->blockalign; | 230 | id3->bytesperframe = fmt->blockalign; |
233 | 231 | ||
diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c index cb7a85ff25..e6e53d7991 100644 --- a/lib/rbcodec/test/warble.c +++ b/lib/rbcodec/test/warble.c | |||
@@ -749,8 +749,6 @@ static void print_mp3entry(const struct mp3entry *id3, FILE *f) | |||
749 | if (id3->bytesperframe) fprintf(f, "Bytes per frame: %lu\n", id3->bytesperframe); | 749 | if (id3->bytesperframe) fprintf(f, "Bytes per frame: %lu\n", id3->bytesperframe); |
750 | if (id3->vbr) fprintf(f, "VBR: true\n"); | 750 | if (id3->vbr) fprintf(f, "VBR: true\n"); |
751 | if (id3->has_toc) fprintf(f, "Has TOC: true\n"); | 751 | if (id3->has_toc) fprintf(f, "Has TOC: true\n"); |
752 | if (id3->channels) fprintf(f, "Number of channels: %u\n", id3->channels); | ||
753 | if (id3->extradata_size) fprintf(f, "Size of extra data: %u\n", id3->extradata_size); | ||
754 | if (id3->needs_upsampling_correction) fprintf(f, "Needs upsampling correction: true\n"); | 752 | if (id3->needs_upsampling_correction) fprintf(f, "Needs upsampling correction: true\n"); |
755 | /* TODO: replaygain; albumart; cuesheet */ | 753 | /* TODO: replaygain; albumart; cuesheet */ |
756 | if (id3->mb_track_id) fprintf(f, "Musicbrainz track ID: %s\n", id3->mb_track_id); | 754 | if (id3->mb_track_id) fprintf(f, "Musicbrainz track ID: %s\n", id3->mb_track_id); |