[Patch] Speedup yuvdeinterlace

"Burkhard Plaum" <[email protected]> Sat, 22 Sep 2007 22:45:24 +0200 (CEST)
Newsgroups gmane.comp.video.mjpeg.devel
Message-ID <48835.91.22.96.246.1190493924.squirrel@ipfmv1.e-technik.uni-stuttgart.de>
Hi,

while porting yuvdeinterlace to gmerlin, I stumbled across something I think
would be a 0th order optimization. The attached patch calls
temporal_reconstruct_frame() only if the frame is actually written, giving
roughly a factor 2 speedup for deinterlace_motion_compensated() if
both_fields
is zero.

Is this acceptable or did I miss some deeper logic here?
The patched version works ok (at least as gmerlin filter, didn't try the
upstream version).

Burkhard

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
Mjpeg-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mjpeg-developer
yuvdeinterlace.patch (text/x-patch, 2.5 KB)
? yuvdeinterlace.patch
Index: yuvdeinterlace/yuvdeinterlace.cc
===================================================================
RCS file: /cvsroot/mjpeg/mjpeg_play/yuvdeinterlace/yuvdeinterlace.cc,v
retrieving revision 1.17
diff -u -r1.17 yuvdeinterlace.cc
--- yuvdeinterlace/yuvdeinterlace.cc	1 Apr 2007 18:06:06 -0000	1.17
+++ yuvdeinterlace/yuvdeinterlace.cc	22 Sep 2007 20:31:40 -0000
@@ -717,13 +717,14 @@
 
 	y4m_write_frame (Y4MStream.fd_out, &Y4MStream.ostreaminfo, &Y4MStream.oframeinfo, outframe);
 
-	temporal_reconstruct_frame (outframe[0], inframe[0], inframe0[0],  inframe1[0], width, height, 0);
-	temporal_reconstruct_frame (outframe[1], inframe[1], inframe0[1],  inframe1[1], cwidth, cheight, 0);
-	temporal_reconstruct_frame (outframe[2], inframe[2], inframe0[2],  inframe1[2], cwidth, cheight, 0);
-
 	if (both_fields == 1)
-	  y4m_write_frame (Y4MStream.fd_out, &Y4MStream.ostreaminfo,
-			   &Y4MStream.oframeinfo, outframe);
+          {
+            temporal_reconstruct_frame (outframe[0], inframe[0], inframe0[0],  inframe1[0], width, height, 0);
+            temporal_reconstruct_frame (outframe[1], inframe[1], inframe0[1],  inframe1[1], cwidth, cheight, 0);
+            temporal_reconstruct_frame (outframe[2], inframe[2], inframe0[2],  inframe1[2], cwidth, cheight, 0);
+	    y4m_write_frame (Y4MStream.fd_out, &Y4MStream.ostreaminfo,
+                             &Y4MStream.oframeinfo, outframe);
+          }
       }
     else
       {
@@ -733,13 +734,15 @@
 
 	y4m_write_frame (Y4MStream.fd_out, &Y4MStream.ostreaminfo, &Y4MStream.oframeinfo, outframe);
 
-	temporal_reconstruct_frame (outframe[0], inframe[0], inframe0[0],  inframe1[0], width, height, 1);
-	temporal_reconstruct_frame (outframe[1], inframe[1], inframe0[1],  inframe1[1], cwidth, cheight, 1);
-	temporal_reconstruct_frame (outframe[2], inframe[2], inframe0[2],  inframe1[2], cwidth, cheight, 1);
-
 	if (both_fields == 1)
-	  y4m_write_frame (Y4MStream.fd_out, &Y4MStream.ostreaminfo,
-			   &Y4MStream.oframeinfo, outframe);
+          {
+            temporal_reconstruct_frame (outframe[0], inframe[0], inframe0[0],  inframe1[0], width, height, 1);
+            temporal_reconstruct_frame (outframe[1], inframe[1], inframe0[1],  inframe1[1], cwidth, cheight, 1);
+            temporal_reconstruct_frame (outframe[2], inframe[2], inframe0[2],  inframe1[2], cwidth, cheight, 1);
+
+	    y4m_write_frame (Y4MStream.fd_out, &Y4MStream.ostreaminfo,
+		             &Y4MStream.oframeinfo, outframe);
+          }
       }
 
   memcpy (inframe1[0],inframe0[0],width*height);