From 9fdf77217b39646afdb8907b977e3d7a59f1cb9e Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 14 May 2011 11:46:14 +0200 Subject: [PATCH] lavfi: add avfilter_get_video_buffer_ref_from_frame to avcodec.h Simplify passing AVFrame data to av_vsrc_buffer_add_video_buffer_ref(). --- doc/APIchanges | 3 +++ ffmpeg.c | 8 +++----- libavfilter/avcodec.c | 13 +++++++++++++ libavfilter/avcodec.h | 8 ++++++++ libavfilter/avfilter.h | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index d9e7d326bd..cd1f88894d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h + Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h. + 2011-05-18 - 64150ff - lavc 53.4.0 - AVCodecContext.request_sample_fmt Add request_sample_fmt field to AVCodecContext. diff --git a/ffmpeg.c b/ffmpeg.c index 340a947dd8..d4c7705a09 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1650,11 +1650,9 @@ static int output_packet(AVInputStream *ist, int ist_index, picture.sample_aspect_ratio = ist->st->sample_aspect_ratio; picture.pts = ist->pts; - picref = avfilter_get_video_buffer_ref_from_arrays( - picture.data, picture.linesize, AV_PERM_WRITE, - picture.width, picture.height, picture.format); - avfilter_copy_frame_props(picref, &picture); - av_vsrc_buffer_add_video_buffer_ref2(ost->input_video_filter, picref, ""); //TODO user setable params + picref = + avfilter_get_video_buffer_ref_from_frame(&picture, AV_PERM_WRITE); + av_vsrc_buffer_add_video_buffer_ref(ost->input_video_filter, picref, ""); //TODO user setable params picref->buf->data[0] = NULL; avfilter_unref_buffer(picref); } diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c index c2f8651106..50670bc55e 100644 --- a/libavfilter/avcodec.c +++ b/libavfilter/avcodec.c @@ -40,3 +40,16 @@ void avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src) dst->video->pict_type = src->pict_type; } } + +AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, + int perms) +{ + AVFilterBufferRef *picref = + avfilter_get_video_buffer_ref_from_arrays(frame->data, frame->linesize, perms, + frame->width, frame->height, + frame->format); + if (!picref) + return NULL; + avfilter_copy_frame_props(picref, frame); + return picref; +} diff --git a/libavfilter/avcodec.h b/libavfilter/avcodec.h index f438860d0b..e6ae907391 100644 --- a/libavfilter/avcodec.h +++ b/libavfilter/avcodec.h @@ -37,4 +37,12 @@ */ void avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src); +/** + * 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_video_buffer_ref_from_frame(const AVFrame *frame, int perms); + #endif /* AVFILTER_AVCODEC_H */ diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 03a1e49a46..171c9e4c74 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -26,7 +26,7 @@ #include "libavutil/samplefmt.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 5 +#define LIBAVFILTER_VERSION_MINOR 6 #define LIBAVFILTER_VERSION_MICRO 0 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \