00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MPLAYER_FASTMEMCPY_H
00020 #define MPLAYER_FASTMEMCPY_H
00021
00022 #include <inttypes.h>
00023 #include <string.h>
00024 #include <stddef.h>
00025
00026 void * fast_memcpy(void * to, const void * from, size_t len);
00027 void * mem2agpcpy(void * to, const void * from, size_t len);
00028
00029 #if ! defined(CONFIG_FASTMEMCPY) || ! (HAVE_MMX || HAVE_MMX2 || HAVE_AMD3DNOW )
00030 #define mem2agpcpy(a,b,c) memcpy(a,b,c)
00031 #define fast_memcpy(a,b,c) memcpy(a,b,c)
00032 #endif
00033
00034 static inline void * mem2agpcpy_pic(void * dst, const void * src, int bytesPerLine, int height, int dstStride, int srcStride)
00035 {
00036 int i;
00037 void *retval=dst;
00038
00039 if(dstStride == srcStride)
00040 {
00041 if (srcStride < 0) {
00042 src = (const uint8_t*)src + (height-1)*srcStride;
00043 dst = (uint8_t*)dst + (height-1)*dstStride;
00044 srcStride = -srcStride;
00045 }
00046
00047 mem2agpcpy(dst, src, srcStride*height);
00048 }
00049 else
00050 {
00051 for(i=0; i<height; i++)
00052 {
00053 mem2agpcpy(dst, src, bytesPerLine);
00054 src = (const uint8_t*)src + srcStride;
00055 dst = (uint8_t*)dst + dstStride;
00056 }
00057 }
00058
00059 return retval;
00060 }
00061
00062 #define memcpy_pic(d, s, b, h, ds, ss) memcpy_pic2(d, s, b, h, ds, ss, 0)
00063 #define my_memcpy_pic(d, s, b, h, ds, ss) memcpy_pic2(d, s, b, h, ds, ss, 1)
00064
00069 static inline void * memcpy_pic2(void * dst, const void * src,
00070 int bytesPerLine, int height,
00071 int dstStride, int srcStride, int limit2width)
00072 {
00073 int i;
00074 void *retval=dst;
00075
00076 if(!limit2width && dstStride == srcStride)
00077 {
00078 if (srcStride < 0) {
00079 src = (const uint8_t*)src + (height-1)*srcStride;
00080 dst = (uint8_t*)dst + (height-1)*dstStride;
00081 srcStride = -srcStride;
00082 }
00083
00084 fast_memcpy(dst, src, srcStride*height);
00085 }
00086 else
00087 {
00088 for(i=0; i<height; i++)
00089 {
00090 fast_memcpy(dst, src, bytesPerLine);
00091 src = (const uint8_t*)src + srcStride;
00092 dst = (uint8_t*)dst + dstStride;
00093 }
00094 }
00095
00096 return retval;
00097 }
00098
00099 #endif