[FFmpeg-devel] [PATCH] libavfilter: implement avfilter_fill_frame_from_video_buffer_ref()

Stefano Sabatini stefano.sabatini-lala at poste.it
Sat Jun 11 19:39:23 CEST 2011


---
 libavfilter/avcodec.c |   18 ++++++++++++++++++
 libavfilter/avcodec.h |   11 +++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
index 50670bc..2010040 100644
--- a/libavfilter/avcodec.c
+++ b/libavfilter/avcodec.c
@@ -53,3 +53,21 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame
     avfilter_copy_frame_props(picref, frame);
     return picref;
 }
+
+int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
+                                              const AVFilterBufferRef *picref)
+{
+    if (!picref || !picref->video || !frame)
+        return AVERROR(EINVAL);
+
+    memcpy(frame->data,     picref->data,     sizeof(frame->data));
+    memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
+    frame->pkt_pos          = picref->pos;
+    frame->interlaced_frame = picref->video->interlaced;
+    frame->top_field_first  = picref->video->top_field_first;
+    frame->key_frame        = picref->video->key_frame;
+    frame->pict_type        = picref->video->pict_type;
+    frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
+
+    return 0;
+}
diff --git a/libavfilter/avcodec.h b/libavfilter/avcodec.h
index 4eed6b2..dec5ae4 100644
--- a/libavfilter/avcodec.h
+++ b/libavfilter/avcodec.h
@@ -47,6 +47,17 @@ void avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src);
 AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms);
 
 /**
+ * Fill an AVFrame with the information stored in picref.
+ *
+ * @param frame an already allocated AVFrame
+ * @param picref a video buffer reference
+ * @return 0 in case of success, a negative AVERROR code in case of
+ * failure
+ */
+int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
+                                              const AVFilterBufferRef *picref);
+
+/**
  * Add frame data to buffer_src.
  *
  * @param buffer_src pointer to a buffer source context
-- 
1.7.2.5



More information about the ffmpeg-devel mailing list