# HG changeset patch # User Chris Cannam # Date 1673950300 0 # Tue Jan 17 10:11:40 2023 +0000 # Node ID 9ccd4c27fa5748aa7717fb16235094e86b1d8acb # Parent 1645e7be5e9f89aecfafccbc5848e7ba6647e6e3 Remove libresample support, which hasn't been exercised in a long time diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -6,7 +6,6 @@ # # -DHAVE_LIBSAMPLERATE The libsamplerate library is available (recommended) # -DHAVE_IPP Intel's Integrated Performance Primitives are available -# -DHAVE_LIBRESAMPLE The libresample library is available # -DUSE_BQRESAMPLER Compile the built-in BQ resampler (pretty good) # -DUSE_SPEEX Compile the built-in Speex-derived resampler # diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -26,6 +26,6 @@ [![Build status](https://builds.sr.ht/~breakfastquay/bqresample.svg)](https://builds.sr.ht/~breakfastquay/bqresample?) -Copyright 2007-2021 Particular Programs Ltd. -Uses Speex code, see speex/COPYING for copyright and licence information. +Copyright 2007-2023 Particular Programs Ltd. +May use Speex code, see speex/COPYING for copyright and licence information. diff --git a/bqresample/Resampler.h b/bqresample/Resampler.h --- a/bqresample/Resampler.h +++ b/bqresample/Resampler.h @@ -6,7 +6,7 @@ A small library wrapping various audio sample rate conversion implementations in C++. - Copyright 2007-2021 Particular Programs Ltd. + Copyright 2007-2023 Particular Programs Ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/src/BQResampler.cpp b/src/BQResampler.cpp --- a/src/BQResampler.cpp +++ b/src/BQResampler.cpp @@ -6,7 +6,7 @@ A small library wrapping various audio sample rate conversion implementations in C++. - Copyright 2007-2021 Particular Programs Ltd. + Copyright 2007-2023 Particular Programs Ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/src/BQResampler.h b/src/BQResampler.h --- a/src/BQResampler.h +++ b/src/BQResampler.h @@ -6,7 +6,7 @@ A small library wrapping various audio sample rate conversion implementations in C++. - Copyright 2007-2021 Particular Programs Ltd. + Copyright 2007-2023 Particular Programs Ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/src/Resampler.cpp b/src/Resampler.cpp --- a/src/Resampler.cpp +++ b/src/Resampler.cpp @@ -6,7 +6,7 @@ A small library wrapping various audio sample rate conversion implementations in C++. - Copyright 2007-2021 Particular Programs Ltd. + Copyright 2007-2023 Particular Programs Ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation @@ -61,10 +61,6 @@ #include #endif -#ifdef HAVE_LIBRESAMPLE -#include -#endif - #ifdef USE_SPEEX #include "../speex/speex_resampler.h" #endif @@ -75,7 +71,6 @@ #ifndef HAVE_IPP #ifndef HAVE_LIBSAMPLERATE -#ifndef HAVE_LIBRESAMPLE #ifndef USE_SPEEX #ifndef USE_BQRESAMPLER #error No resampler implementation selected! @@ -83,7 +78,6 @@ #endif #endif #endif -#endif using namespace std; @@ -773,195 +767,6 @@ #endif /* HAVE_LIBSAMPLERATE */ -#ifdef HAVE_LIBRESAMPLE - -class D_Resample : public Resampler::Impl -{ -public: - D_Resample(Resampler::Quality quality, Resampler::RatioChange, - int channels, double initialSampleRate, - int maxBufferSize, int m_debugLevel); - ~D_Resample(); - - int resample(float *const BQ_R__ *const BQ_R__ out, - int outcount, - const float *const BQ_R__ *const BQ_R__ in, - int incount, - double ratio, - bool final); - - int resampleInterleaved(float *const BQ_R__ out, - int outcount, - const float *const BQ_R__ in, - int incount, - double ratio, - bool final); - - int getChannelCount() const { return m_channels; } - double getEffectiveRatio(double ratio) const { return ratio; } - - void reset(); - -protected: - void *m_src; - float *m_iin; - float *m_iout; - double m_lastRatio; - int m_channels; - int m_iinsize; - int m_ioutsize; - int m_debugLevel; -}; - -D_Resample::D_Resample(Resampler::Quality quality, - int channels, double, int maxBufferSize, int debugLevel) : - m_src(0), - m_iin(0), - m_iout(0), - m_channels(channels), - m_iinsize(0), - m_ioutsize(0), - m_debugLevel(debugLevel) -{ - if (m_debugLevel > 0) { - cerr << "Resampler::Resampler: using implementation: libresample" - << endl; - } - - float min_factor = 0.125f; - float max_factor = 8.0f; - - m_src = resample_open(quality == Resampler::Best ? 1 : 0, min_factor, max_factor); - - if (!m_src) { - cerr << "Resampler::Resampler: failed to create libresample resampler: " - << endl; - throw Resampler::ImplementationError; //!!! of course, need to catch this! - } - - if (maxBufferSize > 0 && m_channels > 1) { - m_iinsize = maxBufferSize * m_channels; - m_ioutsize = maxBufferSize * m_channels * 2; - m_iin = allocate(m_iinsize); - m_iout = allocate(m_ioutsize); - } - - reset(); -} - -D_Resample::~D_Resample() -{ - resample_close(m_src); - if (m_iinsize > 0) { - deallocate(m_iin); - } - if (m_ioutsize > 0) { - deallocate(m_iout); - } -} - -int -D_Resample::resample(float *const BQ_R__ *const BQ_R__ out, - int outcount, - const float *const BQ_R__ *const BQ_R__ in, - int incount, - double ratio, - bool final) -{ - float *data_in; - float *data_out; - int input_frames, output_frames, end_of_input, source_used; - float src_ratio; - - int outcount = (int)lrint(ceil(incount * ratio)); - - if (m_channels == 1) { - data_in = const_cast(*in); //!!!??? - data_out = *out; - } else { - if (incount * m_channels > m_iinsize) { - m_iin = reallocate(m_iin, m_iinsize, incount * m_channels); - m_iinsize = incount * m_channels; - } - if (outcount * m_channels > m_ioutsize) { - m_iout = reallocate(m_iout, m_ioutsize, outcount * m_channels); - m_ioutsize = outcount * m_channels; - } - v_interleave(m_iin, in, m_channels, incount); - data_in = m_iin; - data_out = m_iout; - } - - input_frames = incount; - output_frames = outcount; - src_ratio = ratio; - end_of_input = (final ? 1 : 0); - - int output_frames_gen = resample_process(m_src, - src_ratio, - data_in, - input_frames, - end_of_input, - &source_used, - data_out, - output_frames); - - if (output_frames_gen < 0) { - cerr << "Resampler::process: libresample error: " - << endl; - throw Resampler::ImplementationError; //!!! of course, need to catch this! - } - - if (m_channels > 1) { - v_deinterleave(out, m_iout, m_channels, output_frames_gen); - } - - return output_frames_gen; -} - -int -D_Resample::resampleInterleaved(float *const BQ_R__ out, - int outcount, - const float *const BQ_R__ in, - int incount, - double ratio, - bool final) -{ - int input_frames, output_frames, end_of_input, source_used; - float src_ratio; - - int outcount = (int)lrint(ceil(incount * ratio)); - - input_frames = incount; - output_frames = outcount; - src_ratio = ratio; - end_of_input = (final ? 1 : 0); - - int output_frames_gen = resample_process(m_src, - src_ratio, - const_cast(in), - input_frames, - end_of_input, - &source_used, - out, - output_frames); - - if (output_frames_gen < 0) { - cerr << "Resampler::process: libresample error: " - << endl; - throw Resampler::ImplementationError; //!!! of course, need to catch this! - } - - return output_frames_gen; -} - -void -D_Resample::reset() -{ -} - -#endif /* HAVE_LIBRESAMPLE */ - #ifdef USE_BQRESAMPLER class D_BQResampler : public Resampler::Impl @@ -1414,9 +1219,6 @@ #ifdef USE_SPEEX m_method = 2; #endif -#ifdef HAVE_LIBRESAMPLE - m_method = 3; -#endif #ifdef USE_BQRESAMPLER m_method = 4; #endif @@ -1429,9 +1231,6 @@ #ifdef HAVE_IPP m_method = 0; #endif -#ifdef HAVE_LIBRESAMPLE - m_method = 3; -#endif #ifdef USE_SPEEX m_method = 2; #endif @@ -1447,9 +1246,6 @@ #ifdef HAVE_IPP m_method = 0; #endif -#ifdef HAVE_LIBRESAMPLE - m_method = 3; -#endif #ifdef USE_SPEEX m_method = 2; #endif @@ -1505,16 +1301,6 @@ break; case 3: -#ifdef HAVE_LIBRESAMPLE - d = new Resamplers::D_Resample - (params.quality, params.ratioChange, - channels, - params.initialSampleRate, params.maxBufferSize, params.debugLevel); -#else - cerr << "Resampler::Resampler: No implementation available!" << endl; - abort(); -#endif - break; case 4: #ifdef USE_BQRESAMPLER