aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/inputPlugins/mp3_plugin.c47
-rw-r--r--src/inputPlugins/mpc_plugin.c26
2 files changed, 23 insertions, 50 deletions
diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c
index 471a173a1..15e69c385 100644
--- a/src/inputPlugins/mp3_plugin.c
+++ b/src/inputPlugins/mp3_plugin.c
@@ -57,7 +57,8 @@
#define MUTEFRAME_SEEK 2
/* this is stolen from mpg321! */
-struct audio_dither {
+
+/*struct audio_dither {
mad_fixed_t error[3];
mad_fixed_t random;
};
@@ -108,7 +109,7 @@ signed long audio_linear_dither(unsigned int bits, mad_fixed_t sample, struct au
dither->error[0] = sample - output;
return output >> scalebits;
-}
+}*/
/* end of stolen stuff from mpg321 */
/* decoder stuff is based on madlld */
@@ -135,7 +136,7 @@ typedef struct _mp3DecodeData {
int flush;
unsigned long bitRate;
InputStream * inStream;
- struct audio_dither dither;
+ /*struct audio_dither dither;*/
} mp3DecodeData;
void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) {
@@ -149,7 +150,7 @@ void initMp3DecodeData(mp3DecodeData * data, InputStream * inStream) {
data->currentFrame = 0;
data->flush = 1;
data->inStream = inStream;
- memset(&(data->dither), 0, sizeof(struct audio_dither));
+/* memset(&(data->dither), 0, sizeof(struct audio_dither));*/
mad_stream_init(&data->stream);
data->stream.options |= MAD_OPTION_IGNORECRC;
@@ -566,35 +567,18 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
}
for(i=0;i<(data->synth).pcm.length;i++) {
-#ifdef MPD_FIXED_POINT
- mpd_sint16 * sample;
- sample = (mpd_sint16 *)data->outputPtr;
- *sample = (mpd_sint16) audio_linear_dither(16,
- (data->synth).pcm.samples[0][i],
- &(data->dither));
- data->outputPtr+=2;
-
- if(MAD_NCHANNELS(&(data->frame).header)==2) {
- sample = (mpd_sint16 *)data->outputPtr;
- *sample = (mpd_sint16) audio_linear_dither(16,
- (data->synth).pcm.samples[1][i],
- &(data->dither));
- data->outputPtr+=2;
- }
-#else
- mpd_float32 * sample;
- sample = (mpd_float32 *)data->outputPtr;
- *sample = (mpd_float32) mad_f_todouble(
- (data->synth).pcm.samples[0][i]);
+ mpd_fixed_t * sample;
+ sample = (mpd_fixed_t *)data->outputPtr;
+ *sample = (mpd_fixed_t)
+ ((data->synth).pcm.samples[0][i]);
data->outputPtr+=4;
if(MAD_NCHANNELS(&(data->frame).header)==2) {
- sample = (mpd_sint16 *)data->outputPtr;
- *sample = (mpd_float32) mad_f_todouble(
- (data->synth).pcm.samples[0][i]);
+ sample = (mpd_fixed_t *)data->outputPtr;
+ *sample = (mpd_fixed_t)
+ ((data->synth).pcm.samples[0][i]);
data->outputPtr+=4;
}
-#endif
if(data->outputPtr>=data->outputBufferEnd) {
long ret;
@@ -667,13 +651,8 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
}
void initAudioFormatFromMp3DecodeData(mp3DecodeData * data, AudioFormat * af) {
-#ifdef MPD_FIXED_POINT
- af->bits = 16;
- af->floatSamples = 0;
-#else
af->bits = 32;
- af->floatSamples = 1;
-#endif
+ af->fracBits = MAD_F_FRACBITS;
af->sampleRate = (data->frame).header.samplerate;
af->channels = MAD_NCHANNELS(&(data->frame).header);
}
diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c
index 107792125..799664f2c 100644
--- a/src/inputPlugins/mpc_plugin.c
+++ b/src/inputPlugins/mpc_plugin.c
@@ -82,17 +82,14 @@ static mpc_int32_t mpc_getsize_cb(void * vdata) {
return data->inStream->size;
}
-inline mpd_sint16 convertSample(MPC_SAMPLE_FORMAT sample) {
+inline mpd_fixed_t convertSample(MPC_SAMPLE_FORMAT sample) {
/* only doing 16-bit audio for now */
mpd_sint32 val;
- const int clip_min = -1 << (16 - 1);
- const int clip_max = (1 << (16 - 1)) - 1;
-
#ifdef MPC_FIXED_POINT
- const int shift = 16 - MPC_FIXED_POINT_SCALE_SHIFT;
+ const int shift = 28 - MPC_FIXED_POINT_SCALE_SHIFT;
- if( ssample > 0 ) {
+ if( shift > 0 ) {
sample <<= shift;
}
else if ( shift < 0 ) {
@@ -100,15 +97,12 @@ inline mpd_sint16 convertSample(MPC_SAMPLE_FORMAT sample) {
}
val = sample;
#else
- const int float_scale = 1 << (16 - 1);
+ const mpd_sint32 float_scale = 1L << 28;
val = sample * float_scale;
#endif
-
- if( val < clip_min) val = clip_min;
- else if ( val > clip_max ) val = clip_max;
-
return val;
+
}
static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
@@ -129,7 +123,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
int chunkpos = 0;
long bitRate = 0;
mpd_sint16 * s16 = (mpd_sint16 *) chunk;
- float * f32 = (float *) chunk;
+ mpd_fixed_t * s32 = (mpd_fixed_t *) chunk;
unsigned long samplePos = 0;
mpc_uint32_t vbrUpdateAcc;
mpc_uint32_t vbrUpdateBits;
@@ -178,7 +172,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
dc->totalTime = mpc_streaminfo_get_length(&info);
dc->audioFormat.bits = 32;
- dc->audioFormat.floatSamples = 1;
+ dc->audioFormat.fracBits = 28;
dc->audioFormat.channels = info.channels;
dc->audioFormat.sampleRate = info.sample_freq;
@@ -221,9 +215,9 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
chunkpos += 2;
s16++; */
- *f32 = (float)(sample_buffer[i]);
+ *s32 = convertSample(sample_buffer[i]);
chunkpos += 4;
- f32++;
+ s32++;
if(chunkpos >= MPC_CHUNK_SIZE) {
time = ((float)samplePos) /
@@ -242,7 +236,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc,
chunkpos = 0;
s16 = (mpd_sint16 *)chunk;
- f32 = (float*)chunk;
+ s32 = (mpd_fixed_t *)chunk;
if(dc->stop) {
eof = 1;
break;