Revision 5917d17c libavcodec/ps2/dsputil_mmi.c

View differences:

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

  

Also available in: Unified diff