[FFmpeg-devel] [PATCH] Add get_audio_buffer_ref function to lavfi.

Michael Niedermayer michaelni
Wed Sep 15 20:01:31 CEST 2010


On Wed, Sep 15, 2010 at 09:10:45AM -0700, S.N. Hemanth Meenakshisundaram wrote:
>  On 09/15/2010 05:02 AM, Michael Niedermayer wrote:
> > On Thu, Sep 02, 2010 at 12:52:54AM -0700, S.N. Hemanth Meenakshisundaram wrote:
> > [...]
> >> +int av_asrc_buffer_add_frame(AVFilterContext *ctx, uint8_t *frame, int sample_fmt,
> >> +                             int size, int64_t ch_layout, int planar, int64_t pts)
> >> +{
> >> +    AVFilterLink *link            = ctx->outputs[0];
> >> +    ABufferSourceContext *abuffer = ctx->priv;
> >> +    AVFilterBufferRef *samplesref;
> >> +
> >> +    if (av_fifo_space(abuffer->fifo) < sizeof(samplesref)) {
> >> +        av_log(ctx, AV_LOG_ERROR,
> >> +               "Buffering limit reached. Please consume some available frames before adding new ones.\n");
> >> +        return AVERROR(ENOMEM);
> >> +    }
> >> +
> >> +    samplesref = avfilter_get_audio_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE |
> >> +                                           AV_PERM_REUSE2, sample_fmt, size, ch_layout, planar);
> >> +
> >> +    memcpy(samplesref->data[0], frame, samplesref->audio->size);
> > it still does a memcpy
> > the user should receive a pointer into which she can store the audio not have
> > to provide a pointer to the filter and that then does a forced copy
> >
> > or any other method that avoids the memcpy
> >
> > [...]
> >
> 
> 
> I had sent the attached patch earlier too. This adds a
> get_audio_buffer_ref function that will help avoid the memcpy above.
> 
> If the attached patch is ok, I can modify this asrc_abuffer too.

>  defaults.c |   35 ++++++++++++++++++++++-------------
>  1 file changed, 22 insertions(+), 13 deletions(-)
> 5d9c2d6bba029c6b2b036d125f08af4e0e85b98e  get_buffer_ref.patch
> --- a/libavfilter/defaults.c
> +++ b/libavfilter/defaults.c
> @@ -80,16 +80,20 @@
>      return NULL;
>  }
>  
> -AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
> -                                                     enum SampleFormat sample_fmt, int size,
> -                                                     int64_t channel_layout, int planar)
> +AVFilterBufferRef *
> +avfilter_default_get_audio_buffer_ref(AVFilterLink *link, char *buf, int perms,

link is unused

doxy (in header) missing

and iam unusre if it should free buf on failure or leave that to the caller

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100915/90fa02cb/attachment.pgp>



More information about the ffmpeg-devel mailing list