[Scummvm-git-logs] scummvm master -> 04c6113655bfccb1f5d96b14ddc214a6d496a5da

dreammaster paulfgilbert at gmail.com
Wed Nov 4 04:45:02 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
04c6113655 NUVIE: Cleanup of FMTowns decoder convertSample method


Commit: 04c6113655bfccb1f5d96b14ddc214a6d496a5da
    https://github.com/scummvm/scummvm/commit/04c6113655bfccb1f5d96b14ddc214a6d496a5da
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-11-03T20:44:54-08:00

Commit Message:
NUVIE: Cleanup of FMTowns decoder convertSample method

Changed paths:
    engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.cpp
    engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.h


diff --git a/engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.cpp b/engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.cpp
index a42bce9ab0..f695a61e6b 100644
--- a/engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.cpp
+++ b/engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.cpp
@@ -75,7 +75,7 @@ int FMtownsDecoderStream::readBuffer(sint16 *buffer, const int numSamples) {
 	//DEBUG(0,LEVEL_INFORMATIONAL, "numSamples = %d. buf_pos = %d, buf_len = %d\n", numSamples, buf_pos, buf_len);
 
 	for (; j < numSamples && i < buf_len;) {
-		buffer[j] = convert_sample(raw_audio_buf[i]);
+		buffer[j] = convertSample(READ_LE_UINT16(&raw_audio_buf[i]));
 		j++;
 		i++;
 	}
@@ -86,22 +86,13 @@ int FMtownsDecoderStream::readBuffer(sint16 *buffer, const int numSamples) {
 	return j;
 }
 
-inline sint16 convert_sample(uint16 raw_sample) {
+inline sint16 FMtownsDecoderStream::convertSample(uint16 rawSample) const {
 	sint16 sample;
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-	sint16 temp_sample;
-#endif
 
-	if (raw_sample & 128)
-		sample = ((sint16)(abs(128 - raw_sample) * 256) ^ 0xffff)  + 1;
+	if (rawSample & 128)
+		sample = ((sint16)(ABS(128 - rawSample) * 256) ^ 0xffff)  + 1;
 	else
-		sample = raw_sample * 256;
-
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
-	temp_sample = sample >> 8;
-	temp_sample |= (sample & 0xff) << 8;
-	sample = temp_sample;
-#endif
+		sample = rawSample * 256;
 
 	return sample;
 }
diff --git a/engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.h b/engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.h
index 802c4bdfdd..877a4f1e13 100644
--- a/engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.h
+++ b/engines/ultima/nuvie/sound/decoder/fm_towns_decoder_stream.h
@@ -79,6 +79,8 @@ protected:
 	uint32 buf_len;
 	uint32 buf_pos;
 
+private:
+	inline sint16 convertSample(uint16 rawSample) const;
 };
 
 } // End of namespace Nuvie




More information about the Scummvm-git-logs mailing list