2006-07-29 11:45:33 +03:00
|
|
|
/*
|
|
|
|
* Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
|
|
|
|
* Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de>
|
|
|
|
*
|
2007-12-02 17:43:08 +02:00
|
|
|
* MMX-optimized DSP functions, based on H.264 optimizations by
|
2006-07-29 11:45:33 +03:00
|
|
|
* Michael Niedermayer and Loren Merritt
|
|
|
|
*
|
2006-10-07 18:30:46 +03:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2006-07-29 11:45:33 +03:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 18:30:46 +03:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2006-07-29 11:45:33 +03:00
|
|
|
*
|
2006-10-07 18:30:46 +03:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2006-07-29 11:45:33 +03:00
|
|
|
* 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
|
2006-10-07 18:30:46 +03:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2007-07-05 13:40:25 +03:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-07-29 11:45:33 +03:00
|
|
|
*/
|
|
|
|
|
2013-02-01 12:31:59 +03:00
|
|
|
#include "libavutil/attributes.h"
|
2008-05-09 14:56:36 +03:00
|
|
|
#include "libavutil/common.h"
|
2010-09-08 18:07:14 +03:00
|
|
|
#include "libavutil/cpu.h"
|
2012-08-08 15:51:52 +03:00
|
|
|
#include "libavutil/x86/asm.h"
|
2012-10-07 18:23:54 +03:00
|
|
|
#include "libavutil/x86/cpu.h"
|
2010-08-03 23:59:00 +03:00
|
|
|
#include "libavcodec/cavsdsp.h"
|
2014-01-24 13:55:16 +03:00
|
|
|
#include "libavcodec/idctdsp.h"
|
2017-04-04 18:17:08 +02:00
|
|
|
#include "libavcodec/x86/idctdsp.h"
|
2013-05-08 01:50:17 +03:00
|
|
|
#include "constants.h"
|
2014-01-28 20:19:21 +03:00
|
|
|
#include "fpel.h"
|
2014-01-24 13:55:16 +03:00
|
|
|
#include "idctdsp.h"
|
2012-10-07 18:23:54 +03:00
|
|
|
#include "config.h"
|
2006-07-29 11:45:33 +03:00
|
|
|
|
2012-06-22 20:46:52 +03:00
|
|
|
|
2017-04-04 17:55:16 +02:00
|
|
|
#if HAVE_MMX_EXTERNAL
|
2013-05-08 01:57:57 +03:00
|
|
|
|
2017-04-04 17:55:16 +02:00
|
|
|
void ff_cavs_idct8_mmx(int16_t *out, const int16_t *in);
|
2013-05-08 01:57:57 +03:00
|
|
|
|
2016-08-24 00:18:41 +02:00
|
|
|
static void cavs_idct8_add_mmx(uint8_t *dst, int16_t *block, ptrdiff_t stride)
|
2006-07-29 11:45:33 +03:00
|
|
|
{
|
2015-03-14 15:30:18 +02:00
|
|
|
LOCAL_ALIGNED(16, int16_t, b2, [64]);
|
2017-04-04 17:55:16 +02:00
|
|
|
ff_cavs_idct8_mmx(b2, block);
|
2017-04-04 18:17:08 +02:00
|
|
|
ff_add_pixels_clamped_mmx(b2, dst, stride);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ff_cavs_idct8_sse2(int16_t *out, const int16_t *in);
|
|
|
|
|
|
|
|
static void cavs_idct8_add_sse2(uint8_t *dst, int16_t *block, ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
LOCAL_ALIGNED(16, int16_t, b2, [64]);
|
|
|
|
ff_cavs_idct8_sse2(b2, block);
|
|
|
|
ff_add_pixels_clamped_sse2(b2, dst, stride);
|
2006-07-29 11:45:33 +03:00
|
|
|
}
|
|
|
|
|
2017-04-04 17:55:16 +02:00
|
|
|
#endif /* HAVE_MMX_EXTERNAL */
|
2013-04-20 23:03:19 +03:00
|
|
|
|
|
|
|
#if (HAVE_MMXEXT_INLINE || HAVE_AMD3DNOW_INLINE)
|
|
|
|
|
2006-07-29 11:45:33 +03:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
* motion compensation
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* vertical filter [-1 -2 96 42 -7 0] */
|
2014-04-19 10:54:26 +03:00
|
|
|
#define QPEL_CAVSV1(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
|
2006-07-29 11:45:33 +03:00
|
|
|
"movd (%0), "#F" \n\t"\
|
|
|
|
"movq "#C", %%mm6 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
"pmullw "MANGLE(MUL1)", %%mm6\n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"movq "#D", %%mm7 \n\t"\
|
2009-10-01 18:30:27 +03:00
|
|
|
"pmullw "MANGLE(MUL2)", %%mm7\n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"psllw $3, "#E" \n\t"\
|
|
|
|
"psubw "#E", %%mm6 \n\t"\
|
|
|
|
"psraw $3, "#E" \n\t"\
|
|
|
|
"paddw %%mm7, %%mm6 \n\t"\
|
|
|
|
"paddw "#E", %%mm6 \n\t"\
|
|
|
|
"paddw "#B", "#B" \n\t"\
|
|
|
|
"pxor %%mm7, %%mm7 \n\t"\
|
|
|
|
"add %2, %0 \n\t"\
|
|
|
|
"punpcklbw %%mm7, "#F" \n\t"\
|
|
|
|
"psubw "#B", %%mm6 \n\t"\
|
|
|
|
"psraw $1, "#B" \n\t"\
|
|
|
|
"psubw "#A", %%mm6 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
"paddw "MANGLE(ADD)", %%mm6 \n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"psraw $7, %%mm6 \n\t"\
|
|
|
|
"packuswb %%mm6, %%mm6 \n\t"\
|
|
|
|
OP(%%mm6, (%1), A, d) \
|
|
|
|
"add %3, %1 \n\t"
|
|
|
|
|
|
|
|
/* vertical filter [ 0 -1 5 5 -1 0] */
|
2014-04-19 10:54:26 +03:00
|
|
|
#define QPEL_CAVSV2(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
|
2006-07-29 11:45:33 +03:00
|
|
|
"movd (%0), "#F" \n\t"\
|
|
|
|
"movq "#C", %%mm6 \n\t"\
|
|
|
|
"paddw "#D", %%mm6 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
"pmullw "MANGLE(MUL1)", %%mm6\n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"add %2, %0 \n\t"\
|
|
|
|
"punpcklbw %%mm7, "#F" \n\t"\
|
|
|
|
"psubw "#B", %%mm6 \n\t"\
|
|
|
|
"psubw "#E", %%mm6 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
"paddw "MANGLE(ADD)", %%mm6 \n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"psraw $3, %%mm6 \n\t"\
|
|
|
|
"packuswb %%mm6, %%mm6 \n\t"\
|
|
|
|
OP(%%mm6, (%1), A, d) \
|
|
|
|
"add %3, %1 \n\t"
|
|
|
|
|
|
|
|
/* vertical filter [ 0 -7 42 96 -2 -1] */
|
2014-04-19 10:54:26 +03:00
|
|
|
#define QPEL_CAVSV3(A,B,C,D,E,F,OP,ADD, MUL1, MUL2) \
|
2006-07-29 11:45:33 +03:00
|
|
|
"movd (%0), "#F" \n\t"\
|
|
|
|
"movq "#C", %%mm6 \n\t"\
|
2009-10-01 18:30:27 +03:00
|
|
|
"pmullw "MANGLE(MUL2)", %%mm6\n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"movq "#D", %%mm7 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
"pmullw "MANGLE(MUL1)", %%mm7\n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"psllw $3, "#B" \n\t"\
|
|
|
|
"psubw "#B", %%mm6 \n\t"\
|
|
|
|
"psraw $3, "#B" \n\t"\
|
|
|
|
"paddw %%mm7, %%mm6 \n\t"\
|
|
|
|
"paddw "#B", %%mm6 \n\t"\
|
|
|
|
"paddw "#E", "#E" \n\t"\
|
|
|
|
"pxor %%mm7, %%mm7 \n\t"\
|
|
|
|
"add %2, %0 \n\t"\
|
|
|
|
"punpcklbw %%mm7, "#F" \n\t"\
|
|
|
|
"psubw "#E", %%mm6 \n\t"\
|
|
|
|
"psraw $1, "#E" \n\t"\
|
|
|
|
"psubw "#F", %%mm6 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
"paddw "MANGLE(ADD)", %%mm6 \n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"psraw $7, %%mm6 \n\t"\
|
|
|
|
"packuswb %%mm6, %%mm6 \n\t"\
|
|
|
|
OP(%%mm6, (%1), A, d) \
|
|
|
|
"add %3, %1 \n\t"
|
|
|
|
|
|
|
|
|
|
|
|
#define QPEL_CAVSVNUM(VOP,OP,ADD,MUL1,MUL2)\
|
|
|
|
int w= 2;\
|
|
|
|
src -= 2*srcStride;\
|
|
|
|
\
|
|
|
|
while(w--){\
|
2008-10-16 16:34:09 +03:00
|
|
|
__asm__ volatile(\
|
2006-07-29 11:45:33 +03:00
|
|
|
"pxor %%mm7, %%mm7 \n\t"\
|
|
|
|
"movd (%0), %%mm0 \n\t"\
|
|
|
|
"add %2, %0 \n\t"\
|
|
|
|
"movd (%0), %%mm1 \n\t"\
|
|
|
|
"add %2, %0 \n\t"\
|
|
|
|
"movd (%0), %%mm2 \n\t"\
|
|
|
|
"add %2, %0 \n\t"\
|
|
|
|
"movd (%0), %%mm3 \n\t"\
|
|
|
|
"add %2, %0 \n\t"\
|
|
|
|
"movd (%0), %%mm4 \n\t"\
|
|
|
|
"add %2, %0 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm0 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm1 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm2 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm3 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm4 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
|
2006-07-29 11:45:33 +03:00
|
|
|
\
|
|
|
|
: "+a"(src), "+c"(dst)\
|
2014-04-19 10:54:26 +03:00
|
|
|
: "S"((x86_reg)srcStride), "r"((x86_reg)dstStride)\
|
|
|
|
NAMED_CONSTRAINTS_ADD(ADD,MUL1,MUL2)\
|
2006-07-29 11:45:33 +03:00
|
|
|
: "memory"\
|
|
|
|
);\
|
|
|
|
if(h==16){\
|
2008-10-16 16:34:09 +03:00
|
|
|
__asm__ volatile(\
|
2014-04-19 10:54:26 +03:00
|
|
|
VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm4, %%mm5, %%mm0, %%mm1, %%mm2, %%mm3, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm5, %%mm0, %%mm1, %%mm2, %%mm3, %%mm4, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm0, %%mm1, %%mm2, %%mm3, %%mm4, %%mm5, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm1, %%mm2, %%mm3, %%mm4, %%mm5, %%mm0, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm2, %%mm3, %%mm4, %%mm5, %%mm0, %%mm1, OP, ADD, MUL1, MUL2)\
|
|
|
|
VOP(%%mm3, %%mm4, %%mm5, %%mm0, %%mm1, %%mm2, OP, ADD, MUL1, MUL2)\
|
2006-07-29 11:45:33 +03:00
|
|
|
\
|
|
|
|
: "+a"(src), "+c"(dst)\
|
2014-04-19 10:54:26 +03:00
|
|
|
: "S"((x86_reg)srcStride), "r"((x86_reg)dstStride)\
|
|
|
|
NAMED_CONSTRAINTS_ADD(ADD,MUL1,MUL2)\
|
2006-07-29 11:45:33 +03:00
|
|
|
: "memory"\
|
|
|
|
);\
|
|
|
|
}\
|
|
|
|
src += 4-(h+5)*srcStride;\
|
|
|
|
dst += 4-h*dstStride;\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define QPEL_CAVS(OPNAME, OP, MMX)\
|
2016-08-24 00:18:41 +02:00
|
|
|
static void OPNAME ## cavs_qpel8_h_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
|
|
|
|
{\
|
2006-07-29 11:45:33 +03:00
|
|
|
int h=8;\
|
2008-10-16 16:34:09 +03:00
|
|
|
__asm__ volatile(\
|
2006-07-29 11:45:33 +03:00
|
|
|
"pxor %%mm7, %%mm7 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
"movq "MANGLE(ff_pw_5)", %%mm6\n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"1: \n\t"\
|
|
|
|
"movq (%0), %%mm0 \n\t"\
|
|
|
|
"movq 1(%0), %%mm2 \n\t"\
|
|
|
|
"movq %%mm0, %%mm1 \n\t"\
|
|
|
|
"movq %%mm2, %%mm3 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm0 \n\t"\
|
|
|
|
"punpckhbw %%mm7, %%mm1 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm2 \n\t"\
|
|
|
|
"punpckhbw %%mm7, %%mm3 \n\t"\
|
|
|
|
"paddw %%mm2, %%mm0 \n\t"\
|
|
|
|
"paddw %%mm3, %%mm1 \n\t"\
|
|
|
|
"pmullw %%mm6, %%mm0 \n\t"\
|
|
|
|
"pmullw %%mm6, %%mm1 \n\t"\
|
|
|
|
"movq -1(%0), %%mm2 \n\t"\
|
|
|
|
"movq 2(%0), %%mm4 \n\t"\
|
|
|
|
"movq %%mm2, %%mm3 \n\t"\
|
|
|
|
"movq %%mm4, %%mm5 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm2 \n\t"\
|
|
|
|
"punpckhbw %%mm7, %%mm3 \n\t"\
|
|
|
|
"punpcklbw %%mm7, %%mm4 \n\t"\
|
|
|
|
"punpckhbw %%mm7, %%mm5 \n\t"\
|
|
|
|
"paddw %%mm4, %%mm2 \n\t"\
|
|
|
|
"paddw %%mm3, %%mm5 \n\t"\
|
|
|
|
"psubw %%mm2, %%mm0 \n\t"\
|
|
|
|
"psubw %%mm5, %%mm1 \n\t"\
|
2014-04-19 10:54:26 +03:00
|
|
|
"movq "MANGLE(ff_pw_4)", %%mm5\n\t"\
|
2006-07-29 11:45:33 +03:00
|
|
|
"paddw %%mm5, %%mm0 \n\t"\
|
|
|
|
"paddw %%mm5, %%mm1 \n\t"\
|
|
|
|
"psraw $3, %%mm0 \n\t"\
|
|
|
|
"psraw $3, %%mm1 \n\t"\
|
|
|
|
"packuswb %%mm1, %%mm0 \n\t"\
|
|
|
|
OP(%%mm0, (%1),%%mm5, q) \
|
|
|
|
"add %3, %0 \n\t"\
|
|
|
|
"add %4, %1 \n\t"\
|
|
|
|
"decl %2 \n\t"\
|
|
|
|
" jnz 1b \n\t"\
|
|
|
|
: "+a"(src), "+c"(dst), "+m"(h)\
|
2014-04-19 10:54:26 +03:00
|
|
|
: "d"((x86_reg)srcStride), "S"((x86_reg)dstStride)\
|
|
|
|
NAMED_CONSTRAINTS_ADD(ff_pw_4,ff_pw_5)\
|
2006-07-29 11:45:33 +03:00
|
|
|
: "memory"\
|
|
|
|
);\
|
|
|
|
}\
|
|
|
|
\
|
2016-08-24 00:18:41 +02:00
|
|
|
static inline void OPNAME ## cavs_qpel8or16_v1_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
QPEL_CAVSVNUM(QPEL_CAVSV1,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
|
|
|
|
}\
|
|
|
|
\
|
2016-08-24 00:18:41 +02:00
|
|
|
static inline void OPNAME ## cavs_qpel8or16_v2_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)\
|
|
|
|
{ \
|
2014-05-03 10:59:20 +03:00
|
|
|
QPEL_CAVSVNUM(QPEL_CAVSV2,OP,ff_pw_4,ff_pw_5,ff_pw_42) \
|
2006-07-29 11:45:33 +03:00
|
|
|
}\
|
|
|
|
\
|
2016-08-24 00:18:41 +02:00
|
|
|
static inline void OPNAME ## cavs_qpel8or16_v3_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
QPEL_CAVSVNUM(QPEL_CAVSV3,OP,ff_pw_64,ff_pw_96,ff_pw_42) \
|
|
|
|
}\
|
|
|
|
\
|
2016-08-24 00:18:41 +02:00
|
|
|
static void OPNAME ## cavs_qpel8_v1_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 8);\
|
|
|
|
}\
|
2016-08-24 00:18:41 +02:00
|
|
|
static void OPNAME ## cavs_qpel16_v1_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst , src , dstStride, srcStride, 16);\
|
|
|
|
OPNAME ## cavs_qpel8or16_v1_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
|
|
|
|
}\
|
|
|
|
\
|
2016-08-24 00:18:41 +02:00
|
|
|
static void OPNAME ## cavs_qpel8_v2_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 8);\
|
|
|
|
}\
|
2016-08-24 00:18:41 +02:00
|
|
|
static void OPNAME ## cavs_qpel16_v2_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst , src , dstStride, srcStride, 16);\
|
|
|
|
OPNAME ## cavs_qpel8or16_v2_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
|
|
|
|
}\
|
|
|
|
\
|
2016-08-24 00:18:41 +02:00
|
|
|
static void OPNAME ## cavs_qpel8_v3_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 8);\
|
|
|
|
}\
|
2016-08-24 00:18:41 +02:00
|
|
|
static void OPNAME ## cavs_qpel16_v3_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst , src , dstStride, srcStride, 16);\
|
|
|
|
OPNAME ## cavs_qpel8or16_v3_ ## MMX(dst+8, src+8, dstStride, srcStride, 16);\
|
|
|
|
}\
|
|
|
|
\
|
2016-08-24 00:18:41 +02:00
|
|
|
static void OPNAME ## cavs_qpel16_h_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride)\
|
|
|
|
{ \
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
|
|
|
|
OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
|
|
|
|
src += 8*srcStride;\
|
|
|
|
dst += 8*dstStride;\
|
|
|
|
OPNAME ## cavs_qpel8_h_ ## MMX(dst , src , dstStride, srcStride);\
|
|
|
|
OPNAME ## cavs_qpel8_h_ ## MMX(dst+8, src+8, dstStride, srcStride);\
|
|
|
|
}\
|
|
|
|
|
|
|
|
#define CAVS_MC(OPNAME, SIZE, MMX) \
|
2014-07-25 02:19:45 +03:00
|
|
|
static void OPNAME ## cavs_qpel ## SIZE ## _mc20_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
|
2013-03-09 00:40:03 +03:00
|
|
|
{\
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel ## SIZE ## _h_ ## MMX(dst, src, stride, stride);\
|
|
|
|
}\
|
|
|
|
\
|
2014-07-25 02:19:45 +03:00
|
|
|
static void OPNAME ## cavs_qpel ## SIZE ## _mc01_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
|
2013-03-09 00:40:03 +03:00
|
|
|
{\
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel ## SIZE ## _v1_ ## MMX(dst, src, stride, stride);\
|
|
|
|
}\
|
|
|
|
\
|
2014-07-25 02:19:45 +03:00
|
|
|
static void OPNAME ## cavs_qpel ## SIZE ## _mc02_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
|
2013-03-09 00:40:03 +03:00
|
|
|
{\
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel ## SIZE ## _v2_ ## MMX(dst, src, stride, stride);\
|
|
|
|
}\
|
|
|
|
\
|
2014-07-25 02:19:45 +03:00
|
|
|
static void OPNAME ## cavs_qpel ## SIZE ## _mc03_ ## MMX(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)\
|
2013-03-09 00:40:03 +03:00
|
|
|
{\
|
2006-07-29 11:45:33 +03:00
|
|
|
OPNAME ## cavs_qpel ## SIZE ## _v3_ ## MMX(dst, src, stride, stride);\
|
|
|
|
}\
|
|
|
|
|
|
|
|
#define PUT_OP(a,b,temp, size) "mov" #size " " #a ", " #b " \n\t"
|
|
|
|
#define AVG_3DNOW_OP(a,b,temp, size) \
|
|
|
|
"mov" #size " " #b ", " #temp " \n\t"\
|
|
|
|
"pavgusb " #temp ", " #a " \n\t"\
|
|
|
|
"mov" #size " " #a ", " #b " \n\t"
|
2012-07-08 20:28:57 +03:00
|
|
|
#define AVG_MMXEXT_OP(a, b, temp, size) \
|
2006-07-29 11:45:33 +03:00
|
|
|
"mov" #size " " #b ", " #temp " \n\t"\
|
|
|
|
"pavgb " #temp ", " #a " \n\t"\
|
|
|
|
"mov" #size " " #a ", " #b " \n\t"
|
|
|
|
|
2012-10-07 18:23:54 +03:00
|
|
|
#endif /* (HAVE_MMXEXT_INLINE || HAVE_AMD3DNOW_INLINE) */
|
|
|
|
|
2014-05-19 11:02:19 +03:00
|
|
|
#if HAVE_MMX_EXTERNAL
|
2014-07-25 02:19:45 +03:00
|
|
|
static void put_cavs_qpel8_mc00_mmx(uint8_t *dst, const uint8_t *src,
|
2013-04-27 23:54:57 +03:00
|
|
|
ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
ff_put_pixels8_mmx(dst, src, stride, 8);
|
|
|
|
}
|
|
|
|
|
2014-07-25 02:19:45 +03:00
|
|
|
static void avg_cavs_qpel8_mc00_mmx(uint8_t *dst, const uint8_t *src,
|
2013-04-27 23:54:57 +03:00
|
|
|
ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
ff_avg_pixels8_mmx(dst, src, stride, 8);
|
|
|
|
}
|
|
|
|
|
2014-07-25 13:58:03 +03:00
|
|
|
static void avg_cavs_qpel8_mc00_mmxext(uint8_t *dst, const uint8_t *src,
|
2014-05-25 20:03:10 +03:00
|
|
|
ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
ff_avg_pixels8_mmxext(dst, src, stride, 8);
|
|
|
|
}
|
|
|
|
|
2014-07-25 02:19:45 +03:00
|
|
|
static void put_cavs_qpel16_mc00_mmx(uint8_t *dst, const uint8_t *src,
|
2013-04-27 23:54:57 +03:00
|
|
|
ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
ff_put_pixels16_mmx(dst, src, stride, 16);
|
|
|
|
}
|
|
|
|
|
2014-07-25 02:19:45 +03:00
|
|
|
static void avg_cavs_qpel16_mc00_mmx(uint8_t *dst, const uint8_t *src,
|
2013-04-27 23:54:57 +03:00
|
|
|
ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
ff_avg_pixels16_mmx(dst, src, stride, 16);
|
|
|
|
}
|
2014-05-25 20:03:10 +03:00
|
|
|
|
2014-07-25 13:58:03 +03:00
|
|
|
static void avg_cavs_qpel16_mc00_mmxext(uint8_t *dst, const uint8_t *src,
|
2014-05-25 20:03:10 +03:00
|
|
|
ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
ff_avg_pixels16_mmxext(dst, src, stride, 16);
|
|
|
|
}
|
|
|
|
|
2014-07-25 13:58:03 +03:00
|
|
|
static void put_cavs_qpel16_mc00_sse2(uint8_t *dst, const uint8_t *src,
|
2014-05-25 20:03:10 +03:00
|
|
|
ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
ff_put_pixels16_sse2(dst, src, stride, 16);
|
|
|
|
}
|
|
|
|
|
2014-07-25 13:58:03 +03:00
|
|
|
static void avg_cavs_qpel16_mc00_sse2(uint8_t *dst, const uint8_t *src,
|
2014-05-25 20:03:10 +03:00
|
|
|
ptrdiff_t stride)
|
|
|
|
{
|
|
|
|
ff_avg_pixels16_sse2(dst, src, stride, 16);
|
|
|
|
}
|
2014-05-19 11:02:19 +03:00
|
|
|
#endif
|
2013-04-27 23:54:57 +03:00
|
|
|
|
2013-04-20 23:03:19 +03:00
|
|
|
static av_cold void cavsdsp_init_mmx(CAVSDSPContext *c,
|
|
|
|
AVCodecContext *avctx)
|
|
|
|
{
|
2014-05-19 11:02:19 +03:00
|
|
|
#if HAVE_MMX_EXTERNAL
|
2013-04-27 23:54:57 +03:00
|
|
|
c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_mmx;
|
|
|
|
c->put_cavs_qpel_pixels_tab[1][0] = put_cavs_qpel8_mc00_mmx;
|
|
|
|
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmx;
|
|
|
|
c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmx;
|
2013-04-20 23:03:19 +03:00
|
|
|
|
|
|
|
c->cavs_idct8_add = cavs_idct8_add_mmx;
|
2014-02-18 13:30:55 +03:00
|
|
|
c->idct_perm = FF_IDCT_PERM_TRANSPOSE;
|
2017-04-04 17:55:16 +02:00
|
|
|
#endif /* HAVE_MMX_EXTERNAL */
|
2014-05-19 11:02:19 +03:00
|
|
|
}
|
2013-04-20 23:03:19 +03:00
|
|
|
|
2013-04-20 23:15:22 +03:00
|
|
|
#define DSPFUNC(PFX, IDX, NUM, EXT) \
|
|
|
|
c->PFX ## _cavs_qpel_pixels_tab[IDX][ 2] = PFX ## _cavs_qpel ## NUM ## _mc20_ ## EXT; \
|
|
|
|
c->PFX ## _cavs_qpel_pixels_tab[IDX][ 4] = PFX ## _cavs_qpel ## NUM ## _mc01_ ## EXT; \
|
|
|
|
c->PFX ## _cavs_qpel_pixels_tab[IDX][ 8] = PFX ## _cavs_qpel ## NUM ## _mc02_ ## EXT; \
|
|
|
|
c->PFX ## _cavs_qpel_pixels_tab[IDX][12] = PFX ## _cavs_qpel ## NUM ## _mc03_ ## EXT; \
|
2013-04-20 23:13:01 +03:00
|
|
|
|
2012-10-07 18:23:54 +03:00
|
|
|
#if HAVE_MMXEXT_INLINE
|
2012-07-08 20:56:10 +03:00
|
|
|
QPEL_CAVS(put_, PUT_OP, mmxext)
|
|
|
|
QPEL_CAVS(avg_, AVG_MMXEXT_OP, mmxext)
|
2006-07-29 11:45:33 +03:00
|
|
|
|
2012-07-08 20:56:10 +03:00
|
|
|
CAVS_MC(put_, 8, mmxext)
|
|
|
|
CAVS_MC(put_, 16, mmxext)
|
|
|
|
CAVS_MC(avg_, 8, mmxext)
|
|
|
|
CAVS_MC(avg_, 16, mmxext)
|
2012-10-07 18:23:54 +03:00
|
|
|
#endif /* HAVE_MMXEXT_INLINE */
|
|
|
|
|
|
|
|
#if HAVE_AMD3DNOW_INLINE
|
|
|
|
QPEL_CAVS(put_, PUT_OP, 3dnow)
|
|
|
|
QPEL_CAVS(avg_, AVG_3DNOW_OP, 3dnow)
|
|
|
|
|
|
|
|
CAVS_MC(put_, 8, 3dnow)
|
|
|
|
CAVS_MC(put_, 16,3dnow)
|
|
|
|
CAVS_MC(avg_, 8, 3dnow)
|
|
|
|
CAVS_MC(avg_, 16,3dnow)
|
2006-07-29 11:45:33 +03:00
|
|
|
|
2013-04-20 23:15:22 +03:00
|
|
|
static av_cold void cavsdsp_init_3dnow(CAVSDSPContext *c,
|
|
|
|
AVCodecContext *avctx)
|
2013-02-01 12:31:59 +03:00
|
|
|
{
|
2013-04-20 23:13:01 +03:00
|
|
|
DSPFUNC(put, 0, 16, 3dnow);
|
|
|
|
DSPFUNC(put, 1, 8, 3dnow);
|
|
|
|
DSPFUNC(avg, 0, 16, 3dnow);
|
|
|
|
DSPFUNC(avg, 1, 8, 3dnow);
|
2006-07-29 11:45:33 +03:00
|
|
|
}
|
2012-10-07 18:23:54 +03:00
|
|
|
#endif /* HAVE_AMD3DNOW_INLINE */
|
2010-08-03 23:59:00 +03:00
|
|
|
|
2012-10-07 18:23:54 +03:00
|
|
|
av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c, AVCodecContext *avctx)
|
2010-08-03 23:59:00 +03:00
|
|
|
{
|
2015-09-19 16:34:22 +02:00
|
|
|
av_unused int cpu_flags = av_get_cpu_flags();
|
2010-08-03 23:59:00 +03:00
|
|
|
|
2017-03-05 04:14:27 +02:00
|
|
|
if (X86_MMX(cpu_flags))
|
|
|
|
cavsdsp_init_mmx(c, avctx);
|
|
|
|
|
2012-10-07 18:23:54 +03:00
|
|
|
#if HAVE_AMD3DNOW_INLINE
|
2013-08-20 15:46:58 +03:00
|
|
|
if (INLINE_AMD3DNOW(cpu_flags))
|
2013-04-20 23:15:22 +03:00
|
|
|
cavsdsp_init_3dnow(c, avctx);
|
2012-10-07 18:23:54 +03:00
|
|
|
#endif /* HAVE_AMD3DNOW_INLINE */
|
2013-09-30 16:04:44 +03:00
|
|
|
#if HAVE_MMXEXT_INLINE
|
2014-05-25 20:03:10 +03:00
|
|
|
if (INLINE_MMXEXT(cpu_flags)) {
|
|
|
|
DSPFUNC(put, 0, 16, mmxext);
|
|
|
|
DSPFUNC(put, 1, 8, mmxext);
|
|
|
|
DSPFUNC(avg, 0, 16, mmxext);
|
|
|
|
DSPFUNC(avg, 1, 8, mmxext);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if HAVE_MMX_EXTERNAL
|
|
|
|
if (EXTERNAL_MMXEXT(cpu_flags)) {
|
|
|
|
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_mmxext;
|
|
|
|
c->avg_cavs_qpel_pixels_tab[1][0] = avg_cavs_qpel8_mc00_mmxext;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#if HAVE_SSE2_EXTERNAL
|
|
|
|
if (EXTERNAL_SSE2(cpu_flags)) {
|
|
|
|
c->put_cavs_qpel_pixels_tab[0][0] = put_cavs_qpel16_mc00_sse2;
|
|
|
|
c->avg_cavs_qpel_pixels_tab[0][0] = avg_cavs_qpel16_mc00_sse2;
|
2017-04-04 18:17:08 +02:00
|
|
|
|
|
|
|
c->cavs_idct8_add = cavs_idct8_add_sse2;
|
|
|
|
c->idct_perm = FF_IDCT_PERM_TRANSPOSE;
|
2014-05-25 20:03:10 +03:00
|
|
|
}
|
|
|
|
#endif
|
2010-08-03 23:59:00 +03:00
|
|
|
}
|