[FFmpeg-cvslog] lavfi: add a function for copying properties from AVFilterBufferRef-> AVFrame

Anton Khirnov git at videolan.org
Thu May 10 02:33:18 CEST 2012


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Fri Apr 27 17:27:40 2012 +0200| [ab165047a6142ca0c8c333c36f4ebb96477622d7] | committer: Anton Khirnov

lavfi: add a function for copying properties from AVFilterBufferRef->AVFrame

Based on a commit by Stefano Sabatini <stefano.sabatini-lala at poste.it>

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

 libavfilter/avfilter.c |   30 ++++++++++++++++++++++++++++++
 libavfilter/avfilter.h |    8 ++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index d1c82ce..f12ca3a 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -708,6 +708,36 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
     return 0;
 }
 
+int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
+{
+    memcpy(dst->data, src->data, sizeof(dst->data));
+    memcpy(dst->linesize, src->linesize, sizeof(dst->linesize));
+
+    dst->pts     = src->pts;
+    dst->format  = src->format;
+
+    switch (src->type) {
+    case AVMEDIA_TYPE_VIDEO:
+        dst->width               = src->video->w;
+        dst->height              = src->video->h;
+        dst->sample_aspect_ratio = src->video->pixel_aspect;
+        dst->interlaced_frame    = src->video->interlaced;
+        dst->top_field_first     = src->video->top_field_first;
+        dst->key_frame           = src->video->key_frame;
+        dst->pict_type           = src->video->pict_type;
+        break;
+    case AVMEDIA_TYPE_AUDIO:
+        dst->sample_rate         = src->audio->sample_rate;
+        dst->channel_layout      = src->audio->channel_layout;
+        dst->nb_samples          = src->audio->nb_samples;
+        break;
+    default:
+        return AVERROR(EINVAL);
+    }
+
+    return 0;
+}
+
 void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
 {
     // copy common properties
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index c2049f9..ef61a5d 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -848,4 +848,12 @@ static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index,
  */
 int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
 
+/**
+ * Copy the frame properties and data pointers of src to dst, without copying
+ * the actual data.
+ *
+ * @return 0 on success, a negative number on error.
+ */
+int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src);
+
 #endif /* AVFILTER_AVFILTER_H */



More information about the ffmpeg-cvslog mailing list