forked from len0rd/rockbox
Remove ATRAC3 specific fields (channels, extradata_size) from mp3entry
Also fixes typo of using never initialized id3->channels in wav metadata (introduced in 2d1937a1
)
Change-Id: I28cddec2b9d9bd1e756ffaa004b4f6e8528a7566
This commit is contained in:
parent
be16edc94b
commit
76ec55cc49
11 changed files with 22 additions and 35 deletions
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include "logf.h"
|
||||
#include "codeclib.h"
|
||||
#include "inttypes.h"
|
||||
#include "libatrac/atrac3.h"
|
||||
|
||||
CODEC_HEADER
|
||||
|
@ -66,12 +65,16 @@ enum codec_status codec_run(void)
|
|||
|
||||
ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency);
|
||||
ci->configure(DSP_SET_SAMPLE_DEPTH, 17); /* Remark: atrac3 uses s15.0 by default, s15.2 was hacked. */
|
||||
ci->configure(DSP_SET_STEREO_MODE, ci->id3->channels == 1 ?
|
||||
const uint8_t channels = 2;
|
||||
ci->configure(DSP_SET_STEREO_MODE, channels == 1 ?
|
||||
STEREO_MONO : STEREO_NONINTERLEAVED);
|
||||
|
||||
ci->seek_buffer(0);
|
||||
|
||||
res = atrac3_decode_init(&q, ci->id3);
|
||||
/* fake the atrac3 extradata (wav format, makes stream copy to wav work) */
|
||||
/* ATRAC3 expects and extra-data size of 14 bytes for wav format, and *
|
||||
* looks for that in the id3v2buf. */
|
||||
res = atrac3_decode_init(&q, ci->id3, channels, 14);
|
||||
if(res < 0) {
|
||||
DEBUGF("failed to initialize OMA atrac decoder\n");
|
||||
return CODEC_ERROR;
|
||||
|
@ -143,7 +146,7 @@ enum codec_status codec_run(void)
|
|||
|
||||
if(datasize)
|
||||
ci->pcmbuf_insert(q.outSamples, q.outSamples + 1024,
|
||||
q.samples_per_frame / ci->id3->channels);
|
||||
q.samples_per_frame / channels);
|
||||
|
||||
elapsed += (FRAMESIZE * 8) / BITRATE;
|
||||
ci->set_elapsed(elapsed);
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "codeclib.h"
|
||||
#include "inttypes.h"
|
||||
#include "libatrac/atrac3.h"
|
||||
|
||||
CODEC_HEADER
|
||||
|
@ -109,7 +108,7 @@ enum codec_status codec_run(void)
|
|||
scrambling_unit_size = h * (fs + packet_header_size);
|
||||
spn = h * fs / sps;
|
||||
|
||||
res = atrac3_decode_init(&q, ci->id3);
|
||||
res = atrac3_decode_init(&q, ci->id3, rmctx.nb_channels, rmctx.extradata_size);
|
||||
if(res < 0) {
|
||||
DEBUGF("failed to initialize RM atrac decoder\n");
|
||||
return CODEC_ERROR;
|
||||
|
|
|
@ -1156,8 +1156,8 @@ int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q,
|
|||
* Atrac3 initialization
|
||||
*
|
||||
* @param rmctx pointer to the RMContext
|
||||
*/
|
||||
int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
|
||||
*/
|
||||
int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3, uint16_t channels, uint32_t extradata_size)
|
||||
{
|
||||
int i;
|
||||
uint8_t *edata_ptr = (uint8_t*)&id3->id3v2buf;
|
||||
|
@ -1168,14 +1168,14 @@ int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
|
|||
|
||||
/* Take data from the RM container. */
|
||||
q->sample_rate = id3->frequency;
|
||||
q->channels = id3->channels;
|
||||
q->channels = channels;
|
||||
q->bit_rate = id3->bitrate * 1000;
|
||||
q->bits_per_frame = id3->bytesperframe * 8;
|
||||
q->bytes_per_frame = id3->bytesperframe;
|
||||
|
||||
/* Take care of the codec-specific extradata. */
|
||||
|
||||
if (id3->extradata_size == 14) {
|
||||
if (extradata_size == 14) {
|
||||
/* Parse the extradata, WAV format */
|
||||
DEBUGF("[0-1] %d\n",rm_get_uint16le(&edata_ptr[0])); /* Unknown value always 1 */
|
||||
q->samples_per_channel = rm_get_uint32le(&edata_ptr[2]);
|
||||
|
@ -1200,7 +1200,7 @@ int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
|
|||
return -1;
|
||||
}
|
||||
|
||||
} else if (id3->extradata_size == 10) {
|
||||
} else if (extradata_size == 10) {
|
||||
/* Parse the extradata, RM format. */
|
||||
q->atrac3version = rm_get_uint32be(&edata_ptr[0]);
|
||||
q->samples_per_frame = rm_get_uint16be(&edata_ptr[4]);
|
||||
|
@ -1239,7 +1239,7 @@ int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (id3->channels <= 0 || id3->channels > 2 ) {
|
||||
if (channels <= 0 || channels > 2 ) {
|
||||
DEBUGF("Channel configuration error!\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ typedef struct {
|
|||
//@}
|
||||
} ATRAC3Context;
|
||||
|
||||
int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3);
|
||||
int atrac3_decode_init(ATRAC3Context *q, struct mp3entry *id3, uint16_t channels, uint32_t extradata_size);
|
||||
|
||||
int atrac3_decode_frame(unsigned long block_align, ATRAC3Context *q,
|
||||
int *data_size, const uint8_t *buf, int buf_size);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue