trash XMMS resampling, use ESD's instead, don't understand it, but it works
git-svn-id: https://svn.musicpd.org/mpd/trunk@979 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
33d112499d
commit
69a0b86173
|
@ -152,6 +152,8 @@ void initAudioConfig() {
|
||||||
switch(audio_configFormat->sampleRate) {
|
switch(audio_configFormat->sampleRate) {
|
||||||
case 48000:
|
case 48000:
|
||||||
case 44100:
|
case 44100:
|
||||||
|
case 32000:
|
||||||
|
case 16000:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ERROR("sample rate %i can not be used for audio output\n",
|
ERROR("sample rate %i can not be used for audio output\n",
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
#include <FLAC/metadata.h>
|
#include <FLAC/metadata.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned char chunk[CHUNK_SIZE];
|
#define FLAC_CHUNK_SIZE 4080
|
||||||
|
unsigned char chunk[FLAC_CHUNK_SIZE];
|
||||||
int chunk_length;
|
int chunk_length;
|
||||||
float time;
|
float time;
|
||||||
int bitRate;
|
int bitRate;
|
||||||
|
@ -417,7 +418,7 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec,
|
||||||
u16 = buf[c_chan][c_samp];
|
u16 = buf[c_chan][c_samp];
|
||||||
uc = (unsigned char *)&u16;
|
uc = (unsigned char *)&u16;
|
||||||
for(i=0;i<(data->dc->audioFormat.bits/8);i++) {
|
for(i=0;i<(data->dc->audioFormat.bits/8);i++) {
|
||||||
if(data->chunk_length>=CHUNK_SIZE) {
|
if(data->chunk_length>=FLAC_CHUNK_SIZE) {
|
||||||
if(flacSendChunk(data)<0) {
|
if(flacSendChunk(data)<0) {
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc)
|
||||||
int current_section;
|
int current_section;
|
||||||
int eof = 0;
|
int eof = 0;
|
||||||
long ret;
|
long ret;
|
||||||
#define OGG_CHUNK_SIZE 64
|
#define OGG_CHUNK_SIZE 4096
|
||||||
char chunk[OGG_CHUNK_SIZE];
|
char chunk[OGG_CHUNK_SIZE];
|
||||||
int chunkpos = 0;
|
int chunkpos = 0;
|
||||||
long bitRate = 0;
|
long bitRate = 0;
|
||||||
|
|
|
@ -218,41 +218,29 @@ void pcm_convertAudioFormat(AudioFormat * inFormat, char * inBuffer, size_t
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* only works if outFormat is 16-bit stereo! */
|
/* only works if outFormat is 16-bit stereo! */
|
||||||
/* resampling code blatantly ripped from XMMS */
|
/* resampling code blatantly ripped from ESD */
|
||||||
const int shift = sizeof(mpd_sint16);
|
mpd_sint32 rd_dat = 0;
|
||||||
int x1 = 0, frac;
|
mpd_uint32 wr_dat = 0;
|
||||||
mpd_sint32 i, in_samples, out_samples, x, delta;
|
mpd_sint16 lsample, rsample;
|
||||||
mpd_sint16 * inptr = (mpd_sint16 *)dataChannelConv;
|
register mpd_sint16 * out = (mpd_sint16 *)outBuffer;
|
||||||
mpd_sint16 * outptr = (mpd_sint16 *)outBuffer;
|
register mpd_sint16 * in = (mpd_sint16 *)dataChannelConv;
|
||||||
mpd_uint32 nlen = (((dataChannelLen >> shift) *
|
const int shift = sizeof(mpd_sint16);
|
||||||
(outFormat->sampleRate)) /
|
mpd_uint32 nlen = ((( dataChannelLen >> shift) *
|
||||||
|
(mpd_uint32)(outFormat->sampleRate)) /
|
||||||
inFormat->sampleRate);
|
inFormat->sampleRate);
|
||||||
nlen <<= shift;
|
nlen <<= shift;
|
||||||
in_samples = dataChannelLen >> shift;
|
|
||||||
out_samples = nlen >> shift;
|
while( wr_dat < nlen / shift) {
|
||||||
//printf("in_samples=%i out_samples=%i\n",in_samples,out_samples);
|
rd_dat = wr_dat * inFormat->sampleRate /
|
||||||
delta = ((in_samples-1) << 12) / (out_samples-1);
|
outFormat->sampleRate;
|
||||||
for(x = 0, i = 0; i < out_samples; i++) {
|
rd_dat &= ~1;
|
||||||
//int i1,i2,i3,i4;
|
|
||||||
x1 = (x >> 12) << 12;
|
lsample = in[ rd_dat++ ];
|
||||||
frac = x - x1;
|
rsample = in[ rd_dat++ ];
|
||||||
/* i1 = (x1 >> 12) << 1;
|
|
||||||
i2 = ((x1 >> 12) + 1) << 1;
|
out[ wr_dat++ ] = lsample;
|
||||||
i3 = ((x1 >> 12) << 1) + 1;
|
out[ wr_dat++ ] = rsample;
|
||||||
i4 = (((x1 >> 12) + 1) << 1) + 1;
|
}
|
||||||
printf("%i,%i,%i,%i\n",i1,i2,i3,i4);*/
|
|
||||||
*outptr++ =
|
|
||||||
((inptr[(x1 >> 12) << 1] *
|
|
||||||
((1<<12) - frac) +
|
|
||||||
inptr[((x1 >> 12) + 1) << 1 ] *
|
|
||||||
frac) >> 12);
|
|
||||||
*outptr++ =
|
|
||||||
((inptr[((x1 >> 12) << 1) + 1] *
|
|
||||||
((1<<12) - frac) +
|
|
||||||
inptr[(((x1 >> 12) + 1) << 1) + 1] *
|
|
||||||
frac) >> 12);
|
|
||||||
x += delta;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue