chromaprint: update to 1.4.3, enable all tests again

Changelog:
https://github.com/acoustid/chromaprint/releases/tag/v1.4.3

OK sthen@
This commit is contained in:
cwen 2019-08-23 20:18:04 +00:00
parent c56caff25c
commit 1816ce813d
8 changed files with 113 additions and 77 deletions

View File

@ -1,38 +1,40 @@
# $OpenBSD: Makefile,v 1.12 2019/07/12 20:43:32 sthen Exp $
# $OpenBSD: Makefile,v 1.13 2019/08/23 20:18:04 cwen Exp $
COMMENT = audio fingerprint extraction library
DISTNAME = chromaprint-1.1
GH_ACCOUNT = acoustid
GH_PROJECT = chromaprint
GH_TAGNAME = v1.4.3
SHARED_LIBS = chromaprint 2.0 # 1.4.3
CATEGORIES = audio devel
HOMEPAGE = https://acoustid.org/chromaprint
MASTER_SITES = https://bitbucket.org/acoustid/chromaprint/downloads/
REVISION = 3
SHARED_LIBS = chromaprint 1.0 # 0.1
# LGPL2.1+
# MIT with LGPL2.1+ parts
PERMIT_PACKAGE = Yes
WANTLIB += avcodec avformat avutil c m pthread ${COMPILER_LIBCXX} swresample
WANTLIB += ${COMPILER_LIBCXX} avcodec avformat avutil c m swresample
COMPILER = base-clang ports-gcc base-gcc
# C++11
COMPILER = base-clang ports-gcc
MODULES = devel/cmake
BUILD_DEPENDS = audio/taglib \
devel/boost
BUILD_DEPENDS = audio/taglib
# gtest presence is checked in configure stage, so this cannot be
# in TEST_DEPENDS
BUILD_DEPENDS += devel/gtest
LIB_DEPENDS = graphics/ffmpeg
# gtest presence is checked in configure stage, so this cannot be in TEST_DEPENDS
BUILD_DEPENDS += devel/gtest
CONFIGURE_ARGS = -DBUILD_TESTS:Bool=Yes -DBUILD_EXAMPLES=ON
CONFIGURE_ARGS = -DBUILD_TOOLS=ON \
-DBUILD_TESTS=ON
post-patch:
sed -i 's,/usr/local,${LOCALBASE},' \
${WRKSRC}/cmake/modules/FindGTest.cmake
TEST_TARGET = check
do-test:
cd ${WRKBUILD}/tests && ./all_tests
pre-configure:
${SUBST_CMD} ${WRKSRC}/cmake/modules/FindGTest.cmake
.include <bsd.port.mk>

View File

@ -1,2 +1,2 @@
SHA256 (chromaprint-1.1.tar.gz) = axTX6klkWBtzvT+AOMiFfAHkRkIcGumcu/ZN4mtHzRI=
SIZE (chromaprint-1.1.tar.gz) = 542360
SHA256 (chromaprint-1.4.3.tar.gz) = 1K5llig6rXoBWlsERQEgVMY0pLkynssjAAzTVLQKKDs=
SIZE (chromaprint-1.4.3.tar.gz) = 613718

View File

@ -1,6 +1,10 @@
$OpenBSD: patch-cmake_modules_FindGTest_cmake,v 1.1 2014/05/09 09:00:19 sthen Exp $
--- cmake/modules/FindGTest.cmake.orig Sat Nov 23 16:43:42 2013
+++ cmake/modules/FindGTest.cmake Wed May 7 16:29:15 2014
$OpenBSD: patch-cmake_modules_FindGTest_cmake,v 1.2 2019/08/23 20:18:04 cwen Exp $
Find gtest from devel/gtest.
Index: cmake/modules/FindGTest.cmake
--- cmake/modules/FindGTest.cmake.orig
+++ cmake/modules/FindGTest.cmake
@@ -71,12 +71,24 @@ find_path(GTEST_INCLUDE_DIR
)
mark_as_advanced(GTEST_INCLUDE_DIR)
@ -10,7 +14,7 @@ $OpenBSD: patch-cmake_modules_FindGTest_cmake,v 1.1 2014/05/09 09:00:19 sthen Ex
+ FIND_LIBRARY(${varname}
+ NAMES ${shortname}
+ PATHS
+ /usr/local/lib
+ ${LOCALBASE}/lib
+ NO_DEFAULT_PATH
+ DOC "Location of GTEST Libraries"
+ )
@ -22,9 +26,10 @@ $OpenBSD: patch-cmake_modules_FindGTest_cmake,v 1.1 2014/05/09 09:00:19 sthen Ex
+find_package_handle_standard_args(GTest DEFAULT_MSG GTEST_INCLUDE_DIR)
if(GTEST_FOUND)
set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
- set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
- set(GTEST_LIBRARIES gtest)
- set(GTEST_MAIN_LIBRARIES gtest_main)
+ set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
+ GTEST_FIND(GTEST_LIBRARIES gtest)
+ GTEST_FIND(GTEST_MAIN_LIBRARIES gtest_main)
set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})

View File

@ -1,34 +0,0 @@
$OpenBSD: patch-examples_fpcalc_c,v 1.1 2019/02/18 10:05:39 ajacoutot Exp $
Update for newer FFmpeg API.
Index: examples/fpcalc.c
--- examples/fpcalc.c.orig
+++ examples/fpcalc.c
@@ -126,7 +126,7 @@ int decode_audio_file(ChromaprintContext *chromaprint_
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) {
@@ -134,7 +134,7 @@ int decode_audio_file(ChromaprintContext *chromaprint_
}
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);
@@ -190,7 +190,7 @@ finish:
done:
if (frame) {
- avcodec_free_frame(&frame);
+ av_frame_free(&frame);
}
if (dst_data[0]) {
av_freep(&dst_data[0]);

View File

@ -1,24 +1,29 @@
$OpenBSD: patch-tests_CMakeLists_txt,v 1.2 2019/08/13 18:10:11 phessler Exp $
$OpenBSD: patch-tests_CMakeLists_txt,v 1.3 2019/08/23 20:18:04 cwen Exp $
test-bit_string_*.cpp depends on signed char, failing on aarch64
Using devel/gtest instead of using a third party one that we
would need to download and extract.
Index: tests/CMakeLists.txt
--- tests/CMakeLists.txt.orig
+++ tests/CMakeLists.txt
@@ -3,7 +3,6 @@ include_directories(
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/../src
@@ -3,11 +3,9 @@ find_package(GTest REQUIRED)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${GTEST_INCLUDE_DIRS}
- ${GTEST_SOURCE_DIR}
)
-add_subdirectory(${GTEST_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/gtest_build)
set(tests_SOURCES
set(SRCS
- ${GTEST_SOURCE_DIR}/src/gtest-all.cc
main.cpp
@@ -15,8 +14,6 @@ set(tests_SOURCES
test_integral_image.cpp
test_lloyds.cpp
test_audio_processor.cpp
- test_bit_string_reader.cpp
- test_bit_string_writer.cpp
test_chromaprint.cpp
test_chroma.cpp
test_chroma_filter.cpp
test_api.cpp
test_utils.cpp
@@ -37,6 +35,8 @@ if(BUILD_TOOLS)
set(SRCS ${SRCS} ../src/audio/ffmpeg_audio_reader_test.cpp)
link_libraries(fpcalc_libs)
endif()
+
+link_libraries(gtest)
add_executable(all_tests ${SRCS} $<TARGET_OBJECTS:chromaprint_objs>)
target_link_libraries(all_tests PRIVATE chromaprint ${CMAKE_THREAD_LIBS_INIT})

View File

@ -0,0 +1,29 @@
$OpenBSD: patch-tests_test_utils_cpp,v 1.1 2019/08/23 20:18:04 cwen Exp $
Make tests endian neutral. Can be removed with chromaprint>=1.4.4:
https://github.com/acoustid/chromaprint/commit/8d5f2ca81db8fae6b59b6b9b8bda91526507dbd1
Index: tests/test_utils.cpp
--- tests/test_utils.cpp.orig
+++ tests/test_utils.cpp
@@ -2,6 +2,7 @@
#include <algorithm>
#include <limits>
#include "utils.h"
+#include "test_utils.h"
using namespace chromaprint;
@@ -91,4 +92,12 @@ TEST(Utils, CountSetBits64) {
EXPECT_EQ(56, CountSetBits(0xFFFFFFFFFFFFFFU));
EXPECT_EQ(64, CountSetBits(0xFFFFFFFFFFFFFFFFU));
EXPECT_EQ(8, CountSetBits(0x0101010101010101U));
+}
+
+TEST(Utils, LoadAudioFile) {
+ std::vector<short> data = LoadAudioFile("data/test_mono_44100.raw");
+ ASSERT_EQ(data.size(), 176400/2);
+ EXPECT_EQ(data[1000], 0);
+ EXPECT_EQ(data[2000], 107);
+ EXPECT_EQ(data[3000], 128);
}

View File

@ -0,0 +1,29 @@
$OpenBSD: patch-tests_test_utils_h,v 1.1 2019/08/23 20:18:04 cwen Exp $
Make tests endian neutral. Can be removed with chromaprint>=1.4.4:
https://github.com/acoustid/chromaprint/commit/8d5f2ca81db8fae6b59b6b9b8bda91526507dbd1
Index: tests/test_utils.h
--- tests/test_utils.h.orig
+++ tests/test_utils.h
@@ -31,11 +31,15 @@ inline std::vector<short> LoadAudioFile(const std::str
{
std::string path = TESTS_DIR + file_name;
std::ifstream file(path.c_str(), std::ifstream::in | std::ifstream::binary);
- file.seekg(0, std::ios::end);
- int length = file.tellg();
- file.seekg(0, std::ios::beg);
- std::vector<short> data(length / 2);
- file.read((char *)&data[0], length);
+ uint8_t buf[4096];
+ std::vector<int16_t> data;
+ while (!file.eof()) {
+ file.read((char *) buf, 4096);
+ size_t nread = file.gcount();
+ for (size_t i = 0; i < nread - 1; i += 2) {
+ data.push_back((int16_t) (((uint16_t) buf[i+1] << 8) | ((uint16_t) buf[i])));
+ }
+ }
file.close();
return data;
}

View File

@ -4,4 +4,4 @@ fingerprints from any audio source.
Overview of the fingerprint extraction process can be found in the blog
post "How does Chromaprint work?":
http://oxygene.sk/lukas/2011/01/how-does-chromaprint-work/
https://oxygene.sk/lukas/2011/01/how-does-chromaprint-work/