[FFmpeg-devel] [PATCH] lswr: remove support for libsoxr resampling
James Almer
jamrial at gmail.com
Mon Mar 6 07:15:37 EET 2017
On 3/6/2017 12:19 AM, Rostislav Pehlivanov wrote:
> The soxr resampler is slower and worse than the swr resampler,
> hence drop the former.
>
> Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>
> ---
> Changelog | 1 +
> MAINTAINERS | 1 -
> configure | 5 +-
> doc/resampler.texi | 53 ++++-----------
> libswresample/Makefile | 1 -
> libswresample/options.c | 7 --
> libswresample/resample.c | 2 +-
> libswresample/soxr_resample.c | 130 ------------------------------------
> libswresample/swresample.c | 18 +----
> libswresample/swresample.h | 7 --
> libswresample/swresample_internal.h | 9 +--
> 11 files changed, 21 insertions(+), 213 deletions(-)
> delete mode 100644 libswresample/soxr_resample.c
>
Crashes doing about anything with libswr, like for example "make fate-swr"
[...]
> diff --git a/libswresample/options.c b/libswresample/options.c
> index 4abf5e0518..b450d28475 100644
> --- a/libswresample/options.c
> +++ b/libswresample/options.c
> @@ -91,13 +91,6 @@ static const AVOption options[]={
> /* duplicate option in order to work with avconv */
> {"resample_cutoff" , "set cutoff frequency ratio" , OFFSET(cutoff) , AV_OPT_TYPE_DOUBLE,{.dbl=0. }, 0 , 1 , PARAM },
>
> -{"resampler" , "set resampling Engine" , OFFSET(engine) , AV_OPT_TYPE_INT , {.i64=0 }, 0 , SWR_ENGINE_NB-1, PARAM, "resampler"},
> -{"swr" , "select SW Resampler" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_ENGINE_SWR }, INT_MIN, INT_MAX , PARAM, "resampler"},
> -{"soxr" , "select SoX Resampler" , 0 , AV_OPT_TYPE_CONST, {.i64=SWR_ENGINE_SOXR }, INT_MIN, INT_MAX , PARAM, "resampler"},
> -{"precision" , "set soxr resampling precision (in bits)"
> - , OFFSET(precision) , AV_OPT_TYPE_DOUBLE,{.dbl=20.0 }, 15.0 , 33.0 , PARAM },
> -{"cheby" , "enable soxr Chebyshev passband & higher-precision irrational ratio approximation"
> - , OFFSET(cheby) , AV_OPT_TYPE_BOOL , {.i64=0 }, 0 , 1 , PARAM },
Public options, need to be deprecated before removal.
> diff --git a/libswresample/swresample.c b/libswresample/swresample.c
> index dea61391ac..de46118d86 100644
> --- a/libswresample/swresample.c
> +++ b/libswresample/swresample.c
> @@ -133,7 +133,6 @@ static void clear_context(SwrContext *s){
> swri_audio_convert_free(&s->full_convert);
> swri_rematrix_free(s);
>
> - s->delayed_samples_fixup = 0;
> s->flushed = 0;
> }
>
> @@ -188,16 +187,6 @@ av_cold int swr_init(struct SwrContext *s){
> s->out_ch_layout = 0;
> }
>
> - switch(s->engine){
> -#if CONFIG_LIBSOXR
> - case SWR_ENGINE_SOXR: s->resampler = &swri_soxr_resampler; break;
> -#endif
> - case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break;
> - default:
> - av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n");
> - return AVERROR(EINVAL);
> - }
> -
> if(!s->used_ch_count)
> s->used_ch_count= s->in.ch_count;
>
> @@ -225,8 +214,7 @@ av_cold int swr_init(struct SwrContext *s){
> s->int_sample_fmt= AV_SAMPLE_FMT_S16P;
> }else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P
> && av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P
> - && !s->rematrix
> - && s->engine != SWR_ENGINE_SOXR){
> + && !s->rematrix){
> s->int_sample_fmt= AV_SAMPLE_FMT_S32P;
> }else if(av_get_bytes_per_sample(s->in_sample_fmt) <= 4){
> s->int_sample_fmt= AV_SAMPLE_FMT_FLTP;
> @@ -265,7 +253,7 @@ av_cold int swr_init(struct SwrContext *s){
> }
>
> if (s->out_sample_rate!=s->in_sample_rate || (s->flags & SWR_FLAG_RESAMPLE)){
> - s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, s->kaiser_beta, s->precision, s->cheby, s->exact_rational);
> + s->resample = s->resampler->init(s->resample, s->out_sample_rate, s->in_sample_rate, s->filter_size, s->phase_shift, s->linear_interp, s->cutoff, s->int_sample_fmt, s->filter_type, s->kaiser_beta, s->exact_rational);
s->resampler is NULL here after the chunk removed above. Most assuredly
the source of the crashes.
> if (!s->resample) {
> av_log(s, AV_LOG_ERROR, "Failed to initialize resampler\n");
> return AVERROR(ENOMEM);
> @@ -482,7 +470,7 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count,
> AudioData in, out, tmp;
> int ret_sum=0;
> int border=0;
> - int padless = ARCH_X86 && s->engine == SWR_ENGINE_SWR ? 7 : 0;
> + int padless = ARCH_X86 && 7;
ARCH_X86 ? 7 : 0; is more readable.
>
> av_assert1(s->in_buffer.ch_count == in_param->ch_count);
> av_assert1(s->in_buffer.planar == in_param->planar);
> diff --git a/libswresample/swresample.h b/libswresample/swresample.h
> index a8db5c2490..f63e3aea85 100644
> --- a/libswresample/swresample.h
> +++ b/libswresample/swresample.h
> @@ -159,13 +159,6 @@ enum SwrDitherType {
> SWR_DITHER_NB, ///< not part of API/ABI
> };
>
> -/** Resampling Engines */
> -enum SwrEngine {
> - SWR_ENGINE_SWR, /**< SW Resampler */
> - SWR_ENGINE_SOXR, /**< SoX Resampler */
> - SWR_ENGINE_NB, ///< not part of API/ABI
> -};
This is a public header, you can't remove this without a deprecation
period.
Keep the public facing enums and options, but remove all the internal
changes introduced to accommodate soxr (struct Resampler and related
function pointers, etc).
Choosing SWR_ENGINE_SOXR should still give an error and bail out.
> -
> /** Resampling Filter Types */
> enum SwrFilterType {
> SWR_FILTER_TYPE_CUBIC, /**< Cubic */
> diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h
> index f2ea5a226d..7296d2b9fe 100644
> --- a/libswresample/swresample_internal.h
> +++ b/libswresample/swresample_internal.h
> @@ -69,7 +69,7 @@ struct DitherContext {
> };
>
> typedef struct ResampleContext * (* resample_init_func)(struct ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
> - double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, double precision, int cheby, int exact_rational);
> + double cutoff, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, int exact_rational);
> typedef void (* resample_free_func)(struct ResampleContext **c);
> typedef int (* multiple_resample_func)(struct ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed);
> typedef int (* resample_flush_func)(struct SwrContext *c);
> @@ -89,9 +89,6 @@ struct Resampler {
> get_out_samples_func get_out_samples;
> };
>
> -extern struct Resampler const swri_resampler;
> -extern struct Resampler const swri_soxr_resampler;
> -
> struct SwrContext {
> const AVClass *av_class; ///< AVClass used for AVOption and av_log()
> int log_level_offset; ///< logging level offset
> @@ -112,7 +109,6 @@ struct SwrContext {
> int matrix_encoding; /**< matrixed stereo encoding */
> const int *channel_map; ///< channel index (or -1 if muted channel) map
> int used_ch_count; ///< number of used input channels (mapped channel count if channel_map, otherwise in.ch_count)
> - int engine;
>
> int user_in_ch_count; ///< User set input channel count
> int user_out_ch_count; ///< User set output channel count
> @@ -131,8 +127,6 @@ struct SwrContext {
> double cutoff; /**< resampling cutoff frequency (swr: 6dB point; soxr: 0dB point). 1.0 corresponds to half the output sample rate */
> int filter_type; /**< swr resampling filter type */
> double kaiser_beta; /**< swr beta value for Kaiser window (only applicable if filter_type == AV_FILTER_TYPE_KAISER) */
> - double precision; /**< soxr resampling precision (in bits) */
> - int cheby; /**< soxr: if 1 then passband rolloff will be none (Chebyshev) & irrational ratio approximation precision will be higher */
>
> float min_compensation; ///< swr minimum below which no compensation will happen
> float min_hard_compensation; ///< swr minimum below which no silence inject / sample drop will happen
> @@ -160,7 +154,6 @@ struct SwrContext {
> int64_t outpts; ///< output PTS
> int64_t firstpts; ///< first PTS
> int drop_output; ///< number of output samples to drop
> - double delayed_samples_fixup; ///< soxr 0.1.1: needed to fixup delayed_samples after flush has been called.
>
> struct AudioConvert *in_convert; ///< input conversion context
> struct AudioConvert *out_convert; ///< output conversion context
>
More information about the ffmpeg-devel
mailing list