2007-05-18 10:18:56 +02:00
|
|
|
/*
|
|
|
|
* DSP utils : QNS functions are compiled 3 times for mmx/3dnow/ssse3
|
|
|
|
* Copyright (c) 2004 Michael Niedermayer
|
|
|
|
*
|
2007-07-05 12:37:29 +02:00
|
|
|
* MMX optimization by Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
* 3DNow! and SSSE3 optimization by Zuxy Meng <zuxy.meng@gmail.com>
|
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* This file is part of Libav.
|
2007-05-18 10:18:56 +02:00
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2007-05-18 10:18:56 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2007-05-18 10:18:56 +02: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
|
2011-03-18 18:35:10 +01:00
|
|
|
* License along with Libav; if not, write to the Free Software
|
2007-05-18 10:18:56 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define MAX_ABS (512 >> (SCALE_OFFSET>0 ? SCALE_OFFSET : 0))
|
|
|
|
|
|
|
|
static int DEF(try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale)
|
|
|
|
{
|
2008-05-08 23:11:24 +02:00
|
|
|
x86_reg i=0;
|
2007-05-18 10:18:56 +02:00
|
|
|
|
|
|
|
assert(FFABS(scale) < MAX_ABS);
|
|
|
|
scale<<= 16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT;
|
|
|
|
|
|
|
|
SET_RND(mm6);
|
2008-10-16 15:34:09 +02:00
|
|
|
__asm__ volatile(
|
2007-05-18 10:18:56 +02:00
|
|
|
"pxor %%mm7, %%mm7 \n\t"
|
|
|
|
"movd %4, %%mm5 \n\t"
|
|
|
|
"punpcklwd %%mm5, %%mm5 \n\t"
|
|
|
|
"punpcklwd %%mm5, %%mm5 \n\t"
|
2011-01-15 23:09:35 +01:00
|
|
|
".p2align 4 \n\t"
|
2007-05-18 10:18:56 +02:00
|
|
|
"1: \n\t"
|
|
|
|
"movq (%1, %0), %%mm0 \n\t"
|
|
|
|
"movq 8(%1, %0), %%mm1 \n\t"
|
|
|
|
PMULHRW(%%mm0, %%mm1, %%mm5, %%mm6)
|
|
|
|
"paddw (%2, %0), %%mm0 \n\t"
|
|
|
|
"paddw 8(%2, %0), %%mm1 \n\t"
|
|
|
|
"psraw $6, %%mm0 \n\t"
|
|
|
|
"psraw $6, %%mm1 \n\t"
|
|
|
|
"pmullw (%3, %0), %%mm0 \n\t"
|
|
|
|
"pmullw 8(%3, %0), %%mm1 \n\t"
|
|
|
|
"pmaddwd %%mm0, %%mm0 \n\t"
|
|
|
|
"pmaddwd %%mm1, %%mm1 \n\t"
|
|
|
|
"paddd %%mm1, %%mm0 \n\t"
|
|
|
|
"psrld $4, %%mm0 \n\t"
|
|
|
|
"paddd %%mm0, %%mm7 \n\t"
|
|
|
|
"add $16, %0 \n\t"
|
|
|
|
"cmp $128, %0 \n\t" //FIXME optimize & bench
|
|
|
|
" jb 1b \n\t"
|
|
|
|
PHADDD(%%mm7, %%mm6)
|
|
|
|
"psrld $2, %%mm7 \n\t"
|
|
|
|
"movd %%mm7, %0 \n\t"
|
|
|
|
|
|
|
|
: "+r" (i)
|
|
|
|
: "r"(basis), "r"(rem), "r"(weight), "g"(scale)
|
|
|
|
);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DEF(add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale)
|
|
|
|
{
|
2008-05-08 23:11:24 +02:00
|
|
|
x86_reg i=0;
|
2007-05-18 10:18:56 +02:00
|
|
|
|
|
|
|
if(FFABS(scale) < MAX_ABS){
|
|
|
|
scale<<= 16 + SCALE_OFFSET - BASIS_SHIFT + RECON_SHIFT;
|
|
|
|
SET_RND(mm6);
|
2008-10-16 15:34:09 +02:00
|
|
|
__asm__ volatile(
|
2007-05-18 10:18:56 +02:00
|
|
|
"movd %3, %%mm5 \n\t"
|
|
|
|
"punpcklwd %%mm5, %%mm5 \n\t"
|
|
|
|
"punpcklwd %%mm5, %%mm5 \n\t"
|
2011-01-15 23:09:35 +01:00
|
|
|
".p2align 4 \n\t"
|
2007-05-18 10:18:56 +02:00
|
|
|
"1: \n\t"
|
|
|
|
"movq (%1, %0), %%mm0 \n\t"
|
|
|
|
"movq 8(%1, %0), %%mm1 \n\t"
|
|
|
|
PMULHRW(%%mm0, %%mm1, %%mm5, %%mm6)
|
|
|
|
"paddw (%2, %0), %%mm0 \n\t"
|
|
|
|
"paddw 8(%2, %0), %%mm1 \n\t"
|
|
|
|
"movq %%mm0, (%2, %0) \n\t"
|
|
|
|
"movq %%mm1, 8(%2, %0) \n\t"
|
|
|
|
"add $16, %0 \n\t"
|
|
|
|
"cmp $128, %0 \n\t" // FIXME optimize & bench
|
|
|
|
" jb 1b \n\t"
|
|
|
|
|
|
|
|
: "+r" (i)
|
|
|
|
: "r"(basis), "r"(rem), "g"(scale)
|
|
|
|
);
|
|
|
|
}else{
|
|
|
|
for(i=0; i<8*8; i++){
|
|
|
|
rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|