[FFmpeg-devel] [PATCH] vsrc_buffer.h: remove API dependency on libavcodec/AVFrame

Stefano Sabatini stefano.sabatini-lala at poste.it
Sun Apr 3 17:56:01 CEST 2011


Allow the source to be used in a pure libavfilter application.

A source integrated with libavcodec (a la ffplay.c:input_filter)
should be implemented independently.

Signed-off-by: Stefano Sabatini <stefano.sabatini-lala at poste.it>
---
 ffmpeg.c                  |    5 ++++-
 libavfilter/vsrc_buffer.c |   23 ++++++++++++++---------
 libavfilter/vsrc_buffer.h |    5 +++--
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index 2a7431c..b582b1e 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1624,7 +1624,10 @@ static int output_packet(AVInputStream *ist, int ist_index,
                     if (ist->st->sample_aspect_ratio.num) sar = ist->st->sample_aspect_ratio;
                     else                                  sar = ist->st->codec->sample_aspect_ratio;
                     // add it to be filtered
-                    av_vsrc_buffer_add_frame(ost->input_video_filter, &picture,
+                    av_vsrc_buffer_add_frame(ost->input_video_filter,
+                                             picture.data, picture.linesize,
+                                             picture.interlaced_frame,
+                                             picture.top_field_first,
                                              ist->pts,
                                              sar);
                 }
diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c
index 4967dc6..b8a3c26 100644
--- a/libavfilter/vsrc_buffer.c
+++ b/libavfilter/vsrc_buffer.c
@@ -29,7 +29,10 @@
 
 typedef struct {
     int64_t           pts;
-    AVFrame           frame;
+    uint8_t          *data[4];
+    int              *linesize[4];
+    int               interlaced;
+    int               top_field_first;
     int               has_frame;
     int               h, w;
     enum PixelFormat  pix_fmt;
@@ -37,7 +40,9 @@ typedef struct {
     AVRational        pixel_aspect;
 } BufferSourceContext;
 
-int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
+                             uint8_t *data[4], int linesize[4],
+                             int interlaced, int top_field_first,
                              int64_t pts, AVRational pixel_aspect)
 {
     BufferSourceContext *c = buffer_filter->priv;
@@ -50,10 +55,10 @@ int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
         //return -1;
     }
 
-    memcpy(c->frame.data    , frame->data    , sizeof(frame->data));
-    memcpy(c->frame.linesize, frame->linesize, sizeof(frame->linesize));
-    c->frame.interlaced_frame= frame->interlaced_frame;
-    c->frame.top_field_first = frame->top_field_first;
+    memcpy(c->data    , data    , sizeof(data    [0]) * 4);
+    memcpy(c->linesize, linesize, sizeof(linesize[0]) * 4);
+    c->interlaced      = interlaced;
+    c->top_field_first = top_field_first;
     c->pts = pts;
     c->pixel_aspect = pixel_aspect;
     c->has_frame = 1;
@@ -126,13 +131,13 @@ static int request_frame(AVFilterLink *link)
                                        link->w, link->h);
 
     av_image_copy(picref->data, picref->linesize,
-                  c->frame.data, c->frame.linesize,
+                  c->data, c->linesize,
                   picref->format, link->w, link->h);
 
     picref->pts                    = c->pts;
     picref->video->pixel_aspect    = c->pixel_aspect;
-    picref->video->interlaced      = c->frame.interlaced_frame;
-    picref->video->top_field_first = c->frame.top_field_first;
+    picref->video->interlaced      = c->interlaced;
+    picref->video->top_field_first = c->top_field_first;
     avfilter_start_frame(link, avfilter_ref_buffer(picref, ~0));
     avfilter_draw_slice(link, 0, link->h, 1);
     avfilter_end_frame(link);
diff --git a/libavfilter/vsrc_buffer.h b/libavfilter/vsrc_buffer.h
index a77e42f..2f892ec 100644
--- a/libavfilter/vsrc_buffer.h
+++ b/libavfilter/vsrc_buffer.h
@@ -19,9 +19,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "libavcodec/avcodec.h" /* AVFrame */
 #include "avfilter.h"
 
-int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame,
+int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter,
+                             uint8_t *data[4], int linesize[4],
+                             int interlaced, int top_field_first,
                              int64_t pts, AVRational pixel_aspect);
 
-- 
1.7.2.3



More information about the ffmpeg-devel mailing list