[FFmpeg-soc] [soc]: r1932 - libavfilter/vf_scale.c

koorogi subversion at mplayerhq.hu
Thu Feb 28 00:18:59 CET 2008


Author: koorogi
Date: Thu Feb 28 00:18:58 2008
New Revision: 1932

Log:
Slice support for vf_scale.


Modified:
   libavfilter/vf_scale.c

Modified: libavfilter/vf_scale.c
==============================================================================
--- libavfilter/vf_scale.c	(original)
+++ libavfilter/vf_scale.c	Thu Feb 28 00:18:58 2008
@@ -34,6 +34,8 @@ 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)
@@ -110,6 +112,7 @@ 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);
@@ -122,22 +125,20 @@ 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;
+}
 
-/* TODO: figure out the swscale API well enough to scale slice at a time */
-static void end_frame(AVFilterLink *link)
+static void draw_slice(AVFilterLink *link, int y, int h)
 {
     ScaleContext *scale = link->dst->priv;
+    int outH;
 
-    sws_scale(scale->sws, link->cur_pic->data, link->cur_pic->linesize, 0,
-              link->cur_pic->h, link->dst->outputs[0]->outpic->data,
+    outH = sws_scale(scale->sws, link->cur_pic->data, link->cur_pic->linesize,
+              y, h, link->dst->outputs[0]->outpic->data,
               link->dst->outputs[0]->outpic->linesize);
-    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_draw_slice(link->dst->outputs[0], scale->sliceY, outH);
+    scale->sliceY += outH;
 }
 
 AVFilter avfilter_vf_scale =
@@ -154,7 +155,7 @@ AVFilter avfilter_vf_scale =
     .inputs    = (AVFilterPad[]) {{ .name            = "default",
                                     .type            = CODEC_TYPE_VIDEO,
                                     .start_frame     = start_frame,
-                                    .end_frame       = end_frame,
+                                    .draw_slice      = draw_slice,
                                     .min_perms       = AV_PERM_READ, },
                                   { .name = NULL}},
     .outputs   = (AVFilterPad[]) {{ .name            = "default",



More information about the FFmpeg-soc mailing list