2007-05-28 19:13:52 +02:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with MPlayer; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2008-02-22 10:09:46 +01:00
|
|
|
#ifndef MPLAYER_FASTMEMCPY_H
|
|
|
|
#define MPLAYER_FASTMEMCPY_H
|
2001-04-26 22:35:58 +02:00
|
|
|
|
2004-10-28 03:15:53 +02:00
|
|
|
#include "config.h"
|
2007-01-26 19:43:17 +01:00
|
|
|
#include <inttypes.h>
|
2008-06-16 10:45:01 +02:00
|
|
|
#include <string.h>
|
2001-05-05 15:30:00 +02:00
|
|
|
#include <stddef.h>
|
2001-04-26 22:35:58 +02:00
|
|
|
|
2012-11-25 00:32:47 +01:00
|
|
|
#define my_memcpy_pic memcpy_pic
|
|
|
|
#define memcpy_pic2(d, s, b, h, ds, ss, unused) memcpy_pic(d, s, b, h, ds, ss)
|
2007-06-28 13:24:12 +02:00
|
|
|
|
2012-11-25 00:32:47 +01:00
|
|
|
static inline void * memcpy_pic(void * dst, const void * src,
|
|
|
|
int bytesPerLine, int height,
|
|
|
|
int dstStride, int srcStride)
|
2002-04-06 23:46:07 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
void *retval=dst;
|
|
|
|
|
2012-11-25 00:32:47 +01:00
|
|
|
if(bytesPerLine == dstStride && dstStride == srcStride)
|
2005-04-08 12:31:18 +02:00
|
|
|
{
|
|
|
|
if (srcStride < 0) {
|
2007-01-26 10:07:55 +01:00
|
|
|
src = (uint8_t*)src + (height-1)*srcStride;
|
|
|
|
dst = (uint8_t*)dst + (height-1)*dstStride;
|
2005-04-08 12:31:18 +02:00
|
|
|
srcStride = -srcStride;
|
|
|
|
}
|
|
|
|
|
2012-07-29 14:28:41 +02:00
|
|
|
memcpy(dst, src, srcStride*height);
|
2005-04-08 12:31:18 +02:00
|
|
|
}
|
2002-04-06 23:46:07 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for(i=0; i<height; i++)
|
|
|
|
{
|
2012-07-29 14:28:41 +02:00
|
|
|
memcpy(dst, src, bytesPerLine);
|
2007-01-26 10:07:55 +01:00
|
|
|
src = (uint8_t*)src + srcStride;
|
|
|
|
dst = (uint8_t*)dst + dstStride;
|
2002-04-06 23:46:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2012-09-28 21:25:26 +02:00
|
|
|
static inline void memset_pic(void *dst, int fill, int bytesPerLine, int height,
|
|
|
|
int stride)
|
|
|
|
{
|
|
|
|
if (bytesPerLine == stride) {
|
|
|
|
memset(dst, fill, stride * height);
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < height; i++) {
|
|
|
|
memset(dst, fill, bytesPerLine);
|
|
|
|
dst = (uint8_t *)dst + stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-26 21:13:58 +01:00
|
|
|
static inline void memset16_pic(void *dst, int fill, int unitsPerLine,
|
|
|
|
int height, int stride)
|
|
|
|
{
|
|
|
|
if (fill == 0) {
|
|
|
|
memset_pic(dst, 0, unitsPerLine * 2, height, stride);
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < height; i++) {
|
|
|
|
uint16_t *line = dst;
|
|
|
|
uint16_t *end = line + unitsPerLine;
|
|
|
|
while (line < end)
|
|
|
|
*line++ = fill;
|
|
|
|
dst = (uint8_t *)dst + stride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-22 10:09:46 +01:00
|
|
|
#endif /* MPLAYER_FASTMEMCPY_H */
|