41 #if COMPILE_TEMPLATE_SSE2
42 #define MMREG_WIDTH "16"
46 "pshuflw $0, "a", "a" \n\t"\
47 "punpcklwd "a", "a" \n\t"
48 #define PMAXW(a,b) "pmaxsw "a", "b" \n\t"
50 "movhlps "a", "b" \n\t"\
52 "pshuflw $0x0E, "a", "b" \n\t"\
54 "pshuflw $0x01, "a", "b" \n\t"\
57 #define MMREG_WIDTH "8"
61 "punpcklwd "a", "a" \n\t"\
62 "punpcklwd "a", "a" \n\t"
64 "psubusw "a", "b" \n\t"\
68 "psrlq $32, "a" \n\t"\
71 "psrlq $16, "a" \n\t"\
76 #if COMPILE_TEMPLATE_SSSE3
77 #define SAVE_SIGN(a,b) \
78 "movdqa "b", "a" \n\t"\
80 #define RESTORE_SIGN(a,b) \
81 "psignw "a", "b" \n\t"
83 #define SAVE_SIGN(a,b) \
85 "pcmpgtw "b", "a" \n\t" \
88 #define RESTORE_SIGN(a,b) \
90 "psubw "a", "b" \n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
94 int16_t *
block,
int n,
99 const uint16_t *qmat, *
bias;
103 RENAME_FDCT(ff_fdct)(
block);
112 bias =
s->q_intra_matrix16[qscale][1];
113 qmat =
s->q_intra_matrix16[qscale][0];
116 bias =
s->q_chroma_intra_matrix16[qscale][1];
117 qmat =
s->q_chroma_intra_matrix16[qscale][0];
132 last_non_zero_p1 = 1;
134 last_non_zero_p1 = 0;
135 bias =
s->q_inter_matrix16[qscale][1];
136 qmat =
s->q_inter_matrix16[qscale][0];
142 "movd %%"FF_REG_a
", "MM"3 \n\t"
144 "pxor "MM"7, "MM"7 \n\t"
145 "pxor "MM"4, "MM"4 \n\t"
147 "pxor "MM"6, "MM"6 \n\t"
148 "psubw (%3), "MM"6 \n\t"
149 "mov $-128, %%"FF_REG_a
" \n\t"
152 MOVQ" (%1, %%"FF_REG_a
"), "MM"0 \n\t"
154 "psubusw "MM"6, "MM"0 \n\t"
155 "pmulhw "MM"5, "MM"0 \n\t"
156 "por "MM"0, "MM"4 \n\t"
158 MOVQ" "MM"0, (%5, %%"FF_REG_a
") \n\t"
159 "pcmpeqw "MM"7, "MM"0 \n\t"
160 MOVQ" (%4, %%"FF_REG_a
"), "MM"1 \n\t"
161 MOVQ" "MM"7, (%1, %%"FF_REG_a
") \n\t"
162 "pandn "MM"1, "MM"0 \n\t"
167 "movd "MM"3, %%"FF_REG_a
" \n\t"
168 "movzbl %%al, %%eax \n\t"
169 :
"+a" (last_non_zero_p1)
170 :
"r" (
block+64),
"r" (qmat),
"r" (
bias),
173 "%xmm4",
"%xmm5",
"%xmm6",
"%xmm7")
177 "movd %%"FF_REG_a
", "MM"3 \n\t"
179 "pxor "MM"7, "MM"7 \n\t"
180 "pxor "MM"4, "MM"4 \n\t"
181 "mov $-128, %%"FF_REG_a
" \n\t"
184 MOVQ" (%1, %%"FF_REG_a
"), "MM"0 \n\t"
186 MOVQ" (%3, %%"FF_REG_a
"), "MM"6 \n\t"
187 "paddusw "MM"6, "MM"0 \n\t"
188 MOVQ" (%2, %%"FF_REG_a
"), "MM"5 \n\t"
189 "pmulhw "MM"5, "MM"0 \n\t"
190 "por "MM"0, "MM"4 \n\t"
192 MOVQ" "MM"0, (%5, %%"FF_REG_a
") \n\t"
193 "pcmpeqw "MM"7, "MM"0 \n\t"
194 MOVQ" (%4, %%"FF_REG_a
"), "MM"1 \n\t"
195 MOVQ" "MM"7, (%1, %%"FF_REG_a
") \n\t"
196 "pandn "MM"1, "MM"0 \n\t"
201 "movd "MM"3, %%"FF_REG_a
" \n\t"
202 "movzbl %%al, %%eax \n\t"
203 :
"+a" (last_non_zero_p1)
204 :
"r" (
block+64),
"r" (qmat+64),
"r" (
bias+64),
207 "%xmm4",
"%xmm5",
"%xmm6",
"%xmm7")
211 "movd %1, "MM"1 \n\t"
213 "psubusw "MM"1, "MM"4 \n\t"
214 "packuswb "MM"4, "MM"4 \n\t"
215 #if COMPILE_TEMPLATE_SSE2
216 "packsswb "MM"4, "MM"4 \n\t"
218 "movd "MM"4, %0 \n\t"
220 :
"g" (
s->max_qcoeff)
224 else block[0]= temp_block[0];
228 if(last_non_zero_p1 <= 1)
goto end;
229 block[0x08] = temp_block[0x01];
block[0x10] = temp_block[0x08];
230 block[0x20] = temp_block[0x10];
231 if(last_non_zero_p1 <= 4)
goto end;
232 block[0x18] = temp_block[0x09];
block[0x04] = temp_block[0x02];
233 block[0x09] = temp_block[0x03];
234 if(last_non_zero_p1 <= 7)
goto end;
235 block[0x14] = temp_block[0x0A];
block[0x28] = temp_block[0x11];
236 block[0x12] = temp_block[0x18];
block[0x02] = temp_block[0x20];
237 if(last_non_zero_p1 <= 11)
goto end;
238 block[0x1A] = temp_block[0x19];
block[0x24] = temp_block[0x12];
239 block[0x19] = temp_block[0x0B];
block[0x01] = temp_block[0x04];
240 block[0x0C] = temp_block[0x05];
241 if(last_non_zero_p1 <= 16)
goto end;
242 block[0x11] = temp_block[0x0C];
block[0x29] = temp_block[0x13];
243 block[0x16] = temp_block[0x1A];
block[0x0A] = temp_block[0x21];
244 block[0x30] = temp_block[0x28];
block[0x22] = temp_block[0x30];
245 block[0x38] = temp_block[0x29];
block[0x06] = temp_block[0x22];
246 if(last_non_zero_p1 <= 24)
goto end;
247 block[0x1B] = temp_block[0x1B];
block[0x21] = temp_block[0x14];
248 block[0x1C] = temp_block[0x0D];
block[0x05] = temp_block[0x06];
249 block[0x0D] = temp_block[0x07];
block[0x15] = temp_block[0x0E];
250 block[0x2C] = temp_block[0x15];
block[0x13] = temp_block[0x1C];
251 if(last_non_zero_p1 <= 32)
goto end;
252 block[0x0B] = temp_block[0x23];
block[0x34] = temp_block[0x2A];
253 block[0x2A] = temp_block[0x31];
block[0x32] = temp_block[0x38];
254 block[0x3A] = temp_block[0x39];
block[0x26] = temp_block[0x32];
255 block[0x39] = temp_block[0x2B];
block[0x03] = temp_block[0x24];
256 if(last_non_zero_p1 <= 40)
goto end;
257 block[0x1E] = temp_block[0x1D];
block[0x25] = temp_block[0x16];
258 block[0x1D] = temp_block[0x0F];
block[0x2D] = temp_block[0x17];
259 block[0x17] = temp_block[0x1E];
block[0x0E] = temp_block[0x25];
260 block[0x31] = temp_block[0x2C];
block[0x2B] = temp_block[0x33];
261 if(last_non_zero_p1 <= 48)
goto end;
262 block[0x36] = temp_block[0x3A];
block[0x3B] = temp_block[0x3B];
263 block[0x23] = temp_block[0x34];
block[0x3C] = temp_block[0x2D];
264 block[0x07] = temp_block[0x26];
block[0x1F] = temp_block[0x1F];
265 block[0x0F] = temp_block[0x27];
block[0x35] = temp_block[0x2E];
266 if(last_non_zero_p1 <= 56)
goto end;
267 block[0x2E] = temp_block[0x35];
block[0x33] = temp_block[0x3C];
268 block[0x3E] = temp_block[0x3D];
block[0x27] = temp_block[0x36];
269 block[0x3D] = temp_block[0x2F];
block[0x2F] = temp_block[0x37];
270 block[0x37] = temp_block[0x3E];
block[0x3F] = temp_block[0x3F];
272 if(last_non_zero_p1 <= 1)
goto end;
273 block[0x04] = temp_block[0x01];
274 block[0x08] = temp_block[0x08];
block[0x10] = temp_block[0x10];
275 if(last_non_zero_p1 <= 4)
goto end;
276 block[0x0C] = temp_block[0x09];
block[0x01] = temp_block[0x02];
277 block[0x05] = temp_block[0x03];
278 if(last_non_zero_p1 <= 7)
goto end;
279 block[0x09] = temp_block[0x0A];
block[0x14] = temp_block[0x11];
280 block[0x18] = temp_block[0x18];
block[0x20] = temp_block[0x20];
281 if(last_non_zero_p1 <= 11)
goto end;
282 block[0x1C] = temp_block[0x19];
283 block[0x11] = temp_block[0x12];
block[0x0D] = temp_block[0x0B];
284 block[0x02] = temp_block[0x04];
block[0x06] = temp_block[0x05];
285 if(last_non_zero_p1 <= 16)
goto end;
286 block[0x0A] = temp_block[0x0C];
block[0x15] = temp_block[0x13];
287 block[0x19] = temp_block[0x1A];
block[0x24] = temp_block[0x21];
288 block[0x28] = temp_block[0x28];
block[0x30] = temp_block[0x30];
289 block[0x2C] = temp_block[0x29];
block[0x21] = temp_block[0x22];
290 if(last_non_zero_p1 <= 24)
goto end;
291 block[0x1D] = temp_block[0x1B];
block[0x12] = temp_block[0x14];
292 block[0x0E] = temp_block[0x0D];
block[0x03] = temp_block[0x06];
293 block[0x07] = temp_block[0x07];
block[0x0B] = temp_block[0x0E];
294 block[0x16] = temp_block[0x15];
block[0x1A] = temp_block[0x1C];
295 if(last_non_zero_p1 <= 32)
goto end;
296 block[0x25] = temp_block[0x23];
block[0x29] = temp_block[0x2A];
297 block[0x34] = temp_block[0x31];
block[0x38] = temp_block[0x38];
298 block[0x3C] = temp_block[0x39];
block[0x31] = temp_block[0x32];
299 block[0x2D] = temp_block[0x2B];
block[0x22] = temp_block[0x24];
300 if(last_non_zero_p1 <= 40)
goto end;
301 block[0x1E] = temp_block[0x1D];
block[0x13] = temp_block[0x16];
302 block[0x0F] = temp_block[0x0F];
block[0x17] = temp_block[0x17];
303 block[0x1B] = temp_block[0x1E];
block[0x26] = temp_block[0x25];
304 block[0x2A] = temp_block[0x2C];
block[0x35] = temp_block[0x33];
305 if(last_non_zero_p1 <= 48)
goto end;
306 block[0x39] = temp_block[0x3A];
block[0x3D] = temp_block[0x3B];
307 block[0x32] = temp_block[0x34];
block[0x2E] = temp_block[0x2D];
308 block[0x23] = temp_block[0x26];
block[0x1F] = temp_block[0x1F];
309 block[0x27] = temp_block[0x27];
block[0x2B] = temp_block[0x2E];
310 if(last_non_zero_p1 <= 56)
goto end;
311 block[0x36] = temp_block[0x35];
block[0x3A] = temp_block[0x3C];
312 block[0x3E] = temp_block[0x3D];
block[0x33] = temp_block[0x36];
313 block[0x2F] = temp_block[0x2F];
block[0x37] = temp_block[0x37];
314 block[0x3B] = temp_block[0x3E];
block[0x3F] = temp_block[0x3F];
316 if(last_non_zero_p1 <= 1)
goto end;
317 block[0x01] = temp_block[0x01];
318 block[0x08] = temp_block[0x08];
block[0x10] = temp_block[0x10];
319 if(last_non_zero_p1 <= 4)
goto end;
320 block[0x09] = temp_block[0x09];
block[0x02] = temp_block[0x02];
321 block[0x03] = temp_block[0x03];
322 if(last_non_zero_p1 <= 7)
goto end;
323 block[0x0A] = temp_block[0x0A];
block[0x11] = temp_block[0x11];
324 block[0x18] = temp_block[0x18];
block[0x20] = temp_block[0x20];
325 if(last_non_zero_p1 <= 11)
goto end;
326 block[0x19] = temp_block[0x19];
327 block[0x12] = temp_block[0x12];
block[0x0B] = temp_block[0x0B];
328 block[0x04] = temp_block[0x04];
block[0x05] = temp_block[0x05];
329 if(last_non_zero_p1 <= 16)
goto end;
330 block[0x0C] = temp_block[0x0C];
block[0x13] = temp_block[0x13];
331 block[0x1A] = temp_block[0x1A];
block[0x21] = temp_block[0x21];
332 block[0x28] = temp_block[0x28];
block[0x30] = temp_block[0x30];
333 block[0x29] = temp_block[0x29];
block[0x22] = temp_block[0x22];
334 if(last_non_zero_p1 <= 24)
goto end;
335 block[0x1B] = temp_block[0x1B];
block[0x14] = temp_block[0x14];
336 block[0x0D] = temp_block[0x0D];
block[0x06] = temp_block[0x06];
337 block[0x07] = temp_block[0x07];
block[0x0E] = temp_block[0x0E];
338 block[0x15] = temp_block[0x15];
block[0x1C] = temp_block[0x1C];
339 if(last_non_zero_p1 <= 32)
goto end;
340 block[0x23] = temp_block[0x23];
block[0x2A] = temp_block[0x2A];
341 block[0x31] = temp_block[0x31];
block[0x38] = temp_block[0x38];
342 block[0x39] = temp_block[0x39];
block[0x32] = temp_block[0x32];
343 block[0x2B] = temp_block[0x2B];
block[0x24] = temp_block[0x24];
344 if(last_non_zero_p1 <= 40)
goto end;
345 block[0x1D] = temp_block[0x1D];
block[0x16] = temp_block[0x16];
346 block[0x0F] = temp_block[0x0F];
block[0x17] = temp_block[0x17];
347 block[0x1E] = temp_block[0x1E];
block[0x25] = temp_block[0x25];
348 block[0x2C] = temp_block[0x2C];
block[0x33] = temp_block[0x33];
349 if(last_non_zero_p1 <= 48)
goto end;
350 block[0x3A] = temp_block[0x3A];
block[0x3B] = temp_block[0x3B];
351 block[0x34] = temp_block[0x34];
block[0x2D] = temp_block[0x2D];
352 block[0x26] = temp_block[0x26];
block[0x1F] = temp_block[0x1F];
353 block[0x27] = temp_block[0x27];
block[0x2E] = temp_block[0x2E];
354 if(last_non_zero_p1 <= 56)
goto end;
355 block[0x35] = temp_block[0x35];
block[0x3C] = temp_block[0x3C];
356 block[0x3D] = temp_block[0x3D];
block[0x36] = temp_block[0x36];
357 block[0x2F] = temp_block[0x2F];
block[0x37] = temp_block[0x37];
358 block[0x3E] = temp_block[0x3E];
block[0x3F] = temp_block[0x3F];
360 if(last_non_zero_p1 <= 1)
goto end;
361 block[0x08] = temp_block[0x01];
362 block[0x01] = temp_block[0x08];
block[0x02] = temp_block[0x10];
363 if(last_non_zero_p1 <= 4)
goto end;
364 block[0x09] = temp_block[0x09];
block[0x10] = temp_block[0x02];
365 block[0x18] = temp_block[0x03];
366 if(last_non_zero_p1 <= 7)
goto end;
367 block[0x11] = temp_block[0x0A];
block[0x0A] = temp_block[0x11];
368 block[0x03] = temp_block[0x18];
block[0x04] = temp_block[0x20];
369 if(last_non_zero_p1 <= 11)
goto end;
370 block[0x0B] = temp_block[0x19];
371 block[0x12] = temp_block[0x12];
block[0x19] = temp_block[0x0B];
372 block[0x20] = temp_block[0x04];
block[0x28] = temp_block[0x05];
373 if(last_non_zero_p1 <= 16)
goto end;
374 block[0x21] = temp_block[0x0C];
block[0x1A] = temp_block[0x13];
375 block[0x13] = temp_block[0x1A];
block[0x0C] = temp_block[0x21];
376 block[0x05] = temp_block[0x28];
block[0x06] = temp_block[0x30];
377 block[0x0D] = temp_block[0x29];
block[0x14] = temp_block[0x22];
378 if(last_non_zero_p1 <= 24)
goto end;
379 block[0x1B] = temp_block[0x1B];
block[0x22] = temp_block[0x14];
380 block[0x29] = temp_block[0x0D];
block[0x30] = temp_block[0x06];
381 block[0x38] = temp_block[0x07];
block[0x31] = temp_block[0x0E];
382 block[0x2A] = temp_block[0x15];
block[0x23] = temp_block[0x1C];
383 if(last_non_zero_p1 <= 32)
goto end;
384 block[0x1C] = temp_block[0x23];
block[0x15] = temp_block[0x2A];
385 block[0x0E] = temp_block[0x31];
block[0x07] = temp_block[0x38];
386 block[0x0F] = temp_block[0x39];
block[0x16] = temp_block[0x32];
387 block[0x1D] = temp_block[0x2B];
block[0x24] = temp_block[0x24];
388 if(last_non_zero_p1 <= 40)
goto end;
389 block[0x2B] = temp_block[0x1D];
block[0x32] = temp_block[0x16];
390 block[0x39] = temp_block[0x0F];
block[0x3A] = temp_block[0x17];
391 block[0x33] = temp_block[0x1E];
block[0x2C] = temp_block[0x25];
392 block[0x25] = temp_block[0x2C];
block[0x1E] = temp_block[0x33];
393 if(last_non_zero_p1 <= 48)
goto end;
394 block[0x17] = temp_block[0x3A];
block[0x1F] = temp_block[0x3B];
395 block[0x26] = temp_block[0x34];
block[0x2D] = temp_block[0x2D];
396 block[0x34] = temp_block[0x26];
block[0x3B] = temp_block[0x1F];
397 block[0x3C] = temp_block[0x27];
block[0x35] = temp_block[0x2E];
398 if(last_non_zero_p1 <= 56)
goto end;
399 block[0x2E] = temp_block[0x35];
block[0x27] = temp_block[0x3C];
400 block[0x2F] = temp_block[0x3D];
block[0x36] = temp_block[0x36];
401 block[0x3D] = temp_block[0x2F];
block[0x3E] = temp_block[0x37];
402 block[0x37] = temp_block[0x3E];
block[0x3F] = temp_block[0x3F];
405 (
int)
s->idsp.perm_type);
412 return last_non_zero_p1 - 1;