[FFmpeg-devel] [PATCH] examples: add resampling_audio.c file
Stefano Sabatini
stefasab at gmail.com
Tue Dec 4 00:12:53 CET 2012
On date Monday 2012-12-03 16:42:03 +0100, Michael Niedermayer encoded:
> On Mon, Dec 03, 2012 at 01:31:34PM +0100, Stefano Sabatini wrote:
> > On date Sunday 2012-12-02 00:34:03 +0100, Michael Niedermayer encoded:
> > > On Sat, Dec 01, 2012 at 08:21:47PM +0100, Stefano Sabatini wrote:
[...]
> > [...]
> > > > + /* allocate source and destination samples buffers */
> > > > +
> > > > + src_nb_channels = av_get_channel_layout_nb_channels(src_ch_layout);
> > > > + ret = alloc_samples_array_and_data(&src_data, &src_linesize, src_nb_channels,
> > > > + src_nb_samples, src_sample_fmt, 0);
> > > > + if (ret < 0) {
> > > > + fprintf(stderr, "Could not allocate source samples\n");
> > > > + goto end;
> > > > + }
> > > > +
> > >
> >
> > > > + /* compute the number of converted samples: buffering is avoided
> > > > + * ensuring that the output buffer will contain at least all the
> > > > + * converted input samples */
> > > > + dst_nb_samples = av_rescale_rnd(swr_get_delay(swr_ctx, dst_rate) + src_nb_samples,
> > > > + dst_rate, src_rate, AV_ROUND_UP);
> > >
> > > isnt this mixing up src and dst rates ?
> >
> > Yes, it is:
> >
> > N2 = N1 * R2 / R1
> >
> > and it is copied from the swresample.h doxy.
>
> from where?
>
> the doxy says this:
>
> * av_opt_set_int(swr, "in_sample_rate", 48000, 0);
> * av_opt_set_int(swr, "out_sample_rate", 44100, 0);
> [....]
> * int out_samples = av_rescale_rnd(swr_get_delay(swr, 48000) +
> * in_samples, 44100, 48000, AV_ROUND_UP);
dst_rate = 44100
src_rate = 48000
And I'm not sure why swr_get_delay() is useful/required.
--
FFmpeg = Frightening and Funny Murdering Perfectionist Elected Gadget
More information about the ffmpeg-devel
mailing list