annotate i386/mpegvideo_mmx_template.c @ 376:ba9c3b8088c0 libavcodec

- pict_type exported to AVCodecContext - Added real_pict_num to AVCodecContext, it represent the number of the previous encoded frame, usefull when coding with B frames. - Warning fix in motion_est.c
author pulento
date Sat, 11 May 2002 23:42:16 +0000
parents 6ebbecc10063
children 718a22dc121f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
1 /*
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
2 Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
3
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
6 the Free Software Foundation; either version 2 of the License, or
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
7 (at your option) any later version.
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
8
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
12 GNU General Public License for more details.
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
13
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
15 along with this program; if not, write to the Free Software
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
17 */
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
18
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
19 #undef SPREADW
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
20 #undef PMAXW
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
21 #ifdef HAVE_MMX2
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
22 #define SPREADW(a) "pshufw $0, " #a ", " #a " \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
23 #define PMAXW(a,b) "pmaxsw " #a ", " #b " \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
24
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
25 #else
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
26 #define SPREADW(a) \
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
27 "punpcklwd " #a ", " #a " \n\t"\
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
28 "punpcklwd " #a ", " #a " \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
29 #define PMAXW(a,b) \
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
30 "psubusw " #a ", " #b " \n\t"\
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
31 "paddw " #a ", " #b " \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
32 #endif
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
33
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
34 static int RENAME(dct_quantize)(MpegEncContext *s,
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
35 DCTELEM *block, int n,
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
36 int qscale, int *overflow)
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
37 {
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
38 int level=0, last_non_zero_p1, q; //=0 is cuz gcc says uninitalized ...
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
39 const UINT16 *qmat, *bias;
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
40 static __align8 INT16 temp_block[64];
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
41
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
42 av_fdct (block);
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
43
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
44 if (s->mb_intra) {
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
45 int dummy;
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
46 if (n < 4)
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
47 q = s->y_dc_scale;
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
48 else
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
49 q = s->c_dc_scale;
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
50 /* note: block[0] is assumed to be positive */
350
6ebbecc10063 - Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents: 344
diff changeset
51 if (!s->h263_aic) {
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
52 #if 1
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
53 asm volatile (
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
54 "xorl %%edx, %%edx \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
55 "mul %%ecx \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
56 : "=d" (level), "=a"(dummy)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
57 : "a" (block[0] + (q >> 1)), "c" (inverse[q])
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
58 );
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
59 #else
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
60 asm volatile (
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
61 "xorl %%edx, %%edx \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
62 "divw %%cx \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
63 "movzwl %%ax, %%eax \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
64 : "=a" (level)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
65 : "a" (block[0] + (q >> 1)), "c" (q)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
66 : "%edx"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
67 );
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
68 #endif
350
6ebbecc10063 - Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents: 344
diff changeset
69 } else
6ebbecc10063 - Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents: 344
diff changeset
70 /* For AIC we skip quant/dequant of INTRADC */
6ebbecc10063 - Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents: 344
diff changeset
71 level = block[0];
6ebbecc10063 - Advanced Intra Coding (AIC) support for H.263+ encoder, just DC by now.
pulento
parents: 344
diff changeset
72
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
73 block[0]=0; //avoid fake overflow
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
74 // temp_block[0] = (block[0] + (q >> 1)) / q;
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
75 last_non_zero_p1 = 1;
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
76 bias = s->q_intra_matrix16_bias[qscale];
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
77 qmat = s->q_intra_matrix16[qscale];
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
78 } else {
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
79 last_non_zero_p1 = 0;
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
80 bias = s->q_inter_matrix16_bias[qscale];
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
81 qmat = s->q_inter_matrix16[qscale];
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
82 }
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
83
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
84 if(s->out_format == FMT_H263){
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
85
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
86 asm volatile(
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
87 "movd %%eax, %%mm3 \n\t" // last_non_zero_p1
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
88 SPREADW(%%mm3)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
89 "pxor %%mm7, %%mm7 \n\t" // 0
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
90 "pxor %%mm4, %%mm4 \n\t" // 0
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
91 "movq (%2), %%mm5 \n\t" // qmat[0]
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
92 "pxor %%mm6, %%mm6 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
93 "psubw (%3), %%mm6 \n\t" // -bias[0]
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
94 "movl $-128, %%eax \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
95 ".balign 16 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
96 "1: \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
97 "pxor %%mm1, %%mm1 \n\t" // 0
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
98 "movq (%1, %%eax), %%mm0 \n\t" // block[i]
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
99 "pcmpgtw %%mm0, %%mm1 \n\t" // block[i] <= 0 ? 0xFF : 0x00
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
100 "pxor %%mm1, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
101 "psubw %%mm1, %%mm0 \n\t" // ABS(block[i])
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
102 "psubusw %%mm6, %%mm0 \n\t" // ABS(block[i]) + bias[0]
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
103 "pmulhw %%mm5, %%mm0 \n\t" // (ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
104 "por %%mm0, %%mm4 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
105 "pxor %%mm1, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
106 "psubw %%mm1, %%mm0 \n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
107 "movq %%mm0, (%5, %%eax) \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
108 "pcmpeqw %%mm7, %%mm0 \n\t" // out==0 ? 0xFF : 0x00
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
109 "movq (%4, %%eax), %%mm1 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
110 "movq %%mm7, (%1, %%eax) \n\t" // 0
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
111 "pandn %%mm1, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
112 PMAXW(%%mm0, %%mm3)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
113 "addl $8, %%eax \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
114 " js 1b \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
115 "movq %%mm3, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
116 "psrlq $32, %%mm3 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
117 PMAXW(%%mm0, %%mm3)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
118 "movq %%mm3, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
119 "psrlq $16, %%mm3 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
120 PMAXW(%%mm0, %%mm3)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
121 "movd %%mm3, %%eax \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
122 "movzbl %%al, %%eax \n\t" // last_non_zero_p1
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
123 : "+a" (last_non_zero_p1)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
124 : "r" (block+64), "r" (qmat), "r" (bias),
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
125 "r" (inv_zigzag_direct16+64), "r" (temp_block+64)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
126 );
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
127 // note the asm is split cuz gcc doesnt like that many operands ...
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
128 asm volatile(
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
129 "movd %1, %%mm1 \n\t" // max_qcoeff
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
130 SPREADW(%%mm1)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
131 "psubusw %%mm1, %%mm4 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
132 "packuswb %%mm4, %%mm4 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
133 "movd %%mm4, %0 \n\t" // *overflow
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
134 : "=g" (*overflow)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
135 : "g" (s->max_qcoeff)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
136 );
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
137 }else{ // FMT_H263
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
138 asm volatile(
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
139 "movd %%eax, %%mm3 \n\t" // last_non_zero_p1
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
140 SPREADW(%%mm3)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
141 "pxor %%mm7, %%mm7 \n\t" // 0
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
142 "pxor %%mm4, %%mm4 \n\t" // 0
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
143 "movl $-128, %%eax \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
144 ".balign 16 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
145 "1: \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
146 "pxor %%mm1, %%mm1 \n\t" // 0
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
147 "movq (%1, %%eax), %%mm0 \n\t" // block[i]
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
148 "pcmpgtw %%mm0, %%mm1 \n\t" // block[i] <= 0 ? 0xFF : 0x00
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
149 "pxor %%mm1, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
150 "psubw %%mm1, %%mm0 \n\t" // ABS(block[i])
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
151 "movq (%3, %%eax), %%mm6 \n\t" // bias[0]
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
152 "paddusw %%mm6, %%mm0 \n\t" // ABS(block[i]) + bias[0]
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
153 "movq (%2, %%eax), %%mm5 \n\t" // qmat[i]
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
154 "pmulhw %%mm5, %%mm0 \n\t" // (ABS(block[i])*qmat[0] + bias[0]*qmat[0])>>16
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
155 "por %%mm0, %%mm4 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
156 "pxor %%mm1, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
157 "psubw %%mm1, %%mm0 \n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
158 "movq %%mm0, (%5, %%eax) \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
159 "pcmpeqw %%mm7, %%mm0 \n\t" // out==0 ? 0xFF : 0x00
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
160 "movq (%4, %%eax), %%mm1 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
161 "movq %%mm7, (%1, %%eax) \n\t" // 0
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
162 "pandn %%mm1, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
163 PMAXW(%%mm0, %%mm3)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
164 "addl $8, %%eax \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
165 " js 1b \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
166 "movq %%mm3, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
167 "psrlq $32, %%mm3 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
168 PMAXW(%%mm0, %%mm3)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
169 "movq %%mm3, %%mm0 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
170 "psrlq $16, %%mm3 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
171 PMAXW(%%mm0, %%mm3)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
172 "movd %%mm3, %%eax \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
173 "movzbl %%al, %%eax \n\t" // last_non_zero_p1
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
174 : "+a" (last_non_zero_p1)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
175 : "r" (block+64), "r" (qmat+64), "r" (bias+64),
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
176 "r" (inv_zigzag_direct16+64), "r" (temp_block+64)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
177 );
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
178 // note the asm is split cuz gcc doesnt like that many operands ...
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
179 asm volatile(
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
180 "movd %1, %%mm1 \n\t" // max_qcoeff
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
181 SPREADW(%%mm1)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
182 "psubusw %%mm1, %%mm4 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
183 "packuswb %%mm4, %%mm4 \n\t"
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
184 "movd %%mm4, %0 \n\t" // *overflow
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
185 : "=g" (*overflow)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
186 : "g" (s->max_qcoeff)
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
187 );
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
188 }
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
189
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
190 if(s->mb_intra) temp_block[0]= level; //FIXME move afer permute
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
191 // last_non_zero_p1=64;
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
192 /* permute for IDCT */
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
193 asm volatile(
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
194 "movl %0, %%eax \n\t"
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
195 "pushl %%ebp \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
196 "movl %%esp, " MANGLE(esp_temp) "\n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
197 "1: \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
198 "movzbl (%1, %%eax), %%ebx \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
199 "movzbl 1(%1, %%eax), %%ebp \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
200 "movw (%2, %%ebx, 2), %%cx \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
201 "movw (%2, %%ebp, 2), %%sp \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
202 "movzbl " MANGLE(permutation) "(%%ebx), %%ebx\n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
203 "movzbl " MANGLE(permutation) "(%%ebp), %%ebp\n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
204 "movw %%cx, (%3, %%ebx, 2) \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
205 "movw %%sp, (%3, %%ebp, 2) \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
206 "addl $2, %%eax \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
207 " js 1b \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
208 "movl " MANGLE(esp_temp) ", %%esp\n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
209 "popl %%ebp \n\t"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
210 :
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
211 : "g" (-last_non_zero_p1), "d" (zigzag_direct_noperm+last_non_zero_p1), "S" (temp_block), "D" (block)
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
212 : "%eax", "%ebx", "%ecx"
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
213 );
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
214 /*
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
215 for(i=0; i<last_non_zero_p1; i++)
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
216 {
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
217 int j= zigzag_direct_noperm[i];
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
218 block[block_permute_op(j)]= temp_block[j];
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
219 }
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
220 */
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
221 //block_permute(block);
344
9f6071a87e17 fixed msmpeg4 infinite loop if buggy stream
michaelni
parents: 230
diff changeset
222
220
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
223 return last_non_zero_p1 - 1;
0b234715e205 (commit by michael)
arpi_esp
parents:
diff changeset
224 }