History

sws: fix ED mono dither black level

Michael Niedermayer committed 13 years ago

Commit 5c420781 parent 7ba9f401 file · +6 −6Browse files

Unified · Split

libswscale/output.c+6−6
@@ -351,12 +351,12 @@ yuv2mono_X_c_template(SwsContext *c, const int16_t *lumFilter, · 350 unmodified lines
351351 Y2 = av_clip_uint8(Y2);
352352 }
353353 if (c->flags & SWS_ERROR_DIFFUSION) {
354− Y1 += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4;
354+ 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;
355355 c->dither_error[0][i] = err;
356356 acc = 2*acc + (Y1 >= 128);
357357 Y1 -= 220*(acc&1);
358358
359− 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);
359+ 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);
360360 c->dither_error[0][i+1] = Y1;
361361 acc = 2*acc + (err >= 128);
362362 err -= 220*(acc&1);
@@ -394,13 +394,13 @@ yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2], · 31 unmodified lines
394394 int Y;
395395
396396 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;
397− Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4;
397+ 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;
398398 c->dither_error[0][i] = err;
399399 acc = 2*acc + (Y >= 128);
400400 Y -= 220*(acc&1);
401401
402402 err = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;
403− 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;
403+ 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;
404404 c->dither_error[0][i+1] = Y;
405405 acc = 2*acc + (err >= 128);
406406 err -= 220*(acc&1);
@@ -451,13 +451,13 @@ yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0, · 44 unmodified lines
451451 int Y;
452452
453453 Y = ((buf0[i + 0] + 64) >> 7);
454− Y += (7*err + 1*c->dither_error[0][i] + 5*c->dither_error[0][i+1] + 3*c->dither_error[0][i+2])>>4;
454+ 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;
455455 c->dither_error[0][i] = err;
456456 acc = 2*acc + (Y >= 128);
457457 Y -= 220*(acc&1);
458458
459459 err = ((buf0[i + 1] + 64) >> 7);
460− 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;
460+ 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;
461461 c->dither_error[0][i+1] = Y;
462462 acc = 2*acc + (err >= 128);
463463 err -= 220*(acc&1);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t