[Scummvm-git-logs] scummvm master -> 9d5a5e092bb92f9d86e3f3c826f6721b1c94cba6

sev- noreply at scummvm.org
Fri Sep 6 22:15:11 UTC 2024


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

Summary:
b5afe7e25f CONFIGURE: Don't use pkg-config for libmpcdec
2d9f3dbb32 CONFIGURE: Add --with-mpcdec-prefix support
9d5a5e092b AUDIO: Add support for libmpcdec 1.2.6


Commit: b5afe7e25f228b33cc6730272925df378b6303c8
    https://github.com/scummvm/scummvm/commit/b5afe7e25f228b33cc6730272925df378b6303c8
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-09-07T00:15:07+02:00

Commit Message:
CONFIGURE: Don't use pkg-config for libmpcdec

libmpcdec never provided a pkg-config file.

Changed paths:
    configure


diff --git a/configure b/configure
index 40cd5a331cd..e7154a2707e 100755
--- a/configure
+++ b/configure
@@ -5917,12 +5917,7 @@ define_in_config_if_yes "$_libmikmod" "USE_MIKMOD"
 echocheck "libmpcdec"
 
 if test "$_libmpcdec" != "no"; then
-	if test "$_pkg_config" = "yes" && $_pkgconfig --exists libmpcdec; then
-		append_var LIBMPCDEC_LIBS "`$_pkgconfig --libs libmpcdec`"
-		append_var LIBMPCDEC_CFLAGS "`$_pkgconfig --cflags libmpcdec`"
-	else
-		append_var LIBMPCDEC_LIBS "-lmpcdec"
-	fi
+	append_var LIBMPCDEC_LIBS "-lmpcdec"
 
 	if test "$_libmpcdec" = "auto"; then
 		_libmpcdec=no


Commit: 2d9f3dbb32baa359c52f970f4cb1434335872d1c
    https://github.com/scummvm/scummvm/commit/2d9f3dbb32baa359c52f970f4cb1434335872d1c
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-09-07T00:15:07+02:00

Commit Message:
CONFIGURE: Add --with-mpcdec-prefix support

Changed paths:
    configure


diff --git a/configure b/configure
index e7154a2707e..effe402552a 100755
--- a/configure
+++ b/configure
@@ -1350,6 +1350,11 @@ for ac_option in $@; do
 		A52_CFLAGS="-I$arg/include"
 		A52_LIBS="-L$arg/lib"
 		;;
+	--with-mpcdec-prefix=*)
+		arg=`echo $ac_option | cut -d '=' -f 2`
+		LIBMPCDEC_CFLAGS="-I$arg/include"
+		LIBMPCDEC_LIBS="-L$arg/lib"
+		;;
 	--with-alsa-prefix=*)
 		arg=`echo $ac_option | cut -d '=' -f 2`
 		ALSA_CFLAGS="-I$arg/include"


Commit: 9d5a5e092bb92f9d86e3f3c826f6721b1c94cba6
    https://github.com/scummvm/scummvm/commit/9d5a5e092bb92f9d86e3f3c826f6721b1c94cba6
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-09-07T00:15:07+02:00

Commit Message:
AUDIO: Add support for libmpcdec 1.2.6

Previously, only the latest release was supported.

Changed paths:
    audio/decoders/mpc.cpp
    configure


diff --git a/audio/decoders/mpc.cpp b/audio/decoders/mpc.cpp
index 30bdb8e5db0..b2b8a1cea88 100644
--- a/audio/decoders/mpc.cpp
+++ b/audio/decoders/mpc.cpp
@@ -24,7 +24,11 @@
 
 #ifdef USE_MPCDEC
 
+#ifdef USE_MPCDEC_OLD_API
+#include <mpcdec/mpcdec.h>
+#else
 #include <mpc/mpcdec.h>
+#endif
 
 #include "common/debug.h"
 #include "common/stream.h"
@@ -37,37 +41,63 @@ namespace Audio {
 // These are wrapper functions to allow using a SeekableReadStream object to
 // provide data to the mpc_reader object.
 
+#ifdef USE_MPCDEC_OLD_API
+static mpc_int32_t read_stream(void *data, void *ptr, mpc_int32_t size) {
+	Common::SeekableReadStream *stream = (Common::SeekableReadStream *)data;
+#else
 static mpc_int32_t read_stream(mpc_reader *p_reader, void *ptr, mpc_int32_t size) {
 	Common::SeekableReadStream *stream = (Common::SeekableReadStream *)p_reader->data;
+#endif
 
 	return stream->read(ptr, size);
 }
 
 /// Seeks to byte position offset.
+#ifdef USE_MPCDEC_OLD_API
+static mpc_bool_t seek_stream(void *data, mpc_int32_t offset) {
+	Common::SeekableReadStream *stream = (Common::SeekableReadStream *)data;
+#else
 static mpc_bool_t seek_stream(mpc_reader *p_reader, mpc_int32_t offset) {
 	Common::SeekableReadStream *stream = (Common::SeekableReadStream *)p_reader->data;
+#endif
 
 	return stream->seek(offset);
 }
 
 /// Returns the current byte offset in the stream.
+#ifdef USE_MPCDEC_OLD_API
+static mpc_int32_t tell_stream(void *data) {
+	Common::SeekableReadStream *stream = (Common::SeekableReadStream *)data;
+#else
 static mpc_int32_t tell_stream(mpc_reader *p_reader) {
 	Common::SeekableReadStream *stream = (Common::SeekableReadStream *)p_reader->data;
+#endif
 
 	return stream->pos();
 }
 
 /// Returns the total length of the source stream, in bytes.
+#ifdef USE_MPCDEC_OLD_API
+static mpc_int32_t get_size_stream(void *data) {
+	Common::SeekableReadStream *stream = (Common::SeekableReadStream *)data;
+#else
 static mpc_int32_t get_size_stream(mpc_reader *p_reader) {
 	Common::SeekableReadStream *stream = (Common::SeekableReadStream *)p_reader->data;
+#endif
 
 	return stream->size();
 }
 
 /// True if the stream is a seekable stream.
+#ifdef USE_MPCDEC_OLD_API
+static mpc_bool_t canseek_stream(void *p_reader) {
+	return TRUE;
+}
+#else
 static mpc_bool_t canseek_stream(mpc_reader *p_reader) {
 	return MPC_TRUE;
 }
+#endif
 
 
 #pragma mark -
@@ -86,7 +116,12 @@ protected:
 
 	mpc_reader _reader;
 	mpc_streaminfo _si;
+
+#ifdef USE_MPCDEC_OLD_API
+	mpc_decoder _decoder;
+#else
 	mpc_demux *_demux;
+#endif
 
 	MPC_SAMPLE_FORMAT _bufferDec[MPC_DECODER_BUFFER_LENGTH];
 	uint16 _buffer[MPC_DECODER_BUFFER_LENGTH];
@@ -124,6 +159,19 @@ MPCStream::MPCStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag
 	_reader.canseek = canseek_stream;
 	_reader.data = (void *)inStream;
 
+#ifdef USE_MPCDEC_OLD_API
+	mpc_streaminfo_init(&_si);
+	if (mpc_streaminfo_read(&_si, &_reader) < 0) {
+		warning("Cannot read musepack stream info");
+		return;
+	}
+	mpc_decoder_setup(&_decoder, &_reader);
+	mpc_decoder_scale_output (&_decoder, 1.0);
+	if (!mpc_decoder_initialize(&_decoder, &_si)) {
+		warning("Cannot initialize musepack decoder");
+		return;
+	}
+#else
 	_demux = mpc_demux_init(&_reader);
 
 	if (!_demux) {
@@ -132,6 +180,7 @@ MPCStream::MPCStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag
 	}
 
 	mpc_demux_get_info(_demux, &_si);
+#endif
 
 	_isStereo = _si.channels >= 2;
 	_rate = _si.sample_freq;
@@ -143,8 +192,12 @@ MPCStream::MPCStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag
 
 	debug(9, "stream version %d", _si.stream_version);
 	debug(9, "encoder: %s", _si.encoder);
+#ifdef USE_MPCDEC_OLD_API
+	debug(9, "profile: %s (q=%d)", _si.profile_name, _si.profile);
+#else
 	debug(9, "profile: %s (q=%0.2f)", _si.profile_name, _si.profile - 5);
 	debug(9, "PNS: %s", _si.pns == 0xFF ? "unknow" : _si.pns ? "on" : "off");
+#endif
 	debug(9, "mid/side stereo: %s", _si.ms ? "on" : "off");
 	debug(9, "gapless: %s", _si.is_true_gapless ? "on" : "off");
 	debug(9, "average bitrate: %6.1f kbps", _si.average_bitrate * 1.e-3);
@@ -162,7 +215,9 @@ MPCStream::MPCStream(Common::SeekableReadStream *inStream, DisposeAfterUse::Flag
 }
 
 MPCStream::~MPCStream() {
+#ifndef USE_MPCDEC_OLD_API
 	mpc_demux_exit(_demux);
+#endif
 }
 
 int MPCStream::readBuffer(int16 *buffer, const int numSamples) {
@@ -182,8 +237,12 @@ int MPCStream::readBuffer(int16 *buffer, const int numSamples) {
 }
 
 bool MPCStream::seek(const Timestamp &where) {
-	mpc_status res = mpc_demux_seek_second(_demux, (double)where.msecs() / 1000.0);
-	if (res != MPC_STATUS_OK) {
+#ifdef USE_MPCDEC_OLD_API
+	bool res = (mpc_decoder_seek_seconds(&_decoder, (double)where.msecs() / 1000.0) == TRUE);
+#else
+	bool res = (mpc_demux_seek_second(_demux, (double)where.msecs() / 1000.0) == MPC_STATUS_OK);
+#endif
+	if (!res) {
 		warning("Error seeking in musepack stream");
 		_pos = _bufferEnd;
 		return false;
@@ -193,12 +252,31 @@ bool MPCStream::seek(const Timestamp &where) {
 }
 
 bool MPCStream::refill() {
-	mpc_status result;
+	bool result;
+	uint32 samples;
+
+#ifdef USE_MPCDEC_OLD_API
+	uint32 vbr_update_acc, vbr_update_bits;
+	samples = mpc_decoder_decode(&_decoder, _bufferDec, &vbr_update_acc, &vbr_update_bits);
 
+	if (samples == 0) { // End of stream
+		_pos = _buffer;
+		_bufferEnd = _buffer;
+
+		return false;
+	}
+
+	if (samples == -1u) { // Corruptd stream
+		result = false;
+		samples = 0;
+	} else {
+		result = true;
+	}
+#else
 	mpc_frame_info frame;
 	frame.buffer = _bufferDec;
 
-	result = mpc_demux_decode(_demux, &frame);
+	result = (mpc_demux_decode(_demux, &frame) == MPC_STATUS_OK);
 
 	if (frame.bits == -1) { // End of stream
 		_pos = _buffer;
@@ -207,7 +285,10 @@ bool MPCStream::refill() {
 		return false;
 	}
 
-	if (result != MPC_STATUS_OK) {
+	samples = frame.samples;
+#endif
+
+	if (!result) {
 		// Possibly recoverable, just warn about it
 		warning("Corrupted data in musepack file");
 	}
@@ -231,7 +312,7 @@ bool MPCStream::refill() {
 #endif
 
 	_pos = _buffer;
-	_bufferEnd = &_buffer[frame.samples * _si.channels];
+	_bufferEnd = &_buffer[samples * _si.channels];
 
 	return true;
 }
diff --git a/configure b/configure
index effe402552a..1f7bbcb9696 100755
--- a/configure
+++ b/configure
@@ -5936,7 +5936,27 @@ if test "$_libmpcdec" != "no"; then
 			return 0;
 		}
 EOF
-		cc_check $LIBMPCDEC_CFLAGS $LIBMPCDEC_LIBS && _libmpcdec=yes
+		if cc_check $LIBMPCDEC_CFLAGS $LIBMPCDEC_LIBS; then
+			_libmpcdec=yes
+		else
+			cat > $TMPC << EOF
+			#include <mpcdec/mpcdec.h>
+			int main(void) {
+				mpc_decoder decoder;
+				mpc_reader reader;
+				mpc_streaminfo info;
+
+				mpc_decoder_setup(&decoder, &reader);
+				mpc_decoder_initialize(&decoder, &info);
+
+				return 0;
+			}
+EOF
+			if cc_check $LIBMPCDEC_CFLAGS $LIBMPCDEC_LIBS; then
+				_libmpcdec=yes
+				add_line_to_config_h '#define USE_MPCDEC_OLD_API'
+			fi
+		fi
 	fi
 
 	if test "$_libmpcdec" = "yes"; then




More information about the Scummvm-git-logs mailing list