From 5abfdf4eb03694aaeed6e731eb9ce12f25471e2b Mon Sep 17 00:00:00 2001
From: David Sansome
Date: Wed, 28 Dec 2011 14:13:12 +0100
Subject: [PATCH 01/40] Fix a cmake error when getting the git revision number
of an exact tag checkout (cherry picked from commit
9e2e035ae1a25bc5f37a17ae7ea10ba7c37fb328)
---
cmake/Version.cmake | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/cmake/Version.cmake b/cmake/Version.cmake
index cb22eb7fa..a64bfc1ad 100644
--- a/cmake/Version.cmake
+++ b/cmake/Version.cmake
@@ -139,10 +139,13 @@ else(FORCE_GIT_REVISION)
message(FATAL_ERROR "Failed to parse git revision string '${GIT_REV}'")
endif(NOT GIT_PARTS)
- list(GET GIT_PARTS 0 GIT_TAGNAME)
- list(GET GIT_PARTS 1 GIT_COMMITCOUNT)
- list(GET GIT_PARTS 2 GIT_SHA1)
- set(HAS_GET_REVISION ON)
+ list(LENGTH GIT_PARTS GIT_PARTS_LENGTH)
+ if(GIT_PARTS_LENGTH EQUAL 3)
+ list(GET GIT_PARTS 0 GIT_TAGNAME)
+ list(GET GIT_PARTS 1 GIT_COMMITCOUNT)
+ list(GET GIT_PARTS 2 GIT_SHA1)
+ set(HAS_GET_REVISION ON)
+ endif(GIT_PARTS_LENGTH EQUAL 3)
endif(${GIT_INFO_RESULT} EQUAL 0)
endif(NOT GIT_EXECUTABLE-NOTFOUND)
endif(FORCE_GIT_REVISION)
From cf2c3a981544cb032e2ed9636e53f5653fd1103d Mon Sep 17 00:00:00 2001
From: David Sansome
Date: Wed, 28 Dec 2011 14:24:10 +0100
Subject: [PATCH 02/40] Update the script that uploads stable builds to the PPA
to work with git (cherry picked from commit
5b9a273227648919c8c57c73df9c980c049eccc4)
---
dist/uploadtoppa.sh | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/dist/uploadtoppa.sh b/dist/uploadtoppa.sh
index 4eb446a6b..c4d29a323 100755
--- a/dist/uploadtoppa.sh
+++ b/dist/uploadtoppa.sh
@@ -1,16 +1,16 @@
#!/bin/sh -e
-BRANCH=$1
+REFSPEC=$1
DIST=$2
-if [ -z "$BRANCH" -o -z "$DIST" ]; then
- echo "Usage: $0 "
+if [ -z "$REFSPEC" -o -z "$DIST" ]; then
+ echo "Usage: $0 "
echo "Example: $0 tags/0.7 natty"
exit 1
fi
PPA=ppa:me-davidsansome/clementine
-REPO=http://svn.clementine-player.org/clementine-mirror/$1
+REPO=https://code.google.com/p/clementine-player/
BASE=`pwd`
DIRECTORY=clementine
@@ -19,9 +19,13 @@ DIRECTORY=clementine
rm -rfv $BASE/$DIRECTORY $BASE/*.diff.gz $BASE/*.tar.gz $BASE/*.dsc $BASE/*_source.changes
# Checkout
-svn checkout $REPO $DIRECTORY
+git init $DIRECTORY
+cd $BASE/$DIRECTORY
+git fetch -t $REPO $REFSPEC
+git checkout $REFSPEC
# Generate changelog and maketarball.sh
+mkdir $BASE/$DIRECTORY/bin
cd $BASE/$DIRECTORY/bin
cmake .. -DDEB_DIST=$DIST -DWITH_DEBIAN=ON
rm -rfv $BASE/$DIRECTORY/bin/*
@@ -31,7 +35,7 @@ cd $BASE/$DIRECTORY/dist
./maketarball.sh
mv -v $BASE/$DIRECTORY/dist/*.orig.tar.gz $BASE/
rm -v $BASE/$DIRECTORY/dist/*.tar.gz
-find $BASE/$DIRECTORY/ -depth -path '*/.svn*' -delete
+rm -vrf $BASE/$DIRECTORY/.git
# Build the deb
cd $BASE/$DIRECTORY
From 80aecb2eec220c7fc7206e2cd82781caa4cb2244 Mon Sep 17 00:00:00 2001
From: Arnaud Bienner
Date: Wed, 28 Dec 2011 20:04:12 +0100
Subject: [PATCH 03/40] Update 'All the translators' URL with Transifex (cherry
picked from commit 401c72bf7d5c81b7bd0b0d588b0320aed0884307)
---
src/ui/about.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ui/about.cpp b/src/ui/about.cpp
index 5085c131e..4b42963ce 100644
--- a/src/ui/about.cpp
+++ b/src/ui/about.cpp
@@ -70,8 +70,8 @@ QString About::MakeHtml() const {
foreach (const Person& person, thanks_to_)
ret += "
" + MakeHtml(person);
- ret += QString("
" + tr("All the translators") + " <"
- "https://translations.launchpad.net/clementine>");
+ ret += QString("
" + tr("All the translators") + " <"
+ "https://www.transifex.net/projects/p/clementine>");
ret += QString("
%1
").arg(tr("...and all the Amarok contributors"));
ret += QString("%1").arg(tr("And:"));
From 36b92b229f2b3f77238aab1380a7f5a00308c121 Mon Sep 17 00:00:00 2001
From: David Sansome
Date: Tue, 3 Jan 2012 11:53:34 +0000
Subject: [PATCH 04/40] Always use the C locale when getting the date to put in
the debian changelog - dpkg-buildpackage complains otherwise (cherry picked
from commit 44db77da487a0eb4315ef6f7e63a2d795b0aa3de)
---
debian/CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/debian/CMakeLists.txt b/debian/CMakeLists.txt
index 456a70899..2a8693f74 100644
--- a/debian/CMakeLists.txt
+++ b/debian/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8)
-execute_process(COMMAND date "+%a, %-d %b %Y %H:%M:%S %z"
+execute_process(COMMAND env LC_ALL=C date "+%a, %-d %b %Y %H:%M:%S %z"
OUTPUT_VARIABLE DEB_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
set(DEB_REWRITE_RULES ON CACHE BOOL "Rewrite the debian rules file from rules.in")
From ac44b33ec8da247aa2ec12a6726a3c31d9cf3a7b Mon Sep 17 00:00:00 2001
From: David Sansome
Date: Wed, 4 Jan 2012 22:10:41 +0000
Subject: [PATCH 05/40] Don't set a "file" url scheme on files in devices that
already have URL prefixes (like afc:// for iPod Touches)
Fixes issue 2564
(cherry picked from commit 4cbc221f0001427c85a08ef30ca01c147a462aae)
---
src/core/song.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/core/song.cpp b/src/core/song.cpp
index 9af1e0c4b..b8b12aada 100644
--- a/src/core/song.cpp
+++ b/src/core/song.cpp
@@ -849,7 +849,12 @@ void Song::InitFromLastFM(const lastfm::Track& track) {
QString filename = QString::fromLocal8Bit(track->ipod_path);
filename.replace(':', '/');
- d->url_ = QUrl::fromLocalFile(prefix + filename);
+ if (prefix.contains("://")) {
+ d->url_ = prefix + filename;
+ } else {
+ d->url_ = QUrl::fromLocalFile(prefix + filename);
+ }
+
d->basefilename_ = QFileInfo(filename).fileName();
}
From f1af27f84977269cc041c01d11fa68a407c7f166 Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Wed, 4 Jan 2012 14:08:31 +0000
Subject: [PATCH 06/40] Move mac init code after logging init. (cherry picked
from commit 058e421827fbc801f5745429f58d7d2bf4375672)
---
src/main.cpp | 42 +++++++++++++++++++++++-------------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/src/main.cpp b/src/main.cpp
index 78c77851f..527ec0264 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -142,6 +142,27 @@ void LoadTranslation(const QString& prefix, const QString& path,
#include
#endif
+void IncreaseFDLimit() {
+#ifdef Q_OS_DARWIN
+ // Bump the soft limit for the number of file descriptors from the default of 256 to
+ // the maximum (usually 10240).
+ struct rlimit limit;
+ getrlimit(RLIMIT_NOFILE, &limit);
+
+ // getrlimit() lies about the hard limit so we have to check sysctl.
+ int max_fd = 0;
+ size_t len = sizeof(max_fd);
+ sysctlbyname("kern.maxfilesperproc", &max_fd, &len, NULL, 0);
+
+ limit.rlim_cur = max_fd;
+ int ret = setrlimit(RLIMIT_NOFILE, &limit);
+
+ if (ret == 0) {
+ qLog(Debug) << "Max fd:" << max_fd;
+ }
+#endif
+}
+
int main(int argc, char *argv[]) {
if (CrashReporting::SendCrashReport(argc, argv)) {
return 0;
@@ -153,25 +174,6 @@ int main(int argc, char *argv[]) {
// Do Mac specific startup to get media keys working.
// This must go before QApplication initialisation.
mac::MacMain();
-
- {
- // Bump the soft limit for the number of file descriptors from the default of 256 to
- // the maximum (usually 10240).
- struct rlimit limit;
- getrlimit(RLIMIT_NOFILE, &limit);
-
- // getrlimit() lies about the hard limit so we have to check sysctl.
- int max_fd = 0;
- size_t len = sizeof(max_fd);
- sysctlbyname("kern.maxfilesperproc", &max_fd, &len, NULL, 0);
-
- limit.rlim_cur = max_fd;
- int ret = setrlimit(RLIMIT_NOFILE, &limit);
-
- if (ret == 0) {
- qLog(Debug) << "Max fd:" << max_fd;
- }
- }
#endif
QCoreApplication::setApplicationName("Clementine");
@@ -289,6 +291,8 @@ int main(int argc, char *argv[]) {
logging::SetLevels(options.log_levels());
g_log_set_default_handler(reinterpret_cast(&logging::GLog), NULL);
+ IncreaseFDLimit();
+
QtSingleApplication a(argc, argv);
#ifdef Q_OS_DARWIN
QCoreApplication::setLibraryPaths(
From 4a13d0ce29573a004f4b65ce626a3a3bf3e6ea1c Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Wed, 4 Jan 2012 15:24:53 +0000
Subject: [PATCH 07/40] Add filesystem watcher using Mac FSEvents API. (cherry
picked from commit 96aa95bebd30ba550b0cec7ce7e88afa8fc19ca3)
---
src/CMakeLists.txt | 2 ++
src/core/macfslistener.h | 38 ++++++++++++++++++++
src/core/macfslistener.mm | 75 +++++++++++++++++++++++++++++++++++++++
3 files changed, 115 insertions(+)
create mode 100644 src/core/macfslistener.h
create mode 100644 src/core/macfslistener.mm
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 23fb96c16..443e70be6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -711,6 +711,7 @@ optional_source(APPLE
${GROWL}/Headers
${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/google-breakpad/client/mac/build/Release/Breakpad.framework
SOURCES
+ core/macfslistener.mm
core/macglobalshortcutbackend.mm
core/mac_startup.mm
devices/macdevicelister.mm
@@ -720,6 +721,7 @@ optional_source(APPLE
widgets/maclineedit.mm
widgets/osd_mac.mm
HEADERS
+ core/macfslistener.h
core/macglobalshortcutbackend.h
devices/macdevicelister.h
ui/macscreensaver.h
diff --git a/src/core/macfslistener.h b/src/core/macfslistener.h
new file mode 100644
index 000000000..e33aaf120
--- /dev/null
+++ b/src/core/macfslistener.h
@@ -0,0 +1,38 @@
+#ifndef MACFSLISTENER_H
+#define MACFSLISTENER_H
+
+#include
+
+#include
+#include
+
+class MacFSListener : public QObject {
+ Q_OBJECT
+
+ public:
+ MacFSListener();
+ void Init();
+
+ void AddPath(const QString& path);
+
+ signals:
+ void PathChanged(const QString& path);
+
+ private:
+ void UpdateStream();
+
+ static void EventStreamCallback(
+ ConstFSEventStreamRef stream,
+ void* user_data,
+ size_t num_events,
+ void* event_paths,
+ const FSEventStreamEventFlags event_flags[],
+ const FSEventStreamEventId event_ids[]);
+
+ CFRunLoopRef run_loop_;
+ FSEventStreamRef stream_;
+
+ QSet paths_;
+};
+
+#endif
diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm
new file mode 100644
index 000000000..1c9d5d203
--- /dev/null
+++ b/src/core/macfslistener.mm
@@ -0,0 +1,75 @@
+#include "macfslistener.h"
+
+#include
+#include
+#include
+
+#include "core/logging.h"
+
+MacFSListener::MacFSListener()
+ : run_loop_(NULL),
+ stream_(NULL) {
+}
+
+void MacFSListener::Init() {
+ run_loop_ = CFRunLoopGetCurrent();
+}
+
+void MacFSListener::EventStreamCallback(
+ ConstFSEventStreamRef stream,
+ void* user_data,
+ size_t num_events,
+ void* event_paths,
+ const FSEventStreamEventFlags event_flags[],
+ const FSEventStreamEventId event_ids[]) {
+ MacFSListener* me = reinterpret_cast(user_data);
+ char** paths = reinterpret_cast(event_paths);
+ for (int i = 0; i < num_events; ++i) {
+ QString path = QString::fromUtf8(paths[i]);
+ qLog(Debug) << "Something changed at:" << path;
+ emit me->PathChanged(path);
+ }
+}
+
+void MacFSListener::AddPath(const QString& path) {
+ paths_.insert(path);
+ UpdateStream();
+}
+
+void MacFSListener::UpdateStream() {
+ if (stream_) {
+ FSEventStreamInvalidate(stream_);
+ stream_ = NULL;
+ }
+
+ if (paths_.empty()) {
+ return;
+ }
+
+ NSMutableArray* array = [[NSMutableArray alloc] init];
+
+ foreach (const QString& path, paths_) {
+ NSString* string = [[NSString alloc] initWithUTF8String: path.toUtf8().constData()];
+ [array addObject: string];
+ [string release];
+ }
+
+ FSEventStreamContext context;
+ memset(&context, 0, sizeof(context));
+ context.info = this;
+ CFAbsoluteTime latency = 1.0;
+
+ stream_ = FSEventStreamCreate(
+ NULL,
+ &EventStreamCallback,
+ &context, // Copied
+ (CFArrayRef)array,
+ kFSEventStreamEventIdSinceNow,
+ latency,
+ kFSEventStreamCreateFlagNone);
+
+ FSEventStreamScheduleWithRunLoop(stream_, run_loop_, kCFRunLoopDefaultMode);
+ FSEventStreamStart(stream_);
+
+ [array release];
+}
From 3c867fb05c8fd31623d942d86d7d30891e55c08d Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Wed, 4 Jan 2012 15:26:22 +0000
Subject: [PATCH 08/40] Add QObject constructor. (cherry picked from commit
3f0c779308cfa5cca5193c740d3057a23ddcec25)
---
src/core/macfslistener.h | 2 +-
src/core/macfslistener.mm | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/core/macfslistener.h b/src/core/macfslistener.h
index e33aaf120..f477751db 100644
--- a/src/core/macfslistener.h
+++ b/src/core/macfslistener.h
@@ -10,7 +10,7 @@ class MacFSListener : public QObject {
Q_OBJECT
public:
- MacFSListener();
+ explicit MacFSListener(QObject* parent = 0);
void Init();
void AddPath(const QString& path);
diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm
index 1c9d5d203..cf799bd89 100644
--- a/src/core/macfslistener.mm
+++ b/src/core/macfslistener.mm
@@ -6,8 +6,9 @@
#include "core/logging.h"
-MacFSListener::MacFSListener()
- : run_loop_(NULL),
+MacFSListener::MacFSListener(QObject* parent)
+ : QObject(parent),
+ run_loop_(NULL),
stream_(NULL) {
}
From e27568fbba902bd615aa7f07699bd8e56c4bd603 Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Wed, 4 Jan 2012 15:33:12 +0000
Subject: [PATCH 09/40] Add scoped_nsobject from Chrome. (cherry picked from
commit 0139f36e2db379ceb915c478f9e25813d94bdd51)
---
src/core/macfslistener.mm | 14 ++--
src/core/scoped_nsobject.h | 160 +++++++++++++++++++++++++++++++++++++
2 files changed, 167 insertions(+), 7 deletions(-)
create mode 100644 src/core/scoped_nsobject.h
diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm
index cf799bd89..4ae6c5d5a 100644
--- a/src/core/macfslistener.mm
+++ b/src/core/macfslistener.mm
@@ -5,6 +5,7 @@
#include
#include "core/logging.h"
+#include "core/scoped_nsobject.h"
MacFSListener::MacFSListener(QObject* parent)
: QObject(parent),
@@ -40,6 +41,7 @@ void MacFSListener::AddPath(const QString& path) {
void MacFSListener::UpdateStream() {
if (stream_) {
FSEventStreamInvalidate(stream_);
+ FSEventStreamRelease(stream_);
stream_ = NULL;
}
@@ -47,12 +49,12 @@ void MacFSListener::UpdateStream() {
return;
}
- NSMutableArray* array = [[NSMutableArray alloc] init];
+ scoped_nsobject array([[NSMutableArray alloc] init]);
foreach (const QString& path, paths_) {
- NSString* string = [[NSString alloc] initWithUTF8String: path.toUtf8().constData()];
- [array addObject: string];
- [string release];
+ scoped_nsobject string(
+ [[NSString alloc] initWithUTF8String: path.toUtf8().constData()]);
+ [array addObject: string.get()];
}
FSEventStreamContext context;
@@ -64,13 +66,11 @@ void MacFSListener::UpdateStream() {
NULL,
&EventStreamCallback,
&context, // Copied
- (CFArrayRef)array,
+ reinterpret_cast(array.get()),
kFSEventStreamEventIdSinceNow,
latency,
kFSEventStreamCreateFlagNone);
FSEventStreamScheduleWithRunLoop(stream_, run_loop_, kCFRunLoopDefaultMode);
FSEventStreamStart(stream_);
-
- [array release];
}
diff --git a/src/core/scoped_nsobject.h b/src/core/scoped_nsobject.h
new file mode 100644
index 000000000..cd8271399
--- /dev/null
+++ b/src/core/scoped_nsobject.h
@@ -0,0 +1,160 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_MEMORY_SCOPED_NSOBJECT_H_
+#define BASE_MEMORY_SCOPED_NSOBJECT_H_
+
+#import
+
+// scoped_nsobject<> is patterned after scoped_ptr<>, but maintains ownership
+// of an NSObject subclass object. Style deviations here are solely for
+// compatibility with scoped_ptr<>'s interface, with which everyone is already
+// familiar.
+//
+// When scoped_nsobject<> takes ownership of an object (in the constructor or
+// in reset()), it takes over the caller's existing ownership claim. The
+// caller must own the object it gives to scoped_nsobject<>, and relinquishes
+// an ownership claim to that object. scoped_nsobject<> does not call
+// -retain.
+//
+// scoped_nsobject<> is not to be used for NSAutoreleasePools. For
+// NSAutoreleasePools use ScopedNSAutoreleasePool from
+// scoped_nsautorelease_pool.h instead.
+// We check for bad uses of scoped_nsobject and NSAutoreleasePool at compile
+// time with a template specialization (see below).
+template
+class scoped_nsobject {
+ public:
+ explicit scoped_nsobject(NST* object = nil)
+ : object_(object) {
+ }
+
+ ~scoped_nsobject() {
+ [object_ release];
+ }
+
+ void reset(NST* object = nil) {
+ // We intentionally do not check that object != object_ as the caller must
+ // already have an ownership claim over whatever it gives to
+ // scoped_nsobject and ScopedCFTypeRef, whether it's in the constructor or
+ // in a call to reset(). In either case, it relinquishes that claim and
+ // the scoper assumes it.
+ [object_ release];
+ object_ = object;
+ }
+
+ bool operator==(NST* that) const { return object_ == that; }
+ bool operator!=(NST* that) const { return object_ != that; }
+
+ operator NST*() const {
+ return object_;
+ }
+
+ NST* get() const {
+ return object_;
+ }
+
+ void swap(scoped_nsobject& that) {
+ NST* temp = that.object_;
+ that.object_ = object_;
+ object_ = temp;
+ }
+
+ // scoped_nsobject<>::release() is like scoped_ptr<>::release. It is NOT
+ // a wrapper for [object_ release]. To force a scoped_nsobject<> object to
+ // call [object_ release], use scoped_nsobject<>::reset().
+ NST* release() __attribute__((warn_unused_result)) {
+ NST* temp = object_;
+ object_ = nil;
+ return temp;
+ }
+
+ private:
+ NST* object_;
+
+ Q_DISABLE_COPY(scoped_nsobject);
+};
+
+// Free functions
+template
+void swap(scoped_nsobject& p1, scoped_nsobject& p2) {
+ p1.swap(p2);
+}
+
+template
+bool operator==(C* p1, const scoped_nsobject& p2) {
+ return p1 == p2.get();
+}
+
+template
+bool operator!=(C* p1, const scoped_nsobject& p2) {
+ return p1 != p2.get();
+}
+
+
+// Specialization to make scoped_nsobject work.
+template<>
+class scoped_nsobject {
+ public:
+ explicit scoped_nsobject(id object = nil)
+ : object_(object) {
+ }
+
+ ~scoped_nsobject() {
+ [object_ release];
+ }
+
+ void reset(id object = nil) {
+ // We intentionally do not check that object != object_ as the caller must
+ // already have an ownership claim over whatever it gives to
+ // scoped_nsobject and ScopedCFTypeRef, whether it's in the constructor or
+ // in a call to reset(). In either case, it relinquishes that claim and
+ // the scoper assumes it.
+ [object_ release];
+ object_ = object;
+ }
+
+ bool operator==(id that) const { return object_ == that; }
+ bool operator!=(id that) const { return object_ != that; }
+
+ operator id() const {
+ return object_;
+ }
+
+ id get() const {
+ return object_;
+ }
+
+ void swap(scoped_nsobject& that) {
+ id temp = that.object_;
+ that.object_ = object_;
+ object_ = temp;
+ }
+
+ // scoped_nsobject<>::release() is like scoped_ptr<>::release. It is NOT
+ // a wrapper for [object_ release]. To force a scoped_nsobject<> object to
+ // call [object_ release], use scoped_nsobject<>::reset().
+ id release() __attribute__((warn_unused_result)) {
+ id temp = object_;
+ object_ = nil;
+ return temp;
+ }
+
+ private:
+ id object_;
+
+ Q_DISABLE_COPY(scoped_nsobject);
+};
+
+// Do not use scoped_nsobject for NSAutoreleasePools, use
+// ScopedNSAutoreleasePool instead. This is a compile time check. See details
+// at top of header.
+template<>
+class scoped_nsobject {
+ private:
+ explicit scoped_nsobject(NSAutoreleasePool* object = nil);
+ Q_DISABLE_COPY(scoped_nsobject);
+};
+
+#endif // BASE_MEMORY_SCOPED_NSOBJECT_H_
From ea9a8ea2ed6480dcd8af0388243201e47ddba027 Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Wed, 4 Jan 2012 15:34:52 +0000
Subject: [PATCH 10/40] Add copyright notice for Chromium code. (cherry picked
from commit 6357cb074bec8eeed028d6fc6d18aed83d6a140b)
---
debian/copyright | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/debian/copyright b/debian/copyright
index dc5ee28be..fde23fc18 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -45,6 +45,10 @@ Files: src/core/fht.*
Copyright: 2004, Melchior FRANZ
License: GPL-2+
+Files: src/core/scoped_nsobject.h
+Copyright: 2011, The Chromium Authors
+License: BSD-Google
+
Files: 3rdparty/gmock/*
Copyright: 2008, Google Inc.
License: BSD-Google
From ec2f57148b011d67fc397adf97ca18a021a2c066 Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Thu, 5 Jan 2012 14:51:23 +0000
Subject: [PATCH 11/40] Use FSEvent-based filesystem watcher on Mac. (cherry
picked from commit 9fdfb522254a0a6d3b9175c4d8de32a69f9371d8)
---
src/CMakeLists.txt | 4 +++
src/core/filesystemwatcherinterface.cpp | 23 +++++++++++++++
src/core/filesystemwatcherinterface.h | 19 +++++++++++++
src/core/macfslistener.h | 4 ++-
src/core/macfslistener.mm | 4 ++-
src/core/qtfslistener.cpp | 12 ++++++++
src/core/qtfslistener.h | 19 +++++++++++++
src/library/library.cpp | 3 ++
src/library/librarywatcher.cpp | 37 ++++++++++---------------
src/library/librarywatcher.h | 13 +++++----
src/musicbrainz/musicdnsclient.cpp | 21 ++++++++++++--
11 files changed, 126 insertions(+), 33 deletions(-)
create mode 100644 src/core/filesystemwatcherinterface.cpp
create mode 100644 src/core/filesystemwatcherinterface.h
create mode 100644 src/core/qtfslistener.cpp
create mode 100644 src/core/qtfslistener.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 443e70be6..4ef5790b6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -66,6 +66,7 @@ set(SOURCES
core/deletefiles.cpp
core/encoding.cpp
core/filesystemmusicstorage.cpp
+ core/filesystemwatcherinterface.cpp
core/fht.cpp
core/fmpsparser.cpp
core/globalshortcutbackend.cpp
@@ -80,6 +81,7 @@ set(SOURCES
core/organise.cpp
core/organiseformat.cpp
core/player.cpp
+ core/qtfslistener.cpp
core/qxtglobalshortcutbackend.cpp
core/scopedtransaction.cpp
core/settingsprovider.cpp
@@ -332,6 +334,7 @@ set(HEADERS
core/crashreporting.h
core/database.h
core/deletefiles.h
+ core/filesystemwatcherinterface.h
core/globalshortcuts.h
core/globalshortcutbackend.h
core/gnomeglobalshortcutbackend.h
@@ -340,6 +343,7 @@ set(HEADERS
core/network.h
core/organise.h
core/player.h
+ core/qtfslistener.h
core/songloader.h
core/taskmanager.h
core/urlhandler.h
diff --git a/src/core/filesystemwatcherinterface.cpp b/src/core/filesystemwatcherinterface.cpp
new file mode 100644
index 000000000..074322e73
--- /dev/null
+++ b/src/core/filesystemwatcherinterface.cpp
@@ -0,0 +1,23 @@
+#include "filesystemwatcherinterface.h"
+
+#include "qtfslistener.h"
+
+#ifdef Q_OS_DARWIN
+#include "macfslistener.h"
+#endif
+
+FileSystemWatcherInterface::FileSystemWatcherInterface(QObject* parent)
+ : QObject(parent) {
+}
+
+FileSystemWatcherInterface* FileSystemWatcherInterface::Create(QObject* parent) {
+ FileSystemWatcherInterface* ret;
+#ifdef Q_OS_DARWIN
+ ret = new MacFSListener(parent);
+#else
+ ret = new QtFSListener(parent);
+#endif
+
+ ret->Init();
+ return ret;
+}
diff --git a/src/core/filesystemwatcherinterface.h b/src/core/filesystemwatcherinterface.h
new file mode 100644
index 000000000..582391c02
--- /dev/null
+++ b/src/core/filesystemwatcherinterface.h
@@ -0,0 +1,19 @@
+#ifndef FILESYSTEMWATCHERINTERFACE_H
+#define FILESYSTEMWATCHERINTERFACE_H
+
+#include
+
+class FileSystemWatcherInterface : public QObject {
+ Q_OBJECT
+ public:
+ FileSystemWatcherInterface(QObject* parent = 0);
+ virtual void Init() {}
+ virtual void AddPath(const QString& path) = 0;
+
+ static FileSystemWatcherInterface* Create(QObject* parent = 0);
+
+ signals:
+ void PathChanged(const QString& path);
+};
+
+#endif
diff --git a/src/core/macfslistener.h b/src/core/macfslistener.h
index f477751db..9e214232e 100644
--- a/src/core/macfslistener.h
+++ b/src/core/macfslistener.h
@@ -6,7 +6,9 @@
#include
#include
-class MacFSListener : public QObject {
+#include "filesystemwatcherinterface.h"
+
+class MacFSListener : public FileSystemWatcherInterface {
Q_OBJECT
public:
diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm
index 4ae6c5d5a..3e245ac0c 100644
--- a/src/core/macfslistener.mm
+++ b/src/core/macfslistener.mm
@@ -8,7 +8,7 @@
#include "core/scoped_nsobject.h"
MacFSListener::MacFSListener(QObject* parent)
- : QObject(parent),
+ : FileSystemWatcherInterface(parent),
run_loop_(NULL),
stream_(NULL) {
}
@@ -34,12 +34,14 @@ void MacFSListener::EventStreamCallback(
}
void MacFSListener::AddPath(const QString& path) {
+ Q_ASSERT(run_loop_);
paths_.insert(path);
UpdateStream();
}
void MacFSListener::UpdateStream() {
if (stream_) {
+ FSEventStreamStop(stream_);
FSEventStreamInvalidate(stream_);
FSEventStreamRelease(stream_);
stream_ = NULL;
diff --git a/src/core/qtfslistener.cpp b/src/core/qtfslistener.cpp
new file mode 100644
index 000000000..0a136f779
--- /dev/null
+++ b/src/core/qtfslistener.cpp
@@ -0,0 +1,12 @@
+#include "qtfslistener.h"
+
+QtFSListener::QtFSListener(QObject* parent)
+ : FileSystemWatcherInterface(parent),
+ watcher_(this) {
+ connect(&watcher_, SIGNAL(directoryChanged(const QString&)),
+ SIGNAL(PathChanged(const QString&)));
+}
+
+void QtFSListener::AddPath(const QString& path) {
+ watcher_.addPath(path);
+}
diff --git a/src/core/qtfslistener.h b/src/core/qtfslistener.h
new file mode 100644
index 000000000..8b2dec126
--- /dev/null
+++ b/src/core/qtfslistener.h
@@ -0,0 +1,19 @@
+#ifndef QTFSLISTENER_H
+#define QTFSLISTENER_H
+
+#include "filesystemwatcherinterface.h"
+
+#include
+
+class QtFSListener : public FileSystemWatcherInterface {
+ Q_OBJECT
+ public:
+ QtFSListener(QObject* parent);
+ virtual void AddPath(const QString& path);
+
+ private:
+ QFileSystemWatcher watcher_;
+
+};
+
+#endif
diff --git a/src/library/library.cpp b/src/library/library.cpp
index 64b60d3a5..1f8d14322 100644
--- a/src/library/library.cpp
+++ b/src/library/library.cpp
@@ -16,9 +16,11 @@
*/
#include "library.h"
+
#include "librarymodel.h"
#include "librarybackend.h"
#include "core/database.h"
+#include "core/filesystemwatcherinterface.h"
#include "smartplaylists/generator.h"
#include "smartplaylists/querygenerator.h"
#include "smartplaylists/search.h"
@@ -119,6 +121,7 @@ void Library::WatcherInitialised() {
watcher->set_backend(backend_);
watcher->set_task_manager(task_manager_);
+ watcher->set_filesystem_watcher(FileSystemWatcherInterface::Create());
connect(backend_, SIGNAL(DirectoryDiscovered(Directory,SubdirectoryList)),
watcher, SLOT(AddDirectory(Directory,SubdirectoryList)));
diff --git a/src/library/librarywatcher.cpp b/src/library/librarywatcher.cpp
index da7e86c7a..4396c4f32 100644
--- a/src/library/librarywatcher.cpp
+++ b/src/library/librarywatcher.cpp
@@ -16,12 +16,13 @@
*/
#include "librarywatcher.h"
+
#include "librarybackend.h"
+#include "core/filesystemwatcherinterface.h"
#include "core/logging.h"
#include "core/taskmanager.h"
#include "playlistparsers/cueparser.h"
-#include
#include
#include
#include
@@ -48,6 +49,7 @@ LibraryWatcher::LibraryWatcher(QObject* parent)
: QObject(parent),
backend_(NULL),
task_manager_(NULL),
+ fs_watcher_(NULL),
stop_requested_(false),
scan_on_startup_(true),
monitor_(true),
@@ -113,7 +115,7 @@ LibraryWatcher::ScanTransaction::~ScanTransaction() {
if (watcher_->monitor_) {
// Watch the new subdirectories
foreach (const Subdirectory& subdir, new_subdirs) {
- watcher_->AddWatch(watcher_->watched_dirs_[dir_].watcher, subdir.path);
+ watcher_->AddWatch(subdir.path);
}
}
}
@@ -183,8 +185,6 @@ SubdirectoryList LibraryWatcher::ScanTransaction::GetAllSubdirs() {
void LibraryWatcher::AddDirectory(const Directory& dir, const SubdirectoryList& subdirs) {
DirData data;
data.dir = dir;
- data.watcher = new QFileSystemWatcher(this);
- connect(data.watcher, SIGNAL(directoryChanged(QString)), SLOT(DirectoryChanged(QString)));
watched_dirs_[dir.id] = data;
if (subdirs.isEmpty()) {
@@ -207,7 +207,7 @@ void LibraryWatcher::AddDirectory(const Directory& dir, const SubdirectoryList&
ScanSubdirectory(subdir.path, subdir, &transaction);
if (monitor_)
- AddWatch(data.watcher, subdir.path);
+ AddWatch(subdir.path);
}
}
@@ -546,18 +546,16 @@ uint LibraryWatcher::GetMtimeForCue(const QString& cue_path) {
: 0;
}
-void LibraryWatcher::AddWatch(QFileSystemWatcher* w, const QString& path) {
+void LibraryWatcher::AddWatch(const QString& path) {
if (!QFile::exists(path))
return;
- w->addPath(path);
+ connect(fs_watcher_, SIGNAL(PathChanged(const QString&)), this,
+ SLOT(DirectoryChanged(const QString&)), Qt::UniqueConnection);
+ fs_watcher_->AddPath(path);
}
void LibraryWatcher::RemoveDirectory(const Directory& dir) {
- if (watched_dirs_.contains(dir.id)) {
- delete watched_dirs_[dir.id].watcher;
- }
-
rescan_queue_.remove(dir.id);
watched_dirs_.remove(dir.id);
}
@@ -575,13 +573,9 @@ bool LibraryWatcher::FindSongByPath(const SongList& list, const QString& path, S
void LibraryWatcher::DirectoryChanged(const QString &subdir) {
// Find what dir it was in
- QFileSystemWatcher* watcher = qobject_cast(sender());
- if (!watcher)
- return;
-
Directory dir;
foreach (const DirData& info, watched_dirs_) {
- if (info.watcher == watcher)
+ if (subdir.startsWith(info.dir.path))
dir = info.dir;
}
@@ -689,7 +683,7 @@ void LibraryWatcher::ReloadSettings() {
s.beginGroup(kSettingsGroup);
scan_on_startup_ = s.value("startup_scan", true).toBool();
monitor_ = s.value("monitor", true).toBool();
-
+
best_image_filters_.clear();
QStringList filters = s.value("cover_art_patterns",
QStringList() << "front" << "cover").toStringList();
@@ -698,18 +692,15 @@ void LibraryWatcher::ReloadSettings() {
if (!s.isEmpty())
best_image_filters_ << s;
}
-
+
if (!monitor_ && was_monitoring_before) {
- // Remove all directories from all QFileSystemWatchers
- foreach (const DirData& data, watched_dirs_.values()) {
- data.watcher->removePaths(data.watcher->directories());
- }
+ // TODO: Remove all directories from watcher.
} else if (monitor_ && !was_monitoring_before) {
// Add all directories to all QFileSystemWatchers again
foreach (const DirData& data, watched_dirs_.values()) {
SubdirectoryList subdirs = backend_->SubdirsInDirectory(data.dir.id);
foreach (const Subdirectory& subdir, subdirs) {
- AddWatch(data.watcher, subdir.path);
+ AddWatch(subdir.path);
}
}
}
diff --git a/src/library/librarywatcher.h b/src/library/librarywatcher.h
index 92f7f68c6..f47c6207f 100644
--- a/src/library/librarywatcher.h
+++ b/src/library/librarywatcher.h
@@ -29,6 +29,7 @@ class QFileSystemWatcher;
class QTimer;
class CueParser;
+class FileSystemWatcherInterface;
class LibraryBackend;
class TaskManager;
@@ -42,8 +43,9 @@ class LibraryWatcher : public QObject {
void set_backend(LibraryBackend* backend) { backend_ = backend; }
void set_task_manager(TaskManager* task_manager) { task_manager_ = task_manager; }
+ void set_filesystem_watcher(FileSystemWatcherInterface* watcher) { fs_watcher_ = watcher; }
void set_device_name(const QString& device_name) { device_name_ = device_name; }
-
+
void IncrementalScanAsync();
void FullScanAsync();
void SetRescanPausedAsync(bool pause);
@@ -144,7 +146,7 @@ class LibraryWatcher : public QObject {
inline static QString DirectoryPart( const QString &fileName );
QString PickBestImage(const QStringList& images);
QString ImageForSong(const QString& path, QMap& album_art);
- void AddWatch(QFileSystemWatcher* w, const QString& path);
+ void AddWatch(const QString& path);
uint GetMtimeForCue(const QString& cue_path);
void PerformScan(bool incremental, bool ignore_mtimes);
@@ -172,20 +174,21 @@ class LibraryWatcher : public QObject {
// One of these gets stored for each Directory we're watching
struct DirData {
Directory dir;
- QFileSystemWatcher* watcher;
};
LibraryBackend* backend_;
TaskManager* task_manager_;
QString device_name_;
-
+
+ FileSystemWatcherInterface* fs_watcher_;
+
/* A list of words use to try to identify the (likely) best image
* found in an directory to use as cover artwork.
* e.g. using ["front", "cover"] would identify front.jpg and
* exclude back.jpg.
*/
QStringList best_image_filters_;
-
+
bool stop_requested_;
bool scan_on_startup_;
bool monitor_;
diff --git a/src/musicbrainz/musicdnsclient.cpp b/src/musicbrainz/musicdnsclient.cpp
index bd777d86e..ba8ec2d9f 100644
--- a/src/musicbrainz/musicdnsclient.cpp
+++ b/src/musicbrainz/musicdnsclient.cpp
@@ -16,14 +16,18 @@
*/
#include "musicdnsclient.h"
-#include "core/network.h"
+#include
#include
#include
#include
#include
-const char* MusicDnsClient::kClientId = "c44f70e49000dd7c0d1388bff2bf4152";
+#include "core/logging.h"
+#include "core/network.h"
+
+//const char* MusicDnsClient::kClientId = "c44f70e49000dd7c0d1388bff2bf4152";
+const char* MusicDnsClient::kClientId = "0736ac2cd889ef77f26f6b5e3fb8a09c";
const char* MusicDnsClient::kUrl = "http://ofa.musicdns.org/ofa/1/track";
const int MusicDnsClient::kDefaultTimeout = 5000; // msec
@@ -49,10 +53,12 @@ void MusicDnsClient::Start(int id, const QString& fingerprint, int duration_msec
<< Param("cvr", QString("%1 %2").arg(QCoreApplication::applicationName(),
QCoreApplication::applicationVersion()))
<< Param("dur", QString::number(duration_msec))
+ << Param("lkt", "1")
<< Param("fmt", "unknown")
<< Param("fpt", fingerprint)
<< Param("gnr", "unknown")
<< Param("rmd", "1")
+ << Param("rmt", "0")
<< Param("tnm", "0")
<< Param("ttl", "unknown")
<< Param("yrr", "0");
@@ -61,6 +67,8 @@ void MusicDnsClient::Start(int id, const QString& fingerprint, int duration_msec
url.setQueryItems(parameters);
QNetworkRequest req(url);
+ qLog(Debug) << url;
+
QNetworkReply* reply = network_->get(req);
connect(reply, SIGNAL(finished()), SLOT(RequestFinished()));
requests_[reply] = id;
@@ -90,12 +98,19 @@ void MusicDnsClient::RequestFinished() {
int id = requests_.take(reply);
+ qLog(Debug) << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
+
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
emit Finished(id, QString());
return;
}
- QXmlStreamReader reader(reply);
+ QByteArray data = reply->readAll();
+ qLog(Debug) << data;
+ QBuffer buffer(&data);
+ buffer.open(QIODevice::ReadOnly);
+
+ QXmlStreamReader reader(&buffer);
while (!reader.atEnd()) {
if (reader.readNext() == QXmlStreamReader::StartElement && reader.name() == "puid") {
QString puid = reader.attributes().value("id").toString();
From b5ff9955a87009ebb6dc48c90657876a7fe69bad Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Thu, 5 Jan 2012 15:01:43 +0000
Subject: [PATCH 12/40] Disable watching for FS updates when requested. (cherry
picked from commit 55e9fd8dc39df3a8884656aec6fc1cebf1268ccc)
---
src/core/filesystemwatcherinterface.h | 1 +
src/core/macfslistener.h | 2 +-
src/core/macfslistener.mm | 5 +++++
src/core/qtfslistener.cpp | 7 +++++++
src/core/qtfslistener.h | 1 +
src/library/librarywatcher.cpp | 2 +-
6 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/core/filesystemwatcherinterface.h b/src/core/filesystemwatcherinterface.h
index 582391c02..4663b46c8 100644
--- a/src/core/filesystemwatcherinterface.h
+++ b/src/core/filesystemwatcherinterface.h
@@ -9,6 +9,7 @@ class FileSystemWatcherInterface : public QObject {
FileSystemWatcherInterface(QObject* parent = 0);
virtual void Init() {}
virtual void AddPath(const QString& path) = 0;
+ virtual void Clear() = 0;
static FileSystemWatcherInterface* Create(QObject* parent = 0);
diff --git a/src/core/macfslistener.h b/src/core/macfslistener.h
index 9e214232e..de3602ad0 100644
--- a/src/core/macfslistener.h
+++ b/src/core/macfslistener.h
@@ -14,8 +14,8 @@ class MacFSListener : public FileSystemWatcherInterface {
public:
explicit MacFSListener(QObject* parent = 0);
void Init();
-
void AddPath(const QString& path);
+ void Clear();
signals:
void PathChanged(const QString& path);
diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm
index 3e245ac0c..88d6d1161 100644
--- a/src/core/macfslistener.mm
+++ b/src/core/macfslistener.mm
@@ -39,6 +39,11 @@ void MacFSListener::AddPath(const QString& path) {
UpdateStream();
}
+void MacFSListener::Clear() {
+ paths_.clear();
+ UpdateStream();
+}
+
void MacFSListener::UpdateStream() {
if (stream_) {
FSEventStreamStop(stream_);
diff --git a/src/core/qtfslistener.cpp b/src/core/qtfslistener.cpp
index 0a136f779..5b8560a55 100644
--- a/src/core/qtfslistener.cpp
+++ b/src/core/qtfslistener.cpp
@@ -1,5 +1,7 @@
#include "qtfslistener.h"
+#include
+
QtFSListener::QtFSListener(QObject* parent)
: FileSystemWatcherInterface(parent),
watcher_(this) {
@@ -10,3 +12,8 @@ QtFSListener::QtFSListener(QObject* parent)
void QtFSListener::AddPath(const QString& path) {
watcher_.addPath(path);
}
+
+void QtFSListener::Clear() {
+ watcher_.removePaths(watcher_.directories());
+ watcher_.removePaths(watcher_.files());
+}
diff --git a/src/core/qtfslistener.h b/src/core/qtfslistener.h
index 8b2dec126..cb3b737cb 100644
--- a/src/core/qtfslistener.h
+++ b/src/core/qtfslistener.h
@@ -10,6 +10,7 @@ class QtFSListener : public FileSystemWatcherInterface {
public:
QtFSListener(QObject* parent);
virtual void AddPath(const QString& path);
+ virtual void Clear();
private:
QFileSystemWatcher watcher_;
diff --git a/src/library/librarywatcher.cpp b/src/library/librarywatcher.cpp
index 4396c4f32..74457d239 100644
--- a/src/library/librarywatcher.cpp
+++ b/src/library/librarywatcher.cpp
@@ -694,7 +694,7 @@ void LibraryWatcher::ReloadSettings() {
}
if (!monitor_ && was_monitoring_before) {
- // TODO: Remove all directories from watcher.
+ fs_watcher_->Clear();
} else if (monitor_ && !was_monitoring_before) {
// Add all directories to all QFileSystemWatchers again
foreach (const DirData& data, watched_dirs_.values()) {
From fea20e9c29e0318b0775637eb430bf11ce718b81 Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Thu, 5 Jan 2012 15:06:32 +0000
Subject: [PATCH 13/40] Revert irrelevant musicdns changes. (cherry picked from
commit 047bec831bcc97cdc1986177da8b8f302ea967a0)
---
src/musicbrainz/musicdnsclient.cpp | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/src/musicbrainz/musicdnsclient.cpp b/src/musicbrainz/musicdnsclient.cpp
index ba8ec2d9f..bd777d86e 100644
--- a/src/musicbrainz/musicdnsclient.cpp
+++ b/src/musicbrainz/musicdnsclient.cpp
@@ -16,18 +16,14 @@
*/
#include "musicdnsclient.h"
+#include "core/network.h"
-#include
#include
#include
#include
#include
-#include "core/logging.h"
-#include "core/network.h"
-
-//const char* MusicDnsClient::kClientId = "c44f70e49000dd7c0d1388bff2bf4152";
-const char* MusicDnsClient::kClientId = "0736ac2cd889ef77f26f6b5e3fb8a09c";
+const char* MusicDnsClient::kClientId = "c44f70e49000dd7c0d1388bff2bf4152";
const char* MusicDnsClient::kUrl = "http://ofa.musicdns.org/ofa/1/track";
const int MusicDnsClient::kDefaultTimeout = 5000; // msec
@@ -53,12 +49,10 @@ void MusicDnsClient::Start(int id, const QString& fingerprint, int duration_msec
<< Param("cvr", QString("%1 %2").arg(QCoreApplication::applicationName(),
QCoreApplication::applicationVersion()))
<< Param("dur", QString::number(duration_msec))
- << Param("lkt", "1")
<< Param("fmt", "unknown")
<< Param("fpt", fingerprint)
<< Param("gnr", "unknown")
<< Param("rmd", "1")
- << Param("rmt", "0")
<< Param("tnm", "0")
<< Param("ttl", "unknown")
<< Param("yrr", "0");
@@ -67,8 +61,6 @@ void MusicDnsClient::Start(int id, const QString& fingerprint, int duration_msec
url.setQueryItems(parameters);
QNetworkRequest req(url);
- qLog(Debug) << url;
-
QNetworkReply* reply = network_->get(req);
connect(reply, SIGNAL(finished()), SLOT(RequestFinished()));
requests_[reply] = id;
@@ -98,19 +90,12 @@ void MusicDnsClient::RequestFinished() {
int id = requests_.take(reply);
- qLog(Debug) << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
-
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) {
emit Finished(id, QString());
return;
}
- QByteArray data = reply->readAll();
- qLog(Debug) << data;
- QBuffer buffer(&data);
- buffer.open(QIODevice::ReadOnly);
-
- QXmlStreamReader reader(&buffer);
+ QXmlStreamReader reader(reply);
while (!reader.atEnd()) {
if (reader.readNext() == QXmlStreamReader::StartElement && reader.name() == "puid") {
QString puid = reader.attributes().value("id").toString();
From a4ced28a852ee2efdd0e366241ebd120576da7a5 Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Thu, 5 Jan 2012 15:08:15 +0000
Subject: [PATCH 14/40] Add copyright headers. (cherry picked from commit
97f3885f58420348a44d73cba024ac7114793928)
---
src/core/filesystemwatcherinterface.cpp | 17 +++++++++++++++++
src/core/filesystemwatcherinterface.h | 17 +++++++++++++++++
src/core/macfslistener.h | 17 +++++++++++++++++
src/core/macfslistener.mm | 17 +++++++++++++++++
src/core/qtfslistener.cpp | 17 +++++++++++++++++
src/core/qtfslistener.h | 17 +++++++++++++++++
6 files changed, 102 insertions(+)
diff --git a/src/core/filesystemwatcherinterface.cpp b/src/core/filesystemwatcherinterface.cpp
index 074322e73..b6afcb0af 100644
--- a/src/core/filesystemwatcherinterface.cpp
+++ b/src/core/filesystemwatcherinterface.cpp
@@ -1,3 +1,20 @@
+/* This file is part of Clementine.
+ Copyright 2012, David Sansome
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
#include "filesystemwatcherinterface.h"
#include "qtfslistener.h"
diff --git a/src/core/filesystemwatcherinterface.h b/src/core/filesystemwatcherinterface.h
index 4663b46c8..3c260d784 100644
--- a/src/core/filesystemwatcherinterface.h
+++ b/src/core/filesystemwatcherinterface.h
@@ -1,3 +1,20 @@
+/* This file is part of Clementine.
+ Copyright 2012, David Sansome
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
#ifndef FILESYSTEMWATCHERINTERFACE_H
#define FILESYSTEMWATCHERINTERFACE_H
diff --git a/src/core/macfslistener.h b/src/core/macfslistener.h
index de3602ad0..7d98ebae1 100644
--- a/src/core/macfslistener.h
+++ b/src/core/macfslistener.h
@@ -1,3 +1,20 @@
+/* This file is part of Clementine.
+ Copyright 2012, David Sansome
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
#ifndef MACFSLISTENER_H
#define MACFSLISTENER_H
diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm
index 88d6d1161..e28c2885f 100644
--- a/src/core/macfslistener.mm
+++ b/src/core/macfslistener.mm
@@ -1,3 +1,20 @@
+/* This file is part of Clementine.
+ Copyright 2012, David Sansome
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
#include "macfslistener.h"
#include
diff --git a/src/core/qtfslistener.cpp b/src/core/qtfslistener.cpp
index 5b8560a55..af1356bda 100644
--- a/src/core/qtfslistener.cpp
+++ b/src/core/qtfslistener.cpp
@@ -1,3 +1,20 @@
+/* This file is part of Clementine.
+ Copyright 2012, David Sansome
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
#include "qtfslistener.h"
#include
diff --git a/src/core/qtfslistener.h b/src/core/qtfslistener.h
index cb3b737cb..fcb8d9a69 100644
--- a/src/core/qtfslistener.h
+++ b/src/core/qtfslistener.h
@@ -1,3 +1,20 @@
+/* This file is part of Clementine.
+ Copyright 2012, David Sansome
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
#ifndef QTFSLISTENER_H
#define QTFSLISTENER_H
From f6c229c5e6b38c2e85f6254e9eaa6aa8ad4bccef Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Thu, 5 Jan 2012 15:56:46 +0000
Subject: [PATCH 15/40] Add more robust subdirectory detection in
LibraryWatcher. (cherry picked from commit
761737eb4df64b0cff4b71fe261f9376eaf6ff42)
---
src/core/macfslistener.mm | 3 +++
src/library/librarywatcher.cpp | 17 +++++++++--------
src/library/librarywatcher.h | 18 ++++++++----------
3 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm
index e28c2885f..6d0326710 100644
--- a/src/core/macfslistener.mm
+++ b/src/core/macfslistener.mm
@@ -46,6 +46,9 @@ void MacFSListener::EventStreamCallback(
for (int i = 0; i < num_events; ++i) {
QString path = QString::fromUtf8(paths[i]);
qLog(Debug) << "Something changed at:" << path;
+ if (path.endsWith('/')) {
+ path.chop(1);
+ }
emit me->PathChanged(path);
}
}
diff --git a/src/library/librarywatcher.cpp b/src/library/librarywatcher.cpp
index 74457d239..b99366c09 100644
--- a/src/library/librarywatcher.cpp
+++ b/src/library/librarywatcher.cpp
@@ -115,7 +115,7 @@ LibraryWatcher::ScanTransaction::~ScanTransaction() {
if (watcher_->monitor_) {
// Watch the new subdirectories
foreach (const Subdirectory& subdir, new_subdirs) {
- watcher_->AddWatch(subdir.path);
+ watcher_->AddWatch(watcher_->watched_dirs_[dir_], subdir.path);
}
}
}
@@ -207,7 +207,7 @@ void LibraryWatcher::AddDirectory(const Directory& dir, const SubdirectoryList&
ScanSubdirectory(subdir.path, subdir, &transaction);
if (monitor_)
- AddWatch(subdir.path);
+ AddWatch(data, subdir.path);
}
}
@@ -546,13 +546,14 @@ uint LibraryWatcher::GetMtimeForCue(const QString& cue_path) {
: 0;
}
-void LibraryWatcher::AddWatch(const QString& path) {
+void LibraryWatcher::AddWatch(DirData dir, const QString& path) {
if (!QFile::exists(path))
return;
connect(fs_watcher_, SIGNAL(PathChanged(const QString&)), this,
SLOT(DirectoryChanged(const QString&)), Qt::UniqueConnection);
fs_watcher_->AddPath(path);
+ subdir_mapping_[path] = dir;
}
void LibraryWatcher::RemoveDirectory(const Directory& dir) {
@@ -573,11 +574,11 @@ bool LibraryWatcher::FindSongByPath(const SongList& list, const QString& path, S
void LibraryWatcher::DirectoryChanged(const QString &subdir) {
// Find what dir it was in
- Directory dir;
- foreach (const DirData& info, watched_dirs_) {
- if (subdir.startsWith(info.dir.path))
- dir = info.dir;
+ QHash::const_iterator it = subdir_mapping_.constFind(subdir);
+ if (it == subdir_mapping_.constEnd()) {
+ return;
}
+ Directory dir = it->dir;
qLog(Debug) << "Subdir" << subdir << "changed under directory" << dir.path << "id" << dir.id;
@@ -700,7 +701,7 @@ void LibraryWatcher::ReloadSettings() {
foreach (const DirData& data, watched_dirs_.values()) {
SubdirectoryList subdirs = backend_->SubdirsInDirectory(data.dir.id);
foreach (const Subdirectory& subdir, subdirs) {
- AddWatch(subdir.path);
+ AddWatch(data, subdir.path);
}
}
}
diff --git a/src/library/librarywatcher.h b/src/library/librarywatcher.h
index f47c6207f..024acc98f 100644
--- a/src/library/librarywatcher.h
+++ b/src/library/librarywatcher.h
@@ -21,6 +21,7 @@
#include "directory.h"
#include "core/song.h"
+#include
#include
#include
#include
@@ -140,13 +141,18 @@ class LibraryWatcher : public QObject {
ScanTransaction* t, bool force_noincremental = false);
private:
+ // One of these gets stored for each Directory we're watching
+ struct DirData {
+ Directory dir;
+ };
+
static bool FindSongByPath(const SongList& list, const QString& path, Song* out);
inline static QString NoExtensionPart( const QString &fileName );
inline static QString ExtensionPart( const QString &fileName );
inline static QString DirectoryPart( const QString &fileName );
QString PickBestImage(const QStringList& images);
QString ImageForSong(const QString& path, QMap& album_art);
- void AddWatch(const QString& path);
+ void AddWatch(DirData dir, const QString& path);
uint GetMtimeForCue(const QString& cue_path);
void PerformScan(bool incremental, bool ignore_mtimes);
@@ -171,16 +177,12 @@ class LibraryWatcher : public QObject {
const QString& matching_cue, QSet* cues_processed);
private:
- // One of these gets stored for each Directory we're watching
- struct DirData {
- Directory dir;
- };
-
LibraryBackend* backend_;
TaskManager* task_manager_;
QString device_name_;
FileSystemWatcherInterface* fs_watcher_;
+ QHash subdir_mapping_;
/* A list of words use to try to identify the (likely) best image
* found in an directory to use as cover artwork.
@@ -203,10 +205,6 @@ class LibraryWatcher : public QObject {
CueParser* cue_parser_;
static QStringList sValidImages;
-
- #ifdef Q_OS_DARWIN
- static const int kMaxWatches = 100;
- #endif
};
inline QString LibraryWatcher::NoExtensionPart( const QString &fileName ) {
From 2a72d17f382f7a6a036bdd3627f357e6a9997545 Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Thu, 5 Jan 2012 16:11:39 +0000
Subject: [PATCH 16/40] const& and tweaks to Mac directory canonicalisation.
(cherry picked from commit 483c36748e5896019d1ec197d03feeff78ddcd16)
---
src/core/macfslistener.mm | 2 +-
src/library/librarywatcher.cpp | 2 +-
src/library/librarywatcher.h | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/core/macfslistener.mm b/src/core/macfslistener.mm
index 6d0326710..1fa315fb5 100644
--- a/src/core/macfslistener.mm
+++ b/src/core/macfslistener.mm
@@ -46,7 +46,7 @@ void MacFSListener::EventStreamCallback(
for (int i = 0; i < num_events; ++i) {
QString path = QString::fromUtf8(paths[i]);
qLog(Debug) << "Something changed at:" << path;
- if (path.endsWith('/')) {
+ while (path.endsWith('/')) {
path.chop(1);
}
emit me->PathChanged(path);
diff --git a/src/library/librarywatcher.cpp b/src/library/librarywatcher.cpp
index b99366c09..41afe69be 100644
--- a/src/library/librarywatcher.cpp
+++ b/src/library/librarywatcher.cpp
@@ -546,7 +546,7 @@ uint LibraryWatcher::GetMtimeForCue(const QString& cue_path) {
: 0;
}
-void LibraryWatcher::AddWatch(DirData dir, const QString& path) {
+void LibraryWatcher::AddWatch(const DirData& dir, const QString& path) {
if (!QFile::exists(path))
return;
diff --git a/src/library/librarywatcher.h b/src/library/librarywatcher.h
index 024acc98f..72b69ca16 100644
--- a/src/library/librarywatcher.h
+++ b/src/library/librarywatcher.h
@@ -152,7 +152,7 @@ class LibraryWatcher : public QObject {
inline static QString DirectoryPart( const QString &fileName );
QString PickBestImage(const QStringList& images);
QString ImageForSong(const QString& path, QMap& album_art);
- void AddWatch(DirData dir, const QString& path);
+ void AddWatch(const DirData& dir, const QString& path);
uint GetMtimeForCue(const QString& cue_path);
void PerformScan(bool incremental, bool ignore_mtimes);
From f02732e1382919baf42d976cb3c3be11a7314192 Mon Sep 17 00:00:00 2001
From: John Maguire
Date: Fri, 6 Jan 2012 15:55:50 +0000
Subject: [PATCH 17/40] Add Chromaprint to 3rdparty. (cherry picked from commit
1bcbc2ed3e9547f73c0cc793070d0940fba06371)
---
3rdparty/chromaprint/.gitignore | 38 ++
3rdparty/chromaprint/CHANGES.txt | 5 +
3rdparty/chromaprint/CMakeLists.txt | 158 ++++++
3rdparty/chromaprint/COPYING.txt | 502 ++++++++++++++++++
3rdparty/chromaprint/NEWS.txt | 44 ++
3rdparty/chromaprint/README.txt | 96 ++++
.../chromaprint/cmake/modules/FindFFTW3.cmake | 133 +++++
.../cmake/modules/FindFFmpeg.cmake | 128 +++++
.../chromaprint/cmake/modules/FindGTest.cmake | 175 ++++++
.../cmake/modules/FindTaglib.cmake | 135 +++++
3rdparty/chromaprint/config.h.in | 7 +
3rdparty/chromaprint/examples/CMakeLists.txt | 39 ++
.../examples/ffmpeg/audioconvert.h | 118 ++++
.../chromaprint/examples/ffmpeg/samplefmt.h | 156 ++++++
3rdparty/chromaprint/examples/fpcalc.c | 303 +++++++++++
3rdparty/chromaprint/libchromaprint.pc.cmake | 12 +
3rdparty/chromaprint/src/CMakeLists.txt | 74 +++
3rdparty/chromaprint/src/audio_consumer.h | 38 ++
3rdparty/chromaprint/src/audio_processor.cpp | 191 +++++++
3rdparty/chromaprint/src/audio_processor.h | 87 +++
3rdparty/chromaprint/src/avresample/avcodec.h | 101 ++++
3rdparty/chromaprint/src/avresample/dsputil.h | 1 +
.../chromaprint/src/avresample/resample2.c | 320 +++++++++++
3rdparty/chromaprint/src/base64.cpp | 92 ++++
3rdparty/chromaprint/src/base64.h | 35 ++
3rdparty/chromaprint/src/bit_string_reader.h | 69 +++
3rdparty/chromaprint/src/bit_string_writer.h | 77 +++
3rdparty/chromaprint/src/chroma.cpp | 95 ++++
3rdparty/chromaprint/src/chroma.h | 68 +++
3rdparty/chromaprint/src/chroma_filter.cpp | 69 +++
3rdparty/chromaprint/src/chroma_filter.h | 54 ++
3rdparty/chromaprint/src/chroma_normalizer.h | 55 ++
3rdparty/chromaprint/src/chroma_resampler.cpp | 62 +++
3rdparty/chromaprint/src/chroma_resampler.h | 52 ++
3rdparty/chromaprint/src/chromaprint.cpp | 150 ++++++
3rdparty/chromaprint/src/chromaprint.h | 222 ++++++++
3rdparty/chromaprint/src/classifier.h | 61 +++
3rdparty/chromaprint/src/combined_buffer.h | 176 ++++++
3rdparty/chromaprint/src/debug.h | 42 ++
3rdparty/chromaprint/src/decoder.h | 15 +
3rdparty/chromaprint/src/ext/audio_dumper.h | 30 ++
3rdparty/chromaprint/src/ext/ffmpeg_decoder.h | 230 ++++++++
3rdparty/chromaprint/src/ext/image_utils.cpp | 27 +
3rdparty/chromaprint/src/ext/image_utils.h | 108 ++++
3rdparty/chromaprint/src/ext/sox_decoder.h | 101 ++++
.../chromaprint/src/feature_vector_consumer.h | 39 ++
3rdparty/chromaprint/src/fft.cpp | 77 +++
3rdparty/chromaprint/src/fft.h | 62 +++
3rdparty/chromaprint/src/fft_frame.h | 69 +++
3rdparty/chromaprint/src/fft_frame_consumer.h | 38 ++
3rdparty/chromaprint/src/fft_lib.h | 40 ++
3rdparty/chromaprint/src/fft_lib_avfft.cpp | 60 +++
3rdparty/chromaprint/src/fft_lib_avfft.h | 53 ++
3rdparty/chromaprint/src/fft_lib_fftw3.cpp | 58 ++
3rdparty/chromaprint/src/fft_lib_fftw3.h | 51 ++
3rdparty/chromaprint/src/fft_lib_vdsp.cpp | 61 +++
3rdparty/chromaprint/src/fft_lib_vdsp.h | 52 ++
3rdparty/chromaprint/src/filter.cpp | 47 ++
3rdparty/chromaprint/src/filter.h | 67 +++
3rdparty/chromaprint/src/filter_utils.h | 136 +++++
.../src/fingerprint_calculator.cpp | 67 +++
.../chromaprint/src/fingerprint_calculator.h | 51 ++
.../src/fingerprint_compressor.cpp | 92 ++++
.../chromaprint/src/fingerprint_compressor.h | 59 ++
.../src/fingerprint_decompressor.cpp | 99 ++++
.../src/fingerprint_decompressor.h | 56 ++
3rdparty/chromaprint/src/fingerprinter.cpp | 97 ++++
3rdparty/chromaprint/src/fingerprinter.h | 78 +++
.../src/fingerprinter_configuration.cpp | 107 ++++
.../src/fingerprinter_configuration.h | 126 +++++
3rdparty/chromaprint/src/foo.cpp | 0
3rdparty/chromaprint/src/image.h | 74 +++
3rdparty/chromaprint/src/image_builder.cpp | 43 ++
3rdparty/chromaprint/src/image_builder.h | 66 +++
3rdparty/chromaprint/src/integral_image.cpp | 49 ++
3rdparty/chromaprint/src/integral_image.h | 87 +++
3rdparty/chromaprint/src/lloyds.cpp | 111 ++++
3rdparty/chromaprint/src/lloyds.h | 15 +
3rdparty/chromaprint/src/quantizer.h | 76 +++
3rdparty/chromaprint/src/silence_remover.cpp | 65 +++
3rdparty/chromaprint/src/silence_remover.h | 59 ++
3rdparty/chromaprint/src/sox_audio_source.cpp | 71 +++
3rdparty/chromaprint/src/sox_audio_source.h | 29 +
.../chromaprint/src/spectral_centroid.cpp | 91 ++++
3rdparty/chromaprint/src/spectral_centroid.h | 59 ++
3rdparty/chromaprint/src/spectrum.cpp | 88 +++
3rdparty/chromaprint/src/spectrum.h | 59 ++
3rdparty/chromaprint/src/utils.h | 154 ++++++
3rdparty/chromaprint/tests/CMakeLists.txt | 41 ++
3rdparty/chromaprint/tests/audio_buffer.h | 21 +
.../tests/data/test_mono_11025.raw | Bin 0 -> 44080 bytes
.../tests/data/test_mono_44100.raw | Bin 0 -> 176400 bytes
.../chromaprint/tests/data/test_mono_8000.raw | Bin 0 -> 31982 bytes
.../tests/data/test_stereo_44100.raw | Bin 0 -> 352800 bytes
3rdparty/chromaprint/tests/main.cpp | 8 +
3rdparty/chromaprint/tests/test_api.cpp | 99 ++++
.../tests/test_audio_processor.cpp | 114 ++++
3rdparty/chromaprint/tests/test_base64.cpp | 56 ++
.../tests/test_bit_string_reader.cpp | 47 ++
.../tests/test_bit_string_writer.cpp | 53 ++
3rdparty/chromaprint/tests/test_chroma.cpp | 125 +++++
.../chromaprint/tests/test_chroma_filter.cpp | 74 +++
.../tests/test_chroma_resampler.cpp | 48 ++
.../chromaprint/tests/test_chromaprint.cpp | 67 +++
.../tests/test_combined_buffer.cpp | 95 ++++
3rdparty/chromaprint/tests/test_filter.cpp | 25 +
.../chromaprint/tests/test_filter_utils.cpp | 118 ++++
.../tests/test_fingerprint_calculator.cpp | 53 ++
.../tests/test_fingerprint_compressor.cpp | 79 +++
.../tests/test_fingerprint_decompressor.cpp | 77 +++
.../chromaprint/tests/test_integral_image.cpp | 40 ++
3rdparty/chromaprint/tests/test_lloyds.cpp | 80 +++
3rdparty/chromaprint/tests/test_quantizer.cpp | 17 +
.../tests/test_silence_remover.cpp | 49 ++
3rdparty/chromaprint/tests/test_utils.cpp | 91 ++++
3rdparty/chromaprint/tests/test_utils.h | 42 ++
3rdparty/chromaprint/tools/CMakeLists.txt | 63 +++
3rdparty/chromaprint/tools/chromagram.cpp | 65 +++
3rdparty/chromaprint/tools/decode.cpp | 28 +
3rdparty/chromaprint/tools/fillpuid.py | 76 +++
3rdparty/chromaprint/tools/fpcollect.cpp | 323 +++++++++++
3rdparty/chromaprint/tools/fpeval.cpp | 142 +++++
3rdparty/chromaprint/tools/fpsubmit.py | 121 +++++
3rdparty/chromaprint/tools/learn_filters.cpp | 396 ++++++++++++++
3rdparty/chromaprint/tools/match.h | 42 ++
.../chromaprint/tools/misc/prepare-128mp3.sh | 13 +
.../chromaprint/tools/misc/prepare-32mp3.sh | 13 +
.../chromaprint/tools/misc/prepare-64mp3.sh | 13 +
.../chromaprint/tools/misc/prepare-64wma.sh | 13 +
.../chromaprint/tools/misc/prepare-gain.sh | 17 +
.../tools/misc/prepare-resample.sh | 15 +
.../chromaprint/tools/misc/prepare-wav.sh | 9 +
3rdparty/chromaprint/tools/misc/prepare.sh | 9 +
3rdparty/chromaprint/tools/resample.cpp | 35 ++
3rdparty/chromaprint/tools/spectrogram.cpp | 63 +++
135 files changed, 10664 insertions(+)
create mode 100644 3rdparty/chromaprint/.gitignore
create mode 100644 3rdparty/chromaprint/CHANGES.txt
create mode 100644 3rdparty/chromaprint/CMakeLists.txt
create mode 100644 3rdparty/chromaprint/COPYING.txt
create mode 100644 3rdparty/chromaprint/NEWS.txt
create mode 100644 3rdparty/chromaprint/README.txt
create mode 100644 3rdparty/chromaprint/cmake/modules/FindFFTW3.cmake
create mode 100644 3rdparty/chromaprint/cmake/modules/FindFFmpeg.cmake
create mode 100644 3rdparty/chromaprint/cmake/modules/FindGTest.cmake
create mode 100644 3rdparty/chromaprint/cmake/modules/FindTaglib.cmake
create mode 100644 3rdparty/chromaprint/config.h.in
create mode 100644 3rdparty/chromaprint/examples/CMakeLists.txt
create mode 100644 3rdparty/chromaprint/examples/ffmpeg/audioconvert.h
create mode 100644 3rdparty/chromaprint/examples/ffmpeg/samplefmt.h
create mode 100644 3rdparty/chromaprint/examples/fpcalc.c
create mode 100644 3rdparty/chromaprint/libchromaprint.pc.cmake
create mode 100644 3rdparty/chromaprint/src/CMakeLists.txt
create mode 100644 3rdparty/chromaprint/src/audio_consumer.h
create mode 100644 3rdparty/chromaprint/src/audio_processor.cpp
create mode 100644 3rdparty/chromaprint/src/audio_processor.h
create mode 100644 3rdparty/chromaprint/src/avresample/avcodec.h
create mode 100644 3rdparty/chromaprint/src/avresample/dsputil.h
create mode 100644 3rdparty/chromaprint/src/avresample/resample2.c
create mode 100644 3rdparty/chromaprint/src/base64.cpp
create mode 100644 3rdparty/chromaprint/src/base64.h
create mode 100644 3rdparty/chromaprint/src/bit_string_reader.h
create mode 100644 3rdparty/chromaprint/src/bit_string_writer.h
create mode 100644 3rdparty/chromaprint/src/chroma.cpp
create mode 100644 3rdparty/chromaprint/src/chroma.h
create mode 100644 3rdparty/chromaprint/src/chroma_filter.cpp
create mode 100644 3rdparty/chromaprint/src/chroma_filter.h
create mode 100644 3rdparty/chromaprint/src/chroma_normalizer.h
create mode 100644 3rdparty/chromaprint/src/chroma_resampler.cpp
create mode 100644 3rdparty/chromaprint/src/chroma_resampler.h
create mode 100644 3rdparty/chromaprint/src/chromaprint.cpp
create mode 100644 3rdparty/chromaprint/src/chromaprint.h
create mode 100644 3rdparty/chromaprint/src/classifier.h
create mode 100644 3rdparty/chromaprint/src/combined_buffer.h
create mode 100644 3rdparty/chromaprint/src/debug.h
create mode 100644 3rdparty/chromaprint/src/decoder.h
create mode 100644 3rdparty/chromaprint/src/ext/audio_dumper.h
create mode 100644 3rdparty/chromaprint/src/ext/ffmpeg_decoder.h
create mode 100644 3rdparty/chromaprint/src/ext/image_utils.cpp
create mode 100644 3rdparty/chromaprint/src/ext/image_utils.h
create mode 100644 3rdparty/chromaprint/src/ext/sox_decoder.h
create mode 100644 3rdparty/chromaprint/src/feature_vector_consumer.h
create mode 100644 3rdparty/chromaprint/src/fft.cpp
create mode 100644 3rdparty/chromaprint/src/fft.h
create mode 100644 3rdparty/chromaprint/src/fft_frame.h
create mode 100644 3rdparty/chromaprint/src/fft_frame_consumer.h
create mode 100644 3rdparty/chromaprint/src/fft_lib.h
create mode 100644 3rdparty/chromaprint/src/fft_lib_avfft.cpp
create mode 100644 3rdparty/chromaprint/src/fft_lib_avfft.h
create mode 100644 3rdparty/chromaprint/src/fft_lib_fftw3.cpp
create mode 100644 3rdparty/chromaprint/src/fft_lib_fftw3.h
create mode 100644 3rdparty/chromaprint/src/fft_lib_vdsp.cpp
create mode 100644 3rdparty/chromaprint/src/fft_lib_vdsp.h
create mode 100644 3rdparty/chromaprint/src/filter.cpp
create mode 100644 3rdparty/chromaprint/src/filter.h
create mode 100644 3rdparty/chromaprint/src/filter_utils.h
create mode 100644 3rdparty/chromaprint/src/fingerprint_calculator.cpp
create mode 100644 3rdparty/chromaprint/src/fingerprint_calculator.h
create mode 100644 3rdparty/chromaprint/src/fingerprint_compressor.cpp
create mode 100644 3rdparty/chromaprint/src/fingerprint_compressor.h
create mode 100644 3rdparty/chromaprint/src/fingerprint_decompressor.cpp
create mode 100644 3rdparty/chromaprint/src/fingerprint_decompressor.h
create mode 100644 3rdparty/chromaprint/src/fingerprinter.cpp
create mode 100644 3rdparty/chromaprint/src/fingerprinter.h
create mode 100644 3rdparty/chromaprint/src/fingerprinter_configuration.cpp
create mode 100644 3rdparty/chromaprint/src/fingerprinter_configuration.h
create mode 100644 3rdparty/chromaprint/src/foo.cpp
create mode 100644 3rdparty/chromaprint/src/image.h
create mode 100644 3rdparty/chromaprint/src/image_builder.cpp
create mode 100644 3rdparty/chromaprint/src/image_builder.h
create mode 100644 3rdparty/chromaprint/src/integral_image.cpp
create mode 100644 3rdparty/chromaprint/src/integral_image.h
create mode 100644 3rdparty/chromaprint/src/lloyds.cpp
create mode 100644 3rdparty/chromaprint/src/lloyds.h
create mode 100644 3rdparty/chromaprint/src/quantizer.h
create mode 100644 3rdparty/chromaprint/src/silence_remover.cpp
create mode 100644 3rdparty/chromaprint/src/silence_remover.h
create mode 100644 3rdparty/chromaprint/src/sox_audio_source.cpp
create mode 100644 3rdparty/chromaprint/src/sox_audio_source.h
create mode 100644 3rdparty/chromaprint/src/spectral_centroid.cpp
create mode 100644 3rdparty/chromaprint/src/spectral_centroid.h
create mode 100644 3rdparty/chromaprint/src/spectrum.cpp
create mode 100644 3rdparty/chromaprint/src/spectrum.h
create mode 100644 3rdparty/chromaprint/src/utils.h
create mode 100644 3rdparty/chromaprint/tests/CMakeLists.txt
create mode 100644 3rdparty/chromaprint/tests/audio_buffer.h
create mode 100644 3rdparty/chromaprint/tests/data/test_mono_11025.raw
create mode 100644 3rdparty/chromaprint/tests/data/test_mono_44100.raw
create mode 100644 3rdparty/chromaprint/tests/data/test_mono_8000.raw
create mode 100644 3rdparty/chromaprint/tests/data/test_stereo_44100.raw
create mode 100644 3rdparty/chromaprint/tests/main.cpp
create mode 100644 3rdparty/chromaprint/tests/test_api.cpp
create mode 100644 3rdparty/chromaprint/tests/test_audio_processor.cpp
create mode 100644 3rdparty/chromaprint/tests/test_base64.cpp
create mode 100644 3rdparty/chromaprint/tests/test_bit_string_reader.cpp
create mode 100644 3rdparty/chromaprint/tests/test_bit_string_writer.cpp
create mode 100644 3rdparty/chromaprint/tests/test_chroma.cpp
create mode 100644 3rdparty/chromaprint/tests/test_chroma_filter.cpp
create mode 100644 3rdparty/chromaprint/tests/test_chroma_resampler.cpp
create mode 100644 3rdparty/chromaprint/tests/test_chromaprint.cpp
create mode 100644 3rdparty/chromaprint/tests/test_combined_buffer.cpp
create mode 100644 3rdparty/chromaprint/tests/test_filter.cpp
create mode 100644 3rdparty/chromaprint/tests/test_filter_utils.cpp
create mode 100644 3rdparty/chromaprint/tests/test_fingerprint_calculator.cpp
create mode 100644 3rdparty/chromaprint/tests/test_fingerprint_compressor.cpp
create mode 100644 3rdparty/chromaprint/tests/test_fingerprint_decompressor.cpp
create mode 100644 3rdparty/chromaprint/tests/test_integral_image.cpp
create mode 100644 3rdparty/chromaprint/tests/test_lloyds.cpp
create mode 100644 3rdparty/chromaprint/tests/test_quantizer.cpp
create mode 100644 3rdparty/chromaprint/tests/test_silence_remover.cpp
create mode 100644 3rdparty/chromaprint/tests/test_utils.cpp
create mode 100644 3rdparty/chromaprint/tests/test_utils.h
create mode 100644 3rdparty/chromaprint/tools/CMakeLists.txt
create mode 100644 3rdparty/chromaprint/tools/chromagram.cpp
create mode 100644 3rdparty/chromaprint/tools/decode.cpp
create mode 100755 3rdparty/chromaprint/tools/fillpuid.py
create mode 100644 3rdparty/chromaprint/tools/fpcollect.cpp
create mode 100644 3rdparty/chromaprint/tools/fpeval.cpp
create mode 100755 3rdparty/chromaprint/tools/fpsubmit.py
create mode 100644 3rdparty/chromaprint/tools/learn_filters.cpp
create mode 100644 3rdparty/chromaprint/tools/match.h
create mode 100755 3rdparty/chromaprint/tools/misc/prepare-128mp3.sh
create mode 100755 3rdparty/chromaprint/tools/misc/prepare-32mp3.sh
create mode 100755 3rdparty/chromaprint/tools/misc/prepare-64mp3.sh
create mode 100755 3rdparty/chromaprint/tools/misc/prepare-64wma.sh
create mode 100755 3rdparty/chromaprint/tools/misc/prepare-gain.sh
create mode 100755 3rdparty/chromaprint/tools/misc/prepare-resample.sh
create mode 100755 3rdparty/chromaprint/tools/misc/prepare-wav.sh
create mode 100755 3rdparty/chromaprint/tools/misc/prepare.sh
create mode 100644 3rdparty/chromaprint/tools/resample.cpp
create mode 100644 3rdparty/chromaprint/tools/spectrogram.cpp
diff --git a/3rdparty/chromaprint/.gitignore b/3rdparty/chromaprint/.gitignore
new file mode 100644
index 000000000..f9889eb31
--- /dev/null
+++ b/3rdparty/chromaprint/.gitignore
@@ -0,0 +1,38 @@
+CMakeFiles
+CMakeCache.txt
+Makefile
+cmake_install.cmake
+config.h
+tests/all_tests
+tools/fpgen
+tools/fpcollect
+*.exe
+*.dll
+*.so
+*.a
+tools/fpeval
+tools/learn_filters
+tools/decode
+tools/chromagram
+tools/resample
+libchromaprint.pc
+install_manifest.txt
+tools/spectrogram
+src/libchromaprint.so.*
+*.vcxproj
+*.vcxproj.*
+*.dir
+*.sln
+*.suo
+Debug
+src/Debug
+*.dll
+*.lib
+*.pdb
+*.dll.manifest
+*.exp
+*.dylib
+*.vcproj
+*.user
+*.ncb
+src/Release
diff --git a/3rdparty/chromaprint/CHANGES.txt b/3rdparty/chromaprint/CHANGES.txt
new file mode 100644
index 000000000..6977b6aee
--- /dev/null
+++ b/3rdparty/chromaprint/CHANGES.txt
@@ -0,0 +1,5 @@
+Version 0.1 (2010-10-30)
+========================
+
+- Initial release.
+
diff --git a/3rdparty/chromaprint/CMakeLists.txt b/3rdparty/chromaprint/CMakeLists.txt
new file mode 100644
index 000000000..ddcf7afaa
--- /dev/null
+++ b/3rdparty/chromaprint/CMakeLists.txt
@@ -0,0 +1,158 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(chromaprint)
+set(PROJECT_VERSION 0.6.0)
+
+# 1. If the library source code has changed at all since the last update, then increment revision.
+# 2. If any interfaces have been added, removed, or changed since the last update, increment current, and set revision to 0.
+# 3. If any interfaces have been added since the last public release, then increment age.
+# 4. If any interfaces have been removed since the last public release, then set age to 0.
+set(chromaprint_SOVERSION_CURRENT 1)
+set(chromaprint_SOVERSION_REVISION 4)
+set(chromaprint_SOVERSION_AGE 1)
+
+math(EXPR chromaprint_SOVERSION_MAJOR "${chromaprint_SOVERSION_CURRENT} - ${chromaprint_SOVERSION_AGE}")
+math(EXPR chromaprint_SOVERSION_MINOR "${chromaprint_SOVERSION_AGE}")
+math(EXPR chromaprint_SOVERSION_PATCH "${chromaprint_SOVERSION_REVISION}")
+
+set(chromaprint_VERSION ${chromaprint_SOVERSION_MAJOR}.${chromaprint_SOVERSION_MINOR}.${chromaprint_SOVERSION_PATCH})
+set(chromaprint_SOVERSION ${chromaprint_SOVERSION_MAJOR})
+
+include(CheckFunctionExists)
+set(CMAKE_REQUIRED_LIBRARIES -lm)
+check_function_exists(lrintf HAVE_LRINTF)
+check_function_exists(round HAVE_ROUND)
+
+add_definitions(
+ -DHAVE_CONFIG_H
+ -D_SCL_SECURE_NO_WARNINGS
+ -D_USE_MATH_DEFINES
+ -D__STDC_LIMIT_MACROS
+ -D__STDC_CONSTANT_MACROS
+)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
+set(EXEC_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "Installation prefix for executables and object code libraries" FORCE)
+set(BIN_INSTALL_DIR ${EXEC_INSTALL_PREFIX}/bin CACHE PATH "Installation prefix for user executables" FORCE)
+set(LIB_INSTALL_DIR ${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX} CACHE PATH "Installation prefix for object code libraries" FORCE)
+set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include CACHE PATH "Installation prefix for C header files" FORCE)
+
+if(APPLE)
+ option(BUILD_FRAMEWORK "Build an OS X framework" OFF)
+ set(FRAMEWORK_INSTALL_DIR "/Library/Frameworks" CACHE STRING "Directory to install frameworks to.")
+endif()
+
+option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
+option(BUILD_EXAMPLES "Build the examples" OFF)
+option(BUILD_TESTS "Build the test suite" OFF)
+option(BUILD_TOOLS "Build standard tools" OFF)
+option(BUILD_EXTRA_TOOLS "Build extra tools (only useful for development of this library)" OFF)
+
+if(CMAKE_COMPILER_IS_GNUCXX)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
+endif()
+if(CMAKE_COMPILER_IS_GNUCXX AND BUILD_SHARED_LIBS)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+endif()
+
+if(NOT BUILD_SHARED_LIBS)
+ add_definitions(-DCHROMAPRINT_NODLL)
+endif()
+
+option(WITH_AVFFT "Use FFmpeg for FFT calculations" OFF)
+option(WITH_FFTW3 "Use FFTW3 for FFT calculations" OFF)
+option(WITH_VDSP "Use vDSP for FFT calculations" OFF)
+
+set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests/)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
+find_package(FFmpeg)
+find_package(FFTW3)
+if(APPLE)
+ find_library(ACCELERATE_LIBRARIES Accelerate)
+endif()
+
+set(FFT_OPTION_COUNT 0)
+
+if(WITH_AVFFT)
+ math(EXPR FFT_OPTION_COUNT "${FFT_OPTION_COUNT} + 1")
+endif()
+if(WITH_FFTW3)
+ math(EXPR FFT_OPTION_COUNT "${FFT_OPTION_COUNT} + 1")
+endif()
+if(WITH_VDSP)
+ math(EXPR FFT_OPTION_COUNT "${FFT_OPTION_COUNT} + 1")
+endif()
+if(FFT_OPTION_COUNT GREATER "1")
+ message(FATAL_ERROR "Only one of WITH_AVFFT, WITH_FFTW3 AND WITH_VDSP can be selected")
+endif()
+
+if(WITH_AVFFT AND NOT FFMPEG_LIBAVCODEC_FFT_FOUND)
+ message(FATAL_ERROR "FFmpeg with avfft.h not found")
+endif()
+
+if(WITH_FFTW3 AND NOT FFTW3_FOUND)
+ message(FATAL_ERROR "FFTW3 not found")
+endif()
+
+if(APPLE AND WITH_VDSP AND NOT ACCELERATE_LIBRARIES)
+ message(FATAL_ERROR "vDSP (Accelerate) not found")
+endif()
+
+if(NOT WITH_AVFFT AND NOT WITH_FFTW3)
+ if(APPLE AND ACCELERATE_LIBRARIES)
+ set(WITH_VDSP ON)
+ elseif(FFMPEG_LIBAVCODEC_FFT_FOUND)
+ set(WITH_AVFFT ON)
+ elseif(FFTW3_FOUND)
+ set(WITH_FFTW3 ON)
+ else()
+ message(FATAL_ERROR "Neither FFmpeg with avfft.h nor FFTW3 found")
+ endif()
+endif()
+
+if(WITH_AVFFT)
+ message(STATUS "Using FFmpeg for FFT calculations")
+endif(WITH_AVFFT)
+
+if(WITH_FFTW3)
+ message(STATUS "Using FFTW3 for FFT calculations")
+endif(WITH_FFTW3)
+
+if(NOT APPLE AND NOT BUILD_FRAMEWORK)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libchromaprint.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libchromaprint.pc)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libchromaprint.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+endif()
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
+add_subdirectory(src)
+
+if(BUILD_TOOLS_EXTRA)
+ find_package(PNG REQUIRED)
+endif(BUILD_TOOLS_EXTRA)
+
+find_package(Boost COMPONENTS system filesystem)
+if(BUILD_TOOLS OR BUILD_TOOLS_EXTRA OR BUILD_EXAMPLES)
+ find_package(FFmpeg REQUIRED)
+endif()
+
+if(BUILD_EXAMPLES)
+ add_subdirectory(examples)
+endif()
+
+if(BUILD_TOOLS OR BUILD_TOOLS_EXTRA)
+ find_package(Taglib REQUIRED)
+ add_subdirectory(tools)
+endif(BUILD_TOOLS OR BUILD_TOOLS_EXTRA)
+
+if(BUILD_TESTS)
+ find_package(Threads)
+ find_package(GTest REQUIRED)
+ add_subdirectory(tests)
+endif(BUILD_TESTS)
+
diff --git a/3rdparty/chromaprint/COPYING.txt b/3rdparty/chromaprint/COPYING.txt
new file mode 100644
index 000000000..4362b4915
--- /dev/null
+++ b/3rdparty/chromaprint/COPYING.txt
@@ -0,0 +1,502 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ , 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/3rdparty/chromaprint/NEWS.txt b/3rdparty/chromaprint/NEWS.txt
new file mode 100644
index 000000000..96a12b671
--- /dev/null
+++ b/3rdparty/chromaprint/NEWS.txt
@@ -0,0 +1,44 @@
+Version 0.6 -- December 22, 2011
+================================
+
+ - Support for 24-bit file formats in fpcalc.
+ - The fpcalc utility now uses 120 seconds of audio data by default.
+ - Python bindings moved to a separate project (pyacoustid).
+
+Version 0.5 -- October 6, 2011
+==============================
+
+ - Unicode command line handling in fpcalc.
+ - Fixed a crash in fpcalc when FFmpeg was not able to identify the codec.
+ - Added encode_fingerprint to the Python bindings.
+
+Version 0.4 -- May 14, 2011
+===========================
+
+ - Support for building a Mac OS X framework.
+ - Support for building a static library.
+ - Simple C example (fpcalc) that can be used from external applications for
+ fingerprint calculations.
+
+Version 0.3 -- April 26, 2011
+=============================
+
+ - Fixed compilation with MSVC 2010.
+ - Added support for calculating FFT using the Accelerate framework on
+ Mac OS X and iOS.
+ - Added Python bindings.
+
+Version 0.2 -- January 26, 2011
+===============================
+
+ - New public functions chromaprint_{encode,decode}_fingerprint to
+ encoding/decoding raw fingerprints.
+ - New public function chromaprint_dealloc that should be used for
+ releasing all memory allocated in Chromaprint functions.
+ - Extended fpcollect to allow processing files with MBIDs.
+
+Version 0.1 -- October 30, 2010
+===============================
+
+ - Initial release
+
diff --git a/3rdparty/chromaprint/README.txt b/3rdparty/chromaprint/README.txt
new file mode 100644
index 000000000..aeac70c15
--- /dev/null
+++ b/3rdparty/chromaprint/README.txt
@@ -0,0 +1,96 @@
+Chromaprint
+===========
+
+Dependencies
+------------
+
+The library itself only depends on a FFT library, which at the moment can
+be either FFmpeg [1] (at least r22291, 0.6 is fine), FFTW3 [2] or if you are
+on iOS or OS X, you can use the Accelerate/vDSP framework. See the next
+section for details.
+
+The tools included in the package require FFmpeg (can be older), TagLib [3]
+and Boost Filesystem [4].
+
+In order to build the test suite, you will need the Google Test library [5].
+
+[1] http://www.ffmpeg.org/
+[2] http://www.fftw.org/
+[3] http://developer.kde.org/~wheeler/taglib.html
+[4] http://www.boost.org/
+[5] http://code.google.com/p/googletest/
+
+Installing
+----------
+
+The most common way to build Chromaprint is like this:
+
+$ cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=ON .
+$ make
+$ sudo make install
+
+This will build Chromaprint as a shared library and also include the fpcalc
+utility (which is used by MusicBrainz Picard, for example).
+
+See below for other options.
+
+FFT Library
+-----------
+
+Chromaprint can use three FFT libraries, FFmpeg, FFTW3 and vDSP. FFmpeg is
+preffered, as it's a little faster for our purposes and it's LGPL-licensed,
+so it doesn't impact the license of Chromaprint. The FFT interface was added
+only recently though, so it might not be available in Linux distributions yet.
+FFTW3 can be used in this case, but this library is released under the GPL
+license, which makes also the resulting Chromaprint binary GPL licensed.
+
+If you run simple `cmake .`, it will try to find both FFmpeg and FFTW3 and
+select the first one it finds. If you have new FFmpeg installed in a separate
+location, you can let CMake know using the `FFMPEG_ROOT` option:
+
+$ cmake -DFFMPEG_ROOT=/path/to/local/ffmpeg/install .
+
+If you have new FFmpeg installed, but for some reason prefer to use FFTW3, you
+can use the `WITH_FFTW3` option:
+
+$ cmake -DWITH_FFTW3=ON .
+
+There is also a `WITH_AVFFT` option, but the script will select the FFmpeg FFT
+automatically if it's available, so it shouldn't be necessary to use it.
+
+If you are on Mac, you can use the standard Accelerate framework with the vDSP
+library. This requires you to install no external libraries. It will use
+vDSP by default on OS X (but there still is a `WITH_VDSP` option).
+
+Unit Tests
+----------
+
+The test suite can be built and run using the following commands:
+
+$ cmake -DBUILD_TESTS=ON .
+$ make check
+
+Related Projects
+----------------
+
+ * pyacoustid - https://github.com/sampsyo/pyacoustid
+ * gst-chromaprint - https://github.com/lalinsky/gst-chromaprint
+
+Standing on the Shoulder of Giants
+----------------------------------
+
+I've learned a lot while working on this project, which would not be possible
+without having information from past research. I've read many papers, but the
+concrete ideas implemented in this library are based on the following papers:
+
+ * Yan Ke, Derek Hoiem, Rahul Sukthankar. Computer Vision for Music
+ Identification, Proceedings of Computer Vision and Pattern Recognition,
+ 2005. http://www.cs.cmu.edu/~yke/musicretrieval/
+
+ * Frank Kurth, Meinard Müller. Efficient Index-Based Audio Matching, 2008.
+ http://dx.doi.org/10.1109/TASL.2007.911552
+
+ * Dalwon Jang, Chang D. Yoo, Sunil Lee, Sungwoong Kim, Ton Kalker.
+ Pairwise Boosted Audio Fingerprint, 2009.
+ http://dx.doi.org/10.1109/TIFS.2009.2034452
+
diff --git a/3rdparty/chromaprint/cmake/modules/FindFFTW3.cmake b/3rdparty/chromaprint/cmake/modules/FindFFTW3.cmake
new file mode 100644
index 000000000..fb5cef88d
--- /dev/null
+++ b/3rdparty/chromaprint/cmake/modules/FindFFTW3.cmake
@@ -0,0 +1,133 @@
+#
+# Try to find FFTW3 library
+# (see www.fftw.org)
+# Once run this will define:
+#
+# FFTW3_FOUND
+# FFTW3_INCLUDE_DIR
+# FFTW3_LIBRARIES
+# FFTW3_LINK_DIRECTORIES
+#
+# You may set one of these options before including this file:
+# FFTW3_USE_SSE2
+#
+# TODO: _F_ versions.
+#
+# Jan Woetzel 05/2004
+# www.mip.informatik.uni-kiel.de
+# --------------------------------
+
+ FIND_PATH(FFTW3_INCLUDE_DIR fftw3.h
+ ${FFTW3_DIR}/include
+ ${FFTW3_HOME}/include
+ ${FFTW3_DIR}
+ ${FFTW3_HOME}
+ $ENV{FFTW3_DIR}/include
+ $ENV{FFTW3_HOME}/include
+ $ENV{FFTW3_DIR}
+ $ENV{FFTW3_HOME}
+ /usr/include
+ /usr/local/include
+ $ENV{SOURCE_DIR}/fftw3
+ $ENV{SOURCE_DIR}/fftw3/include
+ $ENV{SOURCE_DIR}/fftw
+ $ENV{SOURCE_DIR}/fftw/include
+ )
+#MESSAGE("DBG FFTW3_INCLUDE_DIR=${FFTW3_INCLUDE_DIR}")
+
+
+SET(FFTW3_POSSIBLE_LIBRARY_PATH
+ ${FFTW3_DIR}/lib
+ ${FFTW3_HOME}/lib
+ ${FFTW3_DIR}
+ ${FFTW3_HOME}
+ $ENV{FFTW3_DIR}/lib
+ $ENV{FFTW3_HOME}/lib
+ $ENV{FFTW3_DIR}
+ $ENV{FFTW3_HOME}
+ /usr/lib
+ /usr/local/lib
+ $ENV{SOURCE_DIR}/fftw3
+ $ENV{SOURCE_DIR}/fftw3/lib
+ $ENV{SOURCE_DIR}/fftw
+ $ENV{SOURCE_DIR}/fftw/lib
+)
+
+
+# the lib prefix is containe din filename onf W32, unfortuantely. JW
+# teh "general" lib:
+FIND_LIBRARY(FFTW3_FFTW_LIBRARY
+ NAMES fftw3 libfftw libfftw3 libfftw3-3
+ PATHS
+ ${FFTW3_POSSIBLE_LIBRARY_PATH}
+ )
+#MESSAGE("DBG FFTW3_FFTW_LIBRARY=${FFTW3_FFTW_LIBRARY}")
+
+FIND_LIBRARY(FFTW3_FFTWF_LIBRARY
+ NAMES fftwf3 fftwf libfftwf libfftwf3 libfftw3f-3
+ PATHS
+ ${FFTW3_POSSIBLE_LIBRARY_PATH}
+ )
+#MESSAGE("DBG FFTW3_FFTWF_LIBRARY=${FFTW3_FFTWF_LIBRARY}")
+
+FIND_LIBRARY(FFTW3_FFTWL_LIBRARY
+ NAMES fftwl3 fftwl libfftwl libfftwl3 libfftw3l-3
+ PATHS
+ ${FFTW3_POSSIBLE_LIBRARY_PATH}
+ )
+#MESSAGE("DBG FFTW3_FFTWF_LIBRARY=${FFTW3_FFTWL_LIBRARY}")
+
+
+FIND_LIBRARY(FFTW3_FFTW_SSE2_LIBRARY
+ NAMES fftw_sse2 fftw3_sse2 libfftw_sse2 libfftw3_sse2
+ PATHS
+ ${FFTW3_POSSIBLE_LIBRARY_PATH}
+ )
+#MESSAGE("DBG FFTW3_FFTW_SSE2_LIBRARY=${FFTW3_FFTW_SSE2_LIBRARY}")
+
+FIND_LIBRARY(FFTW3_FFTWF_SSE_LIBRARY
+ NAMES fftwf_sse fftwf3_sse libfftwf_sse libfftwf3_sse
+ PATHS
+ ${FFTW3_POSSIBLE_LIBRARY_PATH}
+ )
+#MESSAGE("DBG FFTW3_FFTWF_SSE_LIBRARY=${FFTW3_FFTWF_SSE_LIBRARY}")
+
+
+# --------------------------------
+# select one of the above
+# default:
+IF (FFTW3_FFTW_LIBRARY)
+ SET(FFTW3_LIBRARIES ${FFTW3_FFTW_LIBRARY})
+ENDIF (FFTW3_FFTW_LIBRARY)
+# specialized:
+IF (FFTW3_USE_SSE2 AND FFTW3_FFTW_SSE2_LIBRARY)
+ SET(FFTW3_LIBRARIES ${FFTW3_FFTW_SSE2_LIBRARY})
+ENDIF (FFTW3_USE_SSE2 AND FFTW3_FFTW_SSE2_LIBRARY)
+
+# --------------------------------
+
+IF(FFTW3_LIBRARIES)
+ IF (FFTW3_INCLUDE_DIR)
+
+ # OK, found all we need
+ SET(FFTW3_FOUND TRUE)
+ GET_FILENAME_COMPONENT(FFTW3_LINK_DIRECTORIES ${FFTW3_LIBRARIES} PATH)
+
+ ELSE (FFTW3_INCLUDE_DIR)
+ MESSAGE("FFTW3 include dir not found. Set FFTW3_DIR to find it.")
+ ENDIF(FFTW3_INCLUDE_DIR)
+ELSE(FFTW3_LIBRARIES)
+ MESSAGE("FFTW3 lib not found. Set FFTW3_DIR to find it.")
+ENDIF(FFTW3_LIBRARIES)
+
+
+MARK_AS_ADVANCED(
+ FFTW3_INCLUDE_DIR
+ FFTW3_LIBRARIES
+ FFTW3_FFTW_LIBRARY
+ FFTW3_FFTW_SSE2_LIBRARY
+ FFTW3_FFTWF_LIBRARY
+ FFTW3_FFTWF_SSE_LIBRARY
+ FFTW3_FFTWL_LIBRARY
+ FFTW3_LINK_DIRECTORIES
+)
diff --git a/3rdparty/chromaprint/cmake/modules/FindFFmpeg.cmake b/3rdparty/chromaprint/cmake/modules/FindFFmpeg.cmake
new file mode 100644
index 000000000..d29ec802b
--- /dev/null
+++ b/3rdparty/chromaprint/cmake/modules/FindFFmpeg.cmake
@@ -0,0 +1,128 @@
+# Locate ffmpeg
+# This module defines
+# FFMPEG_LIBRARIES
+# FFMPEG_FOUND, if false, do not try to link to ffmpeg
+# FFMPEG_INCLUDE_DIR, where to find the headers
+#
+# $FFMPEG_DIR is an environment variable that would
+# correspond to the ./configure --prefix=$FFMPEG_DIR
+#
+# Created by Robert Osfield.
+# Modified by Lukas Lalinsky.
+
+
+#In ffmpeg code, old version use "#include " and newer use "#include "
+#In OSG ffmpeg plugin, we use "#include " for compatibility with old version of ffmpeg
+
+#We have to search the path which contain the header.h (usefull for old version)
+#and search the path which contain the libname/header.h (usefull for new version)
+
+#Then we need to include ${FFMPEG_libname_INCLUDE_DIRS} (in old version case, use by ffmpeg header and osg plugin code)
+# (in new version case, use by ffmpeg header)
+#and ${FFMPEG_libname_INCLUDE_DIRS/libname} (in new version case, use by osg plugin code)
+
+# Macro to find header and lib directories
+# example: FFMPEG_FIND(AVFORMAT avformat avformat.h)
+MACRO(FFMPEG_FIND varname shortname headername)
+
+ FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
+ PATHS
+ ${FFMPEG_ROOT}/include
+ $ENV{FFMPEG_DIR}/include
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/include
+ /usr/include/
+ /sw/include # Fink
+ /opt/local/include # DarwinPorts
+ /opt/csw/include # Blastwave
+ /opt/include
+ /usr/freeware/include
+ NO_DEFAULT_PATH
+ PATH_SUFFIXES ffmpeg
+ DOC "Location of FFMPEG Headers"
+ )
+ FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
+ PATH_SUFFIXES ffmpeg
+ DOC "Location of FFMPEG Headers"
+ )
+
+ FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
+ NAMES ${shortname}
+ PATHS
+ ${FFMPEG_ROOT}/lib
+ $ENV{FFMPEG_DIR}/lib
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/lib
+ /usr/local/lib64
+ /usr/lib
+ /usr/lib64
+ /sw/lib
+ /opt/local/lib
+ /opt/csw/lib
+ /opt/lib
+ /usr/freeware/lib64
+ NO_DEFAULT_PATH
+ DOC "Location of FFMPEG Libraries"
+ )
+ FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
+ NAMES ${shortname}
+ DOC "Location of FFMPEG Libraries"
+ )
+
+ IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
+ SET(FFMPEG_${varname}_FOUND 1)
+ ENDIF(FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
+
+ENDMACRO(FFMPEG_FIND)
+
+SET(FFMPEG_ROOT "$ENV{FFMPEG_DIR}" CACHE PATH "Location of FFMPEG")
+
+# find stdint.h
+FIND_PATH(FFMPEG_STDINT_INCLUDE_DIR stdint.h
+ PATHS
+ ${FFMPEG_ROOT}/include
+ $ENV{FFMPEG_DIR}/include
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/include
+ /usr/include
+ /sw/include # Fink
+ /opt/local/include # DarwinPorts
+ /opt/csw/include # Blastwave
+ /opt/include
+ /usr/freeware/include
+ PATH_SUFFIXES ffmpeg
+ DOC "Location of FFMPEG stdint.h Header"
+)
+
+FFMPEG_FIND(LIBAVFORMAT avformat avformat.h)
+FFMPEG_FIND(LIBAVDEVICE avdevice avdevice.h)
+FFMPEG_FIND(LIBAVCODEC avcodec avcodec.h)
+FFMPEG_FIND(LIBAVCODEC_FFT avcodec avfft.h)
+FFMPEG_FIND(LIBAVUTIL avutil avutil.h)
+FFMPEG_FIND(LIBSWSCALE swscale swscale.h) # not sure about the header to look for here.
+
+SET(FFMPEG_FOUND "NO")
+# Note we don't check FFMPEG_LIBSWSCALE_FOUND here, it's optional.
+IF (FFMPEG_LIBAVFORMAT_FOUND AND FFMPEG_LIBAVDEVICE_FOUND AND FFMPEG_LIBAVCODEC_FOUND AND FFMPEG_LIBAVUTIL_FOUND AND FFMPEG_STDINT_INCLUDE_DIR)
+
+ SET(FFMPEG_FOUND "YES")
+
+ SET(FFMPEG_INCLUDE_DIRS ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS})
+
+ SET(FFMPEG_LIBRARY_DIRS ${FFMPEG_LIBAVFORMAT_LIBRARY_DIRS})
+
+ # Note we don't add FFMPEG_LIBSWSCALE_LIBRARIES here, it will be added if found later.
+ SET(FFMPEG_LIBRARIES
+ ${FFMPEG_LIBAVFORMAT_LIBRARIES}
+ ${FFMPEG_LIBAVDEVICE_LIBRARIES}
+ ${FFMPEG_LIBAVCODEC_LIBRARIES}
+ ${FFMPEG_LIBAVUTIL_LIBRARIES})
+
+ELSE ()
+
+# MESSAGE(STATUS "Could not find FFMPEG")
+
+ENDIF()
diff --git a/3rdparty/chromaprint/cmake/modules/FindGTest.cmake b/3rdparty/chromaprint/cmake/modules/FindGTest.cmake
new file mode 100644
index 000000000..367ffae66
--- /dev/null
+++ b/3rdparty/chromaprint/cmake/modules/FindGTest.cmake
@@ -0,0 +1,175 @@
+# Locate the Google C++ Testing Framework.
+#
+# Defines the following variables:
+#
+# GTEST_FOUND - Found the Google Testing framework
+# GTEST_INCLUDE_DIRS - Include directories
+#
+# Also defines the library variables below as normal
+# variables. These contain debug/optimized keywords when
+# a debugging library is found.
+#
+# GTEST_BOTH_LIBRARIES - Both libgtest & libgtest-main
+# GTEST_LIBRARIES - libgtest
+# GTEST_MAIN_LIBRARIES - libgtest-main
+#
+# Accepts the following variables as input:
+#
+# GTEST_ROOT - (as CMake or env. variable)
+# The root directory of the gtest install prefix
+#
+# GTEST_MSVC_SEARCH - If on MSVC, enables searching the build tree of
+# GTest if set to MD or MT (defaults: MD)
+#
+#-----------------------
+# Example Usage:
+#
+# enable_testing(true)
+# find_package(GTest REQUIRED)
+# include_directories(${GTEST_INCLUDE_DIRS})
+#
+# add_executable(foo foo.cc)
+# target_link_libraries(foo ${GTEST_BOTH_LIBRARIES})
+#
+# add_test(AllTestsInFoo foo)
+#
+#-----------------------
+#
+# If you would like each Google test to show up in CTest as
+# a test you may use the following macro. NOTE: It WILL slow
+# down your tests, so be warned.
+#
+# GTEST_ADD_TESTS(executable extra_args ARGN)
+# executable = The path to the test executable
+# extra_args = Pass a list of extra arguments to be passed to
+# executable enclosed in quotes (or "" for none)
+# ARGN = A list of source files to search for tests & test
+# fixtures.
+#
+# Example:
+# set(FooTestArgs --foo 1 --bar 2)
+# add_executable(FooTest FooUnitTest.cc)
+# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" FooUnitTest.cc)
+
+#=============================================================================
+# Copyright 2009 Kitware, Inc.
+# Copyright 2009 Philip Lowman
+# Copyright 2009 Daniel Blezek
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+# nor the names of their contributors may be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#=============================================================================
+#
+# Thanks to Daniel Blezek for the GTEST_ADD_TESTS code
+
+function(GTEST_ADD_TESTS executable extra_args)
+ if(NOT ARGN)
+ message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS")
+ endif()
+ foreach(source ${ARGN})
+ file(READ "${source}" contents)
+ string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
+ foreach(hit ${found_tests})
+ string(REGEX REPLACE ".*\\(([A-Za-z_0-9]+)[, ]*([A-Za-z_0-9]+)\\).*" "\\1.\\2" test_name ${hit})
+ add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args})
+ endforeach()
+ endforeach()
+endfunction()
+
+function(_gtest_append_debugs _endvar _library)
+ if(${_library} AND ${_library}_DEBUG)
+ set(_output optimized ${${_library}} debug ${${_library}_DEBUG})
+ else()
+ set(_output ${${_library}})
+ endif()
+ set(${_endvar} ${_output} PARENT_SCOPE)
+endfunction()
+
+function(_gtest_find_library _name)
+ find_library(${_name}
+ NAMES ${ARGN}
+ HINTS
+ $ENV{GTEST_ROOT}
+ ${GTEST_ROOT}
+ PATH_SUFFIXES ${_gtest_libpath_suffixes}
+ )
+ mark_as_advanced(${_name})
+endfunction()
+
+#
+
+if(NOT DEFINED GTEST_MSVC_SEARCH)
+ set(GTEST_MSVC_SEARCH MD)
+endif()
+
+set(_gtest_libpath_suffixes lib)
+if(MSVC)
+ if(GTEST_MSVC_SEARCH STREQUAL "MD")
+ list(APPEND _gtest_libpath_suffixes
+ msvc/gtest-md/Debug
+ msvc/gtest-md/Release)
+ elseif(GTEST_MSVC_SEARCH STREQUAL "MT")
+ list(APPEND _gtest_libpath_suffixes
+ msvc/gtest/Debug
+ msvc/gtest/Release)
+ endif()
+endif()
+
+
+find_path(GTEST_INCLUDE_DIR gtest/gtest.h
+ HINTS
+ $ENV{GTEST_ROOT}/include
+ ${GTEST_ROOT}/include
+)
+mark_as_advanced(GTEST_INCLUDE_DIR)
+
+if(MSVC AND GTEST_MSVC_SEARCH STREQUAL "MD")
+ # The provided /MD project files for Google Test add -md suffixes to the
+ # library names.
+ _gtest_find_library(GTEST_LIBRARY gtest-md gtest)
+ _gtest_find_library(GTEST_LIBRARY_DEBUG gtest-mdd gtestd)
+ _gtest_find_library(GTEST_MAIN_LIBRARY gtest_main-md gtest_main)
+ _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_main-mdd gtest_maind)
+else()
+ _gtest_find_library(GTEST_LIBRARY gtest)
+ _gtest_find_library(GTEST_LIBRARY_DEBUG gtestd)
+ _gtest_find_library(GTEST_MAIN_LIBRARY gtest_main)
+ _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind)
+endif()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTest DEFAULT_MSG GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY)
+
+if(GTEST_FOUND)
+ set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
+ _gtest_append_debugs(GTEST_LIBRARIES GTEST_LIBRARY)
+ _gtest_append_debugs(GTEST_MAIN_LIBRARIES GTEST_MAIN_LIBRARY)
+ set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
+endif()
+
diff --git a/3rdparty/chromaprint/cmake/modules/FindTaglib.cmake b/3rdparty/chromaprint/cmake/modules/FindTaglib.cmake
new file mode 100644
index 000000000..76b83ac55
--- /dev/null
+++ b/3rdparty/chromaprint/cmake/modules/FindTaglib.cmake
@@ -0,0 +1,135 @@
+# - Try to find the Taglib library
+# Once done this will define
+#
+# TAGLIB_FOUND - system has the taglib library
+# TAGLIB_CFLAGS - the taglib cflags
+# TAGLIB_LIBRARIES - The libraries needed to use taglib
+
+# Copyright (c) 2006, Laurent Montel,
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+if(NOT TAGLIB_MIN_VERSION)
+ set(TAGLIB_MIN_VERSION "1.6")
+endif(NOT TAGLIB_MIN_VERSION)
+
+if(NOT WIN32)
+ find_program(TAGLIBCONFIG_EXECUTABLE NAMES taglib-config PATHS
+ ${BIN_INSTALL_DIR}
+ )
+endif(NOT WIN32)
+
+#reset vars
+set(TAGLIB_LIBRARIES)
+set(TAGLIB_CFLAGS)
+
+# if taglib-config has been found
+if(TAGLIBCONFIG_EXECUTABLE)
+
+ exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --version RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_VERSION)
+
+ if(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
+ message(STATUS "TagLib version too old: version searched :${TAGLIB_MIN_VERSION}, found ${TAGLIB_VERSION}")
+ set(TAGLIB_FOUND FALSE)
+ else(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
+
+ exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_LIBRARIES)
+
+ exec_program(${TAGLIBCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE TAGLIB_CFLAGS)
+
+ if(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
+ set(TAGLIB_FOUND TRUE)
+ endif(TAGLIB_LIBRARIES AND TAGLIB_CFLAGS)
+ string(REGEX REPLACE " *-I" ";" TAGLIB_INCLUDES "${TAGLIB_CFLAGS}")
+ endif(TAGLIB_VERSION STRLESS "${TAGLIB_MIN_VERSION}")
+ mark_as_advanced(TAGLIB_CFLAGS TAGLIB_LIBRARIES TAGLIB_INCLUDES)
+
+else(TAGLIBCONFIG_EXECUTABLE)
+
+ find_path(TAGLIB_INCLUDES
+ NAMES
+ tag.h
+ PATH_SUFFIXES taglib
+ PATHS
+ ${KDE4_INCLUDE_DIR}
+ ${INCLUDE_INSTALL_DIR}
+ )
+
+ IF(NOT WIN32)
+ # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX
+
+ FIND_LIBRARY(TAGLIB_LIBRARIES tag PATHS ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR})
+
+ ELSE(NOT WIN32)
+
+ # 1. get all possible libnames
+ SET(args PATHS ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR})
+ SET(newargs "")
+ SET(libnames_release "")
+ SET(libnames_debug "")
+
+ LIST(LENGTH args listCount)
+
+ # just one name
+ LIST(APPEND libnames_release "tag")
+ LIST(APPEND libnames_debug "tagd")
+
+ SET(newargs ${args})
+
+ # search the release lib
+ FIND_LIBRARY(TAGLIB_LIBRARIES_RELEASE
+ NAMES ${libnames_release}
+ ${newargs}
+ )
+
+ # search the debug lib
+ FIND_LIBRARY(TAGLIB_LIBRARIES_DEBUG
+ NAMES ${libnames_debug}
+ ${newargs}
+ )
+
+ IF(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)
+
+ # both libs found
+ SET(TAGLIB_LIBRARIES optimized ${TAGLIB_LIBRARIES_RELEASE}
+ debug ${TAGLIB_LIBRARIES_DEBUG})
+
+ ELSE(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)
+
+ IF(TAGLIB_LIBRARIES_RELEASE)
+
+ # only release found
+ SET(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_RELEASE})
+
+ ELSE(TAGLIB_LIBRARIES_RELEASE)
+
+ # only debug (or nothing) found
+ SET(TAGLIB_LIBRARIES ${TAGLIB_LIBRARIES_DEBUG})
+
+ ENDIF(TAGLIB_LIBRARIES_RELEASE)
+
+ ENDIF(TAGLIB_LIBRARIES_RELEASE AND TAGLIB_LIBRARIES_DEBUG)
+
+ MARK_AS_ADVANCED(TAGLIB_LIBRARIES_RELEASE)
+ MARK_AS_ADVANCED(TAGLIB_LIBRARIES_DEBUG)
+
+ ENDIF(NOT WIN32)
+
+ INCLUDE(FindPackageMessage)
+ INCLUDE(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(Taglib DEFAULT_MSG TAGLIB_INCLUDES TAGLIB_LIBRARIES)
+
+endif(TAGLIBCONFIG_EXECUTABLE)
+
+
+if(TAGLIB_FOUND)
+ if(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
+ message(STATUS "Taglib found: ${TAGLIB_LIBRARIES}")
+ endif(NOT Taglib_FIND_QUIETLY AND TAGLIBCONFIG_EXECUTABLE)
+else(TAGLIB_FOUND)
+ if(Taglib_FIND_REQUIRED)
+ message(FATAL_ERROR "Could not find Taglib")
+ endif(Taglib_FIND_REQUIRED)
+endif(TAGLIB_FOUND)
+
diff --git a/3rdparty/chromaprint/config.h.in b/3rdparty/chromaprint/config.h.in
new file mode 100644
index 000000000..f87db71ad
--- /dev/null
+++ b/3rdparty/chromaprint/config.h.in
@@ -0,0 +1,7 @@
+#cmakedefine HAVE_ROUND 1
+#cmakedefine HAVE_LRINTF 1
+#cmakedefine WITH_AVFFT 1
+#cmakedefine WITH_FFTW3 1
+#cmakedefine WITH_VDSP 1
+#cmakedefine TESTS_DIR "@TESTS_DIR@"
+
diff --git a/3rdparty/chromaprint/examples/CMakeLists.txt b/3rdparty/chromaprint/examples/CMakeLists.txt
new file mode 100644
index 000000000..40bf00395
--- /dev/null
+++ b/3rdparty/chromaprint/examples/CMakeLists.txt
@@ -0,0 +1,39 @@
+set(EXTRA_LIBS)
+if(APPLE)
+ set(EXTRA_LIBS ${EXTRA_LIBS} -lz)
+endif()
+if(UNIX)
+ set(EXTRA_LIBS ${EXTRA_LIBS} -lpthread)
+endif()
+
+set(CMAKE_REQUIRED_LIBRARIES
+ ${FFMPEG_LIBAVFORMAT_LIBRARIES}
+ ${FFMPEG_LIBAVCODEC_LIBRARIES}
+ ${FFMPEG_LIBAVUTIL_LIBRARIES}
+ ${EXTRA_LIBS})
+check_function_exists(av_audio_convert HAVE_AV_AUDIO_CONVERT)
+
+if(HAVE_AV_AUDIO_CONVERT)
+ add_definitions(-DHAVE_AV_AUDIO_CONVERT)
+endif()
+
+include_directories(
+ ${CMAKE_CURRENT_SOURCE_DIR}/../src
+ ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
+ ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
+ ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
+)
+
+add_executable(fpcalc fpcalc.c)
+
+
+target_link_libraries(fpcalc chromaprint
+ ${FFMPEG_LIBAVFORMAT_LIBRARIES}
+ ${FFMPEG_LIBAVCODEC_LIBRARIES}
+ ${FFMPEG_LIBAVUTIL_LIBRARIES}
+ ${EXTRA_LIBS})
+
+install(TARGETS fpcalc
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+)
+
diff --git a/3rdparty/chromaprint/examples/ffmpeg/audioconvert.h b/3rdparty/chromaprint/examples/ffmpeg/audioconvert.h
new file mode 100644
index 000000000..2b28e2eac
--- /dev/null
+++ b/3rdparty/chromaprint/examples/ffmpeg/audioconvert.h
@@ -0,0 +1,118 @@
+/*
+ * audio conversion
+ * Copyright (c) 2006 Michael Niedermayer
+ * Copyright (c) 2008 Peter Ross
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_AUDIOCONVERT_H
+#define AVCODEC_AUDIOCONVERT_H
+
+/**
+ * @file
+ * Audio format conversion routines
+ */
+
+
+#include "libavcodec/avcodec.h"
+#include "samplefmt.h"
+
+#if FF_API_OLD_SAMPLE_FMT
+/**
+ * @deprecated Use av_get_sample_fmt_string() instead.
+ */
+attribute_deprecated
+void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt);
+
+/**
+ * @deprecated Use av_get_sample_fmt_name() instead.
+ */
+attribute_deprecated
+const char *avcodec_get_sample_fmt_name(int sample_fmt);
+
+/**
+ * @deprecated Use av_get_sample_fmt() instead.
+ */
+attribute_deprecated
+enum AVSampleFormat avcodec_get_sample_fmt(const char* name);
+#endif
+
+#if FF_API_OLD_AUDIOCONVERT
+/**
+ * @deprecated Use av_get_channel_layout() instead.
+ */
+attribute_deprecated
+int64_t avcodec_get_channel_layout(const char *name);
+
+/**
+ * @deprecated Use av_get_channel_layout_string() instead.
+ */
+attribute_deprecated
+void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
+
+/**
+ * @deprecated Use av_get_channel_layout_nb_channels() instead.
+ */
+attribute_deprecated
+int avcodec_channel_layout_num_channels(int64_t channel_layout);
+#endif
+
+/**
+ * Guess the channel layout
+ * @param nb_channels
+ * @param codec_id Codec identifier, or CODEC_ID_NONE if unknown
+ * @param fmt_name Format name, or NULL if unknown
+ * @return Channel layout mask
+ */
+uint64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
+
+struct AVAudioConvert;
+typedef struct AVAudioConvert AVAudioConvert;
+
+/**
+ * Create an audio sample format converter context
+ * @param out_fmt Output sample format
+ * @param out_channels Number of output channels
+ * @param in_fmt Input sample format
+ * @param in_channels Number of input channels
+ * @param[in] matrix Channel mixing matrix (of dimension in_channel*out_channels). Set to NULL to ignore.
+ * @param flags See AV_CPU_FLAG_xx
+ * @return NULL on error
+ */
+AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
+ enum AVSampleFormat in_fmt, int in_channels,
+ const float *matrix, int flags);
+
+/**
+ * Free audio sample format converter context
+ */
+void av_audio_convert_free(AVAudioConvert *ctx);
+
+/**
+ * Convert between audio sample formats
+ * @param[in] out array of output buffers for each channel. set to NULL to ignore processing of the given channel.
+ * @param[in] out_stride distance between consecutive output samples (measured in bytes)
+ * @param[in] in array of input buffers for each channel
+ * @param[in] in_stride distance between consecutive input samples (measured in bytes)
+ * @param len length of audio frame size (measured in samples)
+ */
+int av_audio_convert(AVAudioConvert *ctx,
+ void * const out[6], const int out_stride[6],
+ const void * const in[6], const int in_stride[6], int len);
+
+#endif /* AVCODEC_AUDIOCONVERT_H */
diff --git a/3rdparty/chromaprint/examples/ffmpeg/samplefmt.h b/3rdparty/chromaprint/examples/ffmpeg/samplefmt.h
new file mode 100644
index 000000000..1d3748130
--- /dev/null
+++ b/3rdparty/chromaprint/examples/ffmpeg/samplefmt.h
@@ -0,0 +1,156 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_SAMPLEFMT_H
+#define AVUTIL_SAMPLEFMT_H
+
+#include "libavutil/avutil.h"
+
+/**
+ * all in native-endian format
+ */
+enum AVSampleFormat {
+ AV_SAMPLE_FMT_NONE = -1,
+ AV_SAMPLE_FMT_U8, ///< unsigned 8 bits
+ AV_SAMPLE_FMT_S16, ///< signed 16 bits
+ AV_SAMPLE_FMT_S32, ///< signed 32 bits
+ AV_SAMPLE_FMT_FLT, ///< float
+ AV_SAMPLE_FMT_DBL, ///< double
+
+ AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar
+ AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar
+ AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar
+ AV_SAMPLE_FMT_FLTP, ///< float, planar
+ AV_SAMPLE_FMT_DBLP, ///< double, planar
+
+ AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically
+};
+
+/**
+ * Return the name of sample_fmt, or NULL if sample_fmt is not
+ * recognized.
+ */
+const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
+
+/**
+ * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
+ * on error.
+ */
+enum AVSampleFormat av_get_sample_fmt(const char *name);
+
+/**
+ * Return the planar<->packed alternative form of the given sample format, or
+ * AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the
+ * requested planar/packed format, the format returned is the same as the
+ * input.
+ */
+enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar);
+
+/**
+ * Generate a string corresponding to the sample format with
+ * sample_fmt, or a header if sample_fmt is negative.
+ *
+ * @param buf the buffer where to write the string
+ * @param buf_size the size of buf
+ * @param sample_fmt the number of the sample format to print the
+ * corresponding info string, or a negative value to print the
+ * corresponding header.
+ * @return the pointer to the filled buffer or NULL if sample_fmt is
+ * unknown or in case of other errors
+ */
+char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
+
+#if FF_API_GET_BITS_PER_SAMPLE_FMT
+/**
+ * @deprecated Use av_get_bytes_per_sample() instead.
+ */
+attribute_deprecated
+int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
+#endif
+
+/**
+ * Return number of bytes per sample.
+ *
+ * @param sample_fmt the sample format
+ * @return number of bytes per sample or zero if unknown for the given
+ * sample format
+ */
+int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
+
+/**
+ * Check if the sample format is planar.
+ *
+ * @param sample_fmt the sample format to inspect
+ * @return 1 if the sample format is planar, 0 if it is interleaved
+ */
+int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
+
+/**
+ * Get the required buffer size for the given audio parameters.
+ *
+ * @param[out] linesize calculated linesize, may be NULL
+ * @param nb_channels the number of channels
+ * @param nb_samples the number of samples in a single channel
+ * @param sample_fmt the sample format
+ * @return required buffer size, or negative error code on failure
+ */
+int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
+ enum AVSampleFormat sample_fmt, int align);
+
+/**
+ * Fill channel data pointers and linesize for samples with sample
+ * format sample_fmt.
+ *
+ * The pointers array is filled with the pointers to the samples data:
+ * for planar, set the start point of each channel's data within the buffer,
+ * for packed, set the start point of the entire buffer only.
+ *
+ * The linesize array is filled with the aligned size of each channel's data
+ * buffer for planar layout, or the aligned size of the buffer for all channels
+ * for packed layout.
+ *
+ * @param[out] audio_data array to be filled with the pointer for each channel
+ * @param[out] linesize calculated linesize
+ * @param buf the pointer to a buffer containing the samples
+ * @param nb_channels the number of channels
+ * @param nb_samples the number of samples in a single channel
+ * @param sample_fmt the sample format
+ * @param align buffer size alignment (1 = no alignment required)
+ * @return 0 on success or a negative error code on failure
+ */
+int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, uint8_t *buf,
+ int nb_channels, int nb_samples,
+ enum AVSampleFormat sample_fmt, int align);
+
+/**
+ * Allocate a samples buffer for nb_samples samples, and fill data pointers and
+ * linesize accordingly.
+ * The allocated samples buffer can be freed by using av_freep(&audio_data[0])
+ *
+ * @param[out] audio_data array to be filled with the pointer for each channel
+ * @param[out] linesize aligned size for audio buffer(s)
+ * @param nb_channels number of audio channels
+ * @param nb_samples number of samples per channel
+ * @param align buffer size alignment (1 = no alignment required)
+ * @return 0 on success or a negative error code on failure
+ * @see av_samples_fill_arrays()
+ */
+int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
+ int nb_samples, enum AVSampleFormat sample_fmt, int align);
+
+#endif /* AVUTIL_SAMPLEFMT_H */
diff --git a/3rdparty/chromaprint/examples/fpcalc.c b/3rdparty/chromaprint/examples/fpcalc.c
new file mode 100644
index 000000000..e8bf7d5f8
--- /dev/null
+++ b/3rdparty/chromaprint/examples/fpcalc.c
@@ -0,0 +1,303 @@
+#include
+#include
+#include
+#include
+#ifdef HAVE_AV_AUDIO_CONVERT
+#include "ffmpeg/audioconvert.h"
+#include "ffmpeg/samplefmt.h"
+#endif
+#ifdef _WIN32
+#include
+#endif
+
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+#define BUFFER_SIZE (AVCODEC_MAX_AUDIO_FRAME_SIZE * 2)
+
+int decode_audio_file(ChromaprintContext *chromaprint_ctx, int16_t *buffer1, int16_t *buffer2, const char *file_name, int max_length, int *duration)
+{
+ int i, ok = 0, remaining, length, consumed, buffer_size, codec_ctx_opened = 0;
+ AVFormatContext *format_ctx = NULL;
+ AVCodecContext *codec_ctx = NULL;
+ AVCodec *codec = NULL;
+ AVStream *stream = NULL;
+ AVPacket packet, packet_temp;
+#ifdef HAVE_AV_AUDIO_CONVERT
+ AVAudioConvert *convert_ctx = NULL;
+#endif
+ int16_t *buffer;
+
+ if (av_open_input_file(&format_ctx, file_name, NULL, 0, NULL) != 0) {
+ fprintf(stderr, "ERROR: couldn't open the file\n");
+ goto done;
+ }
+
+ if (av_find_stream_info(format_ctx) < 0) {
+ fprintf(stderr, "ERROR: couldn't find stream information in the file\n");
+ goto done;
+ }
+
+ for (i = 0; i < format_ctx->nb_streams; i++) {
+ codec_ctx = format_ctx->streams[i]->codec;
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 64, 0)
+ if (codec_ctx && codec_ctx->codec_type == CODEC_TYPE_AUDIO) {
+#else
+ if (codec_ctx && codec_ctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+#endif
+ stream = format_ctx->streams[i];
+ break;
+ }
+ }
+ if (!stream) {
+ fprintf(stderr, "ERROR: couldn't find any audio stream in the file\n");
+ goto done;
+ }
+
+ codec = avcodec_find_decoder(codec_ctx->codec_id);
+ if (!codec) {
+ fprintf(stderr, "ERROR: unknown codec\n");
+ goto done;
+ }
+
+ if (avcodec_open(codec_ctx, codec) < 0) {
+ fprintf(stderr, "ERROR: couldn't open the codec\n");
+ goto done;
+ }
+ codec_ctx_opened = 1;
+
+ if (codec_ctx->channels <= 0) {
+ fprintf(stderr, "ERROR: no channels found in the audio stream\n");
+ goto done;
+ }
+
+ if (codec_ctx->sample_fmt != SAMPLE_FMT_S16) {
+#ifdef HAVE_AV_AUDIO_CONVERT
+ convert_ctx = av_audio_convert_alloc(SAMPLE_FMT_S16, codec_ctx->channels,
+ codec_ctx->sample_fmt, codec_ctx->channels, NULL, 0);
+ if (!convert_ctx) {
+ fprintf(stderr, "ERROR: couldn't create sample format converter\n");
+ goto done;
+ }
+#else
+ fprintf(stderr, "ERROR: unsupported sample format\n");
+ goto done;
+#endif
+ }
+
+ *duration = stream->time_base.num * stream->duration / stream->time_base.den;
+
+ av_init_packet(&packet);
+ av_init_packet(&packet_temp);
+
+ remaining = max_length * codec_ctx->channels * codec_ctx->sample_rate;
+ chromaprint_start(chromaprint_ctx, codec_ctx->sample_rate, codec_ctx->channels);
+
+ while (1) {
+ if (av_read_frame(format_ctx, &packet) < 0) {
+ break;
+ }
+
+ packet_temp.data = packet.data;
+ packet_temp.size = packet.size;
+
+ while (packet_temp.size > 0) {
+ buffer_size = BUFFER_SIZE;
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52, 25, 0)
+ consumed = avcodec_decode_audio2(codec_ctx,
+ buffer1, &buffer_size, packet_temp.data, packet_temp.size);
+#else
+ consumed = avcodec_decode_audio3(codec_ctx,
+ buffer1, &buffer_size, &packet_temp);
+#endif
+
+ if (consumed < 0) {
+ break;
+ }
+
+ packet_temp.data += consumed;
+ packet_temp.size -= consumed;
+
+ if (buffer_size <= 0) {
+ if (buffer_size < 0) {
+ fprintf(stderr, "WARNING: size returned from avcodec_decode_audioX is too small\n");
+ }
+ continue;
+ }
+ if (buffer_size > BUFFER_SIZE) {
+ fprintf(stderr, "WARNING: size returned from avcodec_decode_audioX is too large\n");
+ continue;
+ }
+
+#ifdef HAVE_AV_AUDIO_CONVERT
+ if (convert_ctx) {
+ const void *ibuf[6] = { buffer1 };
+ void *obuf[6] = { buffer2 };
+ int istride[6] = { av_get_bits_per_sample_format(codec_ctx->sample_fmt) / 8 };
+ int ostride[6] = { 2 };
+ int len = buffer_size / istride[0];
+ if (av_audio_convert(convert_ctx, obuf, ostride, ibuf, istride, len) < 0) {
+ break;
+ }
+ buffer = buffer2;
+ buffer_size = len * ostride[0];
+ }
+ else {
+ buffer = buffer1;
+ }
+#else
+ buffer = buffer1;
+#endif
+
+ length = MIN(remaining, buffer_size / 2);
+ if (!chromaprint_feed(chromaprint_ctx, buffer, length)) {
+ fprintf(stderr, "ERROR: fingerprint calculation failed\n");
+ goto done;
+ }
+
+ if (max_length) {
+ remaining -= length;
+ if (remaining <= 0) {
+ goto finish;
+ }
+ }
+ }
+
+ if (packet.data) {
+ av_free_packet(&packet);
+ }
+ }
+
+finish:
+ if (!chromaprint_finish(chromaprint_ctx)) {
+ fprintf(stderr, "ERROR: fingerprint calculation failed\n");
+ goto done;
+ }
+
+ ok = 1;
+
+done:
+ if (codec_ctx_opened) {
+ avcodec_close(codec_ctx);
+ }
+ if (format_ctx) {
+ av_close_input_file(format_ctx);
+ }
+#ifdef HAVE_AV_AUDIO_CONVERT
+ if (convert_ctx) {
+ av_audio_convert_free(convert_ctx);
+ }
+#endif
+ return ok;
+}
+
+int fpcalc_main(int argc, char **argv)
+{
+ int i, j, max_length = 120, num_file_names = 0, raw = 0, raw_fingerprint_size, duration;
+ int16_t *buffer1, *buffer2;
+ int32_t *raw_fingerprint;
+ char *file_name, *fingerprint, **file_names;
+ ChromaprintContext *chromaprint_ctx;
+
+ file_names = malloc(argc * sizeof(char *));
+ for (i = 1; i < argc; i++) {
+ char *arg = argv[i];
+ if (!strcmp(arg, "-length") && i + 1 < argc) {
+ max_length = atoi(argv[++i]);
+ }
+ else if (!strcmp(arg, "-raw")) {
+ raw = 1;
+ }
+ else {
+ file_names[num_file_names++] = argv[i];
+ }
+ }
+
+ if (!num_file_names) {
+ printf("usage: %s [OPTIONS] FILE...\n\n", argv[0]);
+ printf("Options:\n");
+ printf(" -length SECS length of the audio data used for fingerprint calculation (default 120)\n");
+ printf(" -raw output the raw uncompressed fingerprint\n");
+ return 2;
+ }
+
+ av_register_all();
+ av_log_set_level(AV_LOG_ERROR);
+
+ buffer1 = av_malloc(BUFFER_SIZE + 16);
+ buffer2 = av_malloc(BUFFER_SIZE + 16);
+ chromaprint_ctx = chromaprint_new(CHROMAPRINT_ALGORITHM_DEFAULT);
+
+ for (i = 0; i < num_file_names; i++) {
+ file_name = file_names[i];
+ if (!decode_audio_file(chromaprint_ctx, buffer1, buffer2, file_name, max_length, &duration)) {
+ fprintf(stderr, "ERROR: unable to calculate fingerprint for file %s, skipping\n", file_name);
+ continue;
+ }
+ if (i > 0) {
+ printf("\n");
+ }
+ printf("FILE=%s\n", file_name);
+ printf("DURATION=%d\n", duration);
+ if (raw) {
+ if (!chromaprint_get_raw_fingerprint(chromaprint_ctx, (void **)&raw_fingerprint, &raw_fingerprint_size)) {
+ fprintf(stderr, "ERROR: unable to calculate fingerprint for file %s, skipping\n", file_name);
+ continue;
+ }
+ printf("FINGERPRINT=");
+ for (j = 0; j < raw_fingerprint_size; j++) {
+ printf("%d%s", raw_fingerprint[j], j + 1 < raw_fingerprint_size ? "," : "\n");
+ }
+ chromaprint_dealloc(raw_fingerprint);
+ }
+ else {
+ if (!chromaprint_get_fingerprint(chromaprint_ctx, &fingerprint)) {
+ fprintf(stderr, "ERROR: unable to calculate fingerprint for file %s, skipping\n", file_name);
+ continue;
+ }
+ printf("FINGERPRINT=%s\n", fingerprint);
+ chromaprint_dealloc(fingerprint);
+ }
+ }
+
+ chromaprint_free(chromaprint_ctx);
+ av_free(buffer1);
+ av_free(buffer2);
+ free(file_names);
+
+ return 0;
+}
+
+#ifdef _WIN32
+int main(int win32_argc, char **win32_argv)
+{
+ int i, argc = 0, buffsize = 0, offset = 0;
+ char **utf8_argv, *utf8_argv_ptr;
+ wchar_t **argv;
+
+ argv = CommandLineToArgvW(GetCommandLineW(), &argc);
+
+ buffsize = 0;
+ for (i = 0; i < argc; i++) {
+ buffsize += WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL);
+ }
+
+ utf8_argv = av_mallocz(sizeof(char *) * (argc + 1) + buffsize);
+ utf8_argv_ptr = (char *)utf8_argv + sizeof(char *) * (argc + 1);
+
+ for (i = 0; i < argc; i++) {
+ utf8_argv[i] = &utf8_argv_ptr[offset];
+ offset += WideCharToMultiByte(CP_UTF8, 0, argv[i], -1, &utf8_argv_ptr[offset], buffsize - offset, NULL, NULL);
+ }
+
+ LocalFree(argv);
+
+ return fpcalc_main(argc, utf8_argv);
+}
+#else
+int main(int argc, char **argv)
+{
+ return fpcalc_main(argc, argv);
+}
+#endif
+
diff --git a/3rdparty/chromaprint/libchromaprint.pc.cmake b/3rdparty/chromaprint/libchromaprint.pc.cmake
new file mode 100644
index 000000000..ac94b28da
--- /dev/null
+++ b/3rdparty/chromaprint/libchromaprint.pc.cmake
@@ -0,0 +1,12 @@
+prefix=${CMAKE_INSTALL_PREFIX}
+exec_prefix=${EXEC_INSTALL_PREFIX}
+libdir=${LIB_INSTALL_DIR}
+includedir=${INCLUDE_INSTALL_DIR}
+
+Name: ${PROJECT_NAME}
+Description: Audio fingerprint library
+URL: http://wiki.acoustid.org/wiki/Chromaprint
+Version: ${PROJECT_VERSION}
+Libs: -L${LIB_INSTALL_DIR} -lchromaprint
+Cflags: -I${INCLUDE_INSTALL_DIR}
+
diff --git a/3rdparty/chromaprint/src/CMakeLists.txt b/3rdparty/chromaprint/src/CMakeLists.txt
new file mode 100644
index 000000000..cb0afa505
--- /dev/null
+++ b/3rdparty/chromaprint/src/CMakeLists.txt
@@ -0,0 +1,74 @@
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+set(chromaprint_SRCS
+ chromaprint.cpp
+ audio_processor.cpp
+ chroma.cpp
+ chroma_resampler.cpp
+ chroma_filter.cpp
+ integral_image.cpp
+ spectrum.cpp
+ spectral_centroid.cpp
+ filter.cpp
+ fft.cpp
+ fingerprinter.cpp
+ image_builder.cpp
+ lloyds.cpp
+ silence_remover.cpp
+ fingerprint_calculator.cpp
+ fingerprint_compressor.cpp
+ fingerprint_decompressor.cpp
+ fingerprinter_configuration.cpp
+ base64.cpp
+ avresample/resample2.c
+)
+
+if(WITH_AVFFT)
+ set(chromaprint_SRCS fft_lib_avfft.cpp ${chromaprint_SRCS})
+ set(chromaprint_LINK_LIBS
+ ${FFMPEG_LIBAVCODEC_LIBRARIES}
+ ${FFMPEG_LIBAVUTIL_LIBRARIES}
+ )
+ include_directories(
+ ${FFMPEG_LIBAVCODEC_INCLUDE_DIRS}
+ ${FFMPEG_LIBAVFORMAT_INCLUDE_DIRS}
+ ${FFMPEG_LIBAVUTIL_INCLUDE_DIRS}
+ )
+endif(WITH_AVFFT)
+
+if(WITH_FFTW3)
+ set(chromaprint_SRCS fft_lib_fftw3.cpp ${chromaprint_SRCS})
+ set(chromaprint_LINK_LIBS ${FFTW3_LIBRARIES})
+ include_directories(${FFTW3_INCLUDE_DIR})
+endif(WITH_FFTW3)
+
+if(WITH_VDSP)
+ set(chromaprint_SRCS fft_lib_vdsp.cpp ${chromaprint_SRCS})
+ set(chromaprint_LINK_LIBS ${ACCELERATE_LIBRARIES})
+endif()
+
+add_library(chromaprint_p STATIC ${chromaprint_SRCS})
+target_link_libraries(chromaprint_p ${chromaprint_LINK_LIBS})
+
+set(chromaprint_HDRS chromaprint.h)
+
+add_library(chromaprint ${chromaprint_SRCS} ${chromaprint_SRCS} ${chromaprint_HDRS})
+set_target_properties(chromaprint PROPERTIES
+ VERSION ${chromaprint_VERSION}
+ SOVERSION ${chromaprint_SOVERSION}
+ PUBLIC_HEADER ${chromaprint_HDRS}
+ DEFINE_SYMBOL CHROMAPRINT_API_EXPORTS
+)
+if(BUILD_FRAMEWORK)
+ set_target_properties(chromaprint PROPERTIES FRAMEWORK TRUE)
+endif()
+target_link_libraries(chromaprint ${chromaprint_LINK_LIBS})
+
+install(TARGETS chromaprint
+ FRAMEWORK DESTINATION ${FRAMEWORK_INSTALL_DIR}
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+ RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+ PUBLIC_HEADER DESTINATION ${INCLUDE_INSTALL_DIR}
+)
+
diff --git a/3rdparty/chromaprint/src/audio_consumer.h b/3rdparty/chromaprint/src/audio_consumer.h
new file mode 100644
index 000000000..b5070f640
--- /dev/null
+++ b/3rdparty/chromaprint/src/audio_consumer.h
@@ -0,0 +1,38 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_AUDIO_CONSUMER_H_
+#define CHROMAPRINT_AUDIO_CONSUMER_H_
+
+namespace Chromaprint
+{
+
+ class AudioConsumer
+ {
+ public:
+ virtual ~AudioConsumer() {}
+
+ virtual void Consume(short *input, int length) = 0;
+ };
+
+};
+
+#endif
+
diff --git a/3rdparty/chromaprint/src/audio_processor.cpp b/3rdparty/chromaprint/src/audio_processor.cpp
new file mode 100644
index 000000000..5d8a43a97
--- /dev/null
+++ b/3rdparty/chromaprint/src/audio_processor.cpp
@@ -0,0 +1,191 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include
+#include
+extern "C" {
+#include "avresample/avcodec.h"
+}
+#include "debug.h"
+#include "audio_processor.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+static const int kMinSampleRate = 1000;
+static const int kMaxBufferSize = 1024 * 16;
+
+// Resampler configuration
+static const int kResampleFilterLength = 16;
+static const int kResamplePhaseCount = 10;
+static const int kResampleLinear = 0;
+static const double kResampleCutoff = 0.8;
+
+AudioProcessor::AudioProcessor(int sample_rate, AudioConsumer *consumer)
+ : m_buffer_size(kMaxBufferSize),
+ m_target_sample_rate(sample_rate),
+ m_consumer(consumer),
+ m_resample_ctx(0)
+{
+ m_buffer = new short[kMaxBufferSize];
+ m_buffer_offset = 0;
+ m_resample_buffer = new short[kMaxBufferSize];
+}
+
+AudioProcessor::~AudioProcessor()
+{
+ if (m_resample_ctx) {
+ av_resample_close(m_resample_ctx);
+ }
+ delete[] m_resample_buffer;
+ delete[] m_buffer;
+}
+
+void AudioProcessor::LoadMono(short *input, int length)
+{
+ short *output = m_buffer + m_buffer_offset;
+ while (length--) {
+ *output++ = input[0];
+ input++;
+ }
+}
+
+void AudioProcessor::LoadStereo(short *input, int length)
+{
+ short *output = m_buffer + m_buffer_offset;
+ while (length--) {
+ *output++ = (input[0] + input[1]) / 2;
+ input += 2;
+ }
+}
+
+void AudioProcessor::LoadMultiChannel(short *input, int length)
+{
+ short *output = m_buffer + m_buffer_offset;
+ while (length--) {
+ long sum = 0;
+ for (int i = 0; i < m_num_channels; i++) {
+ sum += *input++;
+ }
+ *output++ = (short)(sum / m_num_channels);
+ }
+}
+
+int AudioProcessor::Load(short *input, int length)
+{
+ assert(length >= 0);
+ assert(m_buffer_offset <= m_buffer_size);
+ length = min(length, m_buffer_size - m_buffer_offset);
+ switch (m_num_channels) {
+ case 1:
+ LoadMono(input, length);
+ break;
+ case 2:
+ LoadStereo(input, length);
+ break;
+ default:
+ LoadMultiChannel(input, length);
+ break;
+ }
+ m_buffer_offset += length;
+ return length;
+}
+
+void AudioProcessor::Resample()
+{
+ if (!m_resample_ctx) {
+ m_consumer->Consume(m_buffer, m_buffer_offset);
+ m_buffer_offset = 0;
+ return;
+ }
+ int consumed = 0;
+ int length = av_resample(m_resample_ctx, m_resample_buffer, m_buffer, &consumed, m_buffer_offset, kMaxBufferSize, 1);
+ if (length > kMaxBufferSize) {
+ DEBUG() << "Chromaprint::AudioProcessor::Resample() -- Resampling overwrote output buffer.\n";
+ length = kMaxBufferSize;
+ }
+ m_consumer->Consume(m_resample_buffer, length);
+ int remaining = m_buffer_offset - consumed;
+ if (remaining > 0) {
+ copy(m_buffer + consumed, m_buffer + m_buffer_offset, m_buffer);
+ }
+ else if (remaining < 0) {
+ DEBUG() << "Chromaprint::AudioProcessor::Resample() -- Resampling overread input buffer.\n";
+ remaining = 0;
+ }
+ m_buffer_offset = remaining;
+}
+
+
+bool AudioProcessor::Reset(int sample_rate, int num_channels)
+{
+ if (num_channels <= 0) {
+ DEBUG() << "Chromaprint::AudioProcessor::Reset() -- No audio channels.\n";
+ return false;
+ }
+ if (sample_rate <= kMinSampleRate) {
+ DEBUG() << "Chromaprint::AudioProcessor::Reset() -- Sample rate less "
+ << "than " << kMinSampleRate << " (" << sample_rate << ").\n";
+ return false;
+ }
+ m_buffer_offset = 0;
+ if (m_resample_ctx) {
+ av_resample_close(m_resample_ctx);
+ m_resample_ctx = 0;
+ }
+ if (sample_rate != m_target_sample_rate) {
+ m_resample_ctx = av_resample_init(
+ m_target_sample_rate, sample_rate,
+ kResampleFilterLength,
+ kResamplePhaseCount,
+ kResampleLinear,
+ kResampleCutoff);
+ }
+ m_num_channels = num_channels;
+ return true;
+}
+
+void AudioProcessor::Consume(short *input, int length)
+{
+ assert(length >= 0);
+ assert(length % m_num_channels == 0);
+ length /= m_num_channels;
+ while (length > 0) {
+ int consumed = Load(input, length);
+ input += consumed * m_num_channels;
+ length -= consumed;
+ if (m_buffer_size == m_buffer_offset) {
+ Resample();
+ if (m_buffer_size == m_buffer_offset) {
+ DEBUG() << "Chromaprint::AudioProcessor::Consume() -- Resampling failed?\n";
+ return;
+ }
+ }
+ }
+}
+
+void AudioProcessor::Flush()
+{
+ if (m_buffer_offset) {
+ Resample();
+ }
+}
+
diff --git a/3rdparty/chromaprint/src/audio_processor.h b/3rdparty/chromaprint/src/audio_processor.h
new file mode 100644
index 000000000..917805427
--- /dev/null
+++ b/3rdparty/chromaprint/src/audio_processor.h
@@ -0,0 +1,87 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_AUDIO_PROCESSOR_H_
+#define CHROMAPRINT_AUDIO_PROCESSOR_H_
+
+#include "utils.h"
+#include "audio_consumer.h"
+
+struct AVResampleContext;
+
+namespace Chromaprint
+{
+
+ class AudioProcessor : public AudioConsumer
+ {
+ public:
+ AudioProcessor(int sample_rate, AudioConsumer *consumer);
+ virtual ~AudioProcessor();
+
+ int target_sample_rate() const
+ {
+ return m_target_sample_rate;
+ }
+
+ void set_target_sample_rate(int sample_rate)
+ {
+ m_target_sample_rate = sample_rate;
+ }
+
+ AudioConsumer *consumer() const
+ {
+ return m_consumer;
+ }
+
+ void set_consumer(AudioConsumer *consumer)
+ {
+ m_consumer = consumer;
+ }
+
+ //! Prepare for a new audio stream
+ bool Reset(int sample_rate, int num_channels);
+ //! Process a chunk of data from the audio stream
+ void Consume(short *input, int length);
+ //! Process any buffered input that was not processed before and clear buffers
+ void Flush();
+
+ private:
+ CHROMAPRINT_DISABLE_COPY(AudioProcessor);
+
+ int Load(short *input, int length);
+ void LoadMono(short *input, int length);
+ void LoadStereo(short *input, int length);
+ void LoadMultiChannel(short *input, int length);
+ void Resample();
+
+ short *m_buffer;
+ short *m_resample_buffer;
+ int m_buffer_offset;
+ int m_buffer_size;
+ int m_target_sample_rate;
+ int m_num_channels;
+ AudioConsumer *m_consumer;
+ struct AVResampleContext *m_resample_ctx;
+ };
+
+};
+
+#endif
+
diff --git a/3rdparty/chromaprint/src/avresample/avcodec.h b/3rdparty/chromaprint/src/avresample/avcodec.h
new file mode 100644
index 000000000..9df0b22dd
--- /dev/null
+++ b/3rdparty/chromaprint/src/avresample/avcodec.h
@@ -0,0 +1,101 @@
+/*
+ * copyright (c) 2001 Fabrice Bellard
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_H
+#define AVCODEC_H
+
+/* Just a heavily bastardized version of the original file from
+ * ffmpeg, just enough to get resample2.c to compile without
+ * modification -- Lennart */
+
+#if defined(HAVE_CONFIG_H)
+#include
+#endif
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+typedef void *AVClass;
+
+#define av_mallocz(l) calloc(1, (l))
+#define av_malloc(l) malloc(l)
+#define av_realloc(p,l) realloc((p),(l))
+#define av_free(p) free(p)
+
+#ifdef _MSC_VER
+#define CHROMAPRINT_C_INLINE __inline
+#else
+#define CHROMAPRINT_C_INLINE inline
+#endif
+
+static CHROMAPRINT_C_INLINE void av_freep(void *k) {
+ void **p = (void **)k;
+
+ if (p) {
+ free(*p);
+ *p = NULL;
+ }
+}
+
+static CHROMAPRINT_C_INLINE int av_clip(int a, int amin, int amax)
+{
+ if (a < amin) return amin;
+ else if (a > amax) return amax;
+ else return a;
+}
+
+#define av_log(a,b,c)
+
+#define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
+#define FFSIGN(a) ((a) > 0 ? 1 : -1)
+
+#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
+#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+
+struct AVResampleContext;
+struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff);
+int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx);
+void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance);
+void av_resample_close(struct AVResampleContext *c);
+void av_build_filter(int16_t *filter, double factor, int tap_count, int phase_count, int scale, int type);
+
+/* error handling */
+#if EDOM > 0
+#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions.
+#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value.
+#else
+/* Some platforms have E* and errno already negated. */
+#define AVERROR(e) (e)
+#define AVUNERROR(e) (e)
+#endif
+
+/*
+ * crude lrintf for non-C99 systems.
+ */
+#ifndef HAVE_LRINTF
+#define lrintf(x) ((long int)floor(x + 0.5))
+#endif
+
+#endif /* AVCODEC_H */
diff --git a/3rdparty/chromaprint/src/avresample/dsputil.h b/3rdparty/chromaprint/src/avresample/dsputil.h
new file mode 100644
index 000000000..8da742d0f
--- /dev/null
+++ b/3rdparty/chromaprint/src/avresample/dsputil.h
@@ -0,0 +1 @@
+/* empty file, just here to allow us to compile an unmodified resampler2.c */
diff --git a/3rdparty/chromaprint/src/avresample/resample2.c b/3rdparty/chromaprint/src/avresample/resample2.c
new file mode 100644
index 000000000..b940059d8
--- /dev/null
+++ b/3rdparty/chromaprint/src/avresample/resample2.c
@@ -0,0 +1,320 @@
+/*
+ * audio resampling
+ * Copyright (c) 2004 Michael Niedermayer
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * audio resampling
+ * @author Michael Niedermayer
+ */
+
+#include "avcodec.h"
+#include "dsputil.h"
+
+#ifndef CONFIG_RESAMPLE_HP
+#define FILTER_SHIFT 15
+
+#define FELEM int16_t
+#define FELEM2 int32_t
+#define FELEML int64_t
+#define FELEM_MAX INT16_MAX
+#define FELEM_MIN INT16_MIN
+#define WINDOW_TYPE 9
+#elif !defined(CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE)
+#define FILTER_SHIFT 30
+
+#define FELEM int32_t
+#define FELEM2 int64_t
+#define FELEML int64_t
+#define FELEM_MAX INT32_MAX
+#define FELEM_MIN INT32_MIN
+#define WINDOW_TYPE 12
+#else
+#define FILTER_SHIFT 0
+
+#define FELEM double
+#define FELEM2 double
+#define FELEML double
+#define WINDOW_TYPE 24
+#endif
+
+
+typedef struct AVResampleContext{
+ const AVClass *av_class;
+ FELEM *filter_bank;
+ int filter_length;
+ int ideal_dst_incr;
+ int dst_incr;
+ int index;
+ int frac;
+ int src_incr;
+ int compensation_distance;
+ int phase_shift;
+ int phase_mask;
+ int linear;
+}AVResampleContext;
+
+/**
+ * 0th order modified bessel function of the first kind.
+ */
+static double bessel(double x){
+ double v=1;
+ double lastv=0;
+ double t=1;
+ int i;
+
+ x= x*x/4;
+ for(i=1; v != lastv; i++){
+ lastv=v;
+ t *= x/(i*i);
+ v += t;
+ }
+ return v;
+}
+
+/**
+ * builds a polyphase filterbank.
+ * @param factor resampling factor
+ * @param scale wanted sum of coefficients for each filter
+ * @param type 0->cubic, 1->blackman nuttall windowed sinc, 2..16->kaiser windowed sinc beta=2..16
+ * @return 0 on success, negative on error
+ */
+static int build_filter(FELEM *filter, double factor, int tap_count, int phase_count, int scale, int type){
+ int ph, i;
+ double x, y, w;
+ double *tab = av_malloc(tap_count * sizeof(*tab));
+ const int center= (tap_count-1)/2;
+
+ if (!tab)
+ return AVERROR(ENOMEM);
+
+ /* if upsampling, only need to interpolate, no filter */
+ if (factor > 1.0)
+ factor = 1.0;
+
+ for(ph=0;phphase_shift= phase_shift;
+ c->phase_mask= phase_count-1;
+ c->linear= linear;
+
+ c->filter_length= FFMAX((int)ceil(filter_size/factor), 1);
+ c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM));
+ if (!c->filter_bank)
+ goto error;
+ if (build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM));
+ c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1];
+
+ c->src_incr= out_rate;
+ c->ideal_dst_incr= c->dst_incr= in_rate * phase_count;
+ c->index= -phase_count*((c->filter_length-1)/2);
+
+ return c;
+error:
+ av_free(c->filter_bank);
+ av_free(c);
+ return NULL;
+}
+
+void av_resample_close(AVResampleContext *c){
+ av_freep(&c->filter_bank);
+ av_freep(&c);
+}
+
+void av_resample_compensate(AVResampleContext *c, int sample_delta, int compensation_distance){
+// sample_delta += (c->ideal_dst_incr - c->dst_incr)*(int64_t)c->compensation_distance / c->ideal_dst_incr;
+ c->compensation_distance= compensation_distance;
+ c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr * (int64_t)sample_delta / compensation_distance;
+}
+
+int av_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx){
+ int dst_index, i;
+ int index= c->index;
+ int frac= c->frac;
+ int dst_incr_frac= c->dst_incr % c->src_incr;
+ int dst_incr= c->dst_incr / c->src_incr;
+ int compensation_distance= c->compensation_distance;
+
+ if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){
+ int64_t index2= ((int64_t)index)<<32;
+ int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr;
+ dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr);
+
+ for(dst_index=0; dst_index < dst_size; dst_index++){
+ dst[dst_index] = src[index2>>32];
+ index2 += incr;
+ }
+ frac += dst_index * dst_incr_frac;
+ index += dst_index * dst_incr;
+ index += frac / c->src_incr;
+ frac %= c->src_incr;
+ }else{
+ for(dst_index=0; dst_index < dst_size; dst_index++){
+ FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask);
+ int sample_index= index >> c->phase_shift;
+ FELEM2 val=0;
+
+ if(sample_index < 0){
+ for(i=0; ifilter_length; i++)
+ val += src[FFABS(sample_index + i) % src_size] * filter[i];
+ }else if(sample_index + c->filter_length > src_size){
+ break;
+ }else if(c->linear){
+ FELEM2 v2=0;
+ for(i=0; ifilter_length; i++){
+ val += src[sample_index + i] * (FELEM2)filter[i];
+ v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length];
+ }
+ val+=(v2-val)*(FELEML)frac / c->src_incr;
+ }else{
+ for(i=0; ifilter_length; i++){
+ val += src[sample_index + i] * (FELEM2)filter[i];
+ }
+ }
+
+#ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE
+ dst[dst_index] = av_clip_int16(lrintf(val));
+#else
+ val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT;
+ dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val;
+#endif
+
+ frac += dst_incr_frac;
+ index += dst_incr;
+ if(frac >= c->src_incr){
+ frac -= c->src_incr;
+ index++;
+ }
+
+ if(dst_index + 1 == compensation_distance){
+ compensation_distance= 0;
+ dst_incr_frac= c->ideal_dst_incr % c->src_incr;
+ dst_incr= c->ideal_dst_incr / c->src_incr;
+ }
+ }
+ }
+ *consumed= FFMAX(index, 0) >> c->phase_shift;
+ if(index>=0) index &= c->phase_mask;
+
+ if(compensation_distance){
+ compensation_distance -= dst_index;
+ assert(compensation_distance > 0);
+ }
+ if(update_ctx){
+ c->frac= frac;
+ c->index= index;
+ c->dst_incr= dst_incr_frac + c->src_incr*dst_incr;
+ c->compensation_distance= compensation_distance;
+ }
+#if 0
+ if(update_ctx && !c->compensation_distance){
+#undef rand
+ av_resample_compensate(c, rand() % (8000*2) - 8000, 8000*2);
+av_log(NULL, AV_LOG_DEBUG, "%d %d %d\n", c->dst_incr, c->ideal_dst_incr, c->compensation_distance);
+ }
+#endif
+
+ return dst_index;
+}
diff --git a/3rdparty/chromaprint/src/base64.cpp b/3rdparty/chromaprint/src/base64.cpp
new file mode 100644
index 000000000..0eb37c79a
--- /dev/null
+++ b/3rdparty/chromaprint/src/base64.cpp
@@ -0,0 +1,92 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include
+#include "base64.h"
+#include "bit_string_writer.h"
+#include "debug.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+static const char kBase64Chars[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
+static const char kBase64CharsReversed[128] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 52,
+ 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 0, 0, 0, 0, 63, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
+ 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0
+};
+
+string Chromaprint::Base64Encode(const string &orig)
+{
+ int size = orig.size();
+ int encoded_size = (size * 4 + 2) / 3;
+ string encoded(encoded_size, '\x00');
+ const unsigned char *src = (unsigned char *)orig.data();
+ string::iterator dest = encoded.begin();
+ while (size > 0) {
+ *dest++ = kBase64Chars[(src[0] >> 2)];
+ *dest++ = kBase64Chars[((src[0] << 4) | (--size ? (src[1] >> 4) : 0)) & 63];
+ if (size) {
+ *dest++ = kBase64Chars[((src[1] << 2) | (--size ? (src[2] >> 6) : 0)) & 63];
+ if (size) {
+ *dest++ = kBase64Chars[src[2] & 63];
+ --size;
+ }
+ }
+ src += 3;
+ }
+ return encoded;
+}
+
+string Chromaprint::Base64Decode(const string &encoded)
+{
+ string str((3 * encoded.size()) / 4, '\x00');
+ const unsigned char *src = (const unsigned char *)encoded.data();
+ int size = encoded.size();
+ string::iterator dest = str.begin();
+ while (size > 0) {
+ int b0 = kBase64CharsReversed[*src++];
+ if (--size) {
+ int b1 = kBase64CharsReversed[*src++];
+ int r = (b0 << 2) | (b1 >> 4);
+ assert(dest != str.end());
+ *dest++ = r;
+ if (--size) {
+ int b2 = kBase64CharsReversed[*src++];
+ r = ((b1 << 4) & 255) | (b2 >> 2);
+ assert(dest != str.end());
+ *dest++ = r;
+ if (--size) {
+ int b3 = kBase64CharsReversed[*src++];
+ r = ((b2 << 6) & 255) | b3;
+ assert(dest != str.end());
+ *dest++ = r;
+ --size;
+ }
+ }
+ }
+ }
+ return str;
+}
+
diff --git a/3rdparty/chromaprint/src/base64.h b/3rdparty/chromaprint/src/base64.h
new file mode 100644
index 000000000..bcae7ac09
--- /dev/null
+++ b/3rdparty/chromaprint/src/base64.h
@@ -0,0 +1,35 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_BASE64_H_
+#define CHROMAPRINT_BASE64_H_
+
+#include
+
+namespace Chromaprint
+{
+
+ std::string Base64Encode(const std::string &str);
+ std::string Base64Decode(const std::string &encoded);
+
+};
+
+#endif
+
diff --git a/3rdparty/chromaprint/src/bit_string_reader.h b/3rdparty/chromaprint/src/bit_string_reader.h
new file mode 100644
index 000000000..ecf78e0fa
--- /dev/null
+++ b/3rdparty/chromaprint/src/bit_string_reader.h
@@ -0,0 +1,69 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_BIT_STRING_READER_H_
+#define CHROMAPRINT_BIT_STRING_READER_H_
+
+#include
+#include
+#include "debug.h"
+
+namespace Chromaprint
+{
+ class BitStringReader
+ {
+ public:
+ BitStringReader(const std::string &input) : m_value(input), m_buffer(0), m_buffer_size(0)
+ {
+ m_value_iter = m_value.begin();
+ }
+
+ uint32_t Read(int bits)
+ {
+ if (m_buffer_size < bits) {
+ if (m_value_iter != m_value.end()) {
+ m_buffer |= (unsigned char)(*m_value_iter++) << m_buffer_size;
+ m_buffer_size += 8;
+ }
+ }
+ uint32_t result = m_buffer & ((1 << bits) - 1);
+ m_buffer >>= bits;
+ m_buffer_size -= bits;
+ return result;
+ }
+
+ void Reset()
+ {
+ m_buffer = 0;
+ m_buffer_size = 0;
+ }
+
+ private:
+
+ std::string m_value;
+ std::string::iterator m_value_iter;
+ uint32_t m_buffer;
+ int m_buffer_size;
+ };
+
+};
+
+#endif
+
diff --git a/3rdparty/chromaprint/src/bit_string_writer.h b/3rdparty/chromaprint/src/bit_string_writer.h
new file mode 100644
index 000000000..c28ca273a
--- /dev/null
+++ b/3rdparty/chromaprint/src/bit_string_writer.h
@@ -0,0 +1,77 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_BIT_STRING_WRITER_H_
+#define CHROMAPRINT_BIT_STRING_WRITER_H_
+
+#include
+#include
+#include
+
+namespace Chromaprint
+{
+ class Classifier;
+ class Image;
+ class IntegralImage;
+
+ class BitStringWriter
+ {
+ public:
+ BitStringWriter() : m_buffer(0), m_buffer_size(0)
+ {
+ }
+
+ void Write(uint32_t x, int bits)
+ {
+ m_buffer |= (x << m_buffer_size);
+ m_buffer_size += bits;
+ while (m_buffer_size >= 8) {
+ m_value.push_back(m_buffer & 255);
+ m_buffer >>= 8;
+ m_buffer_size -= 8;
+ }
+ }
+
+ void Flush()
+ {
+ while (m_buffer_size > 0) {
+ m_value.push_back(m_buffer & 255);
+ m_buffer >>= 8;
+ m_buffer_size -= 8;
+ }
+ m_buffer_size = 0;
+ }
+
+ std::string value() const
+ {
+ return m_value;
+ }
+
+ private:
+
+ std::string m_value;
+ uint32_t m_buffer;
+ int m_buffer_size;
+ };
+
+};
+
+#endif
+
diff --git a/3rdparty/chromaprint/src/chroma.cpp b/3rdparty/chromaprint/src/chroma.cpp
new file mode 100644
index 000000000..b19d0a58e
--- /dev/null
+++ b/3rdparty/chromaprint/src/chroma.cpp
@@ -0,0 +1,95 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include
+#include "fft_frame.h"
+#include "utils.h"
+#include "chroma.h"
+#include "debug.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+static const int NUM_BANDS = 12;
+
+inline double FreqToOctave(double freq, double base = 440.0 / 16.0)
+{
+ return log(freq / base) / log(2.0);
+}
+
+Chroma::Chroma(int min_freq, int max_freq, int frame_size, int sample_rate, FeatureVectorConsumer *consumer)
+ : m_interpolate(false),
+ m_notes(frame_size),
+ m_notes_frac(frame_size),
+ m_features(NUM_BANDS),
+ m_consumer(consumer)
+{
+ PrepareNotes(min_freq, max_freq, frame_size, sample_rate);
+}
+
+Chroma::~Chroma()
+{
+}
+
+void Chroma::PrepareNotes(int min_freq, int max_freq, int frame_size, int sample_rate)
+{
+ m_min_index = max(1, FreqToIndex(min_freq, frame_size, sample_rate));
+ m_max_index = min(frame_size / 2, FreqToIndex(max_freq, frame_size, sample_rate));
+ for (int i = m_min_index; i < m_max_index; i++) {
+ double freq = IndexToFreq(i, frame_size, sample_rate);
+ double octave = FreqToOctave(freq);
+ double note = NUM_BANDS * (octave - floor(octave));
+ m_notes[i] = (char)note;
+ m_notes_frac[i] = note - m_notes[i];
+ }
+}
+
+void Chroma::Reset()
+{
+}
+
+void Chroma::Consume(const FFTFrame &frame)
+{
+ fill(m_features.begin(), m_features.end(), 0.0);
+ for (int i = m_min_index; i < m_max_index; i++) {
+ int note = m_notes[i];
+ double energy = frame.Energy(i);
+ if (m_interpolate) {
+ int note2 = note;
+ double a = 1.0;
+ if (m_notes_frac[i] < 0.5) {
+ note2 = (note + NUM_BANDS - 1) % NUM_BANDS;
+ a = 0.5 + m_notes_frac[i];
+ }
+ if (m_notes_frac[i] > 0.5) {
+ note2 = (note + 1) % NUM_BANDS;
+ a = 1.5 - m_notes_frac[i];
+ }
+ m_features[note] += energy * a;
+ m_features[note2] += energy * (1.0 - a);
+ }
+ else {
+ m_features[note] += energy;
+ }
+ }
+ m_consumer->Consume(m_features);
+}
+
diff --git a/3rdparty/chromaprint/src/chroma.h b/3rdparty/chromaprint/src/chroma.h
new file mode 100644
index 000000000..0183ac1b4
--- /dev/null
+++ b/3rdparty/chromaprint/src/chroma.h
@@ -0,0 +1,68 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_CHROMA_H_
+#define CHROMAPRINT_CHROMA_H_
+
+#include
+#include
+#include "utils.h"
+#include "fft_frame_consumer.h"
+#include "feature_vector_consumer.h"
+
+namespace Chromaprint
+{
+
+ class Chroma : public FFTFrameConsumer
+ {
+ public:
+ Chroma(int min_freq, int max_freq, int frame_size, int sample_rate, FeatureVectorConsumer *consumer);
+ ~Chroma();
+
+ bool interpolate() const
+ {
+ return m_interpolate;
+ }
+
+ void set_interpolate(bool interpolate)
+ {
+ m_interpolate = interpolate;
+ }
+
+ void Reset();
+ void Consume(const FFTFrame &frame);
+
+ private:
+ CHROMAPRINT_DISABLE_COPY(Chroma);
+
+ void PrepareNotes(int min_freq, int max_freq, int frame_size, int sample_rate);
+
+ bool m_interpolate;
+ std::vector m_notes;
+ std::vector m_notes_frac;
+ int m_min_index;
+ int m_max_index;
+ std::vector m_features;
+ FeatureVectorConsumer *m_consumer;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/chroma_filter.cpp b/3rdparty/chromaprint/src/chroma_filter.cpp
new file mode 100644
index 000000000..202c3aa34
--- /dev/null
+++ b/3rdparty/chromaprint/src/chroma_filter.cpp
@@ -0,0 +1,69 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include
+#include
+#include "chroma_filter.h"
+#include "utils.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+ChromaFilter::ChromaFilter(const double *coefficients, int length, FeatureVectorConsumer *consumer)
+ : m_coefficients(coefficients),
+ m_length(length),
+ m_buffer(8),
+ m_result(12),
+ m_buffer_offset(0),
+ m_buffer_size(1),
+ m_consumer(consumer)
+{
+}
+
+ChromaFilter::~ChromaFilter()
+{
+}
+
+void ChromaFilter::Reset()
+{
+ m_buffer_size = 1;
+ m_buffer_offset = 0;
+}
+
+void ChromaFilter::Consume(std::vector &features)
+{
+ m_buffer[m_buffer_offset] = features;
+ m_buffer_offset = (m_buffer_offset + 1) % 8;
+ if (m_buffer_size >= m_length) {
+ int offset = (m_buffer_offset + 8 - m_length) % 8;
+ fill(m_result.begin(), m_result.end(), 0.0);
+ for (int i = 0; i < 12; i++) {
+ for (int j = 0; j < m_length; j++) {
+ m_result[i] += m_buffer[(offset + j) % 8][i] * m_coefficients[j];
+ }
+ }
+ m_consumer->Consume(m_result);
+ }
+ else {
+ m_buffer_size++;
+ }
+}
+
diff --git a/3rdparty/chromaprint/src/chroma_filter.h b/3rdparty/chromaprint/src/chroma_filter.h
new file mode 100644
index 000000000..69f6febdc
--- /dev/null
+++ b/3rdparty/chromaprint/src/chroma_filter.h
@@ -0,0 +1,54 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_CHROMA_FILTER_H_
+#define CHROMAPRINT_CHROMA_FILTER_H_
+
+#include
+#include "feature_vector_consumer.h"
+
+namespace Chromaprint
+{
+
+ class ChromaFilter : public FeatureVectorConsumer
+ {
+ public:
+ ChromaFilter(const double *coefficients, int length, FeatureVectorConsumer *consumer);
+ ~ChromaFilter();
+
+ void Reset();
+ void Consume(std::vector &features);
+
+ FeatureVectorConsumer *consumer() { return m_consumer; }
+ void set_consumer(FeatureVectorConsumer *consumer) { m_consumer = consumer; }
+
+ private:
+ const double *m_coefficients;
+ int m_length;
+ std::vector< std::vector > m_buffer;
+ std::vector m_result;
+ int m_buffer_offset;
+ int m_buffer_size;
+ FeatureVectorConsumer *m_consumer;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/chroma_normalizer.h b/3rdparty/chromaprint/src/chroma_normalizer.h
new file mode 100644
index 000000000..33f1ffd6e
--- /dev/null
+++ b/3rdparty/chromaprint/src/chroma_normalizer.h
@@ -0,0 +1,55 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_CHROMA_NORMALIZER_H_
+#define CHROMAPRINT_CHROMA_NORMALIZER_H_
+
+#include
+#include
+#include "feature_vector_consumer.h"
+#include "utils.h"
+
+namespace Chromaprint
+{
+
+ class ChromaNormalizer : public FeatureVectorConsumer
+ {
+ public:
+ ChromaNormalizer(FeatureVectorConsumer *consumer) : m_consumer(consumer) {}
+ ~ChromaNormalizer() {}
+ void Reset() {}
+
+ void Consume(std::vector &features)
+ {
+ NormalizeVector(features.begin(), features.end(),
+ Chromaprint::EuclideanNorm::iterator>,
+ 0.01);
+ m_consumer->Consume(features);
+ }
+
+ private:
+ CHROMAPRINT_DISABLE_COPY(ChromaNormalizer);
+
+ FeatureVectorConsumer *m_consumer;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/chroma_resampler.cpp b/3rdparty/chromaprint/src/chroma_resampler.cpp
new file mode 100644
index 000000000..6be6c1324
--- /dev/null
+++ b/3rdparty/chromaprint/src/chroma_resampler.cpp
@@ -0,0 +1,62 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include
+#include
+#include "chroma_resampler.h"
+#include "utils.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+ChromaResampler::ChromaResampler(int factor, FeatureVectorConsumer *consumer)
+ : m_result(12, 0.0),
+ m_iteration(0),
+ m_factor(factor),
+ m_consumer(consumer)
+{
+}
+
+ChromaResampler::~ChromaResampler()
+{
+}
+
+void ChromaResampler::Reset()
+{
+ m_iteration = 0;
+ fill(m_result.begin(), m_result.end(), 0.0);
+}
+
+void ChromaResampler::Consume(std::vector &features)
+{
+ for (int i = 0; i < 12; i++) {
+ m_result[i] += features[i];
+ }
+ m_iteration += 1;
+ if (m_iteration == m_factor) {
+ for (int i = 0; i < 12; i++) {
+ m_result[i] /= m_factor;
+ }
+ m_consumer->Consume(m_result);
+ Reset();
+ }
+}
+
diff --git a/3rdparty/chromaprint/src/chroma_resampler.h b/3rdparty/chromaprint/src/chroma_resampler.h
new file mode 100644
index 000000000..36eff29e8
--- /dev/null
+++ b/3rdparty/chromaprint/src/chroma_resampler.h
@@ -0,0 +1,52 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_CHROMA_RESAMPLER_H_
+#define CHROMAPRINT_CHROMA_RESAMPLER_H_
+
+#include
+#include "image.h"
+#include "feature_vector_consumer.h"
+
+namespace Chromaprint
+{
+
+ class ChromaResampler : public FeatureVectorConsumer
+ {
+ public:
+ ChromaResampler(int factor, FeatureVectorConsumer *consumer);
+ ~ChromaResampler();
+
+ void Reset();
+ void Consume(std::vector &features);
+
+ FeatureVectorConsumer *consumer() { return m_consumer; }
+ void set_consumer(FeatureVectorConsumer *consumer) { m_consumer = consumer; }
+
+ private:
+ std::vector m_result;
+ int m_iteration;
+ int m_factor;
+ FeatureVectorConsumer *m_consumer;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/chromaprint.cpp b/3rdparty/chromaprint/src/chromaprint.cpp
new file mode 100644
index 000000000..0b9792b19
--- /dev/null
+++ b/3rdparty/chromaprint/src/chromaprint.cpp
@@ -0,0 +1,150 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include
+#include
+#include
+#include "fingerprinter.h"
+#include "fingerprint_compressor.h"
+#include "fingerprint_decompressor.h"
+#include "fingerprinter_configuration.h"
+#include "base64.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+extern "C" {
+
+struct ChromaprintContextPrivate {
+ int algorithm;
+ Fingerprinter *fingerprinter;
+ vector fingerprint;
+};
+
+#define STR(x) #x
+#define VERSION_STR(minor, major, patch) \
+ STR(major) "." STR(minor) "." STR(patch)
+
+static const char *version_str = VERSION_STR(
+ CHROMAPRINT_VERSION_MAJOR,
+ CHROMAPRINT_VERSION_MINOR,
+ CHROMAPRINT_VERSION_PATCH);
+
+const char *chromaprint_get_version(void)
+{
+ return version_str;
+}
+
+ChromaprintContext *chromaprint_new(int algorithm)
+{
+ ChromaprintContextPrivate *ctx = new ChromaprintContextPrivate();
+ ctx->algorithm = algorithm;
+ ctx->fingerprinter = new Fingerprinter(CreateFingerprinterConfiguration(algorithm));
+ return (ChromaprintContext *)ctx;
+}
+
+void chromaprint_free(ChromaprintContext *c)
+{
+ ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+ delete ctx->fingerprinter;
+ delete ctx;
+}
+
+int chromaprint_start(ChromaprintContext *c, int sample_rate, int num_channels)
+{
+ ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+ return ctx->fingerprinter->Start(sample_rate, num_channels) ? 1 : 0;
+}
+
+int chromaprint_feed(ChromaprintContext *c, void *data, int length)
+{
+ ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+ ctx->fingerprinter->Consume((short *)data, length);
+ return 1;
+}
+
+int chromaprint_finish(ChromaprintContext *c)
+{
+ ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+ ctx->fingerprint = ctx->fingerprinter->Finish();
+ return 1;
+}
+
+int chromaprint_get_fingerprint(ChromaprintContext *c, char **data)
+{
+ ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+ string fp = Chromaprint::Base64Encode(Chromaprint::CompressFingerprint(ctx->fingerprint, ctx->algorithm));
+ *data = (char *)malloc(fp.size() + 1);
+ if (!*data) {
+ return 0;
+ }
+ copy(fp.begin(), fp.end(), *data);
+ (*data)[fp.size()] = 0;
+ return 1;
+}
+
+int chromaprint_get_raw_fingerprint(ChromaprintContext *c, void **data, int *size)
+{
+ ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+ *data = malloc(sizeof(int32_t) * ctx->fingerprint.size());
+ if (!*data) {
+ return 0;
+ }
+ *size = ctx->fingerprint.size();
+ copy(ctx->fingerprint.begin(), ctx->fingerprint.end(), *((int32_t **)data));
+ return 1;
+}
+
+int chromaprint_encode_fingerprint(void *fp, int size, int algorithm, void **encoded_fp, int *encoded_size, int base64)
+{
+ vector uncompressed = vector((int32_t *)fp, (int32_t *)fp + size);
+ string compressed = Chromaprint::CompressFingerprint(uncompressed, algorithm);
+ if (!base64) {
+ *encoded_fp = malloc(compressed.size());
+ *encoded_size = compressed.size();
+ copy(compressed.begin(), compressed.end(), (char *)*encoded_fp);
+ return 1;
+ }
+ string encoded = Chromaprint::Base64Encode(compressed);
+ *encoded_fp = malloc(encoded.size() + 1);
+ *encoded_size = encoded.size();
+ copy(encoded.begin(), encoded.end(), (char *)*encoded_fp);
+ ((char *)*encoded_fp)[encoded.size()] = 0;
+ return 1;
+}
+
+int chromaprint_decode_fingerprint(void *encoded_fp, int encoded_size, void **fp, int *size, int *algorithm, int base64)
+{
+ string encoded = string((char *)encoded_fp, encoded_size);
+ string compressed = base64 ? Chromaprint::Base64Decode(encoded) : encoded;
+ vector uncompressed = Chromaprint::DecompressFingerprint(compressed, algorithm);
+ *fp = malloc(sizeof(int32_t) * uncompressed.size());
+ *size = uncompressed.size();
+ copy(uncompressed.begin(), uncompressed.end(), (int32_t *)*fp);
+ return 0;
+}
+
+void chromaprint_dealloc(void *ptr)
+{
+ free(ptr);
+}
+
+}
diff --git a/3rdparty/chromaprint/src/chromaprint.h b/3rdparty/chromaprint/src/chromaprint.h
new file mode 100644
index 000000000..e7cbe89d0
--- /dev/null
+++ b/3rdparty/chromaprint/src/chromaprint.h
@@ -0,0 +1,222 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_CHROMAPRINT_H_
+#define CHROMAPRINT_CHROMAPRINT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if (defined(_WIN32) || defined(_WIN64))
+# ifdef CHROMAPRINT_NODLL
+# define CHROMAPRINT_API
+# else
+# ifdef CHROMAPRINT_API_EXPORTS
+# define CHROMAPRINT_API __declspec(dllexport)
+# else
+# define CHROMAPRINT_API __declspec(dllimport)
+# endif
+# endif
+#else
+# if __GNUC__ >= 4
+# define CHROMAPRINT_API __attribute__ ((visibility("default")))
+# else
+# define CHROMAPRINT_API
+# endif
+#endif
+
+typedef void *ChromaprintContext;
+
+#define CHROMAPRINT_VERSION_MAJOR 0
+#define CHROMAPRINT_VERSION_MINOR 6
+#define CHROMAPRINT_VERSION_PATCH 0
+
+enum ChromaprintAlgorithm {
+ CHROMAPRINT_ALGORITHM_TEST1 = 0,
+ CHROMAPRINT_ALGORITHM_TEST2,
+ CHROMAPRINT_ALGORITHM_TEST3
+};
+
+#define CHROMAPRINT_ALGORITHM_DEFAULT CHROMAPRINT_ALGORITHM_TEST2
+
+/**
+ * Return the version number of Chromaprint.
+ */
+CHROMAPRINT_API const char *chromaprint_get_version(void);
+
+/**
+ * Allocate and initialize the Chromaprint context.
+ *
+ * Parameters:
+ * - version: Version of the fingerprint algorithm, use
+ * CHROMAPRINT_ALGORITHM_DEFAULT for the default
+ * algorithm
+ *
+ * Returns:
+ * - Chromaprint context pointer
+ */
+CHROMAPRINT_API ChromaprintContext *chromaprint_new(int algorithm);
+
+/**
+ * Deallocate the Chromaprint context.
+ *
+ * Parameters:
+ * - ctx: Chromaprint context pointer
+ */
+CHROMAPRINT_API void chromaprint_free(ChromaprintContext *ctx);
+
+/**
+ * Return the fingerprint algorithm this context is configured to use.
+ */
+CHROMAPRINT_API int chromaprint_get_algorithm(ChromaprintContext *ctx);
+
+/**
+ * Restart the computation of a fingerprint with a new audio stream.
+ *
+ * Parameters:
+ * - ctx: Chromaprint context pointer
+ * - sample_rate: sample rate of the audio stream (in Hz)
+ * - num_channels: numbers of channels in the audio stream (1 or 2)
+ *
+ * Returns:
+ * - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_start(ChromaprintContext *ctx, int sample_rate, int num_channels);
+
+/**
+ * Send audio data to the fingerprint calculator.
+ *
+ * Parameters:
+ * - ctx: Chromaprint context pointer
+ * - data: raw audio data, should point to an array of 16-bit signed
+ * integers in native byte-order
+ * - size: size of the data buffer (in samples)
+ *
+ * Returns:
+ * - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_feed(ChromaprintContext *ctx, void *data, int size);
+
+/**
+ * Process any remaining buffered audio data and calculate the fingerprint.
+ *
+ * Parameters:
+ * - ctx: Chromaprint context pointer
+ *
+ * Returns:
+ * - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_finish(ChromaprintContext *ctx);
+
+/**
+ * Return the calculated fingerprint as a compressed string.
+ *
+ * The caller is responsible for freeing the returned pointer using
+ * chromaprint_dealloc().
+ *
+ * Parameters:
+ * - ctx: Chromaprint context pointer
+ * - fingerprint: pointer to a pointer, where a pointer to the allocated array
+ * will be stored
+ *
+ * Returns:
+ * - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_get_fingerprint(ChromaprintContext *ctx, char **fingerprint);
+
+/**
+ * Return the calculated fingerprint as an array of 32-bit integers.
+ *
+ * The caller is responsible for freeing the returned pointer using
+ * chromaprint_dealloc().
+ *
+ * Parameters:
+ * - ctx: Chromaprint context pointer
+ * - fingerprint: pointer to a pointer, where a pointer to the allocated array
+ * will be stored
+ * - size: number of items in the returned raw fingerprint
+ *
+ * Returns:
+ * - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_get_raw_fingerprint(ChromaprintContext *ctx, void **fingerprint, int *size);
+
+/**
+ * Compress and optionally base64-encode a raw fingerprint
+ *
+ * The caller is responsible for freeing the returned pointer using
+ * chromaprint_dealloc().
+ *
+ * Parameters:
+ * - fp: pointer to an array of 32-bit integers representing the raw
+ * fingerprint to be encoded
+ * - size: number of items in the raw fingerprint
+ * - algorithm: Chromaprint algorithm version which was used to generate the
+ * raw fingerprint
+ * - encoded_fp: pointer to a pointer, where the encoded fingerprint will be
+ * stored
+ * - encoded_size: size of the encoded fingerprint in bytes
+ * - base64: Whether to return binary data or base64-encoded ASCII data. The
+ * compressed fingerprint will be encoded using base64 with the
+ * URL-safe scheme if you set this parameter to 1. It will return
+ * binary data if it's 0.
+ *
+ * Returns:
+ * - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_encode_fingerprint(void *fp, int size, int algorithm, void **encoded_fp, int *encoded_size, int base64);
+
+/**
+ * Uncompress and optionally base64-decode an encoded fingerprint
+ *
+ * The caller is responsible for freeing the returned pointer using
+ * chromaprint_dealloc().
+ *
+ * Parameters:
+ * - encoded_fp: Pointer to an encoded fingerprint
+ * - encoded_size: Size of the encoded fingerprint in bytes
+ * - fp: Pointer to a pointer, where the decoded raw fingerprint (array
+ * of 32-bit integers) will be stored
+ * - size: Number of items in the returned raw fingerprint
+ * - algorithm: Chromaprint algorithm version which was used to generate the
+ * raw fingerprint
+ * - base64: Whether the encoded_fp parameter contains binary data or
+ * base64-encoded ASCII data. If 1, it will base64-decode the data
+ * before uncompressing the fingerprint.
+ *
+ * Returns:
+ * - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_decode_fingerprint(void *encoded_fp, int encoded_size, void **fp, int *size, int *algorithm, int base64);
+
+/**
+ * Free memory allocated by any function from the Chromaprint API.
+ *
+ * Parameters:
+ * - ptr: Pointer to be deallocated
+ */
+CHROMAPRINT_API void chromaprint_dealloc(void *ptr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/3rdparty/chromaprint/src/classifier.h b/3rdparty/chromaprint/src/classifier.h
new file mode 100644
index 000000000..919e64273
--- /dev/null
+++ b/3rdparty/chromaprint/src/classifier.h
@@ -0,0 +1,61 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_CLASSIFIER_H_
+#define CHROMAPRINT_CLASSIFIER_H_
+
+#include
+#include "quantizer.h"
+#include "filter.h"
+#include "integral_image.h"
+
+namespace Chromaprint
+{
+
+ class Classifier
+ {
+ public:
+ Classifier(const Filter &filter = Filter(), const Quantizer &quantizer = Quantizer())
+ : m_filter(filter), m_quantizer(quantizer)
+ {
+ }
+
+ int Classify(IntegralImage *image, int offset) const
+ {
+ double value = m_filter.Apply(image, offset);
+ return m_quantizer.Quantize(value);
+ }
+
+ const Filter &filter() const { return m_filter; }
+ const Quantizer &quantizer() const { return m_quantizer; }
+
+ private:
+ Filter m_filter;
+ Quantizer m_quantizer;
+ };
+
+ inline std::ostream &operator<<(std::ostream &stream, const Classifier &q)
+ {
+ stream << "Classifier(" << q.filter() << ", " << q.quantizer() << ")";
+ return stream;
+ }
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/combined_buffer.h b/3rdparty/chromaprint/src/combined_buffer.h
new file mode 100644
index 000000000..68eb3fbbc
--- /dev/null
+++ b/3rdparty/chromaprint/src/combined_buffer.h
@@ -0,0 +1,176 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_COMBINED_BUFFER_H_
+#define CHROMAPRINT_COMBINED_BUFFER_H_
+
+#include
+#include
+#include
+
+namespace Chromaprint
+{
+
+ template
+ class CombinedBuffer;
+
+ template
+ class _CombinedBufferIterator
+ {
+ public:
+ typedef std::input_iterator_tag iterator_category;
+ typedef T value_type;
+ typedef int difference_type;
+ typedef T* pointer;
+ typedef T& reference;
+
+ _CombinedBufferIterator(CombinedBuffer *buffer = 0, int pos = 0)
+ : m_buffer(buffer)
+ {
+ pos += buffer->Offset();
+ if (pos < buffer->BufferSize(0)) {
+ m_ptr = buffer->Buffer(0) + pos;
+ m_ptr_end = buffer->Buffer(0) + buffer->BufferSize(0);
+ }
+ else {
+ pos -= buffer->BufferSize(0);
+ m_ptr = buffer->Buffer(1) + pos;
+ m_ptr_end = buffer->Buffer(1) + buffer->BufferSize(1);
+ }
+ }
+
+ _CombinedBufferIterator &operator=(const _CombinedBufferIterator &rhs)
+ {
+ m_buffer = rhs.m_buffer;
+ m_ptr = rhs.m_ptr;
+ m_ptr_end = rhs.m_pre_end;
+ return *this;
+ }
+
+ bool operator==(const _CombinedBufferIterator &rhs) const
+ {
+ return (m_ptr == rhs.m_ptr) && (m_buffer == rhs.m_buffer);
+ }
+
+ bool operator!=(const _CombinedBufferIterator &rhs) const
+ {
+ return !(operator==(rhs));
+ }
+
+ void operator++()
+ {
+ ++m_ptr;
+ if (m_ptr >= m_ptr_end) {
+ if (m_ptr_end == m_buffer->Buffer(0) + m_buffer->BufferSize(0)) {
+ m_ptr = m_buffer->Buffer(1);
+ m_ptr_end = m_buffer->Buffer(1) + m_buffer->BufferSize(1);
+ }
+ }
+ }
+
+ void operator++(int)
+ {
+ ++(*this);
+ }
+
+ short &operator*()
+ {
+ assert(m_ptr);
+ return *m_ptr;
+ }
+
+ private:
+ CombinedBuffer *m_buffer;
+ T *m_ptr_end;
+ T *m_ptr;
+ };
+
+ template
+ class CombinedBuffer
+ {
+ public:
+ typedef _CombinedBufferIterator Iterator;
+
+ CombinedBuffer(T *buffer1, int size1, T *buffer2, int size2)
+ : m_offset(0)
+ {
+ m_buffer[0] = buffer1;
+ m_buffer[1] = buffer2;
+ m_buffer[2] = 0;
+ m_size[0] = size1;
+ m_size[1] = size2;
+ m_size[2] = -1;
+ }
+
+ int Size()
+ {
+ return m_size[0] + m_size[1] - m_offset;
+ }
+
+ int Shift(int shift)
+ {
+ m_offset += shift;
+ return m_offset;
+ }
+
+ int Offset() const
+ {
+ return m_offset;
+ }
+
+ Iterator Begin()
+ {
+ return Iterator(this, 0);
+ }
+
+ Iterator End()
+ {
+ return Iterator(this, Size());
+ }
+
+ T &operator[](int i)
+ {
+ i += m_offset;
+ if (i < m_size[0]) {
+ return m_buffer[0][i];
+ }
+ i -= m_size[0];
+ return m_buffer[1][i];
+ }
+
+ T *Buffer(int i)
+ {
+ return m_buffer[i];
+ }
+
+ int BufferSize(int i)
+ {
+ return m_size[i];
+ }
+
+ private:
+ T *m_buffer[3];
+ int m_size[3];
+ int m_offset;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/debug.h b/3rdparty/chromaprint/src/debug.h
new file mode 100644
index 000000000..075cdf8cf
--- /dev/null
+++ b/3rdparty/chromaprint/src/debug.h
@@ -0,0 +1,42 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_DEBUG_H_
+#define CHROMAPRINT_DEBUG_H_
+
+#ifdef NDEBUG
+#include
+#else
+#include
+#endif
+
+namespace Chromaprint
+{
+
+#ifdef NDEBUG
+extern std::ostream noop_ostream;
+#define DEBUG() if (true) {} else noop_ostream
+#else
+#define DEBUG() std::cerr
+#endif
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/decoder.h b/3rdparty/chromaprint/src/decoder.h
new file mode 100644
index 000000000..77e24fbfb
--- /dev/null
+++ b/3rdparty/chromaprint/src/decoder.h
@@ -0,0 +1,15 @@
+#ifndef CHROMAPRINT_DECODER_H_
+#define CHROMAPRINT_DECODER_H_
+
+namespace Chromaprint
+{
+
+ class Decoder
+ {
+ public:
+
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/ext/audio_dumper.h b/3rdparty/chromaprint/src/ext/audio_dumper.h
new file mode 100644
index 000000000..b7795b6e6
--- /dev/null
+++ b/3rdparty/chromaprint/src/ext/audio_dumper.h
@@ -0,0 +1,30 @@
+#ifndef CHROMAPRINT_EXT_AUDIO_DUMPER_H_
+#define CHROMAPRINT_EXT_AUDIO_DUMPER_H_
+
+#include
+#include
+#include "audio_consumer.h"
+
+class AudioDumper : public Chromaprint::AudioConsumer
+{
+public:
+ AudioDumper(const std::string &file_name)
+ {
+ m_file = fopen(file_name.c_str(), "wb");
+ }
+
+ ~AudioDumper()
+ {
+ fclose(m_file);
+ }
+
+ void Consume(short *input, int length)
+ {
+ fwrite(input, sizeof(short), length, m_file);
+ }
+
+private:
+ FILE *m_file;
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/ext/ffmpeg_decoder.h b/3rdparty/chromaprint/src/ext/ffmpeg_decoder.h
new file mode 100644
index 000000000..f8d34c714
--- /dev/null
+++ b/3rdparty/chromaprint/src/ext/ffmpeg_decoder.h
@@ -0,0 +1,230 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef FFMPEG_DECODER_H_
+#define FFMPEG_DECODER_H_
+
+#include
+extern "C" {
+#include
+#include
+}
+#include "audio_consumer.h"
+
+class Decoder
+{
+public:
+ Decoder(const std::string &file_name);
+ ~Decoder();
+
+ bool Open();
+ void Decode(Chromaprint::AudioConsumer *consumer, int max_length = 0);
+
+ int Channels()
+ {
+ return m_codec_ctx->channels;
+ }
+
+ int SampleRate()
+ {
+ return m_codec_ctx->sample_rate;
+ }
+
+ std::string LastError()
+ {
+ return m_error;
+ }
+
+private:
+ static const int BUFFER_SIZE = AVCODEC_MAX_AUDIO_FRAME_SIZE * 2;
+ uint8_t *m_buffer1;
+ uint8_t *m_buffer2;
+ std::string m_file_name;
+ std::string m_error;
+ AVFormatContext *m_format_ctx;
+ AVCodecContext *m_codec_ctx;
+ AVStream *m_stream;
+ //AVAudioConvert *m_convert_ctx;
+};
+
+inline Decoder::Decoder(const std::string &file_name)
+ : m_file_name(file_name), m_format_ctx(0), m_codec_ctx(0), m_stream(0)
+ /*, m_convert_ctx(0)*/
+{
+ av_register_all();
+ av_log_set_level(AV_LOG_ERROR);
+ m_buffer1 = (uint8_t *)av_malloc(BUFFER_SIZE);
+ m_buffer2 = (uint8_t *)av_malloc(BUFFER_SIZE);
+}
+
+inline Decoder::~Decoder()
+{
+ if (m_codec_ctx) {
+ avcodec_close(m_codec_ctx);
+ }
+ if (m_format_ctx) {
+ av_close_input_file(m_format_ctx);
+ }
+ //av_audio_convert_free(m_convert_ctx);
+ av_free(m_buffer2);
+ av_free(m_buffer1);
+}
+
+inline bool Decoder::Open()
+{
+ if (av_open_input_file(&m_format_ctx, m_file_name.c_str(), NULL, 0, NULL) != 0) {
+ m_error = "Couldn't open the file." + m_file_name;
+ return false;
+ }
+
+ if (av_find_stream_info(m_format_ctx) < 0) {
+ m_error = "Couldn't find stream information in the file.";
+ return false;
+ }
+
+ //dump_format(m_format_ctx, 0, m_file_name.c_str(), 0);
+
+ for (size_t i = 0; i < m_format_ctx->nb_streams; i++) {
+ AVCodecContext *avctx = m_format_ctx->streams[i]->codec;
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52, 20, 0)
+ if (avctx && avctx->codec_type == CODEC_TYPE_AUDIO) {
+#else
+ if (avctx && avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+#endif
+ m_stream = m_format_ctx->streams[i];
+ m_codec_ctx = avctx;
+ break;
+ }
+ }
+ if (!m_codec_ctx) {
+ m_error = "Couldn't find any audio stream in the file.";
+ return false;
+ }
+
+ AVCodec *codec = avcodec_find_decoder(m_codec_ctx->codec_id);
+ if (!codec) {
+ m_error = "Unknown codec.";
+ return false;
+ }
+
+ if (avcodec_open(m_codec_ctx, codec) < 0) {
+ m_error = "Couldn't open the codec.";
+ return false;
+ }
+
+ if (m_codec_ctx->sample_fmt != SAMPLE_FMT_S16) {
+ m_error = "Unsupported sample format.\n";
+ return false;
+ }
+ /*m_convert_ctx = av_audio_convert_alloc(SAMPLE_FMT_S16, 1,
+ m_codec_ctx->sample_fmt, 1,
+ NULL, 0);
+ if (!m_convert_ctx) {
+ m_error = "Cannot create sample format converter.";
+ return false;
+ }*/
+
+ if (Channels() <= 0) {
+ m_error = "Invalid audio stream (no channels).\n";
+ return false;
+ }
+
+ return true;
+}
+
+#include
+
+inline void Decoder::Decode(Chromaprint::AudioConsumer *consumer, int max_length)
+{
+ AVPacket packet, packet_temp;
+
+ int remaining = max_length * SampleRate() * Channels();
+ int stop = 0;
+
+ av_init_packet(&packet);
+ av_init_packet(&packet_temp);
+ while (!stop) {
+ if (av_read_frame(m_format_ctx, &packet) < 0) {
+ // consumer->Flush();
+ break;
+ }
+
+ packet_temp.data = packet.data;
+ packet_temp.size = packet.size;
+ while (packet_temp.size > 0) {
+ int buffer_size = BUFFER_SIZE;
+#if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52, 20, 0)
+ int consumed = avcodec_decode_audio2(
+ m_codec_ctx, (int16_t *)m_buffer1, &buffer_size,
+ packet_temp.data, packet_temp.size);
+#else
+ int consumed = avcodec_decode_audio3(
+ m_codec_ctx, (int16_t *)m_buffer1, &buffer_size,
+ &packet_temp);
+#endif
+
+ if (consumed < 0) {
+ break;
+ }
+
+ packet_temp.data += consumed;
+ packet_temp.size -= consumed;
+
+ if (buffer_size <= 0) {
+ continue;
+ }
+
+ int length = buffer_size / 2;
+ int16_t *audio_buffer = (int16_t *)m_buffer1;
+
+ /*if (m_convert_ctx) {
+ const void *ibuf[6] = { m_buffer1 };
+ void *obuf[6] = { m_buffer2 };
+ int istride[6] = { av_get_bits_per_sample_format(m_codec_ctx->sample_fmt) / 8 };
+ int ostride[6] = { 2 };
+ if (av_audio_convert(m_convert_ctx, obuf, ostride, ibuf, istride, len) < 0) {
+ break;
+ }
+ length = buffer_size / istride[0];
+ audio_buffer = (int16_t *)m_buffer2;
+ }*/
+
+ if (max_length) {
+ length = std::min(remaining, length);
+ }
+
+ consumer->Consume(audio_buffer, length);
+
+ if (max_length) {
+ remaining -= length;
+ if (remaining <= 0) {
+ stop = 1;
+ break;
+ }
+ }
+ }
+
+ if (packet.data) {
+ av_free_packet(&packet);
+ }
+ }
+}
+
+#endif
diff --git a/3rdparty/chromaprint/src/ext/image_utils.cpp b/3rdparty/chromaprint/src/ext/image_utils.cpp
new file mode 100644
index 000000000..3bcdd7a41
--- /dev/null
+++ b/3rdparty/chromaprint/src/ext/image_utils.cpp
@@ -0,0 +1,27 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include "image_utils.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+
diff --git a/3rdparty/chromaprint/src/ext/image_utils.h b/3rdparty/chromaprint/src/ext/image_utils.h
new file mode 100644
index 000000000..a0e702788
--- /dev/null
+++ b/3rdparty/chromaprint/src/ext/image_utils.h
@@ -0,0 +1,108 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_EXT_IMAGE_UTILS_H_
+#define CHROMAPRINT_EXT_IMAGE_UTILS_H_
+
+#include
+#include
+#include
+#include
+#include
+#include "image.h"
+
+namespace Chromaprint
+{
+
+ //! Export image to a PNG file
+ inline void ExportImage(Image *data, const std::string &file_name, double power = 1.0)
+ {
+ static const int kNumColors = 6;
+ static int colors[][3] = {
+ { 0, 0, 0 },
+ { 218, 38, 0 },
+ { 221, 99, 0 },
+ { 255, 253, 0 },
+ { 255, 254, 83 },
+ { 255, 255, 200 },
+ { 255, 255, 255 },
+ };
+
+ png::image image(data->NumRows(), data->NumColumns());
+ double min_value = (*data)[0][0], max_value = (*data)[0][0];
+ for (size_t y = 0; y < data->NumRows(); y++) {
+ for (size_t x = 0; x < data->NumColumns(); x++) {
+ double value = (*data)[y][x];
+ min_value = std::min(min_value, value);
+ max_value = std::max(max_value, value);
+ }
+ }
+ //std::cout << "min_value=" << min_value << "\n";
+ //std::cout << "max_value=" << max_value << "\n";
+ for (size_t y = 0; y < data->NumRows(); y++) {
+ for (size_t x = 0; x < data->NumColumns(); x++) {
+ double value = ((*data)[y][x] - min_value) / (max_value - min_value);
+ value = pow(value, power);
+ double color_value = kNumColors * value;
+ int color_index = int(color_value);
+ double color_alpha = color_value - color_index;
+ if (color_index < 0) {
+ color_index = 0;
+ color_alpha = 0;
+ }
+ else if (color_index > kNumColors) {
+ color_index = kNumColors;
+ color_alpha = 0;
+ }
+ //std::cout << "value=" << color_value << "\n";
+ //std::cout << "alpha=" << color_alpha << "\n";
+ int r = colors[color_index][0] + (colors[color_index+1][0] - colors[color_index][0]) * color_alpha;
+ int g = colors[color_index][1] + (colors[color_index+1][1] - colors[color_index][1]) * color_alpha;
+ int b = colors[color_index][2] + (colors[color_index+1][2] - colors[color_index][2]) * color_alpha;
+ //int color = 255 * vlue + 0.5;
+ image[data->NumColumns()-x-1][y] = png::rgb_pixel(r, g, b);
+ }
+ }
+ image.write(file_name);
+ }
+
+ //! Export image in a text format (floating point numbers) to any stream
+ template
+ void ExportTextImage(ImageType *image, std::ostream &stream)
+ {
+ for (int i = 0; i < image->NumRows(); i++) {
+ for (int j = 0; j < image->NumColumns(); j++) {
+ stream << image->Row(i)[j] << " ";
+ }
+ stream << "\n";
+ }
+ }
+
+ //! Export image in a text format (floating point numbers) to a file
+ template
+ void ExportTextImage(ImageType *image, const std::string &file_name)
+ {
+ std::fstream out(file_name.c_str(), std::ios::out);
+ ExportTextImage(image, out);
+ }
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/ext/sox_decoder.h b/3rdparty/chromaprint/src/ext/sox_decoder.h
new file mode 100644
index 000000000..8cf0cfe82
--- /dev/null
+++ b/3rdparty/chromaprint/src/ext/sox_decoder.h
@@ -0,0 +1,101 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef FFMPEG_DECODER_H_
+#define FFMPEG_DECODER_H_
+
+#include
+extern "C" {
+#include
+#include
+}
+#include "sox_audio_source.h"
+#include "audio_consumer.h"
+
+class Decoder
+{
+public:
+ Decoder(const std::string &file_name);
+ ~Decoder();
+
+ bool Open();
+ void Decode(Chromaprint::AudioConsumer *consumer, int max_length = 0);
+
+ int Channels()
+ {
+ return m_source->Channels();
+ }
+
+ int SampleRate()
+ {
+ return m_source->SampleRate();
+ }
+
+ std::string LastError()
+ {
+ return "";
+ // return m_error;
+ }
+
+private:
+ SoxAudioSource *m_source;
+ short m_buffer[1024];
+};
+
+inline Decoder::Decoder(const std::string &file_name)
+{
+ m_source = new SoxAudioSource(file_name);
+ m_source->Open();
+}
+
+inline Decoder::~Decoder()
+{
+ delete m_source;
+}
+
+inline bool Decoder::Open()
+{
+ return true;
+}
+
+#include
+
+inline void Decoder::Decode(Chromaprint::AudioConsumer *consumer, int max_length)
+{
+ int remaining = SampleRate() * Channels() * max_length;
+ while (true) {
+ int res = m_source->Read(m_buffer, size_t(1024));
+ if (res <= 0) {
+ break;
+ }
+ if (max_length) {
+ res = std::min(res, remaining);
+ }
+ consumer->Consume(m_buffer, res);
+ if (max_length) {
+ remaining -= res;
+ if (res <= 0) {
+ break;
+ }
+ }
+ }
+}
+
+#endif
diff --git a/3rdparty/chromaprint/src/feature_vector_consumer.h b/3rdparty/chromaprint/src/feature_vector_consumer.h
new file mode 100644
index 000000000..305aed970
--- /dev/null
+++ b/3rdparty/chromaprint/src/feature_vector_consumer.h
@@ -0,0 +1,39 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FEATURE_VECTOR_CONSUMER_H_
+#define CHROMAPRINT_FEATURE_VECTOR_CONSUMER_H_
+
+#include
+
+namespace Chromaprint
+{
+
+ class FeatureVectorConsumer
+ {
+ public:
+ virtual ~FeatureVectorConsumer() {}
+ virtual void Consume(std::vector &features) = 0;
+ };
+
+};
+
+#endif
+
diff --git a/3rdparty/chromaprint/src/fft.cpp b/3rdparty/chromaprint/src/fft.cpp
new file mode 100644
index 000000000..406f8a969
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft.cpp
@@ -0,0 +1,77 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include "utils.h"
+#include "fft_lib.h"
+#include "fft.h"
+#include "debug.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+FFT::FFT(int frame_size, int overlap, FFTFrameConsumer *consumer)
+ : m_window(new double[frame_size]),
+ m_buffer_offset(0),
+ m_buffer(new short[frame_size]),
+ m_frame(frame_size),
+ m_frame_size(frame_size),
+ m_increment(frame_size - overlap),
+ m_consumer(consumer)
+{
+ PrepareHammingWindow(m_window, m_window + frame_size);
+ for (int i = 0; i < frame_size; i++) {
+ m_window[i] /= numeric_limits::max();
+ }
+ m_lib = new FFTLib(frame_size, m_window);
+}
+
+FFT::~FFT()
+{
+ delete m_lib;
+ delete[] m_buffer;
+ delete[] m_window;
+}
+
+void FFT::Reset()
+{
+ m_buffer_offset = 0;
+}
+
+void FFT::Consume(short *input, int length)
+{
+ // Special case, just pre-filling the buffer
+ if (m_buffer_offset + length < m_frame_size) {
+ copy(input, input + length, m_buffer + m_buffer_offset);
+ m_buffer_offset += length;
+ return;
+ }
+ // Apply FFT on the available data
+ CombinedBuffer combined_buffer(m_buffer, m_buffer_offset, input, length);
+ while (combined_buffer.Size() >= m_frame_size) {
+ m_lib->ComputeFrame(combined_buffer.Begin(), m_frame.data());
+ m_consumer->Consume(m_frame);
+ combined_buffer.Shift(m_increment);
+ }
+ // Copy the remaining input data to the internal buffer
+ copy(combined_buffer.Begin(), combined_buffer.End(), m_buffer);
+ m_buffer_offset = combined_buffer.Size();
+}
+
diff --git a/3rdparty/chromaprint/src/fft.h b/3rdparty/chromaprint/src/fft.h
new file mode 100644
index 000000000..4657e9195
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft.h
@@ -0,0 +1,62 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FFT_H_
+#define CHROMAPRINT_FFT_H_
+
+#include
+#include "utils.h"
+#include "fft_frame.h"
+#include "fft_frame_consumer.h"
+#include "audio_consumer.h"
+#include "combined_buffer.h"
+
+namespace Chromaprint
+{
+ class FFTLib;
+
+ class FFT : public AudioConsumer
+ {
+ public:
+ FFT(int frame_size, int overlap, FFTFrameConsumer *consumer);
+ ~FFT();
+
+ int FrameSize() const { return m_frame_size; }
+ int Overlap() const { return m_frame_size - m_increment; }
+
+ void Reset();
+ void Consume(short *input, int length);
+
+ private:
+ CHROMAPRINT_DISABLE_COPY(FFT);
+
+ double *m_window;
+ int m_buffer_offset;
+ short *m_buffer;
+ FFTFrame m_frame;
+ int m_frame_size;
+ int m_increment;
+ FFTLib *m_lib;
+ FFTFrameConsumer *m_consumer;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/fft_frame.h b/3rdparty/chromaprint/src/fft_frame.h
new file mode 100644
index 000000000..d39dddcf9
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_frame.h
@@ -0,0 +1,69 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FFT_FRAME_H_
+#define CHROMAPRINT_FFT_FRAME_H_
+
+#include
+
+namespace Chromaprint
+{
+
+ class FFTFrame
+ {
+ public:
+ FFTFrame(int size) : m_size(size)
+ {
+ m_data = new double[size];
+ }
+
+ ~FFTFrame()
+ {
+ delete[] m_data;
+ }
+
+ double Magnitude(int i) const
+ {
+ return sqrt(Energy(i));
+ }
+
+ double Energy(int i) const
+ {
+ return m_data[i];
+ }
+
+ int size() const
+ {
+ return m_size;
+ }
+
+ double *data()
+ {
+ return m_data;
+ }
+
+ private:
+ double *m_data;
+ int m_size;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/fft_frame_consumer.h b/3rdparty/chromaprint/src/fft_frame_consumer.h
new file mode 100644
index 000000000..9952232ea
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_frame_consumer.h
@@ -0,0 +1,38 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FFT_FRAME_CONSUMER_H_
+#define CHROMAPRINT_FFT_FRAME_CONSUMER_H_
+
+namespace Chromaprint
+{
+
+ class FFTFrame;
+
+ class FFTFrameConsumer
+ {
+ public:
+ virtual ~FFTFrameConsumer() {}
+ virtual void Consume(const FFTFrame &frame) = 0;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/fft_lib.h b/3rdparty/chromaprint/src/fft_lib.h
new file mode 100644
index 000000000..dc621a3aa
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_lib.h
@@ -0,0 +1,40 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FFT_LIB_H_
+#define CHROMAPRINT_FFT_LIB_H_
+
+#ifdef HAVE_CONFIG_H
+#include
+#endif
+
+#ifdef WITH_AVFFT
+#include "fft_lib_avfft.h"
+#endif
+
+#ifdef WITH_FFTW3
+#include "fft_lib_fftw3.h"
+#endif
+
+#ifdef WITH_VDSP
+#include "fft_lib_vdsp.h"
+#endif
+
+#endif
diff --git a/3rdparty/chromaprint/src/fft_lib_avfft.cpp b/3rdparty/chromaprint/src/fft_lib_avfft.cpp
new file mode 100644
index 000000000..768440084
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_lib_avfft.cpp
@@ -0,0 +1,60 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include "utils.h"
+#include "fft_lib_avfft.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+FFTLib::FFTLib(int frame_size, double *window)
+ : m_window(window),
+ m_frame_size(frame_size)
+{
+ m_input = (float *)av_mallocz(sizeof(float) * frame_size);
+ int bits = -1;
+ while (frame_size) {
+ bits++;
+ frame_size >>= 1;
+ }
+ m_rdft_ctx = av_rdft_init(bits, DFT_R2C);
+}
+
+FFTLib::~FFTLib()
+{
+ av_rdft_end(m_rdft_ctx);
+ av_free(m_input);
+}
+
+void FFTLib::ComputeFrame(CombinedBuffer::Iterator input, double *output)
+{
+ ApplyWindow(input, m_window, m_input, m_frame_size, 1.0);
+ av_rdft_calc(m_rdft_ctx, m_input);
+ float *in_ptr = m_input;
+ output[0] = in_ptr[0] * in_ptr[0];
+ output[m_frame_size / 2] = in_ptr[1] * in_ptr[1];
+ output += 1;
+ in_ptr += 2;
+ for (int i = 1; i < m_frame_size / 2; i++) {
+ *output++ = in_ptr[0] * in_ptr[0] + in_ptr[1] * in_ptr[1];
+ in_ptr += 2;
+ }
+}
+
diff --git a/3rdparty/chromaprint/src/fft_lib_avfft.h b/3rdparty/chromaprint/src/fft_lib_avfft.h
new file mode 100644
index 000000000..87c8034d4
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_lib_avfft.h
@@ -0,0 +1,53 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FFT_LIB_AVFFT_H_
+#define CHROMAPRINT_FFT_LIB_AVFFT_H_
+
+#include
+extern "C" {
+#include
+#include
+}
+#include "combined_buffer.h"
+
+namespace Chromaprint
+{
+
+ class FFTLib
+ {
+ public:
+ FFTLib(int frame_size, double *window);
+ ~FFTLib();
+
+ void ComputeFrame(CombinedBuffer::Iterator input, double *output);
+
+ private:
+ CHROMAPRINT_DISABLE_COPY(FFTLib);
+
+ double *m_window;
+ int m_frame_size;
+ float *m_input;
+ RDFTContext *m_rdft_ctx;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/fft_lib_fftw3.cpp b/3rdparty/chromaprint/src/fft_lib_fftw3.cpp
new file mode 100644
index 000000000..f8beb21c0
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_lib_fftw3.cpp
@@ -0,0 +1,58 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include "utils.h"
+#include "fft_lib_fftw3.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+FFTLib::FFTLib(int frame_size, double *window)
+ : m_frame_size(frame_size),
+ m_window(window)
+{
+ m_input = (double *)fftw_malloc(sizeof(double) * frame_size);
+ m_output = (double *)fftw_malloc(sizeof(double) * frame_size);
+ m_plan = fftw_plan_r2r_1d(frame_size, m_input, m_output, FFTW_R2HC, FFTW_ESTIMATE);
+}
+
+FFTLib::~FFTLib()
+{
+ fftw_destroy_plan(m_plan);
+ fftw_free(m_input);
+ fftw_free(m_output);
+}
+
+void FFTLib::ComputeFrame(CombinedBuffer::Iterator input, double *output)
+{
+ ApplyWindow(input, m_window, m_input, m_frame_size, 1.0);
+ fftw_execute(m_plan);
+ double *in_ptr = m_output;
+ double *rev_in_ptr = m_output + m_frame_size - 1;
+ output[0] = in_ptr[0] * in_ptr[0];
+ output[m_frame_size / 2] = in_ptr[m_frame_size / 2] * in_ptr[m_frame_size / 2];
+ in_ptr += 1;
+ output += 1;
+ for (int i = 1; i < m_frame_size / 2; i++) {
+ *output++ = in_ptr[0] * in_ptr[0] + rev_in_ptr[0] * rev_in_ptr[0];
+ in_ptr++;
+ rev_in_ptr--;
+ }
+}
diff --git a/3rdparty/chromaprint/src/fft_lib_fftw3.h b/3rdparty/chromaprint/src/fft_lib_fftw3.h
new file mode 100644
index 000000000..a21a564d3
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_lib_fftw3.h
@@ -0,0 +1,51 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FFT_LIB_FFTW3_H_
+#define CHROMAPRINT_FFT_LIB_FFTW3_H_
+
+#include
+#include
+#include "combined_buffer.h"
+
+namespace Chromaprint
+{
+
+ class FFTLib
+ {
+ public:
+ FFTLib(int frame_size, double *window);
+ ~FFTLib();
+
+ void ComputeFrame(CombinedBuffer::Iterator input, double *output);
+
+ private:
+ CHROMAPRINT_DISABLE_COPY(FFTLib);
+
+ double *m_window;
+ int m_frame_size;
+ double *m_input;
+ double *m_output;
+ fftw_plan m_plan;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/fft_lib_vdsp.cpp b/3rdparty/chromaprint/src/fft_lib_vdsp.cpp
new file mode 100644
index 000000000..a15e6199a
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_lib_vdsp.cpp
@@ -0,0 +1,61 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2011 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include "utils.h"
+#include "fft_lib_vdsp.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+FFTLib::FFTLib(int frame_size, double *window)
+ : m_window(window),
+ m_frame_size(frame_size)
+{
+ double log2n = log2(frame_size);
+ assert(log2n == int(log2n));
+ m_log2n = int(log2n);
+ m_input = new float[frame_size];
+ m_a.realp = new float[frame_size / 2];
+ m_a.imagp = new float[frame_size / 2];
+ m_setup = vDSP_create_fftsetup(m_log2n, 0);
+}
+
+FFTLib::~FFTLib()
+{
+ vDSP_destroy_fftsetup(m_setup);
+ delete[] m_a.realp;
+ delete[] m_a.imagp;
+ delete[] m_input;
+}
+
+void FFTLib::ComputeFrame(CombinedBuffer::Iterator input, double *output)
+{
+ ApplyWindow(input, m_window, m_input, m_frame_size, 1.0);
+ // XXX we can avoid this ctoz call by changing ApplyWindow, is it worth it?
+ vDSP_ctoz((DSPComplex *)m_input, 2, &m_a, 1, m_frame_size / 2);
+ vDSP_fft_zrip(m_setup, &m_a, 1, m_log2n, FFT_FORWARD);
+ output[0] = m_a.realp[0] * m_a.realp[0];
+ output[m_frame_size / 2] = m_a.imagp[0] * m_a.imagp[0];
+ output += 1;
+ for (int i = 1; i < m_frame_size / 2; i++) {
+ *output++ = m_a.realp[i] * m_a.realp[i] + m_a.imagp[i] * m_a.imagp[i];
+ }
+}
+
diff --git a/3rdparty/chromaprint/src/fft_lib_vdsp.h b/3rdparty/chromaprint/src/fft_lib_vdsp.h
new file mode 100644
index 000000000..dd7fcc335
--- /dev/null
+++ b/3rdparty/chromaprint/src/fft_lib_vdsp.h
@@ -0,0 +1,52 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2011 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FFT_LIB_VDSP_H_
+#define CHROMAPRINT_FFT_LIB_VDSP_H_
+
+#include
+#include
+#include "combined_buffer.h"
+
+namespace Chromaprint
+{
+
+ class FFTLib
+ {
+ public:
+ FFTLib(int frame_size, double *window);
+ ~FFTLib();
+
+ void ComputeFrame(CombinedBuffer::Iterator input, double *output);
+
+ private:
+ CHROMAPRINT_DISABLE_COPY(FFTLib);
+
+ double *m_window;
+ float *m_input;
+ int m_frame_size;
+ int m_log2n;
+ FFTSetup m_setup;
+ DSPSplitComplex m_a;
+ };
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/filter.cpp b/3rdparty/chromaprint/src/filter.cpp
new file mode 100644
index 000000000..c87ae0f24
--- /dev/null
+++ b/3rdparty/chromaprint/src/filter.cpp
@@ -0,0 +1,47 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#include
+#include "filter.h"
+#include "filter_utils.h"
+
+using namespace std;
+using namespace Chromaprint;
+
+#define COMPARE_FUNC SubtractLog
+
+double Filter::Apply(IntegralImage *image, int x) const
+{
+ switch (m_type) {
+ case 0:
+ return Filter0(image, x, m_y, m_width, m_height, COMPARE_FUNC);
+ case 1:
+ return Filter1(image, x, m_y, m_width, m_height, COMPARE_FUNC);
+ case 2:
+ return Filter2(image, x, m_y, m_width, m_height, COMPARE_FUNC);
+ case 3:
+ return Filter3(image, x, m_y, m_width, m_height, COMPARE_FUNC);
+ case 4:
+ return Filter4(image, x, m_y, m_width, m_height, COMPARE_FUNC);
+ case 5:
+ return Filter5(image, x, m_y, m_width, m_height, COMPARE_FUNC);
+ }
+ return 0.0;
+}
diff --git a/3rdparty/chromaprint/src/filter.h b/3rdparty/chromaprint/src/filter.h
new file mode 100644
index 000000000..33899e9d5
--- /dev/null
+++ b/3rdparty/chromaprint/src/filter.h
@@ -0,0 +1,67 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ */
+
+#ifndef CHROMAPRINT_FILTER_H_
+#define CHROMAPRINT_FILTER_H_
+
+#include
+#include "integral_image.h"
+
+namespace Chromaprint
+{
+
+ class Filter
+ {
+ public:
+ Filter(int type = 0, int y = 0, int height = 0, int width = 0)
+ : m_type(type), m_y(y), m_height(height), m_width(width)
+ {}
+
+ double Apply(IntegralImage *image, int offset) const;
+
+ int type() const { return m_type; }
+ void set_type(int type) { m_type = type; }
+
+ int y() const { return m_y; }
+ void set_y(int y) { m_y = y; }
+
+ int height() const { return m_height; }
+ void set_height(int height) { m_height = height; }
+
+ int width() const { return m_width; }
+ void set_width(int width) { m_width = width; }
+
+ private:
+ int m_type;
+ int m_y;
+ int m_height;
+ int m_width;
+ };
+
+ inline std::ostream &operator<<(std::ostream &stream, const Filter &f)
+ {
+ stream << "Filter(" << f.type() << ", " << f.y() << ", "
+ << f.height() << ", " << f.width() << ")";
+ return stream;
+ }
+
+};
+
+#endif
diff --git a/3rdparty/chromaprint/src/filter_utils.h b/3rdparty/chromaprint/src/filter_utils.h
new file mode 100644
index 000000000..99dbaf50f
--- /dev/null
+++ b/3rdparty/chromaprint/src/filter_utils.h
@@ -0,0 +1,136 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2010 Lukas Lalinsky