1
0
forked from blue/mlc

Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

2 changed files with 6 additions and 19 deletions

View File

@ -294,28 +294,16 @@ bool FLACtoMP3::scaleJPEG(const FLAC__StreamMetadata_Picture& picture) {
return true;
}
bool FLACtoMP3::decodeFrame(const int32_t * const buffer[], uint32_t size, const uint32_t bitsPerSample) {
bool FLACtoMP3::decodeFrame(const int32_t * const buffer[], uint32_t size) {
if (!outputInitilized) {
bool success = initializeOutput();
if (!success)
return false;
}
if (bitsPerSample >= 16)
return decodeFrameImpl(buffer, size, 1 << (bitsPerSample - 16));
return false;
}
bool FLACtoMP3::decodeFrameImpl(const int32_t * const buffer[], uint32_t size, const uint32_t divisor)
{
for (size_t i = 0; i < size; ++i) {
int32_t left = buffer[0][i];
int32_t right = buffer[1][i];
left /= divisor;
right /= divisor;
pcm[pcmCounter++] = (int16_t)left;
pcm[pcmCounter++] = (int16_t)right;
pcm[pcmCounter++] = (int16_t)buffer[0][i];
pcm[pcmCounter++] = (int16_t)buffer[1][i];
if (pcmCounter == pcmSize)
return flush();
@ -407,7 +395,7 @@ FLAC__StreamDecoderWriteStatus FLACtoMP3::write(
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
bool result = self->decodeFrame(buffer, frame->header.blocksize, frame->header.bits_per_sample);
bool result = self->decodeFrame(buffer, frame->header.blocksize);
if (result)
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;

View File

@ -29,8 +29,7 @@ private:
void processTags(const FLAC__StreamMetadata_VorbisComment& tags);
void processInfo(const FLAC__StreamMetadata_StreamInfo& info);
void processPicture(const FLAC__StreamMetadata_Picture& picture);
bool decodeFrame(const int32_t * const buffer[], uint32_t size, const uint32_t bitsPerSample);
bool decodeFrameImpl(const int32_t * const buffer[], uint32_t size, const uint32_t divisor);
bool decodeFrame(const int32_t * const buffer[], uint32_t size);
bool flush();
bool initializeOutput();
bool scaleJPEG(const FLAC__StreamMetadata_Picture& picture);