Mercurial > mplayer.hg
changeset 2477:830c0e171d7d
dering in c
dering bugfix
author | michael |
---|---|
date | Fri, 26 Oct 2001 00:35:41 +0000 |
parents | a6c5a537f30a |
children | 42d5846eeb51 |
files | postproc/postprocess.c postproc/postprocess_template.c |
diffstat | 2 files changed, 172 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/postproc/postprocess.c Thu Oct 25 23:34:14 2001 +0000 +++ b/postproc/postprocess.c Fri Oct 26 00:35:41 2001 +0000 @@ -26,7 +26,7 @@ isHorizMinMaxOk a E doHorizLowPass E e e doHorizDefFilter Ec Ec Ec -deRing e e* +deRing E e e* Vertical RKAlgo1 E a a Horizontal RKAlgo1 a a Vertical X1 a E E @@ -93,6 +93,24 @@ #define PAVGB(a,b) "pavgusb " #a ", " #b " \n\t" #endif +#ifdef HAVE_MMX2 +#define PMINUB(a,b,t) "pminub " #a ", " #b " \n\t" +#elif defined (HAVE_MMX) +#define PMINUB(b,a,t) \ + "movq " #a ", " #t " \n\t"\ + "psubusb " #b ", " #t " \n\t"\ + "psubb " #t ", " #a " \n\t" +#endif + +#ifdef HAVE_MMX2 +#define PMAXUB(a,b) "pmaxub " #a ", " #b " \n\t" +#elif defined (HAVE_MMX) +#define PMAXUB(a,b) \ + "psubusb " #a ", " #b " \n\t"\ + "paddb " #a ", " #b " \n\t" +#endif + + #define GET_MODE_BUFFER_SIZE 500 #define OPTIONS_ARRAY_SIZE 10 @@ -1972,22 +1990,21 @@ PAVGB(lx, pplx) \ PAVGB(plx, pplx) /* filtered */\ "movq " #dst ", " #t0 " \n\t" /* dst */\ - "movq " #pplx ", " #t1 " \n\t"\ - "psubusb " #t0 ", " #pplx " \n\t"\ - "psubusb " #t1 ", " #t0 " \n\t"\ - "por " #t0 ", " #pplx " \n\t" /* |filtered - dst| */\ - "psubusb pQPb2, " #pplx " \n\t"\ - "pcmpeqb b00, " #pplx " \n\t"\ + "movq " #t0 ", " #t1 " \n\t" /* dst */\ + "psubusb pQPb2, " #t0 " \n\t"\ + "paddusb pQPb2, " #t1 " \n\t"\ + PMAXUB(t0, pplx)\ + PMINUB(t1, pplx, t0)\ "paddb " #sx ", " #ppsx " \n\t"\ "paddb " #psx ", " #ppsx " \n\t"\ "#paddb b02, " #ppsx " \n\t"\ "pand b08, " #ppsx " \n\t"\ "pcmpeqb b00, " #ppsx " \n\t"\ - "pand " #pplx ", " #ppsx " \n\t"\ - "pand " #ppsx ", " #t1 " \n\t"\ + "pand " #ppsx ", " #pplx " \n\t"\ "pandn " #dst ", " #ppsx " \n\t"\ - "por " #t1 ", " #ppsx " \n\t"\ + "por " #pplx ", " #ppsx " \n\t"\ "movq " #ppsx ", " #dst " \n\t" + /* 0000000 1111111 @@ -2018,8 +2035,65 @@ : "%eax", "%ebx" ); #else - -//FIXME + int y; + int min=255; + int max=0; + int avg; + uint8_t *p; + int s[10]; + + for(y=1; y<9; y++) + { + int x; + p= src + stride*y; + for(x=1; x<9; x++) + { + p++; + if(*p > max) max= *p; + if(*p < min) min= *p; + } + } + avg= (min + max + 1)/2; + + for(y=0; y<10; y++) + { + int x; + int t = 0; + p= src + stride*y; + for(x=0; x<10; x++) + { + if(*p > avg) t |= (1<<x); + p++; + } + t |= (~t)<<16; + t &= (t<<1) & (t>>1); + s[y] = t; + } + + for(y=1; y<9; y++) + { + int x; + int t = s[y-1] & s[y] & s[y+1]; + t|= t>>16; + + p= src + stride*y; + for(x=1; x<9; x++) + { + p++; + if(t & (1<<x)) + { + int f= (*(p-stride-1)) + 2*(*(p-stride)) + (*(p-stride+1)) + +2*(*(p -1)) + 4*(*p ) + 2*(*(p +1)) + +(*(p+stride-1)) + 2*(*(p+stride)) + (*(p+stride+1)); + f= (f + 8)>>4; + + if (*p + 2*QP < f) *p= *p + 2*QP; + else if(*p - 2*QP > f) *p= *p - 2*QP; + else *p=f; + } + } + } + #endif }
--- a/postproc/postprocess_template.c Thu Oct 25 23:34:14 2001 +0000 +++ b/postproc/postprocess_template.c Fri Oct 26 00:35:41 2001 +0000 @@ -26,7 +26,7 @@ isHorizMinMaxOk a E doHorizLowPass E e e doHorizDefFilter Ec Ec Ec -deRing e e* +deRing E e e* Vertical RKAlgo1 E a a Horizontal RKAlgo1 a a Vertical X1 a E E @@ -93,6 +93,24 @@ #define PAVGB(a,b) "pavgusb " #a ", " #b " \n\t" #endif +#ifdef HAVE_MMX2 +#define PMINUB(a,b,t) "pminub " #a ", " #b " \n\t" +#elif defined (HAVE_MMX) +#define PMINUB(b,a,t) \ + "movq " #a ", " #t " \n\t"\ + "psubusb " #b ", " #t " \n\t"\ + "psubb " #t ", " #a " \n\t" +#endif + +#ifdef HAVE_MMX2 +#define PMAXUB(a,b) "pmaxub " #a ", " #b " \n\t" +#elif defined (HAVE_MMX) +#define PMAXUB(a,b) \ + "psubusb " #a ", " #b " \n\t"\ + "paddb " #a ", " #b " \n\t" +#endif + + #define GET_MODE_BUFFER_SIZE 500 #define OPTIONS_ARRAY_SIZE 10 @@ -1972,22 +1990,21 @@ PAVGB(lx, pplx) \ PAVGB(plx, pplx) /* filtered */\ "movq " #dst ", " #t0 " \n\t" /* dst */\ - "movq " #pplx ", " #t1 " \n\t"\ - "psubusb " #t0 ", " #pplx " \n\t"\ - "psubusb " #t1 ", " #t0 " \n\t"\ - "por " #t0 ", " #pplx " \n\t" /* |filtered - dst| */\ - "psubusb pQPb2, " #pplx " \n\t"\ - "pcmpeqb b00, " #pplx " \n\t"\ + "movq " #t0 ", " #t1 " \n\t" /* dst */\ + "psubusb pQPb2, " #t0 " \n\t"\ + "paddusb pQPb2, " #t1 " \n\t"\ + PMAXUB(t0, pplx)\ + PMINUB(t1, pplx, t0)\ "paddb " #sx ", " #ppsx " \n\t"\ "paddb " #psx ", " #ppsx " \n\t"\ "#paddb b02, " #ppsx " \n\t"\ "pand b08, " #ppsx " \n\t"\ "pcmpeqb b00, " #ppsx " \n\t"\ - "pand " #pplx ", " #ppsx " \n\t"\ - "pand " #ppsx ", " #t1 " \n\t"\ + "pand " #ppsx ", " #pplx " \n\t"\ "pandn " #dst ", " #ppsx " \n\t"\ - "por " #t1 ", " #ppsx " \n\t"\ + "por " #pplx ", " #ppsx " \n\t"\ "movq " #ppsx ", " #dst " \n\t" + /* 0000000 1111111 @@ -2018,8 +2035,65 @@ : "%eax", "%ebx" ); #else - -//FIXME + int y; + int min=255; + int max=0; + int avg; + uint8_t *p; + int s[10]; + + for(y=1; y<9; y++) + { + int x; + p= src + stride*y; + for(x=1; x<9; x++) + { + p++; + if(*p > max) max= *p; + if(*p < min) min= *p; + } + } + avg= (min + max + 1)/2; + + for(y=0; y<10; y++) + { + int x; + int t = 0; + p= src + stride*y; + for(x=0; x<10; x++) + { + if(*p > avg) t |= (1<<x); + p++; + } + t |= (~t)<<16; + t &= (t<<1) & (t>>1); + s[y] = t; + } + + for(y=1; y<9; y++) + { + int x; + int t = s[y-1] & s[y] & s[y+1]; + t|= t>>16; + + p= src + stride*y; + for(x=1; x<9; x++) + { + p++; + if(t & (1<<x)) + { + int f= (*(p-stride-1)) + 2*(*(p-stride)) + (*(p-stride+1)) + +2*(*(p -1)) + 4*(*p ) + 2*(*(p +1)) + +(*(p+stride-1)) + 2*(*(p+stride)) + (*(p+stride+1)); + f= (f + 8)>>4; + + if (*p + 2*QP < f) *p= *p + 2*QP; + else if(*p - 2*QP > f) *p= *p - 2*QP; + else *p=f; + } + } + } + #endif }