Add const where appropriate, also gets rid of a compiler warning.
[mplayer/glamo.git] / libvo / fastmemcpy.h
blob16767d9842bccafea6c770b712c23b5e8f70064d
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 MPLAYER_FASTMEMCPY_H
20 #define MPLAYER_FASTMEMCPY_H
22 #include "config.h"
23 #include <inttypes.h>
24 #include <string.h>
26 #if defined(CONFIG_FASTMEMCPY) && (HAVE_MMX || HAVE_MMX2 || HAVE_AMD3DNOW /* || HAVE_SSE || HAVE_SSE2 */)
27 #include <stddef.h>
29 void * fast_memcpy(void * to, const void * from, size_t len);
30 void * mem2agpcpy(void * to, const void * from, size_t len);
32 #else
33 #define mem2agpcpy(a,b,c) memcpy(a,b,c)
34 #define fast_memcpy(a,b,c) memcpy(a,b,c)
35 #endif
37 static inline void * mem2agpcpy_pic(void * dst, const void * src, int bytesPerLine, int height, int dstStride, int srcStride)
39 int i;
40 void *retval=dst;
42 if(dstStride == srcStride)
44 if (srcStride < 0) {
45 src = (uint8_t*)src + (height-1)*srcStride;
46 dst = (uint8_t*)dst + (height-1)*dstStride;
47 srcStride = -srcStride;
50 mem2agpcpy(dst, src, srcStride*height);
52 else
54 for(i=0; i<height; i++)
56 mem2agpcpy(dst, src, bytesPerLine);
57 src = (uint8_t*)src + srcStride;
58 dst = (uint8_t*)dst + dstStride;
62 return retval;
65 #define memcpy_pic(d, s, b, h, ds, ss) memcpy_pic2(d, s, b, h, ds, ss, 0)
66 #define my_memcpy_pic(d, s, b, h, ds, ss) memcpy_pic2(d, s, b, h, ds, ss, 1)
68 /**
69 * \param limit2width always skip data between end of line and start of next
70 * instead of copying the full block when strides are the same
72 static inline void * memcpy_pic2(void * dst, const void * src,
73 int bytesPerLine, int height,
74 int dstStride, int srcStride, int limit2width)
76 int i;
77 void *retval=dst;
79 if(!limit2width && dstStride == srcStride)
81 if (srcStride < 0) {
82 src = (uint8_t*)src + (height-1)*srcStride;
83 dst = (uint8_t*)dst + (height-1)*dstStride;
84 srcStride = -srcStride;
87 fast_memcpy(dst, src, srcStride*height);
89 else
91 for(i=0; i<height; i++)
93 fast_memcpy(dst, src, bytesPerLine);
94 src = (uint8_t*)src + srcStride;
95 dst = (uint8_t*)dst + dstStride;
99 return retval;
102 #endif /* MPLAYER_FASTMEMCPY_H */