[FFmpeg-devel] [PATCH 11/13] src_buffer: implement audio buffer copy.

Stefano Sabatini stefasab at gmail.com
Sun Apr 29 18:31:11 CEST 2012


On date Saturday 2012-04-28 16:31:53 +0200, Nicolas George encoded:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavfilter/src_buffer.c |   12 ++++++++++++
>  1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c
> index 70af9c3..fce30ec 100644
> --- a/libavfilter/src_buffer.c
> +++ b/libavfilter/src_buffer.c
> @@ -220,6 +220,7 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
>  {
>      AVFilterLink *outlink = ctx->outputs[0];
>      AVFilterBufferRef *buf;
> +    int channels, data_size, i;
>  
>      switch (outlink->type) {
>  
> @@ -231,6 +232,17 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx,
>                        ref->format, ref->video->w, ref->video->h);
>          break;
>  

> +    case AVMEDIA_TYPE_AUDIO:
> +        buf = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE,
> +                                        ref->audio->nb_samples);

> +        channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout);
> +        data_size = av_samples_get_buffer_size(NULL, channels,
> +                                               ref->audio->nb_samples,
> +                                               ref->format, 1);
> +        for (i = 0; i < FF_ARRAY_ELEMS(ref->buf->data) && ref->buf->data[i]; i++)
> +            memcpy(buf->buf->data[i], ref->buf->data[i], data_size);

Note: this could became a lavu/samplefmt function.

> +        break;

Should be fine.
-- 
FFmpeg = Fascinating and Formidable Magical Pitiless Ecumenical Gadget


More information about the ffmpeg-devel mailing list