changeset 23666:5c3c7efd9b75

Get rid of my_memcpy_pic code duplication in many filters.
author reimar
date Thu, 28 Jun 2007 11:24:12 +0000
parents 88b417d972ab
children 568e9190f631
files 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
diffstat 10 files changed, 20 insertions(+), 127 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf_detc.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_detc.c	Thu Jun 28 11:24:12 2007 +0000
@@ -53,21 +53,6 @@
 	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;
--- a/libmpcodecs/vf_divtc.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_divtc.c	Thu Jun 28 11:24:12 2007 +0000
@@ -170,6 +170,11 @@
    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 @@
    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 @@
 			      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);
    }
 
--- a/libmpcodecs/vf_filmdint.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_filmdint.c	Thu Jun 28 11:24:12 2007 +0000
@@ -90,21 +90,6 @@
 #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" \
--- a/libmpcodecs/vf_ivtc.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_ivtc.c	Thu Jun 28 11:24:12 2007 +0000
@@ -40,21 +40,6 @@
 	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)
 {
--- a/libmpcodecs/vf_pullup.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_pullup.c	Thu Jun 28 11:24:12 2007 +0000
@@ -24,21 +24,6 @@
 	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;
--- a/libmpcodecs/vf_softpulldown.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_softpulldown.c	Thu Jun 28 11:24:12 2007 +0000
@@ -17,21 +17,6 @@
 	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;
--- a/libmpcodecs/vf_telecine.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_telecine.c	Thu Jun 28 11:24:12 2007 +0000
@@ -15,21 +15,6 @@
 	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;
--- a/libmpcodecs/vf_tfields.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_tfields.c	Thu Jun 28 11:24:12 2007 +0000
@@ -20,21 +20,6 @@
 	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;
--- a/libmpcodecs/vf_tinterlace.c	Thu Jun 28 11:18:16 2007 +0000
+++ b/libmpcodecs/vf_tinterlace.c	Thu Jun 28 11:24:12 2007 +0000
@@ -35,22 +35,6 @@
 	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;
--- a/libvo/fastmemcpy.h	Thu Jun 28 11:18:16 2007 +0000
+++ b/libvo/fastmemcpy.h	Thu Jun 28 11:24:12 2007 +0000
@@ -68,12 +68,21 @@
 	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;