annotate i386/mpegvideo_mmx.c @ 250:3449316664b5 libavcodec

- Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
author pulento
date Fri, 22 Feb 2002 03:35:41 +0000
parents 42a0b7b16738
children ddb1a0e94cf4
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!)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
3 * Copyright (c) 2000,2001 Gerard Lantau.
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
4 *
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
8 * (at your option) any later version.
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
9 *
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
13 * GNU General Public License for more details.
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
14 *
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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>
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
20 * h263 dequantizer 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"
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
26 #include "../mangle.h"
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
27
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
28 extern UINT8 zigzag_end[64];
206
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
29 extern void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w);
220
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
30 extern int (*dct_quantize)(MpegEncContext *s, DCTELEM *block, int n, int qscale);
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
31
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
32 extern UINT8 zigzag_direct_noperm[64];
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
33 extern UINT16 inv_zigzag_direct16[64];
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
34 extern UINT32 inverse[256];
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
35
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
36 #if 0
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
37
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
38 /* XXX: GL: I don't understand why this function needs optimization
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
39 (it is called only once per frame!), so I disabled it */
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
40
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
41 void MPV_frame_start(MpegEncContext *s)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
42 {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
43 if (s->pict_type == B_TYPE) {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
44 __asm __volatile(
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
45 "movl (%1), %%eax\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
46 "movl 4(%1), %%edx\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
47 "movl 8(%1), %%ecx\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
48 "movl %%eax, (%0)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
49 "movl %%edx, 4(%0)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
50 "movl %%ecx, 8(%0)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
51 :
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
52 :"r"(s->current_picture), "r"(s->aux_picture)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
53 :"eax","edx","ecx","memory");
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
54 } else {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
55 /* swap next and last */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
56 __asm __volatile(
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
57 "movl (%1), %%eax\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
58 "movl 4(%1), %%edx\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
59 "movl 8(%1), %%ecx\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
60 "xchgl (%0), %%eax\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
61 "xchgl 4(%0), %%edx\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
62 "xchgl 8(%0), %%ecx\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
63 "movl %%eax, (%1)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
64 "movl %%edx, 4(%1)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
65 "movl %%ecx, 8(%1)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
66 "movl %%eax, (%2)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
67 "movl %%edx, 4(%2)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
68 "movl %%ecx, 8(%2)\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
69 :
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
70 :"r"(s->last_picture), "r"(s->next_picture), "r"(s->current_picture)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
71 :"eax","edx","ecx","memory");
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
72 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
73 }
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
74 #endif
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
75
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
76 static const unsigned long long int mm_wabs __attribute__ ((aligned(8))) = 0xffffffffffffffffULL;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
77 static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001ULL;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
78
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
79
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
80 static void dct_unquantize_h263_mmx(MpegEncContext *s,
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
81 DCTELEM *block, int n, int qscale)
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
82 {
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
83 int i, level, qmul, qadd, nCoeffs;
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
84
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
85 qmul = s->qscale << 1;
248
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 220
diff changeset
86 if (s->h263_aic && s->mb_intra)
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 220
diff changeset
87 qadd = 0;
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 220
diff changeset
88 else
56ee684c48bb - H.263+ decoder support for Advanded INTRA Coding (buggy)
pulento
parents: 220
diff changeset
89 qadd = (s->qscale - 1) | 1;
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
90
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
91 if (s->mb_intra) {
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
92 if (!s->h263_aic) {
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
93 if (n < 4)
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
94 block[0] = block[0] * s->y_dc_scale;
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
95 else
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
96 block[0] = block[0] * s->c_dc_scale;
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
97 }
250
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
98 for(i=1; i<8; i++) {
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
99 level = block[i];
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
100 if (level) {
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
101 if (level < 0) {
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
102 level = level * qmul - qadd;
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
103 } else {
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
104 level = level * qmul + qadd;
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
105 }
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
106 block[i] = level;
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
107 }
3449316664b5 - Bug fix on RTYPE (rounding type) not being honoured by H.263+ decoder.
pulento
parents: 249
diff changeset
108 }
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
109 nCoeffs=64;
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
110 } else {
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
111 i = 0;
249
42a0b7b16738 - Bug fixes in H.263+ Advanced INTRA Coding decoder.
pulento
parents: 248
diff changeset
112 nCoeffs= zigzag_end[ s->block_last_index[n] ];
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
113 }
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
114 //printf("%d %d ", qmul, qadd);
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
115 asm volatile(
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
116 "movd %1, %%mm6 \n\t" //qmul
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
117 "packssdw %%mm6, %%mm6 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
118 "packssdw %%mm6, %%mm6 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
119 "movd %2, %%mm5 \n\t" //qadd
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
120 "pxor %%mm7, %%mm7 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
121 "packssdw %%mm5, %%mm5 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
122 "packssdw %%mm5, %%mm5 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
123 "psubw %%mm5, %%mm7 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
124 "pxor %%mm4, %%mm4 \n\t"
153
acbd3bc999b3 Let loops will be aligned
nickols_k
parents: 145
diff changeset
125 ".balign 16\n\t"
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
126 "1: \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
127 "movq (%0, %3), %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
128 "movq 8(%0, %3), %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
129
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
130 "pmullw %%mm6, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
131 "pmullw %%mm6, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
132
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
133 "movq (%0, %3), %%mm2 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
134 "movq 8(%0, %3), %%mm3 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
135
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
136 "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
137 "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
138
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
139 "pxor %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
140 "pxor %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
141
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
142 "paddw %%mm7, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
143 "paddw %%mm7, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
144
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
145 "pxor %%mm0, %%mm2 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
146 "pxor %%mm1, %%mm3 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
147
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
148 "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
149 "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
150
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
151 "pandn %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
152 "pandn %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
153
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
154 "movq %%mm0, (%0, %3) \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
155 "movq %%mm1, 8(%0, %3) \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
156
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
157 "addl $16, %3 \n\t"
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
158 "js 1b \n\t"
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
159 ::"r" (block+nCoeffs), "g"(qmul), "g" (qadd), "r" (2*(i-nCoeffs))
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
160 : "memory"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
161 );
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
162 }
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
163
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
164
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
165 /*
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
166 NK:
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
167 Note: looking at PARANOID:
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
168 "enable all paranoid tests for rounding, overflows, etc..."
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
169
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
170 #ifdef PARANOID
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
171 if (level < -2048 || level > 2047)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
172 fprintf(stderr, "unquant error %d %d\n", i, level);
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
173 #endif
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
174 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
175 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
176 a complex multiplication.
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
177 =====================================================
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
178 Full formula for multiplication of 2 integer numbers
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
179 which are represent as high:low words:
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
180 input: value1 = high1:low1
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
181 value2 = high2:low2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
182 output: value3 = value1*value2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
183 value3=high3:low3 (on overflow: modulus 2^32 wrap-around)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
184 this mean that for 0x123456 * 0x123456 correct result is 0x766cb0ce4
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
185 but this algorithm will compute only 0x66cb0ce4
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
186 this limited by 16-bit size of operands
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
187 ---------------------------------
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
188 tlow1 = high1*low2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
189 tlow2 = high2*low1
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
190 tlow1 = tlow1 + tlow2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
191 high3:low3 = low1*low2
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
192 high3 += tlow1
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
193 */
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
194 static void dct_unquantize_mpeg1_mmx(MpegEncContext *s,
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
195 DCTELEM *block, int n, int qscale)
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
196 {
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
197 int i, level, nCoeffs;
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
198 const UINT16 *quant_matrix;
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
199
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
200 if(s->alternate_scan) nCoeffs= 64;
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
201 else nCoeffs= nCoeffs= zigzag_end[ s->block_last_index[n] ];
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
202
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
203 if (s->mb_intra) {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
204 if (n < 4)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
205 block[0] = block[0] * s->y_dc_scale;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
206 else
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
207 block[0] = block[0] * s->c_dc_scale;
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
208 /* isnt used anymore (we have a h263 unquantizer since some time)
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
209 if (s->out_format == FMT_H263) {
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
210 i = 1;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
211 goto unquant_even;
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
212 }*/
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
213 /* XXX: only mpeg1 */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
214 quant_matrix = s->intra_matrix;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
215 i=1;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
216 /* Align on 4 elements boundary */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
217 while(i&3)
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
218 {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
219 level = block[i];
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
220 if (level) {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
221 if (level < 0) level = -level;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
222 level = (int)(level * qscale * quant_matrix[i]) >> 3;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
223 level = (level - 1) | 1;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
224 if (block[i] < 0) level = -level;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
225 block[i] = level;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
226 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
227 i++;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
228 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
229 __asm __volatile(
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
230 "movd %0, %%mm6\n\t" /* mm6 = qscale | 0 */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
231 "punpckldq %%mm6, %%mm6\n\t" /* mm6 = qscale | qscale */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
232 "movq %2, %%mm4\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
233 "movq %%mm6, %%mm7\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
234 "movq %1, %%mm5\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
235 "packssdw %%mm6, %%mm7\n\t" /* mm7 = qscale | qscale | qscale | qscale */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
236 "pxor %%mm6, %%mm6\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
237 ::"g"(qscale),"m"(mm_wone),"m"(mm_wabs):"memory");
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
238 for(;i<nCoeffs;i+=4) {
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
239 __asm __volatile(
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
240 "movq %1, %%mm0\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
241 "movq %%mm7, %%mm1\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
242 "movq %%mm0, %%mm2\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
243 "movq %%mm0, %%mm3\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
244 "pcmpgtw %%mm6, %%mm2\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
245 "pmullw %2, %%mm1\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
246 "pandn %%mm4, %%mm2\n\t"
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
247 "por %%mm5, %%mm2\n\t"
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
248 "pmullw %%mm2, %%mm0\n\t" /* mm0 = abs(block[i]). */
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
249
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
250 "pcmpeqw %%mm6, %%mm3\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
251 "pmullw %%mm0, %%mm1\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
252 "psraw $3, %%mm1\n\t"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
253 "psubw %%mm5, %%mm1\n\t" /* block[i] --; */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
254 "pandn %%mm4, %%mm3\n\t" /* fake of pcmpneqw : mm0 != 0 then mm1 = -1 */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
255 "por %%mm5, %%mm1\n\t" /* block[i] |= 1 */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
256 "pmullw %%mm2, %%mm1\n\t" /* change signs again */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
257
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
258 "pand %%mm3, %%mm1\n\t" /* nullify if was zero */
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
259 "movq %%mm1, %0"
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
260 :"=m"(block[i])
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
261 :"m"(block[i]), "m"(quant_matrix[i])
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
262 :"memory");
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
263 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
264 } else {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
265 i = 0;
220
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
266 // unquant_even:
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
267 quant_matrix = s->non_intra_matrix;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
268 /* Align on 4 elements boundary */
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
269 while(i&7)
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
270 {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
271 level = block[i];
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
272 if (level) {
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
273 if (level < 0) level = -level;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
274 level = (((level << 1) + 1) * qscale *
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
275 ((int) quant_matrix[i])) >> 4;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
276 level = (level - 1) | 1;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
277 if(block[i] < 0) level = -level;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
278 block[i] = level;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
279 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
280 i++;
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
281 }
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
282 asm volatile(
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
283 "pcmpeqw %%mm7, %%mm7 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
284 "psrlw $15, %%mm7 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
285 "movd %2, %%mm6 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
286 "packssdw %%mm6, %%mm6 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
287 "packssdw %%mm6, %%mm6 \n\t"
153
acbd3bc999b3 Let loops will be aligned
nickols_k
parents: 145
diff changeset
288 ".balign 16\n\t"
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
289 "1: \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
290 "movq (%0, %3), %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
291 "movq 8(%0, %3), %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
292 "movq (%1, %3), %%mm4 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
293 "movq 8(%1, %3), %%mm5 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
294 "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
295 "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
296 "pxor %%mm2, %%mm2 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
297 "pxor %%mm3, %%mm3 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
298 "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
299 "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
300 "pxor %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
301 "pxor %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
302 "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
303 "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
304 "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
305 "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
306 "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
307 "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
308 "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
309 "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
310 "pxor %%mm4, %%mm4 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
311 "pxor %%mm5, %%mm5 \n\t" // FIXME slow
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
312 "pcmpeqw (%0, %3), %%mm4 \n\t" // block[i] == 0 ? -1 : 0
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
313 "pcmpeqw 8(%0, %3), %%mm5 \n\t" // block[i] == 0 ? -1 : 0
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
314 "psraw $4, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
315 "psraw $4, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
316 "psubw %%mm7, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
317 "psubw %%mm7, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
318 "por %%mm7, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
319 "por %%mm7, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
320 "pxor %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
321 "pxor %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
322 "psubw %%mm2, %%mm0 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
323 "psubw %%mm3, %%mm1 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
324 "pandn %%mm0, %%mm4 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
325 "pandn %%mm1, %%mm5 \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
326 "movq %%mm4, (%0, %3) \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
327 "movq %%mm5, 8(%0, %3) \n\t"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
328
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
329 "addl $16, %3 \n\t"
200
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
330 "js 1b \n\t"
6ab301aaa652 (commit by michael)
arpi_esp
parents: 153
diff changeset
331 ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "r" (2*(i-nCoeffs))
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
332 : "memory"
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
333 );
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
334 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
335 }
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
336
206
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
337 /* draw the edges of width 'w' of an image of size width, height
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
338 this mmx version can only handle w==8 || w==16 */
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
339 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
340 {
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
341 UINT8 *ptr, *last_line;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
342 int i;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
343
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
344 last_line = buf + (height - 1) * wrap;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
345 /* left and right */
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
346 ptr = buf;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
347 if(w==8)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
348 {
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
349 asm volatile(
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
350 "1: \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
351 "movd (%0), %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
352 "punpcklbw %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
353 "punpcklwd %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
354 "punpckldq %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
355 "movq %%mm0, -8(%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
356 "movq -8(%0, %2), %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
357 "punpckhbw %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
358 "punpckhwd %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
359 "punpckhdq %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
360 "movq %%mm1, (%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
361 "addl %1, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
362 "cmpl %3, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
363 " jb 1b \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
364 : "+r" (ptr)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
365 : "r" (wrap), "r" (width), "r" (ptr + wrap*height)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
366 );
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
367 }
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
368 else
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
369 {
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
370 asm volatile(
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
371 "1: \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
372 "movd (%0), %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
373 "punpcklbw %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
374 "punpcklwd %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
375 "punpckldq %%mm0, %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
376 "movq %%mm0, -8(%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
377 "movq %%mm0, -16(%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
378 "movq -8(%0, %2), %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
379 "punpckhbw %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
380 "punpckhwd %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
381 "punpckhdq %%mm1, %%mm1 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
382 "movq %%mm1, (%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
383 "movq %%mm1, 8(%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
384 "addl %1, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
385 "cmpl %3, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
386 " jb 1b \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
387 : "+r" (ptr)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
388 : "r" (wrap), "r" (width), "r" (ptr + wrap*height)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
389 );
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
390 }
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
391
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
392 for(i=0;i<w;i+=4) {
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
393 /* top and bottom (and hopefully also the corners) */
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
394 ptr= buf - (i + 1) * wrap - w;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
395 asm volatile(
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
396 "1: \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
397 "movq (%1, %0), %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
398 "movq %%mm0, (%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
399 "movq %%mm0, (%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
400 "movq %%mm0, (%0, %2, 2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
401 "movq %%mm0, (%0, %3) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
402 "addl $8, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
403 "cmpl %4, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
404 " jb 1b \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
405 : "+r" (ptr)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
406 : "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
407 );
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
408 ptr= last_line + (i + 1) * wrap - w;
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
409 asm volatile(
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
410 "1: \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
411 "movq (%1, %0), %%mm0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
412 "movq %%mm0, (%0) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
413 "movq %%mm0, (%0, %2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
414 "movq %%mm0, (%0, %2, 2) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
415 "movq %%mm0, (%0, %3) \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
416 "addl $8, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
417 "cmpl %4, %0 \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
418 " jb 1b \n\t"
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
419 : "+r" (ptr)
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
420 : "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
421 );
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
422 }
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
423 }
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
424
220
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
425 static volatile int esp_temp;
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
426
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
427 void unused_var_warning_killer(){
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
428 esp_temp++;
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
429 }
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
430
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
431 #undef HAVE_MMX2
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
432 #define RENAME(a) a ## _MMX
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
433 #include "mpegvideo_mmx_template.c"
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
434
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
435 #define HAVE_MMX2
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
436 #undef RENAME
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
437 #define RENAME(a) a ## _MMX2
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
438 #include "mpegvideo_mmx_template.c"
206
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
439
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
440 void MPV_common_init_mmx(MpegEncContext *s)
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
441 {
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
442 if (mm_flags & MM_MMX) {
145
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
443 if (s->out_format == FMT_H263)
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
444 s->dct_unquantize = dct_unquantize_h263_mmx;
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
445 else
bd1adece8280 dct_unquantize_h263_mmx() by Michael Niedermayer <michaelni@gmx.at>
arpi_esp
parents: 14
diff changeset
446 s->dct_unquantize = dct_unquantize_mpeg1_mmx;
206
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
447
994aa8623443 (commit by michael)
arpi_esp
parents: 200
diff changeset
448 draw_edges = draw_edges_mmx;
220
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
449
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
450 if(mm_flags & MM_MMXEXT){
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
451 dct_quantize= dct_quantize_MMX2;
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
452 }else{
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
453 dct_quantize= dct_quantize_MMX;
0b234715e205 (commit by michael)
arpi_esp
parents: 206
diff changeset
454 }
14
8ceb13af9cb6 renamed - use of s->dct_unquantize function pointer - SHOULD add faster h263 mmx specific unquantization stuff
glantau
parents: 8
diff changeset
455 }
8
1b4461b5a7fb Sync with mplayer's stuff
nickols_k
parents:
diff changeset
456 }