[FFmpeg-cvslog] vsrc_buffer: add av_vsrc_buffer_add_frame()

Stefano Sabatini git at videolan.org
Thu May 19 23:33:09 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Thu May 19 01:17:16 2011 +0200| [c000a9f78390b71812c7ee5187bbccc3c2d79b1e] | committer: Stefano Sabatini

vsrc_buffer: add av_vsrc_buffer_add_frame()

The new function is a wrapper around
av_vsrc_buffer_add_video_buffer_ref(), and allows to simplify the act
of pushing AVFrame data to the source buffer.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c000a9f78390b71812c7ee5187bbccc3c2d79b1e
---

 doc/APIchanges            |    3 +++
 ffmpeg.c                  |    7 +------
 libavfilter/avcodec.h     |    9 +++++++++
 libavfilter/avfilter.h    |    2 +-
 libavfilter/vsrc_buffer.c |   17 +++++++++++++++++
 5 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index cd1f888..710967c 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.8.0 - avcodec.h
+  Add av_vsrc_buffer_add_frame() to libavfilter/avcodec.h.
+
 2011-05-XX - XXXXXX - lavfi 2.6.0 - avcodec.h
   Add avfilter_get_video_buffer_ref_from_frame() to libavfilter/avcodec.h.
 
diff --git a/ffmpeg.c b/ffmpeg.c
index 182f929..2b19c7f 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1643,18 +1643,13 @@ static int output_packet(AVInputStream *ist, int ist_index,
 #if CONFIG_AVFILTER
         if(ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
             for(i=0;i<nb_ostreams;i++) {
-                AVFilterBufferRef *picref;
                 ost = ost_table[i];
                 if (ost->input_video_filter && ost->source_index == ist_index) {
                     if (!picture.sample_aspect_ratio.num)
                         picture.sample_aspect_ratio = ist->st->sample_aspect_ratio;
                     picture.pts = ist->pts;
 
-                    picref =
-                        avfilter_get_video_buffer_ref_from_frame(&picture, AV_PERM_WRITE);
-                    av_vsrc_buffer_add_video_buffer_ref(ost->input_video_filter, picref);
-                    picref->buf->data[0] = NULL;
-                    avfilter_unref_buffer(picref);
+                    av_vsrc_buffer_add_frame(ost->input_video_filter, &picture);
                 }
             }
         }
diff --git a/libavfilter/avcodec.h b/libavfilter/avcodec.h
index e6ae907..74434e8 100644
--- a/libavfilter/avcodec.h
+++ b/libavfilter/avcodec.h
@@ -45,4 +45,13 @@ void avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
  */
 AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms);
 
+/**
+ * Add frame data to buffer_src.
+ *
+ * @param buffer_src pointer to a buffer source context
+ * @return >= 0 in case of success, a negative AVERROR code in case of
+ * failure
+ */
+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src, const AVFrame *frame);
+
 #endif /* AVFILTER_AVCODEC_H */
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index a0ad358..02f2ed2 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  7
+#define LIBAVFILTER_VERSION_MINOR  8
 #define LIBAVFILTER_VERSION_MICRO  0
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index 9815f94..6a2fcbf 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -106,6 +106,23 @@ int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, AVFilter
     return 0;
 }
 
+#if CONFIG_AVCODEC
+#include "avcodec.h"
+
+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_src, const AVFrame *frame)
+{
+    AVFilterBufferRef *picref =
+        avfilter_get_video_buffer_ref_from_frame(frame, AV_PERM_WRITE);
+    if (!picref)
+        return AVERROR(ENOMEM);
+    av_vsrc_buffer_add_video_buffer_ref(buffer_src, picref);
+    picref->buf->data[0] = NULL;
+    avfilter_unref_buffer(picref);
+
+    return 0;
+}
+#endif
+
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
 {
     BufferSourceContext *c = ctx->priv;



More information about the ffmpeg-cvslog mailing list