1
0
mirror of https://github.com/dguglielmi/sunny-overlay.git synced 2025-12-06 20:22:38 +01:00
Files
sunny-overlay/media-sound/mixxx/files/mixxx-2.1.0-fix-flac-decoding-and-upgrade-db-schema.patch

374 lines
16 KiB
Diff

From d68a5997c745320555bab6860198d00d3e6b0edf Mon Sep 17 00:00:00 2001
From: Jamie Gifford <james@thoughtpatterns.com.au>
Date: Sun, 22 Apr 2018 11:53:44 +1000
Subject: [PATCH 01/10] Fix -6dB gain in FLAC
---
src/sources/soundsourceflac.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp
index 8a496d2289..e6a356922b 100644
--- a/src/sources/soundsourceflac.cpp
+++ b/src/sources/soundsourceflac.cpp
@@ -437,7 +437,7 @@ void SoundSourceFLAC::flacMetadata(const FLAC__StreamMetadata* metadata) {
// not set before
m_bitsPerSample = bitsPerSample;
m_sampleScaleFactor = CSAMPLE_PEAK
- / CSAMPLE(FLAC__int32(1) << bitsPerSample);
+ / CSAMPLE(FLAC__int32(1) << (bitsPerSample - 1));
} else {
// already set before -> check for consistency
if (bitsPerSample != m_bitsPerSample) {
From 82d7b96b2a976b1f74eef61816bd1bfc64fa30ac Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Sun, 22 Apr 2018 14:21:32 +0200
Subject: [PATCH 02/10] Clarify conversion of fixed-point integer to floating
point samples
---
src/sources/soundsourceflac.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp
index e6a356922b..ecccab61dd 100644
--- a/src/sources/soundsourceflac.cpp
+++ b/src/sources/soundsourceflac.cpp
@@ -436,8 +436,11 @@ void SoundSourceFLAC::flacMetadata(const FLAC__StreamMetadata* metadata) {
if (kBitsPerSampleDefault == m_bitsPerSample) {
// not set before
m_bitsPerSample = bitsPerSample;
- m_sampleScaleFactor = CSAMPLE_PEAK
- / CSAMPLE(FLAC__int32(1) << (bitsPerSample - 1));
+ // Range of signed(!) sample values: [2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1]
+ // See also: https://bugs.launchpad.net/mixxx/+bug/1766042
+ const auto maxAbsSampleValue = FLAC__int32(1) << (bitsPerSample - 1);
+ // Scaled range of samples values: [-1.0, 1.0)
+ m_sampleScaleFactor = CSAMPLE_PEAK / CSAMPLE(maxAbsSampleValue);
} else {
// already set before -> check for consistency
if (bitsPerSample != m_bitsPerSample) {
From e4516a3c82f8b4dd016d712ca3e82017e76c3ffa Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Sun, 22 Apr 2018 14:26:36 +0200
Subject: [PATCH 03/10] Check for valid bits per sample
---
plugins/soundsourcewv/soundsourcewv.cpp | 13 ++++++++++---
src/sources/soundsourceflac.cpp | 18 ++++++++++++------
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/plugins/soundsourcewv/soundsourcewv.cpp b/plugins/soundsourcewv/soundsourcewv.cpp
index 915a66fc03..732b5c0154 100644
--- a/plugins/soundsourcewv/soundsourcewv.cpp
+++ b/plugins/soundsourcewv/soundsourcewv.cpp
@@ -77,9 +77,16 @@ SoundSource::OpenResult SoundSourceWV::tryOpen(
m_sampleScaleFactor = CSAMPLE_PEAK;
} else {
const int bitsPerSample = WavpackGetBitsPerSample(m_wpc);
- const uint32_t wavpackPeakSampleValue = 1u
- << (bitsPerSample - 1);
- m_sampleScaleFactor = CSAMPLE_PEAK / wavpackPeakSampleValue;
+ if (bitsPerSample > 0) {
+ const uint32_t wavpackPeakSampleValue = 1u
+ << (bitsPerSample - 1);
+ m_sampleScaleFactor = CSAMPLE_PEAK / wavpackPeakSampleValue;
+ } else {
+ kLogger.warning()
+ << "Invalid bits per sample:"
+ << bitsPerSample;
+ return OpenResult::Aborted;
+ }
}
m_curFrameIndex = frameIndexMin();
diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp
index ecccab61dd..be79d2a88c 100644
--- a/src/sources/soundsourceflac.cpp
+++ b/src/sources/soundsourceflac.cpp
@@ -435,12 +435,18 @@ void SoundSourceFLAC::flacMetadata(const FLAC__StreamMetadata* metadata) {
DEBUG_ASSERT(kBitsPerSampleDefault != bitsPerSample);
if (kBitsPerSampleDefault == m_bitsPerSample) {
// not set before
- m_bitsPerSample = bitsPerSample;
- // Range of signed(!) sample values: [2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1]
- // See also: https://bugs.launchpad.net/mixxx/+bug/1766042
- const auto maxAbsSampleValue = FLAC__int32(1) << (bitsPerSample - 1);
- // Scaled range of samples values: [-1.0, 1.0)
- m_sampleScaleFactor = CSAMPLE_PEAK / CSAMPLE(maxAbsSampleValue);
+ if (bitsPerSample > 0) {
+ m_bitsPerSample = bitsPerSample;
+ // Range of signed(!) sample values: [2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1]
+ // See also: https://bugs.launchpad.net/mixxx/+bug/1766042
+ const auto maxAbsSampleValue = FLAC__int32(1) << (bitsPerSample - 1);
+ // Scaled range of samples values: [-1.0, 1.0)
+ m_sampleScaleFactor = CSAMPLE_PEAK / CSAMPLE(maxAbsSampleValue);
+ } else {
+ kLogger.warning()
+ << "Invalid bits per sample:"
+ << bitsPerSample;
+ }
} else {
// already set before -> check for consistency
if (bitsPerSample != m_bitsPerSample) {
From 1940455fabbb0ed605c8d9345ade016b9be3347b Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Sun, 22 Apr 2018 15:07:27 +0200
Subject: [PATCH 04/10] Reset wrong replay gain info for all FLAC files
---
res/schema.xml | 10 ++++++++++
src/database/mixxxdb.cpp | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/res/schema.xml b/res/schema.xml
index e58c8033f6..a3ad73a99d 100644
--- a/res/schema.xml
+++ b/res/schema.xml
@@ -426,4 +426,14 @@ METADATA
ALTER TABLE cues ADD COLUMN color INTEGER DEFAULT 4294901760 NOT NULL;
</sql>
</revision>
+ <revision version="28" min_compatible="3">
+ <description>
+ Reset replay gain info for all FLAC files after fixing a decoding bug in version 2.1.0.
+ See also: https://bugs.launchpad.net/mixxx/+bug/1766042
+ </description>
+ <sql>
+ <!-- Reset replay gain values to default -->
+ UPDATE library SET (replaygain,replaygain_peak)=(0.0,-1.0) WHERE filetype='flac';
+ </sql>
+ </revision>
</schema>
diff --git a/src/database/mixxxdb.cpp b/src/database/mixxxdb.cpp
index 2046129b44..a831d35b94 100644
--- a/src/database/mixxxdb.cpp
+++ b/src/database/mixxxdb.cpp
@@ -11,7 +11,7 @@
const QString MixxxDb::kDefaultSchemaFile(":/schema.xml");
//static
-const int MixxxDb::kRequiredSchemaVersion = 27;
+const int MixxxDb::kRequiredSchemaVersion = 28;
namespace {
From 73bc371b2b3913ed39a480a485dd193814b655be Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Sun, 22 Apr 2018 15:20:40 +0200
Subject: [PATCH 05/10] Use case-insensitive string compare for file type
---
res/schema.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/res/schema.xml b/res/schema.xml
index a3ad73a99d..849be6ed73 100644
--- a/res/schema.xml
+++ b/res/schema.xml
@@ -433,7 +433,7 @@ METADATA
</description>
<sql>
<!-- Reset replay gain values to default -->
- UPDATE library SET (replaygain,replaygain_peak)=(0.0,-1.0) WHERE filetype='flac';
+ UPDATE library SET (replaygain,replaygain_peak)=(0.0,-1.0) WHERE filetype='flac' COLLATE NOCASE;
</sql>
</revision>
</schema>
From a5294bd7031e5663c5b320dbd8cea84ef8e1d9aa Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Mon, 23 Apr 2018 08:40:09 +0200
Subject: [PATCH 06/10] FLAC/WavPack: Improve validation, align implementation,
fix comments
---
plugins/soundsourcewv/soundsourcewv.cpp | 10 ++++++----
src/sources/soundsourceflac.cpp | 12 ++++++------
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/plugins/soundsourcewv/soundsourcewv.cpp b/plugins/soundsourcewv/soundsourcewv.cpp
index 732b5c0154..5d5c5b1c08 100644
--- a/plugins/soundsourcewv/soundsourcewv.cpp
+++ b/plugins/soundsourcewv/soundsourcewv.cpp
@@ -77,10 +77,12 @@ SoundSource::OpenResult SoundSourceWV::tryOpen(
m_sampleScaleFactor = CSAMPLE_PEAK;
} else {
const int bitsPerSample = WavpackGetBitsPerSample(m_wpc);
- if (bitsPerSample > 0) {
- const uint32_t wavpackPeakSampleValue = 1u
- << (bitsPerSample - 1);
- m_sampleScaleFactor = CSAMPLE_PEAK / wavpackPeakSampleValue;
+ if ((bitsPerSample >= 8) && (bitsPerSample <= 32)) {
+ // Range of signed sample values: [-2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1]
+ const uint32_t absSamplePeak = 1u << (bitsPerSample - 1);
+ DEBUG_ASSERT(absSamplePeak > 0);
+ // Scaled range of sample values: [-CSAMPLE_PEAK, CSAMPLE_PEAK)
+ m_sampleScaleFactor = CSAMPLE_PEAK / absSamplePeak;
} else {
kLogger.warning()
<< "Invalid bits per sample:"
diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp
index be79d2a88c..aae897164a 100644
--- a/src/sources/soundsourceflac.cpp
+++ b/src/sources/soundsourceflac.cpp
@@ -435,13 +435,13 @@ void SoundSourceFLAC::flacMetadata(const FLAC__StreamMetadata* metadata) {
DEBUG_ASSERT(kBitsPerSampleDefault != bitsPerSample);
if (kBitsPerSampleDefault == m_bitsPerSample) {
// not set before
- if (bitsPerSample > 0) {
+ if ((bitsPerSample >= 8) && (bitsPerSample <= 32)) {
m_bitsPerSample = bitsPerSample;
- // Range of signed(!) sample values: [2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1]
- // See also: https://bugs.launchpad.net/mixxx/+bug/1766042
- const auto maxAbsSampleValue = FLAC__int32(1) << (bitsPerSample - 1);
- // Scaled range of samples values: [-1.0, 1.0)
- m_sampleScaleFactor = CSAMPLE_PEAK / CSAMPLE(maxAbsSampleValue);
+ // Range of signed) sample values: [-2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1]
+ const uint32_t absSamplePeak = 1u << (bitsPerSample - 1);
+ DEBUG_ASSERT(absSamplePeak > 0);
+ // Scaled range of samples values: [-CSAMPLE_PEAK, CSAMPLE_PEAK)
+ m_sampleScaleFactor = CSAMPLE_PEAK / absSamplePeak;
} else {
kLogger.warning()
<< "Invalid bits per sample:"
From a75ff1362d5338973ba9bf257b58838643f16852 Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Mon, 23 Apr 2018 09:17:20 +0200
Subject: [PATCH 07/10] Add Jamie Gifford to the list of contributors
...and fix some tab/space formatting issues
---
src/dialog/dlgabout.cpp | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/dialog/dlgabout.cpp b/src/dialog/dlgabout.cpp
index 95d833d02d..165254fb01 100644
--- a/src/dialog/dlgabout.cpp
+++ b/src/dialog/dlgabout.cpp
@@ -83,17 +83,18 @@ DlgAbout::DlgAbout(QWidget* parent) : QDialog(parent), Ui::DlgAboutDlg() {
<< "Devananda van der Veen"
<< "Tatsuyuki Ishi"
<< "Kilian Feess"
- << "Conner Phillips"
- << "Daniel Poelzleithner"
+ << "Conner Phillips"
+ << "Daniel Poelzleithner"
<< "Artyom Lyan"
<< "Johan Lasperas"
<< "Olaf Hering"
<< "Stefan Weber"
<< "Eduardo Acero"
- << "Kshitij Gupta"
- << "Thomas Jarosch"
- << "Matthew Nicholson"
- << "ronso0";
+ << "Kshitij Gupta"
+ << "Thomas Jarosch"
+ << "Matthew Nicholson"
+ << "ronso0"
+ << "Jamie Gifford";
QStringList specialThanks;
specialThanks
From a9b001279993668a521cb794901597b1f55bb4ce Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Mon, 23 Apr 2018 09:22:49 +0200
Subject: [PATCH 08/10] FLAC: Accept files with 4 to 32 bits per sample
---
src/sources/soundsourceflac.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp
index aae897164a..01dfc00149 100644
--- a/src/sources/soundsourceflac.cpp
+++ b/src/sources/soundsourceflac.cpp
@@ -435,7 +435,7 @@ void SoundSourceFLAC::flacMetadata(const FLAC__StreamMetadata* metadata) {
DEBUG_ASSERT(kBitsPerSampleDefault != bitsPerSample);
if (kBitsPerSampleDefault == m_bitsPerSample) {
// not set before
- if ((bitsPerSample >= 8) && (bitsPerSample <= 32)) {
+ if ((bitsPerSample >= 4) && (bitsPerSample <= 32)) {
m_bitsPerSample = bitsPerSample;
// Range of signed) sample values: [-2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1]
const uint32_t absSamplePeak = 1u << (bitsPerSample - 1);
From 65541c54b86428dbf20d752d1b36b3e1691c5e0d Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Mon, 23 Apr 2018 15:17:30 +0200
Subject: [PATCH 09/10] Hide developer comments during db schema upgrade
---
res/schema.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/res/schema.xml b/res/schema.xml
index 849be6ed73..38a20dbfe1 100644
--- a/res/schema.xml
+++ b/res/schema.xml
@@ -386,7 +386,7 @@ METADATA
<revision version="24" min_compatible="3">
<description>
Add cover art support. Default source is UNKNOWN and default type is NONE.
- See library/coverart.h.
+ <!-- See library/coverart.h. -->
</description>
<sql>
ALTER TABLE library ADD COLUMN coverart_source INTEGER DEFAULT 0;
@@ -419,7 +419,7 @@ METADATA
<revision version="27" min_compatible="3">
<description>
Add cue color support. Default color is #FF0000.
- See library/dao/cue.h.
+ <!-- See library/dao/cue.h. -->
</description>
<sql>
<!-- Default color is #FFFF0000 (in base 10) -->
@@ -429,7 +429,7 @@ METADATA
<revision version="28" min_compatible="3">
<description>
Reset replay gain info for all FLAC files after fixing a decoding bug in version 2.1.0.
- See also: https://bugs.launchpad.net/mixxx/+bug/1766042
+ <!-- See also: https://bugs.launchpad.net/mixxx/+bug/1766042 -->
</description>
<sql>
<!-- Reset replay gain values to default -->
From add395ae54ebb3c4729469cd994fa602cc7738b3 Mon Sep 17 00:00:00 2001
From: Uwe Klotz <uklotz@mixxx.org>
Date: Mon, 23 Apr 2018 15:18:12 +0200
Subject: [PATCH 10/10] Don't reset and preserve 'replaygain_peak' of FLAC
files
---
res/schema.xml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/res/schema.xml b/res/schema.xml
index 38a20dbfe1..a51599ed11 100644
--- a/res/schema.xml
+++ b/res/schema.xml
@@ -429,11 +429,13 @@ METADATA
<revision version="28" min_compatible="3">
<description>
Reset replay gain info for all FLAC files after fixing a decoding bug in version 2.1.0.
+ <!-- The value of 'replaygain_peak' is not yet calculated by any Mixxx analyzer, -->
+ <!-- so we should leave it untouched and don't need to reset it here! -->
<!-- See also: https://bugs.launchpad.net/mixxx/+bug/1766042 -->
</description>
<sql>
- <!-- Reset replay gain values to default -->
- UPDATE library SET (replaygain,replaygain_peak)=(0.0,-1.0) WHERE filetype='flac' COLLATE NOCASE;
+ <!-- Reset replay gain to default value -->
+ UPDATE library SET replaygain=0.0 WHERE filetype='flac' COLLATE NOCASE;
</sql>
</revision>
</schema>