Statistics
| Branch: | Revision:

ffmpeg / libavcodec / i386 / dsputil_mmx.h @ be449fca

History | View | Annotate | Download (4.22 KB)

1 182f56cb Aurelien Jacobs
/*
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 98790382 Stefano Sabatini
#ifndef AVCODEC_I386_DSPUTIL_MMX_H
23
#define AVCODEC_I386_DSPUTIL_MMX_H
24 182f56cb Aurelien Jacobs
25 1b77e877 Aurelien Jacobs
#include <stdint.h>
26 245976da Diego Biurrun
#include "libavcodec/dsputil.h"
27 1b77e877 Aurelien Jacobs
28 fa9b873e Loren Merritt
typedef struct { uint64_t a, b; } xmm_t;
29
30 43de5065 Aurelien Jacobs
extern const uint64_t ff_bone;
31
extern const uint64_t ff_wtwo;
32 182f56cb Aurelien Jacobs
33
extern const uint64_t ff_pdw_80000000[2];
34
35
extern const uint64_t ff_pw_3;
36
extern const uint64_t ff_pw_4;
37 ddf96970 Loren Merritt
extern const xmm_t    ff_pw_5;
38 21383da8 David Conrad
extern const xmm_t    ff_pw_8;
39 182f56cb Aurelien Jacobs
extern const uint64_t ff_pw_15;
40 ddf96970 Loren Merritt
extern const xmm_t    ff_pw_16;
41 182f56cb Aurelien Jacobs
extern const uint64_t ff_pw_20;
42 ce53144b Loren Merritt
extern const xmm_t    ff_pw_28;
43 fa9b873e Loren Merritt
extern const xmm_t    ff_pw_32;
44 182f56cb Aurelien Jacobs
extern const uint64_t ff_pw_42;
45
extern const uint64_t ff_pw_64;
46
extern const uint64_t ff_pw_96;
47
extern const uint64_t ff_pw_128;
48 97d1d009 Aurelien Jacobs
extern const uint64_t ff_pw_255;
49 182f56cb Aurelien Jacobs
50
extern const uint64_t ff_pb_1;
51
extern const uint64_t ff_pb_3;
52
extern const uint64_t ff_pb_7;
53
extern const uint64_t ff_pb_3F;
54
extern const uint64_t ff_pb_A1;
55
extern const uint64_t ff_pb_FC;
56
57
extern const double ff_pd_1[2];
58
extern const double ff_pd_2[2];
59
60 1835cda6 Victor Pollex
#define LOAD4(stride,in,a,b,c,d)\
61
    "movq 0*"#stride"+"#in", "#a"\n\t"\
62
    "movq 1*"#stride"+"#in", "#b"\n\t"\
63
    "movq 2*"#stride"+"#in", "#c"\n\t"\
64
    "movq 3*"#stride"+"#in", "#d"\n\t"
65
66
#define STORE4(stride,out,a,b,c,d)\
67
    "movq "#a", 0*"#stride"+"#out"\n\t"\
68
    "movq "#b", 1*"#stride"+"#out"\n\t"\
69
    "movq "#c", 2*"#stride"+"#out"\n\t"\
70
    "movq "#d", 3*"#stride"+"#out"\n\t"
71
72 28748a91 Christophe Gisquet
/* in/out: mma=mma+mmb, mmb=mmb-mma */
73
#define SUMSUB_BA( a, b ) \
74
    "paddw "#b", "#a" \n\t"\
75
    "paddw "#b", "#b" \n\t"\
76
    "psubw "#a", "#b" \n\t"
77
78
#define SBUTTERFLY(a,b,t,n,m)\
79
    "mov" #m " " #a ", " #t "         \n\t" /* abcd */\
80
    "punpckl" #n " " #b ", " #a "     \n\t" /* aebf */\
81
    "punpckh" #n " " #b ", " #t "     \n\t" /* cgdh */\
82
83
#define TRANSPOSE4(a,b,c,d,t)\
84
    SBUTTERFLY(a,b,t,wd,q) /* a=aebf t=cgdh */\
85
    SBUTTERFLY(c,d,b,wd,q) /* c=imjn b=kolp */\
86
    SBUTTERFLY(a,c,d,dq,q) /* a=aeim d=bfjn */\
87
    SBUTTERFLY(t,b,c,dq,q) /* t=cgko c=dhlp */
88
89
#ifdef ARCH_X86_64
90
// permutes 01234567 -> 05736421
91
#define TRANSPOSE8(a,b,c,d,e,f,g,h,t)\
92
    SBUTTERFLY(a,b,%%xmm8,wd,dqa)\
93
    SBUTTERFLY(c,d,b,wd,dqa)\
94
    SBUTTERFLY(e,f,d,wd,dqa)\
95
    SBUTTERFLY(g,h,f,wd,dqa)\
96
    SBUTTERFLY(a,c,h,dq,dqa)\
97
    SBUTTERFLY(%%xmm8,b,c,dq,dqa)\
98
    SBUTTERFLY(e,g,b,dq,dqa)\
99
    SBUTTERFLY(d,f,g,dq,dqa)\
100
    SBUTTERFLY(a,e,f,qdq,dqa)\
101
    SBUTTERFLY(%%xmm8,d,e,qdq,dqa)\
102
    SBUTTERFLY(h,b,d,qdq,dqa)\
103
    SBUTTERFLY(c,g,b,qdq,dqa)\
104
    "movdqa %%xmm8, "#g"              \n\t"
105
#else
106
#define TRANSPOSE8(a,b,c,d,e,f,g,h,t)\
107
    "movdqa "#h", "#t"                \n\t"\
108
    SBUTTERFLY(a,b,h,wd,dqa)\
109
    "movdqa "#h", 16"#t"              \n\t"\
110
    "movdqa "#t", "#h"                \n\t"\
111
    SBUTTERFLY(c,d,b,wd,dqa)\
112
    SBUTTERFLY(e,f,d,wd,dqa)\
113
    SBUTTERFLY(g,h,f,wd,dqa)\
114
    SBUTTERFLY(a,c,h,dq,dqa)\
115
    "movdqa "#h", "#t"                \n\t"\
116
    "movdqa 16"#t", "#h"              \n\t"\
117
    SBUTTERFLY(h,b,c,dq,dqa)\
118
    SBUTTERFLY(e,g,b,dq,dqa)\
119
    SBUTTERFLY(d,f,g,dq,dqa)\
120
    SBUTTERFLY(a,e,f,qdq,dqa)\
121
    SBUTTERFLY(h,d,e,qdq,dqa)\
122
    "movdqa "#h", 16"#t"              \n\t"\
123
    "movdqa "#t", "#h"                \n\t"\
124
    SBUTTERFLY(h,b,d,qdq,dqa)\
125
    SBUTTERFLY(c,g,b,qdq,dqa)\
126
    "movdqa 16"#t", "#g"              \n\t"
127
#endif
128
129 97d1d009 Aurelien Jacobs
#define MOVQ_WONE(regd) \
130 be449fca Diego Pettenò
    __asm__ volatile ( \
131 97d1d009 Aurelien Jacobs
    "pcmpeqd %%" #regd ", %%" #regd " \n\t" \
132
    "psrlw $15, %%" #regd ::)
133
134
void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx);
135
136 98790382 Stefano Sabatini
#endif /* AVCODEC_I386_DSPUTIL_MMX_H */