comparison postprocess_template.c @ 32:cb746db3fd32 libpostproc

Rename ABS macro to FFABS.
author diego
date Wed, 11 Oct 2006 23:17:58 +0000
parents 81ad3274583c
children 63d07317cd7a
comparison
equal deleted inserted replaced
31:81ad3274583c 32:cb746db3fd32
336 const int l9= stride + l8; 336 const int l9= stride + l8;
337 int x; 337 int x;
338 src+= stride*3; 338 src+= stride*3;
339 for(x=0; x<BLOCK_SIZE; x++) 339 for(x=0; x<BLOCK_SIZE; x++)
340 { 340 {
341 const int first= ABS(src[0] - src[l1]) < c->QP ? src[0] : src[l1]; 341 const int first= FFABS(src[0] - src[l1]) < c->QP ? src[0] : src[l1];
342 const int last= ABS(src[l8] - src[l9]) < c->QP ? src[l9] : src[l8]; 342 const int last= FFABS(src[l8] - src[l9]) < c->QP ? src[l9] : src[l8];
343 343
344 int sums[10]; 344 int sums[10];
345 sums[0] = 4*first + src[l1] + src[l2] + src[l3] + 4; 345 sums[0] = 4*first + src[l1] + src[l2] + src[l3] + 4;
346 sums[1] = sums[0] - first + src[l4]; 346 sums[1] = sums[0] - first + src[l4];
347 sums[2] = sums[1] - first + src[l5]; 347 sums[2] = sums[1] - first + src[l5];
458 const int QP15= QP + (QP>>2); 458 const int QP15= QP + (QP>>2);
459 src+= stride*3; 459 src+= stride*3;
460 for(x=0; x<BLOCK_SIZE; x++) 460 for(x=0; x<BLOCK_SIZE; x++)
461 { 461 {
462 const int v = (src[x+l5] - src[x+l4]); 462 const int v = (src[x+l5] - src[x+l4]);
463 if(ABS(v) < QP15) 463 if(FFABS(v) < QP15)
464 { 464 {
465 src[x+l3] +=v>>3; 465 src[x+l3] +=v>>3;
466 src[x+l4] +=v>>1; 466 src[x+l4] +=v>>1;
467 src[x+l5] -=v>>1; 467 src[x+l5] -=v>>1;
468 src[x+l6] -=v>>3; 468 src[x+l6] -=v>>3;
587 { 587 {
588 int a= src[l3] - src[l4]; 588 int a= src[l3] - src[l4];
589 int b= src[l4] - src[l5]; 589 int b= src[l4] - src[l5];
590 int c= src[l5] - src[l6]; 590 int c= src[l5] - src[l6];
591 591
592 int d= ABS(b) - ((ABS(a) + ABS(c))>>1); 592 int d= FFABS(b) - ((FFABS(a) + FFABS(c))>>1);
593 d= FFMAX(d, 0); 593 d= FFMAX(d, 0);
594 594
595 if(d < co->QP*2) 595 if(d < co->QP*2)
596 { 596 {
597 int v = d * FFSIGN(-b); 597 int v = d * FFSIGN(-b);
843 int x; 843 int x;
844 src-= stride; 844 src-= stride;
845 for(x=0; x<BLOCK_SIZE; x++) 845 for(x=0; x<BLOCK_SIZE; x++)
846 { 846 {
847 const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]); 847 const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]);
848 if(ABS(middleEnergy)< 8*QP) 848 if(FFABS(middleEnergy)< 8*QP)
849 { 849 {
850 const int q=(src[l4] - src[l5])/2; 850 const int q=(src[l4] - src[l5])/2;
851 const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]); 851 const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]);
852 const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]); 852 const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]);
853 853
854 int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) ); 854 int d= FFABS(middleEnergy) - FFMIN( FFABS(leftEnergy), FFABS(rightEnergy) );
855 d= FFMAX(d, 0); 855 d= FFMAX(d, 0);
856 856
857 d= (5*d + 32) >> 6; 857 d= (5*d + 32) >> 6;
858 d*= FFSIGN(-middleEnergy); 858 d*= FFSIGN(-middleEnergy);
859 859
878 { 878 {
879 int y; 879 int y;
880 for(y=4; y<6; y++) 880 for(y=4; y<6; y++)
881 { 881 {
882 int d= src[x+y*stride] - tmp[x+(y-4)*8]; 882 int d= src[x+y*stride] - tmp[x+(y-4)*8];
883 int ad= ABS(d); 883 int ad= FFABS(d);
884 static int max=0; 884 static int max=0;
885 static int sum=0; 885 static int sum=0;
886 static int num=0; 886 static int num=0;
887 static int bias=0; 887 static int bias=0;
888 888
1147 int x; 1147 int x;
1148 src+= stride*3; 1148 src+= stride*3;
1149 for(x=0; x<BLOCK_SIZE; x++) 1149 for(x=0; x<BLOCK_SIZE; x++)
1150 { 1150 {
1151 const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]); 1151 const int middleEnergy= 5*(src[l5] - src[l4]) + 2*(src[l3] - src[l6]);
1152 if(ABS(middleEnergy) < 8*c->QP) 1152 if(FFABS(middleEnergy) < 8*c->QP)
1153 { 1153 {
1154 const int q=(src[l4] - src[l5])/2; 1154 const int q=(src[l4] - src[l5])/2;
1155 const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]); 1155 const int leftEnergy= 5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]);
1156 const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]); 1156 const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]);
1157 1157
1158 int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) ); 1158 int d= FFABS(middleEnergy) - FFMIN( FFABS(leftEnergy), FFABS(rightEnergy) );
1159 d= FFMAX(d, 0); 1159 d= FFMAX(d, 0);
1160 1160
1161 d= (5*d + 32) >> 6; 1161 d= (5*d + 32) >> 6;
1162 d*= FFSIGN(-middleEnergy); 1162 d*= FFSIGN(-middleEnergy);
1163 1163
1489 static int errorSum=0; 1489 static int errorSum=0;
1490 static int worstQP=0; 1490 static int worstQP=0;
1491 static int worstRange=0; 1491 static int worstRange=0;
1492 static int worstDiff=0; 1492 static int worstDiff=0;
1493 int diff= (f - *p); 1493 int diff= (f - *p);
1494 int absDiff= ABS(diff); 1494 int absDiff= FFABS(diff);
1495 int error= diff*diff; 1495 int error= diff*diff;
1496 1496
1497 if(x==1 || x==8 || y==1 || y==8) continue; 1497 if(x==1 || x==8 || y==1 || y==8) continue;
1498 1498
1499 numSkiped++; 1499 numSkiped++;
2550 int ref= tempBlured[ x + y*stride ]; 2550 int ref= tempBlured[ x + y*stride ];
2551 int cur= src[ x + y*stride ]; 2551 int cur= src[ x + y*stride ];
2552 int d1=ref - cur; 2552 int d1=ref - cur;
2553 // if(x==0 || x==7) d1+= d1>>1; 2553 // if(x==0 || x==7) d1+= d1>>1;
2554 // if(y==0 || y==7) d1+= d1>>1; 2554 // if(y==0 || y==7) d1+= d1>>1;
2555 // d+= ABS(d1); 2555 // d+= FFABS(d1);
2556 d+= d1*d1; 2556 d+= d1*d1;
2557 // sysd+= d1; 2557 // sysd+= d1;
2558 } 2558 }
2559 } 2559 }
2560 i=d; 2560 i=d;
3527 RENAME(deInterlaceBlendCubic)(dstBlock, dstStride); 3527 RENAME(deInterlaceBlendCubic)(dstBlock, dstStride);
3528 */ 3528 */
3529 dstBlock+=8; 3529 dstBlock+=8;
3530 srcBlock+=8; 3530 srcBlock+=8;
3531 } 3531 }
3532 if(width==ABS(dstStride)) 3532 if(width==FFABS(dstStride))
3533 linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride); 3533 linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride);
3534 else 3534 else
3535 { 3535 {
3536 int i; 3536 int i;
3537 for(i=0; i<copyAhead; i++) 3537 for(i=0; i<copyAhead; i++)
3549 #ifdef HAVE_MMX 3549 #ifdef HAVE_MMX
3550 uint8_t *tempBlock1= c.tempBlocks; 3550 uint8_t *tempBlock1= c.tempBlocks;
3551 uint8_t *tempBlock2= c.tempBlocks + 8; 3551 uint8_t *tempBlock2= c.tempBlocks + 8;
3552 #endif 3552 #endif
3553 int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride]; 3553 int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride];
3554 int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*ABS(QPStride)]; 3554 int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)];
3555 int QP=0; 3555 int QP=0;
3556 /* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards 3556 /* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards
3557 if not than use a temporary buffer */ 3557 if not than use a temporary buffer */
3558 if(y+15 >= height) 3558 if(y+15 >= height)
3559 { 3559 {
3563 linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead, 3563 linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,
3564 FFMAX(height-y-copyAhead, 0), srcStride); 3564 FFMAX(height-y-copyAhead, 0), srcStride);
3565 3565
3566 /* duplicate last line of src to fill the void upto line (copyAhead+7) */ 3566 /* duplicate last line of src to fill the void upto line (copyAhead+7) */
3567 for(i=FFMAX(height-y, 8); i<copyAhead+8; i++) 3567 for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)
3568 memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), ABS(srcStride)); 3568 memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride));
3569 3569
3570 /* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/ 3570 /* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/
3571 linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride); 3571 linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);
3572 3572
3573 /* duplicate last line of dst to fill the void upto line (copyAhead) */ 3573 /* duplicate last line of dst to fill the void upto line (copyAhead) */
3574 for(i=height-y+1; i<=copyAhead; i++) 3574 for(i=height-y+1; i<=copyAhead; i++)
3575 memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), ABS(dstStride)); 3575 memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride));
3576 3576
3577 dstBlock= tempDst + dstStride; 3577 dstBlock= tempDst + dstStride;
3578 srcBlock= tempSrc; 3578 srcBlock= tempSrc;
3579 } 3579 }
3580 3580
3781 3781
3782 /* did we use a tmp buffer for the last lines*/ 3782 /* did we use a tmp buffer for the last lines*/
3783 if(y+15 >= height) 3783 if(y+15 >= height)
3784 { 3784 {
3785 uint8_t *dstBlock= &(dst[y*dstStride]); 3785 uint8_t *dstBlock= &(dst[y*dstStride]);
3786 if(width==ABS(dstStride)) 3786 if(width==FFABS(dstStride))
3787 linecpy(dstBlock, tempDst + dstStride, height-y, dstStride); 3787 linecpy(dstBlock, tempDst + dstStride, height-y, dstStride);
3788 else 3788 else
3789 { 3789 {
3790 int i; 3790 int i;
3791 for(i=0; i<height-y; i++) 3791 for(i=0; i<height-y; i++)