Mercurial > libavcodec.hg
annotate i386/mpegvideo_mmx.c @ 895:1a5926aeed5f libavcodec
apiexample doesnt send complete frames to the codec
author | michaelni |
---|---|
date | Tue, 26 Nov 2002 16:16:04 +0000 |
parents | df26acd21c84 |
children | 693a0797398f |
rev | line source |
---|---|
8 | 1 /* |
2 * The simplest mpeg encoder (well, it was the simplest!) | |
429 | 3 * Copyright (c) 2000,2001 Fabrice Bellard. |
8 | 4 * |
429 | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
8 | 9 * |
429 | 10 * This library is distributed in the hope that it will be useful, |
8 | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Lesser General Public License for more details. | |
8 | 14 * |
429 | 15 * You should have received a copy of the GNU Lesser General Public |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
8 | 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" |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
26 #include "../simple_idct.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 |
220 | 28 extern UINT8 zigzag_direct_noperm[64]; |
29 extern UINT16 inv_zigzag_direct16[64]; | |
30 extern UINT32 inverse[256]; | |
200 | 31 |
8 | 32 static const unsigned long long int mm_wabs __attribute__ ((aligned(8))) = 0xffffffffffffffffULL; |
33 static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001ULL; | |
34 | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
35 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
36 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
|
37 DCTELEM *block, int n, int qscale) |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
38 { |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
39 int level, qmul, qadd, nCoeffs; |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
40 |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
41 qmul = qscale << 1; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
42 qadd = (qscale - 1) | 1; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
43 |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
44 assert(s->block_last_index[n]>=0); |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
45 |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
46 if (s->mb_intra) { |
249
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
47 if (!s->h263_aic) { |
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
48 if (n < 4) |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
49 level = block[0] * s->y_dc_scale; |
249
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
50 else |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
51 level = block[0] * s->c_dc_scale; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
52 }else{ |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
53 qadd = 0; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
54 level= block[0]; |
249
42a0b7b16738
- Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents:
248
diff
changeset
|
55 } |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
56 nCoeffs=63; |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
57 } else { |
855
df26acd21c84
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
768
diff
changeset
|
58 nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; |
df26acd21c84
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
768
diff
changeset
|
59 level = 0;/* keep gcc quiet */ |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
60 } |
200 | 61 //printf("%d %d ", qmul, qadd); |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
62 asm volatile( |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
63 "movd %1, %%mm6 \n\t" //qmul |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
64 "packssdw %%mm6, %%mm6 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
65 "packssdw %%mm6, %%mm6 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
66 "movd %2, %%mm5 \n\t" //qadd |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
67 "pxor %%mm7, %%mm7 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
68 "packssdw %%mm5, %%mm5 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
69 "packssdw %%mm5, %%mm5 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
70 "psubw %%mm5, %%mm7 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
71 "pxor %%mm4, %%mm4 \n\t" |
153 | 72 ".balign 16\n\t" |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
73 "1: \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
74 "movq (%0, %3), %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
75 "movq 8(%0, %3), %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
76 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
77 "pmullw %%mm6, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
78 "pmullw %%mm6, %%mm1 \n\t" |
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 "movq (%0, %3), %%mm2 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
81 "movq 8(%0, %3), %%mm3 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
82 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
83 "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
|
84 "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
|
85 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
86 "pxor %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
87 "pxor %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
88 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
89 "paddw %%mm7, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
90 "paddw %%mm7, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
91 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
92 "pxor %%mm0, %%mm2 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
93 "pxor %%mm1, %%mm3 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
94 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
95 "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
|
96 "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
|
97 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
98 "pandn %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
99 "pandn %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
100 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
101 "movq %%mm0, (%0, %3) \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
102 "movq %%mm1, 8(%0, %3) \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
103 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
104 "addl $16, %3 \n\t" |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
105 "jng 1b \n\t" |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
106 ::"r" (block+nCoeffs), "g"(qmul), "g" (qadd), "r" (2*(-nCoeffs)) |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
107 : "memory" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
108 ); |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
109 if(s->mb_intra) |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
110 block[0]= level; |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
111 } |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
112 |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
113 |
8 | 114 /* |
115 NK: | |
116 Note: looking at PARANOID: | |
117 "enable all paranoid tests for rounding, overflows, etc..." | |
118 | |
119 #ifdef PARANOID | |
120 if (level < -2048 || level > 2047) | |
121 fprintf(stderr, "unquant error %d %d\n", i, level); | |
122 #endif | |
123 We can suppose that result of two multiplications can't be greate of 0xFFFF | |
124 i.e. is 16-bit, so we use here only PMULLW instruction and can avoid | |
125 a complex multiplication. | |
126 ===================================================== | |
127 Full formula for multiplication of 2 integer numbers | |
128 which are represent as high:low words: | |
129 input: value1 = high1:low1 | |
130 value2 = high2:low2 | |
131 output: value3 = value1*value2 | |
132 value3=high3:low3 (on overflow: modulus 2^32 wrap-around) | |
133 this mean that for 0x123456 * 0x123456 correct result is 0x766cb0ce4 | |
134 but this algorithm will compute only 0x66cb0ce4 | |
135 this limited by 16-bit size of operands | |
136 --------------------------------- | |
137 tlow1 = high1*low2 | |
138 tlow2 = high2*low1 | |
139 tlow1 = tlow1 + tlow2 | |
140 high3:low3 = low1*low2 | |
141 high3 += tlow1 | |
142 */ | |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
143 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
|
144 DCTELEM *block, int n, int qscale) |
8 | 145 { |
325 | 146 int nCoeffs; |
8 | 147 const UINT16 *quant_matrix; |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
148 |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
149 assert(s->block_last_index[n]>=0); |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
150 |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
151 nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1; |
200 | 152 |
8 | 153 if (s->mb_intra) { |
325 | 154 int block0; |
8 | 155 if (n < 4) |
325 | 156 block0 = block[0] * s->y_dc_scale; |
8 | 157 else |
325 | 158 block0 = block[0] * s->c_dc_scale; |
8 | 159 /* XXX: only mpeg1 */ |
160 quant_matrix = s->intra_matrix; | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
161 asm volatile( |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
162 "pcmpeqw %%mm7, %%mm7 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
163 "psrlw $15, %%mm7 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
164 "movd %2, %%mm6 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
165 "packssdw %%mm6, %%mm6 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
166 "packssdw %%mm6, %%mm6 \n\t" |
325 | 167 "movl %3, %%eax \n\t" |
153 | 168 ".balign 16\n\t" |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
169 "1: \n\t" |
325 | 170 "movq (%0, %%eax), %%mm0 \n\t" |
171 "movq 8(%0, %%eax), %%mm1 \n\t" | |
172 "movq (%1, %%eax), %%mm4 \n\t" | |
173 "movq 8(%1, %%eax), %%mm5 \n\t" | |
174 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] | |
175 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] | |
176 "pxor %%mm2, %%mm2 \n\t" | |
177 "pxor %%mm3, %%mm3 \n\t" | |
178 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 | |
179 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 | |
180 "pxor %%mm2, %%mm0 \n\t" | |
181 "pxor %%mm3, %%mm1 \n\t" | |
182 "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) | |
183 "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) | |
184 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q | |
185 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q | |
186 "pxor %%mm4, %%mm4 \n\t" | |
187 "pxor %%mm5, %%mm5 \n\t" // FIXME slow | |
188 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 | |
189 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 | |
190 "psraw $3, %%mm0 \n\t" | |
191 "psraw $3, %%mm1 \n\t" | |
192 "psubw %%mm7, %%mm0 \n\t" | |
193 "psubw %%mm7, %%mm1 \n\t" | |
194 "por %%mm7, %%mm0 \n\t" | |
195 "por %%mm7, %%mm1 \n\t" | |
196 "pxor %%mm2, %%mm0 \n\t" | |
197 "pxor %%mm3, %%mm1 \n\t" | |
198 "psubw %%mm2, %%mm0 \n\t" | |
199 "psubw %%mm3, %%mm1 \n\t" | |
200 "pandn %%mm0, %%mm4 \n\t" | |
201 "pandn %%mm1, %%mm5 \n\t" | |
202 "movq %%mm4, (%0, %%eax) \n\t" | |
203 "movq %%mm5, 8(%0, %%eax) \n\t" | |
204 | |
205 "addl $16, %%eax \n\t" | |
206 "js 1b \n\t" | |
207 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) | |
208 : "%eax", "memory" | |
209 ); | |
210 block[0]= block0; | |
211 | |
212 } else { | |
344 | 213 quant_matrix = s->inter_matrix; |
325 | 214 asm volatile( |
215 "pcmpeqw %%mm7, %%mm7 \n\t" | |
216 "psrlw $15, %%mm7 \n\t" | |
217 "movd %2, %%mm6 \n\t" | |
218 "packssdw %%mm6, %%mm6 \n\t" | |
219 "packssdw %%mm6, %%mm6 \n\t" | |
220 "movl %3, %%eax \n\t" | |
221 ".balign 16\n\t" | |
222 "1: \n\t" | |
223 "movq (%0, %%eax), %%mm0 \n\t" | |
224 "movq 8(%0, %%eax), %%mm1 \n\t" | |
225 "movq (%1, %%eax), %%mm4 \n\t" | |
226 "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
|
227 "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
|
228 "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
|
229 "pxor %%mm2, %%mm2 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
230 "pxor %%mm3, %%mm3 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
231 "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
|
232 "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
|
233 "pxor %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
234 "pxor %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
235 "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
|
236 "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
|
237 "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
|
238 "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
|
239 "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
|
240 "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
|
241 "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
|
242 "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
|
243 "pxor %%mm4, %%mm4 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
244 "pxor %%mm5, %%mm5 \n\t" // FIXME slow |
325 | 245 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 |
246 "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
|
247 "psraw $4, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
248 "psraw $4, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
249 "psubw %%mm7, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
250 "psubw %%mm7, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
251 "por %%mm7, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
252 "por %%mm7, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
253 "pxor %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
254 "pxor %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
255 "psubw %%mm2, %%mm0 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
256 "psubw %%mm3, %%mm1 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
257 "pandn %%mm0, %%mm4 \n\t" |
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
258 "pandn %%mm1, %%mm5 \n\t" |
325 | 259 "movq %%mm4, (%0, %%eax) \n\t" |
260 "movq %%mm5, 8(%0, %%eax) \n\t" | |
261 | |
262 "addl $16, %%eax \n\t" | |
263 "js 1b \n\t" | |
264 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) | |
265 : "%eax", "memory" | |
266 ); | |
267 } | |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
268 |
325 | 269 } |
270 | |
271 static void dct_unquantize_mpeg2_mmx(MpegEncContext *s, | |
272 DCTELEM *block, int n, int qscale) | |
273 { | |
274 int nCoeffs; | |
275 const UINT16 *quant_matrix; | |
276 | |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
277 assert(s->block_last_index[n]>=0); |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
278 |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
279 if(s->alternate_scan) nCoeffs= 63; //FIXME |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
280 else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; |
325 | 281 |
282 if (s->mb_intra) { | |
283 int block0; | |
284 if (n < 4) | |
285 block0 = block[0] * s->y_dc_scale; | |
286 else | |
287 block0 = block[0] * s->c_dc_scale; | |
288 quant_matrix = s->intra_matrix; | |
289 asm volatile( | |
290 "pcmpeqw %%mm7, %%mm7 \n\t" | |
291 "psrlw $15, %%mm7 \n\t" | |
292 "movd %2, %%mm6 \n\t" | |
293 "packssdw %%mm6, %%mm6 \n\t" | |
294 "packssdw %%mm6, %%mm6 \n\t" | |
295 "movl %3, %%eax \n\t" | |
296 ".balign 16\n\t" | |
297 "1: \n\t" | |
298 "movq (%0, %%eax), %%mm0 \n\t" | |
299 "movq 8(%0, %%eax), %%mm1 \n\t" | |
300 "movq (%1, %%eax), %%mm4 \n\t" | |
301 "movq 8(%1, %%eax), %%mm5 \n\t" | |
302 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] | |
303 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] | |
304 "pxor %%mm2, %%mm2 \n\t" | |
305 "pxor %%mm3, %%mm3 \n\t" | |
306 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 | |
307 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 | |
308 "pxor %%mm2, %%mm0 \n\t" | |
309 "pxor %%mm3, %%mm1 \n\t" | |
310 "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) | |
311 "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) | |
312 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q | |
313 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q | |
314 "pxor %%mm4, %%mm4 \n\t" | |
315 "pxor %%mm5, %%mm5 \n\t" // FIXME slow | |
316 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 | |
317 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 | |
318 "psraw $3, %%mm0 \n\t" | |
319 "psraw $3, %%mm1 \n\t" | |
320 "pxor %%mm2, %%mm0 \n\t" | |
321 "pxor %%mm3, %%mm1 \n\t" | |
322 "psubw %%mm2, %%mm0 \n\t" | |
323 "psubw %%mm3, %%mm1 \n\t" | |
324 "pandn %%mm0, %%mm4 \n\t" | |
325 "pandn %%mm1, %%mm5 \n\t" | |
326 "movq %%mm4, (%0, %%eax) \n\t" | |
327 "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
|
328 |
325 | 329 "addl $16, %%eax \n\t" |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
330 "jng 1b \n\t" |
325 | 331 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) |
332 : "%eax", "memory" | |
333 ); | |
334 block[0]= block0; | |
335 //Note, we dont do mismatch control for intra as errors cannot accumulate | |
336 | |
337 } else { | |
344 | 338 quant_matrix = s->inter_matrix; |
325 | 339 asm volatile( |
340 "pcmpeqw %%mm7, %%mm7 \n\t" | |
341 "psrlq $48, %%mm7 \n\t" | |
342 "movd %2, %%mm6 \n\t" | |
343 "packssdw %%mm6, %%mm6 \n\t" | |
344 "packssdw %%mm6, %%mm6 \n\t" | |
345 "movl %3, %%eax \n\t" | |
346 ".balign 16\n\t" | |
347 "1: \n\t" | |
348 "movq (%0, %%eax), %%mm0 \n\t" | |
349 "movq 8(%0, %%eax), %%mm1 \n\t" | |
350 "movq (%1, %%eax), %%mm4 \n\t" | |
351 "movq 8(%1, %%eax), %%mm5 \n\t" | |
352 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] | |
353 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] | |
354 "pxor %%mm2, %%mm2 \n\t" | |
355 "pxor %%mm3, %%mm3 \n\t" | |
356 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 | |
357 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 | |
358 "pxor %%mm2, %%mm0 \n\t" | |
359 "pxor %%mm3, %%mm1 \n\t" | |
360 "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) | |
361 "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) | |
362 "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2 | |
363 "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2 | |
364 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*2*q | |
365 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*2*q | |
366 "paddw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q | |
367 "paddw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q | |
368 "pxor %%mm4, %%mm4 \n\t" | |
369 "pxor %%mm5, %%mm5 \n\t" // FIXME slow | |
370 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 | |
371 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 | |
372 "psrlw $4, %%mm0 \n\t" | |
373 "psrlw $4, %%mm1 \n\t" | |
374 "pxor %%mm2, %%mm0 \n\t" | |
375 "pxor %%mm3, %%mm1 \n\t" | |
376 "psubw %%mm2, %%mm0 \n\t" | |
377 "psubw %%mm3, %%mm1 \n\t" | |
378 "pandn %%mm0, %%mm4 \n\t" | |
379 "pandn %%mm1, %%mm5 \n\t" | |
380 "pxor %%mm4, %%mm7 \n\t" | |
381 "pxor %%mm5, %%mm7 \n\t" | |
382 "movq %%mm4, (%0, %%eax) \n\t" | |
383 "movq %%mm5, 8(%0, %%eax) \n\t" | |
384 | |
385 "addl $16, %%eax \n\t" | |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
386 "jng 1b \n\t" |
325 | 387 "movd 124(%0, %3), %%mm0 \n\t" |
388 "movq %%mm7, %%mm6 \n\t" | |
389 "psrlq $32, %%mm7 \n\t" | |
390 "pxor %%mm6, %%mm7 \n\t" | |
391 "movq %%mm7, %%mm6 \n\t" | |
392 "psrlq $16, %%mm7 \n\t" | |
393 "pxor %%mm6, %%mm7 \n\t" | |
394 "pslld $31, %%mm7 \n\t" | |
395 "psrlq $15, %%mm7 \n\t" | |
396 "pxor %%mm7, %%mm0 \n\t" | |
397 "movd %%mm0, 124(%0, %3) \n\t" | |
398 | |
399 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "r" (-2*nCoeffs) | |
400 : "%eax", "memory" | |
145
bd1adece8280
dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents:
14
diff
changeset
|
401 ); |
8 | 402 } |
403 } | |
404 | |
206 | 405 /* draw the edges of width 'w' of an image of size width, height |
406 this mmx version can only handle w==8 || w==16 */ | |
407 static void draw_edges_mmx(UINT8 *buf, int wrap, int width, int height, int w) | |
408 { | |
409 UINT8 *ptr, *last_line; | |
410 int i; | |
411 | |
412 last_line = buf + (height - 1) * wrap; | |
413 /* left and right */ | |
414 ptr = buf; | |
415 if(w==8) | |
416 { | |
417 asm volatile( | |
418 "1: \n\t" | |
419 "movd (%0), %%mm0 \n\t" | |
420 "punpcklbw %%mm0, %%mm0 \n\t" | |
421 "punpcklwd %%mm0, %%mm0 \n\t" | |
422 "punpckldq %%mm0, %%mm0 \n\t" | |
423 "movq %%mm0, -8(%0) \n\t" | |
424 "movq -8(%0, %2), %%mm1 \n\t" | |
425 "punpckhbw %%mm1, %%mm1 \n\t" | |
426 "punpckhwd %%mm1, %%mm1 \n\t" | |
427 "punpckhdq %%mm1, %%mm1 \n\t" | |
428 "movq %%mm1, (%0, %2) \n\t" | |
429 "addl %1, %0 \n\t" | |
430 "cmpl %3, %0 \n\t" | |
431 " jb 1b \n\t" | |
432 : "+r" (ptr) | |
433 : "r" (wrap), "r" (width), "r" (ptr + wrap*height) | |
434 ); | |
435 } | |
436 else | |
437 { | |
438 asm volatile( | |
439 "1: \n\t" | |
440 "movd (%0), %%mm0 \n\t" | |
441 "punpcklbw %%mm0, %%mm0 \n\t" | |
442 "punpcklwd %%mm0, %%mm0 \n\t" | |
443 "punpckldq %%mm0, %%mm0 \n\t" | |
444 "movq %%mm0, -8(%0) \n\t" | |
445 "movq %%mm0, -16(%0) \n\t" | |
446 "movq -8(%0, %2), %%mm1 \n\t" | |
447 "punpckhbw %%mm1, %%mm1 \n\t" | |
448 "punpckhwd %%mm1, %%mm1 \n\t" | |
449 "punpckhdq %%mm1, %%mm1 \n\t" | |
450 "movq %%mm1, (%0, %2) \n\t" | |
451 "movq %%mm1, 8(%0, %2) \n\t" | |
452 "addl %1, %0 \n\t" | |
453 "cmpl %3, %0 \n\t" | |
454 " jb 1b \n\t" | |
455 : "+r" (ptr) | |
456 : "r" (wrap), "r" (width), "r" (ptr + wrap*height) | |
457 ); | |
458 } | |
459 | |
460 for(i=0;i<w;i+=4) { | |
461 /* top and bottom (and hopefully also the corners) */ | |
462 ptr= buf - (i + 1) * wrap - w; | |
463 asm volatile( | |
464 "1: \n\t" | |
465 "movq (%1, %0), %%mm0 \n\t" | |
466 "movq %%mm0, (%0) \n\t" | |
467 "movq %%mm0, (%0, %2) \n\t" | |
468 "movq %%mm0, (%0, %2, 2) \n\t" | |
469 "movq %%mm0, (%0, %3) \n\t" | |
470 "addl $8, %0 \n\t" | |
471 "cmpl %4, %0 \n\t" | |
472 " jb 1b \n\t" | |
473 : "+r" (ptr) | |
474 : "r" ((int)buf - (int)ptr - w), "r" (-wrap), "r" (-wrap*3), "r" (ptr+width+2*w) | |
475 ); | |
476 ptr= last_line + (i + 1) * wrap - w; | |
477 asm volatile( | |
478 "1: \n\t" | |
479 "movq (%1, %0), %%mm0 \n\t" | |
480 "movq %%mm0, (%0) \n\t" | |
481 "movq %%mm0, (%0, %2) \n\t" | |
482 "movq %%mm0, (%0, %2, 2) \n\t" | |
483 "movq %%mm0, (%0, %3) \n\t" | |
484 "addl $8, %0 \n\t" | |
485 "cmpl %4, %0 \n\t" | |
486 " jb 1b \n\t" | |
487 : "+r" (ptr) | |
488 : "r" ((int)last_line - (int)ptr - w), "r" (wrap), "r" (wrap*3), "r" (ptr+width+2*w) | |
489 ); | |
490 } | |
491 } | |
492 | |
220 | 493 #undef HAVE_MMX2 |
494 #define RENAME(a) a ## _MMX | |
495 #include "mpegvideo_mmx_template.c" | |
496 | |
497 #define HAVE_MMX2 | |
498 #undef RENAME | |
499 #define RENAME(a) a ## _MMX2 | |
500 #include "mpegvideo_mmx_template.c" | |
206 | 501 |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
502 /* external functions, from idct_mmx.c */ |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
503 void ff_mmx_idct(DCTELEM *block); |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
504 void ff_mmxext_idct(DCTELEM *block); |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
505 |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
506 /* XXX: those functions should be suppressed ASAP when all IDCTs are |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
507 converted */ |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
508 static void ff_libmpeg2mmx_idct_put(UINT8 *dest, int line_size, DCTELEM *block) |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
509 { |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
510 ff_mmx_idct (block); |
855
df26acd21c84
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
768
diff
changeset
|
511 put_pixels_clamped_mmx(block, dest, line_size); |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
512 } |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
513 static void ff_libmpeg2mmx_idct_add(UINT8 *dest, int line_size, DCTELEM *block) |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
514 { |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
515 ff_mmx_idct (block); |
855
df26acd21c84
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
768
diff
changeset
|
516 add_pixels_clamped_mmx(block, dest, line_size); |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
517 } |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
518 static void ff_libmpeg2mmx2_idct_put(UINT8 *dest, int line_size, DCTELEM *block) |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
519 { |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
520 ff_mmxext_idct (block); |
855
df26acd21c84
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
768
diff
changeset
|
521 put_pixels_clamped_mmx(block, dest, line_size); |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
522 } |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
523 static void ff_libmpeg2mmx2_idct_add(UINT8 *dest, int line_size, DCTELEM *block) |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
524 { |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
525 ff_mmxext_idct (block); |
855
df26acd21c84
* using DSPContext - so each codec could use its local (sub)set of CPU extension
kabi
parents:
768
diff
changeset
|
526 add_pixels_clamped_mmx(block, dest, line_size); |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
527 } |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
528 |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
529 void MPV_common_init_mmx(MpegEncContext *s) |
8 | 530 { |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
531 if (mm_flags & MM_MMX) { |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
532 int i; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
533 const int dct_algo = s->avctx->dct_algo; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
534 const int idct_algo= s->avctx->idct_algo; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
535 |
325 | 536 s->dct_unquantize_h263 = dct_unquantize_h263_mmx; |
537 s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_mmx; | |
538 s->dct_unquantize_mpeg2 = dct_unquantize_mpeg2_mmx; | |
312 | 539 |
350
6ebbecc10063
- Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents:
344
diff
changeset
|
540 draw_edges = draw_edges_mmx; |
220 | 541 |
625
bb6a69f9d409
slow but accurate integer dct from IJG (should be ok with the LGPL as the old DCT is the fast integer DCT from IJG)
michaelni
parents:
620
diff
changeset
|
542 if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){ |
687
9abb13c21fbe
fdct_mmx -> ff_fdct_mmx (renamed to avoid namespace conflict with xvid)
arpi_esp
parents:
625
diff
changeset
|
543 s->fdct = ff_fdct_mmx; |
625
bb6a69f9d409
slow but accurate integer dct from IJG (should be ok with the LGPL as the old DCT is the fast integer DCT from IJG)
michaelni
parents:
620
diff
changeset
|
544 |
bb6a69f9d409
slow but accurate integer dct from IJG (should be ok with the LGPL as the old DCT is the fast integer DCT from IJG)
michaelni
parents:
620
diff
changeset
|
545 if(mm_flags & MM_MMXEXT){ |
bb6a69f9d409
slow but accurate integer dct from IJG (should be ok with the LGPL as the old DCT is the fast integer DCT from IJG)
michaelni
parents:
620
diff
changeset
|
546 s->dct_quantize= dct_quantize_MMX2; |
bb6a69f9d409
slow but accurate integer dct from IJG (should be ok with the LGPL as the old DCT is the fast integer DCT from IJG)
michaelni
parents:
620
diff
changeset
|
547 } else { |
bb6a69f9d409
slow but accurate integer dct from IJG (should be ok with the LGPL as the old DCT is the fast integer DCT from IJG)
michaelni
parents:
620
diff
changeset
|
548 s->dct_quantize= dct_quantize_MMX; |
bb6a69f9d409
slow but accurate integer dct from IJG (should be ok with the LGPL as the old DCT is the fast integer DCT from IJG)
michaelni
parents:
620
diff
changeset
|
549 } |
350
6ebbecc10063
- Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents:
344
diff
changeset
|
550 } |
768
c3fc09466f92
idct_permutation_type variable, so the permutation type can quickly be identified
michaelni
parents:
706
diff
changeset
|
551 |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
552 if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){ |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
553 s->idct_put= ff_simple_idct_put_mmx; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
554 s->idct_add= ff_simple_idct_add_mmx; |
768
c3fc09466f92
idct_permutation_type variable, so the permutation type can quickly be identified
michaelni
parents:
706
diff
changeset
|
555 s->idct_permutation_type= FF_SIMPLE_IDCT_PERM; |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
556 }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){ |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
557 if(mm_flags & MM_MMXEXT){ |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
558 s->idct_put= ff_libmpeg2mmx2_idct_put; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
559 s->idct_add= ff_libmpeg2mmx2_idct_add; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
560 }else{ |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
561 s->idct_put= ff_libmpeg2mmx_idct_put; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
562 s->idct_add= ff_libmpeg2mmx_idct_add; |
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
563 } |
768
c3fc09466f92
idct_permutation_type variable, so the permutation type can quickly be identified
michaelni
parents:
706
diff
changeset
|
564 s->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; |
706
e65798d228ea
idct permutation cleanup, idct can be selected per context now
michaelni
parents:
687
diff
changeset
|
565 } |
14
8ceb13af9cb6
renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents:
8
diff
changeset
|
566 } |
8 | 567 } |