[FFmpeg-soc] [soc]: r2132 - in libavfilter: graphparser.c vf_overlay.c vf_scale.c

vitor subversion at mplayerhq.hu
Fri Apr 18 20:18:36 CEST 2008


Author: vitor
Date: Fri Apr 18 20:18:35 2008
New Revision: 2132

Log:
Move code from handle_link() to the only place the function is called

Modified:
   libavfilter/graphparser.c
   libavfilter/vf_overlay.c
   libavfilter/vf_scale.c

Modified: libavfilter/graphparser.c
==============================================================================
--- libavfilter/graphparser.c	(original)
+++ libavfilter/graphparser.c	Fri Apr 18 20:18:35 2008
@@ -199,50 +199,6 @@ static void free_inout(AVFilterInOut *he
 }
 
 /**
- * Process a link. This funcion looks for a matching label in the *inout
- * linked list. If none is found, it adds this link to the list.
- */
-static int handle_link(char *name, AVFilterInOut **inout, int pad,
-                       enum LinkType type, AVFilterContext *filter,
-                       AVClass *log_ctx)
-{
-    AVFilterInOut *p = *inout;
-
-    for (; p && strcmp(p->name, name); p = p->next);
-
-    if(!p) {
-        // First label apearence, add it to the linked list
-        AVFilterInOut *inoutn = av_malloc(sizeof(AVFilterInOut));
-
-        inoutn->name    = name;
-        inoutn->type    = type;
-        inoutn->filter  = filter;
-        inoutn->pad_idx = pad;
-        inoutn->next    = *inout;
-        *inout = inoutn;
-         return 0;
-    }
-
-    if(p->type == LinkTypeIn && type == LinkTypeOut) {
-        if(link_filter(filter, pad, p->filter, p->pad_idx, log_ctx) < 0)
-            return -1;
-    } else if(p->type == LinkTypeOut && type == LinkTypeIn) {
-        if(link_filter(p->filter, p->pad_idx, filter, pad, log_ctx) < 0)
-            return -1;
-    } else {
-        av_log(log_ctx, AV_LOG_ERROR,
-               "Two links named '%s' are either both input or both output\n",
-               name);
-        return -1;
-    }
-
-    p->filter = NULL;
-
-    return 0;
-}
-
-
-/**
  * Parse "[a1][link2] ... [etc]"
  */
 static int parse_inouts(const char **buf, AVFilterInOut **inout, int pad,
@@ -251,17 +207,47 @@ static int parse_inouts(const char **buf
 {
     while (**buf == '[') {
         char *name;
+        AVFilterInOut *p = *inout;
 
         parse_link_name(buf, &name, log_ctx);
 
         if(!name)
             return -1;
 
-        if(handle_link(name, inout, pad++, type, filter, log_ctx) < 0)
-            return -1;
+        for (; p && strcmp(p->name, name); p = p->next);
+
+        if(!p) {
+            // First label apearence, add it to the linked list
+            AVFilterInOut *inoutn = av_malloc(sizeof(AVFilterInOut));
 
+            inoutn->name    = name;
+            inoutn->type    = type;
+            inoutn->filter  = filter;
+            inoutn->pad_idx = pad;
+            inoutn->next    = *inout;
+            *inout = inoutn;
+        } else {
+
+            if(p->type == LinkTypeIn && type == LinkTypeOut) {
+                if(link_filter(filter, pad, p->filter, p->pad_idx, log_ctx) < 0)
+                    return -1;
+            } else if(p->type == LinkTypeOut && type == LinkTypeIn) {
+                if(link_filter(p->filter, p->pad_idx, filter, pad, log_ctx) < 0)
+                    return -1;
+            } else {
+                av_log(log_ctx, AV_LOG_ERROR,
+                       "Two links named '%s' are either both input or both output\n",
+                       name);
+                return -1;
+            }
+
+            p->filter = NULL;
+        }
+
+        pad++;
         consume_whitespace(buf);
     }
+
     return pad;
 }
 

Modified: libavfilter/vf_overlay.c
==============================================================================
--- libavfilter/vf_overlay.c	(original)
+++ libavfilter/vf_overlay.c	Fri Apr 18 20:18:35 2008
@@ -37,7 +37,7 @@ typedef struct {
 static int init(AVFilterContext *ctx, const char *args, void *opaque)
 {
     OverlayContext *over = ctx->priv;
-
+    av_log(ctx, AV_LOG_ERROR, "args=\"%s\"\n", args);
     if(!args || sscanf(args, "%d:%d", &over->x, &over->y) != 2) {
         over->x =
         over->y = 0;

Modified: libavfilter/vf_scale.c
==============================================================================
--- libavfilter/vf_scale.c	(original)
+++ libavfilter/vf_scale.c	Fri Apr 18 20:18:35 2008
@@ -34,8 +34,6 @@ typedef struct
      *  -1 = keep original aspect
      */
     int w, h;
-
-    int sliceY;                 ///< top of current output slice
 } ScaleContext;
 
 static int init(AVFilterContext *ctx, const char *args, void *opaque)
@@ -112,7 +110,6 @@ static int config_props(AVFilterLink *li
 
 static void start_frame(AVFilterLink *link, AVFilterPicRef *picref)
 {
-    ScaleContext *scale = link->dst->priv;
     AVFilterLink *out = link->dst->outputs[0];
 
     out->outpic      = avfilter_get_video_buffer(out, AV_PERM_WRITE);
@@ -125,20 +122,22 @@ static void start_frame(AVFilterLink *li
          FFMAX(out->outpic->pixel_aspect.num,  out->outpic->pixel_aspect.den));
 
     avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0));
-
-    scale->sliceY = 0;
 }
 
-static void draw_slice(AVFilterLink *link, int y, int h)
+
+/* TODO: figure out the swscale API well enough to scale slice at a time */
+static void end_frame(AVFilterLink *link)
 {
     ScaleContext *scale = link->dst->priv;
-    int outH;
 
-    outH = sws_scale(scale->sws, link->cur_pic->data, link->cur_pic->linesize,
-              y, h, link->dst->outputs[0]->outpic->data,
+    sws_scale(scale->sws, link->cur_pic->data, link->cur_pic->linesize, 0,
+              link->cur_pic->h, link->dst->outputs[0]->outpic->data,
               link->dst->outputs[0]->outpic->linesize);
-    avfilter_draw_slice(link->dst->outputs[0], scale->sliceY, outH);
-    scale->sliceY += outH;
+    avfilter_draw_slice(link->dst->outputs[0], 0, link->dst->outputs[0]->h);
+    avfilter_end_frame(link->dst->outputs[0]);
+
+    avfilter_unref_pic(link->cur_pic);
+    avfilter_unref_pic(link->dst->outputs[0]->outpic);
 }
 
 AVFilter avfilter_vf_scale =
@@ -155,7 +154,7 @@ AVFilter avfilter_vf_scale =
     .inputs    = (AVFilterPad[]) {{ .name            = "default",
                                     .type            = CODEC_TYPE_VIDEO,
                                     .start_frame     = start_frame,
-                                    .draw_slice      = draw_slice,
+                                    .end_frame       = end_frame,
                                     .min_perms       = AV_PERM_READ, },
                                   { .name = NULL}},
     .outputs   = (AVFilterPad[]) {{ .name            = "default",



More information about the FFmpeg-soc mailing list