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
351 Y2 = av_clip_uint8(Y2);351 Y2 = av_clip_uint8(Y2);
352 }352 }
353 if (c->flags & SWS_ERROR_DIFFUSION) {353 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;
355 c->dither_error[0][i] = err;355 c->dither_error[0][i] = err;
356 acc = 2*acc + (Y1 >= 128);356 acc = 2*acc + (Y1 >= 128);
357 Y1 -= 220*(acc&1);357 Y1 -= 220*(acc&1);
358 358
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);
360 c->dither_error[0][i+1] = Y1;360 c->dither_error[0][i+1] = Y1;
361 acc = 2*acc + (err >= 128);361 acc = 2*acc + (err >= 128);
362 err -= 220*(acc&1);362 err -= 220*(acc&1);
@@ -394,13 +394,13 @@ yuv2mono_2_c_template(SwsContext *c, const int16_t *buf[2], · 31 unmodified lines
394 int Y;394 int Y;
395 395
396 Y = (buf0[i + 0] * yalpha1 + buf1[i + 0] * yalpha) >> 19;396 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;
398 c->dither_error[0][i] = err;398 c->dither_error[0][i] = err;
399 acc = 2*acc + (Y >= 128);399 acc = 2*acc + (Y >= 128);
400 Y -= 220*(acc&1);400 Y -= 220*(acc&1);
401 401
402 err = (buf0[i + 1] * yalpha1 + buf1[i + 1] * yalpha) >> 19;402 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;
404 c->dither_error[0][i+1] = Y;404 c->dither_error[0][i+1] = Y;
405 acc = 2*acc + (err >= 128);405 acc = 2*acc + (err >= 128);
406 err -= 220*(acc&1);406 err -= 220*(acc&1);
@@ -451,13 +451,13 @@ yuv2mono_1_c_template(SwsContext *c, const int16_t *buf0, · 44 unmodified lines
451 int Y;451 int Y;
452 452
453 Y = ((buf0[i + 0] + 64) >> 7);453 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;
455 c->dither_error[0][i] = err;455 c->dither_error[0][i] = err;
456 acc = 2*acc + (Y >= 128);456 acc = 2*acc + (Y >= 128);
457 Y -= 220*(acc&1);457 Y -= 220*(acc&1);
458 458
459 err = ((buf0[i + 1] + 64) >> 7);459 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;
461 c->dither_error[0][i+1] = Y;461 c->dither_error[0][i+1] = Y;
462 acc = 2*acc + (err >= 128);462 acc = 2*acc + (err >= 128);
463 err -= 220*(acc&1);463 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