this allow to use phase_count_compensation on init (rather than rebuild on swr_set_compensation) when options suggest that soft compensation is enabled
Signed-off-by: Muhammad Faiz <mfc...@gmail.com> --- libswresample/resample.c | 4 +++- libswresample/soxr_resample.c | 2 +- libswresample/swresample.c | 5 ++++- libswresample/swresample_internal.h | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libswresample/resample.c b/libswresample/resample.c index 8635bf1..c07a7d7 100644 --- a/libswresample/resample.c +++ b/libswresample/resample.c @@ -302,7 +302,7 @@ fail: static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta, - double precision, int cheby, int exact_rational) + double precision, int cheby, int exact_rational, int force_comp) { double cutoff = cutoff0? cutoff0 : 0.97; double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); @@ -316,6 +316,8 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r if (phase_count_exact <= phase_count) { phase_count_compensation = phase_count_exact * (phase_count / phase_count_exact); phase_count = phase_count_exact; + if (force_comp) + phase_count = phase_count_compensation; } } diff --git a/libswresample/soxr_resample.c b/libswresample/soxr_resample.c index b9c6735..b451b96 100644 --- a/libswresample/soxr_resample.c +++ b/libswresample/soxr_resample.c @@ -30,7 +30,7 @@ #include <soxr.h> static struct ResampleContext *create(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, double precision, int cheby, int exact_rational, int force_comp){ soxr_error_t error; soxr_datatype_t type = diff --git a/libswresample/swresample.c b/libswresample/swresample.c index 0ef4dea..0bc7683 100644 --- a/libswresample/swresample.c +++ b/libswresample/swresample.c @@ -265,7 +265,10 @@ 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->precision, s->cheby, s->exact_rational, + s->min_compensation < FLT_MAX && s->soft_compensation_duration && s->max_soft_compensation); if (!s->resample) { av_log(s, AV_LOG_ERROR, "Failed to initialize resampler\n"); return AVERROR(ENOMEM); diff --git a/libswresample/swresample_internal.h b/libswresample/swresample_internal.h index f2ea5a2..f00439e 100644 --- a/libswresample/swresample_internal.h +++ b/libswresample/swresample_internal.h @@ -69,7 +69,8 @@ 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, double precision, int cheby, + int exact_rational, int force_comp); 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); -- 2.5.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel