[MPlayer-cvslog] r23686 - in trunk: libmpcodecs/vf_detc.c libmpcodecs/vf_divtc.c libmpcodecs/vf_filmdint.c libmpcodecs/vf_ivtc.c libmpcodecs/vf_pullup.c libmpcodecs/vf_softpulldown.c libmpcodecs/vf_telecine.c libmpcodecs/vf_tfields.c libmpcodecs/vf_tinterlace.c libvo/fastmemcpy.h

reimar subversion at mplayerhq.hu
Thu Jun 28 13:24:12 CEST 2007


Author: reimar
Date: Thu Jun 28 13:24:12 2007
New Revision: 23686

Log:
Get rid of my_memcpy_pic code duplication in many filters.


Modified:
   trunk/libmpcodecs/vf_detc.c
   trunk/libmpcodecs/vf_divtc.c
   trunk/libmpcodecs/vf_filmdint.c
   trunk/libmpcodecs/vf_ivtc.c
   trunk/libmpcodecs/vf_pullup.c
   trunk/libmpcodecs/vf_softpulldown.c
   trunk/libmpcodecs/vf_telecine.c
   trunk/libmpcodecs/vf_tfields.c
   trunk/libmpcodecs/vf_tinterlace.c
   trunk/libvo/fastmemcpy.h

Modified: trunk/libmpcodecs/vf_detc.c
==============================================================================
--- trunk/libmpcodecs/vf_detc.c	(original)
+++ trunk/libmpcodecs/vf_detc.c	Thu Jun 28 13:24:12 2007
@@ -53,21 +53,6 @@ enum {
 	TC_IL2
 };
 
-static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
-{
-	int i;
-	void *retval=dst;
-
-	for(i=0; i<height; i++)
-	{
-		fast_memcpy(dst, src, bytesPerLine);
-		src+= srcStride;
-		dst+= dstStride;
-	}
-
-	return retval;
-}
-
 static unsigned int hash_pic(unsigned char *img, int w, int h, int stride)
 {
 	int step = w*h/1024;

Modified: trunk/libmpcodecs/vf_divtc.c
==============================================================================
--- trunk/libmpcodecs/vf_divtc.c	(original)
+++ trunk/libmpcodecs/vf_divtc.c	Thu Jun 28 13:24:12 2007
@@ -170,6 +170,11 @@ static int deghost_plane(unsigned char *
    return 0;
    }
 
+static int copyop(unsigned char *d, unsigned char *s, int bpl, int h, int dstride, int sstride, int dummy) {
+  memcpy_pic(d, s, bpl, h, dstride, sstride);
+  return 0;
+}
+
 static int imgop(int(*planeop)(unsigned char *, unsigned char *,
 			       int, int, int, int, int),
 		 mp_image_t *dst, mp_image_t *src, int arg)
@@ -336,7 +341,7 @@ static int put_image(struct vf_instance_
    switch((p->frameno++-p->phase+10)%5)
       {
       case 0:
-	 imgop((void *)memcpy_pic, dmpi, mpi, 0);
+	 imgop(copyop, dmpi, mpi, 0);
 	 return 0;
 
       case 4:
@@ -348,14 +353,14 @@ static int put_image(struct vf_instance_
 			      mpi->width, mpi->height);
 	    vf_clone_mpi_attributes(tmpi, mpi);
 
-	    imgop((void *)memcpy_pic, tmpi, mpi, 0);
+	    imgop(copyop, tmpi, mpi, 0);
 	    imgop(deghost_plane, tmpi, dmpi, p->deghost);
-	    imgop((void *)memcpy_pic, dmpi, mpi, 0);
+	    imgop(copyop, dmpi, mpi, 0);
 	    return vf_next_put_image(vf, tmpi, MP_NOPTS_VALUE);
 	    }
       }
 
-   imgop((void *)memcpy_pic, dmpi, mpi, 0);
+   imgop(copyop, dmpi, mpi, 0);
    return vf_next_put_image(vf, dmpi, MP_NOPTS_VALUE);
    }
 

Modified: trunk/libmpcodecs/vf_filmdint.c
==============================================================================
--- trunk/libmpcodecs/vf_filmdint.c	(original)
+++ trunk/libmpcodecs/vf_filmdint.c	Thu Jun 28 13:24:12 2007
@@ -90,21 +90,6 @@ extern int opt_screen_size_y;
 #define        MAX(a,b) (((a)>(b))?(a):(b))
 #endif
 
-static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
-{
-    int i;
-    void *retval=dst;
-
-    for(i=0; i<height; i++)
-    {
-	fast_memcpy(dst, src, bytesPerLine);
-	src+= srcStride;
-	dst+= dstStride;
-    }
-
-    return retval;
-}
-
 #define PDIFFUB(X,Y,T) "movq "    #X "," #T "\n\t" \
 		       "psubusb " #Y "," #T "\n\t" \
 		       "psubusb " #X "," #Y "\n\t" \

Modified: trunk/libmpcodecs/vf_ivtc.c
==============================================================================
--- trunk/libmpcodecs/vf_ivtc.c	(original)
+++ trunk/libmpcodecs/vf_ivtc.c	Thu Jun 28 13:24:12 2007
@@ -40,21 +40,6 @@ enum {
 	F_SHOW
 };
 
-static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
-{
-	int i;
-	void *retval=dst;
-
-	for(i=0; i<height; i++)
-	{
-		fast_memcpy(dst, src, bytesPerLine);
-		src+= srcStride;
-		dst+= dstStride;
-	}
-
-	return retval;
-}
-
 #ifdef HAVE_MMX
 static void block_diffs_MMX(struct metrics *m, unsigned char *old, unsigned char *new, int os, int ns)
 {

Modified: trunk/libmpcodecs/vf_pullup.c
==============================================================================
--- trunk/libmpcodecs/vf_pullup.c	(original)
+++ trunk/libmpcodecs/vf_pullup.c	Thu Jun 28 13:24:12 2007
@@ -24,21 +24,6 @@ struct vf_priv_s {
 	char *qbuf;
 };
 
-static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
-{
-	int i;
-	void *retval=dst;
-
-	for(i=0; i<height; i++)
-	{
-		fast_memcpy(dst, src, bytesPerLine);
-		src+= srcStride;
-		dst+= dstStride;
-	}
-
-	return retval;
-}
-
 static inline void *il_memcpy_pic(void *dst, void *src0, void *src1, int w, int h, int ds, int ss)
 {
 	int i;

Modified: trunk/libmpcodecs/vf_softpulldown.c
==============================================================================
--- trunk/libmpcodecs/vf_softpulldown.c	(original)
+++ trunk/libmpcodecs/vf_softpulldown.c	Thu Jun 28 13:24:12 2007
@@ -17,21 +17,6 @@ struct vf_priv_s {
 	long long out;
 };
 
-static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
-{
-	int i;
-	void *retval=dst;
-
-	for(i=0; i<height; i++)
-	{
-		fast_memcpy(dst, src, bytesPerLine);
-		src+= srcStride;
-		dst+= dstStride;
-	}
-
-	return retval;
-}
-
 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
 {
 	mp_image_t *dmpi;

Modified: trunk/libmpcodecs/vf_telecine.c
==============================================================================
--- trunk/libmpcodecs/vf_telecine.c	(original)
+++ trunk/libmpcodecs/vf_telecine.c	Thu Jun 28 13:24:12 2007
@@ -15,21 +15,6 @@ struct vf_priv_s {
 	int frame;
 };
 
-static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
-{
-	int i;
-	void *retval=dst;
-
-	for(i=0; i<height; i++)
-	{
-		fast_memcpy(dst, src, bytesPerLine);
-		src+= srcStride;
-		dst+= dstStride;
-	}
-
-	return retval;
-}
-
 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
 {
 	mp_image_t *dmpi;

Modified: trunk/libmpcodecs/vf_tfields.c
==============================================================================
--- trunk/libmpcodecs/vf_tfields.c	(original)
+++ trunk/libmpcodecs/vf_tfields.c	Thu Jun 28 13:24:12 2007
@@ -20,21 +20,6 @@ struct vf_priv_s {
 	double buffered_pts;
 };
 
-static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
-{
-	int i;
-	void *retval=dst;
-
-	for(i=0; i<height; i++)
-	{
-		fast_memcpy(dst, src, bytesPerLine);
-		src+= srcStride;
-		dst+= dstStride;
-	}
-
-	return retval;
-}
-
 static void deint(unsigned char *dest, int ds, unsigned char *src, int ss, int w, int h, int field)
 {
 	int x, y;

Modified: trunk/libmpcodecs/vf_tinterlace.c
==============================================================================
--- trunk/libmpcodecs/vf_tinterlace.c	(original)
+++ trunk/libmpcodecs/vf_tinterlace.c	Thu Jun 28 13:24:12 2007
@@ -35,22 +35,6 @@ struct vf_priv_s {
 	mp_image_t *dmpi;
 };
 
-// Copied verbatim from vf_telecine.c:
-static inline void *my_memcpy_pic(void * dst, void * src, int bytesPerLine, int height, int dstStride, int srcStride)
-{
-	int i;
-	void *retval=dst;
-
-	for(i=0; i<height; i++)
-	{
-		fast_memcpy(dst, src, bytesPerLine);
-		src+= srcStride;
-		dst+= dstStride;
-	}
-
-	return retval;
-}
-
 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts)
 {
 	int ret = 0;

Modified: trunk/libvo/fastmemcpy.h
==============================================================================
--- trunk/libvo/fastmemcpy.h	(original)
+++ trunk/libvo/fastmemcpy.h	Thu Jun 28 13:24:12 2007
@@ -68,12 +68,21 @@ static inline void * mem2agpcpy_pic(void
 	return retval;
 }
 
-static inline void * memcpy_pic(void * dst, const void * src, int bytesPerLine, int height, int dstStride, int srcStride)
+#define memcpy_pic(d, s, b, h, ds, ss) memcpy_pic2(d, s, b, h, ds, ss, 0)
+#define my_memcpy_pic(d, s, b, h, ds, ss) memcpy_pic2(d, s, b, h, ds, ss, 1)
+
+/**
+ * \param limit2width always skip data between end of line and start of next
+ *                    instead of copying the full block when strides are the same
+ */
+static inline void * memcpy_pic2(void * dst, const void * src,
+                                 int bytesPerLine, int height,
+                                 int dstStride, int srcStride, int limit2width)
 {
 	int i;
 	void *retval=dst;
 
-	if(dstStride == srcStride)
+	if(!limit2width && dstStride == srcStride)
 	{
 		if (srcStride < 0) {
 	    		src = (uint8_t*)src + (height-1)*srcStride;



More information about the MPlayer-cvslog mailing list