dslinux/user/pixil/apps/fltk/mp3/mpegsound Book_Purchase_Form.DOC Makefile Makefile.am Makefile.in bitwindow.cc fileinput.cc fileplayer.cc filter.cc filter_2.cc fixed_point.h httpinput.cc huffmantable.cc mpeglayer1.cc mpeglayer2.cc mpeglayer3.cc mpeglayer3mktables.cc mpeglayer3tables.h mpegsound.h mpegsound_locals.h mpegtable.cc mpegtoraw.cc rawplayer.cc rawtofile.cc soundinputstream.cc soundplayer.cc wavetoraw.cc
amadeus
dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:24:27 CEST 2006
Update of /cvsroot/dslinux/dslinux/user/pixil/apps/fltk/mp3/mpegsound
In directory antilope:/tmp/cvs-serv11916/apps/fltk/mp3/mpegsound
Added Files:
Book_Purchase_Form.DOC Makefile Makefile.am Makefile.in
bitwindow.cc fileinput.cc fileplayer.cc filter.cc filter_2.cc
fixed_point.h httpinput.cc huffmantable.cc mpeglayer1.cc
mpeglayer2.cc mpeglayer3.cc mpeglayer3mktables.cc
mpeglayer3tables.h mpegsound.h mpegsound_locals.h mpegtable.cc
mpegtoraw.cc rawplayer.cc rawtofile.cc soundinputstream.cc
soundplayer.cc wavetoraw.cc
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it
--- NEW FILE: mpeglayer3tables.h ---
// mpeglayer3tables.h
// It is included by mpeglayer3.cc
// This file was generated using mpeglayer3mktables.cc
// Do not edit this file but mpeglayer3mktables.cc instead
#include <values.h>
#ifndef FIXED_POINT
#define X( x ) (x)
#define inf MAXFLOAT
#define Inf MAXFLOAT
#else
#define inf MAXINT
#define Inf MAXINT
#endif
#ifdef FIXED_POINT
[...4671 lines suppressed...]
X(164280.826200210), X(164307.670020720), X(164334.514937679),
X(164361.360950997),
X(164388.208060586), X(164415.056266355), X(164441.905568216),
X(164468.755966078),
X(164495.607459853), X(164522.460049450), X(164549.313734781),
X(164576.168515756),
X(164603.024392285), X(164629.881364280), X(164656.739431650),
X(164683.598594307),
X(164710.458852161), X(164737.320205122), X(164764.182653103),
X(164791.046196012),
X(164817.910833762), X(164844.776566263), X(164871.643393425),
X(164898.511315159),
X(164925.380331377), X(164952.250441989), X(164979.121646906),
X(165005.993946038),
X(165032.867339298), X(165059.741826595), X(165086.617407840),
X(165113.494082945)
};
#define cos1_6 0.866025403784439
#define cos2_6 0.500000000000000
--- NEW FILE: mpeglayer1.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Mpeglayer1.cc
// It's for MPEG Layer 1
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegsound.h"
#ifndef FIXED_POINT
#define X( x ) (x)
#else
#define X( x ) {FL2FIX( x, FIXED_POINT_FRACBITS )}
#endif
// Tables for layer 1
static const REAL factortable[15] = {
X(0.0),
X((1.0 / 2.0) * (4.0 / 3.0)), X((1.0 / 4.0) * (8.0 / 7.0)),
X((1.0 / 8.0) * (16.0 / 15.0)), X((1.0 / 16.0) * (32.0 / 31.0)),
X((1.0 / 32.0) * (64.0 / 63.0)), X((1.0 / 64.0) * (128.0 / 127.0)),
X((1.0 / 128.0) * (256.0 / 255.0)), X((1.0 / 256.0) * (512.0 / 511.0)),
X((1.0 / 512.0) * (1024.0 / 1023.0)),
X((1.0 / 1024.0) * (2048.0 / 2047.0)),
X((1.0 / 2048.0) * (4096.0 / 4095.0)),
X((1.0 / 4096.0) * (8192.0 / 8191.0)),
X((1.0 / 8192.0) * (16384.0 / 16383.0)),
X((1.0 / 16384.0) * (32768.0 / 32767.0))
};
static const REAL offsettable[15] = {
X(0.0),
X(((1.0 / 2.0) - 1.0) * (4.0 / 3.0)),
X(((1.0 / 4.0) - 1.0) * (8.0 / 7.0)),
X(((1.0 / 8.0) - 1.0) * (16.0 / 15.0)),
X(((1.0 / 16.0) - 1.0) * (32.0 / 31.0)),
X(((1.0 / 32.0) - 1.0) * (64.0 / 63.0)),
X(((1.0 / 64.0) - 1.0) * (128.0 / 127.0)),
X(((1.0 / 128.0) - 1.0) * (256.0 / 255.0)),
X(((1.0 / 256.0) - 1.0) * (512.0 / 511.0)),
X(((1.0 / 512.0) - 1.0) * (1024.0 / 1023.0)),
X(((1.0 / 1024.0) - 1.0) * (2048.0 / 2047.0)),
X(((1.0 / 2048.0) - 1.0) * (4096.0 / 4095.0)),
X(((1.0 / 4096.0) - 1.0) * (8192.0 / 8191.0)),
X(((1.0 / 8192.0) - 1.0) * (16384.0 / 16383.0)),
X(((1.0 / 16384.0) - 1.0) * (32768.0 / 32767.0))
};
// Mpeg layer 1
void
Mpegtoraw::extractlayer1(void)
{
REAL fraction[MAXCHANNEL][MAXSUBBAND];
REAL scalefactor[MAXCHANNEL][MAXSUBBAND];
int bitalloc[MAXCHANNEL][MAXSUBBAND], sample[MAXCHANNEL][MAXSUBBAND];
register int i, j;
int s = stereobound, l;
// Bitalloc
for (i = 0; i < s; i++) {
bitalloc[LS][i] = getbits(4);
bitalloc[RS][i] = getbits(4);
}
for (; i < MAXSUBBAND; i++)
bitalloc[LS][i] = bitalloc[RS][i] = getbits(4);
// Scale index
if (inputstereo)
for (i = 0; i < MAXSUBBAND; i++) {
if (bitalloc[LS][i])
scalefactor[LS][i] = scalefactorstable[getbits(6)];
if (bitalloc[RS][i])
scalefactor[RS][i] = scalefactorstable[getbits(6)];
} else
for (i = 0; i < MAXSUBBAND; i++)
if (bitalloc[LS][i])
scalefactor[LS][i] = scalefactorstable[getbits(6)];
for (l = 0; l < SCALEBLOCK; l++) {
// Sample
for (i = 0; i < s; i++) {
if ((j = bitalloc[LS][i]))
sample[LS][i] = getbits(j + 1);
if ((j = bitalloc[RS][i]))
sample[RS][i] = getbits(j + 1);
}
for (; i < MAXSUBBAND; i++)
if ((j = bitalloc[LS][i]))
sample[LS][i] = sample[RS][i] = getbits(j + 1);
// Fraction
if (outputstereo)
for (i = 0; i < MAXSUBBAND; i++) {
if ((j = bitalloc[LS][i]))
fraction[LS][i] =
(sample[LS][i] * factortable[j] + offsettable[j])
* scalefactor[LS][i];
else
fraction[LS][i] = 0.0;
if ((j = bitalloc[RS][i]))
fraction[RS][i] =
(sample[RS][i] * factortable[j] + offsettable[j])
* scalefactor[RS][i];
else
fraction[RS][i] = 0.0;
} else
for (i = 0; i < MAXSUBBAND; i++)
if ((j = bitalloc[LS][i]))
fraction[LS][i] =
(sample[LS][i] * factortable[j] + offsettable[j])
* scalefactor[LS][i];
else
fraction[LS][i] = 0.0;
subbandsynthesis(fraction[LS], fraction[RS]);
}
}
--- NEW FILE: Makefile ---
# apps/mp3/mpegsound/Makefile
LIB_STATIC=libmpeg.a
SRC= soundinputstream.cc fileinput.cc httpinput.cc \
soundplayer.cc rawplayer.cc rawtofile.cc \
mpegtable.cc filter.cc filter_2.cc \
mpegtoraw.cc mpeglayer1.cc mpeglayer2.cc \
mpeglayer3.cc bitwindow.cc huffmantable.cc \
wavetoraw.cc fileplayer.cc
OBJS=${SRC:.cc=.o}
CFLAGS ?=
ifeq ($(CONFIG_MP3_USE_PTHREAD),y)
CFLAGS += -DPTHREADEDMPEG
endif
ifeq ($(CROSS_COMPILE),y)
CFLAGS += -fpermissive
endif
include $(BASE_DIR)/Rules.make
--- NEW FILE: mpegsound.h ---
#define FIXED_POINT
/* MPEG/WAVE Sound library
(C) 1997 by Woo-jae Jung */
// Mpegsound.h
// This is typeset for functions in MPEG/WAVE Sound library.
// Now, it's for only linux-pc-?86
/* Added for Pixil. This is stupid, so somebody fix it */
#define HAVE_PTHREAD_H
/************************************/
/* Include default library packages */
/************************************/
#include <stdio.h>
#include <sys/types.h>
#ifdef PTHREADEDMPEG
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#else
#ifdef HAVE_PTHREAD_MIT_PTHREAD_H
#include <pthread/mit/pthread.h>
#endif
#endif
#endif
#ifndef _L__SOUND__
#define _L__SOUND__
/****************/
/* Sound Errors */
/****************/
// General error
#define SOUND_ERROR_OK 0
#define SOUND_ERROR_FINISH -1
// Device error (for player)
#define SOUND_ERROR_DEVOPENFAIL 1
#define SOUND_ERROR_DEVBUSY 2
#define SOUND_ERROR_DEVBADBUFFERSIZE 3
#define SOUND_ERROR_DEVCTRLERROR 4
// Sound file (for reader)
#define SOUND_ERROR_FILEOPENFAIL 5
#define SOUND_ERROR_FILEREADFAIL 6
// Network
#define SOUND_ERROR_UNKNOWNPROXY 7
#define SOUND_ERROR_UNKNOWNHOST 8
#define SOUND_ERROR_SOCKET 9
#define SOUND_ERROR_CONNECT 10
#define SOUND_ERROR_FDOPEN 11
#define SOUND_ERROR_HTTPFAIL 12
#define SOUND_ERROR_HTTPWRITEFAIL 13
#define SOUND_ERROR_TOOMANYRELOC 14
// Miscellneous (for translater)
#define SOUND_ERROR_MEMORYNOTENOUGH 15
#define SOUND_ERROR_EOF 16
#define SOUND_ERROR_BAD 17
#define SOUND_ERROR_THREADFAIL 18
#define SOUND_ERROR_UNKNOWN 19
/**************************/
/* Define values for MPEG */
/**************************/
#define SCALEBLOCK 12
#define CALCBUFFERSIZE 512
#define MAXSUBBAND 32
#define MAXCHANNEL 2
#define SCALE 32768
#define MAXSCALE (SCALE-1)
#define MINSCALE (-SCALE)
#define RAWDATASIZE (2*2*32*SSLIMIT)
#define LS 0
#define RS 1
#define SSLIMIT 18
#define SBLIMIT 32
#define WINDOWSIZE 4096
// Huffmancode
#define HTN 34
/*******************************************/
/* Define values for Microsoft WAVE format */
/*******************************************/
#define RIFF 0x46464952
#define WAVE 0x45564157
#define FMT 0x20746D66
#define DATA 0x61746164
#define PCM_CODE 1
#define WAVE_MONO 1
#define WAVE_STEREO 2
#define MODE_MONO 0
#define MODE_STEREO 1
/********************/
/* Type definitions */
/********************/
#ifndef FIXED_POINT
typedef float REAL;
typedef float REAL13;
typedef float REAL19;
#else
#include "fixed_point.h"
#endif
typedef struct _waveheader
{
u_int32_t main_chunk; // 'RIFF'
u_int32_t length; // filelen
u_int32_t chunk_type; // 'WAVE'
u_int32_t sub_chunk; // 'fmt '
u_int32_t sc_len; // length of sub_chunk, =16
u_int16_t format; // should be 1 for PCM-code
u_int16_t modus; // 1 Mono, 2 Stereo
u_int32_t sample_fq; // frequence of sample
u_int32_t byte_p_sec;
u_int16_t byte_p_spl; // samplesize; 1 or 2 bytes
u_int16_t bit_p_spl; // 8, 12 or 16 bit
u_int32_t data_chunk; // 'data'
u_int32_t data_length; // samplecount
}
WAVEHEADER;
typedef struct
{
bool generalflag;
unsigned int part2_3_length;
unsigned int big_values;
unsigned int global_gain;
unsigned int scalefac_compress;
unsigned int window_switching_flag;
unsigned int block_type;
unsigned int mixed_block_flag;
unsigned int table_select[3];
unsigned int subblock_gain[3];
unsigned int region0_count;
unsigned int region1_count;
unsigned int preflag;
unsigned int scalefac_scale;
unsigned int count1table_select;
}
layer3grinfo;
typedef struct
{
unsigned main_data_begin;
unsigned private_bits;
struct
{
unsigned scfsi[4];
layer3grinfo gr[2];
}
ch[2];
}
layer3sideinfo;
typedef struct
{
int l[23]; /* [cb] */
int s[3][13]; /* [window][cb] */
}
layer3scalefactor; /* [ch] */
typedef struct
{
int tablename;
unsigned int xlen, ylen;
unsigned int linbits;
unsigned int treelen;
const unsigned int (*val)[2];
}
HUFFMANCODETABLE;
/*********************************/
/* Sound input interface classes */
/*********************************/
// Superclass for Inputbitstream // Yet, Temporary
class Soundinputstream
{
public:
Soundinputstream();
virtual ~ Soundinputstream();
static Soundinputstream *hopen(char *filename, int *errcode);
int geterrorcode(void)
{
return __errorcode;
};
virtual bool open(char *filename) = 0;
virtual int getbytedirect(void) = 0;
virtual bool _readbuffer(char *buffer, int size) = 0;
virtual bool eof(void) = 0;
virtual int getblock(char *buffer, int size) = 0;
virtual int getsize(void) = 0;
virtual int getposition(void) = 0;
virtual void setposition(int pos) = 0;
protected:
void seterrorcode(int errorcode)
{
__errorcode = errorcode;
};
private:
int __errorcode;
};
// Inputstream from file
class Soundinputstreamfromfile:public Soundinputstream
{
public:
Soundinputstreamfromfile()
{
fp = NULL;
};
~Soundinputstreamfromfile();
bool open(char *filename);
bool _readbuffer(char *buffer, int bytes);
int getbytedirect(void);
bool eof(void);
int getblock(char *buffer, int size);
int getsize(void);
int getposition(void);
void setposition(int pos);
private:
FILE * fp;
int size;
};
// Inputstream from http
class Soundinputstreamfromhttp:public Soundinputstream
{
public:
Soundinputstreamfromhttp();
~Soundinputstreamfromhttp();
bool open(char *filename);
bool _readbuffer(char *buffer, int bytes);
int getbytedirect(void);
bool eof(void);
int getblock(char *buffer, int size);
int getsize(void);
int getposition(void);
void setposition(int pos);
private:
FILE * fp;
int size;
bool writestring(int fd, char *string);
bool readstring(char *string, int maxlen, FILE * f);
FILE *http_open(char *url);
};
/**********************************/
/* Sound player interface classes */
/**********************************/
// Superclass for player
class Soundplayer
{
public:
Soundplayer()
{
__errorcode = SOUND_ERROR_OK;
};
virtual ~ Soundplayer();
virtual bool initialize(char *filename) = 0;
virtual void abort(void);
virtual int getprocessed(void);
virtual bool setsoundtype(int stereo, int samplesize, int speed) = 0;
virtual bool resetsoundtype(void);
virtual bool putblock(void *buffer, int size) = 0;
virtual int getblocksize(void);
int geterrorcode(void)
{
return __errorcode;
};
protected:
bool seterrorcode(int errorno) {
__errorcode = errorno;
return false;
};
private:
int __errorcode;
};
class Rawtofile:public Soundplayer
{
public:
~Rawtofile();
bool initialize(char *filename);
bool setsoundtype(int stereo, int samplesize, int speed);
bool putblock(void *buffer, int size);
private:
int filehandle;
int rawstereo, rawsamplesize, rawspeed;
};
// Class for playing raw data
class Rawplayer:public Soundplayer
{
public:
~Rawplayer();
bool initialize(char *filename);
void abort(void);
int getprocessed(void);
bool setsoundtype(int stereo, int samplesize, int speed);
bool resetsoundtype(void);
bool putblock(void *buffer, int size);
int getblocksize(void);
void setquota(int q)
{
quota = q;
};
int getquota(void)
{
return quota;
};
static char *defaultdevice;
static int setvolume(int volume);
private:
short int rawbuffer[RAWDATASIZE];
int rawbuffersize;
int audiohandle, audiobuffersize;
int rawstereo, rawsamplesize, rawspeed;
bool forcetomono, forceto8;
int quota;
};
/*********************************/
/* Data format converter classes */
/*********************************/
// Class for converting wave format to raw format
class Wavetoraw
{
public:
Wavetoraw(Soundinputstream * loader, Soundplayer * player);
~Wavetoraw();
bool initialize(void);
void setforcetomono(bool flag)
{
forcetomonoflag = flag;
};
bool run(void);
int getfrequency(void) const
{
return speed;
};
bool isstereo(void) const
{
return stereo;
};
int getsamplesize(void) const
{
return samplesize;
};
int geterrorcode(void) const
{
return __errorcode;
};
int gettotallength(void) const
{
return size / pcmsize;
};
int getcurrentpoint(void) const
{
return currentpoint / pcmsize;
};
void setcurrentpoint(int p);
private:
int __errorcode;
void seterrorcode(int errorcode)
{
__errorcode = errorcode;
};
bool forcetomonoflag;
Soundinputstream *loader;
Soundplayer *player;
bool initialized;
char *buffer;
int buffersize;
int samplesize, speed, stereo;
int currentpoint, size;
int pcmsize;
bool testwave(char *buffer);
};
// Class for Mpeg layer3
class Mpegbitwindow
{
public:
Mpegbitwindow()
{
bitindex = point = 0;
};
void initialize(void)
{
bitindex = point = 0;
};
int gettotalbit(void) const
{
return bitindex;
};
void putbyte(int c)
{
buffer[point & (WINDOWSIZE - 1)] = c;
point++;
};
void wrap(void);
void rewind(int bits)
{
bitindex -= bits;
};
void forward(int bits)
{
bitindex += bits;
};
int getbit(void);
int getbits9(int bits);
int getbits(int bits);
private:
int point, bitindex;
char buffer[2 * WINDOWSIZE];
};
// Class for converting mpeg format to raw format
class Mpegtoraw
{
/*****************************/
/* Constant tables for layer */
/*****************************/
private:
static const int bitrate[2][3][15], frequencies[2][3];
static const REAL scalefactorstable[64];
static const HUFFMANCODETABLE ht[HTN];
static const REAL filter[512];
static const REAL hcos_64[16], hcos_32[8], hcos_16[4], hcos_8[2], hcos_4;
/*************************/
/* MPEG header variables */
/*************************/
private:
int layer, protection, bitrateindex, padding, extendedmode;
enum _mpegversion
{ mpeg1, mpeg2 }
version;
enum _mode
{ fullstereo, joint, dual, single }
mode;
enum _frequency
{ frequency44100, frequency48000, frequency32000 }
frequency;
/*******************************************/
/* Functions getting MPEG header variables */
/*******************************************/
public:
// General
int getversion(void) const
{
return version;
};
int getlayer(void) const
{
return layer;
};
bool getcrccheck(void) const
{
return (!protection);
};
// Stereo or not
int getmode(void) const
{
return mode;
};
bool isstereo(void) const
{
return (getmode() != single);
};
// Frequency and bitrate
int getfrequency(void) const
{
return frequencies[version][frequency];
};
int getbitrate(void) const
{
return bitrate[version][layer - 1][bitrateindex];
};
/***************************************/
/* Interface for setting music quality */
/***************************************/
private:
bool forcetomonoflag;
int downfrequency;
public:
void setforcetomono(bool flag);
void setdownfrequency(int value);
/******************************************/
/* Functions getting other MPEG variables */
/******************************************/
public:
bool getforcetomono(void);
int getdownfrequency(void);
int getpcmperframe(void);
/******************************/
/* Frame management variables */
/******************************/
private:
int currentframe, totalframe;
int decodeframe;
int *frameoffsets;
/******************************/
/* Frame management functions */
/******************************/
public:
int getcurrentframe(void) const
{
return currentframe;
};
int gettotalframe(void) const
{
return totalframe;
};
void setframe(int framenumber);
/***************************************/
/* Variables made by MPEG-Audio header */
/***************************************/
private:
int tableindex, channelbitrate;
int stereobound, subbandnumber, inputstereo, outputstereo;
REAL scalefactor;
int framesize;
/********************/
/* Song information */
/********************/
private:
struct
{
char name[30 + 1];
char artist[30 + 1];
char album[30 + 1];
char year[4 + 1];
char comment[30 + 1];
// char type ;
}
songinfo;
/* Song information functions */
public:
const char *getname(void) const
{
return (const char *) songinfo.name;
};
const char *getartist(void) const
{
return (const char *) songinfo.artist;
};
const char *getalbum(void) const
{
return (const char *) songinfo.album;
};
const char *getyear(void) const
{
return (const char *) songinfo.year;
};
const char *getcomment(void) const
{
return (const char *) songinfo.comment;
};
/*******************/
/* Mpegtoraw class */
/*******************/
public:
Mpegtoraw(Soundinputstream * loader, Soundplayer * player);
~Mpegtoraw();
void initialize(char *filename);
bool run(int frames);
int geterrorcode(void)
{
return __errorcode;
};
void clearbuffer(void);
private:
int __errorcode;
bool seterrorcode(int errorno)
{
__errorcode = errorno;
return false;
};
/*****************************/
/* Loading MPEG-Audio stream */
/*****************************/
private:
Soundinputstream * loader; // Interface
union
{
unsigned char store[4];
unsigned int current;
}
u;
char buffer[4096];
int bitindex;
bool fillbuffer(int size)
{
bitindex = 0;
return loader->_readbuffer(buffer, size);
};
void sync(void)
{
bitindex = (bitindex + 7) & 0xFFFFFFF8;
};
bool issync(void)
{
return (bitindex & 7);
};
int getbyte(void);
int getbits(int bits);
int getbits9(int bits);
int getbits8(void);
int getbit(void);
/********************/
/* Global variables */
/********************/
private:
int lastfrequency, laststereo;
// for Layer3
int layer3slots, layer3framestart, layer3part2start;
REAL prevblck[2][2][SBLIMIT][SSLIMIT];
int currentprevblock;
layer3sideinfo sideinfo;
layer3scalefactor scalefactors[2];
Mpegbitwindow bitwindow;
int wgetbit(void);
int wgetbits9(int bits);
int wgetbits(int bits);
/*************************************/
/* Decoding functions for each layer */
/*************************************/
private:
bool loadheader(void);
//
// Subbandsynthesis
//
REAL calcbufferL[2][CALCBUFFERSIZE], calcbufferR[2][CALCBUFFERSIZE];
int currentcalcbuffer, calcbufferoffset;
void computebuffer(REAL * fraction, REAL buffer[2][CALCBUFFERSIZE]);
void generatesingle(void);
void generate(void);
void subbandsynthesis(REAL * fractionL, REAL * fractionR);
void computebuffer_2(REAL * fraction, REAL buffer[2][CALCBUFFERSIZE]);
void generatesingle_2(void);
void generate_2(void);
void subbandsynthesis_2(REAL * fractionL, REAL * fractionR);
// Extractor
void extractlayer1(void); // MPEG-1
void extractlayer2(void);
void extractlayer3(void);
void extractlayer3_2(void); // MPEG-2
// Functions for layer 3
void layer3initialize(void);
bool layer3getsideinfo(void);
bool layer3getsideinfo_2(void);
void layer3getscalefactors(int ch, int gr);
void layer3getscalefactors_2(int ch);
void layer3huffmandecode(int ch, int gr, int out[SBLIMIT][SSLIMIT]);
REAL layer3twopow2(int scale, int preflag, int pretab_offset, int l);
REAL layer3twopow2_1(int a, int b, int c);
void layer3dequantizesample(int ch, int gr, int in[SBLIMIT][SSLIMIT],
REAL out[SBLIMIT][SSLIMIT]);
void layer3fixtostereo(int gr, REAL in[2][SBLIMIT][SSLIMIT]);
void layer3reorderandantialias(int ch, int gr, REAL in[SBLIMIT][SSLIMIT],
REAL out[SBLIMIT][SSLIMIT]);
void layer3hybrid(int ch, int gr, REAL in[SBLIMIT][SSLIMIT],
REAL out[SSLIMIT][SBLIMIT]);
void huffmandecoder_1(const HUFFMANCODETABLE * h, int *x, int *y);
void huffmandecoder_2(const HUFFMANCODETABLE * h, int *x, int *y, int *v,
int *w);
/********************/
/* Playing raw data */
/********************/
private:
Soundplayer * player; // General playing interface
int rawdataoffset;
short int rawdata[RAWDATASIZE];
void clearrawdata(void)
{
rawdataoffset = 0;
};
void putraw(short int pcm)
{
rawdata[rawdataoffset++] = pcm;
};
void flushrawdata(void);
public:
void *GetRawData()
{
return (void *) rawdata;
};
/***************************/
/* Interface for threading */
/***************************/
#ifdef PTHREADEDMPEG
private:
struct
{
short int *buffer;
int framenumber, frametail;
int head, tail;
int *sizes;
}
threadqueue;
struct
{
bool thread;
bool quit, done;
bool pause;
bool criticallock, criticalflag;
}
threadflags;
pthread_t thread;
public:
void threadedplayer(void);
bool makethreadedplayer(int framenumbers);
void freethreadedplayer(void);
void stopthreadedplayer(void);
void pausethreadedplayer(void);
void unpausethreadedplayer(void);
bool existthread(void);
int getframesaved(void);
#endif
};
/***********************/
/* File player classes */
/***********************/
// Superclass for playing file
class Fileplayer
{
public:
Fileplayer();
virtual ~ Fileplayer();
int geterrorcode(void)
{
return __errorcode;
};
virtual bool openfile(char *filename, char *device) = 0;
virtual void setforcetomono(bool flag) = 0;
virtual bool playing(int verbose) = 0;
protected:
bool seterrorcode(int errorno)
{
__errorcode = errorno;
return false;
};
Soundplayer *player;
private:
int __errorcode;
};
// Class for playing wave file
class Wavefileplayer:public Fileplayer
{
public:
Wavefileplayer();
~Wavefileplayer();
bool openfile(char *filename, char *device);
void setforcetomono(bool flag);
bool playing(int verbose);
private:
Soundinputstream * loader;
Wavetoraw *server;
};
// Class for playing MPEG file
class Mpegfileplayer:public Fileplayer
{
public:
Mpegfileplayer();
~Mpegfileplayer();
bool openfile(char *filename, char *device);
void setforcetomono(bool flag);
void setdownfrequency(int value);
bool playing(int verbose);
#if PTHREADEDMPEG
bool playingwiththread(int verbose, int framenumbers);
#endif
private:
Soundinputstream * loader;
Mpegtoraw *server;
void showverbose(int verbose);
};
typedef struct
{
char songname[1024];
char artist[1024];
char album[1024];
char year[1024];
char comment[1024];
}
ID3;
void parseID3(Soundinputstream *, ID3 *);
#endif
--- NEW FILE: fileplayer.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Fileplayer.cc
// It's an example for how to use MPEG/WAVE Sound library
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "mpegsound.h"
// File player superclass
Fileplayer::Fileplayer()
{
__errorcode = SOUND_ERROR_OK;
player = NULL;
};
Fileplayer::~Fileplayer()
{
delete player;
};
// Wave file player
Wavefileplayer::Wavefileplayer()
{
loader = NULL;
server = NULL;
}
Wavefileplayer::~Wavefileplayer()
{
if (loader)
delete loader;
if (server)
delete server;
}
bool
Wavefileplayer::openfile(char *filename, char *device)
{
// Player
if (device == NULL)
device = Rawplayer::defaultdevice;
if (device[0] == '/')
player = new Rawplayer;
else {
if (device[0] == '-')
device = NULL;
player = new Rawtofile;
}
if (player == NULL)
return seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
if (!player->initialize(device))
return seterrorcode(player->geterrorcode());
// Loader
{
int err;
if ((loader = Soundinputstream::hopen(filename, &err)) == NULL)
return seterrorcode(err);
}
// Server
if ((server = new Wavetoraw(loader, player)) == NULL)
return seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
return server->initialize();
}
void
Wavefileplayer::setforcetomono(bool flag)
{
server->setforcetomono(flag);
};
bool
Wavefileplayer::playing(int verbose)
{
if (!server->run())
return false; // Read first time
if (verbose > 0) {
fprintf(stderr,
"Verbose : %dbits, "
"%dHz, "
"%s\n",
server->getsamplesize(),
server->getfrequency(),
server->isstereo()? "Stereo" : "Mono");
}
while (server->run()); // Playing
seterrorcode(server->geterrorcode());
if (geterrorcode() == SOUND_ERROR_FINISH)
return true;
return false;
}
// Mpegfileplayer
Mpegfileplayer::Mpegfileplayer()
{
loader = NULL;
server = NULL;
};
Mpegfileplayer::~Mpegfileplayer()
{
if (loader)
delete loader;
if (server)
delete server;
}
bool
Mpegfileplayer::openfile(char *filename, char *device)
{
// Player
if (device == NULL)
device = Rawplayer::defaultdevice;
if (device[0] == '/')
player = new Rawplayer;
else {
if (device[0] == '-')
device = NULL;
player = new Rawtofile;
}
if (player == NULL)
return seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
if (!player->initialize(device))
return seterrorcode(player->geterrorcode());
// Loader
{
int err;
if ((loader = Soundinputstream::hopen(filename, &err)) == NULL)
return seterrorcode(err);
}
// Server
if ((server = new Mpegtoraw(loader, player)) == NULL)
return seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
// Initialize server
server->initialize(filename);
return true;
}
void
Mpegfileplayer::setforcetomono(bool flag)
{
server->setforcetomono(flag);
};
void
Mpegfileplayer::setdownfrequency(int value)
{
server->setdownfrequency(value);
};
bool
Mpegfileplayer::playing(int verbose)
{
if (!server->run(-1))
return false; // Initialize MPEG Layer 3
if (verbose > 0)
showverbose(verbose);
while (server->run(100)); // Playing
seterrorcode(server->geterrorcode());
if (seterrorcode(SOUND_ERROR_FINISH))
return true;
return false;
}
#ifdef PTHREADEDMPEG
bool
Mpegfileplayer::playingwiththread(int verbose, int framenumbers)
{
if (framenumbers < 20)
return playing(verbose);
server->makethreadedplayer(framenumbers);
if (!server->run(-1))
return false; // Initialize MPEG Layer 3
if (verbose > 0)
showverbose(verbose);
while (server->run(100)); // Playing
server->freethreadedplayer();
seterrorcode(server->geterrorcode());
if (seterrorcode(SOUND_ERROR_FINISH))
return true;
return false;
}
#endif
void
Mpegfileplayer::showverbose(int verbose)
{
static char *modestring[4] =
{ "stereo", "joint stereo", "dual channel", "mono" };
fprintf(stderr, "Verbose: MPEG-%d Layer %d, %s,\n\t%dHz%s, %dkbit/s, ",
server->getversion() + 1,
server->getlayer(), modestring[server->getmode()],
server->getfrequency(), server->getdownfrequency()? "//2" : "",
server->getbitrate());
fprintf(stderr, server->getcrccheck()
? "with crc check\n" : "without crc check\n");
if (verbose > 1) {
fprintf(stderr,
"Songname : %s\n"
"Artist : %s\n"
"Album : %s\n"
"Year : %s\n"
"Comment : %s\n",
server->getname(),
server->getartist(),
server->getalbum(), server->getyear(), server->getcomment());
}
}
--- NEW FILE: rawplayer.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Rawplayer.cc
// Playing raw data with sound type.
// It's for only Linux
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include "mpegsound.h"
/* IOCTL */
#ifdef SOUND_VERSION
#define IOCTL(a,b,c) ioctl(a,b,&c)
#else
#define IOCTL(a,b,c) (c = ioctl(a,b,c) )
#endif
char *
Rawplayer::defaultdevice =
"/dev/dsp";
/* Volume */
int
Rawplayer::setvolume(int volume)
{
int handle;
int r;
handle = open("/dev/mixer", O_RDWR);
if (volume > 100)
volume = 100;
if (volume >= 0) {
r = (volume << 8) | volume;
ioctl(handle, MIXER_WRITE(SOUND_MIXER_VOLUME), &r);
}
ioctl(handle, MIXER_READ(SOUND_MIXER_VOLUME), &r);
close(handle);
return (r & 0xFF);
}
/*******************/
/* Rawplayer class */
/*******************/
// Rawplayer class
Rawplayer::~Rawplayer()
{
close(audiohandle);
}
bool
Rawplayer::initialize(char *filename)
{
int flag;
rawbuffersize = 0;
quota = 0;
if ((audiohandle = open(filename, O_WRONLY | O_NDELAY, 0)) == -1)
return seterrorcode(SOUND_ERROR_DEVOPENFAIL);
if ((flag = fcntl(audiohandle, F_GETFL, 0)) < 0)
return seterrorcode(SOUND_ERROR_DEVOPENFAIL);
flag &= ~O_NDELAY;
if (fcntl(audiohandle, F_SETFL, flag) < 0)
return seterrorcode(SOUND_ERROR_DEVOPENFAIL);
IOCTL(audiohandle, SNDCTL_DSP_GETBLKSIZE, audiobuffersize);
if (audiobuffersize < 4 || audiobuffersize > 65536)
return seterrorcode(SOUND_ERROR_DEVBADBUFFERSIZE);
return true;
}
void
Rawplayer::abort(void)
{
int a;
IOCTL(audiohandle, SNDCTL_DSP_RESET, a);
}
int
Rawplayer::getprocessed(void)
{
audio_buf_info info;
int r;
IOCTL(audiohandle, SNDCTL_DSP_GETOSPACE, info);
r = (info.fragstotal - info.fragments) * info.fragsize;
return r;
}
bool
Rawplayer::setsoundtype(int stereo, int samplesize, int speed)
{
rawstereo = stereo;
rawsamplesize = samplesize;
rawspeed = speed;
forcetomono = forceto8 = false;
return resetsoundtype();
}
bool
Rawplayer::resetsoundtype(void)
{
int tmp;
if (ioctl(audiohandle, SNDCTL_DSP_SYNC, NULL) < 0)
return seterrorcode(SOUND_ERROR_DEVCTRLERROR);
#ifdef SOUND_VERSION
if (ioctl(audiohandle, SNDCTL_DSP_STEREO, &rawstereo) < 0)
#else
if (rawstereo != ioctl(audiohandle, SNDCTL_DSP_STEREO, rawstereo))
#endif
{
rawstereo = MODE_MONO;
forcetomono = true;
}
tmp = rawsamplesize;
IOCTL(audiohandle, SNDCTL_DSP_SAMPLESIZE, tmp);
if (tmp != rawsamplesize)
if (rawsamplesize == 16) {
rawsamplesize = 8;
IOCTL(audiohandle, SNDCTL_DSP_SAMPLESIZE, rawsamplesize);
if (rawsamplesize != 8)
return seterrorcode(SOUND_ERROR_DEVCTRLERROR);
forceto8 = true;
}
if (IOCTL(audiohandle, SNDCTL_DSP_SPEED, rawspeed) < 0)
return seterrorcode(SOUND_ERROR_DEVCTRLERROR);
return true;
}
bool
Rawplayer::putblock(void *buffer, int size)
{
int modifiedsize = size;
if (forcetomono || forceto8) {
register unsigned char modify = 0;
register unsigned char *source, *dest;
int increment = 0, c;
source = dest = (unsigned char *) buffer;
if (forcetomono)
increment++;
if (forceto8)
increment++, source++;
c = modifiedsize = size >> increment;
increment <<= 1;
while (c--) {
*(dest++) = (*source) + modify;
source += increment;
}
}
if (quota)
while (getprocessed() > quota)
usleep(3);
write(audiohandle, buffer, modifiedsize);
return true;
}
int
Rawplayer::getblocksize(void)
{
return audiobuffersize;
}
--- NEW FILE: mpeglayer2.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Mpeglayer2.cc
// It's for MPEG Layer 2
//
// MPEG-2 support added by Stephane Dalton <stephaned at visuaide.com>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegsound.h"
#ifndef FIXED_POINT
#define X( x ) (x)
#else
#define X( x ) {FL2FIX( x, FIXED_POINT_FRACBITS )}
[...1070 lines suppressed...]
fraction[LS][2][i] =
(fraction[LS][2][i] + d[LS][i]) * c[LS][i];
}
REAL t = scalefactor[LS][l >> 2][i];
fraction[LS][0][i] *= t;
fraction[LS][1][i] *= t;
fraction[LS][2][i] *= t;
}
for (; i < MAXSUBBAND; i++)
fraction[LS][0][i] = fraction[LS][1][i] = fraction[LS][2][i] =
fraction[RS][0][i] = fraction[RS][1][i] =
fraction[RS][2][i] = 0.0;
for (i = 0; i < 3; i++)
subbandsynthesis(fraction[LS][i], fraction[RS][i]);
}
}
}
--- NEW FILE: fileinput.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Woo-jae Jung */
// Binput.cc
// Inputstream from file
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/stat.h>
#include <unistd.h>
#include "mpegsound.h"
/************************/
/* Input bitstrem class */
/************************/
Soundinputstreamfromfile::~Soundinputstreamfromfile()
{
if (fp)
fclose(fp);
}
bool
Soundinputstreamfromfile::open(char *filename)
{
struct stat buf;
if (filename == NULL) {
fp = stdin;
size = 0;
return true;
} else if ((fp = fopen(filename, "r")) == NULL) {
seterrorcode(SOUND_ERROR_FILEOPENFAIL);
return false;
}
stat(filename, &buf);
size = buf.st_size;
return true;
}
int
Soundinputstreamfromfile::getbytedirect(void)
{
int c;
if ((c = getc(fp)) < 0)
seterrorcode(SOUND_ERROR_FILEREADFAIL);
return c;
}
bool
Soundinputstreamfromfile::_readbuffer(char *buffer, int size)
{
if (fread(buffer, size, 1, fp) != 1) {
seterrorcode(SOUND_ERROR_FILEREADFAIL);
return false;
}
return true;
}
bool
Soundinputstreamfromfile::eof(void)
{
return feof(fp);
};
int
Soundinputstreamfromfile::getblock(char *buffer, int size)
{
return fread(buffer, 1, size, fp);
}
int
Soundinputstreamfromfile::getsize(void)
{
return size;
}
void
Soundinputstreamfromfile::setposition(int pos)
{
if (fp == stdin)
return;
fseek(fp, pos, SEEK_SET);
}
int
Soundinputstreamfromfile::getposition(void)
{
if (fp == stdin)
return 0;
return ftell(fp);
}
--- NEW FILE: bitwindow.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae
Portions Copyright (c) 2003 Century Software, Inc. All Rights Reserved.
*/
// Bitwindow.cc
// It's bit reservior for MPEG layer 3
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegsound.h"
#ifndef WORDS_BIGENDIAN
#define _KEY 0
#else
#define _KEY 3
#endif
int
Mpegbitwindow::getbits(int bits)
{
union
{
char store[4];
int current;
}
u;
int bi;
if (!bits)
return 0;
u.current = 0;
bi = (bitindex & 7);
// u.store[_KEY]=buffer[(bitindex>>3)&(WINDOWSIZE-1)]<<bi;
u.store[_KEY] = buffer[bitindex >> 3] << bi;
bi = 8 - bi;
bitindex += bi;
while (bits) {
if (!bi) {
// u.store[_KEY]=buffer[(bitindex>>3)&(WINDOWSIZE-1)];
u.store[_KEY] = buffer[bitindex >> 3];
bitindex += 8;
bi = 8;
}
if (bits >= bi) {
u.current <<= bi;
bits -= bi;
bi = 0;
} else {
u.current <<= bits;
bi -= bits;
bits = 0;
}
}
bitindex -= bi;
return (u.current >> 8);
}
--- NEW FILE: mpeglayer3.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Mpeglayer3.cc
// It's for MPEG Layer 3
// I've made array of superior functions for speed.
// Extend TO_FOUR_THIRDS to negative.
// Bug fix : maplay 1.2+ have wrong TO_FOUR_THIRDS ranges.
// Force to mono!!
// MPEG-2 is implemented
// Speed up in fixstereo (maybe buggy)
//
// Fixed point support by Nicolas Pitre <nico at cam.org>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
[...2013 lines suppressed...]
NEG(b2.hout[0][0][i - 30]);
} while ((i -= 2 * SBLIMIT) > 0);
} else {
register int i = SSLIMIT * SBLIMIT - 1;
do {
NEG(b2.hout[0][0][i - 16]);
NEG(b2.hout[0][0][i - 18]);
NEG(b2.hout[0][0][i - 20]);
NEG(b2.hout[0][0][i - 22]);
NEG(b2.hout[0][0][i - 24]);
NEG(b2.hout[0][0][i - 26]);
NEG(b2.hout[0][0][i - 28]);
NEG(b2.hout[0][0][i - 30]);
} while ((i -= 2 * SBLIMIT) > 0);
}
for (int ss = 0; ss < SSLIMIT; ss++)
subbandsynthesis(b2.hout[LS][ss], b2.hout[RS][ss]);
}
}
--- NEW FILE: Makefile.in ---
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AR = @AR@
CC = @CC@
CXX = @CXX@
KOREAN_OBJECT = @KOREAN_OBJECT@
LIBCOMMON = @LIBCOMMON@
LIBFLTKEXT = @LIBFLTKEXT@
LIBFLTKPIM = @LIBFLTKPIM@
LIBMPEGSOUND = @LIBMPEGSOUND@
MAKEINFO = @MAKEINFO@
MPEGSOUND = @MPEGSOUND@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
SRCDIRS = @SRCDIRS@
STRIP = @STRIP@
VERSION = @VERSION@
XLIBS = @XLIBS@
noinst_LIBRARIES = libmpegsound.a
libmpegsound_a_SOURCES = soundinputstream.cc fileinput.cc httpinput.cc soundplayer.cc rawplayer.cc rawtofile.cc mpegtable.cc filter.cc filter_2.cc mpegtoraw.cc mpeglayer1.cc mpeglayer2.cc mpeglayer3.cc bitwindow.cc huffmantable.cc wavetoraw.cc fileplayer.cc
noinst_HEADERS = mpegsound.h mpegsound_locals.h mpeglayer3tables.h fixed_point.h
INCLUDES = @INCLUDES@ -I. -I../fltk
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I..
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libmpegsound_a_LIBADD =
libmpegsound_a_OBJECTS = soundinputstream.o fileinput.o httpinput.o \
soundplayer.o rawplayer.o rawtofile.o mpegtable.o filter.o filter_2.o \
mpegtoraw.o mpeglayer1.o mpeglayer2.o mpeglayer3.o bitwindow.o \
huffmantable.o wavetoraw.o fileplayer.o
CXXFLAGS = @CXXFLAGS@
CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@
HEADERS = $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
DEP_FILES = .deps/bitwindow.P .deps/fileinput.P .deps/fileplayer.P \
.deps/filter.P .deps/filter_2.P .deps/httpinput.P .deps/huffmantable.P \
.deps/mpeglayer1.P .deps/mpeglayer2.P .deps/mpeglayer3.P \
.deps/mpegtable.P .deps/mpegtoraw.P .deps/rawplayer.P .deps/rawtofile.P \
.deps/soundinputstream.P .deps/soundplayer.P .deps/wavetoraw.P
SOURCES = $(libmpegsound_a_SOURCES)
OBJECTS = $(libmpegsound_a_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .cc .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu mpegsound/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
mostlyclean-noinstLIBRARIES:
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
distclean-noinstLIBRARIES:
maintainer-clean-noinstLIBRARIES:
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
libmpegsound.a: $(libmpegsound_a_OBJECTS) $(libmpegsound_a_DEPENDENCIES)
-rm -f libmpegsound.a
$(AR) cru libmpegsound.a $(libmpegsound_a_OBJECTS) $(libmpegsound_a_LIBADD)
$(RANLIB) libmpegsound.a
.cc.o:
$(CXXCOMPILE) -c $<
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = mpegsound
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu mpegsound/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
mostlyclean-depend:
clean-depend:
distclean-depend:
-rm -rf .deps
maintainer-clean-depend:
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
%.o: %.cc
@echo '$(CXXCOMPILE) -c $<'; \
$(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.cc
@echo '$(LTCXXCOMPILE) -c $<'; \
$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am:
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile $(LIBRARIES) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-tags mostlyclean-depend mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-depend \
clean-generic mostlyclean-am
clean: clean-am
distclean-am: distclean-noinstLIBRARIES distclean-compile \
distclean-tags distclean-depend distclean-generic \
clean-am
distclean: distclean-am
maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-depend maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir mostlyclean-depend \
distclean-depend clean-depend maintainer-clean-depend info-am info \
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
--- NEW FILE: httpinput.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Woo-jae Jung */
// Httpinputstream.cc
// Inputstream for http
// It's from mpg123
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <sys/stat.h>
#include <unistd.h>
#include "mpegsound.h"
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <netdb.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
#endif
static const char *httpstr = "http://";
bool
Soundinputstreamfromhttp::writestring(int fd, char *string)
{
int result, bytes = strlen(string);
while (bytes) {
if ((result = write(fd, string, bytes)) < 0 && errno != EINTR) {
seterrorcode(SOUND_ERROR_HTTPWRITEFAIL);
return false;
} else if (result == 0) {
seterrorcode(SOUND_ERROR_HTTPWRITEFAIL);
return false;
}
string += result;
bytes -= result;
}
return true;
}
bool
Soundinputstreamfromhttp::readstring(char *string, int maxlen, FILE * f)
{
char *result;
do {
result = fgets(string, maxlen, f);
} while (!result && errno == EINTR);
if (!result) {
seterrorcode(SOUND_ERROR_FILEREADFAIL);
return false;
}
return true;
}
static char *
strndup(char *src, int num)
{
char *dst;
if (!(dst = (char *) malloc(num + 1)))
return NULL;
dst[num] = '\0';
return strncpy(dst, src, num);
}
static char *
url2hostport(char *url, char **hname, unsigned long *hip, unsigned int *port)
{
char *cptr;
struct hostent *myhostent;
struct in_addr myaddr;
int isip = 1;
if (!(strncmp(url, httpstr, 7)))
url += 7;
cptr = url;
while (*cptr && *cptr != ':' && *cptr != '/') {
if ((*cptr < '0' || *cptr > '9') && *cptr != '.')
isip = 0;
cptr++;
}
if (!(*hname = strndup(url, cptr - url))) {
*hname = NULL;
return NULL;
}
if (!isip) {
if (!(myhostent = gethostbyname(*hname)))
return NULL;
memcpy(&myaddr, myhostent->h_addr, sizeof(myaddr));
*hip = myaddr.s_addr;
} else if ((*hip = inet_addr(*hname)) == INADDR_NONE)
return NULL;
if (!*cptr || *cptr == '/') {
*port = 80;
return cptr;
}
*port = atoi(++cptr);
while (*cptr && *cptr != '/')
cptr++;
return cptr;
}
char *proxyurl = NULL;
unsigned long proxyip = 0;
unsigned int proxyport;
FILE *
Soundinputstreamfromhttp::http_open(char *url)
{
char *purl = NULL, *host, *request, *sptr;
char agent[50];
int linelength;
unsigned long myip;
unsigned int myport;
int sock;
int relocate = 0, numrelocs = 0;
struct sockaddr_in server;
FILE *myfile;
if (!proxyip) {
if (!proxyurl)
if (!(proxyurl = getenv("MP3_HTTP_PROXY")))
if (!(proxyurl = getenv("http_proxy")))
proxyurl = getenv("HTTP_PROXY");
if (proxyurl && proxyurl[0] && strcmp(proxyurl, "none")) {
if (!(url2hostport(proxyurl, &host, &proxyip, &proxyport))) {
seterrorcode(SOUND_ERROR_UNKNOWNPROXY);
return NULL;
}
if (host)
free(host);
} else
proxyip = INADDR_NONE;
}
if ((linelength = strlen(url) + 100) < 1024)
linelength = 1024;
if (!(request = (char *) malloc(linelength))
|| !(purl = (char *) malloc(1024))) {
seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
return NULL;
}
strncpy(purl, url, 1023);
purl[1023] = '\0';
do {
strcpy(request, "GET ");
if (proxyip != INADDR_NONE) {
if (strncmp(url, httpstr, 7))
strcat(request, httpstr);
strcat(request, purl);
myport = proxyport;
myip = proxyip;
} else {
if (!(sptr = url2hostport(purl, &host, &myip, &myport))) {
seterrorcode(SOUND_ERROR_UNKNOWNHOST);
return NULL;
}
if (host)
free(host);
strcat(request, sptr);
}
sprintf(agent, " HTTP/1.0\r\nUser-Agent: %s/%s\r\n\r\n",
"Splay", "0.6");
strcat(request, agent);
server.sin_family = AF_INET;
server.sin_port = htons(myport);
server.sin_addr.s_addr = myip;
if ((sock = socket(PF_INET, SOCK_STREAM, 6)) < 0) {
seterrorcode(SOUND_ERROR_SOCKET);
return NULL;
}
if (connect(sock, (struct sockaddr *) &server, sizeof(server))) {
seterrorcode(SOUND_ERROR_CONNECT);
return NULL;
}
if (!writestring(sock, request))
return NULL;
if (!(myfile = fdopen(sock, "rb"))) {
seterrorcode(SOUND_ERROR_FDOPEN);
return NULL;
};
relocate = false;
purl[0] = '\0';
if (!readstring(request, linelength - 1, myfile))
return NULL;
if ((sptr = strchr(request, ' '))) {
switch (sptr[1]) {
case '3':
relocate = true;
case '2':
break;
default:
seterrorcode(SOUND_ERROR_HTTPFAIL);
return NULL;
}
}
do {
if (!readstring(request, linelength - 1, myfile))
return NULL;
if (!strncmp(request, "Location:", 9))
strncpy(purl, request + 10, 1023);
} while (request[0] != '\r' && request[0] != 'n');
} while (relocate && purl[0] && numrelocs++ < 5);
if (relocate) {
seterrorcode(SOUND_ERROR_TOOMANYRELOC);
return NULL;
}
free(purl);
free(request);
return myfile;
}
Soundinputstreamfromhttp::Soundinputstreamfromhttp()
{
fp = NULL;
}
Soundinputstreamfromhttp::~Soundinputstreamfromhttp()
{
if (fp)
fclose(fp);
}
bool
Soundinputstreamfromhttp::open(char *url)
{
if ((fp = http_open(url)) == NULL) {
seterrorcode(SOUND_ERROR_FILEOPENFAIL);
return false;
}
return true;
}
int
Soundinputstreamfromhttp::getbytedirect(void)
{
int c;
if ((c = getc(fp)) < 0) {
seterrorcode(SOUND_ERROR_FILEREADFAIL);
return -1;
}
return c;
}
bool
Soundinputstreamfromhttp::_readbuffer(char *buffer, int size)
{
if (fread(buffer, size, 1, fp) != 1) {
seterrorcode(SOUND_ERROR_FILEREADFAIL);
return false;
}
return true;
}
bool
Soundinputstreamfromhttp::eof(void)
{
return feof(fp);
};
int
Soundinputstreamfromhttp::getblock(char *buffer, int size)
{
int l;
l = fread(buffer, 1, size, fp);
if (l == 0)
seterrorcode(SOUND_ERROR_FILEREADFAIL);
return l;
}
int
Soundinputstreamfromhttp::getsize(void)
{
return 0;
}
void
Soundinputstreamfromhttp::setposition(int)
{
}
int
Soundinputstreamfromhttp::getposition(void)
{
return 0;
}
--- NEW FILE: mpegsound_locals.h ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Mpegsound_locals.h
// It is used for compiling library
#ifndef _L__SOUND_LOCALS__
#define _L__SOUND_LOCALS__
// Inline functions
inline int
Mpegtoraw::getbyte(void)
{
int r = (unsigned char) buffer[bitindex >> 3];
bitindex += 8;
return r;
};
inline int
Mpegtoraw::getbits9(int bits)
{
register unsigned short a;
#ifndef WORDS_BIGENDIAN
{
int offset = bitindex >> 3;
a = (((unsigned char) buffer[offset]) << 8) | ((unsigned char)
buffer[offset + 1]);
}
#else
a = ((unsigned short *) (buffer + ((bixindex >> 3))));
#endif
a <<= (bitindex & 7);
bitindex += bits;
return (int) ((unsigned int) (a >> (16 - bits)));
};
inline int
Mpegtoraw::getbits8(void)
{
register unsigned short a;
#ifndef WORDS_BIGENDIAN
{
int offset = bitindex >> 3;
a = (((unsigned char) buffer[offset]) << 8) | ((unsigned char)
buffer[offset + 1]);
}
#else
a = ((unsigned short *) (buffer + ((bixindex >> 3))));
#endif
a <<= (bitindex & 7);
bitindex += 8;
return (int) ((unsigned int) (a >> 8));
};
inline int
Mpegtoraw::getbit(void)
{
register int r = (buffer[bitindex >> 3] >> (7 - (bitindex & 7))) & 1;
bitindex++;
return r;
};
#endif
--- NEW FILE: Book_Purchase_Form.DOC ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: soundinputstream.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Woo-jae Jung */
// Soundinputstream.cc
// Abstractclass of inputstreams
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
#include "mpegsound.h"
Soundinputstream::Soundinputstream()
{
__errorcode = SOUND_ERROR_OK;
};
Soundinputstream::~Soundinputstream()
{
// Nothing...
};
/********************/
/* File & Http open */
/********************/
Soundinputstream *
Soundinputstream::hopen(char *filename, int *errorcode)
{
Soundinputstream *st;
if (filename == NULL)
st = new Soundinputstreamfromfile;
else if (strstr(filename, "://"))
st = new Soundinputstreamfromhttp;
else
st = new Soundinputstreamfromfile;
if (st == NULL) {
*errorcode = SOUND_ERROR_MEMORYNOTENOUGH;
return NULL;
}
if (!st->open(filename)) {
*errorcode = st->geterrorcode();
delete st;
return NULL;
}
return st;
}
--- NEW FILE: mpegtable.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Mpegtable.cc
// It has tables for MPEG layer 1, 2 and a part of layer 3
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegsound.h"
#ifndef FIXED_POINT
#define X( x ) (x)
#else
#define X( x ) {FL2FIX( x, FIXED_POINT_FRACBITS )}
#endif
// For header
const int
Mpegtoraw::frequencies[2][3] = {
{44100, 48000, 32000}, // MPEG 1
{22050, 24000, 16000} // MPEG 2
};
const int
Mpegtoraw::bitrate[2][3][15] = {
// MPEG 1
{{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448},
{0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384},
{0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320}},
// MPEG 2
{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
{0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}}
};
// Mpeg general table
const REAL
Mpegtoraw::scalefactorstable[64] = {
X(2.00000000000000),
X(1.58740105196820),
X(1.25992104989487),
X(1.00000000000000),
X(0.79370052598410),
X(0.62996052494744),
X(0.50000000000000),
X(0.39685026299205),
X(0.31498026247372),
X(0.25000000000000),
X(0.19842513149602),
X(0.15749013123686),
X(0.12500000000000),
X(0.09921256574801),
X(0.07874506561843),
X(0.06250000000000),
X(0.04960628287401),
X(0.03937253280921),
X(0.03125000000000),
X(0.02480314143700),
X(0.01968626640461),
X(0.01562500000000),
X(0.01240157071850),
X(0.00984313320230),
X(0.00781250000000),
X(0.00620078535925),
X(0.00492156660115),
X(0.00390625000000),
X(0.00310039267963),
X(0.00246078330058),
X(0.00195312500000),
X(0.00155019633981),
X(0.00123039165029),
X(0.00097656250000),
X(0.00077509816991),
X(0.00061519582514),
X(0.00048828125000),
X(0.00038754908495),
X(0.00030759791257),
X(0.00024414062500),
X(0.00019377454248),
X(0.00015379895629),
X(0.00012207031250),
X(0.00009688727124),
X(0.00007689947814),
X(0.00006103515625),
X(0.00004844363562),
X(0.00003844973907),
X(0.00003051757813),
X(0.00002422181781),
X(0.00001922486954),
X(0.00001525878906),
X(0.00001211090890),
X(0.00000961243477),
X(0.00000762939453),
X(0.00000605545445),
X(0.00000480621738),
X(0.00000381469727),
X(0.00000302772723),
X(0.00000240310869),
X(0.00000190734863),
X(0.00000151386361),
X(0.00000120155435),
X(0.00000000000000)
};
const REAL
Mpegtoraw::filter[512] = {
X(0.000000000),
X(-0.000442505),
X(0.003250122),
X(-0.007003784),
X(0.031082153),
X(-0.078628540),
X(0.100311279),
X(-0.572036743),
X(1.144989014),
X(0.572036743),
X(0.100311279),
X(0.078628540),
X(0.031082153),
X(0.007003784),
X(0.003250122),
X(0.000442505),
X(-0.000015259),
X(-0.000473022),
X(0.003326416),
X(-0.007919312),
X(0.030517578),
X(-0.084182739),
X(0.090927124),
X(-0.600219727),
X(1.144287109),
X(0.543823242),
X(0.108856201),
X(0.073059082),
X(0.031478882),
X(0.006118774),
X(0.003173828),
X(0.000396729),
X(-0.000015259),
X(-0.000534058),
X(0.003387451),
X(-0.008865356),
X(0.029785156),
X(-0.089706421),
X(0.080688477),
X(-0.628295898),
X(1.142211914),
X(0.515609741),
X(0.116577148),
X(0.067520142),
X(0.031738281),
X(0.005294800),
X(0.003082275),
X(0.000366211),
X(-0.000015259),
X(-0.000579834),
X(0.003433228),
X(-0.009841919),
X(0.028884888),
X(-0.095169067),
X(0.069595337),
X(-0.656219482),
X(1.138763428),
X(0.487472534),
X(0.123474121),
X(0.061996460),
X(0.031845093),
X(0.004486084),
X(0.002990723),
X(0.000320435),
X(-0.000015259),
X(-0.000625610),
X(0.003463745),
X(-0.010848999),
X(0.027801514),
X(-0.100540161),
X(0.057617188),
X(-0.683914185),
X(1.133926392),
X(0.459472656),
X(0.129577637),
X(0.056533813),
X(0.031814575),
X(0.003723145),
X(0.002899170),
X(0.000289917),
X(-0.000015259),
X(-0.000686646),
X(0.003479004),
X(-0.011886597),
X(0.026535034),
X(-0.105819702),
X(0.044784546),
X(-0.711318970),
X(1.127746582),
X(0.431655884),
X(0.134887695),
X(0.051132202),
X(0.031661987),
X(0.003005981),
X(0.002792358),
X(0.000259399),
X(-0.000015259),
X(-0.000747681),
X(0.003479004),
X(-0.012939453),
X(0.025085449),
X(-0.110946655),
X(0.031082153),
X(-0.738372803),
X(1.120223999),
X(0.404083252),
X(0.139450073),
X(0.045837402),
X(0.031387329),
X(0.002334595),
X(0.002685547),
X(0.000244141),
X(-0.000030518),
X(-0.000808716),
X(0.003463745),
X(-0.014022827),
X(0.023422241),
X(-0.115921021),
X(0.016510010),
X(-0.765029907),
X(1.111373901),
X(0.376800537),
X(0.143264771),
X(0.040634155),
X(0.031005859),
X(0.001693726),
X(0.002578735),
X(0.000213623),
X(-0.000030518),
X(-0.000885010),
X(0.003417969),
X(-0.015121460),
X(0.021575928),
X(-0.120697021),
X(0.001068115),
X(-0.791213989),
X(1.101211548),
X(0.349868774),
X(0.146362305),
X(0.035552979),
X(0.030532837),
X(0.001098633),
X(0.002456665),
X(0.000198364),
X(-0.000030518),
X(-0.000961304),
X(0.003372192),
X(-0.016235352),
X(0.019531250),
X(-0.125259399),
X(-0.015228271),
X(-0.816864014),
X(1.089782715),
X(0.323318481),
X(0.148773193),
X(0.030609131),
X(0.029937744),
X(0.000549316),
X(0.002349854),
X(0.000167847),
X(-0.000030518),
X(-0.001037598),
X(0.003280640),
X(-0.017349243),
X(0.017257690),
X(-0.129562378),
X(-0.032379150),
X(-0.841949463),
X(1.077117920),
X(0.297210693),
X(0.150497437),
X(0.025817871),
X(0.029281616),
X(0.000030518),
X(0.002243042),
X(0.000152588),
X(-0.000045776),
X(-0.001113892),
X(0.003173828),
X(-0.018463135),
X(0.014801025),
X(-0.133590698),
X(-0.050354004),
X(-0.866363525),
X(1.063217163),
X(0.271591187),
X(0.151596069),
X(0.021179199),
X(0.028533936),
X(-0.000442505),
X(0.002120972),
X(0.000137329),
X(-0.000045776),
X(-0.001205444),
X(0.003051758),
X(-0.019577026),
X(0.012115479),
X(-0.137298584),
X(-0.069168091),
X(-0.890090942),
X(1.048156738),
X(0.246505737),
X(0.152069092),
X(0.016708374),
X(0.027725220),
X(-0.000869751),
X(0.002014160),
X(0.000122070),
X(-0.000061035),
X(-0.001296997),
X(0.002883911),
X(-0.020690918),
X(0.009231567),
X(-0.140670776),
X(-0.088775635),
X(-0.913055420),
X(1.031936646),
X(0.221984863),
X(0.151962280),
X(0.012420654),
X(0.026840210),
X(-0.001266479),
X(0.001907349),
X(0.000106812),
X(-0.000061035),
X(-0.001388550),
X(0.002700806),
X(-0.021789551),
X(0.006134033),
X(-0.143676758),
X(-0.109161377),
X(-0.935195923),
X(1.014617920),
X(0.198059082),
X(0.151306152),
X(0.008316040),
X(0.025909424),
X(-0.001617432),
X(0.001785278),
X(0.000106812),
X(-0.000076294),
X(-0.001480103),
X(0.002487183),
X(-0.022857666),
X(0.002822876),
X(-0.146255493),
X(-0.130310059),
X(-0.956481934),
X(0.996246338),
X(0.174789429),
X(0.150115967),
X(0.004394531),
X(0.024932861),
X(-0.001937866),
X(0.001693726),
X(0.000091553),
X(-0.000076294),
X(-0.001586914),
X(0.002227783),
X(-0.023910522),
X(-0.000686646),
X(-0.148422241),
X(-0.152206421),
X(-0.976852417),
X(0.976852417),
X(0.152206421),
X(0.148422241),
X(0.000686646),
X(0.023910522),
X(-0.002227783),
X(0.001586914),
X(0.000076294),
X(-0.000091553),
X(-0.001693726),
X(0.001937866),
X(-0.024932861),
X(-0.004394531),
X(-0.150115967),
X(-0.174789429),
X(-0.996246338),
X(0.956481934),
X(0.130310059),
X(0.146255493),
X(-0.002822876),
X(0.022857666),
X(-0.002487183),
X(0.001480103),
X(0.000076294),
X(-0.000106812),
X(-0.001785278),
X(0.001617432),
X(-0.025909424),
X(-0.008316040),
X(-0.151306152),
X(-0.198059082),
X(-1.014617920),
X(0.935195923),
X(0.109161377),
X(0.143676758),
X(-0.006134033),
X(0.021789551),
X(-0.002700806),
X(0.001388550),
X(0.000061035),
X(-0.000106812),
X(-0.001907349),
X(0.001266479),
X(-0.026840210),
X(-0.012420654),
X(-0.151962280),
X(-0.221984863),
X(-1.031936646),
X(0.913055420),
X(0.088775635),
X(0.140670776),
X(-0.009231567),
X(0.020690918),
X(-0.002883911),
X(0.001296997),
X(0.000061035),
X(-0.000122070),
X(-0.002014160),
X(0.000869751),
X(-0.027725220),
X(-0.016708374),
X(-0.152069092),
X(-0.246505737),
X(-1.048156738),
X(0.890090942),
X(0.069168091),
X(0.137298584),
X(-0.012115479),
X(0.019577026),
X(-0.003051758),
X(0.001205444),
X(0.000045776),
X(-0.000137329),
X(-0.002120972),
X(0.000442505),
X(-0.028533936),
X(-0.021179199),
X(-0.151596069),
X(-0.271591187),
X(-1.063217163),
X(0.866363525),
X(0.050354004),
X(0.133590698),
X(-0.014801025),
X(0.018463135),
X(-0.003173828),
X(0.001113892),
X(0.000045776),
X(-0.000152588),
X(-0.002243042),
X(-0.000030518),
X(-0.029281616),
X(-0.025817871),
X(-0.150497437),
X(-0.297210693),
X(-1.077117920),
X(0.841949463),
X(0.032379150),
X(0.129562378),
X(-0.017257690),
X(0.017349243),
X(-0.003280640),
X(0.001037598),
X(0.000030518),
X(-0.000167847),
X(-0.002349854),
X(-0.000549316),
X(-0.029937744),
X(-0.030609131),
X(-0.148773193),
X(-0.323318481),
X(-1.089782715),
X(0.816864014),
X(0.015228271),
X(0.125259399),
X(-0.019531250),
X(0.016235352),
X(-0.003372192),
X(0.000961304),
X(0.000030518),
X(-0.000198364),
X(-0.002456665),
X(-0.001098633),
X(-0.030532837),
X(-0.035552979),
X(-0.146362305),
X(-0.349868774),
X(-1.101211548),
X(0.791213989),
X(-0.001068115),
X(0.120697021),
X(-0.021575928),
X(0.015121460),
X(-0.003417969),
X(0.000885010),
X(0.000030518),
X(-0.000213623),
X(-0.002578735),
X(-0.001693726),
X(-0.031005859),
X(-0.040634155),
X(-0.143264771),
X(-0.376800537),
X(-1.111373901),
X(0.765029907),
X(-0.016510010),
X(0.115921021),
X(-0.023422241),
X(0.014022827),
X(-0.003463745),
X(0.000808716),
X(0.000030518),
X(-0.000244141),
X(-0.002685547),
X(-0.002334595),
X(-0.031387329),
X(-0.045837402),
X(-0.139450073),
X(-0.404083252),
X(-1.120223999),
X(0.738372803),
X(-0.031082153),
X(0.110946655),
X(-0.025085449),
X(0.012939453),
X(-0.003479004),
X(0.000747681),
X(0.000015259),
X(-0.000259399),
X(-0.002792358),
X(-0.003005981),
X(-0.031661987),
X(-0.051132202),
X(-0.134887695),
X(-0.431655884),
X(-1.127746582),
X(0.711318970),
X(-0.044784546),
X(0.105819702),
X(-0.026535034),
X(0.011886597),
X(-0.003479004),
X(0.000686646),
X(0.000015259),
X(-0.000289917),
X(-0.002899170),
X(-0.003723145),
X(-0.031814575),
X(-0.056533813),
X(-0.129577637),
X(-0.459472656),
X(-1.133926392),
X(0.683914185),
X(-0.057617188),
X(0.100540161),
X(-0.027801514),
X(0.010848999),
X(-0.003463745),
X(0.000625610),
X(0.000015259),
X(-0.000320435),
X(-0.002990723),
X(-0.004486084),
X(-0.031845093),
X(-0.061996460),
X(-0.123474121),
X(-0.487472534),
X(-1.138763428),
X(0.656219482),
X(-0.069595337),
X(0.095169067),
X(-0.028884888),
X(0.009841919),
X(-0.003433228),
X(0.000579834),
X(0.000015259),
X(-0.000366211),
X(-0.003082275),
X(-0.005294800),
X(-0.031738281),
X(-0.067520142),
X(-0.116577148),
X(-0.515609741),
X(-1.142211914),
X(0.628295898),
X(-0.080688477),
X(0.089706421),
X(-0.029785156),
X(0.008865356),
X(-0.003387451),
X(0.000534058),
X(0.000015259),
X(-0.000396729),
X(-0.003173828),
X(-0.006118774),
X(-0.031478882),
X(-0.073059082),
X(-0.108856201),
X(-0.543823242),
X(-1.144287109),
X(0.600219727),
X(-0.090927124),
X(0.084182739),
X(-0.030517578),
X(0.007919312),
X(-0.003326416),
X(0.000473022),
X(0.000015259)
};
/* hcos_64[i] = 1.0 / (2.0*cos(PI*double(i*2+1)/64.0)) */
const REAL
Mpegtoraw::hcos_64[16] = {
X(0.500602998235196),
X(0.505470959897544),
X(0.515447309922625),
X(0.531042591089784),
X(0.553103896034445),
X(0.582934968206134),
X(0.622504123035665),
X(0.674808341455006),
X(0.744536271002298),
X(0.839349645415527),
X(0.972568237861961),
X(1.169439933432885),
X(1.484164616314166),
X(2.057781009953411),
X(3.407608418468719),
X(10.190008123548033)
};
/* hcos_32[i] = 1.0 / (2.0*cos(PI*double(i*2+1)/32.0)) */
const REAL
Mpegtoraw::hcos_32[8] = {
X(0.502419286188156),
X(0.522498614939689),
X(0.566944034816358),
X(0.646821783359990),
X(0.788154623451250),
X(1.060677685990347),
X(1.722447098238334),
X(5.101148618689155)
};
/* hcos_16[i] = 1.0 / (2.0*cos(PI*double(i*2+1)/16.0)) */
const REAL
Mpegtoraw::hcos_16[4] = {
X(0.509795579104159),
X(0.601344886935045),
X(0.899976223136416),
X(2.562915447741505)
};
/* hcos_8 [i] = 1.0 / (2.0*cos(PI*double(i*2+1)/ 8.0)) */
const REAL
Mpegtoraw::hcos_8[2] = {
X(0.541196100146197),
X(1.306562964876376)
};
/* hcos_4 = 1.0 / (2.0*cos(PI*1.0/4.0)) */
const REAL
Mpegtoraw::hcos_4 =
X(0.707106781186547);
--- NEW FILE: filter_2.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Filter.cc
// Subbandsynthesis routines from maplay 1.2 for Linux
// I've modified some macros for reducing source code.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegsound.h"
void
Mpegtoraw::computebuffer_2(REAL * fraction, REAL buffer[2][CALCBUFFERSIZE])
{
REAL p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pa, pb, pc, pd, pe, pf;
REAL q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, qa, qb, qc, qd, qe, qf;
[...994 lines suppressed...]
void
Mpegtoraw::subbandsynthesis_2(REAL * fractionL, REAL * fractionR)
{
computebuffer_2(fractionL, calcbufferL);
if (!outputstereo)
generatesingle_2();
else {
computebuffer_2(fractionR, calcbufferR);
generate_2();
}
if (calcbufferoffset < 15)
calcbufferoffset++;
else
calcbufferoffset = 0;
currentcalcbuffer ^= 1;
}
--- NEW FILE: mpegtoraw.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Mpegtoraw.cc
// Server which get mpeg format and put raw format.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <math.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream.h>
#include <string.h>
#include "mpegsound.h"
#include "mpegsound_locals.h"
extern pthread_mutex_t startuplock;
Mpegtoraw::Mpegtoraw(Soundinputstream * loader, Soundplayer * player)
{
__errorcode = SOUND_ERROR_OK;
frameoffsets = NULL;
forcetomonoflag = false;
downfrequency = 0;
this->loader = loader;
this->player = player;
}
Mpegtoraw::~Mpegtoraw()
{
if (frameoffsets)
delete[]frameoffsets;
}
#ifndef WORDS_BIGENDIAN
#define _KEY 0
#else
#define _KEY 3
#endif
int
Mpegtoraw::getbits(int bits)
{
union
{
char store[4];
int current;
}
u;
int bi;
if (!bits)
return 0;
u.current = 0;
bi = (bitindex & 7);
u.store[_KEY] = buffer[bitindex >> 3] << bi;
bi = 8 - bi;
bitindex += bi;
while (bits) {
if (!bi) {
u.store[_KEY] = buffer[bitindex >> 3];
bitindex += 8;
bi = 8;
}
if (bits >= bi) {
u.current <<= bi;
bits -= bi;
bi = 0;
} else {
u.current <<= bits;
bi -= bits;
bits = 0;
}
}
bitindex -= bi;
return (u.current >> 8);
}
void
Mpegtoraw::setforcetomono(bool flag)
{
forcetomonoflag = flag;
}
void
Mpegtoraw::setdownfrequency(int value)
{
downfrequency = 0;
if (value)
downfrequency = 1;
}
bool
Mpegtoraw::getforcetomono(void)
{
return forcetomonoflag;
}
int
Mpegtoraw::getdownfrequency(void)
{
return downfrequency;
}
int
Mpegtoraw::getpcmperframe(void)
{
int s;
s = 32;
if (layer == 3) {
s *= 18;
if (version == 0)
s *= 2;
} else {
s *= SCALEBLOCK;
if (layer == 2)
s *= 3;
}
return s;
}
inline void
Mpegtoraw::flushrawdata(void)
#ifdef PTHREADEDMPEG
{
pthread_mutex_lock(&startuplock);
if (threadflags.thread) {
if (((threadqueue.tail + 1) % threadqueue.framenumber) ==
threadqueue.head) {
while (((threadqueue.tail + 1) % threadqueue.framenumber) ==
threadqueue.head)
usleep(200);
}
memcpy(threadqueue.buffer + (threadqueue.tail * RAWDATASIZE), rawdata,
RAWDATASIZE * sizeof(short int));
threadqueue.sizes[threadqueue.tail] = (rawdataoffset << 1);
if (threadqueue.tail >= threadqueue.frametail)
threadqueue.tail = 0;
else
threadqueue.tail++;
} else {
player->putblock((char *) rawdata, rawdataoffset << 1);
currentframe++;
}
rawdataoffset = 0;
pthread_mutex_unlock(&startuplock);
}
#else
{
player->putblock((char *) rawdata, rawdataoffset << 1);
currentframe++;
rawdataoffset = 0;
};
#endif
static void
strman(char *str, int max)
{
int i;
str[max] = 0;
for (i = max - 1; i >= 0; i--)
if (((unsigned char) str[i]) < 26 || str[i] == ' ')
str[i] = 0;
else
break;
}
void
parseID3(Soundinputstream * fp, ID3 * data)
{
int tryflag = 0;
data->songname[0] = 0;
data->artist[0] = 0;
data->album[0] = 0;
data->year[0] = 0;
data->comment[0] = 0;
fp->setposition(fp->getsize() - 128);
for (;;) {
if (fp->getbytedirect() == 0x54)
if (fp->getbytedirect() == 0x41)
if (fp->getbytedirect() == 0x47) {
fp->_readbuffer(data->songname, 30);
strman(data->songname, 30);
fp->_readbuffer(data->artist, 30);
strman(data->artist, 30);
fp->_readbuffer(data->album, 30);
strman(data->album, 30);
fp->_readbuffer(data->year, 7);
strman(data->year, 7);
fp->_readbuffer(data->comment, 30);
strman(data->comment, 30);
break;
}
tryflag++;
if (tryflag == 1)
fp->setposition(fp->getsize() - 125); // for mpd 0.1, Sorry..
else
break;
}
fp->setposition(0);
}
inline void
stripfilename(char *dtr, char *str, int max)
{
char *ss;
int p = 0, s = 0;
for (; str[p]; p++)
if (str[p] == '/') {
p++;
s = p;
}
ss = str + s;
for (p = 0; p < max && ss[p]; p++)
dtr[p] = ss[p];
dtr[p] = 0;
}
// Convert mpeg to raw
// Mpeg headder class
void
Mpegtoraw::initialize(char *filename)
{
static bool initialized = false;
register int i;
register REAL *s1, *s2;
REAL *s3, *s4;
scalefactor = SCALE;
calcbufferoffset = 15;
currentcalcbuffer = 0;
s1 = calcbufferL[0];
s2 = calcbufferR[0];
s3 = calcbufferL[1];
s4 = calcbufferR[1];
for (i = CALCBUFFERSIZE - 1; i >= 0; i--)
calcbufferL[0][i] = calcbufferL[1][i] =
calcbufferR[0][i] = calcbufferR[1][i] = 0;
initialized = true;
layer3initialize();
currentframe = decodeframe = 0;
if (loadheader()) {
totalframe = (loader->getsize() + framesize - 1) / framesize;
loader->setposition(0);
} else
totalframe = 0;
if (frameoffsets)
delete[]frameoffsets;
songinfo.name[0] = 0;
if (totalframe > 0) {
frameoffsets = new int[totalframe];
for (i = totalframe - 1; i >= 0; i--)
frameoffsets[i] = 0;
{
ID3 data;
strcpy(data.songname, songinfo.name);
strcpy(data.artist, songinfo.artist);
strcpy(data.album, songinfo.album);
strcpy(data.year, songinfo.year);
strcpy(data.comment, songinfo.comment);
parseID3(loader, &data);
}
} else
frameoffsets = NULL;
if (songinfo.name[0] == 0)
if (filename != NULL)
stripfilename(songinfo.name, filename, 30);
#ifdef PTHREADEDMPEG
threadflags.thread = false;
threadqueue.buffer = NULL;
threadqueue.sizes = NULL;
#endif
};
void
Mpegtoraw::setframe(int framenumber)
{
int pos = 0;
if (frameoffsets == NULL)
return;
if (framenumber == 0)
pos = frameoffsets[0];
else {
if (framenumber >= totalframe)
framenumber = totalframe - 1;
pos = frameoffsets[framenumber];
if (pos == 0) {
int i;
for (i = framenumber - 1; i > 0; i--)
if (frameoffsets[i] != 0)
break;
loader->setposition(frameoffsets[i]);
while (i < framenumber) {
loadheader();
i++;
frameoffsets[i] = loader->getposition();
}
pos = frameoffsets[framenumber];
}
}
clearbuffer();
loader->setposition(pos);
decodeframe = currentframe = framenumber;
}
void
Mpegtoraw::clearbuffer(void)
{
#ifdef PTHREADEDMPEG
if (threadflags.thread) {
threadflags.criticalflag = false;
threadflags.criticallock = true;
while (!threadflags.criticalflag)
usleep(1);
threadqueue.head = threadqueue.tail = 0;
threadflags.criticallock = false;
}
#endif
player->abort();
player->resetsoundtype();
}
bool
Mpegtoraw::loadheader(void)
{
register int c;
bool flag;
sync();
// Synchronize
flag = false;
do {
if ((c = loader->getbytedirect()) < 0)
break;
if (c == 0xff)
while (!flag) {
if ((c = loader->getbytedirect()) < 0) {
flag = true;
break;
}
if ((c & 0xf0) == 0xf0) {
flag = true;
break;
} else if (c != 0xff)
break;
}
} while (!flag);
if (c < 0)
return seterrorcode(SOUND_ERROR_FINISH);
// Analyzing
c &= 0xf;
protection = c & 1;
layer = 4 - ((c >> 1) & 3);
version = (_mpegversion) ((c >> 3) ^ 1);
c = ((loader->getbytedirect())) >> 1;
padding = (c & 1);
c >>= 1;
frequency = (_frequency) (c & 2);
c >>= 2;
bitrateindex = (int) c;
if (bitrateindex == 15)
return seterrorcode(SOUND_ERROR_BAD);
c = ((unsigned int) (loader->getbytedirect())) >> 4;
extendedmode = c & 3;
mode = (_mode) (c >> 2);
// Making information
inputstereo = (mode == single) ? 0 : 1;
if (forcetomonoflag)
outputstereo = 0;
else
outputstereo = inputstereo;
/* if(layer==2)
if((bitrateindex>=1 && bitrateindex<=3) || (bitrateindex==5)) {
if(inputstereo)return seterrorcode(SOUND_ERROR_BAD); }
else if(bitrateindex==11 && mode==single)
return seterrorcode(SOUND_ERROR_BAD); */
channelbitrate = bitrateindex;
if (inputstereo)
if (channelbitrate == 4)
channelbitrate = 1;
else
channelbitrate -= 4;
if (channelbitrate == 1 || channelbitrate == 2)
tableindex = 0;
else
tableindex = 1;
if (layer == 1)
subbandnumber = MAXSUBBAND;
else if ((layer == 2) && (version == mpeg2)) {
subbandnumber = 30;
tableindex = 2;
} else {
if (!tableindex)
if (frequency == frequency32000)
subbandnumber = 12;
else
subbandnumber = 8;
else if (frequency == frequency48000 ||
(channelbitrate >= 3 && channelbitrate <= 5))
subbandnumber = 27;
else
subbandnumber = 30;
}
if (mode == single)
stereobound = 0;
else if (mode == joint)
stereobound = (extendedmode + 1) << 2;
else
stereobound = subbandnumber;
if (stereobound > subbandnumber)
stereobound = subbandnumber;
// framesize & slots
if (layer == 1) {
framesize = (12000 * bitrate[version][0][bitrateindex]) /
frequencies[version][frequency];
if (frequency == frequency44100 && padding)
framesize++;
framesize <<= 2;
} else {
framesize = (144000 * bitrate[version][layer - 1][bitrateindex]) /
(frequencies[version][frequency] << ((layer == 3) ? version : 0));
if (padding)
framesize++;
if (layer == 3) {
if (version)
layer3slots = framesize - ((mode == single) ? 9 : 17)
- (protection ? 0 : 2)
- 4;
else
layer3slots = framesize - ((mode == single) ? 17 : 32)
- (protection ? 0 : 2)
- 4;
}
}
if (!fillbuffer(framesize - 4))
seterrorcode(SOUND_ERROR_FILEREADFAIL);
if (!protection) {
getbyte(); // CRC, Not check!!
getbyte();
}
if (loader->eof())
return seterrorcode(SOUND_ERROR_FINISH);
return true;
}
/***************************/
/* Playing in multi-thread */
/***************************/
#ifdef PTHREADEDMPEG
/* Player routine */
void
Mpegtoraw::threadedplayer(void)
{
while (!threadflags.quit) {
while (threadflags.pause || threadflags.criticallock) {
threadflags.criticalflag = true;
usleep(200);
}
if (threadqueue.head != threadqueue.tail) {
player->putblock(threadqueue.buffer +
threadqueue.head * RAWDATASIZE,
threadqueue.sizes[threadqueue.head]);
currentframe++;
if (threadqueue.head == threadqueue.frametail)
threadqueue.head = 0;
else
threadqueue.head++;
} else {
if (threadflags.done)
break; // Terminate when done
usleep(200);
}
}
threadflags.thread = false;
}
static void *
threadlinker(void *arg)
{
((Mpegtoraw *) arg)->threadedplayer();
return NULL;
}
bool
Mpegtoraw::makethreadedplayer(int framenumbers)
{
threadqueue.buffer =
(short int *) malloc(sizeof(short int) * RAWDATASIZE * framenumbers);
if (threadqueue.buffer == NULL)
seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
threadqueue.sizes = (int *) malloc(sizeof(int) * framenumbers);
if (threadqueue.sizes == NULL)
seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
threadqueue.framenumber = framenumbers;
threadqueue.frametail = framenumbers - 1;
threadqueue.head = threadqueue.tail = 0;
threadflags.quit = threadflags.done =
threadflags.pause = threadflags.criticallock = false;
threadflags.thread = true;
if (pthread_create(&thread, 0, threadlinker, this))
seterrorcode(SOUND_ERROR_THREADFAIL);
return true;
}
void
Mpegtoraw::freethreadedplayer(void)
{
threadflags.criticallock = threadflags.pause = false;
threadflags.done = true; // Terminate thread player
while (threadflags.thread)
usleep(10); // Wait for done...
if (threadqueue.buffer)
free(threadqueue.buffer);
if (threadqueue.sizes)
free(threadqueue.sizes);
}
void
Mpegtoraw::stopthreadedplayer(void)
{
threadflags.quit = true;
};
void
Mpegtoraw::pausethreadedplayer(void)
{
threadflags.pause = true;
};
void
Mpegtoraw::unpausethreadedplayer(void)
{
threadflags.pause = false;
};
bool
Mpegtoraw::existthread(void)
{
return threadflags.thread;
}
int
Mpegtoraw::getframesaved(void)
{
if (threadqueue.framenumber)
return
((threadqueue.tail + threadqueue.framenumber - threadqueue.head)
% threadqueue.framenumber);
return 0;
}
#endif
// Convert mpeg to raw
bool
Mpegtoraw::run(int frames)
{
clearrawdata();
if (frames < 0)
lastfrequency = 0;
for (; frames; frames--) {
if (totalframe > 0) {
if (decodeframe < totalframe)
frameoffsets[decodeframe] = loader->getposition();
}
if (loader->eof()) {
seterrorcode(SOUND_ERROR_FINISH);
break;
}
if (loadheader() == false)
break;
if (frequency != lastfrequency) {
if (lastfrequency > 0)
seterrorcode(SOUND_ERROR_BAD);
lastfrequency = frequency;
}
if (frames < 0) {
frames = -frames;
player->setsoundtype(outputstereo, 16,
frequencies[version][frequency] >>
downfrequency);
}
decodeframe++;
if (layer == 3)
extractlayer3();
else if (layer == 2)
extractlayer2();
else if (layer == 1)
extractlayer1();
flushrawdata();
if (player->geterrorcode()) {
printf("player gave us an error\n");
seterrorcode(geterrorcode());
}
}
return (geterrorcode() == SOUND_ERROR_OK);
}
--- NEW FILE: Makefile.am ---
noinst_LIBRARIES = libmpegsound.a
libmpegsound_a_SOURCES = soundinputstream.cc fileinput.cc httpinput.cc \
soundplayer.cc rawplayer.cc rawtofile.cc \
mpegtable.cc filter.cc filter_2.cc \
mpegtoraw.cc mpeglayer1.cc mpeglayer2.cc \
mpeglayer3.cc bitwindow.cc huffmantable.cc \
wavetoraw.cc \
fileplayer.cc
noinst_HEADERS = mpegsound.h mpegsound_locals.h mpeglayer3tables.h fixed_point.h
INCLUDES = @INCLUDES@ -I. -I../fltk
--- NEW FILE: soundplayer.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Soundplayer.cc
// Superclass of Rawplayer and Rawtofile
// It's used for set player of Mpegtoraw & Wavetoraw
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegsound.h"
/*********************/
/* Soundplayer class */
/*********************/
Soundplayer::~Soundplayer()
{
// Nothing...
}
void
Soundplayer::abort(void)
{
// Nothing....
}
int
Soundplayer::getprocessed(void)
{
return 0;
}
bool
Soundplayer::resetsoundtype(void)
{
return true;
}
int
Soundplayer::getblocksize(void)
{
return 1024; // Default value
}
--- NEW FILE: wavetoraw.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Wavetoraw.cc
// Server which strips wave header.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <malloc.h>
#include "mpegsound.h"
Wavetoraw::Wavetoraw(Soundinputstream * loader, Soundplayer * player)
{
__errorcode = SOUND_ERROR_OK;
initialized = false;
buffer = NULL;
this->loader = loader;
this->player = player;
};
Wavetoraw::~Wavetoraw()
{
if (buffer)
free(buffer);
};
// Convert wave format to raw format class
bool
Wavetoraw::initialize(void)
{
if (!buffer) {
buffersize = player->getblocksize();
if ((buffer = (char *) malloc(buffersize)) == NULL) {
seterrorcode(SOUND_ERROR_MEMORYNOTENOUGH);
return false;
}
}
return true;
}
bool
Wavetoraw::run(void)
{
int c;
if (initialized) {
c = loader->getblock(buffer, buffersize);
if (c == 0) {
seterrorcode(SOUND_ERROR_FILEREADFAIL);
return false;
}
currentpoint += c;
if (player->putblock(buffer, buffersize) == false)
return false;
if (currentpoint >= size) {
seterrorcode(SOUND_ERROR_FINISH);
return false;
}
} else {
c = loader->getblock(buffer, sizeof(WAVEHEADER));
if (c == 0) {
seterrorcode(SOUND_ERROR_FILEREADFAIL);
return false;
}
if (!testwave(buffer))
return false;
if (player->setsoundtype(stereo, samplesize, speed) == false)
return false;
currentpoint = 0;
initialized = true;
}
return true;
}
void
Wavetoraw::setcurrentpoint(int p)
{
if (p * pcmsize > size)
currentpoint = size;
else
currentpoint = p * pcmsize;
loader->setposition(currentpoint + sizeof(WAVEHEADER));
}
bool
Wavetoraw::testwave(char *buffer)
{
WAVEHEADER *tmp = (WAVEHEADER *) buffer;
if (tmp->main_chunk == RIFF && tmp->chunk_type == WAVE &&
tmp->sub_chunk == FMT && tmp->data_chunk == DATA)
if (tmp->format == PCM_CODE && tmp->modus <= 2) {
stereo = (tmp->modus == WAVE_STEREO) ? 1 : 0;
samplesize = (int) (tmp->bit_p_spl);
speed = (int) (tmp->sample_fq);
size = (int) (tmp->data_length);
pcmsize = 1;
if (stereo == 1)
pcmsize *= 2;
if (samplesize == 16)
pcmsize *= 2;
return true;
}
seterrorcode(SOUND_ERROR_BAD);
return false;
}
--- NEW FILE: rawtofile.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Rawtofile.cc
// Output raw data to file.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <fcntl.h>
#include <unistd.h>
#include "mpegsound.h"
// Rawplayer class
Rawtofile::~Rawtofile()
{
close(filehandle);
}
bool
Rawtofile::initialize(char *filename)
{
if (filename == NULL)
filehandle = 1;
else if ((filehandle = creat(filename, 0644)) == -1)
return seterrorcode(SOUND_ERROR_DEVOPENFAIL);
return true;
}
bool
Rawtofile::setsoundtype(int stereo, int samplesize, int speed)
{
rawstereo = stereo;
rawsamplesize = samplesize;
rawspeed = speed;
return true;
}
bool
Rawtofile::putblock(void *buffer, int size)
{
return (write(filehandle, buffer, size) == size);
};
--- NEW FILE: mpeglayer3mktables.cc ---
00
// mpeglayer3mktables.cc
// (C) 1999 Nicolas Pitre <nico at cam.org>
//
// This code generate the mpeglayer3tables.h file
//
// To compile: gcc -Wall -O2 -o mk mpeglayer3mktables.cc -lm
// To build the table: ./mk
#include <math.h>
#include <stdio.h>
#define OUT_FNAME "mpeglayer3tables.h"
typedef double REAL;
#define PI M_PI
#define PI_12 (PI/12.0)
#define PI_18 (PI/18.0)
#define PI_24 (PI/24.0)
#define PI_36 (PI/36.0)
#define PI_72 (PI/72.0)
#define FOURTHIRDSTABLENUMBER (1<<13)
static REAL two_to_negative_half_pow[40];
static REAL TO_FOUR_THIRDSTABLE[FOURTHIRDSTABLENUMBER];
static REAL POW2[256];
static REAL POW2_1[8][2][16];
static REAL ca[8], cs[8];
static REAL win[4][36];
static REAL cos_18[9];
static REAL hsec_36[9], hsec_12[3];
REAL cos1_6 = cos(PI / 6.0 * 1.0);
REAL cos2_6 = cos(PI / 6.0 * 2.0);
typedef struct
{
REAL l, r;
}
RATIOS;
static RATIOS rat_1[16], rat_2[2][64];
int
main(void)
{
/* code for computing all tables */
int i, j, k;
// Calculate win
{
for (i = 0; i < 18; i++)
win[0][i] = win[1][i] =
0.5 * sin(PI_72 * (double) (2 * i + 1)) / cos(PI_72 *
(double) (2 *
i +
19));
for (; i < 36; i++)
win[0][i] = win[3][i] =
0.5 * sin(PI_72 * (double) (2 * i + 1)) / cos(PI_72 *
(double) (2 *
i +
19));
for (i = 0; i < 6; i++) {
win[1][i + 18] = 0.5 / cos(PI_72 * (double) (2 * (i + 18) + 19));
win[3][i + 12] = 0.5 / cos(PI_72 * (double) (2 * (i + 12) + 19));
win[1][i + 24] =
0.5 * sin(PI_24 * (double) (2 * i + 13)) / cos(PI_72 *
(double) (2 *
(i +
24)
+
19));
win[1][i + 30] = win[3][i] = 0.0;
win[3][i + 6] =
0.5 * sin(PI_24 * (double) (2 * i + 1)) / cos(PI_72 *
(double) (2 *
(i +
6) +
19));
}
for (i = 0; i < 12; i++)
win[2][i] =
0.5 * sin(PI_24 * (double) (2 * i + 1)) / cos(PI_24 *
(double) (2 *
i +
7));
}
for (i = 0; i < 9; i++)
cos_18[i] = cos(PI_18 * double (i));
for (i = 0; i < 9; i++)
hsec_36[i] = 0.5 / cos(PI_36 * double (i * 2 + 1));
for (i = 0; i < 3; i++)
hsec_12[i] = 0.5 / cos(PI_12 * double (i * 2 + 1));
for (i = 0; i < 40; i++)
two_to_negative_half_pow[i] = (REAL) pow(2.0, -0.5 * (double) i);
for (i = 0; i < FOURTHIRDSTABLENUMBER; i++)
TO_FOUR_THIRDSTABLE[i] = (REAL) pow((double) i, 4.0 / 3.0);
for (i = 0; i < 256; i++)
POW2[i] = (REAL) pow(2.0, (0.25 * (i - 210.0)));
for (i = 0; i < 8; i++)
for (j = 0; j < 2; j++)
for (k = 0; k < 16; k++)
POW2_1[i][j][k] =
pow(2.0, (-2.0 * i) - (0.5 * (1.0 + j) * k));
{
static REAL TAN12[16] = { 0.0, 0.26794919, 0.57735027, 1.0,
1.73205081, 3.73205081, 9.9999999e10, -3.73205081,
-1.73205081, -1.01, -0.57735027, -0.26794919,
0.0, 0.26794919, 0.57735027, 1.0
};
for (i = 0; i < 16; i++) {
rat_1[i].l = TAN12[i] / (1.0 + TAN12[i]);
rat_1[i].r = 1.0 / (1.0 + TAN12[i]);
}
}
#define IO0 ((double)0.840896415256)
#define IO1 ((double)0.707106781188)
rat_2[0][0].l = rat_2[0][0].r = rat_2[1][0].l = rat_2[1][0].r = 1.;
for (i = 1; i < 64; i++)
if ((i % 2) == 1) {
rat_2[0][i].l = pow(IO0, (i + 1) / 2);
rat_2[1][i].l = pow(IO1, (i + 1) / 2);
rat_2[0][i].r = rat_2[1][i].r = 1.;
} else {
rat_2[0][i].l = rat_2[1][i].l = 1.;
rat_2[0][i].r = pow(IO0, i / 2);
rat_2[1][i].r = pow(IO1, i / 2);
}
{
static REAL Ci[8] =
{ -0.6f, -0.535f, -0.33f, -0.185f, -0.095f, -0.041f, -0.0142f,
-0.0037f };
REAL sq;
for (i = 0; i < 8; i++) {
sq = sqrt(1.0f + Ci[i] * Ci[i]);
cs[i] = 1.0f / sq;
ca[i] = Ci[i] * cs[i];
}
}
/* now print out those tables to the appropriate file */
FILE *out = fopen(OUT_FNAME, "w");
if (!out) {
perror(OUT_FNAME);
exit(-1);
}
fprintf(out, "// " OUT_FNAME "\n");
fprintf(out, "// It is included by mpeglayer3.cc\n");
fprintf(out, "// This file was generated using mpeglayer3mktables.cc\n");
fprintf(out,
"// Do not edit this file but mpeglayer3mktables.cc instead\n\n\n");
fprintf(out, "#include <values.h>\n");
fprintf(out, "#ifndef FIXED_POINT\n");
fprintf(out, "#define X( x ) (x)\n");
fprintf(out, "#define inf MAXFLOAT\n");
fprintf(out, "#define Inf MAXFLOAT\n");
fprintf(out, "#else\n");
fprintf(out, "#define inf MAXINT\n");
fprintf(out, "#define Inf MAXINT\n");
fprintf(out, "#endif\n\n\n");
int s;
static char sp[] = " ";
#define TABLE( DECL, I, J, K, FMT, WRAP, VAL... ) \
fprintf( out, "static const " DECL " =\n{\n" ); \
s = 0; \
i = 0; \
do{ \
if( I ){ \
s++; \
fprintf( out, "%s{\n", sp+3-s ); \
} \
j = 0; \
do{ \
if( J ){ \
s++; \
fprintf( out, "%s{\n", sp+3-s ); \
} \
k = 0; \
do{ \
if( (k % WRAP) == 0 ) fprintf( out, "%s", sp+3-s ); \
fprintf( out, " "FMT, ##VAL ); \
if( k < K-1 ) fprintf( out, "," ); \
if( ((k+1) % WRAP) == 0 ) fprintf( out, "\n" ); \
}while( ++k < K ); \
if( J ){ \
fprintf( out, "%s}\n", sp+3-s ); \
if( j < J-1 ) fprintf( out, "%s,\n", sp+3-s ); \
s--; \
} \
}while( ++j < J ); \
if( I ){ \
fprintf( out, "%s}\n", sp+3-s ); \
if( i < I-1 ) fprintf( out, "%s,\n", sp+3-s ); \
s--; \
} \
}while( ++i < I ); \
fprintf( out, "};\n\n" );
fprintf(out, "\n#ifdef FIXED_POINT\n");
fprintf(out, "#undef X\n");
fprintf(out, "#define X( x ) {FL2FIX( x, FIXED_POINT_FRACBITS )}\n");
fprintf(out, "#endif\n\n");
TABLE("REAL two_to_negative_half_pow[40]", 0, 0, 40,
"X(%.15f)", 4, two_to_negative_half_pow[k]);
TABLE("REAL POW2_1[8][2][16]", 8, 2, 16, "X(%.15f)", 4, POW2_1[i][j][k]);
TABLE("REAL ca[8]", 0, 0, 8, "X(%.15f)", 4, ca[k]);
TABLE("REAL cs[8]", 0, 0, 8, "X(%.15f)", 4, cs[k]);
TABLE("REAL win[4][36]", 0, 4, 36, "X(%.15f)", 4, win[j][k]);
TABLE("REAL cos_18[9]", 0, 0, 9, "X(%.15f)", 3, cos_18[k]);
TABLE("REAL hsec_36[9]", 0, 0, 9, "X(%.15f)", 3, hsec_36[k]);
TABLE("REAL hsec_12[3]", 0, 0, 3, "X(%.15f)", 3, hsec_12[k]);
TABLE("RATIOS rat_1[16]", 0, 0, 16, "{X(% .15f), X(% .15f)}", 2,
rat_1[k].l, rat_1[k].r);
TABLE("RATIOS rat_2[2][64]", 0, 2, 64, "{X(%.15f), X(%.15f)}", 2,
rat_2[j][k].l, rat_2[j][k].r);
fprintf(out, "\n#ifdef FIXED_POINT\n");
fprintf(out, "#undef X\n");
fprintf(out, "#define X( x ) {FL2FIX( x, 19 )}\n");
fprintf(out, "#endif\n\n");
TABLE("REAL19 POW2[256]", 0, 0, 256, "X(%.15f)", 4, POW2[k]);
fprintf(out, "\n#ifdef FIXED_POINT\n");
fprintf(out, "#undef X\n");
fprintf(out, "#define X( x ) {FL2FIX( x, 13 )}\n");
fprintf(out, "#endif\n\n");
TABLE("REAL13 TO_FOUR_THIRDSTABLE[FOURTHIRDSTABLENUMBER]",
0, 0, FOURTHIRDSTABLENUMBER, "X(%17.9f)", 4,
TO_FOUR_THIRDSTABLE[k]);
fprintf(out, "#define cos1_6 %.15f\n", cos1_6);
fprintf(out, "#define cos2_6 %.15f\n", cos2_6);
fprintf(out, "\n");
fclose(out);
printf("File " OUT_FNAME " written.\n");
return 0;
}
--- NEW FILE: huffmantable.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Huffmantable.cc
// It contains initialized huffman table for MPEG layer 3
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegsound.h"
static const unsigned int
htd01[7][2] = { {2, 1}, {0, 0}, {2, 1}, {0, 16}, {2, 1}, {0, 1},
{0, 17}
}, htd02[17][2] =
{ {
2, 1}
[...5674 lines suppressed...]
{15, 16 - 1, 16 - 1, 0, 511, htd15},
{16, 16 - 1, 16 - 1, 1, 511, htd16},
{17, 16 - 1, 16 - 1, 2, 511, htd16},
{18, 16 - 1, 16 - 1, 3, 511, htd16},
{19, 16 - 1, 16 - 1, 4, 511, htd16},
{20, 16 - 1, 16 - 1, 6, 511, htd16},
{21, 16 - 1, 16 - 1, 8, 511, htd16},
{22, 16 - 1, 16 - 1, 10, 511, htd16},
{23, 16 - 1, 16 - 1, 13, 511, htd16},
{24, 16 - 1, 16 - 1, 4, 512, htd24},
{25, 16 - 1, 16 - 1, 5, 512, htd24},
{26, 16 - 1, 16 - 1, 6, 512, htd24},
{27, 16 - 1, 16 - 1, 7, 512, htd24},
{28, 16 - 1, 16 - 1, 8, 512, htd24},
{29, 16 - 1, 16 - 1, 9, 512, htd24},
{30, 16 - 1, 16 - 1, 11, 512, htd24},
{31, 16 - 1, 16 - 1, 13, 512, htd24},
{32, 1 - 1, 16 - 1, 0, 31, htd32},
{33, 1 - 1, 16 - 1, 0, 31, htd33}
};
--- NEW FILE: fixed_point.h ---
// Definitions and operators for fixed point math
//
// (C) 1999 Nicolas Pitre <nico at cam.org>
#define FIXED_POINT_FRACBITS 24
#define FL2FIX( x, fracs ) ((int)((x)*(1<<fracs)))
#define FIX2FL( x, fracs ) ((double)(x)/(1<<fracs))
// The REAL class defines fixed point number objects with all associated
// operators. The number of fractional bits is defined by the
// FIXED_POINT_FRACBITS value.
class REAL
{
public:
int x;
//REAL( void ) {};
//inline REAL( const int );
//inline REAL( const double );
inline REAL operator=(const REAL);
inline REAL operator=(const int);
inline REAL operator=(const double);
inline REAL operator+(const REAL) const;
inline REAL operator+(const double) const;
inline REAL operator-(const REAL) const;
inline REAL operator-(const double) const;
inline REAL operator-(void) const;
inline REAL operator+=(const REAL);
inline REAL operator-=(const REAL);
inline REAL operator*(const REAL) const;
inline REAL operator*(const double) const;
inline REAL operator*=(const REAL);
inline REAL operator*=(const double);
inline int operator==(const int) const;
inline int operator!=(const int) const;
inline REAL operator*(const class REAL13) const;
};
//inline REAL::REAL( const int i )
//{
// x = i << FIXED_POINT_FRACBITS;
//}
//inline REAL::REAL( const double d )
//{
// x = FL2FIX( d, FIXED_POINT_FRACBITS );
//}
inline REAL
REAL::operator=(const REAL r)
{
x = r.x;
return *this;
}
inline REAL
REAL::operator=(const int i)
{
x = i << FIXED_POINT_FRACBITS;
return *this;
}
inline REAL
REAL::operator=(const double d)
{
x = FL2FIX(d, FIXED_POINT_FRACBITS);
return *this;
}
inline REAL
REAL::operator+(const REAL r) const
{
REAL s;
do {
s.x = x + r.x;
} while (0);
return s;
}
inline REAL
REAL::operator+(const double d) const
{
REAL s;
do {
s.x = x + FL2FIX(d, FIXED_POINT_FRACBITS);
} while (0);
return s;
}
inline REAL
REAL::operator-(const REAL r) const
{
REAL s;
do {
s.x = x - r.x;
} while (0);
return s;
}
inline REAL
REAL::operator-(const double d) const
{
REAL s;
do {
s.x = x - FL2FIX(d, FIXED_POINT_FRACBITS);
} while (0);
return s;
}
inline REAL
REAL::operator-(void) const
{
REAL s;
do {
s.x = -x;
} while (0);
return s;
}
inline REAL
REAL::operator+=(REAL r)
{
do {
x += r.x;
} while (0);
return *this;
}
inline REAL
REAL::operator-=(REAL r)
{
do {
x -= r.x;
} while (0);
return *this;
}
inline REAL
REAL::operator*(const REAL r) const
{
REAL s;
do {
register long long l = (long long) x * (long long) r.x;
s.x = (int) (l >> FIXED_POINT_FRACBITS);
} while (0);
return s;
}
inline REAL
REAL::operator*(const double d) const
{
REAL s;
do {
long long l =
(long long) x * (long long) FL2FIX(d, FIXED_POINT_FRACBITS);
s.x = (int) (l >> FIXED_POINT_FRACBITS);
} while (0);
return s;
}
inline REAL
REAL::operator*=(const REAL r)
{
return (*this = *this * r);
}
inline REAL
REAL::operator*=(const double d)
{
return (*this = *this * d);
}
inline int
REAL::operator==(const int i) const
{
return (x == (i << FIXED_POINT_FRACBITS));
}
inline int
REAL::operator!=(const int i) const
{
return (x != (i << FIXED_POINT_FRACBITS));
}
// The REAL13 class is mostly like the REAL class but with 13 fractional bits
// values. It is required by the TO_FOUR_THIRDSTABLE array in order to fit
// its value range.
class REAL13
{
public:
int x;
//inline REAL13( void ) {};
//inline REAL13( const double );
inline REAL13 operator=(const REAL13);
inline REAL13 operator=(const double);
inline REAL13 operator-(void) const;
};
//inline REAL13::REAL13( const double d )
//{
// x = FL2FIX( d, 13 );
//}
inline REAL13
REAL13::operator=(const REAL13 r)
{
x = r.x;
return *this;
}
inline REAL13
REAL13::operator=(const double d)
{
x = FL2FIX(d, 13);
return *this;
}
inline REAL13
REAL13::operator-(void) const
{
REAL13 s;
do {
s.x = -x;
} while (0);
return s;
}
inline REAL
REAL::operator*(const REAL13 r) const
{
REAL s;
do {
long long l = (long long) x * (long long) r.x;
s.x = (int) (l >> 13);
} while (0);
return s;
}
// The REAL19 class is mostly like the REAL class but with 19 fractional bits
// values. It is required by the POW2 array in order to fit
// its value range.
class REAL19
{
public:
int x;
//inline REAL19( void ) {};
//inline REAL19( const double );
inline REAL19 operator=(const double);
inline REAL operator*(const REAL) const;
inline REAL operator*(const REAL13) const;
};
//inline REAL19::REAL19( const double d )
//{
// x = FL2FIX( d, 19 );
//}
inline REAL19
REAL19::operator=(const double d)
{
x = FL2FIX(d, 19);
return *this;
}
inline REAL
REAL19::operator*(const REAL r) const
{
REAL s;
do {
long long l = (long long) x * (long long) r.x;
s.x = (int) (l >> 19);
} while (0);
return s;
}
inline REAL
REAL19::operator*(const REAL13 r) const
{
REAL s;
do {
long long l = (long long) x * (long long) r.x;
s.x = (int) (l >> (19 + 13 - FIXED_POINT_FRACBITS));
} while (0);
return s;
}
// Misc global operators
inline REAL
operator*(const int i, const REAL r)
{
REAL s;
s.x = i * r.x;
return s;
}
--- NEW FILE: filter.cc ---
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Filter.cc
// Subbandsynthesis routines from maplay 1.2 for Linux
// I've modified some macros for reducing source code.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mpegsound.h"
void
Mpegtoraw::computebuffer(REAL * fraction, REAL buffer[2][CALCBUFFERSIZE])
{
REAL p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, pa, pb, pc, pd, pe, pf;
REAL q0, q1, q2, q3, q4, q5, q6, q7, q8, q9, qa, qb, qc, qd, qe, qf;
[...1146 lines suppressed...]
return;
}
computebuffer(fractionL, calcbufferL);
if (!outputstereo)
generatesingle();
else {
computebuffer(fractionR, calcbufferR);
generate();
}
if (calcbufferoffset < 15)
calcbufferoffset++;
else
calcbufferoffset = 0;
currentcalcbuffer ^= 1;
}
More information about the dslinux-commit
mailing list