[FFmpeg-devel] [PATCH] libavfilter: add atempo filter (revised patch v5)
Michael Niedermayer
michaelni at gmx.at
Wed Jun 13 04:27:51 CEST 2012
On Tue, Jun 12, 2012 at 08:25:34PM -0600, Pavel Koshevoy wrote:
> On 6/12/2012 7:19 PM, Pavel Koshevoy wrote:
> >On 06/12/2012 05:07 PM, Michael Niedermayer wrote:
> >>On Mon, Jun 11, 2012 at 09:18:02PM -0600, Pavel Koshevoy wrote:
> >
> >[...]
> >
> >>>+/**
> >>>+ * Prepare filter for processing audio data of given format,
> >>>+ * sample rate and number of channels.
> >>>+ */
> >>>+static int yae_reset(ATempoContext *atempo,
> >>>+ enum AVSampleFormat format,
> >>>+ int sample_rate,
> >>>+ int channels)
> >>>+{
> >>>+ const int sample_size = av_get_bytes_per_sample(format);
> >>>+ uint32_t nlevels = 0;
> >>>+ uint32_t pot;
> >>>+ int i;
> >>>+
> >>>+ atempo->format = format;
> >>>+ atempo->channels = channels;
> >>>+ atempo->stride = sample_size * channels;
> >>>+
> >>>+ // pick a segment window size:
> >>>+ atempo->window = sample_rate / 24;
> >>>+
> >>>+ // adjust window size to be a power-of-two integer:
> >>>+ nlevels = av_log2(atempo->window);
> >>>+ pot = 1<< nlevels;
> >>>+ av_assert0(pot<= atempo->window);
> >>>+
> >>>+ if (pot< atempo->window) {
> >>>+ atempo->window = pot * 2;
> >>>+ nlevels++;
> >>>+ }
> >>>+
> >>>+ // initialize audio fragment buffers:
> >>>+ REALLOC_OR_FAIL(atempo->frag[0].data,
> >>>+ atempo->window * atempo->stride);
> >>>+
> >>>+ REALLOC_OR_FAIL(atempo->frag[1].data,
> >>>+ atempo->window * atempo->stride);
> >>>+
> >>>+ REALLOC_OR_FAIL(atempo->frag[0].xdat,
> >>>+ atempo->window * 2 * sizeof(FFTComplex));
> >>>+
> >>>+ REALLOC_OR_FAIL(atempo->frag[1].xdat,
> >>>+ atempo->window * 2 * sizeof(FFTComplex));
> >>>+
> >>>+ // initialize FFT contexts:
> >>>+ av_fft_end(atempo->fft_forward);
> >>>+ av_fft_end(atempo->fft_inverse);
> >>maybe this should call uninit()
> >>
> >>also if something in this fails then the resuslting state is a mess
> >>some arrays one size some others another some memleaks and the ffts
> >>might even end with a double free i think
> >
> >I'll look into that, thank you.
> >
> >>
> >>
> >>>+
> >>>+ atempo->fft_forward = av_fft_init(nlevels + 1, 0);
> >>>+ if (!atempo->fft_forward) {
> >>>+ return AVERROR(ENOMEM);
> >>>+ }
> >>>+
> >>>+ atempo->fft_inverse = av_fft_init(nlevels + 1, 1);
> >>>+ if (!atempo->fft_inverse) {
> >>>+ return AVERROR(ENOMEM);
> >>>+ }
> >>by using a RDFT you can cut the computations needed down by a factor
> >>of 2
> >
> >My DSP experience is limited. What is the procedure for computing
> >cross correlation of two signals using rDFT?
>
>
> I've found this -- http://www.fftw.org/doc/The-1d-Real_002ddata-DFT.html
> I'll see what I can do.
also see
av_rdft_init() and av_rdft_calc() in case you havnt seen them yet
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120613/5adf093d/attachment.asc>
More information about the ffmpeg-devel
mailing list