annotate i386/mpegvideo_mmx.c @ 706:e65798d228ea libavcodec

idct permutation cleanup, idct can be selected per context now fixing some threadunsafe code
author michaelni
date Sun, 29 Sep 2002 22:44:22 +0000
parents 9abb13c21fbe
children c3fc09466f92
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"
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
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
28 /* Input permutation for the simple_idct_mmx */
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
29 static UINT8 simple_mmx_permutation[64]={
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
30 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
31 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
32 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
33 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
34 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
35 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
36 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
37 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
38 };
220
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
39
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
40 extern UINT8 zigzag_direct_noperm[64];
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
41 extern UINT16 inv_zigzag_direct16[64];
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
42 extern UINT32 inverse[256];
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
43
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
44 static const unsigned long long int mm_wabs __attribute__ ((aligned(8))) = 0xffffffffffffffffULL;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
45 static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001ULL;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
46
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
47
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
48 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
49 DCTELEM *block, int n, int qscale)
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
50 {
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
51 int level, qmul, qadd, nCoeffs;
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
52
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
53 qmul = qscale << 1;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
54 qadd = (qscale - 1) | 1;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
55
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
56 assert(s->block_last_index[n]>=0);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
57
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
58 if (s->mb_intra) {
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
59 if (!s->h263_aic) {
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
60 if (n < 4)
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
61 level = block[0] * s->y_dc_scale;
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
62 else
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
63 level = block[0] * s->c_dc_scale;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
64 }else{
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
65 qadd = 0;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
66 level= block[0];
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
67 }
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
68 nCoeffs=63;
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
69 } else {
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
70 nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
71 }
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
72 //printf("%d %d ", qmul, qadd);
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
73 asm volatile(
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
74 "movd %1, %%mm6 \n\t" //qmul
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
75 "packssdw %%mm6, %%mm6 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
76 "packssdw %%mm6, %%mm6 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
77 "movd %2, %%mm5 \n\t" //qadd
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
78 "pxor %%mm7, %%mm7 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
79 "packssdw %%mm5, %%mm5 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
80 "packssdw %%mm5, %%mm5 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
81 "psubw %%mm5, %%mm7 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
82 "pxor %%mm4, %%mm4 \n\t"
153
acbd3bc999b3 Let loops will be aligned
nickols_k
parents: 145
diff changeset
83 ".balign 16\n\t"
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
84 "1: \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
85 "movq (%0, %3), %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
86 "movq 8(%0, %3), %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
87
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
88 "pmullw %%mm6, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
89 "pmullw %%mm6, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
90
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
91 "movq (%0, %3), %%mm2 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
92 "movq 8(%0, %3), %%mm3 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
93
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
94 "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
95 "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
96
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
97 "pxor %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
98 "pxor %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
99
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
100 "paddw %%mm7, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
101 "paddw %%mm7, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
102
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
103 "pxor %%mm0, %%mm2 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
104 "pxor %%mm1, %%mm3 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
105
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
106 "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
107 "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
108
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
109 "pandn %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
110 "pandn %%mm3, %%mm1 \n\t"
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 "movq %%mm0, (%0, %3) \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
113 "movq %%mm1, 8(%0, %3) \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
114
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
115 "addl $16, %3 \n\t"
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
116 "jng 1b \n\t"
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
117 ::"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
118 : "memory"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
119 );
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
120 if(s->mb_intra)
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
121 block[0]= level;
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
122 }
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
123
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
124
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
125 /*
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
126 NK:
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
127 Note: looking at PARANOID:
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
128 "enable all paranoid tests for rounding, overflows, etc..."
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
129
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
130 #ifdef PARANOID
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
131 if (level < -2048 || level > 2047)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
132 fprintf(stderr, "unquant error %d %d\n", i, level);
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
133 #endif
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
134 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
135 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
136 a complex multiplication.
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
137 =====================================================
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
138 Full formula for multiplication of 2 integer numbers
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
139 which are represent as high:low words:
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
140 input: value1 = high1:low1
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
141 value2 = high2:low2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
142 output: value3 = value1*value2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
143 value3=high3:low3 (on overflow: modulus 2^32 wrap-around)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
144 this mean that for 0x123456 * 0x123456 correct result is 0x766cb0ce4
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
145 but this algorithm will compute only 0x66cb0ce4
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
146 this limited by 16-bit size of operands
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
147 ---------------------------------
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
148 tlow1 = high1*low2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
149 tlow2 = high2*low1
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
150 tlow1 = tlow1 + tlow2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
151 high3:low3 = low1*low2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
152 high3 += tlow1
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
153 */
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
154 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
155 DCTELEM *block, int n, int qscale)
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
156 {
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
157 int nCoeffs;
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
158 const UINT16 *quant_matrix;
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
159
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
160 assert(s->block_last_index[n]>=0);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
161
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
162 nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]+1;
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
163
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
164 if (s->mb_intra) {
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
165 int block0;
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
166 if (n < 4)
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
167 block0 = block[0] * s->y_dc_scale;
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
168 else
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
169 block0 = block[0] * s->c_dc_scale;
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
170 /* XXX: only mpeg1 */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
171 quant_matrix = s->intra_matrix;
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
172 asm volatile(
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
173 "pcmpeqw %%mm7, %%mm7 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
174 "psrlw $15, %%mm7 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
175 "movd %2, %%mm6 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
176 "packssdw %%mm6, %%mm6 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
177 "packssdw %%mm6, %%mm6 \n\t"
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
178 "movl %3, %%eax \n\t"
153
acbd3bc999b3 Let loops will be aligned
nickols_k
parents: 145
diff changeset
179 ".balign 16\n\t"
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
180 "1: \n\t"
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
181 "movq (%0, %%eax), %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
182 "movq 8(%0, %%eax), %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
183 "movq (%1, %%eax), %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
184 "movq 8(%1, %%eax), %%mm5 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
185 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
186 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
187 "pxor %%mm2, %%mm2 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
188 "pxor %%mm3, %%mm3 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
189 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
190 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
191 "pxor %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
192 "pxor %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
193 "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
194 "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
195 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
196 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
197 "pxor %%mm4, %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
198 "pxor %%mm5, %%mm5 \n\t" // FIXME slow
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
199 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
200 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
201 "psraw $3, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
202 "psraw $3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
203 "psubw %%mm7, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
204 "psubw %%mm7, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
205 "por %%mm7, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
206 "por %%mm7, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
207 "pxor %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
208 "pxor %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
209 "psubw %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
210 "psubw %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
211 "pandn %%mm0, %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
212 "pandn %%mm1, %%mm5 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
213 "movq %%mm4, (%0, %%eax) \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
214 "movq %%mm5, 8(%0, %%eax) \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
215
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
216 "addl $16, %%eax \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
217 "js 1b \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
218 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
219 : "%eax", "memory"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
220 );
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
221 block[0]= block0;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
222
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
223 } else {
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 325
diff changeset
224 quant_matrix = s->inter_matrix;
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
225 asm volatile(
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
226 "pcmpeqw %%mm7, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
227 "psrlw $15, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
228 "movd %2, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
229 "packssdw %%mm6, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
230 "packssdw %%mm6, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
231 "movl %3, %%eax \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
232 ".balign 16\n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
233 "1: \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
234 "movq (%0, %%eax), %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
235 "movq 8(%0, %%eax), %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
236 "movq (%1, %%eax), %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
237 "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
238 "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
239 "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
240 "pxor %%mm2, %%mm2 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
241 "pxor %%mm3, %%mm3 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
242 "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
243 "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
244 "pxor %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
245 "pxor %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
246 "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
247 "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
248 "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
249 "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
250 "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
251 "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
252 "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
253 "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
254 "pxor %%mm4, %%mm4 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
255 "pxor %%mm5, %%mm5 \n\t" // FIXME slow
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
256 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
257 "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
258 "psraw $4, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
259 "psraw $4, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
260 "psubw %%mm7, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
261 "psubw %%mm7, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
262 "por %%mm7, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
263 "por %%mm7, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
264 "pxor %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
265 "pxor %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
266 "psubw %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
267 "psubw %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
268 "pandn %%mm0, %%mm4 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
269 "pandn %%mm1, %%mm5 \n\t"
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
270 "movq %%mm4, (%0, %%eax) \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
271 "movq %%mm5, 8(%0, %%eax) \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
272
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
273 "addl $16, %%eax \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
274 "js 1b \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
275 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
276 : "%eax", "memory"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
277 );
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
278 }
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
279
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
280 }
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
281
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
282 static void dct_unquantize_mpeg2_mmx(MpegEncContext *s,
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
283 DCTELEM *block, int n, int qscale)
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
284 {
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
285 int nCoeffs;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
286 const UINT16 *quant_matrix;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
287
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
288 assert(s->block_last_index[n]>=0);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
289
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
290 if(s->alternate_scan) nCoeffs= 63; //FIXME
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
291 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
292
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
293 if (s->mb_intra) {
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
294 int block0;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
295 if (n < 4)
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
296 block0 = block[0] * s->y_dc_scale;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
297 else
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
298 block0 = block[0] * s->c_dc_scale;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
299 quant_matrix = s->intra_matrix;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
300 asm volatile(
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
301 "pcmpeqw %%mm7, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
302 "psrlw $15, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
303 "movd %2, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
304 "packssdw %%mm6, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
305 "packssdw %%mm6, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
306 "movl %3, %%eax \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
307 ".balign 16\n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
308 "1: \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
309 "movq (%0, %%eax), %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
310 "movq 8(%0, %%eax), %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
311 "movq (%1, %%eax), %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
312 "movq 8(%1, %%eax), %%mm5 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
313 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
314 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
315 "pxor %%mm2, %%mm2 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
316 "pxor %%mm3, %%mm3 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
317 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
318 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
319 "pxor %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
320 "pxor %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
321 "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
322 "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
323 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
324 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
325 "pxor %%mm4, %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
326 "pxor %%mm5, %%mm5 \n\t" // FIXME slow
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
327 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
328 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
329 "psraw $3, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
330 "psraw $3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
331 "pxor %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
332 "pxor %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
333 "psubw %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
334 "psubw %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
335 "pandn %%mm0, %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
336 "pandn %%mm1, %%mm5 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
337 "movq %%mm4, (%0, %%eax) \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
338 "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
339
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
340 "addl $16, %%eax \n\t"
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
341 "jng 1b \n\t"
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
342 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs)
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
343 : "%eax", "memory"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
344 );
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
345 block[0]= block0;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
346 //Note, we dont do mismatch control for intra as errors cannot accumulate
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
347
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
348 } else {
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 325
diff changeset
349 quant_matrix = s->inter_matrix;
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
350 asm volatile(
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
351 "pcmpeqw %%mm7, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
352 "psrlq $48, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
353 "movd %2, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
354 "packssdw %%mm6, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
355 "packssdw %%mm6, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
356 "movl %3, %%eax \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
357 ".balign 16\n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
358 "1: \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
359 "movq (%0, %%eax), %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
360 "movq 8(%0, %%eax), %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
361 "movq (%1, %%eax), %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
362 "movq 8(%1, %%eax), %%mm5 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
363 "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i]
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
364 "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i]
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
365 "pxor %%mm2, %%mm2 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
366 "pxor %%mm3, %%mm3 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
367 "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
368 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
369 "pxor %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
370 "pxor %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
371 "psubw %%mm2, %%mm0 \n\t" // abs(block[i])
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
372 "psubw %%mm3, %%mm1 \n\t" // abs(block[i])
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
373 "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
374 "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
375 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*2*q
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
376 "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*2*q
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
377 "paddw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
378 "paddw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
379 "pxor %%mm4, %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
380 "pxor %%mm5, %%mm5 \n\t" // FIXME slow
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
381 "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
382 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
383 "psrlw $4, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
384 "psrlw $4, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
385 "pxor %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
386 "pxor %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
387 "psubw %%mm2, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
388 "psubw %%mm3, %%mm1 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
389 "pandn %%mm0, %%mm4 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
390 "pandn %%mm1, %%mm5 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
391 "pxor %%mm4, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
392 "pxor %%mm5, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
393 "movq %%mm4, (%0, %%eax) \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
394 "movq %%mm5, 8(%0, %%eax) \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
395
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
396 "addl $16, %%eax \n\t"
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
397 "jng 1b \n\t"
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
398 "movd 124(%0, %3), %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
399 "movq %%mm7, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
400 "psrlq $32, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
401 "pxor %%mm6, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
402 "movq %%mm7, %%mm6 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
403 "psrlq $16, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
404 "pxor %%mm6, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
405 "pslld $31, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
406 "psrlq $15, %%mm7 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
407 "pxor %%mm7, %%mm0 \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
408 "movd %%mm0, 124(%0, %3) \n\t"
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
409
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
410 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "r" (-2*nCoeffs)
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
411 : "%eax", "memory"
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
412 );
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
413 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
414 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
415
206
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
416 /* draw the edges of width 'w' of an image of size width, height
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
417 this mmx version can only handle w==8 || w==16 */
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
418 static void draw_edges_mmx(UINT8 *buf, int wrap, int width, int height, int w)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
419 {
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
420 UINT8 *ptr, *last_line;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
421 int i;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
422
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
423 last_line = buf + (height - 1) * wrap;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
424 /* left and right */
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
425 ptr = buf;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
426 if(w==8)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
427 {
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
428 asm volatile(
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
429 "1: \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
430 "movd (%0), %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
431 "punpcklbw %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
432 "punpcklwd %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
433 "punpckldq %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
434 "movq %%mm0, -8(%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
435 "movq -8(%0, %2), %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
436 "punpckhbw %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
437 "punpckhwd %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
438 "punpckhdq %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
439 "movq %%mm1, (%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
440 "addl %1, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
441 "cmpl %3, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
442 " jb 1b \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
443 : "+r" (ptr)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
444 : "r" (wrap), "r" (width), "r" (ptr + wrap*height)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
445 );
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
446 }
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
447 else
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
448 {
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
449 asm volatile(
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
450 "1: \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
451 "movd (%0), %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
452 "punpcklbw %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
453 "punpcklwd %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
454 "punpckldq %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
455 "movq %%mm0, -8(%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
456 "movq %%mm0, -16(%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
457 "movq -8(%0, %2), %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
458 "punpckhbw %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
459 "punpckhwd %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
460 "punpckhdq %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
461 "movq %%mm1, (%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
462 "movq %%mm1, 8(%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
463 "addl %1, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
464 "cmpl %3, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
465 " jb 1b \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
466 : "+r" (ptr)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
467 : "r" (wrap), "r" (width), "r" (ptr + wrap*height)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
468 );
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
469 }
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
470
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
471 for(i=0;i<w;i+=4) {
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
472 /* top and bottom (and hopefully also the corners) */
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
473 ptr= buf - (i + 1) * wrap - w;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
474 asm volatile(
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
475 "1: \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
476 "movq (%1, %0), %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
477 "movq %%mm0, (%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
478 "movq %%mm0, (%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
479 "movq %%mm0, (%0, %2, 2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
480 "movq %%mm0, (%0, %3) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
481 "addl $8, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
482 "cmpl %4, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
483 " jb 1b \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
484 : "+r" (ptr)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
485 : "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
486 );
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
487 ptr= last_line + (i + 1) * wrap - w;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
488 asm volatile(
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
489 "1: \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
490 "movq (%1, %0), %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
491 "movq %%mm0, (%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
492 "movq %%mm0, (%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
493 "movq %%mm0, (%0, %2, 2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
494 "movq %%mm0, (%0, %3) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
495 "addl $8, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
496 "cmpl %4, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
497 " jb 1b \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
498 : "+r" (ptr)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
499 : "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
500 );
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
501 }
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
502 }
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
503
220
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
504 #undef HAVE_MMX2
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
505 #define RENAME(a) a ## _MMX
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
506 #include "mpegvideo_mmx_template.c"
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
507
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
508 #define HAVE_MMX2
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
509 #undef RENAME
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
510 #define RENAME(a) a ## _MMX2
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
511 #include "mpegvideo_mmx_template.c"
206
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
512
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
513 /* external functions, from idct_mmx.c */
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
514 void ff_mmx_idct(DCTELEM *block);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
515 void ff_mmxext_idct(DCTELEM *block);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
516
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
517 /* 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
518 converted */
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
519 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
520 {
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
521 ff_mmx_idct (block);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
522 put_pixels_clamped(block, dest, line_size);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
523 }
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
524 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
525 {
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
526 ff_mmx_idct (block);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
527 add_pixels_clamped(block, dest, line_size);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
528 }
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
529 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
530 {
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
531 ff_mmxext_idct (block);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
532 put_pixels_clamped(block, dest, line_size);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
533 }
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
534 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
535 {
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
536 ff_mmxext_idct (block);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
537 add_pixels_clamped(block, dest, line_size);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
538 }
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
539
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
540 void MPV_common_init_mmx(MpegEncContext *s)
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
541 {
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
542 if (mm_flags & MM_MMX) {
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
543 int i;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
544 const int dct_algo = s->avctx->dct_algo;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
545 const int idct_algo= s->avctx->idct_algo;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
546
325
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
547 s->dct_unquantize_h263 = dct_unquantize_h263_mmx;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
548 s->dct_unquantize_mpeg1 = dct_unquantize_mpeg1_mmx;
15efd80cf51e mpeg2/mpeg4 dequantizer support (c & mmx)
michaelni
parents: 312
diff changeset
549 s->dct_unquantize_mpeg2 = dct_unquantize_mpeg2_mmx;
312
8cf5507e6ca5 mpeg4 mpeg quantizer support
michaelni
parents: 252
diff changeset
550
350
6ebbecc10063 - Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents: 344
diff changeset
551 draw_edges = draw_edges_mmx;
220
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
552
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
553 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
554 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
555
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
556 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
557 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
558 } 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
559 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
560 }
350
6ebbecc10063 - Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents: 344
diff changeset
561 }
706
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
562
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
563 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
564 s->idct_put= ff_simple_idct_put_mmx;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
565 s->idct_add= ff_simple_idct_add_mmx;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
566 for(i=0; i<64; i++)
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
567 s->idct_permutation[i]= simple_mmx_permutation[i];
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
568 }else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
569 if(mm_flags & MM_MMXEXT){
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
570 s->idct_put= ff_libmpeg2mmx2_idct_put;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
571 s->idct_add= ff_libmpeg2mmx2_idct_add;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
572 }else{
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
573 s->idct_put= ff_libmpeg2mmx_idct_put;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
574 s->idct_add= ff_libmpeg2mmx_idct_add;
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
575 }
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
576 for(i=0; i<64; i++)
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
577 s->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
e65798d228ea idct permutation cleanup, idct can be selected per context now
michaelni
parents: 687
diff changeset
578 }
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
579 }
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
580 }