Mercurial > libavcodec.hg
annotate i386/mpegvideo_mmx.c @ 325:15efd80cf51e libavcodec
mpeg2/mpeg4 dequantizer support (c & mmx)
mpeg1 dequantizer optimizations
author | michaelni |
---|---|
date | Wed, 17 Apr 2002 16:30:31 +0000 |
parents | 8cf5507e6ca5 |
children | 9f6071a87e17 |
rev | line source |
---|---|
8 | 1 /* |
2 * The simplest mpeg encoder (well, it was the simplest!) | |
3 * Copyright (c) 2000,2001 Gerard Lantau. | |
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 * Optimized for ia32 cpus by Nick Kurshev <nickols_k@mail.ru> | |
325 | 20 * h263, mpeg1, mpeg2 dequantizer & draw_edges by Michael Niedermayer <michaelni@gmx.at> |
8 | 21 */ |
22 | |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
23 #include "../dsputil.h" |
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
24 #include "../mpegvideo.h" |
220 | 25 #include "../avcodec.h" |
26 #include "../mangle.h" | |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
27 |
200 | 28 extern UINT8 zigzag_end[64]; |
206 | 29 extern void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w); |
220 | 30 extern int (*dct_quantize)(MpegEncContext *s, DCTELEM *block, int n, int qscale); |
31 | |
32 extern UINT8 zigzag_direct_noperm[64]; | |
33 extern UINT16 inv_zigzag_direct16[64]; | |
34 extern UINT32 inverse[256]; | |
200 | 35 |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
36 #if 0 |
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
37 |
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
38 /* XXX: GL: I don't understand why this function needs optimization |
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
39 (it is called only once per frame!), so I disabled it */ |
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
40 |
8 | 41 void MPV_frame_start(MpegEncContext *s) |
42 { | |
43 if (s->pict_type == B_TYPE) { | |
44 __asm __volatile( | |
45 "movl (%1), %%eax\n\t" | |
46 "movl 4(%1), %%edx\n\t" | |
47 "movl 8(%1), %%ecx\n\t" | |
48 "movl %%eax, (%0)\n\t" | |
49 "movl %%edx, 4(%0)\n\t" | |
50 "movl %%ecx, 8(%0)\n\t" | |
51 : | |
52 :"r"(s->current_picture), "r"(s->aux_picture) | |
53 :"eax","edx","ecx","memory"); | |
54 } else { | |
55 /* swap next and last */ | |
56 __asm __volatile( | |
57 "movl (%1), %%eax\n\t" | |
58 "movl 4(%1), %%edx\n\t" | |
59 "movl 8(%1), %%ecx\n\t" | |
60 "xchgl (%0), %%eax\n\t" | |
61 "xchgl 4(%0), %%edx\n\t" | |
62 "xchgl 8(%0), %%ecx\n\t" | |
63 "movl %%eax, (%1)\n\t" | |
64 "movl %%edx, 4(%1)\n\t" | |
65 "movl %%ecx, 8(%1)\n\t" | |
66 "movl %%eax, (%2)\n\t" | |
67 "movl %%edx, 4(%2)\n\t" | |
68 "movl %%ecx, 8(%2)\n\t" | |
69 : | |
70 :"r"(s->last_picture), "r"(s->next_picture), "r"(s->current_picture) | |
71 :"eax","edx","ecx","memory"); | |
72 } | |
73 } | |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
74 #endif |
8 | 75 |
76 static const unsigned long long int mm_wabs __attribute__ ((aligned(8))) = 0xffffffffffffffffULL; | |
77 static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001ULL; | |
78 | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
79 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
80 static void dct_unquantize_h263_mmx(MpegEncContext *s, |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
81 DCTELEM *block, int n, int qscale) |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
82 { |
200 | 83 int i, level, qmul, qadd, nCoeffs; |
84 | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
85 qmul = s->qscale << 1; |
248
56ee684c48bb
- H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents:
220
diff
changeset
|
86 if (s->h263_aic && s->mb_intra) |
56ee684c48bb
- H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents:
220
diff
changeset
|
87 qadd = 0; |
56ee684c48bb
- H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents:
220
diff
changeset
|
88 else |
56ee684c48bb
- H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents:
220
diff
changeset
|
89 qadd = (s->qscale - 1) | 1; |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
90 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
91 if (s->mb_intra) { |
249
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
92 if (!s->h263_aic) { |
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
93 if (n < 4) |
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
94 block[0] = block[0] * s->y_dc_scale; |
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
95 else |
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
96 block[0] = block[0] * s->c_dc_scale; |
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
97 } |
250
3449316664b5
- Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents:
249
diff
changeset
|
98 for(i=1; i<8; i++) { |
252
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
250
diff
changeset
|
99 level = block[i]; |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
250
diff
changeset
|
100 if (level) { |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
250
diff
changeset
|
101 if (level < 0) { |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
250
diff
changeset
|
102 level = level * qmul - qadd; |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
250
diff
changeset
|
103 } else { |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
250
diff
changeset
|
104 level = level * qmul + qadd; |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
250
diff
changeset
|
105 } |
ddb1a0e94cf4
- Added PSNR feature to libavcodec and ffmpeg. By now just Y PSNR until I'm
pulento
parents:
250
diff
changeset
|
106 block[i] = level; |
250
3449316664b5
- Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents:
249
diff
changeset
|
107 } |
3449316664b5
- Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents:
249
diff
changeset
|
108 } |
249
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
109 nCoeffs=64; |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
110 } else { |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
111 i = 0; |
249
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
112 nCoeffs= zigzag_end[ s->block_last_index[n] ]; |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
113 } |
200 | 114 //printf("%d %d ", qmul, qadd); |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
115 asm volatile( |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
116 "movd %1, %%mm6 \n\t" //qmul |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
117 "packssdw %%mm6, %%mm6 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
118 "packssdw %%mm6, %%mm6 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
119 "movd %2, %%mm5 \n\t" //qadd |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
120 "pxor %%mm7, %%mm7 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
121 "packssdw %%mm5, %%mm5 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
122 "packssdw %%mm5, %%mm5 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
123 "psubw %%mm5, %%mm7 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
124 "pxor %%mm4, %%mm4 \n\t" |
153 | 125 ".balign 16\n\t" |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
126 "1: \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
127 "movq (%0, %3), %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
128 "movq 8(%0, %3), %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
129 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
130 "pmullw %%mm6, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
131 "pmullw %%mm6, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
132 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
133 "movq (%0, %3), %%mm2 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
134 "movq 8(%0, %3), %%mm3 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
135 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
136 "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
137 "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
138 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
139 "pxor %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
140 "pxor %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
141 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
142 "paddw %%mm7, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
143 "paddw %%mm7, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
144 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
145 "pxor %%mm0, %%mm2 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
146 "pxor %%mm1, %%mm3 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
147 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
148 "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
149 "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
150 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
151 "pandn %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
152 "pandn %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
153 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
154 "movq %%mm0, (%0, %3) \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
155 "movq %%mm1, 8(%0, %3) \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
156 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
157 "addl $16, %3 \n\t" |
200 | 158 "js 1b \n\t" |
159 ::"r" (block+nCoeffs), "g"(qmul), "g" (qadd), "r" (2*(i-nCoeffs)) | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
160 : "memory" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
161 ); |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
162 } |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
163 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
164 |
8 | 165 /* |
166 NK: | |
167 Note: looking at PARANOID: | |
168 "enable all paranoid tests for rounding, overflows, etc..." | |
169 | |
170 #ifdef PARANOID | |
171 if (level < -2048 || level > 2047) | |
172 fprintf(stderr, "unquant error %d %d\n", i, level); | |
173 #endif | |
174 We can suppose that result of two multiplications can't be greate of 0xFFFF | |
175 i.e. is 16-bit, so we use here only PMULLW instruction and can avoid | |
176 a complex multiplication. | |
177 ===================================================== | |
178 Full formula for multiplication of 2 integer numbers | |
179 which are represent as high:low words: | |
180 input: value1 = high1:low1 | |
181 value2 = high2:low2 | |
182 output: value3 = value1*value2 | |
183 value3=high3:low3 (on overflow: modulus 2^32 wrap-around) | |
184 this mean that for 0x123456 * 0x123456 correct result is 0x766cb0ce4 | |
185 but this algorithm will compute only 0x66cb0ce4 | |
186 this limited by 16-bit size of operands | |
187 --------------------------------- | |
188 tlow1 = high1*low2 | |
189 tlow2 = high2*low1 | |
190 tlow1 = tlow1 + tlow2 | |
191 high3:low3 = low1*low2 | |
192 high3 += tlow1 | |
193 */ | |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
194 static void dct_unquantize_mpeg1_mmx(MpegEncContext *s, |
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
195 DCTELEM *block, int n, int qscale) |
8 | 196 { |
325 | 197 int nCoeffs; |
8 | 198 const UINT16 *quant_matrix; |
200 | 199 |
200 if(s->alternate_scan) nCoeffs= 64; | |
201 else nCoeffs= nCoeffs= zigzag_end[ s->block_last_index[n] ]; | |
202 | |
8 | 203 if (s->mb_intra) { |
325 | 204 int block0; |
8 | 205 if (n < 4) |
325 | 206 block0 = block[0] * s->y_dc_scale; |
8 | 207 else |
325 | 208 block0 = block[0] * s->c_dc_scale; |
8 | 209 /* XXX: only mpeg1 */ |
210 quant_matrix = s->intra_matrix; | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
211 asm volatile( |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
212 "pcmpeqw %%mm7, %%mm7 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
213 "psrlw $15, %%mm7 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
214 "movd %2, %%mm6 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
215 "packssdw %%mm6, %%mm6 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
216 "packssdw %%mm6, %%mm6 \n\t" |
325 | 217 "movl %3, %%eax \n\t" |
153 | 218 ".balign 16\n\t" |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
219 "1: \n\t" |
325 | 220 "movq (%0, %%eax), %%mm0 \n\t" |
221 "movq 8(%0, %%eax), %%mm1 \n\t" | |
222 "movq (%1, %%eax), %%mm4 \n\t" | |
223 "movq 8(%1, %%eax), %%mm5 \n\t" | |
224 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] | |
225 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] | |
226 "pxor %%mm2, %%mm2 \n\t" | |
227 "pxor %%mm3, %%mm3 \n\t" | |
228 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 | |
229 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 | |
230 "pxor %%mm2, %%mm0 \n\t" | |
231 "pxor %%mm3, %%mm1 \n\t" | |
232 "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) | |
233 "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) | |
234 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q | |
235 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q | |
236 "pxor %%mm4, %%mm4 \n\t" | |
237 "pxor %%mm5, %%mm5 \n\t" // FIXME slow | |
238 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 | |
239 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 | |
240 "psraw $3, %%mm0 \n\t" | |
241 "psraw $3, %%mm1 \n\t" | |
242 "psubw %%mm7, %%mm0 \n\t" | |
243 "psubw %%mm7, %%mm1 \n\t" | |
244 "por %%mm7, %%mm0 \n\t" | |
245 "por %%mm7, %%mm1 \n\t" | |
246 "pxor %%mm2, %%mm0 \n\t" | |
247 "pxor %%mm3, %%mm1 \n\t" | |
248 "psubw %%mm2, %%mm0 \n\t" | |
249 "psubw %%mm3, %%mm1 \n\t" | |
250 "pandn %%mm0, %%mm4 \n\t" | |
251 "pandn %%mm1, %%mm5 \n\t" | |
252 "movq %%mm4, (%0, %%eax) \n\t" | |
253 "movq %%mm5, 8(%0, %%eax) \n\t" | |
254 | |
255 "addl $16, %%eax \n\t" | |
256 "js 1b \n\t" | |
257 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) | |
258 : "%eax", "memory" | |
259 ); | |
260 block[0]= block0; | |
261 | |
262 } else { | |
263 quant_matrix = s->non_intra_matrix; | |
264 asm volatile( | |
265 "pcmpeqw %%mm7, %%mm7 \n\t" | |
266 "psrlw $15, %%mm7 \n\t" | |
267 "movd %2, %%mm6 \n\t" | |
268 "packssdw %%mm6, %%mm6 \n\t" | |
269 "packssdw %%mm6, %%mm6 \n\t" | |
270 "movl %3, %%eax \n\t" | |
271 ".balign 16\n\t" | |
272 "1: \n\t" | |
273 "movq (%0, %%eax), %%mm0 \n\t" | |
274 "movq 8(%0, %%eax), %%mm1 \n\t" | |
275 "movq (%1, %%eax), %%mm4 \n\t" | |
276 "movq 8(%1, %%eax), %%mm5 \n\t" | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
277 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
278 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
279 "pxor %%mm2, %%mm2 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
280 "pxor %%mm3, %%mm3 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
281 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
282 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
283 "pxor %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
284 "pxor %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
285 "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
286 "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
287 "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
288 "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
289 "paddw %%mm7, %%mm0 \n\t" // abs(block[i])*2 + 1 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
290 "paddw %%mm7, %%mm1 \n\t" // abs(block[i])*2 + 1 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
291 "pmullw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
292 "pmullw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
293 "pxor %%mm4, %%mm4 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
294 "pxor %%mm5, %%mm5 \n\t" // FIXME slow |
325 | 295 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 |
296 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
297 "psraw $4, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
298 "psraw $4, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
299 "psubw %%mm7, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
300 "psubw %%mm7, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
301 "por %%mm7, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
302 "por %%mm7, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
303 "pxor %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
304 "pxor %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
305 "psubw %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
306 "psubw %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
307 "pandn %%mm0, %%mm4 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
308 "pandn %%mm1, %%mm5 \n\t" |
325 | 309 "movq %%mm4, (%0, %%eax) \n\t" |
310 "movq %%mm5, 8(%0, %%eax) \n\t" | |
311 | |
312 "addl $16, %%eax \n\t" | |
313 "js 1b \n\t" | |
314 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) | |
315 : "%eax", "memory" | |
316 ); | |
317 } | |
318 } | |
319 | |
320 static void dct_unquantize_mpeg2_mmx(MpegEncContext *s, | |
321 DCTELEM *block, int n, int qscale) | |
322 { | |
323 int nCoeffs; | |
324 const UINT16 *quant_matrix; | |
325 | |
326 if(s->alternate_scan) nCoeffs= 64; | |
327 else nCoeffs= nCoeffs= zigzag_end[ s->block_last_index[n] ]; | |
328 | |
329 if (s->mb_intra) { | |
330 int block0; | |
331 if (n < 4) | |
332 block0 = block[0] * s->y_dc_scale; | |
333 else | |
334 block0 = block[0] * s->c_dc_scale; | |
335 quant_matrix = s->intra_matrix; | |
336 asm volatile( | |
337 "pcmpeqw %%mm7, %%mm7 \n\t" | |
338 "psrlw $15, %%mm7 \n\t" | |
339 "movd %2, %%mm6 \n\t" | |
340 "packssdw %%mm6, %%mm6 \n\t" | |
341 "packssdw %%mm6, %%mm6 \n\t" | |
342 "movl %3, %%eax \n\t" | |
343 ".balign 16\n\t" | |
344 "1: \n\t" | |
345 "movq (%0, %%eax), %%mm0 \n\t" | |
346 "movq 8(%0, %%eax), %%mm1 \n\t" | |
347 "movq (%1, %%eax), %%mm4 \n\t" | |
348 "movq 8(%1, %%eax), %%mm5 \n\t" | |
349 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] | |
350 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] | |
351 "pxor %%mm2, %%mm2 \n\t" | |
352 "pxor %%mm3, %%mm3 \n\t" | |
353 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 | |
354 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 | |
355 "pxor %%mm2, %%mm0 \n\t" | |
356 "pxor %%mm3, %%mm1 \n\t" | |
357 "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) | |
358 "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) | |
359 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q | |
360 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q | |
361 "pxor %%mm4, %%mm4 \n\t" | |
362 "pxor %%mm5, %%mm5 \n\t" // FIXME slow | |
363 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 | |
364 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 | |
365 "psraw $3, %%mm0 \n\t" | |
366 "psraw $3, %%mm1 \n\t" | |
367 "pxor %%mm2, %%mm0 \n\t" | |
368 "pxor %%mm3, %%mm1 \n\t" | |
369 "psubw %%mm2, %%mm0 \n\t" | |
370 "psubw %%mm3, %%mm1 \n\t" | |
371 "pandn %%mm0, %%mm4 \n\t" | |
372 "pandn %%mm1, %%mm5 \n\t" | |
373 "movq %%mm4, (%0, %%eax) \n\t" | |
374 "movq %%mm5, 8(%0, %%eax) \n\t" | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
375 |
325 | 376 "addl $16, %%eax \n\t" |
200 | 377 "js 1b \n\t" |
325 | 378 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) |
379 : "%eax", "memory" | |
380 ); | |
381 block[0]= block0; | |
382 //Note, we dont do mismatch control for intra as errors cannot accumulate | |
383 | |
384 } else { | |
385 quant_matrix = s->non_intra_matrix; | |
386 asm volatile( | |
387 "pcmpeqw %%mm7, %%mm7 \n\t" | |
388 "psrlq $48, %%mm7 \n\t" | |
389 "movd %2, %%mm6 \n\t" | |
390 "packssdw %%mm6, %%mm6 \n\t" | |
391 "packssdw %%mm6, %%mm6 \n\t" | |
392 "movl %3, %%eax \n\t" | |
393 ".balign 16\n\t" | |
394 "1: \n\t" | |
395 "movq (%0, %%eax), %%mm0 \n\t" | |
396 "movq 8(%0, %%eax), %%mm1 \n\t" | |
397 "movq (%1, %%eax), %%mm4 \n\t" | |
398 "movq 8(%1, %%eax), %%mm5 \n\t" | |
399 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] | |
400 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] | |
401 "pxor %%mm2, %%mm2 \n\t" | |
402 "pxor %%mm3, %%mm3 \n\t" | |
403 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 | |
404 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 | |
405 "pxor %%mm2, %%mm0 \n\t" | |
406 "pxor %%mm3, %%mm1 \n\t" | |
407 "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) | |
408 "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) | |
409 "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2 | |
410 "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2 | |
411 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*2*q | |
412 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*2*q | |
413 "paddw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q | |
414 "paddw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q | |
415 "pxor %%mm4, %%mm4 \n\t" | |
416 "pxor %%mm5, %%mm5 \n\t" // FIXME slow | |
417 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 | |
418 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 | |
419 "psrlw $4, %%mm0 \n\t" | |
420 "psrlw $4, %%mm1 \n\t" | |
421 "pxor %%mm2, %%mm0 \n\t" | |
422 "pxor %%mm3, %%mm1 \n\t" | |
423 "psubw %%mm2, %%mm0 \n\t" | |
424 "psubw %%mm3, %%mm1 \n\t" | |
425 "pandn %%mm0, %%mm4 \n\t" | |
426 "pandn %%mm1, %%mm5 \n\t" | |
427 "pxor %%mm4, %%mm7 \n\t" | |
428 "pxor %%mm5, %%mm7 \n\t" | |
429 "movq %%mm4, (%0, %%eax) \n\t" | |
430 "movq %%mm5, 8(%0, %%eax) \n\t" | |
431 | |
432 "addl $16, %%eax \n\t" | |
433 "js 1b \n\t" | |
434 "movd 124(%0, %3), %%mm0 \n\t" | |
435 "movq %%mm7, %%mm6 \n\t" | |
436 "psrlq $32, %%mm7 \n\t" | |
437 "pxor %%mm6, %%mm7 \n\t" | |
438 "movq %%mm7, %%mm6 \n\t" | |
439 "psrlq $16, %%mm7 \n\t" | |
440 "pxor %%mm6, %%mm7 \n\t" | |
441 "pslld $31, %%mm7 \n\t" | |
442 "psrlq $15, %%mm7 \n\t" | |
443 "pxor %%mm7, %%mm0 \n\t" | |
444 "movd %%mm0, 124(%0, %3) \n\t" | |
445 | |
446 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "r" (-2*nCoeffs) | |
447 : "%eax", "memory" | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
448 ); |
8 | 449 } |
450 } | |
451 | |
206 | 452 /* draw the edges of width 'w' of an image of size width, height |
453 this mmx version can only handle w==8 || w==16 */ | |
454 static void draw_edges_mmx(UINT8 *buf, int wrap, int width, int height, int w) | |
455 { | |
456 UINT8 *ptr, *last_line; | |
457 int i; | |
458 | |
459 last_line = buf + (height - 1) * wrap; | |
460 /* left and right */ | |
461 ptr = buf; | |
462 if(w==8) | |
463 { | |
464 asm volatile( | |
465 "1: \n\t" | |
466 "movd (%0), %%mm0 \n\t" | |
467 "punpcklbw %%mm0, %%mm0 \n\t" | |
468 "punpcklwd %%mm0, %%mm0 \n\t" | |
469 "punpckldq %%mm0, %%mm0 \n\t" | |
470 "movq %%mm0, -8(%0) \n\t" | |
471 "movq -8(%0, %2), %%mm1 \n\t" | |
472 "punpckhbw %%mm1, %%mm1 \n\t" | |
473 "punpckhwd %%mm1, %%mm1 \n\t" | |
474 "punpckhdq %%mm1, %%mm1 \n\t" | |
475 "movq %%mm1, (%0, %2) \n\t" | |
476 "addl %1, %0 \n\t" | |
477 "cmpl %3, %0 \n\t" | |
478 " jb 1b \n\t" | |
479 : "+r" (ptr) | |
480 : "r" (wrap), "r" (width), "r" (ptr + wrap*height) | |
481 ); | |
482 } | |
483 else | |
484 { | |
485 asm volatile( | |
486 "1: \n\t" | |
487 "movd (%0), %%mm0 \n\t" | |
488 "punpcklbw %%mm0, %%mm0 \n\t" | |
489 "punpcklwd %%mm0, %%mm0 \n\t" | |
490 "punpckldq %%mm0, %%mm0 \n\t" | |
491 "movq %%mm0, -8(%0) \n\t" | |
492 "movq %%mm0, -16(%0) \n\t" | |
493 "movq -8(%0, %2), %%mm1 \n\t" | |
494 "punpckhbw %%mm1, %%mm1 \n\t" | |
495 "punpckhwd %%mm1, %%mm1 \n\t" | |
496 "punpckhdq %%mm1, %%mm1 \n\t" | |
497 "movq %%mm1, (%0, %2) \n\t" | |
498 "movq %%mm1, 8(%0, %2) \n\t" | |
499 "addl %1, %0 \n\t" | |
500 "cmpl %3, %0 \n\t" | |
501 " jb 1b \n\t" | |
502 : "+r" (ptr) | |
503 : "r" (wrap), "r" (width), "r" (ptr + wrap*height) | |
504 ); | |
505 } | |
506 | |
507 for(i=0;i<w;i+=4) { | |
508 /* top and bottom (and hopefully also the corners) */ | |
509 ptr= buf - (i + 1) * wrap - w; | |
510 asm volatile( | |
511 "1: \n\t" | |
512 "movq (%1, %0), %%mm0 \n\t" | |
513 "movq %%mm0, (%0) \n\t" | |
514 "movq %%mm0, (%0, %2) \n\t" | |
515 "movq %%mm0, (%0, %2, 2) \n\t" | |
516 "movq %%mm0, (%0, %3) \n\t" | |
517 "addl $8, %0 \n\t" | |
518 "cmpl %4, %0 \n\t" | |
519 " jb 1b \n\t" | |
520 : "+r" (ptr) | |
521 : "r" ((int)buf - (int)ptr - w), "r" (-wrap), "r" (-wrap*3), "r" (ptr+width+2*w) | |
522 ); | |
523 ptr= last_line + (i + 1) * wrap - w; | |
524 asm volatile( | |
525 "1: \n\t" | |
526 "movq (%1, %0), %%mm0 \n\t" | |
527 "movq %%mm0, (%0) \n\t" | |
528 "movq %%mm0, (%0, %2) \n\t" | |
529 "movq %%mm0, (%0, %2, 2) \n\t" | |
530 "movq %%mm0, (%0, %3) \n\t" | |
531 "addl $8, %0 \n\t" | |
532 "cmpl %4, %0 \n\t" | |
533 " jb 1b \n\t" | |
534 : "+r" (ptr) | |
535 : "r" ((int)last_line - (int)ptr - w), "r" (wrap), "r" (wrap*3), "r" (ptr+width+2*w) | |
536 ); | |
537 } | |
538 } | |
539 | |
220 | 540 static volatile int esp_temp; |
541 | |
542 void unused_var_warning_killer(){ | |
543 esp_temp++; | |
544 } | |
545 | |
546 #undef HAVE_MMX2 | |
547 #define RENAME(a) a ## _MMX | |
548 #include "mpegvideo_mmx_template.c" | |
549 | |
550 #define HAVE_MMX2 | |
551 #undef RENAME | |
552 #define RENAME(a) a ## _MMX2 | |
553 #include "mpegvideo_mmx_template.c" | |
206 | 554 |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
555 void MPV_common_init_mmx(MpegEncContext *s) |
8 | 556 { |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
557 if (mm_flags & MM_MMX) { |
325 | 558 s->dct_unquantize_h263 = dct_unquantize_h263_mmx; |
559 s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_mmx; | |
560 s->dct_unquantize_mpeg2 = dct_unquantize_mpeg2_mmx; | |
312 | 561 |
206 | 562 draw_edges = draw_edges_mmx; |
220 | 563 |
564 if(mm_flags & MM_MMXEXT){ | |
565 dct_quantize= dct_quantize_MMX2; | |
566 }else{ | |
567 dct_quantize= dct_quantize_MMX; | |
568 } | |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
569 } |
8 | 570 } |