[FFmpeg-devel] [PATCH] lavfi: implement avfilter_get_audio_buffer_ref_from_arrays()
Michael Niedermayer
michaelni at gmx.at
Fri Jun 10 01:48:55 CEST 2011
On Fri, Jun 10, 2011 at 01:35:11AM +0200, Stefano Sabatini wrote:
> On date Thursday 2011-06-09 20:17:55 +0200, Michael Niedermayer encoded:
> > On Thu, Jun 09, 2011 at 10:37:41AM +0200, Stefano Sabatini wrote:
> > > ---
> > > libavfilter/avfilter.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> > > libavfilter/avfilter.h | 18 ++++++++++++++++++
> > > 2 files changed, 62 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
> > > index 6d55350..acab816 100644
> > > --- a/libavfilter/avfilter.c
> > > +++ b/libavfilter/avfilter.c
> > > @@ -421,6 +421,50 @@ AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
> > > return ret;
> > > }
> > >
> > > +AVFilterBufferRef *
> > > +avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms,
> > > + int nb_samples, enum AVSampleFormat sample_fmt,
> > > + int64_t channel_layout, int planar)
> > > +{
> > > + AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
> > > + AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef));
> > > +
> > > + if (!samples || !samplesref)
> > > + goto fail;
> > > +
> > > + samplesref->buf = samples;
> > > + samplesref->buf->free = ff_avfilter_default_free_buffer;
> > > + if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps))))
> > > + goto fail;
> > > +
> > > + samplesref->audio->nb_samples = nb_samples;
> > > + samplesref->audio->channel_layout = channel_layout;
> > > + samplesref->audio->planar = planar;
> > > +
> > > + /* make sure the buffer gets read permission or it's useless for output */
> > > + samplesref->perms = perms | AV_PERM_READ;
> > > +
> > > + samples->refcount = 1;
> > > + samplesref->type = AVMEDIA_TYPE_AUDIO;
> > > + samplesref->format = sample_fmt;
> > > +
> > > + memcpy(samples->data, data, sizeof(samples->data));
> > > + memcpy(samples->linesize, linesize, sizeof(samples->linesize));
> > > + memcpy(samplesref->data, data, sizeof(samplesref->data));
> > > + memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize));
> > > +
> > > + return samplesref;
> > > +
> > > +fail:
> > > + if (samplesref) {
> > > + if (samplesref->audio)
> > > + av_free(samplesref->audio);
> > > + av_free(samplesref);
> > > + }
> > > + if (samples) av_free(samples);
> >
> > av_freep()
>
> Note that it matters as the variables are locals.
until someone makes non locals out of them, but i see your point of
course
[...]
> + * @param data pointers to the samples plane buffers
> + * @param linesize linesize for the samples plane buffers
> + * @param perms the required access permissions
> + * @param nb_samples number of samples per channel
> + * @param sample_fmt the format of each sample in the buffer to allocate
> + * @param planar audio data layout - planar or packed
> + * @param channel_layout the channel layout of the buffer, <=0 if unknown
> + * @param nb_channels the number of channels, <= 0 if unknown
nit: some vertical alignment could be added
LGTM either way
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes
-------------- 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/20110610/9f2f7a40/attachment.asc>
More information about the ffmpeg-devel
mailing list