Add explanatory comments to the #endif part of multiple inclusion guards.
[mplayer/greg.git] / libvo / fastmemcpy.h
blobe09deb4f5b8e5511bfec57476afa9b6d9295839d
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with MPlayer; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef FASTMEMCPY_H
20 #define FASTMEMCPY_H
22 #include "config.h"
23 #include <inttypes.h>
25 #ifdef USE_FASTMEMCPY
26 #if defined(HAVE_MMX) || defined(HAVE_MMX2) || defined(HAVE_3DNOW) \
27 /* || defined(HAVE_SSE) || defined(HAVE_SSE2) */
28 #include <stddef.h>
30 extern void * fast_memcpy(void * to, const void * from, size_t len);
31 extern void * mem2agpcpy(void * to, const void * from, size_t len);
33 #else /* HAVE_MMX/MMX2/3DNOW/SSE/SSE2 */
34 #define mem2agpcpy(a,b,c) memcpy(a,b,c)
35 #define fast_memcpy(a,b,c) memcpy(a,b,c)
36 #endif
38 #else /* USE_FASTMEMCPY */
39 #define mem2agpcpy(a,b,c) memcpy(a,b,c)
40 #define fast_memcpy(a,b,c) memcpy(a,b,c)
41 #endif
43 static inline void * mem2agpcpy_pic(void * dst, const void * src, int bytesPerLine, int height, int dstStride, int srcStride)
45 int i;
46 void *retval=dst;
48 if(dstStride == srcStride)
50 if (srcStride < 0) {
51 src = (uint8_t*)src + (height-1)*srcStride;
52 dst = (uint8_t*)dst + (height-1)*dstStride;
53 srcStride = -srcStride;
56 mem2agpcpy(dst, src, srcStride*height);
58 else
60 for(i=0; i<height; i++)
62 mem2agpcpy(dst, src, bytesPerLine);
63 src = (uint8_t*)src + srcStride;
64 dst = (uint8_t*)dst + dstStride;
68 return retval;
71 #define memcpy_pic(d, s, b, h, ds, ss) memcpy_pic2(d, s, b, h, ds, ss, 0)
72 #define my_memcpy_pic(d, s, b, h, ds, ss) memcpy_pic2(d, s, b, h, ds, ss, 1)
74 /**
75 * \param limit2width always skip data between end of line and start of next
76 * instead of copying the full block when strides are the same
78 static inline void * memcpy_pic2(void * dst, const void * src,
79 int bytesPerLine, int height,
80 int dstStride, int srcStride, int limit2width)
82 int i;
83 void *retval=dst;
85 if(!limit2width && dstStride == srcStride)
87 if (srcStride < 0) {
88 src = (uint8_t*)src + (height-1)*srcStride;
89 dst = (uint8_t*)dst + (height-1)*dstStride;
90 srcStride = -srcStride;
93 fast_memcpy(dst, src, srcStride*height);
95 else
97 for(i=0; i<height; i++)
99 fast_memcpy(dst, src, bytesPerLine);
100 src = (uint8_t*)src + srcStride;
101 dst = (uint8_t*)dst + dstStride;
105 return retval;
108 #endif /* FASTMEMCPY_H */