summaryrefslogtreecommitdiff
path: root/libavcodec/ps2/mpegvideo_mmi.c
diff options
context:
space:
mode:
authorLeon van Stuivenberg <leonvs@iae.nl>2002-10-03 20:57:19 +0000
committerMichael Niedermayer <michaelni@gmx.at>2002-10-03 20:57:19 +0000
commit5917d17cb79af27681209a745492bdccc37d2f76 (patch)
treefc485a567406369162ff76ef6b14bf769a1177aa /libavcodec/ps2/mpegvideo_mmi.c
parenta46a3ce416ce058c9553fb4fd6865fbf623fa64b (diff)
ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
Originally committed as revision 996 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ps2/mpegvideo_mmi.c')
-rw-r--r--libavcodec/ps2/mpegvideo_mmi.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/libavcodec/ps2/mpegvideo_mmi.c b/libavcodec/ps2/mpegvideo_mmi.c
new file mode 100644
index 0000000000..f12640cb8b
--- /dev/null
+++ b/libavcodec/ps2/mpegvideo_mmi.c
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2000,2001 Fabrice Bellard.
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * MMI optimization by Leon van Stuivenberg <leonvs@iae.nl>
+ */
+
+#include "../dsputil.h"
+#include "../mpegvideo.h"
+#include "../avcodec.h"
+
+void ff_mmi_idct_put(UINT8 *dest, int line_size, DCTELEM *block);
+void ff_mmi_idct_add(UINT8 *dest, int line_size, DCTELEM *block);
+
+
+static void dct_unquantize_h263_mmi(MpegEncContext *s,
+ DCTELEM *block, int n, int qscale)
+{
+ int level=0, qmul, qadd;
+ int nCoeffs;
+
+ assert(s->block_last_index[n]>=0);
+
+ qadd = (qscale - 1) | 1;
+ qmul = qscale << 1;
+
+ if (s->mb_intra) {
+ if (!s->h263_aic) {
+ if (n < 4)
+ level = block[0] * s->y_dc_scale;
+ else
+ level = block[0] * s->c_dc_scale;
+ }else {
+ qadd = 0;
+ level = block[0];
+ }
+ nCoeffs= 63; //does not allways use zigzag table
+ } else {
+ nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
+ }
+
+ asm volatile(
+ "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
+ ".p2align 2 \n\t"
+ "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"
+ "pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd
+ "pmfhl.uw $11 \n\t"
+ "pinteh $10, $11, $10 \n\t" //r10 = level * qmul
+ "paddh $10, $10, $13 \n\t"
+ "pand $10, $10, $12 \n\t"
+ "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" );
+
+ if(s->mb_intra)
+ block[0]= level;
+}
+
+
+void MPV_common_init_mmi(MpegEncContext *s)
+{
+ int i;
+// const int dct_algo = s->avctx->dct_algo;
+ const int idct_algo= s->avctx->idct_algo;
+
+ if(idct_algo==FF_IDCT_AUTO){
+ s->idct_put= ff_mmi_idct_put;
+ s->idct_add= ff_mmi_idct_add;
+ for(i=0; i<64; i++)
+ s->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
+ }
+ s->dct_unquantize_h263 = dct_unquantize_h263_mmi;
+}
+
+