libavfilter/libmpcodecs/libvo/fastmemcpy.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of MPlayer.
00003  *
00004  * MPlayer is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * MPlayer is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with MPlayer; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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 /* || HAVE_SSE || HAVE_SSE2 */)
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 /* MPLAYER_FASTMEMCPY_H */