40 #if COMPILE_TEMPLATE_SSE2
41 #define MMREG_WIDTH "16"
45 "pshuflw $0, "a", "a" \n\t"\
46 "punpcklwd "a", "a" \n\t"
47 #define PMAXW(a,b) "pmaxsw "a", "b" \n\t"
49 "movhlps "a", "b" \n\t"\
51 "pshuflw $0x0E, "a", "b" \n\t"\
53 "pshuflw $0x01, "a", "b" \n\t"\
56 #define MMREG_WIDTH "8"
59 #if COMPILE_TEMPLATE_MMXEXT
60 #define SPREADW(a) "pshufw $0, "a", "a" \n\t"
61 #define PMAXW(a,b) "pmaxsw "a", "b" \n\t"
63 "pshufw $0x0E, "a", "b" \n\t"\
65 "pshufw $0x01, "a", "b" \n\t"\
69 "punpcklwd "a", "a" \n\t"\
70 "punpcklwd "a", "a" \n\t"
72 "psubusw "a", "b" \n\t"\
76 "psrlq $32, "a" \n\t"\
79 "psrlq $16, "a" \n\t"\
85 #if COMPILE_TEMPLATE_SSSE3
86 #define SAVE_SIGN(a,b) \
87 "movdqa "b", "a" \n\t"\
89 #define RESTORE_SIGN(a,b) \
90 "psignw "a", "b" \n\t"
92 #define SAVE_SIGN(a,b) \
94 "pcmpgtw "b", "a" \n\t" \
97 #define RESTORE_SIGN(a,b) \
99 "psubw "a", "b" \n\t" // out=((ABS(block[i])*qmat[0] - bias[0]*qmat[0])>>16)*sign(block[i])
104 int qscale,
int *overflow)
108 const uint16_t *qmat, *bias;
114 RENAME_FDCT(ff_fdct)(
block);
123 bias =
s->q_intra_matrix16[qscale][1];
124 qmat =
s->q_intra_matrix16[qscale][0];
127 bias =
s->q_chroma_intra_matrix16[qscale][1];
128 qmat =
s->q_chroma_intra_matrix16[qscale][0];
134 :
"=d" (
level),
"=a"(dummy)
139 level = (
block[0] + 4)>>3;
143 last_non_zero_p1 = 1;
145 last_non_zero_p1 = 0;
146 bias =
s->q_inter_matrix16[qscale][1];
147 qmat =
s->q_inter_matrix16[qscale][0];
153 "movd %%"FF_REG_a
", "MM"3 \n\t"
155 "pxor "MM"7, "MM"7 \n\t"
156 "pxor "MM"4, "MM"4 \n\t"
158 "pxor "MM"6, "MM"6 \n\t"
159 "psubw (%3), "MM"6 \n\t"
160 "mov $-128, %%"FF_REG_a
" \n\t"
163 MOVQ" (%1, %%"FF_REG_a
"), "MM"0 \n\t"
165 "psubusw "MM"6, "MM"0 \n\t"
166 "pmulhw "MM"5, "MM"0 \n\t"
167 "por "MM"0, "MM"4 \n\t"
169 MOVQ" "MM"0, (%5, %%"FF_REG_a
") \n\t"
170 "pcmpeqw "MM"7, "MM"0 \n\t"
171 MOVQ" (%4, %%"FF_REG_a
"), "MM"1 \n\t"
172 MOVQ" "MM"7, (%1, %%"FF_REG_a
") \n\t"
173 "pandn "MM"1, "MM"0 \n\t"
178 "movd "MM"3, %%"FF_REG_a
" \n\t"
179 "movzbl %%al, %%eax \n\t"
180 :
"+a" (last_non_zero_p1)
181 :
"r" (
block+64),
"r" (qmat),
"r" (bias),
184 "%xmm4",
"%xmm5",
"%xmm6",
"%xmm7")
188 "movd %%"FF_REG_a
", "MM"3 \n\t"
190 "pxor "MM"7, "MM"7 \n\t"
191 "pxor "MM"4, "MM"4 \n\t"
192 "mov $-128, %%"FF_REG_a
" \n\t"
195 MOVQ" (%1, %%"FF_REG_a
"), "MM"0 \n\t"
197 MOVQ" (%3, %%"FF_REG_a
"), "MM"6 \n\t"
198 "paddusw "MM"6, "MM"0 \n\t"
199 MOVQ" (%2, %%"FF_REG_a
"), "MM"5 \n\t"
200 "pmulhw "MM"5, "MM"0 \n\t"
201 "por "MM"0, "MM"4 \n\t"
203 MOVQ" "MM"0, (%5, %%"FF_REG_a
") \n\t"
204 "pcmpeqw "MM"7, "MM"0 \n\t"
205 MOVQ" (%4, %%"FF_REG_a
"), "MM"1 \n\t"
206 MOVQ" "MM"7, (%1, %%"FF_REG_a
") \n\t"
207 "pandn "MM"1, "MM"0 \n\t"
212 "movd "MM"3, %%"FF_REG_a
" \n\t"
213 "movzbl %%al, %%eax \n\t"
214 :
"+a" (last_non_zero_p1)
215 :
"r" (
block+64),
"r" (qmat+64),
"r" (bias+64),
218 "%xmm4",
"%xmm5",
"%xmm6",
"%xmm7")
222 "movd %1, "MM"1 \n\t"
224 "psubusw "MM"1, "MM"4 \n\t"
225 "packuswb "MM"4, "MM"4 \n\t"
226 #if COMPILE_TEMPLATE_SSE2
227 "packsswb "MM"4, "MM"4 \n\t"
229 "movd "MM"4, %0 \n\t"
231 :
"g" (
s->max_qcoeff)
235 else block[0]= temp_block[0];
238 if(last_non_zero_p1 <= 1)
goto end;
239 block[0x08] = temp_block[0x01];
block[0x10] = temp_block[0x08];
240 block[0x20] = temp_block[0x10];
241 if(last_non_zero_p1 <= 4)
goto end;
242 block[0x18] = temp_block[0x09];
block[0x04] = temp_block[0x02];
243 block[0x09] = temp_block[0x03];
244 if(last_non_zero_p1 <= 7)
goto end;
245 block[0x14] = temp_block[0x0A];
block[0x28] = temp_block[0x11];
246 block[0x12] = temp_block[0x18];
block[0x02] = temp_block[0x20];
247 if(last_non_zero_p1 <= 11)
goto end;
248 block[0x1A] = temp_block[0x19];
block[0x24] = temp_block[0x12];
249 block[0x19] = temp_block[0x0B];
block[0x01] = temp_block[0x04];
250 block[0x0C] = temp_block[0x05];
251 if(last_non_zero_p1 <= 16)
goto end;
252 block[0x11] = temp_block[0x0C];
block[0x29] = temp_block[0x13];
253 block[0x16] = temp_block[0x1A];
block[0x0A] = temp_block[0x21];
254 block[0x30] = temp_block[0x28];
block[0x22] = temp_block[0x30];
255 block[0x38] = temp_block[0x29];
block[0x06] = temp_block[0x22];
256 if(last_non_zero_p1 <= 24)
goto end;
257 block[0x1B] = temp_block[0x1B];
block[0x21] = temp_block[0x14];
258 block[0x1C] = temp_block[0x0D];
block[0x05] = temp_block[0x06];
259 block[0x0D] = temp_block[0x07];
block[0x15] = temp_block[0x0E];
260 block[0x2C] = temp_block[0x15];
block[0x13] = temp_block[0x1C];
261 if(last_non_zero_p1 <= 32)
goto end;
262 block[0x0B] = temp_block[0x23];
block[0x34] = temp_block[0x2A];
263 block[0x2A] = temp_block[0x31];
block[0x32] = temp_block[0x38];
264 block[0x3A] = temp_block[0x39];
block[0x26] = temp_block[0x32];
265 block[0x39] = temp_block[0x2B];
block[0x03] = temp_block[0x24];
266 if(last_non_zero_p1 <= 40)
goto end;
267 block[0x1E] = temp_block[0x1D];
block[0x25] = temp_block[0x16];
268 block[0x1D] = temp_block[0x0F];
block[0x2D] = temp_block[0x17];
269 block[0x17] = temp_block[0x1E];
block[0x0E] = temp_block[0x25];
270 block[0x31] = temp_block[0x2C];
block[0x2B] = temp_block[0x33];
271 if(last_non_zero_p1 <= 48)
goto end;
272 block[0x36] = temp_block[0x3A];
block[0x3B] = temp_block[0x3B];
273 block[0x23] = temp_block[0x34];
block[0x3C] = temp_block[0x2D];
274 block[0x07] = temp_block[0x26];
block[0x1F] = temp_block[0x1F];
275 block[0x0F] = temp_block[0x27];
block[0x35] = temp_block[0x2E];
276 if(last_non_zero_p1 <= 56)
goto end;
277 block[0x2E] = temp_block[0x35];
block[0x33] = temp_block[0x3C];
278 block[0x3E] = temp_block[0x3D];
block[0x27] = temp_block[0x36];
279 block[0x3D] = temp_block[0x2F];
block[0x2F] = temp_block[0x37];
280 block[0x37] = temp_block[0x3E];
block[0x3F] = temp_block[0x3F];
282 if(last_non_zero_p1 <= 1)
goto end;
283 block[0x04] = temp_block[0x01];
284 block[0x08] = temp_block[0x08];
block[0x10] = temp_block[0x10];
285 if(last_non_zero_p1 <= 4)
goto end;
286 block[0x0C] = temp_block[0x09];
block[0x01] = temp_block[0x02];
287 block[0x05] = temp_block[0x03];
288 if(last_non_zero_p1 <= 7)
goto end;
289 block[0x09] = temp_block[0x0A];
block[0x14] = temp_block[0x11];
290 block[0x18] = temp_block[0x18];
block[0x20] = temp_block[0x20];
291 if(last_non_zero_p1 <= 11)
goto end;
292 block[0x1C] = temp_block[0x19];
293 block[0x11] = temp_block[0x12];
block[0x0D] = temp_block[0x0B];
294 block[0x02] = temp_block[0x04];
block[0x06] = temp_block[0x05];
295 if(last_non_zero_p1 <= 16)
goto end;
296 block[0x0A] = temp_block[0x0C];
block[0x15] = temp_block[0x13];
297 block[0x19] = temp_block[0x1A];
block[0x24] = temp_block[0x21];
298 block[0x28] = temp_block[0x28];
block[0x30] = temp_block[0x30];
299 block[0x2C] = temp_block[0x29];
block[0x21] = temp_block[0x22];
300 if(last_non_zero_p1 <= 24)
goto end;
301 block[0x1D] = temp_block[0x1B];
block[0x12] = temp_block[0x14];
302 block[0x0E] = temp_block[0x0D];
block[0x03] = temp_block[0x06];
303 block[0x07] = temp_block[0x07];
block[0x0B] = temp_block[0x0E];
304 block[0x16] = temp_block[0x15];
block[0x1A] = temp_block[0x1C];
305 if(last_non_zero_p1 <= 32)
goto end;
306 block[0x25] = temp_block[0x23];
block[0x29] = temp_block[0x2A];
307 block[0x34] = temp_block[0x31];
block[0x38] = temp_block[0x38];
308 block[0x3C] = temp_block[0x39];
block[0x31] = temp_block[0x32];
309 block[0x2D] = temp_block[0x2B];
block[0x22] = temp_block[0x24];
310 if(last_non_zero_p1 <= 40)
goto end;
311 block[0x1E] = temp_block[0x1D];
block[0x13] = temp_block[0x16];
312 block[0x0F] = temp_block[0x0F];
block[0x17] = temp_block[0x17];
313 block[0x1B] = temp_block[0x1E];
block[0x26] = temp_block[0x25];
314 block[0x2A] = temp_block[0x2C];
block[0x35] = temp_block[0x33];
315 if(last_non_zero_p1 <= 48)
goto end;
316 block[0x39] = temp_block[0x3A];
block[0x3D] = temp_block[0x3B];
317 block[0x32] = temp_block[0x34];
block[0x2E] = temp_block[0x2D];
318 block[0x23] = temp_block[0x26];
block[0x1F] = temp_block[0x1F];
319 block[0x27] = temp_block[0x27];
block[0x2B] = temp_block[0x2E];
320 if(last_non_zero_p1 <= 56)
goto end;
321 block[0x36] = temp_block[0x35];
block[0x3A] = temp_block[0x3C];
322 block[0x3E] = temp_block[0x3D];
block[0x33] = temp_block[0x36];
323 block[0x2F] = temp_block[0x2F];
block[0x37] = temp_block[0x37];
324 block[0x3B] = temp_block[0x3E];
block[0x3F] = temp_block[0x3F];
326 if(last_non_zero_p1 <= 1)
goto end;
327 block[0x01] = temp_block[0x01];
328 block[0x08] = temp_block[0x08];
block[0x10] = temp_block[0x10];
329 if(last_non_zero_p1 <= 4)
goto end;
330 block[0x09] = temp_block[0x09];
block[0x02] = temp_block[0x02];
331 block[0x03] = temp_block[0x03];
332 if(last_non_zero_p1 <= 7)
goto end;
333 block[0x0A] = temp_block[0x0A];
block[0x11] = temp_block[0x11];
334 block[0x18] = temp_block[0x18];
block[0x20] = temp_block[0x20];
335 if(last_non_zero_p1 <= 11)
goto end;
336 block[0x19] = temp_block[0x19];
337 block[0x12] = temp_block[0x12];
block[0x0B] = temp_block[0x0B];
338 block[0x04] = temp_block[0x04];
block[0x05] = temp_block[0x05];
339 if(last_non_zero_p1 <= 16)
goto end;
340 block[0x0C] = temp_block[0x0C];
block[0x13] = temp_block[0x13];
341 block[0x1A] = temp_block[0x1A];
block[0x21] = temp_block[0x21];
342 block[0x28] = temp_block[0x28];
block[0x30] = temp_block[0x30];
343 block[0x29] = temp_block[0x29];
block[0x22] = temp_block[0x22];
344 if(last_non_zero_p1 <= 24)
goto end;
345 block[0x1B] = temp_block[0x1B];
block[0x14] = temp_block[0x14];
346 block[0x0D] = temp_block[0x0D];
block[0x06] = temp_block[0x06];
347 block[0x07] = temp_block[0x07];
block[0x0E] = temp_block[0x0E];
348 block[0x15] = temp_block[0x15];
block[0x1C] = temp_block[0x1C];
349 if(last_non_zero_p1 <= 32)
goto end;
350 block[0x23] = temp_block[0x23];
block[0x2A] = temp_block[0x2A];
351 block[0x31] = temp_block[0x31];
block[0x38] = temp_block[0x38];
352 block[0x39] = temp_block[0x39];
block[0x32] = temp_block[0x32];
353 block[0x2B] = temp_block[0x2B];
block[0x24] = temp_block[0x24];
354 if(last_non_zero_p1 <= 40)
goto end;
355 block[0x1D] = temp_block[0x1D];
block[0x16] = temp_block[0x16];
356 block[0x0F] = temp_block[0x0F];
block[0x17] = temp_block[0x17];
357 block[0x1E] = temp_block[0x1E];
block[0x25] = temp_block[0x25];
358 block[0x2C] = temp_block[0x2C];
block[0x33] = temp_block[0x33];
359 if(last_non_zero_p1 <= 48)
goto end;
360 block[0x3A] = temp_block[0x3A];
block[0x3B] = temp_block[0x3B];
361 block[0x34] = temp_block[0x34];
block[0x2D] = temp_block[0x2D];
362 block[0x26] = temp_block[0x26];
block[0x1F] = temp_block[0x1F];
363 block[0x27] = temp_block[0x27];
block[0x2E] = temp_block[0x2E];
364 if(last_non_zero_p1 <= 56)
goto end;
365 block[0x35] = temp_block[0x35];
block[0x3C] = temp_block[0x3C];
366 block[0x3D] = temp_block[0x3D];
block[0x36] = temp_block[0x36];
367 block[0x2F] = temp_block[0x2F];
block[0x37] = temp_block[0x37];
368 block[0x3E] = temp_block[0x3E];
block[0x3F] = temp_block[0x3F];
371 return last_non_zero_p1 - 1;
static uint16_t inv_zigzag_direct16[64]
const uint32_t ff_inverse[257]
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static av_cold int end(AVCodecContext *avctx)
#define RESTORE_SIGN(a, b)
common internal API header
#define XMM_CLOBBERS_ONLY(...)
#define LOCAL_ALIGNED_16(t, v,...)