Mercurial > libavcodec.hg
comparison cabac.h @ 3948:3edbf131ee44 libavcodec
refill cabac variables in 16bit steps, 3% faster get_cabac()
author | michael |
---|---|
date | Sat, 07 Oct 2006 15:44:14 +0000 |
parents | c8c591fe26f8 |
children | 900d21b85dd6 |
comparison
equal
deleted
inserted
replaced
3947:c8c591fe26f8 | 3948:3edbf131ee44 |
---|---|
27 | 27 |
28 | 28 |
29 //#undef NDEBUG | 29 //#undef NDEBUG |
30 #include <assert.h> | 30 #include <assert.h> |
31 | 31 |
32 #define CABAC_BITS 8 | 32 #define CABAC_BITS 16 |
33 #define CABAC_MASK ((1<<CABAC_BITS)-1) | 33 #define CABAC_MASK ((1<<CABAC_BITS)-1) |
34 | 34 |
35 typedef struct CABACContext{ | 35 typedef struct CABACContext{ |
36 int low; | 36 int low; |
37 int range; | 37 int range; |
300 #ifdef ARCH_X86 | 300 #ifdef ARCH_X86 |
301 int temp; | 301 int temp; |
302 #if 0 | 302 #if 0 |
303 //P3:683 | 303 //P3:683 |
304 asm( | 304 asm( |
305 "lea -0x20000(%0), %2 \n\t" | 305 "lea -0x2000000(%0), %2 \n\t" |
306 "shr $31, %2 \n\t" //FIXME 31->63 for x86-64 | 306 "shr $31, %2 \n\t" //FIXME 31->63 for x86-64 |
307 "shl %%cl, %0 \n\t" | 307 "shl %%cl, %0 \n\t" |
308 "shl %%cl, %1 \n\t" | 308 "shl %%cl, %1 \n\t" |
309 : "+r"(c->range), "+r"(c->low), "+c"(temp) | 309 : "+r"(c->range), "+r"(c->low), "+c"(temp) |
310 ); | 310 ); |
311 #elif 0 | 311 #elif 0 |
312 //P3:680 | 312 //P3:680 |
313 asm( | 313 asm( |
314 "cmp $0x20000, %0 \n\t" | 314 "cmp $0x2000000, %0 \n\t" |
315 "setb %%cl \n\t" //FIXME 31->63 for x86-64 | 315 "setb %%cl \n\t" //FIXME 31->63 for x86-64 |
316 "shl %%cl, %0 \n\t" | 316 "shl %%cl, %0 \n\t" |
317 "shl %%cl, %1 \n\t" | 317 "shl %%cl, %1 \n\t" |
318 : "+r"(c->range), "+r"(c->low), "+c"(temp) | 318 : "+r"(c->range), "+r"(c->low), "+c"(temp) |
319 ); | 319 ); |
320 #elif 1 | 320 #elif 1 |
321 int temp2; | 321 int temp2; |
322 //P3:665 | 322 //P3:665 |
323 asm( | 323 asm( |
324 "lea -0x20000(%0), %%eax \n\t" | 324 "lea -0x2000000(%0), %%eax \n\t" |
325 "cdq \n\t" | 325 "cdq \n\t" |
326 "mov %0, %%eax \n\t" | 326 "mov %0, %%eax \n\t" |
327 "and %%edx, %0 \n\t" | 327 "and %%edx, %0 \n\t" |
328 "and %1, %%edx \n\t" | 328 "and %1, %%edx \n\t" |
329 "add %%eax, %0 \n\t" | 329 "add %%eax, %0 \n\t" |
332 ); | 332 ); |
333 #elif 0 | 333 #elif 0 |
334 int temp2; | 334 int temp2; |
335 //P3:673 | 335 //P3:673 |
336 asm( | 336 asm( |
337 "cmp $0x20000, %0 \n\t" | 337 "cmp $0x2000000, %0 \n\t" |
338 "sbb %%edx, %%edx \n\t" | 338 "sbb %%edx, %%edx \n\t" |
339 "mov %0, %%eax \n\t" | 339 "mov %0, %%eax \n\t" |
340 "and %%edx, %0 \n\t" | 340 "and %%edx, %0 \n\t" |
341 "and %1, %%edx \n\t" | 341 "and %1, %%edx \n\t" |
342 "add %%eax, %0 \n\t" | 342 "add %%eax, %0 \n\t" |
345 ); | 345 ); |
346 #else | 346 #else |
347 int temp2; | 347 int temp2; |
348 //P3:677 | 348 //P3:677 |
349 asm( | 349 asm( |
350 "cmp $0x20000, %0 \n\t" | 350 "cmp $0x2000000, %0 \n\t" |
351 "lea (%0, %0), %%eax \n\t" | 351 "lea (%0, %0), %%eax \n\t" |
352 "lea (%1, %1), %%edx \n\t" | 352 "lea (%1, %1), %%edx \n\t" |
353 "cmovb %%eax, %0 \n\t" | 353 "cmovb %%eax, %0 \n\t" |
354 "cmovb %%edx, %1 \n\t" | 354 "cmovb %%edx, %1 \n\t" |
355 : "+r"(c->range), "+r"(c->low), "+a"(temp), "+d"(temp2) | 355 : "+r"(c->range), "+r"(c->low), "+a"(temp), "+d"(temp2) |