Whitespace cleanup

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
master
Alexander Golubev 3 weeks ago
parent 6e0631b21a
commit baa4672751

@ -13,12 +13,12 @@ MPC_INT64 StreamInfo::GetLenthSamples()
} else {
samples -= MPC_decoder::SynthDelay;
}
return samples;
return samples;
}
double StreamInfo::GetLength()
{
return (double)GetLenthSamples() / (double)simple.SampleFreq;
return (double)GetLenthSamples() / (double)simple.SampleFreq;
}

@ -41,103 +41,103 @@ MPC_decoder::RESET_Globals ( void )
unsigned int
MPC_decoder::decode_internal ( MPC_SAMPLE_FORMAT *buffer )
{
unsigned int output_frame_length = FrameLength;
unsigned int FrameBitCnt = 0;
if ( DecodedFrames >= OverallFrames )
return (unsigned int)(-1); // end of file -> abort decoding
// read jump-info for validity check of frame
FwdJumpInfo = Bitstream_read (20);
SeekTable [DecodedFrames] = 20 + FwdJumpInfo; // ...
ActDecodePos = (Zaehler << 5) + pos;
// decode data and check for validity of frame
FrameBitCnt = BitsRead ();
switch ( StreamVersion ) {
case 0x04:
case 0x05:
case 0x06:
Lese_Bitstrom_SV6 ();
break;
case 0x07:
case 0x17:
Lese_Bitstrom_SV7 ();
break;
default:
return (unsigned int)(-1);
}
FrameWasValid = BitsRead() - FrameBitCnt == FwdJumpInfo;
// synthesize signal
Requantisierung ( Max_Band );
//if ( EQ_activated && PluginSettings.EQbyMPC )
// perform_EQ ();
Synthese_Filter_float ( buffer );
DecodedFrames++;
// cut off first SynthDelay zero-samples
if ( DecodedFrames == OverallFrames && StreamVersion >= 6 )
{ // reconstruct exact filelength
int mod_block = Bitstream_read (11);
int FilterDecay;
if (mod_block == 0) mod_block = 1152; // Encoder bugfix
FilterDecay = (mod_block + SynthDelay) % FrameLength;
// additional FilterDecay samples are needed for decay of synthesis filter
if ( SynthDelay + mod_block >= FrameLength ) {
// **********************************************************************
// Rhoades 4/16/2002
// Commented out are blocks of code which cause gapless playback to fail.
// Temporary fix...
// **********************************************************************
if ( ! TrueGaplessPresent ) {
RESET_Y ();
} else {
//if ( FrameLength != LastValidSamples ) {
Bitstream_read (20);
Lese_Bitstrom_SV7 ();
Requantisierung ( Max_Band );
//FilterDecay = LastValidSamples;
//}
//else {
//FilterDecay = 0;
//}
}
Synthese_Filter_float ( buffer + 2304 );
output_frame_length = FrameLength + FilterDecay;
}
else { // there are only FilterDecay samples needed for this frame
output_frame_length = FilterDecay;
}
}
if ( samples_to_skip ) {
if (output_frame_length < samples_to_skip)
{
samples_to_skip -= output_frame_length;
output_frame_length = 0;
}
else
{
output_frame_length -= samples_to_skip;
memmove ( buffer, buffer + samples_to_skip * 2, output_frame_length * 2 * sizeof (MPC_SAMPLE_FORMAT) );
samples_to_skip = 0;
}
}
return output_frame_length;
unsigned int output_frame_length = FrameLength;
unsigned int FrameBitCnt = 0;
if ( DecodedFrames >= OverallFrames )
return (unsigned int)(-1); // end of file -> abort decoding
// read jump-info for validity check of frame
FwdJumpInfo = Bitstream_read (20);
SeekTable [DecodedFrames] = 20 + FwdJumpInfo; // ...
ActDecodePos = (Zaehler << 5) + pos;
// decode data and check for validity of frame
FrameBitCnt = BitsRead ();
switch ( StreamVersion ) {
case 0x04:
case 0x05:
case 0x06:
Lese_Bitstrom_SV6 ();
break;
case 0x07:
case 0x17:
Lese_Bitstrom_SV7 ();
break;
default:
return (unsigned int)(-1);
}
FrameWasValid = BitsRead() - FrameBitCnt == FwdJumpInfo;
// synthesize signal
Requantisierung ( Max_Band );
//if ( EQ_activated && PluginSettings.EQbyMPC )
// perform_EQ ();
Synthese_Filter_float ( buffer );
DecodedFrames++;
// cut off first SynthDelay zero-samples
if ( DecodedFrames == OverallFrames && StreamVersion >= 6 )
{ // reconstruct exact filelength
int mod_block = Bitstream_read (11);
int FilterDecay;
if (mod_block == 0) mod_block = 1152; // Encoder bugfix
FilterDecay = (mod_block + SynthDelay) % FrameLength;
// additional FilterDecay samples are needed for decay of synthesis filter
if ( SynthDelay + mod_block >= FrameLength ) {
// **********************************************************************
// Rhoades 4/16/2002
// Commented out are blocks of code which cause gapless playback to fail.
// Temporary fix...
// **********************************************************************
if ( ! TrueGaplessPresent ) {
RESET_Y ();
} else {
//if ( FrameLength != LastValidSamples ) {
Bitstream_read (20);
Lese_Bitstrom_SV7 ();
Requantisierung ( Max_Band );
//FilterDecay = LastValidSamples;
//}
//else {
//FilterDecay = 0;
//}
}
Synthese_Filter_float ( buffer + 2304 );
output_frame_length = FrameLength + FilterDecay;
}
else { // there are only FilterDecay samples needed for this frame
output_frame_length = FilterDecay;
}
}
if ( samples_to_skip ) {
if (output_frame_length < samples_to_skip)
{
samples_to_skip -= output_frame_length;
output_frame_length = 0;
}
else
{
output_frame_length -= samples_to_skip;
memmove ( buffer, buffer + samples_to_skip * 2, output_frame_length * 2 * sizeof (MPC_SAMPLE_FORMAT) );
samples_to_skip = 0;
}
}
return output_frame_length;
}
@ -158,20 +158,20 @@ unsigned int MPC_decoder::Decode ( MPC_SAMPLE_FORMAT *buffer, unsigned int * vbr
if ( FrameWasValid == 0 ) { // error occurred in bitstream
return (unsigned int)(-1);
} else
{
if (vbr_update_acc && vbr_update_bits)
{
(*vbr_update_acc) ++;
vbr_ring = (Zaehler << 5) + pos - vbr_ring;
if (vbr_ring < 0) vbr_ring += 524288;
(*vbr_update_bits) += vbr_ring;
}
}
UpdateBuffer ( RING );
if (valid_samples > 0) return valid_samples;
}
{
if (vbr_update_acc && vbr_update_bits)
{
(*vbr_update_acc) ++;
vbr_ring = (Zaehler << 5) + pos - vbr_ring;
if (vbr_ring < 0) vbr_ring += 524288;
(*vbr_update_bits) += vbr_ring;
}
}
UpdateBuffer ( RING );
if (valid_samples > 0) return valid_samples;
}
}
void
@ -191,7 +191,7 @@ MPC_decoder::Requantisierung ( const int Last_Band )
#ifdef MPC_FIXED_POINT
#if MPC_FIXED_POINT_FRACTPART == 14
#define MPC_MULTIPLY_SCF(CcVal, SCF_idx) \
MPC_MULTIPLY_EX(CcVal,SCF[SCF_idx],SCF_shift[SCF_idx])
MPC_MULTIPLY_EX(CcVal,SCF[SCF_idx],SCF_shift[SCF_idx])
#else
#error FIXME, Cc table is in 18.14 format
@ -199,7 +199,7 @@ MPC_decoder::Requantisierung ( const int Last_Band )
#endif
#else
#define MPC_MULTIPLY_SCF(CcVal, SCF_idx) \
MPC_MULTIPLY(CcVal,SCF[SCF_idx])
MPC_MULTIPLY(CcVal,SCF[SCF_idx])
#endif
// requantization and scaling of subband-samples
for ( Band = 0; Band <= Last_Band; Band++ ) { // setting pointers
@ -232,7 +232,7 @@ MPC_decoder::Requantisierung ( const int Last_Band )
} else { // M!=0, S==0
facL = MPC_MULTIPLY_SCF( Cc[Res_L[Band]] , (unsigned char)SCF_Index_L[Band][0]);
for ( n = 0; n < 12; n++, YL += 32, YR += 32 ) {
*YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
*YR = *YL = MPC_MULTIPLY_FLOAT_INT(facL,*L++);
}
facL = MPC_MULTIPLY_SCF( Cc[Res_L[Band]] , (unsigned char)SCF_Index_L[Band][1]);
for ( ; n < 24; n++, YL += 32, YR += 32 ) {
@ -886,8 +886,8 @@ MPC_decoder::MPC_decoder ( MPC_reader *r, double scale_factor )
void MPC_decoder::SetStreamInfo ( const StreamInfo *si )
{
RESET_Synthesis ();
RESET_Globals ();
RESET_Synthesis ();
RESET_Globals ();
StreamVersion = si->simple.StreamVersion;
MS_used = si->simple.MS;
@ -899,14 +899,14 @@ void MPC_decoder::SetStreamInfo ( const StreamInfo *si )
SampleRate = (int)si->simple.SampleFreq;
if ( SeekTable != NULL ) free ( SeekTable );
SeekTable = (unsigned short *)calloc ( sizeof(unsigned short), OverallFrames+64 );
SeekTable = (unsigned short *)calloc ( OverallFrames+64, sizeof(unsigned short) );
samples_to_skip = SynthDelay;
}
bool MPC_decoder::Initialize(const StreamInfo * info)
{
SetStreamInfo(info);
SetStreamInfo(info);
// AB: setting position to the beginning of the data-bitstream
switch ( StreamVersion ) {
@ -971,7 +971,7 @@ static unsigned int get_initial_fpos(unsigned int StreamVersion)
case 0x07:
case 0x17: fpos = 200; break;
}
return fpos;
return fpos;
}
bool MPC_decoder::SeekSeconds ( double seconds )
@ -985,8 +985,8 @@ bool MPC_decoder::SeekSample(MPC_INT64 destsample)
unsigned long fpos;
unsigned int fwd;
fwd = (unsigned) (destsample / FrameLength);
samples_to_skip = SynthDelay + (unsigned)(destsample % FrameLength);
fwd = (unsigned) (destsample / FrameLength);
samples_to_skip = SynthDelay + (unsigned)(destsample % FrameLength);
memset ( Y_L , 0, sizeof Y_L );
memset ( Y_R , 0, sizeof Y_R );
@ -1058,17 +1058,17 @@ void MPC_decoder::UpdateBuffer ( unsigned int RING )
static unsigned long swap32(unsigned long val)
{
const unsigned char * src = (const unsigned char*)&val;
return (unsigned long)src[0] | ((unsigned long)src[1] << 8) | ((unsigned long)src[2] << 16) | ((unsigned long)src[3] << 24);
const unsigned char * src = (const unsigned char*)&val;
return (unsigned long)src[0] | ((unsigned long)src[1] << 8) | ((unsigned long)src[2] << 16) | ((unsigned long)src[3] << 24);
}
int MPC_decoder::f_read_dword( unsigned int * ptr, unsigned int count)
{
count = f_read(ptr,count << 2) >> 2;
count = f_read(ptr,count << 2) >> 2;
#ifndef MPC_LITTLE_ENDIAN
unsigned int n;
for(n=0;n<count;n++)
ptr[n] = swap32(ptr[n]);
unsigned int n;
for(n=0;n<count;n++)
ptr[n] = swap32(ptr[n]);
#endif
return count;
return count;
}

@ -31,24 +31,24 @@ typedef MPC_INT64 MPC_SAMPLE_FORMAT_MULTIPLY;
#define MAKE_MPC_SAMPLE_EX(X,Y) (MPC_SAMPLE_FORMAT)((double)(X) * (double)(((MPC_INT64)1)<<(Y)))
#define MPC_MULTIPLY_NOTRUNCATE(X,Y) \
(((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> MPC_FIXED_POINT_FRACTPART)
(((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> MPC_FIXED_POINT_FRACTPART)
#define MPC_MULTIPLY_EX_NOTRUNCATE(X,Y,Z) \
(((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> (Z))
(((MPC_SAMPLE_FORMAT_MULTIPLY)(X) * (MPC_SAMPLE_FORMAT_MULTIPLY)(Y)) >> (Z))
#ifdef _DEBUG
static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2)
{
MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_NOTRUNCATE(item1,item2);
assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp);
return (MPC_SAMPLE_FORMAT)temp;
MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_NOTRUNCATE(item1,item2);
assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp);
return (MPC_SAMPLE_FORMAT)temp;
}
static inline MPC_SAMPLE_FORMAT MPC_MULTIPLY_EX(MPC_SAMPLE_FORMAT item1,MPC_SAMPLE_FORMAT item2,unsigned shift)
{
MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_EX_NOTRUNCATE(item1,item2,shift);
assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp);
return (MPC_SAMPLE_FORMAT)temp;
MPC_SAMPLE_FORMAT_MULTIPLY temp = MPC_MULTIPLY_EX_NOTRUNCATE(item1,item2,shift);
assert(temp == (MPC_SAMPLE_FORMAT_MULTIPLY)(MPC_SAMPLE_FORMAT)temp);
return (MPC_SAMPLE_FORMAT)temp;
}
#else

@ -34,12 +34,12 @@ const int __Dc [1 + 18] = {
static unsigned find_shift(double fval)
{
MPC_INT64 val = (MPC_INT64)fval;
if (val<0) val = -val;
unsigned ptr = 0;
while(val) {val>>=1;ptr++;}
MPC_INT64 val = (MPC_INT64)fval;
if (val<0) val = -val;
unsigned ptr = 0;
while(val) {val>>=1;ptr++;}
return ptr > 31 ? 0 : 31 - ptr;
return ptr > 31 ? 0 : 31 - ptr;
}
/* F U N C T I O N S */
@ -50,24 +50,24 @@ void
MPC_decoder::ScaleOutput ( double factor )
{
#ifndef MPC_FIXED_POINT
factor *= 1.0 / (double)(1<<(MPC_FIXED_POINT_SHIFT-1));
factor *= 1.0 / (double)(1<<(MPC_FIXED_POINT_SHIFT-1));
#else
factor *= 1.0 / (double)(1<<(16 - MPC_FIXED_POINT_SHIFT));
factor *= 1.0 / (double)(1<<(16 - MPC_FIXED_POINT_SHIFT));
#endif
int n;
double f1 = factor;
double f2 = factor;
// handles +1.58...-98.41 dB, where's scf[n] / scf[n-1] = 1.20050805774840750476
SET_SCF(1,factor);
f1 *= 0.83298066476582673961;
f2 *= 1/0.83298066476582673961;
SET_SCF(1,factor);
f1 *= 0.83298066476582673961;
f2 *= 1/0.83298066476582673961;
for ( n = 1; n <= 128; n++ ) {
SET_SCF((unsigned char)(1+n),f1);
SET_SCF((unsigned char)(1-n),f2);
SET_SCF((unsigned char)(1+n),f1);
SET_SCF((unsigned char)(1-n),f2);
f1 *= 0.83298066476582673961;
f2 *= 1/0.83298066476582673961;
}

@ -145,8 +145,8 @@ int StreamInfo::ReadHeaderSV6 ( unsigned int HeaderData [8] )
static unsigned int swap32(unsigned int val)
{
const unsigned char * src = (const unsigned char*)&val;
return (unsigned int)src[0] | ((unsigned int)src[1] << 8) | ((unsigned int)src[2] << 16) | ((unsigned int)src[3] << 24);
const unsigned char * src = (const unsigned char*)&val;
return (unsigned int)src[0] | ((unsigned int)src[1] << 8) | ((unsigned int)src[2] << 16) | ((unsigned int)src[3] << 24);
}
// reads file header and tags
@ -158,19 +158,19 @@ int StreamInfo::ReadStreamInfo ( MPC_reader* fp)
//memset ( &simple, 0, sizeof (BasicData) ); // Reset Info-Data
if ( (simple.HeaderPosition = JumpID3v2 (fp)) < 0 ) // get header position
return ERROR_CODE_FILE;
if ( (simple.HeaderPosition = JumpID3v2 (fp)) < 0 ) // get header position
return ERROR_CODE_FILE;
if ( !fp->seek ( simple.HeaderPosition, SEEK_SET ) ) // seek to first byte of mpc data
return ERROR_CODE_FILE;
if ( !fp->seek ( simple.HeaderPosition, SEEK_SET ) ) // seek to first byte of mpc data
return ERROR_CODE_FILE;
if ( fp->read ( HeaderData, 8*4 ) != 8*4 )
return ERROR_CODE_FILE;
if (!fp->seek(simple.HeaderPosition+6*4,SEEK_SET)) return ERROR_CODE_FILE;
/* if ( fp->read ( HeaderData, 6*4 ) != 6*4 )
return ERROR_CODE_FILE;
HeaderData[6]=HeaderData[7]=0;
*/
if (!fp->seek(simple.HeaderPosition+6*4,SEEK_SET)) return ERROR_CODE_FILE;
/*
if ( fp->read ( HeaderData, 6*4 ) != 6*4 )
return ERROR_CODE_FILE;
HeaderData[6]=HeaderData[7]=0;
*/
/*
if ( fp->seek ( 0L, SEEK_END ) != 0 ) // get filelength
return ERROR_CODE_FILE;
@ -180,12 +180,12 @@ int StreamInfo::ReadStreamInfo ( MPC_reader* fp)
simple.TagOffset = simple.TotalFileLength;
if ( memcmp ( HeaderData, "MP+", 3 ) == 0 )
{
{
#ifndef MPC_LITTLE_ENDIAN
{
unsigned int ptr;
for(ptr=0;ptr<8;ptr++) HeaderData[ptr] = swap32(HeaderData[ptr]);
}
{
unsigned int ptr;
for(ptr=0;ptr<8;ptr++) HeaderData[ptr] = swap32(HeaderData[ptr]);
}
#endif
simple.StreamVersion = HeaderData[0] >> 24;

@ -202,14 +202,14 @@ static FLAC__StreamDecoderWriteStatus write_callback(
outFrame->sample_rate = frame->header.sample_rate;
if (channels == 1 || channels == 2)
outFrame->channel_config = aKode::MonoStereo;
outFrame->channel_config = aKode::MonoStereo;
else if (channels > 2 && channels < 8)
outFrame->channel_config = aKode::Surround;
outFrame->channel_config = aKode::Surround;
else
outFrame->channel_config = aKode::MultiChannel;
outFrame->channel_config = aKode::MultiChannel;
for(int i = 0; i<channels; i++) {
if (outFrame->data[i] == 0) break;
if (outFrame->data[i] == 0) break;
if (bits<=8) {
int8_t** data = (int8_t**)outFrame->data;
for(long j=0; j<frameSize; j++)
@ -245,15 +245,15 @@ static void metadata_callback(
data->max_block_size = metadata->data.stream_info.max_blocksize;
if (data->config.channels <= 2)
data->config.channel_config = aKode::MonoStereo;
data->config.channel_config = aKode::MonoStereo;
else if (data->config.channels <= 7)
data->config.channel_config = aKode::Surround;
data->config.channel_config = aKode::Surround;
else
data->config.channel_config = aKode::MultiChannel;
data->config.channel_config = aKode::MultiChannel;
data->si = &metadata->data.stream_info;
data->position = 0;
data->position = 0;
} else
if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
@ -263,7 +263,7 @@ static void metadata_callback(
static void error_callback(
const FLAC__StreamDecoder *,
FLAC__StreamDecoderErrorStatus status,
FLAC__StreamDecoderErrorStatus status,
void* /* client_data */)
{
std::cerr << "FLAC error: " << FLAC__StreamDecoderErrorStatusString[status] << "\n";

Loading…
Cancel
Save