annotate i386/mpegvideo_mmx.c @ 1318:209abbb4c4f7 libavcodec

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