[MPlayer-dev-eng] [PATCH] get rid of my_memcpy_pic code duplication
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Jun 24 14:58:09 CEST 2007
Hello,
Seems rather stupid that each filter has this filter copy-and-pasted
(esp. since they also do void * arithmetic).
I have not properly benchmarked it, but I don't think there is even a
real need for those functions to be static inline at all.
Ok to apply?
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libvo/fastmemcpy.h
===================================================================
--- libvo/fastmemcpy.h (revision 23641)
+++ libvo/fastmemcpy.h (working copy)
@@ -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 forceskip 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 forceskip)
{
int i;
void *retval=dst;
- if(dstStride == srcStride)
+ if(!forceskip && dstStride == srcStride)
{
if (srcStride < 0) {
src = (uint8_t*)src + (height-1)*srcStride;
Index: libmpcodecs/vf_filmdint.c
===================================================================
--- libmpcodecs/vf_filmdint.c (revision 23641)
+++ libmpcodecs/vf_filmdint.c (working copy)
@@ -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" \
Index: libmpcodecs/vf_tinterlace.c
===================================================================
--- libmpcodecs/vf_tinterlace.c (revision 23641)
+++ libmpcodecs/vf_tinterlace.c (working copy)
@@ -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;
Index: libmpcodecs/vf_telecine.c
===================================================================
--- libmpcodecs/vf_telecine.c (revision 23641)
+++ libmpcodecs/vf_telecine.c (working copy)
@@ -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;
Index: libmpcodecs/vf_tfields.c
===================================================================
--- libmpcodecs/vf_tfields.c (revision 23641)
+++ libmpcodecs/vf_tfields.c (working copy)
@@ -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;
Index: libmpcodecs/vf_softpulldown.c
===================================================================
--- libmpcodecs/vf_softpulldown.c (revision 23641)
+++ libmpcodecs/vf_softpulldown.c (working copy)
@@ -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;
Index: libmpcodecs/vf_pullup.c
===================================================================
--- libmpcodecs/vf_pullup.c (revision 23641)
+++ libmpcodecs/vf_pullup.c (working copy)
@@ -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;
Index: libmpcodecs/vf_ivtc.c
===================================================================
--- libmpcodecs/vf_ivtc.c (revision 23641)
+++ libmpcodecs/vf_ivtc.c (working copy)
@@ -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)
{
Index: libmpcodecs/vf_detc.c
===================================================================
--- libmpcodecs/vf_detc.c (revision 23641)
+++ libmpcodecs/vf_detc.c (working copy)
@@ -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;
More information about the MPlayer-dev-eng
mailing list