[FFmpeg-devel] [PATCH] swresample: make swr_get_out_samples() work with all resamplers

Michael Niedermayer michaelni at gmx.at
Tue Jun 16 01:43:59 CEST 2015


On Thu, Jun 04, 2015 at 07:19:25PM +0200, wm4 wrote:
> Making it fail if e.g. soxr is used makes the function completely
> useless.
> ---
>  libswresample/swresample.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

this together with the other commit results in an insufficent number
of samples being returned for some inputs

an example of this is
./ffmpeg -f s32le -acodec pcm_s32le -ar 44100 -ac 1 -i lena.pnm -af aresample=osr=96000:resampler=soxr:cutoff=.993 -f null -

iam also CCing, Rob Sykes, who is also working on this


> 
> diff --git a/libswresample/swresample.c b/libswresample/swresample.c
> index 9ab29d6..0ef556a 100644
> --- a/libswresample/swresample.c
> +++ b/libswresample/swresample.c
> @@ -852,9 +852,13 @@ int swr_get_out_samples(struct SwrContext *s, int in_samples)
>          return AVERROR(EINVAL);
>  
>      if (s->resampler && s->resample) {
> -        if (!s->resampler->get_out_samples)
> -            return AVERROR(ENOSYS);
> -        out_samples = s->resampler->get_out_samples(s, in_samples);
> +        if (s->resampler->get_out_samples) {
> +            out_samples = s->resampler->get_out_samples(s, in_samples);
> +        } else {
> +            out_samples = av_rescale_rnd(in_samples, s->out_sample_rate,
> +                                         s->in_sample_rate, AV_ROUND_UP) +
> +                          swr_get_delay(s, s->out_sample_rate);
> +        }
>      } else {
>          out_samples = s->in_buffer_count + in_samples;
>          av_assert0(s->out_sample_rate == s->in_sample_rate);
> -- 
> 2.1.4
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150616/bfae3254/attachment.asc>


More information about the ffmpeg-devel mailing list