Mercurial > libavcodec.hg
annotate i386/dsputil_mmx.h @ 8261:5f48c58bfd51 libavcodec
Fix an overflow in the predictor.
fixes issue 636
Patch by Jai.
author | benoit |
---|---|
date | Fri, 05 Dec 2008 07:58:31 +0000 |
parents | 0839f325edb5 |
children | 08b0f63a91c5 |
rev | line source |
---|---|
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
1 /* |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
2 * MMX optimized DSP utils |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
3 * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org> |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
4 * |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
6 * |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
11 * |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
16 * |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
20 */ |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
21 |
7760 | 22 #ifndef AVCODEC_I386_DSPUTIL_MMX_H |
23 #define AVCODEC_I386_DSPUTIL_MMX_H | |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
24 |
6013
af8951e74098
add required include to make this file self-contained
aurel
parents:
5952
diff
changeset
|
25 #include <stdint.h> |
6763 | 26 #include "libavcodec/dsputil.h" |
6013
af8951e74098
add required include to make this file self-contained
aurel
parents:
5952
diff
changeset
|
27 |
6329
5969caa9190d
clean up an ugliness introduced in r11826. this syntax will require fewer changes when adding future sse2 code.
lorenm
parents:
6320
diff
changeset
|
28 typedef struct { uint64_t a, b; } xmm_t; |
5969caa9190d
clean up an ugliness introduced in r11826. this syntax will require fewer changes when adding future sse2 code.
lorenm
parents:
6320
diff
changeset
|
29 |
5947 | 30 extern const uint64_t ff_bone; |
31 extern const uint64_t ff_wtwo; | |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
32 |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
33 extern const uint64_t ff_pdw_80000000[2]; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
34 |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
35 extern const uint64_t ff_pw_3; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
36 extern const uint64_t ff_pw_4; |
6331 | 37 extern const xmm_t ff_pw_5; |
7741 | 38 extern const xmm_t ff_pw_8; |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
39 extern const uint64_t ff_pw_15; |
6331 | 40 extern const xmm_t ff_pw_16; |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
41 extern const uint64_t ff_pw_20; |
6557 | 42 extern const xmm_t ff_pw_28; |
6329
5969caa9190d
clean up an ugliness introduced in r11826. this syntax will require fewer changes when adding future sse2 code.
lorenm
parents:
6320
diff
changeset
|
43 extern const xmm_t ff_pw_32; |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
44 extern const uint64_t ff_pw_42; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
45 extern const uint64_t ff_pw_64; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
46 extern const uint64_t ff_pw_96; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
47 extern const uint64_t ff_pw_128; |
6403
9a736918fd90
split encoding part of dsputil_mmx into its own file
aurel
parents:
6331
diff
changeset
|
48 extern const uint64_t ff_pw_255; |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
49 |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
50 extern const uint64_t ff_pb_1; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
51 extern const uint64_t ff_pb_3; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
52 extern const uint64_t ff_pb_7; |
8032 | 53 extern const uint64_t ff_pb_1F; |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
54 extern const uint64_t ff_pb_3F; |
8032 | 55 extern const uint64_t ff_pb_81; |
5946
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
56 extern const uint64_t ff_pb_A1; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
57 extern const uint64_t ff_pb_FC; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
58 |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
59 extern const double ff_pd_1[2]; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
60 extern const double ff_pd_2[2]; |
55251379b5b1
make ff_p* vars extern so that they can be used in various *_mmx.c files
aurel
parents:
diff
changeset
|
61 |
7220 | 62 #define LOAD4(stride,in,a,b,c,d)\ |
63 "movq 0*"#stride"+"#in", "#a"\n\t"\ | |
64 "movq 1*"#stride"+"#in", "#b"\n\t"\ | |
65 "movq 2*"#stride"+"#in", "#c"\n\t"\ | |
66 "movq 3*"#stride"+"#in", "#d"\n\t" | |
67 | |
68 #define STORE4(stride,out,a,b,c,d)\ | |
69 "movq "#a", 0*"#stride"+"#out"\n\t"\ | |
70 "movq "#b", 1*"#stride"+"#out"\n\t"\ | |
71 "movq "#c", 2*"#stride"+"#out"\n\t"\ | |
72 "movq "#d", 3*"#stride"+"#out"\n\t" | |
73 | |
6135
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
74 /* in/out: mma=mma+mmb, mmb=mmb-mma */ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
75 #define SUMSUB_BA( a, b ) \ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
76 "paddw "#b", "#a" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
77 "paddw "#b", "#b" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
78 "psubw "#a", "#b" \n\t" |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
79 |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
80 #define SBUTTERFLY(a,b,t,n,m)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
81 "mov" #m " " #a ", " #t " \n\t" /* abcd */\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
82 "punpckl" #n " " #b ", " #a " \n\t" /* aebf */\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
83 "punpckh" #n " " #b ", " #t " \n\t" /* cgdh */\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
84 |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
85 #define TRANSPOSE4(a,b,c,d,t)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
86 SBUTTERFLY(a,b,t,wd,q) /* a=aebf t=cgdh */\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
87 SBUTTERFLY(c,d,b,wd,q) /* c=imjn b=kolp */\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
88 SBUTTERFLY(a,c,d,dq,q) /* a=aeim d=bfjn */\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
89 SBUTTERFLY(t,b,c,dq,q) /* t=cgko c=dhlp */ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
90 |
8032 | 91 // e,f,g,h can be memory |
92 // out: a,d,t,c | |
93 #define TRANSPOSE8x4(a,b,c,d,e,f,g,h,t)\ | |
94 "punpcklbw " #e ", " #a " \n\t" /* a0 e0 a1 e1 a2 e2 a3 e3 */\ | |
95 "punpcklbw " #f ", " #b " \n\t" /* b0 f0 b1 f1 b2 f2 b3 f3 */\ | |
96 "punpcklbw " #g ", " #c " \n\t" /* c0 g0 c1 g1 c2 g2 d3 g3 */\ | |
97 "punpcklbw " #h ", " #d " \n\t" /* d0 h0 d1 h1 d2 h2 d3 h3 */\ | |
98 SBUTTERFLY(a, b, t, bw, q) /* a= a0 b0 e0 f0 a1 b1 e1 f1 */\ | |
99 /* t= a2 b2 e2 f2 a3 b3 e3 f3 */\ | |
100 SBUTTERFLY(c, d, b, bw, q) /* c= c0 d0 g0 h0 c1 d1 g1 h1 */\ | |
101 /* b= c2 d2 g2 h2 c3 d3 g3 h3 */\ | |
102 SBUTTERFLY(a, c, d, wd, q) /* a= a0 b0 c0 d0 e0 f0 g0 h0 */\ | |
103 /* d= a1 b1 c1 d1 e1 f1 g1 h1 */\ | |
104 SBUTTERFLY(t, b, c, wd, q) /* t= a2 b2 c2 d2 e2 f2 g2 h2 */\ | |
105 /* c= a3 b3 c3 d3 e3 f3 g3 h3 */ | |
106 | |
6135
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
107 #ifdef ARCH_X86_64 |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
108 // permutes 01234567 -> 05736421 |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
109 #define TRANSPOSE8(a,b,c,d,e,f,g,h,t)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
110 SBUTTERFLY(a,b,%%xmm8,wd,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
111 SBUTTERFLY(c,d,b,wd,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
112 SBUTTERFLY(e,f,d,wd,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
113 SBUTTERFLY(g,h,f,wd,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
114 SBUTTERFLY(a,c,h,dq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
115 SBUTTERFLY(%%xmm8,b,c,dq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
116 SBUTTERFLY(e,g,b,dq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
117 SBUTTERFLY(d,f,g,dq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
118 SBUTTERFLY(a,e,f,qdq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
119 SBUTTERFLY(%%xmm8,d,e,qdq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
120 SBUTTERFLY(h,b,d,qdq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
121 SBUTTERFLY(c,g,b,qdq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
122 "movdqa %%xmm8, "#g" \n\t" |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
123 #else |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
124 #define TRANSPOSE8(a,b,c,d,e,f,g,h,t)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
125 "movdqa "#h", "#t" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
126 SBUTTERFLY(a,b,h,wd,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
127 "movdqa "#h", 16"#t" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
128 "movdqa "#t", "#h" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
129 SBUTTERFLY(c,d,b,wd,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
130 SBUTTERFLY(e,f,d,wd,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
131 SBUTTERFLY(g,h,f,wd,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
132 SBUTTERFLY(a,c,h,dq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
133 "movdqa "#h", "#t" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
134 "movdqa 16"#t", "#h" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
135 SBUTTERFLY(h,b,c,dq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
136 SBUTTERFLY(e,g,b,dq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
137 SBUTTERFLY(d,f,g,dq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
138 SBUTTERFLY(a,e,f,qdq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
139 SBUTTERFLY(h,d,e,qdq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
140 "movdqa "#h", 16"#t" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
141 "movdqa "#t", "#h" \n\t"\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
142 SBUTTERFLY(h,b,d,qdq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
143 SBUTTERFLY(c,g,b,qdq,dqa)\ |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
144 "movdqa 16"#t", "#g" \n\t" |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
145 #endif |
1c67967d893b
Factorize some duplicated code from CAVS and H.264 into a common file.
diego
parents:
6013
diff
changeset
|
146 |
6403
9a736918fd90
split encoding part of dsputil_mmx into its own file
aurel
parents:
6331
diff
changeset
|
147 #define MOVQ_WONE(regd) \ |
8031 | 148 __asm__ volatile ( \ |
6403
9a736918fd90
split encoding part of dsputil_mmx into its own file
aurel
parents:
6331
diff
changeset
|
149 "pcmpeqd %%" #regd ", %%" #regd " \n\t" \ |
9a736918fd90
split encoding part of dsputil_mmx into its own file
aurel
parents:
6331
diff
changeset
|
150 "psrlw $15, %%" #regd ::) |
9a736918fd90
split encoding part of dsputil_mmx into its own file
aurel
parents:
6331
diff
changeset
|
151 |
9a736918fd90
split encoding part of dsputil_mmx into its own file
aurel
parents:
6331
diff
changeset
|
152 void dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx); |
9a736918fd90
split encoding part of dsputil_mmx into its own file
aurel
parents:
6331
diff
changeset
|
153 |
7760 | 154 #endif /* AVCODEC_I386_DSPUTIL_MMX_H */ |