added cbr, abr and vbr setting feature with encoding quality

This commit is contained in:
darkeye 2002-04-13 11:26:00 +00:00
parent ae1f874cea
commit 7e9555b97c
11 changed files with 535 additions and 297 deletions

View File

@ -1,3 +1,9 @@
DarkIce 0.10
o added possibility to select constant, average and variable bit rate
encoding modes with specifying encoding quality as well.
thanks to Nicu Pavel <npavel@ituner.com>
09-04-2002: DarkIce 0.9.1 released 09-04-2002: DarkIce 0.9.1 released
o bugfix: a memory leak was introduced in 0.9, which is fixed thanks to o bugfix: a memory leak was introduced in 0.9, which is fixed thanks to

View File

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/DarkIce.cpp) AC_INIT(src/DarkIce.cpp)
AM_INIT_AUTOMAKE(darkice, 0.9.1) AM_INIT_AUTOMAKE(darkice, 0.10beta)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)

View File

@ -17,7 +17,9 @@ channel = 2 # channels. 1 = mono, 2 = stereo
# there may be up to 8 of these sections, named [icecast-0] ... [icecast-7] # there may be up to 8 of these sections, named [icecast-0] ... [icecast-7]
# these can be mixed with [icecast2-x] and [shoutcast-x] sections # these can be mixed with [icecast2-x] and [shoutcast-x] sections
[icecast-0] [icecast-0]
bitrateMode = cbr # constant bit rate
bitrate = 96 # bitrate of the mp3 stream sent to the server bitrate = 96 # bitrate of the mp3 stream sent to the server
quality = 0.8 # encoding quality
server = yp.yourserver.com server = yp.yourserver.com
# host name of the server # host name of the server
port = 8000 # port of the IceCast server, usually 8000 port = 8000 # port of the IceCast server, usually 8000
@ -36,6 +38,7 @@ public = yes # advertise this stream?
# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7] # there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections # these can be mixed with [icecast-x] and [shoutcast-x] sections
[icecast2-0] [icecast2-0]
bitrateMode = abr # average bit rate
format = vorbis # format of the stream: ogg vorbis format = vorbis # format of the stream: ogg vorbis
bitrate = 96 # bitrate of the stream sent to the server bitrate = 96 # bitrate of the stream sent to the server
server = yp.yourserver.com server = yp.yourserver.com
@ -56,7 +59,8 @@ public = yes # advertise this stream?
# there may be up to 8 of these sections, named [shoutcast-0] ... [shoutcast-7] # there may be up to 8 of these sections, named [shoutcast-0] ... [shoutcast-7]
# these can be mixed with [icecast-x] and [icecast2-x] sections # these can be mixed with [icecast-x] and [icecast2-x] sections
[shoutcast-0] [shoutcast-0]
bitrate = 96 # bitrate of the mp3 stream sent to the server bitrateMode = vbr # variable bit rate mode
quality = 0.5 # encoding quality
server = yp.yourserver.com server = yp.yourserver.com
# host name of the server # host name of the server
port = 8001 # source port of the ShoutCast server, usually 8001 port = 8001 # source port of the ShoutCast server, usually 8001

View File

@ -1,4 +1,4 @@
.TH darkice 1 "September 18, 2001" "DarkIce" "DarkIce live audio streamer" .TH darkice 1 "April 13, 2002" "DarkIce" "DarkIce live audio streamer"
.SH NAME .SH NAME
darkice \- an icecast / shoutcast live audio streamer darkice \- an icecast / shoutcast live audio streamer
.SH SYNOPSIS .SH SYNOPSIS
@ -81,6 +81,9 @@ Ogg Vorbis encoding code based on the contribution of aNa|0Gue
BSD porting help from Robin P. Blanchard BSD porting help from Robin P. Blanchard
.I <Robin_Blanchard@gactr.uga.edu> .I <Robin_Blanchard@gactr.uga.edu>
CBR, ABR and VBR and encoding quality setting feature from Nicu Pavel
.I <npavel@ituner.com>
.SH LINKS .SH LINKS
Project homepage: Project homepage:

View File

@ -1,4 +1,4 @@
.TH darkice.cfg 5 "March 28, 2002" "DarkIce" "DarkIce live audio streamer" .TH darkice.cfg 5 "April 13, 2002" "DarkIce" "DarkIce live audio streamer"
.SH NAME .SH NAME
darkice.cfg \- configuration file for darkice darkice.cfg \- configuration file for darkice
.SH DESCRIPTION .SH DESCRIPTION
@ -86,9 +86,21 @@ The stream will be reachable at
Required values: Required values:
.TP
.I bitrateMode
The bit rate mode of the encoding, either "cbr", "abr" or "vbr",
standing for constant bit rate, average bit rate and variable bit
respectively. Use the bitrate and/or quality values to specify details
of the appropriate bit rate mode.
.TP .TP
.I bitrate .I bitrate
Bit rate to encode to in kBits / sec (e.g. 96) Bit rate to encode to in kBits / sec (e.g. 96). Only used when cbr or
abr bit rate modes are specified.
.TP
.I quality
The quality of encoding a value between 0.0 .. 1.0 (e.g. 0.8), with 1.0 being
the highest quality. Use a value greater than 0.0. Only used when cbr or vbr
bit rate modes are specified.
.TP .TP
.I server .I server
The The
@ -177,14 +189,20 @@ Format of the stream sent to the
.B IceCast2 .B IceCast2
server. Currently the only supported value here is 'vorbis'. server. Currently the only supported value here is 'vorbis'.
.TP .TP
.I bitrateMode
The bit rate mode of the encoding, either "cbr", "abr" or "vbr",
standing for constant bit rate, average bit rate and variable bit
respectively. Use the bitrate and/or quality values to specify details
of the appropriate bit rate mode.
.TP
.I bitrate .I bitrate
Bit rate to encode to in kBits / sec (e.g. 96) Bit rate to encode to in kBits / sec (e.g. 96). Only used when cbr or
If specified, the quality field may not be specified. abr bit rate modes are specified.
.TP .TP
.I quality .I quality
Quality of a variable bitrate stream, a number between 0.0 ... 1.0 The quality of encoding a value between 0.0 .. 1.0 (e.g. 0.8), with 1.0 being
(e.g. 0.8). the highest quality. Use a value greater than 0.0. Only used when cbr or vbr
If specified, the bitrate field may not be specified. bit rate modes are specified.
.TP .TP
.I server .I server
The The
@ -244,9 +262,21 @@ The stream will be reachable at
Required values: Required values:
.TP
.I bitrateMode
The bit rate mode of the encoding, either "cbr", "abr" or "vbr",
standing for constant bit rate, average bit rate and variable bit
respectively. Use the bitrate and/or quality values to specify details
of the appropriate bit rate mode.
.TP .TP
.I bitrate .I bitrate
Bit rate to encode to in kBits / sec (e.g. 96) Bit rate to encode to in kBits / sec (e.g. 96). Only used when cbr or
abr bit rate modes are specified.
.TP
.I quality
The quality of encoding a value between 0.0 .. 1.0 (e.g. 0.8), with 1.0 being
the highest quality. Use a value greater than 0.0. Only used when cbr or vbr
bit rate modes are specified.
.TP .TP
.I server .I server
The The
@ -319,8 +349,20 @@ Required values:
.I format .I format
Format to encode in. Must be either 'mp3' or 'vorbis'. Format to encode in. Must be either 'mp3' or 'vorbis'.
.TP .TP
.I bitrateMode
The bit rate mode of the encoding, either "cbr", "abr" or "vbr",
standing for constant bit rate, average bit rate and variable bit
respectively. Use the bitrate and/or quality values to specify details
of the appropriate bit rate mode.
.TP
.I bitrate .I bitrate
Bit rate to encode to in kBits / sec (e.g. 96) Bit rate to encode to in kBits / sec (e.g. 96). Only used when cbr or
abr bit rate modes are specified.
.TP
.I quality
The quality of encoding a value between 0.0 .. 1.0 (e.g. 0.8), with 1.0 being
the highest quality. Use a value greater than 0.0. Only used when cbr or vbr
bit rate modes are specified.
.TP .TP
.I fileName .I fileName
The name of the local file to save the encoded data into. The name of the local file to save the encoded data into.
@ -355,7 +397,8 @@ at 22.05kHz, 16 bit stereo.
It will build up a connection to the It will build up a connection to the
.B IceCast .B IceCast
server yp.yourserver.com on port 8000 with the password "hackme". server yp.yourserver.com on port 8000 with the password "hackme".
The stream will be encoded to 96 kb/s mp3, and will be reachable at The stream will be encoded to 96 kb/s mp3 with quality 0.8, and will be
reachable at
.I http://yp.yourserver.com:8000/live96 .I http://yp.yourserver.com:8000/live96
to mp3 players. to mp3 players.
The encoding session will be stored by The encoding session will be stored by
@ -380,7 +423,9 @@ bitsPerSample = 16
channel = 2 channel = 2
[icecast-0] [icecast-0]
bitrateMode = cbr
bitrate = 96 bitrate = 96
quality = 0.8
server = yp.yourserver.com server = yp.yourserver.com
port = 8000 port = 8000
password = hackme password = hackme
@ -397,8 +442,8 @@ localDumpFile = /tmp/encoder-dump.mp3
.PP .PP
The following sample configuration file simply encodes the 16 bit stereo The following sample configuration file simply encodes the 16 bit stereo
44.1 kHz sound card input into Ogg Vorbis at 96 kb/s for 60 seconds, and saves 44.1 kHz sound card input into Ogg Vorbis at average bit rate 96 kb/s for 60
it in the local file at /tmp/save.ogg. seconds, and saves it in the local file at /tmp/save.ogg.
.nf .nf
[general] [general]
@ -413,6 +458,7 @@ channel = 2
[file-0] [file-0]
format = vorbis format = vorbis
bitrateMode = abr
bitrate = 96 bitrate = 96
fileName = /tmp/save.ogg fileName = /tmp/save.ogg
.fi .fi
@ -429,7 +475,8 @@ It will build up a connection to an
.B IceCast .B IceCast
server yp.your-ice-server.com on port 8000 with the password "ice-hackme". server yp.your-ice-server.com on port 8000 with the password "ice-hackme".
The sound for this stream will be cut at 10500 Hz from above. The sound for this stream will be cut at 10500 Hz from above.
The stream will be encoded to 96 kb/s mp3 and resampled to 22.05kHz. The stream will be encoded to average bit rate 96 kb/s mp3 and resampled to
22.05kHz.
The stream will be reachable at The stream will be reachable at
.I http://yp.your-ice-server.com:8000/live96 .I http://yp.your-ice-server.com:8000/live96
to mp3 players. to mp3 players.
@ -442,7 +489,8 @@ on the server side.
It will also connect to a It will also connect to a
.I ShoutCast .I ShoutCast
server at yp.your-shout-server.com on port 8001 with the password "shout-hackme" server at yp.your-shout-server.com on port 8001 with the password "shout-hackme"
This stream will be encoded to 128 kb/s mp3, and will be reachable at This stream will be encoded to constant bit rate 128 kb/s mp3 with quality
0.8, and will be reachable at
.I http://yp.your-shout-server.com:8000 .I http://yp.your-shout-server.com:8000
to mp3 players. to mp3 players.
@ -459,6 +507,7 @@ channel = 2
[icecast-0] [icecast-0]
sampleRate = 22050 sampleRate = 22050
bitrateMode = abr
bitrate = 96 bitrate = 96
lowpass = 10500 lowpass = 10500
server = yp.your-ice-server.com server = yp.your-ice-server.com
@ -473,7 +522,9 @@ public = yes
remoteDumpFile = /tmp/live96.mp3 remoteDumpFile = /tmp/live96.mp3
[shoutcast-0] [shoutcast-0]
bitrateMode = cbr
bitrate = 128 bitrate = 128
quality = 0.8
server = yp.your-shout-server.com server = yp.your-shout-server.com
port = 8001 port = 8001
password = shout-hackme password = shout-hackme

View File

@ -57,6 +57,18 @@
*/ */
class AudioEncoder : public Sink, public virtual Referable class AudioEncoder : public Sink, public virtual Referable
{ {
public:
/**
* Type to specify bitrate mode. Possible values:
* - cbr - constant bitrate mode
* described by bitrate
* - abr - average bitrate mode
* described by an average bitrate and quality
* - vbr - variable bitrate mode
* described by quality
*/
enum BitrateMode { cbr, abr, vbr };
private: private:
/** /**
@ -79,6 +91,11 @@ class AudioEncoder : public Sink, public virtual Referable
*/ */
bool inBigEndian; bool inBigEndian;
/**
* The bitrate mode of the encoder
*/
BitrateMode outBitrateMode;
/** /**
* Bit rate of the output in kbits/sec, for fixed bitrate encodings. * Bit rate of the output in kbits/sec, for fixed bitrate encodings.
*/ */
@ -105,7 +122,8 @@ class AudioEncoder : public Sink, public virtual Referable
* @param inSampleRate sample rate of the input. * @param inSampleRate sample rate of the input.
* @param inBitsPerSample number of bits per sample of the input. * @param inBitsPerSample number of bits per sample of the input.
* @param inChannel number of channels of the input. * @param inChannel number of channels of the input.
* @param inBigEndian shows if the input is big or little endian * @param inBigEndian shows if the input is big or little endian.
* @param outBitrateMode the bit rate mode of the output.
* @param outBitrate bit rate of the output. * @param outBitrate bit rate of the output.
* @param outSampleRate sample rate of the output. * @param outSampleRate sample rate of the output.
* @param outChannel number of channels of the output. * @param outChannel number of channels of the output.
@ -116,8 +134,9 @@ class AudioEncoder : public Sink, public virtual Referable
unsigned int inBitsPerSample, unsigned int inBitsPerSample,
unsigned int inChannel, unsigned int inChannel,
bool inBigEndian, bool inBigEndian,
BitrateMode outBitrateMode,
unsigned int outBitrate, unsigned int outBitrate,
float outQuality, double outQuality,
unsigned int outSampleRate, unsigned int outSampleRate,
unsigned int outChannel ) throw ( Exception ) unsigned int outChannel ) throw ( Exception )
{ {
@ -125,10 +144,15 @@ class AudioEncoder : public Sink, public virtual Referable
this->inBitsPerSample = inBitsPerSample; this->inBitsPerSample = inBitsPerSample;
this->inChannel = inChannel; this->inChannel = inChannel;
this->inBigEndian = inBigEndian; this->inBigEndian = inBigEndian;
this->outBitrateMode = outBitrateMode;
this->outBitrate = outBitrate; this->outBitrate = outBitrate;
this->outQuality = outQuality; this->outQuality = outQuality;
this->outSampleRate = outSampleRate; this->outSampleRate = outSampleRate;
this->outChannel = outChannel; this->outChannel = outChannel;
if ( outQuality < 0 || 1.0 < outQuality ) {
throw Exception( __FILE__, __LINE__, "invalid encoder quality");
}
} }
/** /**
@ -156,46 +180,14 @@ class AudioEncoder : public Sink, public virtual Referable
} }
/** /**
* Constructor for fixed bitrate encoding. * Constructor.
* *
* @param inSampleRate sample rate of the input. * @param inSampleRate sample rate of the input.
* @param inBitsPerSample number of bits per sample of the input. * @param inBitsPerSample number of bits per sample of the input.
* @param inChannel number of channels of the input. * @param inChannel number of channels of the input.
* @param inBigEndian shows if the input is big or little endian * @param inBigEndian shows if the input is big or little endian
* @param outBitrateMode the bit rate mode of the output.
* @param outBitrate bit rate of the output (kbits/sec). * @param outBitrate bit rate of the output (kbits/sec).
* @param outSampleRate sample rate of the output.
* If 0, inSampleRate is used.
* @param outChannel number of channels of the output.
* If 0, inChannel is used.
* @exception Exception
*/
inline
AudioEncoder ( unsigned int inSampleRate,
unsigned int inBitsPerSample,
unsigned int inChannel,
bool inBigEndian,
unsigned int outBitrate,
unsigned int outSampleRate = 0,
unsigned int outChannel = 0 )
throw ( Exception )
{
init ( inSampleRate,
inBitsPerSample,
inChannel,
inBigEndian,
outBitrate,
0.0,
outSampleRate ? outSampleRate : inSampleRate,
outChannel ? outChannel : inChannel );
}
/**
* Constructor for variable bitrate encoding.
*
* @param inSampleRate sample rate of the input.
* @param inBitsPerSample number of bits per sample of the input.
* @param inChannel number of channels of the input.
* @param inBigEndian shows if the input is big or little endian
* @param outQuality the quality of the stream. * @param outQuality the quality of the stream.
* @param outSampleRate sample rate of the output. * @param outSampleRate sample rate of the output.
* If 0, inSampleRate is used. * If 0, inSampleRate is used.
@ -208,6 +200,8 @@ class AudioEncoder : public Sink, public virtual Referable
unsigned int inBitsPerSample, unsigned int inBitsPerSample,
unsigned int inChannel, unsigned int inChannel,
bool inBigEndian, bool inBigEndian,
BitrateMode outBitrateMode,
unsigned int outBitrate,
double outQuality, double outQuality,
unsigned int outSampleRate = 0, unsigned int outSampleRate = 0,
unsigned int outChannel = 0 ) unsigned int outChannel = 0 )
@ -217,46 +211,20 @@ class AudioEncoder : public Sink, public virtual Referable
inBitsPerSample, inBitsPerSample,
inChannel, inChannel,
inBigEndian, inBigEndian,
0, outBitrateMode,
outBitrate,
outQuality, outQuality,
outSampleRate ? outSampleRate : inSampleRate, outSampleRate ? outSampleRate : inSampleRate,
outChannel ? outChannel : inChannel ); outChannel ? outChannel : inChannel );
} }
/** /**
* Constructor for fixed bitrate encoding. * Constructor.
* *
* @param as get input sample rate, bits per sample and channels * @param as get input sample rate, bits per sample and channels
* from this AudioSource. * from this AudioSource.
* @param outBitrateMode the bit rate mode of the output.
* @param outBitrate bit rate of the output (kbits/sec). * @param outBitrate bit rate of the output (kbits/sec).
* @param outSampleRate sample rate of the output.
* If 0, input sample rate is used.
* @param outChannel number of channels of the output.
* If 0, input channel is used.
* @exception Exception
*/
inline
AudioEncoder ( const AudioSource * as,
unsigned int outBitrate,
unsigned int outSampleRate = 0,
unsigned int outChannel = 0 )
throw ( Exception)
{
init( as->getSampleRate(),
as->getBitsPerSample(),
as->getChannel(),
as->isBigEndian(),
outBitrate,
0.0,
outSampleRate ? outSampleRate : as->getSampleRate(),
outChannel ? outChannel : as->getChannel() );
}
/**
* Constructor for variable bitrate encoding.
*
* @param as get input sample rate, bits per sample and channels
* from this AudioSource.
* @param outQuality the quality of the stream. * @param outQuality the quality of the stream.
* @param outSampleRate sample rate of the output. * @param outSampleRate sample rate of the output.
* If 0, input sample rate is used. * If 0, input sample rate is used.
@ -266,6 +234,8 @@ class AudioEncoder : public Sink, public virtual Referable
*/ */
inline inline
AudioEncoder ( const AudioSource * as, AudioEncoder ( const AudioSource * as,
BitrateMode outBitrateMode,
unsigned int outBitrate,
double outQuality, double outQuality,
unsigned int outSampleRate = 0, unsigned int outSampleRate = 0,
unsigned int outChannel = 0 ) unsigned int outChannel = 0 )
@ -275,7 +245,8 @@ class AudioEncoder : public Sink, public virtual Referable
as->getBitsPerSample(), as->getBitsPerSample(),
as->getChannel(), as->getChannel(),
as->isBigEndian(), as->isBigEndian(),
0, outBitrateMode,
outBitrate,
outQuality, outQuality,
outSampleRate ? outSampleRate : as->getSampleRate(), outSampleRate ? outSampleRate : as->getSampleRate(),
outChannel ? outChannel : as->getChannel() ); outChannel ? outChannel : as->getChannel() );
@ -293,6 +264,7 @@ class AudioEncoder : public Sink, public virtual Referable
encoder.inBitsPerSample, encoder.inBitsPerSample,
encoder.inChannel, encoder.inChannel,
encoder.inBigEndian, encoder.inBigEndian,
encoder.outBitrateMode,
encoder.outBitrate, encoder.outBitrate,
encoder.outQuality, encoder.outQuality,
encoder.outSampleRate, encoder.outSampleRate,
@ -316,6 +288,7 @@ class AudioEncoder : public Sink, public virtual Referable
encoder.inBitsPerSample, encoder.inBitsPerSample,
encoder.inChannel, encoder.inChannel,
encoder.inBigEndian, encoder.inBigEndian,
encoder.outBitrateMode,
encoder.outBitrate, encoder.outBitrate,
encoder.outQuality, encoder.outQuality,
encoder.outSampleRate, encoder.outSampleRate,
@ -405,6 +378,17 @@ class AudioEncoder : public Sink, public virtual Referable
return outSampleRate; return outSampleRate;
} }
/**
* Get the bit rate mode of the output.
*
* @return the bit rate mode of the output.
*/
inline BitrateMode
getOutBitrateMode ( void ) const throw ()
{
return outBitrateMode;
}
/** /**
* Get the bit rate of the output in kbits/sec, for fixed bitrate * Get the bit rate of the output in kbits/sec, for fixed bitrate
* encodings. * encodings.
@ -429,18 +413,6 @@ class AudioEncoder : public Sink, public virtual Referable
return outQuality; return outQuality;
} }
/**
* Tell if this encoding is fixed bitrate or variable bitrate.
*
* @return <code>true</code> if this encoding is variable bitrate,
* <code>false</code> if fixed bitrate.
*/
inline bool
isVBR ( void ) const throw ()
{
return outBitrate == 0;
}
/** /**
* Check wether encoding is in progress. * Check wether encoding is in progress.
* *
@ -484,6 +456,9 @@ class AudioEncoder : public Sink, public virtual Referable
$Source$ $Source$
$Log$ $Log$
Revision 1.7 2002/04/13 11:26:00 darkeye
added cbr, abr and vbr setting feature with encoding quality
Revision 1.6 2002/03/28 16:39:32 darkeye Revision 1.6 2002/03/28 16:39:32 darkeye
added interface for variable bitrate encoding added interface for variable bitrate encoding

View File

@ -201,7 +201,9 @@ DarkIce :: configIceCast ( const Config & config,
const char * str; const char * str;
unsigned int sampleRate = 0; unsigned int sampleRate = 0;
AudioEncoder::BitrateMode bitrateMode;
unsigned int bitrate = 0; unsigned int bitrate = 0;
double quality = 0.0;
const char * server = 0; const char * server = 0;
unsigned int port = 0; unsigned int port = 0;
const char * password = 0; const char * password = 0;
@ -219,8 +221,45 @@ DarkIce :: configIceCast ( const Config & config,
str = cs->get( "sampleRate"); str = cs->get( "sampleRate");
sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); sampleRate = str ? Util::strToL( str) : dsp->getSampleRate();
str = cs->getForSure("bitrate", " missing in section ", stream);
bitrate = Util::strToL( str); str = cs->get( "bitrate");
bitrate = str ? Util::strToL( str) : 0;
str = cs->get( "quality");
quality = str ? Util::strToD( str) : 0.0;
str = cs->getForSure( "bitrateMode",
" not specified in section ",
stream);
if ( Util::strEq( str, "cbr") ) {
bitrateMode = AudioEncoder::cbr;
if ( bitrate == 0 ) {
throw Exception( __FILE__, __LINE__,
"bitrate not specified for CBR encoding");
}
if ( quality == 0 ) {
throw Exception( __FILE__, __LINE__,
"quality not specified for CBR encoding");
}
} else if ( Util::strEq( str, "abr") ) {
bitrateMode = AudioEncoder::abr;
if ( bitrate == 0 ) {
throw Exception( __FILE__, __LINE__,
"bitrate not specified for ABR encoding");
}
} else if ( Util::strEq( str, "vbr") ) {
bitrateMode = AudioEncoder::vbr;
if ( quality == 0 ) {
throw Exception( __FILE__, __LINE__,
"quality not specified for VBR encoding");
}
} else {
throw Exception( __FILE__, __LINE__,
"invalid bitrate mode: ", str);
}
server = cs->getForSure( "server", " missing in section ", stream); server = cs->getForSure( "server", " missing in section ", stream);
str = cs->getForSure( "port", " missing in section ", stream); str = cs->getForSure( "port", " missing in section ", stream);
port = Util::strToL( str); port = Util::strToL( str);
@ -239,6 +278,7 @@ DarkIce :: configIceCast ( const Config & config,
lowpass = str ? Util::strToL( str) : 0; lowpass = str ? Util::strToL( str) : 0;
str = cs->get( "highpass"); str = cs->get( "highpass");
highpass = str ? Util::strToL( str) : 0; highpass = str ? Util::strToL( str) : 0;
localDumpName = cs->get( "localDumpFile"); localDumpName = cs->get( "localDumpFile");
// go on and create the things // go on and create the things
@ -278,7 +318,9 @@ DarkIce :: configIceCast ( const Config & config,
audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(), audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(),
dsp.get(), dsp.get(),
bitrateMode,
bitrate, bitrate,
quality,
sampleRate, sampleRate,
dsp->getChannel(), dsp->getChannel(),
lowpass, lowpass,
@ -320,6 +362,7 @@ DarkIce :: configIceCast2 ( const Config & config,
IceCast2::StreamFormat format; IceCast2::StreamFormat format;
unsigned int sampleRate = 0; unsigned int sampleRate = 0;
AudioEncoder::BitrateMode bitrateMode;
unsigned int bitrate = 0; unsigned int bitrate = 0;
double quality = 0.0; double quality = 0.0;
const char * server = 0; const char * server = 0;
@ -357,15 +400,37 @@ DarkIce :: configIceCast2 ( const Config & config,
str = cs->get( "quality"); str = cs->get( "quality");
quality = str ? Util::strToD( str) : 0.0; quality = str ? Util::strToD( str) : 0.0;
if ( bitrate == 0 && quality == 0.0 ) { str = cs->getForSure( "bitrateMode",
throw Exception( __FILE__, __LINE__, " not specified in section ",
"neither fixed bitrate nor VBR quality specified in ",
stream); stream);
if ( Util::strEq( str, "cbr") ) {
bitrateMode = AudioEncoder::cbr;
if ( bitrate == 0 ) {
throw Exception( __FILE__, __LINE__,
"bitrate not specified for CBR encoding");
} }
if ( bitrate != 0 && quality != 0.0 ) { if ( quality == 0 ) {
throw Exception( __FILE__, __LINE__, throw Exception( __FILE__, __LINE__,
"both fixed bitrate and VBR quality specified in ", "quality not specified for CBR encoding");
stream); }
} else if ( Util::strEq( str, "abr") ) {
bitrateMode = AudioEncoder::abr;
if ( bitrate == 0 ) {
throw Exception( __FILE__, __LINE__,
"bitrate not specified for ABR encoding");
}
} else if ( Util::strEq( str, "vbr") ) {
bitrateMode = AudioEncoder::vbr;
if ( quality == 0 ) {
throw Exception( __FILE__, __LINE__,
"quality not specified for VBR encoding");
}
} else {
throw Exception( __FILE__, __LINE__,
"invalid bitrate mode: ", str);
} }
server = cs->getForSure( "server", " missing in section ", stream); server = cs->getForSure( "server", " missing in section ", stream);
@ -429,7 +494,9 @@ DarkIce :: configIceCast2 ( const Config & config,
audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].encoder = new LameLibEncoder(
audioOuts[u].server.get(), audioOuts[u].server.get(),
dsp.get(), dsp.get(),
bitrateMode,
bitrate, bitrate,
quality,
sampleRate, sampleRate,
dsp->getChannel() ); dsp->getChannel() );
#endif // HAVE_LAME_LIB #endif // HAVE_LAME_LIB
@ -442,21 +509,14 @@ DarkIce :: configIceCast2 ( const Config & config,
"thus can't Ogg Vorbis stream: ", "thus can't Ogg Vorbis stream: ",
stream); stream);
#else #else
if ( bitrate != 0 ) {
audioOuts[u].encoder = new VorbisLibEncoder( audioOuts[u].encoder = new VorbisLibEncoder(
audioOuts[u].server.get(), audioOuts[u].server.get(),
dsp.get(), dsp.get(),
bitrateMode,
bitrate, bitrate,
sampleRate,
dsp->getChannel() );
} else {
audioOuts[u].encoder = new VorbisLibEncoder(
audioOuts[u].server.get(),
dsp.get(),
quality, quality,
sampleRate, sampleRate,
dsp->getChannel() ); dsp->getChannel() );
}
#endif // HAVE_VORBIS_LIB #endif // HAVE_VORBIS_LIB
break; break;
@ -480,7 +540,7 @@ DarkIce :: configShoutCast ( const Config & config,
unsigned int bufferSecs ) unsigned int bufferSecs )
throw ( Exception ) throw ( Exception )
{ {
// look for IceCast encoder output streams, // look for Shoutcast encoder output streams,
// sections [shoutcast-0], [shoutcast-1], ... // sections [shoutcast-0], [shoutcast-1], ...
char stream[] = "shoutcast- "; char stream[] = "shoutcast- ";
size_t streamLen = Util::strLen( stream); size_t streamLen = Util::strLen( stream);
@ -506,7 +566,9 @@ DarkIce :: configShoutCast ( const Config & config,
const char * str; const char * str;
unsigned int sampleRate = 0; unsigned int sampleRate = 0;
AudioEncoder::BitrateMode bitrateMode;
unsigned int bitrate = 0; unsigned int bitrate = 0;
double quality = 0.0;
const char * server = 0; const char * server = 0;
unsigned int port = 0; unsigned int port = 0;
const char * password = 0; const char * password = 0;
@ -524,8 +586,45 @@ DarkIce :: configShoutCast ( const Config & config,
str = cs->get( "sampleRate"); str = cs->get( "sampleRate");
sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); sampleRate = str ? Util::strToL( str) : dsp->getSampleRate();
str = cs->getForSure("bitrate", " missing in section ", stream);
bitrate = Util::strToL( str); str = cs->get( "bitrate");
bitrate = str ? Util::strToL( str) : 0;
str = cs->get( "quality");
quality = str ? Util::strToD( str) : 0.0;
str = cs->getForSure( "bitrateMode",
" not specified in section ",
stream);
if ( Util::strEq( str, "cbr") ) {
bitrateMode = AudioEncoder::cbr;
if ( bitrate == 0 ) {
throw Exception( __FILE__, __LINE__,
"bitrate not specified for CBR encoding");
}
if ( quality == 0 ) {
throw Exception( __FILE__, __LINE__,
"quality not specified for CBR encoding");
}
} else if ( Util::strEq( str, "abr") ) {
bitrateMode = AudioEncoder::abr;
if ( bitrate == 0 ) {
throw Exception( __FILE__, __LINE__,
"bitrate not specified for ABR encoding");
}
} else if ( Util::strEq( str, "vbr") ) {
bitrateMode = AudioEncoder::vbr;
if ( quality == 0 ) {
throw Exception( __FILE__, __LINE__,
"quality not specified for VBR encoding");
}
} else {
throw Exception( __FILE__, __LINE__,
"invalid bitrate mode: ", str);
}
server = cs->getForSure( "server", " missing in section ", stream); server = cs->getForSure( "server", " missing in section ", stream);
str = cs->getForSure( "port", " missing in section ", stream); str = cs->getForSure( "port", " missing in section ", stream);
port = Util::strToL( str); port = Util::strToL( str);
@ -581,7 +680,9 @@ DarkIce :: configShoutCast ( const Config & config,
audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(), audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].server.get(),
dsp.get(), dsp.get(),
bitrateMode,
bitrate, bitrate,
quality,
sampleRate, sampleRate,
dsp->getChannel(), dsp->getChannel(),
lowpass, lowpass,
@ -621,7 +722,9 @@ DarkIce :: configFileCast ( const Config & config )
const char * str; const char * str;
const char * format = 0; const char * format = 0;
AudioEncoder::BitrateMode bitrateMode;
unsigned int bitrate = 0; unsigned int bitrate = 0;
double quality = 0.0;
const char * targetFileName = 0; const char * targetFileName = 0;
unsigned int sampleRate = 0; unsigned int sampleRate = 0;
int lowpass = 0; int lowpass = 0;
@ -640,6 +743,45 @@ DarkIce :: configFileCast ( const Config & config )
stream); stream);
str = cs->get( "sampleRate"); str = cs->get( "sampleRate");
sampleRate = str ? Util::strToL( str) : dsp->getSampleRate(); sampleRate = str ? Util::strToL( str) : dsp->getSampleRate();
str = cs->get( "bitrate");
bitrate = str ? Util::strToL( str) : 0;
str = cs->get( "quality");
quality = str ? Util::strToD( str) : 0.0;
str = cs->getForSure( "bitrateMode",
" not specified in section ",
stream);
if ( Util::strEq( str, "cbr") ) {
bitrateMode = AudioEncoder::cbr;
if ( bitrate == 0 ) {
throw Exception( __FILE__, __LINE__,
"bitrate not specified for CBR encoding");
}
if ( quality == 0 ) {
throw Exception( __FILE__, __LINE__,
"quality not specified for CBR encoding");
}
} else if ( Util::strEq( str, "abr") ) {
bitrateMode = AudioEncoder::abr;
if ( bitrate == 0 ) {
throw Exception( __FILE__, __LINE__,
"bitrate not specified for ABR encoding");
}
} else if ( Util::strEq( str, "vbr") ) {
bitrateMode = AudioEncoder::vbr;
if ( quality == 0 ) {
throw Exception( __FILE__, __LINE__,
"quality not specified for VBR encoding");
}
} else {
throw Exception( __FILE__, __LINE__,
"invalid bitrate mode: ", str);
}
str = cs->get( "lowpass"); str = cs->get( "lowpass");
lowpass = str ? Util::strToL( str) : 0; lowpass = str ? Util::strToL( str) : 0;
str = cs->get( "highpass"); str = cs->get( "highpass");
@ -670,7 +812,9 @@ DarkIce :: configFileCast ( const Config & config )
audioOuts[u].encoder = new LameLibEncoder( audioOuts[u].encoder = new LameLibEncoder(
audioOuts[u].server.get(), audioOuts[u].server.get(),
dsp.get(), dsp.get(),
bitrateMode,
bitrate, bitrate,
quality,
sampleRate, sampleRate,
dsp->getChannel(), dsp->getChannel(),
lowpass, lowpass,
@ -686,7 +830,9 @@ DarkIce :: configFileCast ( const Config & config )
audioOuts[u].encoder = new VorbisLibEncoder( audioOuts[u].encoder = new VorbisLibEncoder(
audioOuts[u].server.get(), audioOuts[u].server.get(),
dsp.get(), dsp.get(),
bitrateMode,
bitrate, bitrate,
quality,
dsp->getSampleRate(), dsp->getSampleRate(),
dsp->getChannel() ); dsp->getChannel() );
#endif // HAVE_VORBIS_LIB #endif // HAVE_VORBIS_LIB
@ -834,6 +980,9 @@ DarkIce :: run ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.27 2002/04/13 11:26:00 darkeye
added cbr, abr and vbr setting feature with encoding quality
Revision 1.26 2002/03/28 16:43:11 darkeye Revision 1.26 2002/03/28 16:43:11 darkeye
enabled resampling and variable bitrates for vorbis (icecast2) streams enabled resampling and variable bitrates for vorbis (icecast2) streams

View File

@ -37,6 +37,7 @@
#ifdef HAVE_LAME_LIB #ifdef HAVE_LAME_LIB
#include "Exception.h" #include "Exception.h"
#include "Util.h" #include "Util.h"
#include "LameLibEncoder.h" #include "LameLibEncoder.h"
@ -117,13 +118,81 @@ LameLibEncoder :: open ( void )
"set lame out sample rate", "set lame out sample rate",
lame_get_out_samplerate( lameGlobalFlags)); lame_get_out_samplerate( lameGlobalFlags));
switch ( getOutBitrateMode() ) {
case cbr: {
if ( 0 > lame_set_brate( lameGlobalFlags, getOutBitrate()) ) { if ( 0 > lame_set_brate( lameGlobalFlags, getOutBitrate()) ) {
throw Exception( __FILE__, __LINE__, throw Exception( __FILE__, __LINE__,
"lame lib setting output bit rate error", "lame lib setting output bit rate error",
getOutBitrate() ); getOutBitrate() );
} }
reportEvent( 5, "set lame bit rate", lame_get_brate( lameGlobalFlags)); reportEvent( 5,
"set lame bit rate",
lame_get_brate( lameGlobalFlags));
double d = (1.0 - getOutQuality()) * 10.0;
int q = int (d + 0.499999);
if ( 0 > lame_set_quality( lameGlobalFlags, q) ) {
throw Exception( __FILE__, __LINE__,
"lame lib setting quality error", q);
}
reportEvent( 5,
"set lame quality",
lame_get_quality( lameGlobalFlags));
} break;
case abr:
if ( 0 > lame_set_VBR( lameGlobalFlags,vbr_abr)) {
throw Exception( __FILE__, __LINE__,
"lame lib setting abr error", vbr_abr);
}
reportEvent( 5,
"set lame abr bitrate",
lame_get_VBR( lameGlobalFlags));
if ( 0 > lame_set_VBR_mean_bitrate_kbps( lameGlobalFlags,
getOutBitrate())) {
throw Exception( __FILE__, __LINE__,
"lame lib setting abr mean bitrate error",
getOutBitrate());
}
reportEvent( 5,
"set lame abr mean bitrate",
lame_get_VBR_mean_bitrate_kbps( lameGlobalFlags));
break;
case vbr: {
if ( 0 > lame_set_VBR( lameGlobalFlags, vbr_mtrh)) {
throw Exception( __FILE__, __LINE__,
"lame lib setting vbr error", vbr_mtrh );
}
reportEvent( 5,
"set lame vbr bitrate",
lame_get_VBR( lameGlobalFlags));
double d = (1.0 - getOutQuality()) * 10.0;
int q = int (d + 0.499999);
if ( 0 > lame_set_VBR_q( lameGlobalFlags, q) ) {
throw Exception( __FILE__, __LINE__,
"lame lib setting vbr quality error", q);
}
reportEvent( 5,
"set lame vbr quality",
lame_get_VBR_q( lameGlobalFlags));
} break;
}
if ( 0 > lame_set_lowpassfreq( lameGlobalFlags, lowpass) ) { if ( 0 > lame_set_lowpassfreq( lameGlobalFlags, lowpass) ) {
throw Exception( __FILE__, __LINE__, throw Exception( __FILE__, __LINE__,
@ -145,16 +214,11 @@ LameLibEncoder :: open ( void )
"set lame highpass frequency", "set lame highpass frequency",
lame_get_highpassfreq( lameGlobalFlags)); lame_get_highpassfreq( lameGlobalFlags));
// not configurable lame settings // not configurable lame settings
if ( 0 > lame_set_quality( lameGlobalFlags, 2) ) {
throw Exception( __FILE__, __LINE__,
"lame lib setting quality error",
2 );
}
reportEvent( 5, "set lame quality", lame_get_quality( lameGlobalFlags));
if ( 0 > lame_set_exp_nspsytune( lameGlobalFlags, 1) ) { if ( 0 > lame_set_exp_nspsytune( lameGlobalFlags, 1) ) {
throw Exception( __FILE__, __LINE__, throw Exception( __FILE__, __LINE__,
"lame lib setting psycho acoustic model error"); "lame lib setting psycho acoustic model error");
@ -315,6 +379,9 @@ LameLibEncoder :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.11 2002/04/13 11:26:00 darkeye
added cbr, abr and vbr setting feature with encoding quality
Revision 1.10 2002/03/28 16:38:37 darkeye Revision 1.10 2002/03/28 16:38:37 darkeye
moved functions conv8() and conv16() to class Util moved functions conv8() and conv16() to class Util

View File

@ -164,11 +164,14 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
* @param inSampleRate sample rate of the input. * @param inSampleRate sample rate of the input.
* @param inBitsPerSample number of bits per sample of the input. * @param inBitsPerSample number of bits per sample of the input.
* @param inChannel number of channels of the input. * @param inChannel number of channels of the input.
* @param outBitrate bit rate of the output (bits/sec). * @param outBitrateMode the bit rate mode of the output.
* @param outBitrate bit rate of the output (kbits/sec).
* @param outQuality the quality of the stream.
* @param outSampleRate sample rate of the output. * @param outSampleRate sample rate of the output.
* If 0, inSampleRate is used. * If 0, inSampleRate is used.
* @param outChannel number of channels of the output. * @param outChannel number of channels of the output.
* If 0, inChannel is used. * If 0, inChannel is used.
* @param inBigEndian shows if the input is big or little endian
* @param lowpass frequency threshold for the lowpass filter. * @param lowpass frequency threshold for the lowpass filter.
* Input above this frequency is cut. * Input above this frequency is cut.
* If 0, lame's default values are used, * If 0, lame's default values are used,
@ -184,7 +187,10 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
unsigned int inSampleRate, unsigned int inSampleRate,
unsigned int inBitsPerSample, unsigned int inBitsPerSample,
unsigned int inChannel, unsigned int inChannel,
bool inBigEndian,
BitrateMode outBitrateMode,
unsigned int outBitrate, unsigned int outBitrate,
double outQuality,
unsigned int outSampleRate = 0, unsigned int outSampleRate = 0,
unsigned int outChannel = 0, unsigned int outChannel = 0,
int lowpass = 0, int lowpass = 0,
@ -194,11 +200,14 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
: AudioEncoder ( inSampleRate, : AudioEncoder ( inSampleRate,
inBitsPerSample, inBitsPerSample,
inChannel, inChannel,
inBigEndian,
outBitrateMode,
outBitrate, outBitrate,
outQuality,
outSampleRate, outSampleRate,
outChannel ) outChannel )
{ {
init( sink, lowpass, highpass ); init( sink, lowpass, highpass);
} }
/** /**
@ -207,7 +216,9 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
* @param sink the sink to send mp3 output to * @param sink the sink to send mp3 output to
* @param as get input sample rate, bits per sample and channels * @param as get input sample rate, bits per sample and channels
* from this AudioSource. * from this AudioSource.
* @param outBitrate bit rate of the output (bits/sec). * @param outBitrateMode the bit rate mode of the output.
* @param outBitrate bit rate of the output (kbits/sec).
* @param outQuality the quality of the stream.
* @param outSampleRate sample rate of the output. * @param outSampleRate sample rate of the output.
* If 0, input sample rate is used. * If 0, input sample rate is used.
* @param outChannel number of channels of the output. * @param outChannel number of channels of the output.
@ -225,7 +236,9 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
inline inline
LameLibEncoder ( Sink * sink, LameLibEncoder ( Sink * sink,
const AudioSource * as, const AudioSource * as,
BitrateMode outBitrateMode,
unsigned int outBitrate, unsigned int outBitrate,
double outQuality,
unsigned int outSampleRate = 0, unsigned int outSampleRate = 0,
unsigned int outChannel = 0, unsigned int outChannel = 0,
int lowpass = 0, int lowpass = 0,
@ -233,11 +246,13 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
throw ( Exception ) throw ( Exception )
: AudioEncoder ( as, : AudioEncoder ( as,
outBitrateMode,
outBitrate, outBitrate,
outQuality,
outSampleRate, outSampleRate,
outChannel ) outChannel )
{ {
init( sink, lowpass, highpass ); init( sink, lowpass, highpass);
} }
/** /**
@ -253,6 +268,7 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
init( encoder.sink.get(), encoder.lowpass, encoder.highpass ); init( encoder.sink.get(), encoder.lowpass, encoder.highpass );
} }
/** /**
* Destructor. * Destructor.
* *
@ -420,6 +436,9 @@ class LameLibEncoder : public AudioEncoder, public virtual Reporter
$Source$ $Source$
$Log$ $Log$
Revision 1.12 2002/04/13 11:26:00 darkeye
added cbr, abr and vbr setting feature with encoding quality
Revision 1.11 2002/03/28 16:38:37 darkeye Revision 1.11 2002/03/28 16:38:37 darkeye
moved functions conv8() and conv16() to class Util moved functions conv8() and conv16() to class Util

View File

@ -73,22 +73,16 @@ VorbisLibEncoder :: open ( void )
vorbis_info_init( &vorbisInfo); vorbis_info_init( &vorbisInfo);
if ( isVBR() ) { switch ( getOutBitrateMode() ) {
if ( (ret = vorbis_encode_init_vbr( &vorbisInfo, case cbr:
getInChannel(), case abr:
getOutSampleRate(),
getOutQuality() )) ) {
throw Exception( __FILE__, __LINE__,
"vorbis encode init error", ret);
}
} else {
#ifdef VORBIS_LIB_RC3 #ifdef VORBIS_LIB_RC3
if ( (ret = vorbis_encode_init( &vorbisInfo, if ( (ret = vorbis_encode_init( &vorbisInfo,
getInChannel(), getInChannel(),
getOutSampleRate(), getOutSampleRate(),
getOutBitrate() * 1024, getOutBitrate() * 1000,
getOutBitrate() * 1024, getOutBitrate() * 1000,
-1 )) ) { -1 )) ) {
throw Exception( __FILE__, __LINE__, throw Exception( __FILE__, __LINE__,
"vorbis encode init error", ret); "vorbis encode init error", ret);
@ -98,12 +92,24 @@ VorbisLibEncoder :: open ( void )
getInChannel(), getInChannel(),
getOutSampleRate(), getOutSampleRate(),
-1, -1,
getOutBitrate() * 1024, getOutBitrate() * 1000,
-1 )) ) { -1 )) ) {
throw Exception( __FILE__, __LINE__, throw Exception( __FILE__, __LINE__,
"vorbis encode init error", ret); "vorbis encode init error", ret);
} }
#endif #endif
break;
case vbr:
if ( (ret = vorbis_encode_init_vbr( &vorbisInfo,
getInChannel(),
getOutSampleRate(),
getOutQuality() )) ) {
throw Exception( __FILE__, __LINE__,
"vorbis encode init error", ret);
}
break;
} }
if ( (ret = vorbis_analysis_init( &vorbisDspState, &vorbisInfo)) ) { if ( (ret = vorbis_analysis_init( &vorbisDspState, &vorbisInfo)) ) {
@ -310,6 +316,9 @@ VorbisLibEncoder :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.8 2002/04/13 11:26:00 darkeye
added cbr, abr and vbr setting feature with encoding quality
Revision 1.7 2002/03/28 16:47:38 darkeye Revision 1.7 2002/03/28 16:47:38 darkeye
moved functions conv8() and conv16() to class Util (as conv()) moved functions conv8() and conv16() to class Util (as conv())
added resampling functionality added resampling functionality

View File

@ -191,13 +191,16 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
public: public:
/** /**
* Constructor for fixed bitrate encoding. * Constructor.
* *
* @param sink the sink to send mp3 output to * @param sink the sink to send mp3 output to
* @param inSampleRate sample rate of the input. * @param inSampleRate sample rate of the input.
* @param inBitsPerSample number of bits per sample of the input. * @param inBitsPerSample number of bits per sample of the input.
* @param inChannel number of channels of the input. * @param inChannel number of channels of the input.
* @param inBigEndian shows if the input is big or little endian
* @param outBitrateMode the bit rate mode of the output.
* @param outBitrate bit rate of the output (kbits/sec). * @param outBitrate bit rate of the output (kbits/sec).
* @param outQuality the quality of the stream.
* @param outSampleRate sample rate of the output. * @param outSampleRate sample rate of the output.
* If 0, inSampleRate is used. * If 0, inSampleRate is used.
* @param outChannel number of channels of the output. * @param outChannel number of channels of the output.
@ -209,40 +212,9 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
unsigned int inSampleRate, unsigned int inSampleRate,
unsigned int inBitsPerSample, unsigned int inBitsPerSample,
unsigned int inChannel, unsigned int inChannel,
bool inBigEndian,
BitrateMode outBitrateMode,
unsigned int outBitrate, unsigned int outBitrate,
unsigned int outSampleRate = 0,
unsigned int outChannel = 0 )
throw ( Exception )
: AudioEncoder ( inSampleRate,
inBitsPerSample,
inChannel,
outBitrate,
outSampleRate,
outChannel )
{
init( sink);
}
/**
* Constructor for variable bitrate encoding.
*
* @param sink the sink to send mp3 output to
* @param inSampleRate sample rate of the input.
* @param inBitsPerSample number of bits per sample of the input.
* @param inChannel number of channels of the input.
* @param outQuality the quality of the stream (0.0 .. 1.0).
* @param outSampleRate sample rate of the output.
* If 0, inSampleRate is used.
* @param outChannel number of channels of the output.
* If 0, inChannel is used.
* @exception Exception
*/
inline
VorbisLibEncoder ( Sink * sink,
unsigned int inSampleRate,
unsigned int inBitsPerSample,
unsigned int inChannel,
double outQuality, double outQuality,
unsigned int outSampleRate = 0, unsigned int outSampleRate = 0,
unsigned int outChannel = 0 ) unsigned int outChannel = 0 )
@ -251,6 +223,9 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
: AudioEncoder ( inSampleRate, : AudioEncoder ( inSampleRate,
inBitsPerSample, inBitsPerSample,
inChannel, inChannel,
inBigEndian,
outBitrateMode,
outBitrate,
outQuality, outQuality,
outSampleRate, outSampleRate,
outChannel ) outChannel )
@ -259,12 +234,14 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
} }
/** /**
* Constructor for fixed bitrate encoding. * Constructor.
* *
* @param sink the sink to send mp3 output to * @param sink the sink to send mp3 output to
* @param as get input sample rate, bits per sample and channels * @param as get input sample rate, bits per sample and channels
* from this AudioSource. * from this AudioSource.
* @param outBitrateMode the bit rate mode of the output.
* @param outBitrate bit rate of the output (kbits/sec). * @param outBitrate bit rate of the output (kbits/sec).
* @param outQuality the quality of the stream.
* @param outSampleRate sample rate of the output. * @param outSampleRate sample rate of the output.
* If 0, input sample rate is used. * If 0, input sample rate is used.
* @param outChannel number of channels of the output. * @param outChannel number of channels of the output.
@ -274,41 +251,16 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
inline inline
VorbisLibEncoder ( Sink * sink, VorbisLibEncoder ( Sink * sink,
const AudioSource * as, const AudioSource * as,
BitrateMode outBitrateMode,
unsigned int outBitrate, unsigned int outBitrate,
unsigned int outSampleRate = 0,
unsigned int outChannel = 0 )
throw ( Exception )
: AudioEncoder ( as,
outBitrate,
outSampleRate,
outChannel )
{
init( sink);
}
/**
* Constructor for variable bitrate encoding.
*
* @param sink the sink to send mp3 output to
* @param as get input sample rate, bits per sample and channels
* from this AudioSource.
* @param outQuality the quality of the stream (0.0 .. 1.0).
* @param outSampleRate sample rate of the output.
* If 0, input sample rate is used.
* @param outChannel number of channels of the output.
* If 0, input channel is used.
* @exception Exception
*/
inline
VorbisLibEncoder ( Sink * sink,
const AudioSource * as,
double outQuality, double outQuality,
unsigned int outSampleRate = 0, unsigned int outSampleRate = 0,
unsigned int outChannel = 0 ) unsigned int outChannel = 0 )
throw ( Exception ) throw ( Exception )
: AudioEncoder ( as, : AudioEncoder ( as,
outBitrateMode,
outBitrate,
outQuality, outQuality,
outSampleRate, outSampleRate,
outChannel ) outChannel )
@ -493,6 +445,9 @@ class VorbisLibEncoder : public AudioEncoder, public virtual Reporter
$Source$ $Source$
$Log$ $Log$
Revision 1.5 2002/04/13 11:26:00 darkeye
added cbr, abr and vbr setting feature with encoding quality
Revision 1.4 2002/03/28 16:47:38 darkeye Revision 1.4 2002/03/28 16:47:38 darkeye
moved functions conv8() and conv16() to class Util (as conv()) moved functions conv8() and conv16() to class Util (as conv())
added resampling functionality added resampling functionality