summaryrefslogtreecommitdiff
path: root/libswscale/output.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-19 04:21:44 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-19 04:21:44 +0100
commit5c42078b9901f95026d2ed4dae0df0d8abd90d03 (patch)
tree4910e7e28f989e7169f774d8340867b7fccb3a4d /libswscale/output.c
parent7ba9f40ac6029ef0922cf50c357d9927d6a181e4 (diff)
sws: fix ED mono dither black level
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswscale/output.c')
-rw-r--r--libswscale/output.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libswscale/output.c b/libswscale/output.c
index 665176a11d..d185dfc34e 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -351,12 +351,12 @@ yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter,
Y2 = av_clip_uint8(Y2);
}
if (c->flags & SWS_ERROR_DIFFUSION) {
- Y1 += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4;
+ Y1 += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
c->dither_error[0][i] = err;
acc = 2*acc + (Y1 >= 128);
Y1 -= 220*(acc&1);
- err = Y2 + ((7*Y1 + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3])>>4);
+ err = Y2 + ((7*Y1 + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4);
c->dither_error[0][i+1] = Y1;
acc = 2*acc + (err >= 128);
err -= 220*(acc&1);
@@ -394,13 +394,13 @@ yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2],
int Y;
Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
- Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4;
+ Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
c->dither_error[0][i] = err;
acc = 2*acc + (Y >= 128);
Y -= 220*(acc&1);
err = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
- err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3])>>4;
+ err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4;
c->dither_error[0][i+1] = Y;
acc = 2*acc + (err >= 128);
err -= 220*(acc&1);
@@ -451,13 +451,13 @@ yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0,
int Y;
Y = ((buf0[i + 0] + 64) >> 7);
- Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4;
+ Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2] + 8 - 256)>>4;
c->dither_error[0][i] = err;
acc = 2*acc + (Y >= 128);
Y -= 220*(acc&1);
err = ((buf0[i + 1] + 64) >> 7);
- err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3])>>4;
+ err += (7*Y + 1*c->dither_error[0][i+1] + 5*c->dither_error[0][i+2] + 3*c->dither_error[0][i+3] + 8 - 256)>>4;
c->dither_error[0][i+1] = Y;
acc = 2*acc + (err >= 128);
err -= 220*(acc&1);