comparison ps2/mpegvideo_mmi.c @ 721:71f669e9f633 libavcodec

ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
author michaelni
date Thu, 03 Oct 2002 20:57:19 +0000
parents
children c3fc09466f92
comparison
equal deleted inserted replaced
720:409bdaa0b964 721:71f669e9f633
1 /*
2 * Copyright (c) 2000,2001 Fabrice Bellard.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * MMI optimization by Leon van Stuivenberg <leonvs@iae.nl>
19 */
20
21 #include "../dsputil.h"
22 #include "../mpegvideo.h"
23 #include "../avcodec.h"
24
25 void ff_mmi_idct_put(UINT8 *dest, int line_size, DCTELEM *block);
26 void ff_mmi_idct_add(UINT8 *dest, int line_size, DCTELEM *block);
27
28
29 static void dct_unquantize_h263_mmi(MpegEncContext *s,
30 DCTELEM *block, int n, int qscale)
31 {
32 int level=0, qmul, qadd;
33 int nCoeffs;
34
35 assert(s->block_last_index[n]>=0);
36
37 qadd = (qscale - 1) | 1;
38 qmul = qscale << 1;
39
40 if (s->mb_intra) {
41 if (!s->h263_aic) {
42 if (n < 4)
43 level = block[0] * s->y_dc_scale;
44 else
45 level = block[0] * s->c_dc_scale;
46 }else {
47 qadd = 0;
48 level = block[0];
49 }
50 nCoeffs= 63; //does not allways use zigzag table
51 } else {
52 nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
53 }
54
55 asm volatile(
56 "add $14, $0, %3 \n\t"
57 "pcpyld $8, %0, %0 \n\t"
58 "pcpyh $8, $8 \n\t" //r8 = qmul
59 "pcpyld $9, %1, %1 \n\t"
60 "pcpyh $9, $9 \n\t" //r9 = qadd
61 ".p2align 2 \n\t"
62 "1: \n\t"
63 "lq $10, 0($14) \n\t" //r10 = level
64 "addi $14, $14, 16 \n\t" //block+=8
65 "addi %2, %2, -8 \n\t"
66 "pcgth $11, $0, $10 \n\t" //r11 = level < 0 ? -1 : 0
67 "pcgth $12, $10, $0 \n\t" //r12 = level > 0 ? -1 : 0
68 "por $12, $11, $12 \n\t"
69 "pmulth $10, $10, $8 \n\t"
70 "paddh $13, $9, $11 \n\t"
71 "pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd
72 "pmfhl.uw $11 \n\t"
73 "pinteh $10, $11, $10 \n\t" //r10 = level * qmul
74 "paddh $10, $10, $13 \n\t"
75 "pand $10, $10, $12 \n\t"
76 "sq $10, -16($14) \n\t"
77 "bgez %2, 1b \n\t"
78 :: "r"(qmul), "r" (qadd), "r" (nCoeffs), "r" (block) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" );
79
80 if(s->mb_intra)
81 block[0]= level;
82 }
83
84
85 void MPV_common_init_mmi(MpegEncContext *s)
86 {
87 int i;
88 // const int dct_algo = s->avctx->dct_algo;
89 const int idct_algo= s->avctx->idct_algo;
90
91 if(idct_algo==FF_IDCT_AUTO){
92 s->idct_put= ff_mmi_idct_put;
93 s->idct_add= ff_mmi_idct_add;
94 for(i=0; i<64; i++)
95 s->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
96 }
97 s->dct_unquantize_h263 = dct_unquantize_h263_mmi;
98 }
99
100