Loading media/extractors/flac/FLACExtractor.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -401,6 +401,7 @@ void FLACParser::errorCallback(FLAC__StreamDecoderErrorStatus status) // Copy samples from FLAC native 32-bit non-interleaved to 16-bit signed // or 32-bit float interleaved. // TODO: Consider moving to audio_utils. // These are candidates for optimization if needed. static void copyTo16Signed( short *dst, Loading @@ -408,12 +409,21 @@ static void copyTo16Signed( unsigned nSamples, unsigned nChannels, unsigned bitsPerSample) { const unsigned leftShift = 16 - bitsPerSample; const int leftShift = 16 - (int)bitsPerSample; // cast to int to prevent unsigned overflow. if (leftShift >= 0) { for (unsigned i = 0; i < nSamples; ++i) { for (unsigned c = 0; c < nChannels; ++c) { *dst++ = src[c][i] << leftShift; } } } else { const int rightShift = -leftShift; for (unsigned i = 0; i < nSamples; ++i) { for (unsigned c = 0; c < nChannels; ++c) { *dst++ = src[c][i] >> rightShift; } } } } static void copyToFloat( Loading Loading
media/extractors/flac/FLACExtractor.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -401,6 +401,7 @@ void FLACParser::errorCallback(FLAC__StreamDecoderErrorStatus status) // Copy samples from FLAC native 32-bit non-interleaved to 16-bit signed // or 32-bit float interleaved. // TODO: Consider moving to audio_utils. // These are candidates for optimization if needed. static void copyTo16Signed( short *dst, Loading @@ -408,12 +409,21 @@ static void copyTo16Signed( unsigned nSamples, unsigned nChannels, unsigned bitsPerSample) { const unsigned leftShift = 16 - bitsPerSample; const int leftShift = 16 - (int)bitsPerSample; // cast to int to prevent unsigned overflow. if (leftShift >= 0) { for (unsigned i = 0; i < nSamples; ++i) { for (unsigned c = 0; c < nChannels; ++c) { *dst++ = src[c][i] << leftShift; } } } else { const int rightShift = -leftShift; for (unsigned i = 0; i < nSamples; ++i) { for (unsigned c = 0; c < nChannels; ++c) { *dst++ = src[c][i] >> rightShift; } } } } static void copyToFloat( Loading