Hello community,

here is the log from the commit of package chromaprint for openSUSE:Factory 
checked in at 2016-02-25 21:43:21
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/chromaprint (Old)
 and      /work/SRC/openSUSE:Factory/.chromaprint.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "chromaprint"

Changes:
--------
--- /work/SRC/openSUSE:Factory/chromaprint/chromaprint.changes  2015-12-20 
10:51:32.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.chromaprint.new/chromaprint.changes     
2016-02-25 21:43:26.000000000 +0100
@@ -1,0 +2,9 @@
+Mon Feb 15 12:33:23 UTC 2016 - [email protected]
+
+- Update to new upstream release 1.3.1
+* Support for ffmpeg 3.x
+* You can use use "-length 0" in fpcalc to get the full fingerprint
+* New function chromaprint_get_fingerprint_hash for calculating
+  SimHash from the fingerprint data
+
+-------------------------------------------------------------------

Old:
----
  chromaprint-1.2.tar.gz

New:
----
  chromaprint-1.3.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ chromaprint.spec ++++++
--- /var/tmp/diff_new_pack.cXfusD/_old  2016-02-25 21:43:28.000000000 +0100
+++ /var/tmp/diff_new_pack.cXfusD/_new  2016-02-25 21:43:28.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package chromaprint
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
 # Copyright (c) 2012 Pascal Bleser <[email protected]>
 #
 # All modifications and additions to the file contributed by third parties
@@ -17,10 +17,10 @@
 #
 
 
-%define soname      0
+%define soname      1
 %bcond_without ffmpeg
 Name:           chromaprint
-Version:        1.2
+Version:        1.3.1
 Release:        0
 Summary:        Audio Fingerprinting Library
 License:        GPL-2.0+

++++++ baselibs.conf ++++++
--- /var/tmp/diff_new_pack.cXfusD/_old  2016-02-25 21:43:28.000000000 +0100
+++ /var/tmp/diff_new_pack.cXfusD/_new  2016-02-25 21:43:28.000000000 +0100
@@ -1 +1 @@
-libchromaprint0
\ No newline at end of file
+libchromaprint1

++++++ chromaprint-1.2.tar.gz -> chromaprint-1.3.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/CMakeLists.txt 
new/chromaprint-1.3.1/CMakeLists.txt
--- old/chromaprint-1.2/CMakeLists.txt  2014-08-26 18:57:36.000000000 +0200
+++ new/chromaprint-1.3.1/CMakeLists.txt        2016-02-10 14:12:35.000000000 
+0100
@@ -1,15 +1,19 @@
 cmake_minimum_required(VERSION 2.6)
 
+if(POLICY CMP0048)
+    cmake_policy(SET CMP0048 OLD)
+endif()
+
 project(chromaprint)
-set(PROJECT_VERSION 1.2.0)
+set(PROJECT_VERSION 1.3.1)
 
 # 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  2)
-set(chromaprint_SOVERSION_REVISION 3)
-set(chromaprint_SOVERSION_AGE      2)
+set(chromaprint_SOVERSION_CURRENT  4)
+set(chromaprint_SOVERSION_REVISION 0)
+set(chromaprint_SOVERSION_AGE      3)
 
 math(EXPR chromaprint_SOVERSION_MAJOR "${chromaprint_SOVERSION_CURRENT} - 
${chromaprint_SOVERSION_AGE}")
 math(EXPR chromaprint_SOVERSION_MINOR "${chromaprint_SOVERSION_AGE}")
@@ -132,7 +136,7 @@
        message(STATUS "Using KissFFT for FFT calculations")
 endif()
 
-if(NOT APPLE AND NOT BUILD_FRAMEWORK)
+if(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()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/NEWS.txt 
new/chromaprint-1.3.1/NEWS.txt
--- old/chromaprint-1.2/NEWS.txt        2014-08-26 18:57:36.000000000 +0200
+++ new/chromaprint-1.3.1/NEWS.txt      2016-02-10 14:12:35.000000000 +0100
@@ -1,3 +1,20 @@
+Version 1.3.1 -- February 10, 2016
+==================================
+
+ - Fixed `fpcalc -length` to actually restrict fingerprints the requested 
length.
+ - Fixed SONAME version for the shared library.
+
+Version 1.3 -- February 2, 2016
+===============================
+
+ - You can use use "-length 0" in fpcalc to get the full fingerprint
+ - New function chromaprint_get_fingerprint_hash for calculating
+   SimHash from the fingerprint data
+ - Added info section to the fpcalc executable on Mac OS X
+ - Generate .pc (pkg-config) file on Mac OS X when not building a framework
+ - Removed use of some long deprecated FFmpeg APIs
+ - Some smaller bug fixes
+
 Version 1.2 -- August 26, 2014
 ==============================
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/cmake/modules/FindKissFFT.cmake 
new/chromaprint-1.3.1/cmake/modules/FindKissFFT.cmake
--- old/chromaprint-1.2/cmake/modules/FindKissFFT.cmake 1970-01-01 
01:00:00.000000000 +0100
+++ new/chromaprint-1.3.1/cmake/modules/FindKissFFT.cmake       2016-02-10 
14:12:35.000000000 +0100
@@ -0,0 +1,70 @@
+# 
+# Try to find Kiss FFT library  
+#
+# Defines the following variables:
+# 
+#   KISSFFT_FOUND - Found the Kiss FFT library
+#   KISSFFT_INCLUDE_DIRS - Include directories
+#   KISSFFT_SOURCES - Source code to include in your project
+#
+# Accepts the following variables as input:
+#
+#   KISSFFT_ROOT - (as CMake or environment variable)
+#                  The root directory of Kiss FFT sources
+#
+# =========================================================
+#
+# Copyright (C) 2014 Lukas Lalinsky <[email protected]>
+#
+# 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.
+#
+#  * The names of Kitware, Inc., the Insight Consortium, or the names of
+#    any consortium members, or of any contributors, may not be used to
+#    endorse or promote products derived from this software without
+#    specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER 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 AUTHORS 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.
+
+find_path(KISSFFT_SOURCE_DIR
+    NAMES
+        tools/kiss_fftr.h
+        tools/kiss_fftr.c
+    PATHS
+        $ENV{KISSFFT_ROOT}
+        ${KISSFFT_ROOT}
+    NO_DEFAULT_PATH
+    DOC "Kiss FFT tools headers"
+)
+mark_as_advanced(KISSFFT_SOURCE_DIR)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(KissFFT DEFAULT_MSG KISSFFT_SOURCE_DIR)
+
+if(KISSFFT_FOUND)
+    SET(KISSFFT_INCLUDE_DIRS
+        ${KISSFFT_SOURCE_DIR}
+        ${KISSFFT_SOURCE_DIR}/tools
+    )
+    SET(KISSFFT_SOURCES
+        ${KISSFFT_SOURCE_DIR}/kiss_fft.c
+        ${KISSFFT_SOURCE_DIR}/tools/kiss_fftr.c
+    )
+endif()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/examples/CMakeLists.txt 
new/chromaprint-1.3.1/examples/CMakeLists.txt
--- old/chromaprint-1.2/examples/CMakeLists.txt 2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/examples/CMakeLists.txt       2016-02-10 
14:12:35.000000000 +0100
@@ -1,6 +1,7 @@
 set(EXTRA_LIBS)
 if(APPLE)
     set(EXTRA_LIBS ${EXTRA_LIBS} -lz)
+    set(CMAKE_EXE_LINKER_FLAGS "-sectcreate __TEXT __info_plist 
${CMAKE_CURRENT_SOURCE_DIR}/Info.plist")
 endif()
 if(UNIX)
     set(EXTRA_LIBS ${EXTRA_LIBS} -lpthread -lm)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/examples/Info.plist 
new/chromaprint-1.3.1/examples/Info.plist
--- old/chromaprint-1.2/examples/Info.plist     1970-01-01 01:00:00.000000000 
+0100
+++ new/chromaprint-1.3.1/examples/Info.plist   2016-02-10 14:12:35.000000000 
+0100
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 
"http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
+<plist version="1.0">
+<dict>
+       <key>CFBundleDevelopmentRegion</key>
+       <string>English</string>
+       <key>CFBundleIdentifier</key>
+       <string>org.acoustid.fpcalc</string>
+       <key>CFBundleInfoDictionaryVersion</key>
+       <string>6.0</string>
+       <key>CFBundleName</key>
+       <string>fpcalc</string>
+       <key>CFBundleExecutable</key>
+       <string>fpcalc</string>
+       <key>CFBundleVersion</key>
+       <string>1.1</string>
+</dict>
+</plist>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/examples/fpcalc.c 
new/chromaprint-1.3.1/examples/fpcalc.c
--- old/chromaprint-1.2/examples/fpcalc.c       2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/examples/fpcalc.c     2016-02-10 14:12:35.000000000 
+0100
@@ -17,13 +17,29 @@
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 #define MIN(a, b) ((a) < (b) ? (a) : (b))
 
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 28, 0)
-#define avcodec_free_frame av_freep
+int64_t get_default_channel_layout(int nb_channels)
+{
+/* 51.8.0 for FFmpeg, 51.26.0 for libav. I don't know how to identify them,
+   so let's use the higher one. I really wish Ubuntu would stop being
+   stupid and just drop libav. */
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 26, 0)
+       return av_get_default_channel_layout(nb_channels);
+#else
+       switch (nb_channels) {
+               case 1:
+                       return AV_CH_LAYOUT_MONO;
+               case 2:
+                       return AV_CH_LAYOUT_STEREO;
+               default:
+                       return 0;
+       }
 #endif
+}
 
 int decode_audio_file(ChromaprintContext *chromaprint_ctx, const char 
*file_name, int max_length, int *duration)
 {
-       int ok = 0, remaining, length, consumed, codec_ctx_opened = 0, 
got_frame, stream_index;
+       int ok = 0, length, consumed, codec_ctx_opened = 0, got_frame, 
stream_index, last_chunk = 0;
+       unsigned long long remaining;
        AVFormatContext *format_ctx = NULL;
        AVCodecContext *codec_ctx = NULL;
        AVCodec *codec = NULL;
@@ -80,7 +96,7 @@
        if (codec_ctx->sample_fmt != AV_SAMPLE_FMT_S16) {
                int64_t channel_layout = codec_ctx->channel_layout;
                if (!channel_layout) {
-                       channel_layout = 
av_get_default_channel_layout(codec_ctx->channels);
+                       channel_layout = 
get_default_channel_layout(codec_ctx->channels);
                }
 #if defined(HAVE_SWRESAMPLE)
                convert_ctx = swr_alloc_set_opts(NULL,
@@ -131,7 +147,7 @@
        remaining = max_length * codec_ctx->channels * codec_ctx->sample_rate;
        chromaprint_start(chromaprint_ctx, codec_ctx->sample_rate, 
codec_ctx->channels);
 
-       frame = avcodec_alloc_frame();
+       frame = av_frame_alloc();
 
        while (1) {
                if (av_read_frame(format_ctx, &packet) < 0) {
@@ -139,7 +155,7 @@
                }
 
                if (packet.stream_index == stream_index) {
-                       avcodec_get_frame_defaults(frame);
+                       av_frame_unref(frame);
 
                        got_frame = 0;
                        consumed = avcodec_decode_audio4(codec_ctx, frame, 
&got_frame, &packet);
@@ -170,16 +186,22 @@
                                        }
                                        data = dst_data;
                                }
-                               length = MIN(remaining, frame->nb_samples * 
codec_ctx->channels);
+
+                               length = frame->nb_samples * 
codec_ctx->channels;
+                               if (max_length > 0) {
+                                       if (remaining < length) {
+                                               length = remaining;
+                                               last_chunk = 1;
+                                       }
+                               }
+                               remaining -= length;
+
                                if (!chromaprint_feed(chromaprint_ctx, data[0], 
length)) {
                                        goto done;
                                }
 
-                               if (max_length) {
-                                       remaining -= length;
-                                       if (remaining <= 0) {
-                                               goto finish;
-                                       }
+                               if (last_chunk) {
+                                       goto finish;
                                }
                        }
                }
@@ -196,7 +218,7 @@
 
 done:
        if (frame) {
-               avcodec_free_frame(&frame);
+               av_frame_free(&frame);
        }
        if (dst_data[0]) {
                av_freep(&dst_data[0]);
@@ -223,7 +245,7 @@
        int32_t *raw_fingerprint;
        char *file_name, *fingerprint, **file_names;
        ChromaprintContext *chromaprint_ctx;
-       int algo = CHROMAPRINT_ALGORITHM_DEFAULT, num_failed = 0;
+       int algo = CHROMAPRINT_ALGORITHM_DEFAULT, num_failed = 0, do_hash = 0;
 
        file_names = malloc(argc * sizeof(char *));
        for (i = 1; i < argc; i++) {
@@ -238,6 +260,9 @@
                else if (!strcmp(arg, "-raw")) {
                        raw = 1;
                }
+               else if (!strcmp(arg, "-hash")) {
+                       do_hash = 1;
+               }
                else if (!strcmp(arg, "-algo") && i + 1 < argc) {
                        const char *v = argv[++i];
                        if (!strcmp(v, "test1")) { algo = 
CHROMAPRINT_ALGORITHM_TEST1; }
@@ -263,6 +288,7 @@
                printf("  -length SECS  length of the audio data used for 
fingerprint calculation (default 120)\n");
                printf("  -raw          output the raw uncompressed 
fingerprint\n");
                printf("  -algo NAME    version of the fingerprint 
algorithm\n");
+               printf("  -hash         calculate also the fingerprint hash\n");
                return 2;
        }
 
@@ -317,6 +343,11 @@
                        printf("FINGERPRINT=%s\n", fingerprint);
                        chromaprint_dealloc(fingerprint);
                }
+        if (do_hash) {
+            int32_t hash = 0;
+            chromaprint_get_fingerprint_hash(chromaprint_ctx, &hash);
+            printf("HASH=%d\n", hash);
+        }
        }
 
        chromaprint_free(chromaprint_ctx);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/src/CMakeLists.txt 
new/chromaprint-1.3.1/src/CMakeLists.txt
--- old/chromaprint-1.2/src/CMakeLists.txt      2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/src/CMakeLists.txt    2016-02-10 14:12:35.000000000 
+0100
@@ -19,6 +19,8 @@
        fingerprinter.cpp
        image_builder.cpp
        lloyds.cpp
+       simhash.h
+       simhash.cpp
        silence_remover.cpp
        fingerprint_calculator.cpp
        fingerprint_compressor.cpp
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/src/chromaprint.cpp 
new/chromaprint-1.3.1/src/chromaprint.cpp
--- old/chromaprint-1.2/src/chromaprint.cpp     2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/src/chromaprint.cpp   2016-02-10 14:12:35.000000000 
+0100
@@ -27,6 +27,7 @@
 #include "fingerprint_decompressor.h"
 #include "fingerprinter_configuration.h"
 #include "base64.h"
+#include "simhash.h"
 
 using namespace std;
 using namespace Chromaprint;
@@ -34,6 +35,7 @@
 extern "C" {
 
 struct ChromaprintContextPrivate {
+       bool finished;
        int algorithm;
        Fingerprinter *fingerprinter;
        vector<int32_t> fingerprint;
@@ -56,6 +58,7 @@
 ChromaprintContext *chromaprint_new(int algorithm)
 {
        ChromaprintContextPrivate *ctx = new ChromaprintContextPrivate();
+       ctx->finished = false;
        ctx->algorithm = algorithm;
        ctx->fingerprinter = new 
Fingerprinter(CreateFingerprinterConfiguration(algorithm));
        return (ChromaprintContext *)ctx;
@@ -77,6 +80,7 @@
 int chromaprint_start(ChromaprintContext *c, int sample_rate, int num_channels)
 {
        ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+       ctx->finished = false;
        return ctx->fingerprinter->Start(sample_rate, num_channels) ? 1 : 0;
 }
 
@@ -91,12 +95,16 @@
 {
        ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
        ctx->fingerprint = ctx->fingerprinter->Finish();
+       ctx->finished = true;
        return 1;
 }
 
 int chromaprint_get_fingerprint(ChromaprintContext *c, char **data)
 {
        ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+       if (!ctx->finished) {
+               return 0;
+       }
        string fp = 
Chromaprint::Base64Encode(Chromaprint::CompressFingerprint(ctx->fingerprint, 
ctx->algorithm));
        *data = (char *)malloc(fp.size() + 1);
        if (!*data) {
@@ -110,6 +118,9 @@
 int chromaprint_get_raw_fingerprint(ChromaprintContext *c, void **data, int 
*size)
 {
        ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+       if (!ctx->finished) {
+               return 0;
+       }
        *data = malloc(sizeof(int32_t) * ctx->fingerprint.size());
        if (!*data) {
                return 0;
@@ -119,6 +130,16 @@
        return 1;
 }
 
+int chromaprint_get_fingerprint_hash(ChromaprintContext *c, void *hash)
+{
+       ChromaprintContextPrivate *ctx = (ChromaprintContextPrivate *)c;
+       if (!ctx->finished) {
+               return 0;
+       }
+       *((int32_t *)hash) = SimHash(ctx->fingerprint);
+       return 1;
+}
+
 int chromaprint_encode_fingerprint(const void *fp, int size, int algorithm, 
void **encoded_fp, int *encoded_size, int base64)
 {
        vector<int32_t> uncompressed = vector<int32_t>((const int32_t *)fp, 
(const int32_t *)fp + size);
@@ -148,6 +169,15 @@
        return 1;
 }
 
+int chromaprint_hash_fingerprint(const void *fp, int size, void *hash)
+{
+       if (fp == NULL || size < 0 || hash == NULL) {
+               return 0;
+       }
+       *((int32_t *)hash) = SimHash((const int32_t *)fp, size);
+       return 1;
+}
+
 void chromaprint_dealloc(void *ptr)
 {
        free(ptr);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/src/chromaprint.h 
new/chromaprint-1.3.1/src/chromaprint.h
--- old/chromaprint-1.2/src/chromaprint.h       2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/src/chromaprint.h     2016-02-10 14:12:35.000000000 
+0100
@@ -46,8 +46,8 @@
 typedef void *ChromaprintContext;
 
 #define CHROMAPRINT_VERSION_MAJOR 1
-#define CHROMAPRINT_VERSION_MINOR 2
-#define CHROMAPRINT_VERSION_PATCH 0
+#define CHROMAPRINT_VERSION_MINOR 3
+#define CHROMAPRINT_VERSION_PATCH 1
 
 enum ChromaprintAlgorithm {
        CHROMAPRINT_ALGORITHM_TEST1 = 0,
@@ -188,6 +188,20 @@
 CHROMAPRINT_API int chromaprint_get_raw_fingerprint(ChromaprintContext *ctx, 
void **fingerprint, int *size);
 
 /**
+ * Return 32-bit hash of the calculated fingerprint.
+ *
+ * See chromaprint_hash_fingerprint() for details on how to use the hash.
+ *
+ * Parameters:
+ *  - ctx: Chromaprint context pointer
+ *  - hash: pointer to a 32-bit integer where the hash will be stored
+ *
+ * Returns:
+ *  - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_get_fingerprint_hash(ChromaprintContext *ctx, 
void *hash);
+
+/**
  * Compress and optionally base64-encode a raw fingerprint
  *
  * The caller is responsible for freeing the returned pointer using
@@ -236,6 +250,30 @@
 CHROMAPRINT_API int chromaprint_decode_fingerprint(const void *encoded_fp, int 
encoded_size, void **fp, int *size, int *algorithm, int base64);
 
 /**
+ * Generate a single 32-bit hash for a raw fingerprint.
+ *
+ * If two fingerprints are similar, their hashes generated by this function
+ * will also be similar. If they are significantly different, their hashes
+ * will most likely be significantly different as well, but you can't rely
+ * on that.
+ *
+ * You compare two hashes by counting the bits in which they differ. Normally
+ * that would be something like POPCNT(hash1 XOR hash2), which returns a
+ * number between 0 and 32. Anthing above 15 means the hashes are
+ * completely different.
+ *
+ * Parameters:
+ *  - fp: pointer to an array of 32-bit integers representing the raw
+ *        fingerprint to be hashed
+ *  - size: number of items in the raw fingerprint
+ *  - hash: pointer to a 32-bit integer where the hash will be stored
+ *
+ * Returns:
+ *  - 0 on error, 1 on success
+ */
+CHROMAPRINT_API int chromaprint_hash_fingerprint(const void *fp, int size, 
void *hash);
+
+/**
  * Free memory allocated by any function from the Chromaprint API.
  *
  * Parameters:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/src/combined_buffer.h 
new/chromaprint-1.3.1/src/combined_buffer.h
--- old/chromaprint-1.2/src/combined_buffer.h   2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/src/combined_buffer.h 2016-02-10 14:12:35.000000000 
+0100
@@ -24,6 +24,7 @@
 #include <math.h>
 #include <assert.h>
 #include <algorithm>
+#include <iterator>
 
 namespace Chromaprint
 {
@@ -32,14 +33,9 @@
        class CombinedBuffer;
 
        template<class T>
-       class _CombinedBufferIterator
+       class _CombinedBufferIterator : public 
std::iterator<std::forward_iterator_tag, T>
        {
        public:
-               typedef std::input_iterator_tag iterator_category;
-               typedef T value_type;
-               typedef int difference_type;
-               typedef T* pointer;
-               typedef T& reference;
 
                _CombinedBufferIterator(CombinedBuffer<T> *buffer = 0, int pos 
= 0)
                        : m_buffer(buffer)
@@ -66,7 +62,7 @@
 
                bool operator==(const _CombinedBufferIterator<T> &rhs) const
                {
-                       return (m_ptr == rhs.m_ptr) && (m_buffer == 
rhs.m_buffer);
+                       return (m_ptr == rhs.m_ptr) && (m_ptr_end == 
rhs.m_ptr_end) && (m_buffer == rhs.m_buffer);
                }
 
                bool operator!=(const _CombinedBufferIterator<T> &rhs) const
@@ -76,6 +72,7 @@
 
                void operator++()
                {
+                       assert(m_ptr < m_ptr_end);
                        ++m_ptr;
                        if (m_ptr >= m_ptr_end) {
                                if (m_ptr_end == m_buffer->Buffer(0) + 
m_buffer->BufferSize(0)) {
@@ -84,13 +81,13 @@
                                }
                        }
                }
-       
+
                void operator++(int)
                {
                        ++(*this);
                }
 
-               short &operator*()
+               T &operator*()
                {
                        assert(m_ptr);
                        return *m_ptr;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/src/fingerprint_decompressor.cpp 
new/chromaprint-1.3.1/src/fingerprint_decompressor.cpp
--- old/chromaprint-1.2/src/fingerprint_decompressor.cpp        2014-08-26 
18:57:36.000000000 +0200
+++ new/chromaprint-1.3.1/src/fingerprint_decompressor.cpp      2016-02-10 
14:12:35.000000000 +0100
@@ -72,7 +72,8 @@
                                
DEBUG("FingerprintDecompressor::ReadExceptionBits() -- Invalid fingerprint 
(reached EOF while reading exception bits)");
                                return false;
                        }
-                       m_bits[i] += reader->Read(kExceptionBits);
+                       int bit = reader->Read(kExceptionBits);
+                       m_bits[i] += bit;
                }
        }
        return true;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/src/simhash.cpp 
new/chromaprint-1.3.1/src/simhash.cpp
--- old/chromaprint-1.2/src/simhash.cpp 1970-01-01 01:00:00.000000000 +0100
+++ new/chromaprint-1.3.1/src/simhash.cpp       2016-02-10 14:12:35.000000000 
+0100
@@ -0,0 +1,59 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2015  Lukas Lalinsky <[email protected]>
+ *
+ * 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 "simhash.h"
+
+namespace Chromaprint {
+
+    int32_t SimHash(const int32_t *data, size_t size)
+    {
+        int v[32];
+
+        for (size_t i = 0; i < 32; i++) {
+            v[i] = 0;
+        }
+
+        for (size_t i = 0; i < size; i++) {
+            uint32_t local_hash = SignedToUnsigned(data[i]);
+            for (size_t j = 0; j < 32; j++) {
+                v[j] += (local_hash & (1 << j)) ? 1 : -1;
+            }
+        }
+
+        uint32_t hash = 0;
+        for (size_t i = 0; i < 32; i++) {
+            if (v[i] > 0) {
+                hash |= (1 << i);
+            }
+        }
+
+        return UnsignedToSigned(hash);
+    }
+
+    int32_t SimHash(const std::vector<int32_t> &data)
+    {
+               if (data.empty()) {
+                       return 0;
+               } else {
+                       return SimHash(&data[0], data.size());
+               }
+    }
+
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/src/simhash.h 
new/chromaprint-1.3.1/src/simhash.h
--- old/chromaprint-1.2/src/simhash.h   1970-01-01 01:00:00.000000000 +0100
+++ new/chromaprint-1.3.1/src/simhash.h 2016-02-10 14:12:35.000000000 +0100
@@ -0,0 +1,36 @@
+/*
+ * Chromaprint -- Audio fingerprinting toolkit
+ * Copyright (C) 2015  Lukas Lalinsky <[email protected]>
+ *
+ * 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_SIMHASH_H_
+#define CHROMAPRINT_SIMHASH_H_
+
+#include <vector>
+#include "utils.h"
+
+namespace Chromaprint
+{
+
+    int32_t SimHash(const int32_t *data, size_t size);
+
+    int32_t SimHash(const std::vector<int32_t> &data);
+
+};
+
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/src/utils.h 
new/chromaprint-1.3.1/src/utils.h
--- old/chromaprint-1.2/src/utils.h     2014-08-26 18:57:36.000000000 +0200
+++ new/chromaprint-1.3.1/src/utils.h   2016-02-10 14:12:35.000000000 +0100
@@ -28,6 +28,7 @@
 #include <math.h>
 #include <stddef.h>
 #include <stdint.h>
+#include <limits.h>
 #include <algorithm>
 #include <limits>
 #include <iterator>
@@ -128,7 +129,11 @@
     inline int32_t UnsignedToSigned(uint32_t x)
     {
         return *((int32_t *)&x);
-        //return x & 0x80000000 ? x & 0x7FFFFFFF - 0x80000000 : x;
+    }
+
+    inline uint32_t SignedToUnsigned(int32_t x)
+    {
+        return *((uint32_t *)&x);
     }
 
        template<class T>
@@ -150,6 +155,57 @@
                return z;
        }
 
+       // 
https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
+       #define CHROMAPRINT_POPCNT_IMPL(T) \
+               v = v - ((v >> 1) & (T)~(T)0/3);                           \
+               v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3);      \
+               v = (v + (v >> 4)) & (T)~(T)0/255*15;                      \
+               c = (T)(v * ((T)~(T)0/255)) >> (sizeof(T) - 1) * CHAR_BIT; \
+
+       template<typename T, int Size, bool IsSigned>
+       struct _CountSetBits_Impl {
+               static unsigned int Do(T v) {
+                       return T::not_implemented;
+               }
+       };
+
+       template<typename T>
+       inline unsigned int CountSetBits(T v) {
+               return _CountSetBits_Impl<T, sizeof(T), 
std::numeric_limits<T>::is_signed>::Do(v);
+       }
+
+       template<typename T, int Size>
+       struct _CountSetBits_Impl<T, Size, true> {
+               static unsigned int Do(T v) {
+                       return CountSetBits(SignedToUnsigned(v));
+               }
+       };
+
+       template<typename T>
+       struct _CountSetBits_Impl<T, 4, false> {
+               static unsigned int Do(T v) {
+                       unsigned int c;
+                       CHROMAPRINT_POPCNT_IMPL(uint32_t);
+                       return c;
+               }
+       };
+
+       template<typename T>
+       struct _CountSetBits_Impl<T, 8, false> {
+               static unsigned int Do(T v) {
+                       unsigned int c;
+                       CHROMAPRINT_POPCNT_IMPL(uint64_t);
+                       return c;
+               }
+       };
+
+       #undef CHROMAPRINT_POPCNT_IMPL
+
+       template<typename T>
+       inline unsigned int HammingDistance(T a, T b) {
+               return CountSetBits(a ^ b);
+       }
+
 };
 
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/tests/CMakeLists.txt 
new/chromaprint-1.3.1/tests/CMakeLists.txt
--- old/chromaprint-1.2/tests/CMakeLists.txt    2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/tests/CMakeLists.txt  2016-02-10 14:12:35.000000000 
+0100
@@ -17,6 +17,7 @@
        test_audio_processor.cpp
        test_bit_string_reader.cpp
        test_bit_string_writer.cpp
+       test_simhash.cpp
        test_chromaprint.cpp
        test_chroma.cpp
        test_chroma_filter.cpp
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/tests/test_api.cpp 
new/chromaprint-1.3.1/tests/test_api.cpp
--- old/chromaprint-1.2/tests/test_api.cpp      2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/tests/test_api.cpp    2016-02-10 14:12:35.000000000 
+0100
@@ -20,12 +20,15 @@
        }
 
        char *fp;
+       int32_t fp_hash;
 
        chromaprint_finish(ctx);
        chromaprint_get_fingerprint(ctx, &fp);
+       chromaprint_get_fingerprint_hash(ctx, &fp_hash);
 
        ASSERT_EQ(18, strlen(fp));
        EXPECT_EQ(string("AQAAA0mUaEkSRZEGAA"), string(fp));
+       ASSERT_EQ(627964279, fp_hash);
 }
 
 TEST(API, Test2SilenceRawFp)
@@ -98,3 +101,15 @@
        ASSERT_EQ(0, fingerprint[1]);
 }
 
+TEST(API, TestHashFingerprint)
+{
+       int32_t fingerprint[] = { 19681, 22345, 312312, 453425 };
+    int32_t hash;
+
+    ASSERT_EQ(0, chromaprint_hash_fingerprint(NULL, 4, &hash));
+    ASSERT_EQ(0, chromaprint_hash_fingerprint(fingerprint, -1, &hash));
+    ASSERT_EQ(0, chromaprint_hash_fingerprint(fingerprint, 4, NULL));
+
+    ASSERT_EQ(1, chromaprint_hash_fingerprint(fingerprint, 4, &hash));
+    ASSERT_EQ(17249, hash);
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/tests/test_combined_buffer.cpp 
new/chromaprint-1.3.1/tests/test_combined_buffer.cpp
--- old/chromaprint-1.2/tests/test_combined_buffer.cpp  2014-08-26 
18:57:36.000000000 +0200
+++ new/chromaprint-1.3.1/tests/test_combined_buffer.cpp        2016-02-10 
14:12:35.000000000 +0100
@@ -56,6 +56,15 @@
        EXPECT_TRUE(buffer.End() == iter);
 }
 
+TEST(CombinedBuffer, SecondBufferBeforeFirst) {
+  short buffer[] = {4, 5, 1, 2, 3};
+       CombinedBuffer<short> combined(buffer + 2, 3, buffer, 2);
+       for (int i = 0; i < 5; i++) {
+               EXPECT_EQ(i + 1, combined[i]);
+       }
+  EXPECT_FALSE(combined.Begin() == combined.End());
+}
+
 TEST(CombinedBuffer, CopyUsingStlAlgorithms) {
        short buffer1[] = { 1, 2, 3, 4, 5 };
        short buffer2[] = { 6, 7, 8 };
@@ -92,4 +101,3 @@
                EXPECT_EQ(0, tmp[i]);
        }
 }
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/chromaprint-1.2/tests/test_fingerprint_decompressor.cpp 
new/chromaprint-1.3.1/tests/test_fingerprint_decompressor.cpp
--- old/chromaprint-1.2/tests/test_fingerprint_decompressor.cpp 2014-08-26 
18:57:36.000000000 +0200
+++ new/chromaprint-1.3.1/tests/test_fingerprint_decompressor.cpp       
2016-02-10 14:12:35.000000000 +0100
@@ -2,6 +2,7 @@
 #include <algorithm>
 #include <vector>
 #include "fingerprint_decompressor.h"
+#include "base64.h"
 #include "utils.h"
 #include "test_utils.h"
 
@@ -86,3 +87,13 @@
        ASSERT_EQ(0, algorithm);
 }
 
+TEST(FingerprintDecompressor, Long)
+{
+       int32_t expected[] = { 
-587455133,-591649759,-574868448,-576973520,-543396544,1330439488,1326360000,1326355649,1191625921,1192674515,1194804466,1195336818,1165981042,1165956451,1157441379,1157441299,1291679571,1291673457,1170079601
 };
+       std::string data = 
Base64Decode("AQAAEwkjrUmSJQpUHflR9mjSJMdZpcO_Imdw9dCO9Clu4_wQPvhCB01w6xAtXNcAp5RASgDBhDSCGGIAcwA");
+
+       int algorithm = 2;
+       vector<int32_t> value = DecompressFingerprint(data, &algorithm);
+       CheckFingerprints(value, expected, NELEMS(expected));
+       ASSERT_EQ(1, algorithm);
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/tests/test_simhash.cpp 
new/chromaprint-1.3.1/tests/test_simhash.cpp
--- old/chromaprint-1.2/tests/test_simhash.cpp  1970-01-01 01:00:00.000000000 
+0100
+++ new/chromaprint-1.3.1/tests/test_simhash.cpp        2016-02-10 
14:12:35.000000000 +0100
@@ -0,0 +1,27 @@
+#include <gtest/gtest.h>
+#include "simhash.h"
+#include "utils.h"
+
+using namespace Chromaprint;
+
+TEST(SimHash, Empty)
+{
+    ASSERT_EQ(0, SimHash(std::vector<int32_t>()));
+}
+
+TEST(SimHash, Normal)
+{
+    int32_t data[948] = 
{-1518991452,-1511651436,-1511579771,-1528353403,-1528469033,-1528501962,-1511724778,-1511543546,-1477991162,-1478183674,-1502310138,-1506504441,-1506482827,-1489541659,-1489619548,-1485437532,-1510078540,-1511127164,-1528353403,-1527829033,-1528469130,-1511720650,-1511741178,-1478185722,-1477139194,-1502300922,-1506504441,-1506499307,-1489640091,-1489607196,-1485437020,-1518991452,-1511061628,-1527826556,-1527828587,-1526896137,-1527907978,-1511720682,-1511741178,-1478185722,-1478187770,-1502310138,-1506504441,-1506482891,-1489541659,-1489619548,-1485437020,-1510078540,-1511061627,-1528352891,-1531105897,-1531090442,-1532692202,-1511741178,-1511740154,-1478187770,-1485523706,-1506504441,-1506482921,-1489640091,-1489607195,-1485437020,-1518991451,-1511061627,-1527824507,-1527829113,-1526896137,-1527383690,-1511737082,-1511740154,-1478187770,-1493912314,-1506504441,-1506495225,-1506417307,-1489607195,-1489619036,-1518991451,-1511127147,-1527834747,-1527828603,-1532155433,-1532106378,-1515914986,-1515935482,-1478185722,-1478187770,-1502301946,-1506508537,-1506482891,-1489541659,-1489623644,-1518991452,-1518991451,-1528363131,-1528352891,-1527435881,-1527486089,-1511659210,-1511675642,-1478185722,-1477139194,-1502301946,-1506504441,-1506483939,-1489639955,-1489605148,-1518985308,-1518989404,-1510535532,-1527302523,-1527437691,-1527419177,-1510609130,-1510675178,-1510691818,-1481262058,-1477143546,-1502309370,-1508577209,-434870827,-434756188,-415879260,-445247580,-437907532,-454621308,-459200571,-459247673,-459215018,-454956282,-168580858,-135021306,-135166714,-428829674,-432999337,-164600619,-147771996,-183358044,-177070172,-168687968,-168622448,-169789756,-174053819,-241111289,-207574778,-207378170,-136135418,-136149758,-144670458,-147803385,-181341379,-466589844,-466472980,-462280212,-453899804,-441249884,-441448828,-405790003,-405773617,-212797746,-210506258,-504190746,-508315418,-508457770,-235866938,1932534159,1930441613,1930568684,1915889644,1936856420,1944259940,1906313541,1906339141,1906371911,1889648454,1894956870,1911729990,1936891142,1936885046,1935705190,1935696999,1935680743,1902128629,1886531045,1886533092,1894909920,1894777456,1894838788,1910546948,1910552069,1927327253,-220026347,-220026091,-220029161,-160267513,-143604977,-181374401,-198158807,-197973207,-194893779,-185460627,-185579027,-168802355,-179281267,2001760911,1980842638,1930589094,1934812326,1911745702,-172897118,1974498438,1978687623,1399857613,1378957149,1383218988,1382169892,1407388961,1373635889,1352671493,1352725255,1356976982,1424160326,1416802119,1429389059,1395821841,1377864993,1382081892,1390470500,1408268276,1374830549,1355952117,1347567523,1364264418,1364197858,1364222290,1408299330,1390540098,1390586946,1407364163,1398967619,1398966083,1366327891,1362141814,1345385062,1882324582,1886579046,1893886055,-253671323,1911604565,1903223300,1932648964,1932612101,1932752501,1903356389,1911744743,1907574951,1940999303,1945118087,1397760903,1381040783,1381118975,1383212135,1399002147,1373637667,1373662227,1356915719,1352711495,1358085959,1374863175,1397931331,1379044675,1379110177,1382085985,1407247719,1373660535,1358067031,1358069223,1347556833,1347438433,1364214641,1366352385,1399894529,1391504977,1391700545,1391635395,1391640515,1383237443,1467056711,1362162199,-265230801,-265261521,-261986001,-186484691,-186529755,-185545355,-168758715,-212802875,-233745785,-216894826,-212703834,-237868894,-242071390,-256685950,1353786498,1374692806,1399859142,1383282022,-697160666,-966649822,-941619166,-941615086,-975116030,-710824190,-1800225022,-1648969982,-1651067646,-1650555343,-1615296992,-1619484128,-1641487776,-567803168,-567737696,-30797152,-163958620,1999438061,1973814334,1889668106,815933450,279062538,279063562,14740507,299955499,291799915,828670569,828691033,807727737,874897979,879190827,342258986,484924714,484825466,484948298,1567079370,1601018826,2145951706,-5664262,-5663814,-22310216,-559238472,-559177048,-567745876,-566746460,-566684960,-567659676,1982738468,2003238959,1973816334,815933450,279062538,279066634,11537482,15785339,7656939,291816427,291799979,828699579,820376507,350614457,342356923,73848250,207871466,207731578,1298381594,1566817034,1609018122,-558911734,-22044406,-559238630,-559250888,-559185304,-555179288,-566697236,-566742300,-567602464,-567660060,-30469916,2003240173,1973816394,884096010,347219978,351419402,342899738,351282218,351285354,882901098,887357658,887361754,878989787,879063387,342356283,342349178,350723578,367507866,350726538,1978121098,1978505866,1978506906,-139619686,-156265767,-156331400,-156323272,-697376216,-701685140,-700702108,-700636320,-164298524,2004091111,1906508926,1889668110,279066634,279062538,279063562,14738491,283157803,291537259,828408683,828670715,828748409,811704953,811837049,811771385,811834792,887197096,887201688,896646792,829660808,825472648,825484952,829612472,829616552,837996968,838001576,835723949,324018879,307241727,309469543,309470247,316677155,333449251,333473795,295762945,10747713,15924929,24280769,17989440,53628240,52446560,65037665,60845411,329317846,27459014,15924418,1232098,1082723,17860387,288403969,1399895553,1390521873,1390586641,1390587185,1382200625,1383236113,1393672709,1360065031,1880159807,1882319406,1886578734,1962072111,1957742695,1955646935,1976623821,1997566671,1913717391,1930568366,1930570918,1909598374,1907493026,1907559554,1907434630,298852742,324022983,307392885,309486629,333708321,299944993,299957265,278983937,279051847,15924935,24276679,51544003,53611859,321998049,325084385,329278693,329315829,280096197,11726293,5436915,1234787,17875747,288403987,1399886339,1390456595,1390586131,1390585873,1382193233,1383237440,1378910720,1362141717,1882255933,1882258989,1886578991,1894967335,1890699367,1957743719,1959818055,1901093583,1930494670,1930561246,1934764198,1945249958,1941129382,1907427463,1911563655,1934631559,303043214,303178479,309469223,325202979,299895843,283130899,278948867,279051525,10681925,32669377,38960961,101866817,36851057,39900257,312517857,396404198,1957799366,1957868998,1414700390,1410436390,1410369830,-718230778,-147801338,-164562170,-165482730,-151591642,-155258841,-557924320,-558349968,-558341184,-566726080,-700956144,1463423520,1463690016,1429610532,1442267191,347210766,351411470,338824970,338890251,338959737,880026729,900998377,632565993,632565977,614731849,878985545,879149881,887535419,1017556778,497336186,497335130,1608825802,1601018762,1596825482,1584103834,-559246918,-559246934,-693456472,-559176792,-555162968,-567745876,-683904340,-717327652,1966482040,1966224680,1978747945,1978682394,1978923018,1965287434,1965091850,891415627,895730937,636731817,565461481,552874969,540029449,540029465,606216747,1692542763,1956785450,1973442874,1974786314,2012518666,-30110902,-30634022,-26242566,-22376022,-5598293,-22367576,-22306136,-25632084,-1103568156,-1103498528,-163679520,-164728736,-161201952,-140459785,-173882170,1977772230,1948412302,1949514127,1966091695,1970283695,1978663147,1974468859,1973428299,888152075,888152331,888301370,1957854762,1957874218,1420872218,1441839626,-680224246,-165376246,-30570726,-26561734,-22367894,-1096121368,-1096117528,-1095195992,-1082596692,-1086823700,-1086651668,-12700948,-147446548,-176944024,-441447365,1706167306,1978805258,1901210698,1896885466,823141546,837812394,833880234,832843930,820256906,811872714,812057370,811992874,283520298,346433834,1420060954,1420077322,1424263434,1441566282,-38959398,-5668262,-22375877,-22375880,-22367704,-26631576,-30907676,-30928160,-30866784,-163901020,1983709421,2011497582,1906707466,816199690,816195594,279063562,278930442,14738475,283148649,291537897,895779561,879030905,879096379,879190555,342254874,476476458,484924458,216520730,1575467082,1567078730,1609408474,-5728294,-5663846,-22310215,-22310216,-559238488,-554065240,-566730068,-566746464,-566619424,-567660508,1982795813,2011628590,1973554190,279062538,279062538,77732874,82838539,82867563,74498409,358924649,367301097,887403513,887469019,887600091,342276058,476485594,476552698,493336922,1567078746,1596438986,2120596954,-17979942,-22301702,-22375687,-22375688,-22367576,-1092050200,-1087839512,-1087835416,-1121316184,-1523698264,-450618135,-436991894,-441382822,1708268618,1699884234,1695687882,1997743322,930152618,670105770,665850043,636498059,628109515,611324171,877818427,886205994,884108074,1957755706,1973725450,2011478282,1998883146,-13856806,-26508390,-22375430,-22375815,-22371736,-559308184,-555163028,-567778716,-29814176,-29748640,-29478812,-143392667,1978729534,1957825550,1962032142,875703370,875768907,875834857,905192681,900989161,632553977,632558027,610534155,610583066,610723626,1021766954,1017572650,2108995866,2142538058,2138344394,2117439114,-29509990,-25513030,-21326918,-4549720,-4545880,-21454168,-25632092,-29859088,-163966240,-163958172,-147972060,-144441305,1973683262,1906707470,1889937418,812001290,807877706,271859067,905188587,833880299,832844011,564408537,820269129,811979097,887534459,883340923,884457082,888446970,888446938,891591050,1998953882,1982315930,1982247322,1986433467,1990628265,1991701160,1995858664,1999905388,1999905324,-182050260,1965175596,1977812268,1973421096,1974469641,1978807563,1968316170,890246922,890250602,894448874,636486890,615776442,614731914,618934474,878989771,879153945,879142697,887533355,900054842,1470413658,1608825418,1583651530,2116914826,-26507366,-18181702,-559246870,-559238807,-559242392,-559357332,-563551708,-567746016,-566312416,-700517536,-684269344,2012664032,1979106499,1979108486,1965476231,1965542277,1965391269,1965319597,1978671277,1703948521,1703948569,609231113,609231627,609362730,619851562,1957828906,1957693754,1958005002,1974769930,2004126538,2116849562,-165050438,-152399430,-156593221,-156585304,-693460312,-689380696,-700947796,-700964124,-163704092,-163700700,-161214427,2007237679,1973816334,1894131722,812001290,270994698,270800235,812922091,821298347,816058539,564425883,551867787,618956683,619093691,1977788075,2012391082,2012260090,1987097434,-165637350,-433871046,-433936598,-433674950,-1486444753,-1514749396,-1246313940,-1245949380,-176397804,-180592108,-148037088,-147967455,-433848286,-404486942,-408664842,-442055546,1979120774,1966501262,1949727119,1949400493,1970300077};
+    int32_t hash1 = SimHash(std::vector<int32_t>(data, data + 948));
+    ASSERT_EQ(1961926954, hash1);
+}
+
+TEST(SimHash, CompareCropped)
+{
+    int32_t data[948] = 
{-1518991452,-1511651436,-1511579771,-1528353403,-1528469033,-1528501962,-1511724778,-1511543546,-1477991162,-1478183674,-1502310138,-1506504441,-1506482827,-1489541659,-1489619548,-1485437532,-1510078540,-1511127164,-1528353403,-1527829033,-1528469130,-1511720650,-1511741178,-1478185722,-1477139194,-1502300922,-1506504441,-1506499307,-1489640091,-1489607196,-1485437020,-1518991452,-1511061628,-1527826556,-1527828587,-1526896137,-1527907978,-1511720682,-1511741178,-1478185722,-1478187770,-1502310138,-1506504441,-1506482891,-1489541659,-1489619548,-1485437020,-1510078540,-1511061627,-1528352891,-1531105897,-1531090442,-1532692202,-1511741178,-1511740154,-1478187770,-1485523706,-1506504441,-1506482921,-1489640091,-1489607195,-1485437020,-1518991451,-1511061627,-1527824507,-1527829113,-1526896137,-1527383690,-1511737082,-1511740154,-1478187770,-1493912314,-1506504441,-1506495225,-1506417307,-1489607195,-1489619036,-1518991451,-1511127147,-1527834747,-1527828603,-1532155433,-1532106378,-1515914986,-1515935482,-1478185722,-1478187770,-1502301946,-1506508537,-1506482891,-1489541659,-1489623644,-1518991452,-1518991451,-1528363131,-1528352891,-1527435881,-1527486089,-1511659210,-1511675642,-1478185722,-1477139194,-1502301946,-1506504441,-1506483939,-1489639955,-1489605148,-1518985308,-1518989404,-1510535532,-1527302523,-1527437691,-1527419177,-1510609130,-1510675178,-1510691818,-1481262058,-1477143546,-1502309370,-1508577209,-434870827,-434756188,-415879260,-445247580,-437907532,-454621308,-459200571,-459247673,-459215018,-454956282,-168580858,-135021306,-135166714,-428829674,-432999337,-164600619,-147771996,-183358044,-177070172,-168687968,-168622448,-169789756,-174053819,-241111289,-207574778,-207378170,-136135418,-136149758,-144670458,-147803385,-181341379,-466589844,-466472980,-462280212,-453899804,-441249884,-441448828,-405790003,-405773617,-212797746,-210506258,-504190746,-508315418,-508457770,-235866938,1932534159,1930441613,1930568684,1915889644,1936856420,1944259940,1906313541,1906339141,1906371911,1889648454,1894956870,1911729990,1936891142,1936885046,1935705190,1935696999,1935680743,1902128629,1886531045,1886533092,1894909920,1894777456,1894838788,1910546948,1910552069,1927327253,-220026347,-220026091,-220029161,-160267513,-143604977,-181374401,-198158807,-197973207,-194893779,-185460627,-185579027,-168802355,-179281267,2001760911,1980842638,1930589094,1934812326,1911745702,-172897118,1974498438,1978687623,1399857613,1378957149,1383218988,1382169892,1407388961,1373635889,1352671493,1352725255,1356976982,1424160326,1416802119,1429389059,1395821841,1377864993,1382081892,1390470500,1408268276,1374830549,1355952117,1347567523,1364264418,1364197858,1364222290,1408299330,1390540098,1390586946,1407364163,1398967619,1398966083,1366327891,1362141814,1345385062,1882324582,1886579046,1893886055,-253671323,1911604565,1903223300,1932648964,1932612101,1932752501,1903356389,1911744743,1907574951,1940999303,1945118087,1397760903,1381040783,1381118975,1383212135,1399002147,1373637667,1373662227,1356915719,1352711495,1358085959,1374863175,1397931331,1379044675,1379110177,1382085985,1407247719,1373660535,1358067031,1358069223,1347556833,1347438433,1364214641,1366352385,1399894529,1391504977,1391700545,1391635395,1391640515,1383237443,1467056711,1362162199,-265230801,-265261521,-261986001,-186484691,-186529755,-185545355,-168758715,-212802875,-233745785,-216894826,-212703834,-237868894,-242071390,-256685950,1353786498,1374692806,1399859142,1383282022,-697160666,-966649822,-941619166,-941615086,-975116030,-710824190,-1800225022,-1648969982,-1651067646,-1650555343,-1615296992,-1619484128,-1641487776,-567803168,-567737696,-30797152,-163958620,1999438061,1973814334,1889668106,815933450,279062538,279063562,14740507,299955499,291799915,828670569,828691033,807727737,874897979,879190827,342258986,484924714,484825466,484948298,1567079370,1601018826,2145951706,-5664262,-5663814,-22310216,-559238472,-559177048,-567745876,-566746460,-566684960,-567659676,1982738468,2003238959,1973816334,815933450,279062538,279066634,11537482,15785339,7656939,291816427,291799979,828699579,820376507,350614457,342356923,73848250,207871466,207731578,1298381594,1566817034,1609018122,-558911734,-22044406,-559238630,-559250888,-559185304,-555179288,-566697236,-566742300,-567602464,-567660060,-30469916,2003240173,1973816394,884096010,347219978,351419402,342899738,351282218,351285354,882901098,887357658,887361754,878989787,879063387,342356283,342349178,350723578,367507866,350726538,1978121098,1978505866,1978506906,-139619686,-156265767,-156331400,-156323272,-697376216,-701685140,-700702108,-700636320,-164298524,2004091111,1906508926,1889668110,279066634,279062538,279063562,14738491,283157803,291537259,828408683,828670715,828748409,811704953,811837049,811771385,811834792,887197096,887201688,896646792,829660808,825472648,825484952,829612472,829616552,837996968,838001576,835723949,324018879,307241727,309469543,309470247,316677155,333449251,333473795,295762945,10747713,15924929,24280769,17989440,53628240,52446560,65037665,60845411,329317846,27459014,15924418,1232098,1082723,17860387,288403969,1399895553,1390521873,1390586641,1390587185,1382200625,1383236113,1393672709,1360065031,1880159807,1882319406,1886578734,1962072111,1957742695,1955646935,1976623821,1997566671,1913717391,1930568366,1930570918,1909598374,1907493026,1907559554,1907434630,298852742,324022983,307392885,309486629,333708321,299944993,299957265,278983937,279051847,15924935,24276679,51544003,53611859,321998049,325084385,329278693,329315829,280096197,11726293,5436915,1234787,17875747,288403987,1399886339,1390456595,1390586131,1390585873,1382193233,1383237440,1378910720,1362141717,1882255933,1882258989,1886578991,1894967335,1890699367,1957743719,1959818055,1901093583,1930494670,1930561246,1934764198,1945249958,1941129382,1907427463,1911563655,1934631559,303043214,303178479,309469223,325202979,299895843,283130899,278948867,279051525,10681925,32669377,38960961,101866817,36851057,39900257,312517857,396404198,1957799366,1957868998,1414700390,1410436390,1410369830,-718230778,-147801338,-164562170,-165482730,-151591642,-155258841,-557924320,-558349968,-558341184,-566726080,-700956144,1463423520,1463690016,1429610532,1442267191,347210766,351411470,338824970,338890251,338959737,880026729,900998377,632565993,632565977,614731849,878985545,879149881,887535419,1017556778,497336186,497335130,1608825802,1601018762,1596825482,1584103834,-559246918,-559246934,-693456472,-559176792,-555162968,-567745876,-683904340,-717327652,1966482040,1966224680,1978747945,1978682394,1978923018,1965287434,1965091850,891415627,895730937,636731817,565461481,552874969,540029449,540029465,606216747,1692542763,1956785450,1973442874,1974786314,2012518666,-30110902,-30634022,-26242566,-22376022,-5598293,-22367576,-22306136,-25632084,-1103568156,-1103498528,-163679520,-164728736,-161201952,-140459785,-173882170,1977772230,1948412302,1949514127,1966091695,1970283695,1978663147,1974468859,1973428299,888152075,888152331,888301370,1957854762,1957874218,1420872218,1441839626,-680224246,-165376246,-30570726,-26561734,-22367894,-1096121368,-1096117528,-1095195992,-1082596692,-1086823700,-1086651668,-12700948,-147446548,-176944024,-441447365,1706167306,1978805258,1901210698,1896885466,823141546,837812394,833880234,832843930,820256906,811872714,812057370,811992874,283520298,346433834,1420060954,1420077322,1424263434,1441566282,-38959398,-5668262,-22375877,-22375880,-22367704,-26631576,-30907676,-30928160,-30866784,-163901020,1983709421,2011497582,1906707466,816199690,816195594,279063562,278930442,14738475,283148649,291537897,895779561,879030905,879096379,879190555,342254874,476476458,484924458,216520730,1575467082,1567078730,1609408474,-5728294,-5663846,-22310215,-22310216,-559238488,-554065240,-566730068,-566746464,-566619424,-567660508,1982795813,2011628590,1973554190,279062538,279062538,77732874,82838539,82867563,74498409,358924649,367301097,887403513,887469019,887600091,342276058,476485594,476552698,493336922,1567078746,1596438986,2120596954,-17979942,-22301702,-22375687,-22375688,-22367576,-1092050200,-1087839512,-1087835416,-1121316184,-1523698264,-450618135,-436991894,-441382822,1708268618,1699884234,1695687882,1997743322,930152618,670105770,665850043,636498059,628109515,611324171,877818427,886205994,884108074,1957755706,1973725450,2011478282,1998883146,-13856806,-26508390,-22375430,-22375815,-22371736,-559308184,-555163028,-567778716,-29814176,-29748640,-29478812,-143392667,1978729534,1957825550,1962032142,875703370,875768907,875834857,905192681,900989161,632553977,632558027,610534155,610583066,610723626,1021766954,1017572650,2108995866,2142538058,2138344394,2117439114,-29509990,-25513030,-21326918,-4549720,-4545880,-21454168,-25632092,-29859088,-163966240,-163958172,-147972060,-144441305,1973683262,1906707470,1889937418,812001290,807877706,271859067,905188587,833880299,832844011,564408537,820269129,811979097,887534459,883340923,884457082,888446970,888446938,891591050,1998953882,1982315930,1982247322,1986433467,1990628265,1991701160,1995858664,1999905388,1999905324,-182050260,1965175596,1977812268,1973421096,1974469641,1978807563,1968316170,890246922,890250602,894448874,636486890,615776442,614731914,618934474,878989771,879153945,879142697,887533355,900054842,1470413658,1608825418,1583651530,2116914826,-26507366,-18181702,-559246870,-559238807,-559242392,-559357332,-563551708,-567746016,-566312416,-700517536,-684269344,2012664032,1979106499,1979108486,1965476231,1965542277,1965391269,1965319597,1978671277,1703948521,1703948569,609231113,609231627,609362730,619851562,1957828906,1957693754,1958005002,1974769930,2004126538,2116849562,-165050438,-152399430,-156593221,-156585304,-693460312,-689380696,-700947796,-700964124,-163704092,-163700700,-161214427,2007237679,1973816334,1894131722,812001290,270994698,270800235,812922091,821298347,816058539,564425883,551867787,618956683,619093691,1977788075,2012391082,2012260090,1987097434,-165637350,-433871046,-433936598,-433674950,-1486444753,-1514749396,-1246313940,-1245949380,-176397804,-180592108,-148037088,-147967455,-433848286,-404486942,-408664842,-442055546,1979120774,1966501262,1949727119,1949400493,1970300077};
+    int32_t hash1 = SimHash(std::vector<int32_t>(data, data + 948));
+    int32_t hash2 = SimHash(std::vector<int32_t>(data + 10, data + 948 - 10));
+    int32_t hash3 = SimHash(std::vector<int32_t>(data + 10, data + 948 - 100));
+    ASSERT_LE(0, HammingDistance(hash1, hash2));
+    ASSERT_LE(1, HammingDistance(hash1, hash3));
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/chromaprint-1.2/tests/test_utils.cpp 
new/chromaprint-1.3.1/tests/test_utils.cpp
--- old/chromaprint-1.2/tests/test_utils.cpp    2014-08-26 18:57:36.000000000 
+0200
+++ new/chromaprint-1.3.1/tests/test_utils.cpp  2016-02-10 14:12:35.000000000 
+0100
@@ -89,3 +89,25 @@
     EXPECT_FALSE(IsNaN(0.0));
     EXPECT_TRUE(IsNaN(sqrt(-1.0)));
 }
+
+TEST(Utils, CountSetBits32) {
+    EXPECT_EQ(0, CountSetBits(0x00U));
+    EXPECT_EQ(8, CountSetBits(0xFFU));
+    EXPECT_EQ(16, CountSetBits(0xFFFFU));
+    EXPECT_EQ(24, CountSetBits(0xFFFFFFU));
+    EXPECT_EQ(32, CountSetBits(0xFFFFFFFFU));
+    EXPECT_EQ(4, CountSetBits(0x01010101U));
+}
+
+TEST(Utils, CountSetBits64) {
+    EXPECT_EQ(0, CountSetBits(0x00U));
+    EXPECT_EQ(8, CountSetBits(0xFFU));
+    EXPECT_EQ(16, CountSetBits(0xFFFFU));
+    EXPECT_EQ(24, CountSetBits(0xFFFFFFU));
+    EXPECT_EQ(32, CountSetBits(0xFFFFFFFFU));
+    EXPECT_EQ(40, CountSetBits(0xFFFFFFFFFFU));
+    EXPECT_EQ(48, CountSetBits(0xFFFFFFFFFFFFU));
+    EXPECT_EQ(56, CountSetBits(0xFFFFFFFFFFFFFFU));
+    EXPECT_EQ(64, CountSetBits(0xFFFFFFFFFFFFFFFFU));
+    EXPECT_EQ(8, CountSetBits(0x0101010101010101U));
+}


Reply via email to