# HG changeset patch # User michael # Date 1066410938 0 # Node ID 8af26336d9f7ecccb158baee6fa1d496d7387d27 # Parent e1c3f72da3d1a2a63cc6254bba2e2da268e90d4c optimization diff -r e1c3f72da3d1 -r 8af26336d9f7 libmpcodecs/vf_eq2.c --- a/libmpcodecs/vf_eq2.c Fri Oct 17 17:10:48 2003 +0000 +++ b/libmpcodecs/vf_eq2.c Fri Oct 17 17:15:38 2003 +0000 @@ -6,12 +6,14 @@ * Hampa Hug (original LUT gamma/contrast/brightness filter) * Daniel Moreno (saturation, R/G/B gamma support) * Richard Felker (original MMX contrast/brightness code (vf_eq.c)) + * Michael Niedermayer (LUT16) */ #include #include #include #include +#include #include "config.h" #include "mp_msg.h" @@ -25,10 +27,14 @@ #include #endif +#define LUT16 /* Per channel parameters */ typedef struct eq2_param_t { unsigned char lut[256]; +#ifdef LUT16 + uint16_t lut16[256*256]; +#endif int lut_clean; void (*adjust) (struct eq2_param_t *par, unsigned char *dst, unsigned char *src, @@ -90,6 +96,12 @@ } } +#ifdef LUT16 + for(i=0; i<256*256; i++){ + par->lut16[i]= par->lut[i&0xFF] + (par->lut[i>>8]<<8); + } +#endif + par->lut_clean = 1; } @@ -165,17 +177,43 @@ void apply_lut (eq2_param_t *par, unsigned char *dst, unsigned char *src, unsigned w, unsigned h, unsigned dstride, unsigned sstride) { - unsigned i, j; + unsigned i, j, w2; unsigned char *lut; + uint16_t *lut16; if (!par->lut_clean) { create_lut (par); } lut = par->lut; - +#ifdef LUT16 + lut16 = par->lut16; + w2= (w>>3)<<2; for (j = 0; j < h; j++) { - for (i = 0; i < w; i++) { + uint16_t *src16= (uint16_t*)src; + uint16_t *dst16= (uint16_t*)dst; + for (i = 0; i < w2; i+=4) { + dst16[i+0] = lut16[src16[i+0]]; + dst16[i+1] = lut16[src16[i+1]]; + dst16[i+2] = lut16[src16[i+2]]; + dst16[i+3] = lut16[src16[i+3]]; + } + i <<= 1; +#else + w2= (w>>3)<<3; + for (j = 0; j < h; j++) { + for (i = 0; i < w2; i+=8) { + dst[i+0] = lut[src[i+0]]; + dst[i+1] = lut[src[i+1]]; + dst[i+2] = lut[src[i+2]]; + dst[i+3] = lut[src[i+3]]; + dst[i+4] = lut[src[i+4]]; + dst[i+5] = lut[src[i+5]]; + dst[i+6] = lut[src[i+6]]; + dst[i+7] = lut[src[i+7]]; + } +#endif + for (; i < w; i++) { dst[i] = lut[src[i]]; }