1
0
mirror of http://mpg123.de/trunk/.git synced 2025-11-01 12:51:03 +03:00

I couldn't help myself... here is the option for a build using the generic decoder that produces 32bit float output.

You select it via --with-cpu=generic_float, which implies dummy output and also disables the buffer.
The decoded audio can be written raw or to a IEEE float wav file.

This demonstrates that it's doable and not too complicated for the generic code.
Next would be to a) make it into a runtime option and b) adapt assembler opts to that.
The latter will most likely not happen for every opt.



git-svn-id: svn://scm.orgis.org/mpg123/trunk@668 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
thor
2007-05-31 15:54:06 +00:00
parent 2861500b29
commit 933198fc46
15 changed files with 292 additions and 125 deletions

View File

@@ -93,6 +93,7 @@ AC_ARG_ENABLE(fifo,
AC_ARG_WITH([cpu], [
--with-cpu=generic[_fpu] Use generic processor code with floating point arithmetic
--with-cpu=generic_float A special build with generic fpu code that produces 32bit float output
--with-cpu=generic_nofpu Use generic processor code with fixed point arithmetic (p.ex. ARM, experimental)
--with-cpu=i386[_fpu] Use code optimized for i386 processors with floating point arithmetic
--with-cpu=i386_nofpu Use code optimized for i386 processors with fixed point arithmetic (experimental)
@@ -393,6 +394,9 @@ case $cpu_type in
generic)
CFLAGS="$CFLAGS -DOPT_GENERIC -DREAL_IS_FLOAT"
;;
generic_float)
CFLAGS="$CFLAGS -DOPT_GENERIC -DFLOATOUT -DNOXFERMEM -DREAL_IS_FLOAT"
;;
generic_fpu)
CFLAGS="$CFLAGS -DOPT_GENERIC -DREAL_IS_FLOAT"
;;
@@ -444,7 +448,11 @@ case $cpu_type in
;;
esac
CPU_TYPE_LIB="libcpu_$cpu_type.a"
if test $cpu_type = "generic_float"; then
CPU_TYPE_LIB="libcpu_generic.a"
else
CPU_TYPE_LIB="libcpu_$cpu_type.a"
fi
AC_SUBST( CPU_TYPE_LIB )
@@ -503,8 +511,10 @@ AC_DEFINE_UNQUOTED(INDEX_SIZE, $seektable, [size of the frame index seek table])
dnl ############## Audio Sub-system Settings
# Choose audio subsystem based on what we have.
if test "x$HAVE_ALSA" = "xyes"; then
if test $cpu_type = "generic_float"; then
audio_system="dummy"
AC_MSG_WARN( Defaulting to dummy output with float samples, as the audio device system cannot handle floats. )
elif test "x$HAVE_ALSA" = "xyes"; then
audio_system="alsa"
elif test "x$HAVE_OSS" = "xyes"; then
audio_system="oss"
@@ -683,6 +693,11 @@ echo ")
Seek table size ......... $seektable
FIFO support ............ $fifo
"
if test $cpu_type = "generic_float"; then
echo "You chose the generic build with 32bit float output.
That means output via -s, -O or -w to a file/pipe and no buffer.
"
fi
if test "$debugging" = "enabled"; then
echo "CFLAGS='$CFLAGS'"

View File

@@ -73,7 +73,7 @@ unsigned long track_frames = 0;
#define TRACK_MAX_FRAMES ULONG_MAX/4/1152
/* this could become a struct... */
long lastscale = -1; /* last used scale */
scale_t lastscale = -1; /* last used scale */
int rva_level[2] = {-1,-1}; /* significance level of stored rva */
float rva_gain[2] = {0,0}; /* mix, album */
float rva_peak[2] = {0,0};
@@ -129,6 +129,9 @@ unsigned long samples_to_bytes(unsigned long s, struct frame *fr , struct audio_
samf = floor(sammy);
return (unsigned long)
(((ai->format & AUDIO_FORMAT_MASK) == AUDIO_FORMAT_16) ? 2 : 1)
#ifdef FLOATOUT
* 2
#endif
* ai->channels
* (int) (((sammy - samf) < 0.5) ? samf : ( sammy-samf > 0.5 ? samf+1 : ((unsigned long) samf % 2 == 0 ? samf : samf + 1)));
}
@@ -247,9 +250,10 @@ void do_volume(double factor)
/* adjust the volume, taking both outscale and rva values into account */
void do_rva()
{
float rvafact = 1;
double rvafact = 1;
float peak = 0;
long newscale;
scale_t newscale;
if(param.rva)
{
int rt = 0;
@@ -272,7 +276,7 @@ void do_rva()
/* if peak is unknown (== 0) this check won't hurt */
if((peak*newscale) > MAXOUTBURST)
{
newscale = (long) ((float) MAXOUTBURST/peak);
newscale = (scale_t) ((double) MAXOUTBURST/peak);
warning2("limiting scale value to %li to prevent clipping with indicated peak factor of %f", newscale, peak);
}
/* first rva setting is forced with lastscale < 0 */

View File

@@ -102,7 +102,7 @@ void print_stat(struct frame *fr,unsigned long no,long buffsize,struct audio_inf
void clear_stat();
/* rva data, used in common.c, set in id3.c */
extern long lastscale;
extern scale_t lastscale;
extern int rva_level[2];
extern float rva_gain[2];
extern float rva_peak[2];

View File

@@ -12,16 +12,14 @@
#include "config.h"
#include "mpg123.h"
#include "decode.h"
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > REAL_PLUS_32767) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < REAL_MINUS_32768) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = REAL_TO_SHORT(sum); }
/* 8bit functions silenced for FLOATOUT */
int synth_1to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp + channel;
sample_t samples_tmp[64];
sample_t *tmp1 = samples_tmp + channel;
int i,ret;
int pnt1=0;
@@ -29,7 +27,11 @@ int synth_1to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
samples += channel + *pnt;
for(i=0;i<32;i++) {
#ifdef FLOATOUT
*samples = 0;
#else
*samples = conv16to8[*tmp1>>AUSHIFT];
#endif
samples += 2;
tmp1 += 2;
}
@@ -40,8 +42,8 @@ int synth_1to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
int synth_1to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
sample_t samples_tmp[64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -49,7 +51,11 @@ int synth_1to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<32;i++) {
#ifdef FLOATOUT
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 32;
@@ -59,8 +65,8 @@ int synth_1to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
int synth_1to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
sample_t samples_tmp[64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -68,8 +74,13 @@ int synth_1to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<32;i++) {
#ifdef FLOATOUT
*samples++ = 0;
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 64;
@@ -79,8 +90,8 @@ int synth_1to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[64];
short *tmp1 = samples_tmp;
sample_t samples_tmp[64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -88,11 +99,11 @@ int synth_1to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<32;i++) {
*( (short *)samples) = *tmp1;
samples += 2;
*( (sample_t *)samples) = *tmp1;
samples += sizeof(sample_t);
tmp1 += 2;
}
*pnt += 64;
*pnt += 32*sizeof(sample_t);
return ret;
}
@@ -103,11 +114,11 @@ int synth_1to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
int i,ret;
ret = synth_1to1(bandPtr,0,samples,pnt);
samples = samples + *pnt - 128;
samples = samples + *pnt - 64*sizeof(sample_t);
for(i=0;i<32;i++) {
((short *)samples)[1] = ((short *)samples)[0];
samples+=4;
((sample_t *)samples)[1] = ((sample_t *)samples)[0];
samples+=2*sizeof(sample_t);
}
return ret;
@@ -119,7 +130,7 @@ int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
short *samples = (short *) (out+*pnt);
sample_t *samples = (sample_t *) (out+*pnt);
real *b0,(*buf)[0x110];
int clip = 0;
@@ -216,7 +227,7 @@ int synth_1to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
}
}
*pnt += 128;
*pnt += 64*sizeof(sample_t);
return clip;
}

18
src/decode.h Normal file
View File

@@ -0,0 +1,18 @@
/*
decode.h: common definitions for decode functions
copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
see COPYING and AUTHORS files in distribution or http://mpg123.de
initially written by Thomas Orgis, taking WRITE_SAMPLE from decode.c
*/
#ifdef FLOATOUT
#define WRITE_SAMPLE(samples,sum,clip) *(samples) = sum
#define sample_t float
#else
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > REAL_PLUS_32767) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < REAL_MINUS_32768) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = REAL_TO_SHORT(sum); }
#define sample_t short
#endif

View File

@@ -12,16 +12,12 @@
#include "config.h"
#include "mpg123.h"
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = sum; }
#include "decode.h"
int synth_2to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
short samples_tmp[32];
short *tmp1 = samples_tmp + channel;
sample_t samples_tmp[32];
sample_t *tmp1 = samples_tmp + channel;
int i,ret;
int pnt1 = 0;
@@ -29,7 +25,11 @@ int synth_2to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
samples += channel + *pnt;
for(i=0;i<16;i++) {
#ifdef FLOATOUT
*samples = 0;
#else
*samples = conv16to8[*tmp1>>AUSHIFT];
#endif
samples += 2;
tmp1 += 2;
}
@@ -40,8 +40,8 @@ int synth_2to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
int synth_2to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[32];
short *tmp1 = samples_tmp;
sample_t samples_tmp[32];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -49,7 +49,11 @@ int synth_2to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<16;i++) {
#ifdef FLOATOUT
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 16;
@@ -60,8 +64,8 @@ int synth_2to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
int synth_2to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[32];
short *tmp1 = samples_tmp;
sample_t samples_tmp[32];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -69,8 +73,13 @@ int synth_2to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<16;i++) {
#ifdef FLOATOUT
*samples++ = 0;
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 32;
@@ -80,8 +89,8 @@ int synth_2to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
int synth_2to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[32];
short *tmp1 = samples_tmp;
sample_t samples_tmp[32];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1=0;
@@ -89,11 +98,11 @@ int synth_2to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<16;i++) {
*( (short *) samples) = *tmp1;
samples += 2;
*( (sample_t *) samples) = *tmp1;
samples += sizeof(sample_t);
tmp1 += 2;
}
*pnt += 32;
*pnt += 16*sizeof(sample_t);
return ret;
}
@@ -103,11 +112,11 @@ int synth_2to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
int i,ret;
ret = synth_2to1(bandPtr,0,samples,pnt);
samples = samples + *pnt - 64;
samples = samples + *pnt - 32*sizeof(sample_t);
for(i=0;i<16;i++) {
((short *)samples)[1] = ((short *)samples)[0];
samples+=4;
((sample_t *)samples)[1] = ((sample_t *)samples)[0];
samples+=2*sizeof(sample_t);
}
return ret;
@@ -118,7 +127,7 @@ int synth_2to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
short *samples = (short *) (out + *pnt);
sample_t *samples = (sample_t *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;
@@ -223,7 +232,7 @@ int synth_2to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
}
}
*pnt += 64;
*pnt += 32*sizeof(sample_t);
return clip;
}

View File

@@ -15,16 +15,12 @@
#include "config.h"
#include "mpg123.h"
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = sum; }
#include "decode.h"
int synth_4to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
short samples_tmp[16];
short *tmp1 = samples_tmp + channel;
sample_t samples_tmp[16];
sample_t *tmp1 = samples_tmp + channel;
int i,ret;
int pnt1 = 0;
@@ -32,7 +28,11 @@ int synth_4to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
samples += channel + *pnt;
for(i=0;i<8;i++) {
#ifdef FLOATOUT
*samples = 0;
#else
*samples = conv16to8[*tmp1>>AUSHIFT];
#endif
samples += 2;
tmp1 += 2;
}
@@ -43,8 +43,8 @@ int synth_4to1_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
int synth_4to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[16];
short *tmp1 = samples_tmp;
sample_t samples_tmp[16];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -52,7 +52,11 @@ int synth_4to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<8;i++) {
#ifdef FLOATOUT
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 8;
@@ -63,8 +67,8 @@ int synth_4to1_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
int synth_4to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[16];
short *tmp1 = samples_tmp;
sample_t samples_tmp[16];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -72,8 +76,13 @@ int synth_4to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<8;i++) {
#ifdef FLOATOUT
*samples++ = 0;
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += 16;
@@ -83,8 +92,8 @@ int synth_4to1_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
int synth_4to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[16];
short *tmp1 = samples_tmp;
sample_t samples_tmp[16];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -92,11 +101,11 @@ int synth_4to1_mono(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<8;i++) {
*( (short *)samples) = *tmp1;
samples += 2;
*( (sample_t *)samples) = *tmp1;
samples += sizeof(sample_t);
tmp1 += 2;
}
*pnt += 16;
*pnt += 8*sizeof(sample_t);
return ret;
}
@@ -106,11 +115,11 @@ int synth_4to1_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
int i,ret;
ret = synth_4to1(bandPtr,0,samples,pnt);
samples = samples + *pnt - 32;
samples = samples + *pnt - 16*sizeof(sample_t);
for(i=0;i<8;i++) {
((short *)samples)[1] = ((short *)samples)[0];
samples+=4;
((sample_t *)samples)[1] = ((sample_t *)samples)[0];
samples+=2*sizeof(sample_t);
}
return ret;
@@ -121,7 +130,7 @@ int synth_4to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
short *samples = (short *) (out + *pnt);
sample_t *samples = (sample_t *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;
@@ -232,7 +241,7 @@ int synth_4to1(real *bandPtr,int channel,unsigned char *out,int *pnt)
}
}
*pnt += 32;
*pnt += 16*sizeof(sample_t);
return clip;
}

View File

@@ -13,11 +13,7 @@
#include "config.h"
#include "mpg123.h"
#include "debug.h"
#define WRITE_SAMPLE(samples,sum,clip) \
if( (sum) > 32767.0) { *(samples) = 0x7fff; (clip)++; } \
else if( (sum) < -32768.0) { *(samples) = -0x8000; (clip)++; } \
else { *(samples) = sum; }
#include "decode.h"
#define NTOM_MUL (32768)
static unsigned long ntom_val[2] = { NTOM_MUL>>1,NTOM_MUL>>1 };
@@ -48,8 +44,8 @@ int synth_ntom_set_step(long m,long n)
int synth_ntom_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
{
short samples_tmp[8*64];
short *tmp1 = samples_tmp + channel;
sample_t samples_tmp[8*64];
sample_t *tmp1 = samples_tmp + channel;
int i,ret;
int pnt1 = 0;
@@ -57,7 +53,11 @@ int synth_ntom_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
samples += channel + *pnt;
for(i=0;i<(pnt1>>2);i++) {
#ifdef FLOATOUT
*samples = 0;
#else
*samples = conv16to8[*tmp1>>AUSHIFT];
#endif
samples += 2;
tmp1 += 2;
}
@@ -68,8 +68,8 @@ int synth_ntom_8bit(real *bandPtr,int channel,unsigned char *samples,int *pnt)
int synth_ntom_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[8*64];
short *tmp1 = samples_tmp;
sample_t samples_tmp[8*64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -77,7 +77,11 @@ int synth_ntom_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<(pnt1>>2);i++) {
#ifdef FLOATOUT
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += pnt1 >> 2;
@@ -87,8 +91,8 @@ int synth_ntom_8bit_mono(real *bandPtr,unsigned char *samples,int *pnt)
int synth_ntom_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[8*64];
short *tmp1 = samples_tmp;
sample_t samples_tmp[8*64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -96,8 +100,13 @@ int synth_ntom_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<(pnt1>>2);i++) {
#ifdef FLOATOUT
*samples++ = 0;
*samples++ = 0;
#else
*samples++ = conv16to8[*tmp1>>AUSHIFT];
*samples++ = conv16to8[*tmp1>>AUSHIFT];
#endif
tmp1 += 2;
}
*pnt += pnt1 >> 1;
@@ -107,8 +116,8 @@ int synth_ntom_8bit_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
int synth_ntom_mono(real *bandPtr,unsigned char *samples,int *pnt)
{
short samples_tmp[8*64];
short *tmp1 = samples_tmp;
sample_t samples_tmp[8*64];
sample_t *tmp1 = samples_tmp;
int i,ret;
int pnt1 = 0;
@@ -116,11 +125,11 @@ int synth_ntom_mono(real *bandPtr,unsigned char *samples,int *pnt)
samples += *pnt;
for(i=0;i<(pnt1>>2);i++) {
*( (short *)samples) = *tmp1;
samples += 2;
*( (sample_t *)samples) = *tmp1;
samples += sizeof(sample_t);
tmp1 += 2;
}
*pnt += pnt1 >> 1;
*pnt += (pnt1>>2)*sizeof(sample_t);
return ret;
}
@@ -135,8 +144,8 @@ int synth_ntom_mono2stereo(real *bandPtr,unsigned char *samples,int *pnt)
samples += pnt1;
for(i=0;i<((*pnt-pnt1)>>2);i++) {
((short *)samples)[1] = ((short *)samples)[0];
samples+=4;
((sample_t *)samples)[1] = ((sample_t *)samples)[0];
samples+=2*sizeof(sample_t);
}
return ret;
@@ -148,7 +157,7 @@ int synth_ntom(real *bandPtr,int channel,unsigned char *out,int *pnt)
static real buffs[2][2][0x110];
static const int step = 2;
static int bo = 1;
short *samples = (short *) (out + *pnt);
sample_t *samples = (sample_t *) (out + *pnt);
real *b0,(*buf)[0x110];
int clip = 0;

View File

@@ -71,6 +71,7 @@ int performoption (int argc, char *argv[], topt *opt)
debug1("int at %p", opt->var);
*( (int *) opt->var ) = (int) opt->value;
}
/* GLO_DOUBLE is not supported here */
else prog_error();
debug("casting assignment done");
@@ -90,6 +91,8 @@ int performoption (int argc, char *argv[], topt *opt)
*((long *) opt->var) = atol(loptarg);
else if(opt->flags & GLO_INT)
*((int *) opt->var) = atoi(loptarg);
else if(opt->flags & GLO_DOUBLE)
*((double *) opt->var) = atof(loptarg);
else prog_error();
}
else

View File

@@ -33,6 +33,7 @@ for .... no flag) */
#define GLO_CHAR 2
#define GLO_INT 4
#define GLO_LONG 8
#define GLO_DOUBLE 16
/* flags:
* bit 0 = 0 - no argument

View File

@@ -107,7 +107,7 @@ char *prgName = NULL;
char *equalfile = NULL;
/* ThOr: pointers are not TRUE or FALSE */
int have_eq_settings = FALSE;
long outscale = MAXOUTBURST;
scale_t outscale = MAXOUTBURST;
long numframes = -1;
long startFrame= 0;
int buffer_fd[2];
@@ -364,7 +364,11 @@ topt opts[] = {
{0, "speaker", 0, set_output_s, 0,0},
{0, "lineout", 0, set_output_l, 0,0},
{'o', "output", GLO_ARG | GLO_CHAR, set_output, 0, 0},
#ifdef FLOATOUT
{'f', "scale", GLO_ARG | GLO_DOUBLE, 0, &outscale, 0},
#else
{'f', "scale", GLO_ARG | GLO_LONG, 0, &outscale, 0},
#endif
{'n', "frames", GLO_ARG | GLO_LONG, 0, &numframes, 0},
#ifdef HAVE_TERMIOS
{'C', "control", GLO_INT, 0, &param.term_ctrl, TRUE},
@@ -1120,7 +1124,7 @@ static void usage(int err) /* print syntax & exit */
fprintf(o," -w <filename> write Output as WAV file\n");
fprintf(o," -k n skip first n frames [0] -n n decode only n frames [all]\n");
fprintf(o," -c check range violations -y DISABLE resync on errors\n");
fprintf(o," -b n output buffer: n Kbytes [0] -f n change scalefactor [32768]\n");
fprintf(o," -b n output buffer: n Kbytes [0] -f n change scalefactor [%g]\n", (double)outscale);
fprintf(o," -r n set/force samplerate [auto] -g n set audio hardware output gain\n");
fprintf(o," -os,-ol,-oh output to built-in speaker,line-out connector,headphones\n");
#ifdef NAS
@@ -1187,7 +1191,7 @@ static void long_usage(int err)
fprintf(o," --cdr <f> write samples as CDR file in <f> (- is stdout)\n");
fprintf(o," --reopen force close/open on audiodevice\n");
fprintf(o," -g --gain set audio hardware output gain\n");
fprintf(o," -f <n> --scale <n> scale output samples (soft gain, default=%li)\n", outscale);
fprintf(o," -f <n> --scale <n> scale output samples (soft gain, default=%g)\n", (double)outscale);
fprintf(o," --rva-mix,\n");
fprintf(o," --rva-radio use RVA2/ReplayGain values for mix/radio mode\n");
fprintf(o," --rva-album,\n");

View File

@@ -138,8 +138,15 @@ typedef unsigned char byte;
#define MPG_MD_DUAL_CHANNEL 2
#define MPG_MD_MONO 3
/* float output only for generic decoder! */
#ifdef FLOATOUT
#define MAXOUTBURST 1.0
#define scale_t double
#else
/* I suspect that 32767 would be a better idea here, but Michael put this in... */
#define MAXOUTBURST 32768
#define scale_t long
#endif
/* Pre Shift fo 16 to 8 bit converter table */
#define AUSHIFT (3)
@@ -417,7 +424,7 @@ extern struct parameter param;
/* avoid the SIGINT in terminal control */
void next_track(void);
extern long outscale;
extern scale_t outscale;
#include "optimize.h"

View File

@@ -34,7 +34,7 @@ typedef int (*func_synth_pent)(real *,int,unsigned char *);
/* last headaches about getting mmx hardcode out */
real init_layer3_gainpow2(int i);
real* init_layer2_table(real *table, double m);
void make_decode_tables(long scale);
void make_decode_tables(scale_t scaleval);
/* only 3dnow replaces that one, it's internal to layer3.c otherwise */
void dct36(real *,real *,real *,real *,real *);

View File

@@ -60,7 +60,7 @@ static long intwinbase[] = {
64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835,
73415, 73908, 74313, 74630, 74856, 74992, 75038 };
void make_decode_tables(long scaleval)
void make_decode_tables(scale_t scaleval)
{
int i,j,k,kr,divv;
real *costab;

View File

@@ -20,13 +20,20 @@
#include "mpg123.h"
#include "debug.h"
#ifdef FLOATOUT
#define WAVE_FORMAT 3
#else
#define WAVE_FORMAT 1
#endif
struct
{
byte riffheader[4];
byte WAVElen[4];
byte WAVElen[4]; /* should this include riffheader or not? */
struct
{
byte fmtheader[8];
byte WAVEID[4];
byte fmtheader[4];
byte fmtlen[4];
struct
{
@@ -36,7 +43,18 @@ struct
byte AvgBytesPerSec[4];
byte BlockAlign[2];
byte BitsPerSample[2]; /* format specific for PCM */
#ifdef FLOATOUT
byte cbSize[2];
#endif
} fmt;
#ifdef FLOATOUT
byte factheader[4];
byte factlen[4];
struct
{
byte samplelen[4];
} fact;
#endif
struct
{
byte dataheader[4];
@@ -45,9 +63,26 @@ struct
} data;
} WAVE;
} RIFF =
{ { 'R','I','F','F' } , { sizeof(RIFF.WAVE),0,0,0 } ,
{ { 'W','A','V','E','f','m','t',' ' } , { sizeof(RIFF.WAVE.fmt),0,0,0} ,
{ {1,0} , {0,0},{0,0,0,0},{0,0,0,0},{0,0},{0,0} } ,
{
{ 'R','I','F','F' } ,
{ sizeof(RIFF.WAVE),0,0,0 } ,
{
{ 'W','A','V','E' },
{ 'f','m','t',' ' },
{ sizeof(RIFF.WAVE.fmt),0,0,0 } ,
{
{WAVE_FORMAT,0} , {0,0},{0,0,0,0},{0,0,0,0},{0,0},{0,0}
#ifdef FLOATOUT
,{0,0}
#endif
} ,
#ifdef FLOATOUT
{ 'f','a','c','t' },
{ sizeof(RIFF.WAVE.fact),0,0,0 },
{
{0,0,0,0} /* to be filled later, like datalen and wavelen */
},
#endif
{ { 'd','a','t','a' } , {0,0,0,0} }
}
};
@@ -90,6 +125,15 @@ static void long2bigendian(long inval,byte *outval,int b)
}
}
static long from_little(byte *inval, int b)
{
long ret = 0;
int i;
for(i=0;i<b;++i) ret += ((long)inval[i])<<(i*8);
return ret;
}
static int testEndian(void)
{
long i,a=0,b=0,c=0;
@@ -129,6 +173,10 @@ static int open_file(char *filename)
int au_open(struct audio_info_struct *ai, char *aufilename)
{
#ifdef FLOATOUT
error("AU file support for float values not there yet");
return -1;
#else
flipendian = 0;
switch(ai->format) {
@@ -161,10 +209,15 @@ int au_open(struct audio_info_struct *ai, char *aufilename)
datalen = 0;
return 0;
#endif
}
int cdr_open(struct audio_info_struct *ai, char *cdrfilename)
{
#ifdef FLOATOUT
error("refusing to produce cdr file with float values");
return -1;
#else
param.force_stereo = 0;
ai->format = AUDIO_FORMAT_SIGNED_16;
ai->rate = 44100;
@@ -182,6 +235,7 @@ int cdr_open(struct audio_info_struct *ai, char *cdrfilename)
return -1;
return 0;
#endif
}
int wav_open(struct audio_info_struct *ai, char *wavfilename)
@@ -191,8 +245,11 @@ int wav_open(struct audio_info_struct *ai, char *wavfilename)
flipendian = 0;
/* standard MS PCM, and its format specific is BitsPerSample */
long2littleendian(1,RIFF.WAVE.fmt.FormatTag,sizeof(RIFF.WAVE.fmt.FormatTag));
long2littleendian(WAVE_FORMAT,RIFF.WAVE.fmt.FormatTag,sizeof(RIFF.WAVE.fmt.FormatTag));
#ifdef FLOATOUT
long2littleendian(bps=32,RIFF.WAVE.fmt.BitsPerSample,sizeof(RIFF.WAVE.fmt.BitsPerSample));
flipendian = testEndian();
#else
if(ai->format == AUDIO_FORMAT_SIGNED_16) {
long2littleendian(bps=16,RIFF.WAVE.fmt.BitsPerSample,sizeof(RIFF.WAVE.fmt.BitsPerSample));
flipendian = testEndian();
@@ -204,6 +261,7 @@ int wav_open(struct audio_info_struct *ai, char *wavfilename)
error("Format not supported.");
return -1;
}
#endif
if(ai->rate < 0) ai->rate = 44100;
@@ -235,6 +293,20 @@ int wav_write(unsigned char *buf,int len)
return 0;
if(flipendian) {
#ifdef FLOATOUT
if(len & 3)
{
error("Number of bytes no multiple of 4 (32bit)!");
return 0;
}
for(i=0;i<len;i+=4)
{
int j;
unsigned char tmp[4];
for(j = 0; j<=3; ++j) tmp[j] = buf[i+j];
for(j = 0; j<=3; ++j) buf[i+j] = tmp[3-j];
}
#else
if(len & 1) {
error("Odd number of bytes!");
return 0;
@@ -245,6 +317,7 @@ int wav_write(unsigned char *buf,int len)
buf[i+0] = buf[i+1];
buf[i+1] = tmp;
}
#endif
}
temp = fwrite(buf, 1, len, wavfp);
@@ -264,6 +337,10 @@ int wav_close(void)
if(fseek(wavfp, 0L, SEEK_SET) >= 0) {
long2littleendian(datalen,RIFF.WAVE.data.datalen,sizeof(RIFF.WAVE.data.datalen));
long2littleendian(datalen+sizeof(RIFF.WAVE),RIFF.WAVElen,sizeof(RIFF.WAVElen));
#ifdef FLOATOUT
long2littleendian(datalen/(from_little(RIFF.WAVE.fmt.Channels,2)*from_little(RIFF.WAVE.fmt.BitsPerSample,2)/8),
RIFF.WAVE.fact.samplelen,sizeof(RIFF.WAVE.fact.samplelen));
#endif
fwrite(&RIFF, sizeof(RIFF),1,wavfp);
}
else {