44 unsigned char lut[256];
51 unsigned w,
unsigned h,
unsigned dstride,
unsigned sstride);
74 unsigned char *
buf[3];
89 if ((g < 0.001) || (g > 1000.0)) {
95 for (i = 0; i < 256; i++) {
96 v = (double) i / 255.0;
97 v = par->
c * (v - 0.5) + 0.5 + par->
b;
103 v = v*lw + pow(v, g)*gw;
109 par->
lut[i] = (
unsigned char) (256.0 * v);
115 for(i=0; i<256*256; i++){
116 par->
lut16[i]= par->
lut[i&0xFF] + (par->
lut[i>>8]<<8);
126 unsigned w,
unsigned h,
unsigned dstride,
unsigned sstride)
129 int contrast, brightness;
130 unsigned dstep, sstep;
137 contrast = (int) (par->
c * 256 * 16);
138 brightness = ((int) (100.0 * par->
b + 100.0) * 511) / 200 - 128 - contrast / 32;
140 brvec[0] = brvec[1] = brvec[2] = brvec[3] = brightness;
141 contvec[0] = contvec[1] = contvec[2] = contvec[3] = contrast;
148 "movq (%5), %%mm3 \n\t"
149 "movq (%6), %%mm4 \n\t"
150 "pxor %%mm0, %%mm0 \n\t"
154 "movq (%0), %%mm1 \n\t"
155 "movq (%0), %%mm2 \n\t"
156 "punpcklbw %%mm0, %%mm1 \n\t"
157 "punpckhbw %%mm0, %%mm2 \n\t"
158 "psllw $4, %%mm1 \n\t"
159 "psllw $4, %%mm2 \n\t"
160 "pmulhw %%mm4, %%mm1 \n\t"
161 "pmulhw %%mm4, %%mm2 \n\t"
162 "paddw %%mm3, %%mm1 \n\t"
163 "paddw %%mm3, %%mm2 \n\t"
164 "packuswb %%mm2, %%mm1 \n\t"
166 "movq %%mm1, (%1) \n\t"
170 :
"=r" (
src),
"=r" (dst)
171 :
"0" (
src),
"1" (dst),
"r" (w >> 3),
"r" (brvec),
"r" (contvec)
175 for (i = w & 7; i > 0; i--) {
176 pel = ((*src++ * contrast) >> 12) + brightness;
187 __asm__
volatile (
"emms \n\t" :::
"memory" );
193 unsigned w,
unsigned h,
unsigned dstride,
unsigned sstride)
207 for (j = 0; j < h; j++) {
208 uint16_t *src16= (uint16_t*)src;
209 uint16_t *dst16= (uint16_t*)dst;
210 for (i = 0; i < w2; i+=4) {
211 dst16[i+0] = lut16[src16[i+0]];
212 dst16[i+1] = lut16[src16[i+1]];
213 dst16[i+2] = lut16[src16[i+2]];
214 dst16[i+3] = lut16[src16[i+3]];
219 for (j = 0; j < h; j++) {
220 for (i = 0; i < w2; i+=8) {
221 dst[i+0] = lut[src[i+0]];
222 dst[i+1] = lut[src[i+1]];
223 dst[i+2] = lut[src[i+2]];
224 dst[i+3] = lut[src[i+3]];
225 dst[i+4] = lut[src[i+4]];
226 dst[i+5] = lut[src[i+5]];
227 dst[i+6] = lut[src[i+6]];
228 dst[i+7] = lut[src[i+7]];
232 dst[i] = lut[src[i]];
246 unsigned long img_n,img_c;
250 if ((eq2->
buf_w[0] != src->
w) || (eq2->
buf_h[0] != src->
h)) {
258 eq2->
buf[0] = realloc (eq2->
buf[0], img_n + 2*img_c);
259 eq2->
buf[1] = eq2->
buf[0] + img_n;
260 eq2->
buf[2] = eq2->
buf[1] + img_c;
262 eq2->
buf[0] = realloc (eq2->
buf[0], img_n);
267 for (i = 0; i < ((src->
num_planes>1)?3:1); i++) {
289 if ((par->
c == 1.0) && (par->
b == 0.0) && (par->
g == 1.0)) {
377 if (strcmp (eq->
item,
"gamma") == 0) {
381 else if (strcmp (eq->
item,
"contrast") == 0) {
385 else if (strcmp (eq->
item,
"brightness") == 0) {
389 else if (strcmp (eq->
item,
"saturation") == 0) {
397 if (strcmp (eq->
item,
"gamma") == 0) {
398 eq->
value = (int) (100.0 * log (vf->
priv->gamma) / log (8.0));
401 else if (strcmp (eq->
item,
"contrast") == 0) {
405 else if (strcmp (eq->
item,
"brightness") == 0) {
409 else if (strcmp (eq->
item,
"saturation") == 0) {
410 eq->
value = (int) (100.0 * vf->
priv->saturation) - 100;
442 if (vf->
priv != NULL) {
463 for (i = 0; i < 3; i++) {
494 sscanf (args,
"%lf:%lf:%lf:%lf:%lf:%lf:%lf:%lf",
495 par, par + 1, par + 2, par + 3, par + 4, par + 5, par + 6, par + 7
513 "Software equalizer",
515 "Hampa Hug, Daniel Moreno, Richard Felker",