Statistics
| Branch: | Revision:

ffmpeg / libavcodec / i386 / dsputil_mmx.h @ fa9b873e

History | View | Annotate | Download (3.53 KB)

1
/*
2
 * MMX optimized DSP utils
3
 * Copyright (c) 2007  Aurelien Jacobs <aurel@gnuage.org>
4
 *
5
 * This file is part of FFmpeg.
6
 *
7
 * FFmpeg is free software; you can redistribute it and/or
8
 * modify it under the terms of the GNU Lesser General Public
9
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 * Lesser General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
 */
21

    
22
#ifndef FFMPEG_DSPUTIL_MMX_H
23
#define FFMPEG_DSPUTIL_MMX_H
24

    
25
#include <stdint.h>
26

    
27
typedef struct { uint64_t a, b; } xmm_t;
28

    
29
extern const uint64_t ff_bone;
30
extern const uint64_t ff_wtwo;
31

    
32
extern const uint64_t ff_pdw_80000000[2];
33

    
34
extern const uint64_t ff_pw_3;
35
extern const uint64_t ff_pw_4;
36
extern const uint64_t ff_pw_5;
37
extern const uint64_t ff_pw_8;
38
extern const uint64_t ff_pw_15;
39
extern const uint64_t ff_pw_16;
40
extern const uint64_t ff_pw_20;
41
extern const xmm_t    ff_pw_32;
42
extern const uint64_t ff_pw_42;
43
extern const uint64_t ff_pw_64;
44
extern const uint64_t ff_pw_96;
45
extern const uint64_t ff_pw_128;
46

    
47
extern const uint64_t ff_pb_1;
48
extern const uint64_t ff_pb_3;
49
extern const uint64_t ff_pb_7;
50
extern const uint64_t ff_pb_3F;
51
extern const uint64_t ff_pb_A1;
52
extern const uint64_t ff_pb_FC;
53

    
54
extern const double ff_pd_1[2];
55
extern const double ff_pd_2[2];
56

    
57
/* in/out: mma=mma+mmb, mmb=mmb-mma */
58
#define SUMSUB_BA( a, b ) \
59
    "paddw "#b", "#a" \n\t"\
60
    "paddw "#b", "#b" \n\t"\
61
    "psubw "#a", "#b" \n\t"
62

    
63
#define SBUTTERFLY(a,b,t,n,m)\
64
    "mov" #m " " #a ", " #t "         \n\t" /* abcd */\
65
    "punpckl" #n " " #b ", " #a "     \n\t" /* aebf */\
66
    "punpckh" #n " " #b ", " #t "     \n\t" /* cgdh */\
67

    
68
#define TRANSPOSE4(a,b,c,d,t)\
69
    SBUTTERFLY(a,b,t,wd,q) /* a=aebf t=cgdh */\
70
    SBUTTERFLY(c,d,b,wd,q) /* c=imjn b=kolp */\
71
    SBUTTERFLY(a,c,d,dq,q) /* a=aeim d=bfjn */\
72
    SBUTTERFLY(t,b,c,dq,q) /* t=cgko c=dhlp */
73

    
74
#ifdef ARCH_X86_64
75
// permutes 01234567 -> 05736421
76
#define TRANSPOSE8(a,b,c,d,e,f,g,h,t)\
77
    SBUTTERFLY(a,b,%%xmm8,wd,dqa)\
78
    SBUTTERFLY(c,d,b,wd,dqa)\
79
    SBUTTERFLY(e,f,d,wd,dqa)\
80
    SBUTTERFLY(g,h,f,wd,dqa)\
81
    SBUTTERFLY(a,c,h,dq,dqa)\
82
    SBUTTERFLY(%%xmm8,b,c,dq,dqa)\
83
    SBUTTERFLY(e,g,b,dq,dqa)\
84
    SBUTTERFLY(d,f,g,dq,dqa)\
85
    SBUTTERFLY(a,e,f,qdq,dqa)\
86
    SBUTTERFLY(%%xmm8,d,e,qdq,dqa)\
87
    SBUTTERFLY(h,b,d,qdq,dqa)\
88
    SBUTTERFLY(c,g,b,qdq,dqa)\
89
    "movdqa %%xmm8, "#g"              \n\t"
90
#else
91
#define TRANSPOSE8(a,b,c,d,e,f,g,h,t)\
92
    "movdqa "#h", "#t"                \n\t"\
93
    SBUTTERFLY(a,b,h,wd,dqa)\
94
    "movdqa "#h", 16"#t"              \n\t"\
95
    "movdqa "#t", "#h"                \n\t"\
96
    SBUTTERFLY(c,d,b,wd,dqa)\
97
    SBUTTERFLY(e,f,d,wd,dqa)\
98
    SBUTTERFLY(g,h,f,wd,dqa)\
99
    SBUTTERFLY(a,c,h,dq,dqa)\
100
    "movdqa "#h", "#t"                \n\t"\
101
    "movdqa 16"#t", "#h"              \n\t"\
102
    SBUTTERFLY(h,b,c,dq,dqa)\
103
    SBUTTERFLY(e,g,b,dq,dqa)\
104
    SBUTTERFLY(d,f,g,dq,dqa)\
105
    SBUTTERFLY(a,e,f,qdq,dqa)\
106
    SBUTTERFLY(h,d,e,qdq,dqa)\
107
    "movdqa "#h", 16"#t"              \n\t"\
108
    "movdqa "#t", "#h"                \n\t"\
109
    SBUTTERFLY(h,b,d,qdq,dqa)\
110
    SBUTTERFLY(c,g,b,qdq,dqa)\
111
    "movdqa 16"#t", "#g"              \n\t"
112
#endif
113

    
114
#endif /* FFMPEG_DSPUTIL_MMX_H */