[FFmpeg-devel] [ffmpeg-devel] [PATCH 4/4] lavfi: add audio resample filter

Mina Nagy Zaki mnzaki at gmail.com
Mon Aug 1 11:34:10 CEST 2011


On Wed, Jul 27, 2011 at 12:53:01PM +0200, Stefano Sabatini wrote:
> On date Wednesday 2011-07-27 01:05:20 +0300, Mina Nagy Zaki encoded:
[...]
> > +        for (i = 0; i < nb_channels; i++) {
> > +            resample->cached_data[i]    =
> > +                av_realloc(resample->cached_data[i], cached_nb_samples * sizeof(int16_t));
> 
> > +            resample->resampled_data[i] =
> > +                av_realloc(resample->resampled_data[i], 4 * requested_out_nb_samples + 16);
> 
> More readable
> 4 * requested_out_nb_samples + 16 =>
> 
> requested_out_nb_samples * sizeof(int16_t) * 2 + 16
> 
> 16 may be replaced by a macro ALIGN,

Can you elaborate?

> *2 is from the libavcodec resample code, and I can't comment on it,
> what happens if you drop it?

Like I mentioned before, I don't quite see what the extra 2 factor is for.
Removing it has no side effects (besides lower memory usage that is...)

> > +        }
> > +        if (resample->outsamplesref)
> > +            avfilter_unref_buffer(resample->outsamplesref);
> > +        resample->outsamplesref = avfilter_get_audio_buffer(outlink,
> > +                                                            AV_PERM_WRITE | AV_PERM_REUSE2,
> > +                                                            inlink->format,
> > +                                                            requested_out_nb_samples,
> > +                                                            insamplesref->audio->channel_layout,
> > +                                                            insamplesref->audio->planar);
> 
> Possibly missing avfilter_copy_buffer_ref_props(outsamplesref, insamplesref);

I don't think so, this is just a normal output buffer request, and besides
everything has already been done in get_audio_buffer.

> 
> > +        resample->outsamplesref->audio->sample_rate = outlink->sample_rate;
> 
> 
> > +        resample->cached_nb_samples = cached_nb_samples;
> 
> This should be set in the previous block (when the buffers are realloced).

Moved.

[...]
> Missing docs.

Added simple doc.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-lavfi-add-audio-resample-filter.patch
Type: text/x-diff
Size: 14384 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110801/6624c315/attachment.bin>


More information about the ffmpeg-devel mailing list