Browse code

avfilter/phase: avoid a memcpy per frame.

Clément Bœsch authored on 2014/05/04 05:42:54
Showing 1 changed files
... ...
@@ -251,13 +251,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
251 251
     av_frame_copy_props(out, in);
252 252
 
253 253
     if (!s->frame) {
254
+        s->frame = in;
254 255
         mode = PROGRESSIVE;
255
-        s->frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
256
-        if (!s->frame) {
257
-            av_frame_free(&in);
258
-            av_frame_free(&out);
259
-            return AVERROR(ENOMEM);
260
-        }
261 256
     } else {
262 257
         mode = analyze_plane(ctx, s->mode, s->frame, in);
263 258
     }
... ...
@@ -269,7 +264,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
269 269
 
270 270
         for (y = 0, top = 1; y < s->planeheight[plane]; y++, top ^= 1) {
271 271
             memcpy(to, mode == (top ? BOTTOM_FIRST : TOP_FIRST) ? buf : from, s->linesize[plane]);
272
-            memcpy(buf, from, s->linesize[plane]);
273 272
 
274 273
             buf += s->frame->linesize[plane];
275 274
             from += in->linesize[plane];
... ...
@@ -277,7 +271,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
277 277
         }
278 278
     }
279 279
 
280
-    av_frame_free(&in);
280
+    if (in != s->frame)
281
+        av_frame_free(&s->frame);
282
+    s->frame = in;
281 283
     return ff_filter_frame(outlink, out);
282 284
 }
283 285