2002-10-03 23:57:19 +03:00
|
|
|
/*
|
2009-01-19 17:46:40 +02:00
|
|
|
* Copyright (c) 2000,2001 Fabrice Bellard
|
2002-10-03 23:57:19 +03:00
|
|
|
*
|
2007-07-05 13:37:29 +03:00
|
|
|
* MMI optimization by Leon van Stuivenberg
|
|
|
|
*
|
2006-10-07 18:30:46 +03:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2002-10-03 23:57:19 +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.
|
2002-10-03 23:57:19 +03:00
|
|
|
*
|
2006-10-07 18:30:46 +03:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2002-10-03 23:57:19 +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
|
2006-01-13 00:43:26 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2002-10-03 23:57:19 +03:00
|
|
|
*/
|
2005-12-17 20:14:38 +02:00
|
|
|
|
2008-05-09 14:56:36 +03:00
|
|
|
#include "libavcodec/avcodec.h"
|
|
|
|
#include "libavcodec/dsputil.h"
|
|
|
|
#include "libavcodec/mpegvideo.h"
|
2002-10-03 23:57:19 +03:00
|
|
|
|
2005-12-17 20:14:38 +02:00
|
|
|
static void dct_unquantize_h263_mmi(MpegEncContext *s,
|
2002-10-03 23:57:19 +03:00
|
|
|
DCTELEM *block, int n, int qscale)
|
|
|
|
{
|
|
|
|
int level=0, qmul, qadd;
|
|
|
|
int nCoeffs;
|
2005-12-17 20:14:38 +02:00
|
|
|
|
2002-10-03 23:57:19 +03:00
|
|
|
assert(s->block_last_index[n]>=0);
|
2005-12-17 20:14:38 +02:00
|
|
|
|
2002-10-03 23:57:19 +03:00
|
|
|
qadd = (qscale - 1) | 1;
|
|
|
|
qmul = qscale << 1;
|
2005-12-17 20:14:38 +02:00
|
|
|
|
2002-10-03 23:57:19 +03:00
|
|
|
if (s->mb_intra) {
|
|
|
|
if (!s->h263_aic) {
|
2005-12-17 20:14:38 +02:00
|
|
|
if (n < 4)
|
2002-10-03 23:57:19 +03:00
|
|
|
level = block[0] * s->y_dc_scale;
|
|
|
|
else
|
|
|
|
level = block[0] * s->c_dc_scale;
|
|
|
|
}else {
|
|
|
|
qadd = 0;
|
2005-12-22 03:10:11 +02:00
|
|
|
level = block[0];
|
2002-10-03 23:57:19 +03:00
|
|
|
}
|
2007-04-07 17:09:20 +03:00
|
|
|
nCoeffs= 63; //does not always use zigzag table
|
2002-10-03 23:57:19 +03:00
|
|
|
} else {
|
|
|
|
nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
|
|
|
|
}
|
|
|
|
|
2008-10-16 16:34:09 +03:00
|
|
|
__asm__ volatile(
|
2005-12-22 03:10:11 +02:00
|
|
|
"add $14, $0, %3 \n\t"
|
|
|
|
"pcpyld $8, %0, %0 \n\t"
|
|
|
|
"pcpyh $8, $8 \n\t" //r8 = qmul
|
|
|
|
"pcpyld $9, %1, %1 \n\t"
|
|
|
|
"pcpyh $9, $9 \n\t" //r9 = qadd
|
2002-10-03 23:57:19 +03:00
|
|
|
".p2align 2 \n\t"
|
2005-12-22 03:10:11 +02:00
|
|
|
"1: \n\t"
|
|
|
|
"lq $10, 0($14) \n\t" //r10 = level
|
|
|
|
"addi $14, $14, 16 \n\t" //block+=8
|
|
|
|
"addi %2, %2, -8 \n\t"
|
|
|
|
"pcgth $11, $0, $10 \n\t" //r11 = level < 0 ? -1 : 0
|
|
|
|
"pcgth $12, $10, $0 \n\t" //r12 = level > 0 ? -1 : 0
|
|
|
|
"por $12, $11, $12 \n\t"
|
|
|
|
"pmulth $10, $10, $8 \n\t"
|
|
|
|
"paddh $13, $9, $11 \n\t"
|
2002-10-03 23:57:19 +03:00
|
|
|
"pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd
|
2005-12-22 03:10:11 +02:00
|
|
|
"pmfhl.uw $11 \n\t"
|
|
|
|
"pinteh $10, $11, $10 \n\t" //r10 = level * qmul
|
|
|
|
"paddh $10, $10, $13 \n\t"
|
2002-10-03 23:57:19 +03:00
|
|
|
"pand $10, $10, $12 \n\t"
|
2005-12-22 03:10:11 +02:00
|
|
|
"sq $10, -16($14) \n\t"
|
|
|
|
"bgez %2, 1b \n\t"
|
|
|
|
:: "r"(qmul), "r" (qadd), "r" (nCoeffs), "r" (block) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" );
|
2002-10-03 23:57:19 +03:00
|
|
|
|
|
|
|
if(s->mb_intra)
|
|
|
|
block[0]= level;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MPV_common_init_mmi(MpegEncContext *s)
|
|
|
|
{
|
2005-12-17 20:14:38 +02:00
|
|
|
s->dct_unquantize_h263_intra =
|
2004-02-26 15:42:17 +02:00
|
|
|
s->dct_unquantize_h263_inter = dct_unquantize_h263_mmi;
|
2002-10-03 23:57:19 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|