annotate ps2/mpegvideo_mmi.c @ 1064:b32afefe7d33 libavcodec

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