Statistics
| Branch: | Revision:

ffmpeg / libavcodec / alpha / pixops.h @ 1e98dffb

History | View | Annotate | Download (3.42 KB)

1
/*
2
 * Alpha optimized DSP utils
3
 * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 */
19

    
20
/* This file is intended to be #included with proper definitions of
21
 * PIXOPNAME, BTYPE, AVG2, AVG4 and STORE.  */
22

    
23
static void PIXOPNAME(_pixels_axp)(BTYPE *block, const UINT8 *pixels,
24
                                   int line_size, int h)
25
{
26
    if ((size_t) pixels & 0x7) {
27
        do {
28
            STORE(uldq(pixels), block);
29
            pixels += line_size;
30
            block  += line_size;
31
        } while (--h);
32
    } else {
33
        do {
34
            STORE(ldq(pixels), block);
35
            pixels += line_size;
36
            block  += line_size;
37
        } while (--h);
38
    }
39
}
40

    
41
static void PIXOPNAME(_pixels_x2_axp)(BTYPE *block, const UINT8 *pixels,
42
                                      int line_size, int h)
43
{
44
    if ((size_t) pixels & 0x7) {
45
        do {
46
            UINT64 pix1, pix2;
47

    
48
            pix1 = uldq(pixels);
49
            pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56);
50
            STORE(AVG2(pix1, pix2), block);
51
            pixels += line_size;
52
            block += line_size;
53
        } while (--h);
54
    } else {
55
        do {
56
            UINT64 pix1, pix2;
57

    
58
            pix1 = ldq(pixels);
59
            pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56);
60
            STORE(AVG2(pix1, pix2), block);
61
            pixels += line_size;
62
            block += line_size;
63
        } while (--h);
64
    }
65
}
66

    
67
static void PIXOPNAME(_pixels_y2_axp)(BTYPE *block, const UINT8 *pixels,
68
                                      int line_size, int h)
69
{
70
    if ((size_t) pixels & 0x7) {
71
        UINT64 pix = uldq(pixels);
72
        do {
73
            UINT64 next_pix;
74

    
75
            pixels += line_size;
76
            next_pix = uldq(pixels);
77
            STORE(AVG2(pix, next_pix), block);
78
            block += line_size;
79
            pix = next_pix;
80
        } while (--h);
81
    } else {
82
        UINT64 pix = ldq(pixels);
83
        do {
84
            UINT64 next_pix;
85

    
86
            pixels += line_size;
87
            next_pix = ldq(pixels);
88
            STORE(AVG2(pix, next_pix), block);
89
            block += line_size;
90
            pix = next_pix;
91
        } while (--h);
92
    }
93
}
94

    
95
/* This could be further sped up by recycling AVG4 intermediate
96
  results from the previous loop pass.  */
97
static void PIXOPNAME(_pixels_xy2_axp)(BTYPE *block, const UINT8 *pixels,
98
                                       int line_size, int h)
99
{
100
    if ((size_t) pixels & 0x7) {
101
        UINT64 pix1 = uldq(pixels);
102
        UINT64 pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56);
103

    
104
        do {
105
            UINT64 next_pix1, next_pix2;
106

    
107
            pixels += line_size;
108
            next_pix1 = uldq(pixels);
109
            next_pix2 = next_pix1 >> 8 | ((UINT64) pixels[8] << 56);
110

    
111
            STORE(AVG4(pix1, pix2, next_pix1, next_pix2), block);
112

    
113
            block += line_size;
114
            pix1 = next_pix1;
115
            pix2 = next_pix2;
116
        } while (--h);
117
    } else {
118
        UINT64 pix1 = ldq(pixels);
119
        UINT64 pix2 = pix1 >> 8 | ((UINT64) pixels[8] << 56);
120

    
121
        do {
122
            UINT64 next_pix1, next_pix2;
123

    
124
            pixels += line_size;
125
            next_pix1 = ldq(pixels);
126
            next_pix2 = next_pix1 >> 8 | ((UINT64) pixels[8] << 56);
127

    
128
            STORE(AVG4(pix1, pix2, next_pix1, next_pix2), block);
129

    
130
            block += line_size;
131
            pix1 = next_pix1;
132
            pix2 = next_pix2;
133
        } while (--h);
134
    }
135
}