[FFmpeg-devel] [PATCH 09/13] lavfi: implement avfilter_get_audio_buffer_ref_from_frame.
Stefano Sabatini
stefasab at gmail.com
Sun Apr 29 17:56:32 CEST 2012
On date Saturday 2012-04-28 16:31:51 +0200, Nicolas George encoded:
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavfilter/avcodec.c | 14 ++++++++++++++
> libavfilter/avcodec.h | 10 ++++++++++
> 2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
> index 3581aef..4702461 100644
> --- a/libavfilter/avcodec.c
> +++ b/libavfilter/avcodec.c
> @@ -56,6 +56,20 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame
> return picref;
> }
>
> +AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame,
> + int perms)
> +{
> + AVFilterBufferRef *picref =
> + avfilter_get_audio_buffer_ref_from_arrays((uint8_t **)frame->data, (int *)frame->linesize, perms,
> + frame->nb_samples, frame->format,
> + frame->channel_layout,
> + av_sample_fmt_is_planar(frame->format));
> + if (!picref)
> + return NULL;
> + avfilter_copy_frame_props(picref, frame);
> + return picref;
> +}
I suppose this can't work if the frame has more than 8 channels and
format is planar, but this should be possibly fixed in
avfilter_get_audio_buffer_ref_from_arrays() and in how we represent
the audio data in libavfilter (current limit of 8 channels), so
unrelated to this patch.
> +
> int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
> const AVFilterBufferRef *samplesref)
> {
> diff --git a/libavfilter/avcodec.h b/libavfilter/avcodec.h
> index 64773a6..1aa8b9c 100644
> --- a/libavfilter/avcodec.h
> +++ b/libavfilter/avcodec.h
> @@ -46,6 +46,16 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
> */
> AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms);
>
> +
> +/**
> + * Create and return a picref reference from the data and properties
> + * contained in frame.
> + *
> + * @param perms permissions to assign to the new buffer reference
> + */
> +AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_frame(const AVFrame *frame,
> + int perms);
> +
LGTM.
--
FFmpeg = Fiendish and Fiendish Mega Power Elastic God
More information about the ffmpeg-devel
mailing list