comparison h264.c @ 8440:649ce1b30344 libavcodec

Optimize 0 0 0-3 search, 45% faster on pentium dual.
author michael
date Tue, 23 Dec 2008 00:38:45 +0000
parents 89f7279e1eaa
children f97c423dcb7f
comparison
equal deleted inserted replaced
8439:c5302e0ecf4e 8440:649ce1b30344
1373 src++; length--; 1373 src++; length--;
1374 #if 0 1374 #if 0
1375 for(i=0; i<length; i++) 1375 for(i=0; i<length; i++)
1376 printf("%2X ", src[i]); 1376 printf("%2X ", src[i]);
1377 #endif 1377 #endif
1378
1379 #ifdef HAVE_FAST_UNALIGNED
1380 # ifdef HAVE_FAST_64BIT
1381 # define RS 7
1382 for(i=0; i+1<length; i+=9){
1383 if(!((~*(uint64_t*)(src+i) & (*(uint64_t*)(src+i) - 0x0100010001000101ULL)) & 0x8000800080008080ULL))
1384 # else
1385 # define RS 3
1386 for(i=0; i+1<length; i+=5){
1387 if(!((~*(uint32_t*)(src+i) & (*(uint32_t*)(src+i) - 0x01000101U)) & 0x80008080U))
1388 # endif
1389 continue;
1390 if(i>0 && !src[i]) i--;
1391 while(src[i]) i++;
1392 #else
1393 # define RS 0
1378 for(i=0; i+1<length; i+=2){ 1394 for(i=0; i+1<length; i+=2){
1379 if(src[i]) continue; 1395 if(src[i]) continue;
1380 if(i>0 && src[i-1]==0) i--; 1396 if(i>0 && src[i-1]==0) i--;
1397 #endif
1381 if(i+2<length && src[i+1]==0 && src[i+2]<=3){ 1398 if(i+2<length && src[i+1]==0 && src[i+2]<=3){
1382 if(src[i+2]!=3){ 1399 if(src[i+2]!=3){
1383 /* startcode, so we must be past the end */ 1400 /* startcode, so we must be past the end */
1384 length=i; 1401 length=i;
1385 } 1402 }