2006-09-10 16:02:42 +02:00
|
|
|
/*
|
|
|
|
* copyright (c) 2004 AGAWA Koji
|
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* This file is part of Libav.
|
2006-10-07 17:30:46 +02:00
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* Libav is free software; you can redistribute it and/or
|
2006-09-10 16:02:42 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 17:30:46 +02:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2006-09-10 16:02:42 +02:00
|
|
|
*
|
2011-03-18 18:35:10 +01:00
|
|
|
* Libav is distributed in the hope that it will be useful,
|
2006-09-10 16:02:42 +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
|
2006-09-10 16:02:42 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2010-09-04 11:59:08 +02:00
|
|
|
#include "libavutil/cpu.h"
|
2008-05-09 13:56:36 +02:00
|
|
|
#include "libavcodec/avcodec.h"
|
|
|
|
#include "libavcodec/dsputil.h"
|
|
|
|
#include "libavcodec/mpegvideo.h"
|
2010-03-08 03:36:07 +01:00
|
|
|
#include "mpegvideo_arm.h"
|
2005-05-26 16:32:46 +02:00
|
|
|
|
|
|
|
static void dct_unquantize_h263_intra_iwmmxt(MpegEncContext *s,
|
|
|
|
DCTELEM *block, int n, int qscale)
|
|
|
|
{
|
|
|
|
int level, qmul, qadd;
|
|
|
|
int nCoeffs;
|
|
|
|
DCTELEM *block_orig = block;
|
|
|
|
|
|
|
|
assert(s->block_last_index[n]>=0);
|
|
|
|
|
|
|
|
qmul = qscale << 1;
|
|
|
|
|
|
|
|
if (!s->h263_aic) {
|
|
|
|
if (n < 4)
|
|
|
|
level = block[0] * s->y_dc_scale;
|
|
|
|
else
|
|
|
|
level = block[0] * s->c_dc_scale;
|
|
|
|
qadd = (qscale - 1) | 1;
|
|
|
|
}else{
|
|
|
|
qadd = 0;
|
|
|
|
level = block[0];
|
|
|
|
}
|
|
|
|
if(s->ac_pred)
|
|
|
|
nCoeffs=63;
|
|
|
|
else
|
|
|
|
nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
|
|
|
|
|
2008-10-16 15:34:09 +02:00
|
|
|
__asm__ volatile (
|
2005-05-26 16:32:46 +02:00
|
|
|
/* "movd %1, %%mm6 \n\t" //qmul */
|
|
|
|
/* "packssdw %%mm6, %%mm6 \n\t" */
|
|
|
|
/* "packssdw %%mm6, %%mm6 \n\t" */
|
|
|
|
"tbcsth wr6, %[qmul] \n\t"
|
|
|
|
/* "movd %2, %%mm5 \n\t" //qadd */
|
|
|
|
/* "packssdw %%mm5, %%mm5 \n\t" */
|
|
|
|
/* "packssdw %%mm5, %%mm5 \n\t" */
|
|
|
|
"tbcsth wr5, %[qadd] \n\t"
|
|
|
|
"wzero wr7 \n\t" /* "pxor %%mm7, %%mm7 \n\t" */
|
|
|
|
"wzero wr4 \n\t" /* "pxor %%mm4, %%mm4 \n\t" */
|
|
|
|
"wsubh wr7, wr5, wr7 \n\t" /* "psubw %%mm5, %%mm7 \n\t" */
|
|
|
|
"1: \n\t"
|
|
|
|
"wldrd wr2, [%[block]] \n\t" /* "movq (%0, %3), %%mm0 \n\t" */
|
|
|
|
"wldrd wr3, [%[block], #8] \n\t" /* "movq 8(%0, %3), %%mm1 \n\t" */
|
|
|
|
"wmulsl wr0, wr6, wr2 \n\t" /* "pmullw %%mm6, %%mm0 \n\t" */
|
|
|
|
"wmulsl wr1, wr6, wr3 \n\t" /* "pmullw %%mm6, %%mm1 \n\t" */
|
|
|
|
/* "movq (%0, %3), %%mm2 \n\t" */
|
|
|
|
/* "movq 8(%0, %3), %%mm3 \n\t" */
|
|
|
|
"wcmpgtsh wr2, wr4, wr2 \n\t" /* "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 */
|
|
|
|
"wcmpgtsh wr3, wr4, wr2 \n\t" /* "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 */
|
|
|
|
"wxor wr0, wr2, wr0 \n\t" /* "pxor %%mm2, %%mm0 \n\t" */
|
|
|
|
"wxor wr1, wr3, wr1 \n\t" /* "pxor %%mm3, %%mm1 \n\t" */
|
|
|
|
"waddh wr0, wr7, wr0 \n\t" /* "paddw %%mm7, %%mm0 \n\t" */
|
|
|
|
"waddh wr1, wr7, wr1 \n\t" /* "paddw %%mm7, %%mm1 \n\t" */
|
|
|
|
"wxor wr2, wr0, wr2 \n\t" /* "pxor %%mm0, %%mm2 \n\t" */
|
|
|
|
"wxor wr3, wr1, wr3 \n\t" /* "pxor %%mm1, %%mm3 \n\t" */
|
|
|
|
"wcmpeqh wr0, wr7, wr0 \n\t" /* "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0 */
|
|
|
|
"wcmpeqh wr1, wr7, wr1 \n\t" /* "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0 */
|
|
|
|
"wandn wr0, wr2, wr0 \n\t" /* "pandn %%mm2, %%mm0 \n\t" */
|
|
|
|
"wandn wr1, wr3, wr1 \n\t" /* "pandn %%mm3, %%mm1 \n\t" */
|
|
|
|
"wstrd wr0, [%[block]] \n\t" /* "movq %%mm0, (%0, %3) \n\t" */
|
|
|
|
"wstrd wr1, [%[block], #8] \n\t" /* "movq %%mm1, 8(%0, %3) \n\t" */
|
|
|
|
"add %[block], %[block], #16 \n\t" /* "addl $16, %3 \n\t" */
|
|
|
|
"subs %[i], %[i], #1 \n\t"
|
|
|
|
"bne 1b \n\t" /* "jng 1b \n\t" */
|
|
|
|
:[block]"+r"(block)
|
|
|
|
:[i]"r"((nCoeffs + 8) / 8), [qmul]"r"(qmul), [qadd]"r"(qadd)
|
|
|
|
:"memory");
|
|
|
|
|
|
|
|
block_orig[0] = level;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MPV_common_init_iwmmxt(MpegEncContext *s)
|
|
|
|
{
|
2010-09-04 11:59:08 +02:00
|
|
|
if (!(mm_flags & AV_CPU_FLAG_IWMMXT)) return;
|
2005-06-29 00:46:36 +02:00
|
|
|
|
2005-05-26 16:32:46 +02:00
|
|
|
s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_iwmmxt;
|
|
|
|
}
|