From 8206e467daf365a77e74b38fb6d8d646bbb5624e3c0372cf8a957c0b58ae0552 Mon Sep 17 00:00:00 2001
From: Michael Gorse <mgorse@suse.com>
Date: Mon, 11 Mar 2024 19:58:29 +0000
Subject: [PATCH] Accepting request 1157023 from
 home:mgorse:branches:multimedia:libs

- Rework libmpcdec.patch and libmpcdec-extern.patch so that they
  apply with -p1, and use autosetup.
- Add libmpcdec-gcc14.patch: fix the build with gcc 14
  (boo#1221008).

OBS-URL: https://build.opensuse.org/request/show/1157023
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/musepack?expand=0&rev=14
---
 libmpcdec-extern.patch |  9 ++++-----
 libmpcdec-gcc14.patch  | 43 ++++++++++++++++++++++++++++++++++++++++++
 libmpcdec.patch        |  5 +++--
 musepack.changes       |  8 ++++++++
 musepack.spec          |  6 ++----
 5 files changed, 60 insertions(+), 11 deletions(-)
 create mode 100644 libmpcdec-gcc14.patch

diff --git a/libmpcdec-extern.patch b/libmpcdec-extern.patch
index 64f7759..c2e89a5 100644
--- a/libmpcdec-extern.patch
+++ b/libmpcdec-extern.patch
@@ -1,8 +1,7 @@
-Index: libmpcdec/requant.h
-===================================================================
---- libmpcdec/requant.h	(revision 478)
-+++ libmpcdec/requant.h	(revision 479)
-@@ -47,9 +47,9 @@
+diff -urp musepack_src_r475.orig/libmpcdec/requant.h musepack_src_r475/libmpcdec/requant.h
+--- musepack_src_r475.orig/libmpcdec/requant.h	2009-02-23 12:44:04.000000000 -0600
++++ musepack_src_r475/libmpcdec/requant.h	2024-03-10 13:23:35.095195384 -0500
+@@ -47,9 +47,9 @@ extern "C" {
  
  
  /* C O N S T A N T S */
diff --git a/libmpcdec-gcc14.patch b/libmpcdec-gcc14.patch
new file mode 100644
index 0000000..95bd98c
--- /dev/null
+++ b/libmpcdec-gcc14.patch
@@ -0,0 +1,43 @@
+diff -urp musepack_src_r475.orig/libmpcpsy/libmpcpsy.h musepack_src_r475/libmpcpsy/libmpcpsy.h
+--- musepack_src_r475.orig/libmpcpsy/libmpcpsy.h	2007-01-20 13:43:42.000000000 -0600
++++ musepack_src_r475/libmpcpsy/libmpcpsy.h	2024-03-11 14:44:50.561339438 -0500
+@@ -85,9 +85,8 @@ typedef struct {
+ 	float KBD1; // = 2.
+ 	float KBD2; // = -1.
+ 
+-	// FIXME : remove this :
+-	int * SCF_Index_L;
+-	int * SCF_Index_R;              // Scalefactor-index for Bitstream
++    int   SCF_Index_L [32] [3];
++    int   SCF_Index_R [32] [3];       // holds scalefactor-indices
+ 
+ } PsyModel;
+ 
+diff -urp musepack_src_r475.orig/mpcenc/mpcenc.c musepack_src_r475/mpcenc/mpcenc.c
+--- musepack_src_r475.orig/mpcenc/mpcenc.c	2009-08-26 15:39:06.000000000 -0500
++++ musepack_src_r475/mpcenc/mpcenc.c	2024-03-11 14:54:47.759752494 -0500
+@@ -1535,8 +1535,8 @@ mainloop ( int argc, char** argv )
+ 
+     // initialize tables which must be initialized once and only once
+ 
+-	m.SCF_Index_L = (int*) e.SCF_Index_L;
+-	m.SCF_Index_R = (int*) e.SCF_Index_R;
++	memcpy (&m.SCF_Index_L, &e.SCF_Index_L, sizeof (m.SCF_Index_L));
++	memcpy (&m.SCF_Index_R, &e.SCF_Index_R, sizeof (m.SCF_Index_R));
+ 
+ 	Init_Psychoakustik (&m);
+ 	Init_FPU ();
+diff -urp musepack_src_r475.orig/mpcenc/mpcenc.h musepack_src_r475/mpcenc/mpcenc.h
+--- musepack_src_r475.orig/mpcenc/mpcenc.h	2009-02-23 12:15:46.000000000 -0600
++++ musepack_src_r475/mpcenc/mpcenc.h	2024-03-11 14:53:19.692828299 -0500
+@@ -254,8 +254,8 @@ extern float __invSCF [128 + 6];
+ 
+ float  ISNR_Schaetzer                  ( const float* samples, const float comp, const int res);
+ float  ISNR_Schaetzer_Trans            ( const float* samples, const float comp, const int res);
+-void   QuantizeSubband                 ( unsigned int* qu_output, const float* input, const int res, float* errors, const int maxNsOrder );
+-void   QuantizeSubbandWithNoiseShaping ( unsigned int* qu_output, const float* input, const int res, float* errors, const float* FIR );
++void   QuantizeSubband                 ( mpc_int16_t* qu_output, const float* input, const int res, float* errors, const int maxNsOrder );
++void   QuantizeSubbandWithNoiseShaping ( mpc_int16_t* qu_output, const float* input, const int res, float* errors, const float* FIR );
+ 
+ void   NoiseInjectionComp ( void );
+ 
diff --git a/libmpcdec.patch b/libmpcdec.patch
index f2e7f48..f75696d 100644
--- a/libmpcdec.patch
+++ b/libmpcdec.patch
@@ -1,5 +1,6 @@
---- libmpcdec/CMakeLists.txt.orig	2010-08-21 18:55:01.000000000 +0300
-+++ libmpcdec/CMakeLists.txt	2013-03-11 22:28:18.414009124 +0200
+diff -urp musepack_src_r475.orig/libmpcdec/CMakeLists.txt musepack_src_r475/libmpcdec/CMakeLists.txt
+--- musepack_src_r475.orig/libmpcdec/CMakeLists.txt	2010-08-21 10:55:01.000000000 -0500
++++ musepack_src_r475/libmpcdec/CMakeLists.txt	2024-03-10 13:21:31.111523099 -0500
 @@ -1,7 +1,11 @@
  include_directories(${libmpc_SOURCE_DIR}/include)
  if(SHARED)
diff --git a/musepack.changes b/musepack.changes
index d452710..e76e914 100644
--- a/musepack.changes
+++ b/musepack.changes
@@ -1,3 +1,11 @@
+-------------------------------------------------------------------
+Mon Mar 11 19:56:41 UTC 2024 - Michael Gorse <mgorse@suse.com>
+
+- Rework libmpcdec.patch and libmpcdec-extern.patch so that they
+  apply with -p1, and use autosetup.
+- Add libmpcdec-gcc14.patch: fix the build with gcc 14
+  (boo#1221008).
+
 -------------------------------------------------------------------
 Thu Feb 22 11:51:15 UTC 2024 - pgajdos@suse.com
 
diff --git a/musepack.spec b/musepack.spec
index 7ea4b51..2485bb4 100644
--- a/musepack.spec
+++ b/musepack.spec
@@ -33,6 +33,7 @@ Patch0:         libmpcdec.patch
 # PATCh-FIX-UPSTREAM libmpcdec-extern.patch boo#1160284 mgorse@suse.com -- add extern declarations.
 Patch1:         libmpcdec-extern.patch
 Patch2:         libmpcdec-fastmath-no-const.patch
+Patch3:         libmpcdec-gcc14.patch
 BuildRequires:  cmake
 BuildRequires:  libcuefile-devel
 BuildRequires:  libreplaygain-devel
@@ -71,10 +72,7 @@ It is based on the MPEG-1 Layer-2 / MP2 algorithms, but has further
 been developed.
 
 %prep
-%setup -q -n %{name}_src_%{version}
-%patch -P 0
-%patch -P 1
-%patch -P 2 -p1
+%autosetup -p1 -n %{name}_src_%{version}
 
 %build
 # Fix rpmlint warning "version-control-internal-file"