Browse code

vf_drawbox: switch to filter frame

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Anton Khirnov authored on 2012/11/29 08:09:53
Showing 1 changed files
... ...
@@ -130,27 +130,26 @@ static int config_input(AVFilterLink *inlink)
130 130
     return 0;
131 131
 }
132 132
 
133
-static int draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)
133
+static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
134 134
 {
135 135
     DrawBoxContext *drawbox = inlink->dst->priv;
136 136
     int plane, x, y, xb = drawbox->x, yb = drawbox->y;
137 137
     unsigned char *row[4];
138
-    AVFilterBufferRef *picref = inlink->cur_buf;
139 138
 
140
-    for (y = FFMAX(yb, y0); y < y0 + h && y < yb + drawbox->h; y++) {
141
-        row[0] = picref->data[0] + y * picref->linesize[0];
139
+    for (y = FFMAX(yb, 0); y < frame->video->h && y < (yb + drawbox->h); y++) {
140
+        row[0] = frame->data[0] + y * frame->linesize[0];
142 141
 
143 142
         for (plane = 1; plane < 3; plane++)
144
-            row[plane] = picref->data[plane] +
145
-                picref->linesize[plane] * (y >> drawbox->vsub);
143
+            row[plane] = frame->data[plane] +
144
+                 frame->linesize[plane] * (y >> drawbox->vsub);
146 145
 
147 146
         if (drawbox->invert_color) {
148
-            for (x = FFMAX(xb, 0); x < xb + drawbox->w && x < picref->video->w; x++)
147
+            for (x = FFMAX(xb, 0); x < xb + drawbox->w && x < frame->video->w; x++)
149 148
                 if ((y - yb < drawbox->thickness-1) || (yb + drawbox->h - y < drawbox->thickness) ||
150 149
                     (x - xb < drawbox->thickness-1) || (xb + drawbox->w - x < drawbox->thickness))
151 150
                     row[0][x] = 0xff - row[0][x];
152 151
         } else {
153
-            for (x = FFMAX(xb, 0); x < xb + drawbox->w && x < picref->video->w; x++) {
152
+            for (x = FFMAX(xb, 0); x < xb + drawbox->w && x < frame->video->w; x++) {
154 153
                 double alpha = (double)drawbox->yuv_color[A] / 255;
155 154
 
156 155
                 if ((y - yb < drawbox->thickness-1) || (yb + drawbox->h - y < drawbox->thickness) ||
... ...
@@ -163,7 +162,7 @@ static int draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)
163 163
         }
164 164
     }
165 165
 
166
-    return ff_draw_slice(inlink->dst->outputs[0], y0, h, 1);
166
+    return ff_filter_frame(inlink->dst->outputs[0], frame);
167 167
 }
168 168
 
169 169
 static const AVFilterPad avfilter_vf_drawbox_inputs[] = {
... ...
@@ -172,9 +171,7 @@ static const AVFilterPad avfilter_vf_drawbox_inputs[] = {
172 172
         .type             = AVMEDIA_TYPE_VIDEO,
173 173
         .config_props     = config_input,
174 174
         .get_video_buffer = ff_null_get_video_buffer,
175
-        .start_frame      = ff_null_start_frame,
176
-        .draw_slice       = draw_slice,
177
-        .end_frame        = ff_null_end_frame,
175
+        .filter_frame     = filter_frame,
178 176
         .min_perms        = AV_PERM_WRITE | AV_PERM_READ,
179 177
     },
180 178
     { NULL }