[FFmpeg-cvslog] avfilter/phase: avoid a memcpy per frame.

Clément Bœsch git at videolan.org
Thu May 8 23:58:49 CEST 2014


ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Sat May  3 22:42:54 2014 +0200| [8de600de553a133bead1b54128c482bcaaa2d292] | committer: Clément Bœsch

avfilter/phase: avoid a memcpy per frame.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8de600de553a133bead1b54128c482bcaaa2d292
---

 libavfilter/vf_phase.c |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vf_phase.c b/libavfilter/vf_phase.c
index 11337e4..dd3eced 100644
--- a/libavfilter/vf_phase.c
+++ b/libavfilter/vf_phase.c
@@ -251,13 +251,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     av_frame_copy_props(out, in);
 
     if (!s->frame) {
+        s->frame = in;
         mode = PROGRESSIVE;
-        s->frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
-        if (!s->frame) {
-            av_frame_free(&in);
-            av_frame_free(&out);
-            return AVERROR(ENOMEM);
-        }
     } else {
         mode = analyze_plane(ctx, s->mode, s->frame, in);
     }
@@ -269,7 +264,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         for (y = 0, top = 1; y < s->planeheight[plane]; y++, top ^= 1) {
             memcpy(to, mode == (top ? BOTTOM_FIRST : TOP_FIRST) ? buf : from, s->linesize[plane]);
-            memcpy(buf, from, s->linesize[plane]);
 
             buf += s->frame->linesize[plane];
             from += in->linesize[plane];
@@ -277,7 +271,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         }
     }
 
-    av_frame_free(&in);
+    if (in != s->frame)
+        av_frame_free(&s->frame);
+    s->frame = in;
     return ff_filter_frame(outlink, out);
 }
 



More information about the ffmpeg-cvslog mailing list