Revision 5917d17c

View differences:

libavcodec/Makefile
77 77
endif
78 78

  
79 79
ifeq ($(TARGET_MMI),yes)
80
OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o
80
OBJS += ps2/dsputil_mmi.o ps2/idct_mmi.o ps2/mpegvideo_mmi.o
81 81
endif
82 82

  
83 83
ifeq ($(TARGET_ALTIVEC),yes)
libavcodec/mpegvideo.c
216 216
#ifdef HAVE_MLIB
217 217
    MPV_common_init_mlib(s);
218 218
#endif
219
#ifdef HAVE_MMI
220
    MPV_common_init_mmi(s);
221
#endif
219 222
    
220 223

  
221 224
    /* load & permutate scantables
libavcodec/mpegvideo.h
503 503
#ifdef HAVE_MLIB
504 504
void MPV_common_init_mlib(MpegEncContext *s);
505 505
#endif
506
#ifdef HAVE_MMI
507
void MPV_common_init_mmi(MpegEncContext *s);
508
#endif
506 509
extern void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w);
507 510
void ff_conceal_past_errors(MpegEncContext *s, int conceal_all);
508 511
void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length);
libavcodec/ps2/dsputil_mmi.c
20 20
 */
21 21

  
22 22
#include "../dsputil.h"
23

  
24
void ff_mmi_idct(DCTELEM * block);
25

  
26 23
#include "mmi.h"
27 24

  
25
/* the provided 'as' in binutils 2.9EE doesn't support
26
the EE's mips3 instructions properly */
27
#define AS_BUGGY
28

  
28 29

  
29 30
static void clear_blocks_mmi(DCTELEM * blocks)
30 31
{
31
    /* $4 = blocks */
32 32
    int i;
33 33
    for (i = 0; i < 6; i++) {
34
        sq($0, 0, $4);
35
        sq($0, 16, $4);
36
        sq($0, 32, $4);
37
        sq($0, 48, $4);
38
        sq($0, 64, $4);
39
        sq($0, 80, $4);
40
        sq($0, 96, $4);
41
        sq($0, 112, $4);
42
        __asm__ __volatile__("addi $4, $4, 128");
34
        asm volatile(
35
        "sq     $0, 0(%0)       \n\t"
36
        "sq     $0, 16(%0)      \n\t"
37
        "sq     $0, 32(%0)      \n\t"
38
        "sq     $0, 48(%0)      \n\t"
39
        "sq     $0, 64(%0)      \n\t"
40
        "sq     $0, 80(%0)      \n\t"
41
        "sq     $0, 96(%0)      \n\t"
42
        "sq     $0, 112(%0)     \n\t" :: "r" (blocks) : "memory" );
43
        blocks += 64;
43 44
    }
44 45
}
45 46

  
46 47

  
47
static void put_pixels_clamped_mmi(const DCTELEM * block, UINT8 * pixels,
48
				   int line_size)
48
static void get_pixels_mmi(DCTELEM *block, const UINT8 *pixels, int line_size)
49 49
{
50
    /* $4 = block, $5 = pixels, $6 = line_size */
51
    __asm__ __volatile__("li $11, 255":::"$11");
52
    lq($4, 0, $12);
53
    pcpyld($11, $11, $11);
54
    pcpyh($11, $11);
55

  
56
#define PUT(rs) \
57
    ppacb($0, $##rs, $##rs); \
58
    sd3(rs, 0, 5); \
59
    __asm__ __volatile__ ("add $5, $5, $6");
60

  
61
    pminh($12, $11, $12);
62
    pmaxh($12, $0, $12);
63
    lq($4, 16, $13);
64
    PUT(12);
65

  
66
    pminh($13, $11, $13);
67
    pmaxh($13, $0, $13);
68
    lq($4, 32, $12);
69
    PUT(13);
70

  
71
    pminh($12, $11, $12);
72
    pmaxh($12, $0, $12);
73
    lq($4, 48, $13);
74
    PUT(12);
75

  
76
    pminh($13, $11, $13);
77
    pmaxh($13, $0, $13);
78
    lq($4, 64, $12);
79
    PUT(13);
80

  
81
    pminh($12, $11, $12);
82
    pmaxh($12, $0, $12);
83
    lq($4, 80, $13);
84
    PUT(12);
85

  
86
    pminh($13, $11, $13);
87
    pmaxh($13, $0, $13);
88
    lq($4, 96, $12);
89
    PUT(13);
50
    int i;
51
    for(i=0;i<8;i++) {
52
#ifdef AS_BUGGY
53
        ld3(5, 0, 8);
54
        asm volatile(
55
        "add    %1, %1, %2      \n\t"
56
        "pextlb $8, $0, $8      \n\t"
57
        "sq     $8, 0(%0)       \n\t" :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "memory" );
58
#else
59
        asm volatile(
60
        "ld     $8, 0(%1)       \n\t"
61
        "add    %1, %1, %2      \n\t"
62
        "pextlb $8, $0, $8      \n\t"
63
        "sq     $8, 0(%0)       \n\t" :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "memory" );
64
#endif
65
        block += 8;
66
    }
67
}
90 68

  
91
    pminh($12, $11, $12);
92
    pmaxh($12, $0, $12);
93
    lq($4, 112, $13);
94
    PUT(12);
95 69

  
96
    pminh($13, $11, $13);
97
    pmaxh($13, $0, $13);
98
    PUT(13);
70
static void put_pixels8_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
71
{
72
    int i;
73
    for(i=0; i<h; i++) {
74
#ifdef AS_BUGGY
75
        ldr3(5, 0, 8);
76
        ldl3(5, 7, 8);
77
        asm volatile ( "add $5, $5, $6 \n\t" );
78
        sd3(8, 0, 4);
79
        asm volatile ( "add $4, $4, $6 \n\t" );
80
#else
81
        asm volatile(
82
        "ldr    $8, 0(%1)       \n\t"
83
        "ldl    $8, 7(%1)       \n\t"
84
        "add    %1, %1, %2      \n\t"
85
        "sd     $8, 0(%0)       \n\t"
86
        "add    %0, %0, %2      \n\t" :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "memory" );
87
#endif
88
    }
99 89
}
100 90

  
101
/* todo
102
static void add_pixels_clamped_mmi(const DCTELEM * block, UINT8 * pixels,
103
				   int line_size)
91

  
92
static void put_pixels16_mmi(uint8_t *block, const uint8_t *pixels, int line_size, int h)
104 93
{
94
    int i;
95
    for(i=0; i<h; i++) {
96
#ifdef AS_BUGGY
97
        ldr3(5, 0, 8);
98
        ldl3(5, 7, 8);
99
        ldr3(5, 8, 9);
100
        ldl3(5, 15, 9);
101
        asm volatile ( "add $5, $5, $6 \n\t" );
102
        pcpyld($9, $8, $8);
103
        sq($8, 0, $4);
104
        asm volatile ( "add $4, $4, $6 \n\t" );
105
#else
106
        asm volatile (
107
        "ldr    $8, 0(%1)       \n\t"
108
        "ldl    $8, 7(%1)       \n\t"
109
        "ldr    $9, 8(%1)       \n\t"
110
        "ldl    $9, 15(%1)      \n\t"
111
        "add    %1, %1, %2      \n\t"
112
        "pcpyld $8, $9, $8      \n\t"
113
        "sq     $8, 0(%0)       \n\t"
114
        "add    %0, %0, %2      \n\t" :: "r" (block), "r" (pixels), "r" (line_size) : "$8", "$9", "memory" );
115
#endif
116
    }
105 117
}
106
*/
107 118

  
108 119

  
109 120
void dsputil_init_mmi(void)
110 121
{
111
    put_pixels_clamped = put_pixels_clamped_mmi;
112
    //add_pixels_clamped = add_pixels_clamped_mmi;
113 122
    clear_blocks = clear_blocks_mmi;
114
    ff_idct = ff_mmi_idct;
123
    
124
    put_pixels_tab[1][0] = put_pixels8_mmi;
125
    put_no_rnd_pixels_tab[1][0] = put_pixels8_mmi;
126
    
127
    put_pixels_tab[0][0] = put_pixels16_mmi;
128
    put_no_rnd_pixels_tab[0][0] = put_pixels16_mmi;
129
    
130
    get_pixels = get_pixels_mmi;
115 131
}
132

  
libavcodec/ps2/idct_mmi.c
12 12
  mmi port by leonvs@iae.nl
13 13
*/  
14 14
#include "../common.h"
15
#include "../dsputil.h"
15 16
#include "mmi.h"
16 17

  
17 18
#define BITS_INV_ACC	5	// 4 or 5 for IEEE
18 19
#define SHIFT_INV_ROW	(16 - BITS_INV_ACC)
19 20
#define SHIFT_INV_COL   (1 + BITS_INV_ACC)
20 21

  
21
// assume SHIFT_INV_ROW == 11
22
static int roundertable[8][4] align16 = {
23
    { 0x103ff, 0x103ff, 0x103ff, 0x103ff },
24
    { 1023,  1023,  1023,  1023}
25
};
26

  
27

  
28
#define TAB_i_04	0
29
#define TAB_i_17	64
30
#define TAB_i_26	128
31
#define TAB_i_35	192
32

  
33
static short rowtable[4][32] align16 = {
34
    {
35
     16384, 16384, 22725, 12873, 21407, 8867, 19266, 4520,
36
     16384, -16383, 19266, -22724, 8867, -21406, -4519, -12872,
37
     16384, -16383, 12873, 4520, -8866, 21407, -22724, 19266,
38
     16384, 16384, 4520, 19266, -21406, -8866, -12872, -22724},
39
    {
40
     22725, 22725, 31521, 17855, 29692, 12299, 26722, 6270,
41
     22725, -22724, 26722, -31520, 12299, -29691, -6269, -17854,
42
     22725, -22724, 17855, 6270, -12298, 29692, -31520, 26722,
43
     22725, 22725, 6270, 26722, -29691, -12298, -17854, -31520},
44
    {
45
     21407, 21407, 29692, 16819, 27969, 11585, 25172, 5906,
46
     21407, -21406, 25172, -29691, 11585, -27968, -5905, -16818,
47
     21407, -21406, 16819, 5906, -11584, 27969, -29691, 25172,
48
     21407, 21407, 5906, 25172, -27968, -11584, -16818, -29691},
49
    {
50
     19266, 19266, 26722, 15137, 25172, 10426, 22654, 5315,
51
     19266, -19265, 22654, -26721, 10426, -25171, -5314, -15136,
52
     19266, -19265, 15137, 5315, -10425, 25172, -26721, 22654,
53
     19266, 19266, 5315, 22654, -25171, -10425, -15136, -26721}
54
};
55

  
56

  
57
#define TG_3_16_minus_one	0
58
#define ONE_plus_tg_3_16	16
59
#define ONE_plus_tg_1_16	32
60
#define TG_1_16_minus_one	48
61
#define TG_2_16_minus_one	64
62
#define ONE_plus_tg_2_16	80
63
#define ZERO_ocos_4_16		96
64

  
65 22
#define TG1	6518
66 23
#define TG2	13573
67 24
#define TG3	21895
68
#define MN1	-32768
69
#define PL1	32768
70 25
#define CS4	23170
71 26

  
72
static short coltable[7][8] align16 = {
73
    { MN1,  TG3,  MN1,  TG3,  MN1,  TG3,  MN1,  TG3},
74
    {-TG3, -PL1, -TG3, -PL1, -TG3, -PL1, -TG3, -PL1},
75
    {-TG1, -PL1, -TG1, -PL1, -TG1, -PL1, -TG1, -PL1},
76
    { MN1,  TG1,  MN1,  TG1,  MN1,  TG1,  MN1,  TG1},
77
    { MN1,  TG2,  MN1,  TG2,  MN1,  TG2,  MN1,  TG2},
78
    {-TG2, -PL1, -TG2, -PL1, -TG2, -PL1, -TG2, -PL1},
79
    { CS4,    0,  CS4,    0,  CS4,    0,  CS4,    0}
27
#define ROUNDER_0	0
28
#define ROUNDER_1	16
29

  
30
#define TAB_i_04	(32+0)
31
#define TAB_i_17	(32+64)
32
#define TAB_i_26	(32+128)
33
#define TAB_i_35	(32+192)
34

  
35
#define TG_1_16		(32+256+0)
36
#define TG_2_16		(32+256+16)
37
#define TG_3_16		(32+256+32)
38
#define COS_4_16	(32+256+48)
39

  
40
#define CLIPMAX		(32+256+64+0)
41

  
42
static short consttable[] align16 = {
43
/* rounder 0*/	// assume SHIFT_INV_ROW == 11
44
 0x3ff, 1, 0x3ff, 1, 0x3ff, 1, 0x3ff, 1,
45
/* rounder 1*/
46
 0x3ff, 0, 0x3ff, 0, 0x3ff, 0, 0x3ff, 0,
47
/* row 0/4*/
48
 16384,  21407, -16384, -21407,  22725,  19266, -22725, -12873, 
49
  8867,  16384,   8867,  16384,   4520,  12873,  -4520,  19266, 
50
 16384,  -8867,  16384,  -8867,  12873, -22725,  19266, -22725, 
51
 21407, -16384, -21407,  16384,  19266,   4520, -12873,   4520, 
52
/* row 1/7*/
53
 22725,  29692, -22725, -29692,  31521,  26722, -31521, -17855, 
54
 12299,  22725,  12299,  22725,   6270,  17855,  -6270,  26722, 
55
 22725, -12299,  22725, -12299,  17855, -31521,  26722, -31521, 
56
 29692, -22725, -29692,  22725,  26722,   6270, -17855,   6270, 
57
/* row 2/6*/
58
 21407,  27969, -21407, -27969,  29692,  25172, -29692, -16819, 
59
 11585,  21407,  11585,  21407,   5906,  16819,  -5906,  25172, 
60
 21407, -11585,  21407, -11585,  16819, -29692,  25172, -29692, 
61
 27969, -21407, -27969,  21407,  25172,   5906, -16819,   5906, 
62
/*row 3/5*/
63
 19266,  25172, -19266, -25172,  26722,  22654, -26722, -15137, 
64
 10426,  19266,  10426,  19266,   5315,  15137,  -5315,  22654, 
65
 19266, -10426,  19266, -10426,  15137, -26722,  22654, -26722, 
66
 25172, -19266, -25172,  19266,  22654,   5315, -15137,   5315,
67
/*column constants*/
68
 TG1, TG1, TG1, TG1, TG1, TG1, TG1, TG1,
69
 TG2, TG2, TG2, TG2, TG2, TG2, TG2, TG2,
70
 TG3, TG3, TG3, TG3, TG3, TG3, TG3, TG3,
71
 CS4, CS4, CS4, CS4, CS4, CS4, CS4, CS4,
72
/* clamp */
73
 255, 255, 255, 255, 255, 255, 255, 255
80 74
};
81 75

  
82
#define	noprevh(rt, rd)
83

  
84

  
85
#define DCT_8_INV_ROW1(rowoff, taboff, rnd, outreg) { \
86
\
87
	lq($4, rowoff, $16);	/* r16 = x7  x6  x5  x4  x3  x2  x1  x0 */ \
88
	lq($24, 0+taboff, $17);	/* r17 = w19 w17 w3  w1  w18 w16 w2  w0 */ \
89
	pinth($16, $16, $16);	/* r16 = x7  x3  x6  x2  x5  x1  x4  x0 */ \
90
	phmadh($17, $16, $17);	/* r17 = (x7*w19+x3*w17)b0'' (x6*w3+x2*w1)a0'' (x5*w18+x1*w16)b0' (x4*w2+x0*w0)a0' */ \
91
	lq($24, 16+taboff, $18);/* r18 = w23 w21 w7  w5  w22 w20 w6  w4 */ \
92
	lq($24, 32+taboff, $19);/* r19 = w27 w25 w11 w9  w26 w24 w10 w8 */ \
93
	lq($24, 48+taboff, $20);/* r20 = w31 w29 w15 w13 w30 w28 w14 w12 */ \
94
	phmadh($18, $16, $18);	/* r18 = (b1'')(a1'')(b1')(a1') */ \
95
	pcpyud($17, $17, $21);	/* r21 = (b0'')(a0'')(b0'')(a0'') */ \
96
	paddw($17, $21, $17);	/* r17 = (--)(--)(b0)(a0) */ \
97
	phmadh($19, $16, $19);	/* r19 = (b2'')(a2'')(b2')(a2') */ \
98
	pcpyud($18, $18, $21);	/* r21 = (b1'')(a1'')(b1'')(a1'') */ \
99
	paddw($18, $21, $18);	/* r18 = (--)(--)(b1)(a1) */ \
100
	pcpyud($19, $19, $21);	\
101
	phmadh($20, $16, $20);	/* r12 = (b3'')(a3'')(b3')(a3') */ \
102
	paddw($19, $21, $19);	/* r19 = (--)(--)(b2)(a2) */ \
103
	pextlw($19, $17, $16);	/* r16 = (b2)(b0)(a2)(a0) */ \
104
	pcpyud($20, $20, $21);	\
105
	paddw($20, $21, $20);	/* r20 = (--)(--)(b3)(a3) */ \
106
	pextlw($20, $18, $17);	/* r17 = (b3)(b1)(a3)(a1) */ \
107
	pextlw($17, $16, $20);	/* r20 = (a3)(a2)(a1)(a0)" */ \
108
	pextuw($17, $16, $21);	/* r21 = (b3)(b2)(b1)(b0) */ \
109
	paddw($20, rnd, $20);	/* r20 = (a3)(a2)(a1)(a0) */\
110
	paddw($20, $21, $17);	/* r17 = ()()()(a0+b0) */ \
111
	psubw($20, $21, $18);	/* r18 = ()()()(a0-b0) */ \
76

  
77
#define DCT_8_INV_ROW1(blk, rowoff, taboff, rnd, outreg) { \
78
	lq(blk, rowoff, $16);	/* r16 = x7  x5  x3  x1  x6  x4  x2  x0 */ \
79
	/*slot*/ \
80
	lq($24, 0+taboff, $17);	/* r17 = w */ \
81
	/*delay slot $16*/ \
82
	lq($24, 16+taboff, $18);/* r18 = w */ \
83
	prevh($16, $2);		/* r2  = x1  x3  x5  x7  x0  x2  x4  x6 */ \
84
	lq($24, 32+taboff, $19);/* r19 = w */ \
85
	phmadh($17, $16, $17);	/* r17 = b1"b0'a1"a0' */ \
86
	lq($24, 48+taboff, $20);/* r20 = w */ \
87
	phmadh($18, $2, $18);	/* r18 = b1'b0"a1'a0" */ \
88
	phmadh($19, $16, $19);	/* r19 = b3"b2'a3"a2' */ \
89
	phmadh($20, $2, $20);	/* r20 = b3'b2"a3'a2" */ \
90
	paddw($17, $18, $17);	/* r17 = (b1)(b0)(a1)(a0) */ \
91
	paddw($19, $20, $19);	/* r19 = (b3)(b2)(a3)(a2) */ \
92
	pcpyld($19, $17, $18);	/* r18 = (a3)(a2)(a1)(a0) */ \
93
	pcpyud($17, $19, $20);	/* r20 = (b3)(b2)(b1)(b0) */ \
94
	paddw($18, rnd, $18);	/* r18 = (a3)(a2)(a1)(a0) */\
95
	paddw($18, $20, $17);	/* r17 = ()()()(a0+b0) */ \
96
	psubw($18, $20, $20);	/* r20 = ()()()(a0-b0) */ \
112 97
	psraw($17, SHIFT_INV_ROW, $17); /* r17 = (y3 y2 y1 y0) */ \
113
	psraw($18, SHIFT_INV_ROW, $18);	/* r18 = (y4 y5 y6 y7) */ \
114
	ppach($18, $17, outreg);/* out = y4 y5 y6 y7 y3 y2 y1 y0  Note order */ \
98
	psraw($20, SHIFT_INV_ROW, $20);	/* r20 = (y4 y5 y6 y7) */ \
99
	ppach($20, $17, outreg);/* out = y4 y5 y6 y7 y3 y2 y1 y0  Note order */ \
100
\
101
	prevh(outreg, $2);	\
102
	pcpyud($2, $2, $2);	\
103
	pcpyld($2, outreg, outreg);	\
115 104
}
116 105

  
117 106

  
118
#define DCT_8_INV_COL4(pextop, blkoff, revop) { \
119
	lq($24, TG_3_16_minus_one, $2);	/* r2  = (tn3)(-1) x 4 */	\
120
	pextop($11, $13, $3);		/* r3  = (x3)(x5) x 4 */	\
121
	lq($24, ONE_plus_tg_3_16, $16);	/* r16 = -((+1)(tn3)) x 4 */	\
122
	phmadh($3, $2, $17);		/* r17 = (tm35) x 4 */		\
123
	lq($24, ONE_plus_tg_1_16, $2);	/* r2  = -((+1)(tn1)) x 4 */	\
124
	phmadh($3, $16, $18);		/* r18 = -(tp35) x 4 */		\
125
	lq($24, TG_1_16_minus_one, $16);/* r16 = (tn1)(-1) x 4 */	\
126
	pextop($9, $15, $3);		/* r3  = (x1)(x7) x 4 */	\
127
	phmadh($3, $2, $19);						\
128
	lq($24, ZERO_ocos_4_16, $2);	/* r2  = (0)(cos4) x 4 */	\
129
	phmadh($3, $16, $20);		/* r20 = (tm17) x 4 */		\
130
	psubw($0, $19, $19);		/* r19 = (tp17) x 4 */		\
131
	paddw($19, $18, $3);		/* r3  = t1 */			\
132
	paddw($20, $17, $16);		/* r16 = t2 */			\
133
	psubw($20, $17, $23);		/* r23 = b3 */			\
134
	psubw($19, $18, $20);		/* r20 = b0 */			\
135
	paddw($3, $16, $17);		/* (t1+t2) */			\
136
	psubw($3, $16, $18);		/* (t1-t2) */			\
137
	psraw($17, 15, $17);						\
138
	lq($24, TG_2_16_minus_one, $3);	/* r3  = (tn2)(-1) x 4 */	\
139
	pmulth($17, $2, $21);		/* r21 = b1 */			\
140
	psraw($18, 15, $18);						\
141
	lq($24, ONE_plus_tg_2_16, $16);	/* r16 = -((+1)(tn2)) x 4 */	\
142
	pmulth($18, $2, $22);		/* r22 = b2 */			\
143
\
144
	pextop($10, $14, $2);		/* r2  = (x2)(x6) x 4 */	\
145
	phmadh($2, $3, $18);		/* r18 = (tm26) x 4 */		\
146
	phmadh($2, $16, $19);		/* r19 = -(tp26) x 4 */		\
147
	pextop($8, $0, $17);		/* r17 = (x0)(0) x 4 */		\
148
	psraw($17, 1, $17);						\
149
	pextop($12, $0, $16);		/* r16 = (x4)(0) x 4 */		\
150
	psraw($16, 1, $16);						\
151
	paddw($17, $16, $2);		/* r2  = tp04 */		\
152
	psubw($17, $16, $3);		/* r3  = tm04 */		\
153
	psubw($2, $19, $16);		/* r16 = a0 */			\
154
	paddw($3, $18, $17);		/* r17 = a1 */			\
155
	psubw($3, $18, $18);		/* r18 = a2 */			\
156
	paddw($2, $19, $19);		/* r19 = a3 */			\
157
\
158
	paddw($16, $20, $2);	/* y0  a0+b0 */		\
159
	psubw($16, $20, $16);	/* y7  a0-b0 */		\
160
	psraw($2, SHIFT_INV_COL+15, $2);		\
161
	psraw($16, SHIFT_INV_COL+15, $16);		\
162
	ppach($0, $2, $2);				\
163
	ppach($0, $16, $16);				\
164
	revop($2, $2);					\
165
	revop($16, $16);				\
166
	sd3(2, 0+blkoff, 4); 				\
167
	sd3(16, 112+blkoff, 4); 			\
168
\
169
	paddw($17, $21, $3);	/* y1  a1+b1 */		\
170
	psubw($17, $21, $17);	/* y6  a1-b1 */		\
171
	psraw($3, SHIFT_INV_COL+15, $3);		\
172
	psraw($17, SHIFT_INV_COL+15, $17);		\
173
	ppach($0, $3, $3);				\
174
	ppach($0, $17, $17);			\
175
	revop($3, $3);				\
176
	revop($17, $17);			\
177
	sd3(3, 16+blkoff, 4);			\
178
	sd3(17, 96+blkoff, 4);			\
179
\
180
	paddw($18, $22, $2);	/* y2  a2+b2 */	\
181
	psubw($18, $22, $18);	/* y5  a2-b2 */	\
182
	psraw($2, SHIFT_INV_COL+15, $2);	\
183
	psraw($18, SHIFT_INV_COL+15, $18);	\
184
	ppach($0, $2, $2);			\
185
	ppach($0, $18, $18);			\
186
	revop($2, $2);				\
187
	revop($18, $18);			\
188
	sd3(2, 32+blkoff, 4);			\
189
	sd3(18, 80+blkoff, 4);			\
190
\
191
	paddw($19, $23, $3);	/* y3  a3+b3 */	\
192
	psubw($19, $23, $19);	/* y4  a3-b3 */	\
193
	psraw($3, SHIFT_INV_COL+15, $3);	\
194
	psraw($19, SHIFT_INV_COL+15, $19);	\
195
	ppach($0, $3, $3);			\
196
	ppach($0, $19, $19);			\
197
	revop($3, $3);				\
198
	revop($19, $19);			\
199
	sd3(3, 48+blkoff, 4);			\
200
	sd3(19, 64+blkoff, 4);			\
201
}
107
#define DCT_8_INV_COL8() \
108
\
109
	lq($24, TG_3_16, $2);	/* r2  = tn3 */	\
110
\
111
	pmulth($11, $2, $17);	/* r17 = x3 * tn3 (6420) */ \
112
	psraw($17, 15, $17);	\
113
	pmfhl_uw($3);		/* r3  = 7531 */	\
114
	psraw($3, 15, $3);	\
115
	pinteh($3, $17, $17);	/* r17 = x3 * tn3 */ \
116
	psubh($17, $13, $17);	/* r17 = tm35 */	\
117
\
118
	pmulth($13, $2, $18);	/* r18 = x5 * tn3 (6420) */ \
119
	psraw($18, 15, $18);	\
120
	pmfhl_uw($3);		/* r3  = 7531 */	\
121
	psraw($3, 15, $3);	\
122
	pinteh($3, $18, $18);	/* r18 = x5 * tn3 */ \
123
	paddh($18, $11, $18);	/* r18 = tp35 */	\
124
\
125
	lq($24, TG_1_16, $2);	/* r2  = tn1 */	\
126
\
127
	pmulth($15, $2, $19);	/* r19 = x7 * tn1 (6420) */ \
128
	psraw($19, 15, $19);	\
129
	pmfhl_uw($3);		/* r3  = 7531 */	\
130
	psraw($3, 15, $3);	\
131
	pinteh($3, $19, $19);	/* r19 = x7 * tn1 */ \
132
	paddh($19, $9, $19);	/* r19 = tp17 */	\
133
\
134
	pmulth($9, $2, $20);	/* r20 = x1 * tn1 (6420) */ \
135
	psraw($20, 15, $20);	\
136
	pmfhl_uw($3);		/* r3  = 7531 */	\
137
	psraw($3, 15, $3);	\
138
	pinteh($3, $20, $20);	/* r20 = x1 * tn1 */ \
139
	psubh($20, $15, $20);	/* r20 = tm17 */	\
140
\
141
	psubh($19, $18, $3);	/* r3  = t1 */	\
142
	paddh($20, $17, $16);	/* r16 = t2 */	\
143
	psubh($20, $17, $23);	/* r23 = b3 */	\
144
	paddh($19, $18, $20);	/* r20 = b0 */	\
145
\
146
	lq($24, COS_4_16, $2);	/* r2  = cs4 */	\
147
\
148
	paddh($3, $16, $21);	/* r21 = t1+t2 */	\
149
	psubh($3, $16, $22);	/* r22 = t1-t2 */	\
150
\
151
	pmulth($21, $2, $21);	/* r21 = cs4 * (t1+t2) 6420 */ \
152
	psraw($21, 15, $21);	\
153
	pmfhl_uw($3);		/* r3  = 7531 */	\
154
	psraw($3, 15, $3);	\
155
	pinteh($3, $21, $21);	/* r21 = b1 */	\
156
\
157
	pmulth($22, $2, $22);	/* r22 = cs4 * (t1-t2) 6420 */ \
158
	psraw($22, 15, $22);	\
159
	pmfhl_uw($3);		/* r3  = 7531 */	\
160
	psraw($3, 15, $3);	\
161
	pinteh($3, $22, $22);	/* r22 = b2 */	\
162
\
163
	lq($24, TG_2_16, $2);	/* r2  = tn2 */	\
164
\
165
	pmulth($10, $2, $17);	/* r17 = x2 * tn2 (6420) */ \
166
	psraw($17, 15, $17);	\
167
	pmfhl_uw($3);		/* r3  = 7531 */	\
168
	psraw($3, 15, $3);	\
169
	pinteh($3, $17, $17);	/* r17 = x3 * tn3 */ \
170
	psubh($17, $14, $17);	/* r17 = tm26 */	\
171
\
172
	pmulth($14, $2, $18);	/* r18 = x6 * tn2 (6420) */ \
173
	psraw($18, 15, $18);	\
174
	pmfhl_uw($3);		/* r3  = 7531 */	\
175
	psraw($3, 15, $3);	\
176
	pinteh($3, $18, $18);	/* r18 = x6 * tn2 */ \
177
	paddh($18, $10, $18);	/* r18 = tp26 */	\
178
\
179
	paddh($8, $12, $2);	/* r2  = tp04 */	\
180
	psubh($8, $12, $3);	/* r3  = tm04 */	\
181
\
182
	paddh($2, $18, $16);	/* r16 = a0 */			\
183
	psubh($2, $18, $19);	/* r19 = a3 */			\
184
	psubh($3, $17, $18);	/* r18 = a2 */			\
185
	paddh($3, $17, $17);	/* r17 = a1 */
186

  
187

  
188
#define DCT_8_INV_COL8_STORE(blk) \
189
\
190
	paddh($16, $20, $2);	/* y0  a0+b0 */		\
191
	psubh($16, $20, $16);	/* y7  a0-b0 */		\
192
	psrah($2, SHIFT_INV_COL, $2);		\
193
	psrah($16, SHIFT_INV_COL, $16);		\
194
	sq($2, 0, blk); 			\
195
	sq($16, 112, blk); 			\
196
\
197
	paddh($17, $21, $3);	/* y1  a1+b1 */		\
198
	psubh($17, $21, $17);	/* y6  a1-b1 */		\
199
	psrah($3, SHIFT_INV_COL, $3);		\
200
	psrah($17, SHIFT_INV_COL, $17);		\
201
	sq($3, 16, blk);			\
202
	sq($17, 96, blk);			\
203
\
204
	paddh($18, $22, $2);	/* y2  a2+b2 */	\
205
	psubh($18, $22, $18);	/* y5  a2-b2 */	\
206
	psrah($2, SHIFT_INV_COL, $2);	\
207
	psrah($18, SHIFT_INV_COL, $18);	\
208
	sq($2, 32, blk);			\
209
	sq($18, 80, blk);			\
210
\
211
	paddh($19, $23, $3);	/* y3  a3+b3 */	\
212
	psubh($19, $23, $19);	/* y4  a3-b3 */	\
213
	psrah($3, SHIFT_INV_COL, $3);	\
214
	psrah($19, SHIFT_INV_COL, $19);	\
215
	sq($3, 48, blk);			\
216
	sq($19, 64, blk);
217

  
218

  
219

  
220
#define DCT_8_INV_COL8_PMS() \
221
	paddh($16, $20, $2);	/* y0  a0+b0 */		\
222
	psubh($16, $20, $20);	/* y7  a0-b0 */		\
223
	psrah($2, SHIFT_INV_COL, $16);		\
224
	psrah($20, SHIFT_INV_COL, $20);		\
225
\
226
	paddh($17, $21, $3);	/* y1  a1+b1 */		\
227
	psubh($17, $21, $21);	/* y6  a1-b1 */		\
228
	psrah($3, SHIFT_INV_COL, $17);		\
229
	psrah($21, SHIFT_INV_COL, $21);		\
230
\
231
	paddh($18, $22, $2);	/* y2  a2+b2 */	\
232
	psubh($18, $22, $22);	/* y5  a2-b2 */	\
233
	psrah($2, SHIFT_INV_COL, $18);	\
234
	psrah($22, SHIFT_INV_COL, $22);	\
235
\
236
	paddh($19, $23, $3);	/* y3  a3+b3 */	\
237
	psubh($19, $23, $23);	/* y4  a3-b3 */	\
238
	psrah($3, SHIFT_INV_COL, $19);	\
239
	psrah($23, SHIFT_INV_COL, $23);
240

  
241
#define PUT(rs) \
242
	pminh(rs, $11, $2);	\
243
    	pmaxh($2, $0, $2);	\
244
	ppacb($0, $2, $2); \
245
	sd3(2, 0, 4); \
246
	__asm__ __volatile__ ("add $4, $5, $4");
247

  
248
#define DCT_8_INV_COL8_PUT() \
249
    	PUT($16);		\
250
    	PUT($17);		\
251
    	PUT($18);		\
252
    	PUT($19);		\
253
    	PUT($23);		\
254
    	PUT($22);		\
255
    	PUT($21);		\
256
    	PUT($20);
257

  
258
#define ADD(rs) \
259
    ld3(4, 0, 2); \
260
    pextlb($0, $2, $2); \
261
    paddh($2, rs, $2); \
262
    pminh($2, $11, $2);	\
263
    pmaxh($2, $0, $2);	\
264
    ppacb($0, $2, $2); \
265
    sd3(2, 0, 4); \
266
    __asm__ __volatile__ ("add $4, $5, $4");
267

  
268
/*fixme: schedule*/
269
#define DCT_8_INV_COL8_ADD() \
270
    	ADD($16);		\
271
    	ADD($17);		\
272
    	ADD($18);		\
273
    	ADD($19);		\
274
    	ADD($23);		\
275
    	ADD($22);		\
276
    	ADD($21);		\
277
    	ADD($20);
202 278

  
203 279

  
204 280
void ff_mmi_idct(int16_t * block)
205 281
{
206 282
    /* $4 = block */
207
    __asm__ __volatile__("la $7, %0"::"m"(roundertable[0][0]));
208
    __asm__ __volatile__("la $24, %0"::"m"(rowtable[0][0]));
209
    lq($7, 0, $6);
210
    lq($7, 16, $7);
211
    DCT_8_INV_ROW1(0, TAB_i_04, $6, $8);
212
    DCT_8_INV_ROW1(16, TAB_i_17, $7, $9);
213
    DCT_8_INV_ROW1(32, TAB_i_26, $7, $10);
214
    DCT_8_INV_ROW1(48, TAB_i_35, $7, $11);
215
    DCT_8_INV_ROW1(64, TAB_i_04, $7, $12);
216
    DCT_8_INV_ROW1(80, TAB_i_35, $7, $13);
217
    DCT_8_INV_ROW1(96, TAB_i_26, $7, $14);
218
    DCT_8_INV_ROW1(112, TAB_i_17, $7, $15);
219

  
220
    __asm__ __volatile__("la $24, %0"::"m"(coltable[0][0]));
221
    DCT_8_INV_COL4(pextlh, 0, noprevh);
222
    DCT_8_INV_COL4(pextuh, 8, prevh);
283
    __asm__ __volatile__("la $24, %0"::"m"(consttable[0]));
284
    lq($24, ROUNDER_0, $8);
285
    lq($24, ROUNDER_1, $7);
286
    DCT_8_INV_ROW1($4, 0, TAB_i_04, $8, $8);
287
    DCT_8_INV_ROW1($4, 16, TAB_i_17, $7, $9);
288
    DCT_8_INV_ROW1($4, 32, TAB_i_26, $7, $10);
289
    DCT_8_INV_ROW1($4, 48, TAB_i_35, $7, $11);
290
    DCT_8_INV_ROW1($4, 64, TAB_i_04, $7, $12);
291
    DCT_8_INV_ROW1($4, 80, TAB_i_35, $7, $13);
292
    DCT_8_INV_ROW1($4, 96, TAB_i_26, $7, $14);
293
    DCT_8_INV_ROW1($4, 112, TAB_i_17, $7, $15);
294
    DCT_8_INV_COL8();
295
    DCT_8_INV_COL8_STORE($4);
296
 
297
    //let savedtemp regs be saved
298
    __asm__ __volatile__(" ":::"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23");
299
}
300

  
301

  
302
void ff_mmi_idct_put(UINT8 *dest, int line_size, DCTELEM *block)
303
{
304
    /* $4 = dest, $5 = line_size, $6 = block */
305
    __asm__ __volatile__("la $24, %0"::"m"(consttable[0]));
306
    lq($24, ROUNDER_0, $8);
307
    lq($24, ROUNDER_1, $7);
308
    DCT_8_INV_ROW1($6, 0, TAB_i_04, $8, $8);
309
    DCT_8_INV_ROW1($6, 16, TAB_i_17, $7, $9);
310
    DCT_8_INV_ROW1($6, 32, TAB_i_26, $7, $10);
311
    DCT_8_INV_ROW1($6, 48, TAB_i_35, $7, $11);
312
    DCT_8_INV_ROW1($6, 64, TAB_i_04, $7, $12);
313
    DCT_8_INV_ROW1($6, 80, TAB_i_35, $7, $13);
314
    DCT_8_INV_ROW1($6, 96, TAB_i_26, $7, $14);
315
    DCT_8_INV_ROW1($6, 112, TAB_i_17, $7, $15);
316
    DCT_8_INV_COL8();
317
    lq($24, CLIPMAX, $11);
318
    DCT_8_INV_COL8_PMS();
319
    DCT_8_INV_COL8_PUT();
320

  
321
    //let savedtemp regs be saved
322
    __asm__ __volatile__(" ":::"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23");
323
}
324

  
325

  
326
void ff_mmi_idct_add(UINT8 *dest, int line_size, DCTELEM *block)
327
{
328
    /* $4 = dest, $5 = line_size, $6 = block */
329
    __asm__ __volatile__("la $24, %0"::"m"(consttable[0]));
330
    lq($24, ROUNDER_0, $8);
331
    lq($24, ROUNDER_1, $7);
332
    DCT_8_INV_ROW1($6, 0, TAB_i_04, $8, $8);
333
    DCT_8_INV_ROW1($6, 16, TAB_i_17, $7, $9);
334
    DCT_8_INV_ROW1($6, 32, TAB_i_26, $7, $10);
335
    DCT_8_INV_ROW1($6, 48, TAB_i_35, $7, $11);
336
    DCT_8_INV_ROW1($6, 64, TAB_i_04, $7, $12);
337
    DCT_8_INV_ROW1($6, 80, TAB_i_35, $7, $13);
338
    DCT_8_INV_ROW1($6, 96, TAB_i_26, $7, $14);
339
    DCT_8_INV_ROW1($6, 112, TAB_i_17, $7, $15);
340
    DCT_8_INV_COL8();
341
    lq($24, CLIPMAX, $11);
342
    DCT_8_INV_COL8_PMS();
343
    DCT_8_INV_COL8_ADD();
223 344

  
224 345
    //let savedtemp regs be saved
225
    __asm__ __volatile__(" ":::"$16", "$17", "$18", "$19", "$20", "$21",
226
			 "$22", "$23", "$6", "$7");
346
    __asm__ __volatile__(" ":::"$16", "$17", "$18", "$19", "$20", "$21", "$22", "$23");
227 347
}
228 348

  
libavcodec/ps2/mmi.h
49 49
	__asm__ __volatile__ ("sq " #reg ", %0("#base ")" : : "i" (off) )
50 50

  
51 51
/*
52
#define	ld(base, off, reg)	\
53
	__asm__ __volatile__ ("ld " #reg ", " #off "("#base ")")
54
*/
55

  
56
#define	ld3(base, off, reg)	\
57
	__asm__ __volatile__ (".word %0" : : "i" ( 0xdc000000 | (base<<21) | (reg<<16) | (off)))
58

  
59
#define	ldr3(base, off, reg)	\
60
	__asm__ __volatile__ (".word %0" : : "i" ( 0x6c000000 | (base<<21) | (reg<<16) | (off)))
61

  
62
#define	ldl3(base, off, reg)	\
63
	__asm__ __volatile__ (".word %0" : : "i" ( 0x68000000 | (base<<21) | (reg<<16) | (off)))
64

  
65
/*
52 66
#define	sd(reg, off, base)	\
53 67
	__asm__ __volatile__ ("sd " #reg ", " #off "("#base ")")
54 68
*/
......
116 130
#define	pminh(rs, rt, rd) \
117 131
	__asm__ __volatile__ ("pminh " #rd ", " #rs ", " #rt )
118 132

  
133
#define	pinteh(rs, rt, rd) \
134
	__asm__ __volatile__ ("pinteh  " #rd ", " #rs ", " #rt )
135

  
136
#define	paddh(rs, rt, rd) \
137
	__asm__ __volatile__ ("paddh  " #rd ", " #rs ", " #rt )
138

  
139
#define	psubh(rs, rt, rd) \
140
	__asm__ __volatile__ ("psubh  " #rd ", " #rs ", " #rt )
141

  
142
#define	psrah(rt, sa, rd) \
143
	__asm__ __volatile__ ("psrah  " #rd ", " #rt ", %0" : : "i"(sa) )
144

  
145
#define	pmfhl_uw(rd) \
146
	__asm__ __volatile__ ("pmfhl.uw  " #rd)
147

  
148
#define	pextlb(rs, rt, rd) \
149
	__asm__ __volatile__ ("pextlb  " #rd ", " #rs ", " #rt )
119 150

  
120 151
#endif
152

  
libavcodec/ps2/mpegvideo_mmi.c
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

  

Also available in: Unified diff