Burkes according to https://bisqwit.iki.fi/jutut/kuvat/ordered_dither/error_diffusion.txt: * 8 4 2 4 8 4 2 / 32
Unified · Split
| @@ -18526,6 +18526,8 @@ Frankie Sierra dithering v2 (error diffusion) · 18525 unmodified lines | ||
| 18526 | 18526 | Frankie Sierra dithering v2 "Lite" (error diffusion) |
| 18527 | 18527 | @item sierra3 |
| 18528 | 18528 | Frankie Sierra dithering v3 (error diffusion) |
| 18529 | +@item burkes | |
| 18530 | +Burkes dithering (error diffusion) | |
| 18529 | 18531 | @end table |
| 18530 | 18532 | |
| 18531 | 18533 | Default is @var{sierra2_4a}. |
| @@ -43,6 +43,7 @@ enum dithering_mode { · 42 unmodified lines | ||
| 43 | 43 | DITHERING_SIERRA2, |
| 44 | 44 | DITHERING_SIERRA2_4A, |
| 45 | 45 | DITHERING_SIERRA3, |
| 46 | + DITHERING_BURKES, | |
| 46 | 47 | NB_DITHERING |
| 47 | 48 | }; |
| 48 | 49 | |
| @@ -115,6 +116,7 @@ static const AVOption paletteuse_options[] = { · 66 unmodified lines | ||
| 115 | 116 | { "sierra2", "Frankie Sierra dithering v2 (error diffusion)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_SIERRA2}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" }, |
| 116 | 117 | { "sierra2_4a", "Frankie Sierra dithering v2 \"Lite\" (error diffusion)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_SIERRA2_4A}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" }, |
| 117 | 118 | { "sierra3", "Frankie Sierra dithering v3 (error diffusion)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_SIERRA3}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" }, |
| 119 | + { "burkes", "Burkes dithering (error diffusion)", 0, AV_OPT_TYPE_CONST, {.i64=DITHERING_BURKES}, INT_MIN, INT_MAX, FLAGS, "dithering_mode" }, | |
| 118 | 120 | { "bayer_scale", "set scale for bayer dithering", OFFSET(bayer_scale), AV_OPT_TYPE_INT, {.i64=2}, 0, 5, FLAGS }, |
| 119 | 121 | { "diff_mode", "set frame difference mode", OFFSET(diff_mode), AV_OPT_TYPE_INT, {.i64=DIFF_MODE_NONE}, 0, NB_DIFF_MODE-1, FLAGS, "diff_mode" }, |
| 120 | 122 | { "rectangle", "process smallest different rectangle", 0, AV_OPT_TYPE_CONST, {.i64=DIFF_MODE_RECTANGLE}, INT_MIN, INT_MAX, FLAGS, "diff_mode" }, |
| @@ -396,6 +398,26 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram · 275 unmodified lines | ||
| 396 | 398 | } |
| 397 | 399 | } |
| 398 | 400 | |
| 401 | + } else if (dither == DITHERING_BURKES) { | |
| 402 | + const int right = x < w - 1, down = y < h - 1, left = x > x_start; | |
| 403 | + const int right2 = x < w - 2, left2 = x > x_start + 1; | |
| 404 | + const int color = get_dst_color_err(s, src[x], &er, &eg, &eb); | |
| 405 | + | |
| 406 | + if (color < 0) | |
| 407 | + return color; | |
| 408 | + dst[x] = color; | |
| 409 | + | |
| 410 | + if (right) src[ x + 1] = dither_color(src[ x + 1], er, eg, eb, 8, 5); | |
| 411 | + if (right2) src[ x + 2] = dither_color(src[ x + 2], er, eg, eb, 4, 5); | |
| 412 | + | |
| 413 | + if (down) { | |
| 414 | + if (left2) src[src_linesize + x - 2] = dither_color(src[src_linesize + x - 2], er, eg, eb, 2, 5); | |
| 415 | + if (left) src[src_linesize + x - 1] = dither_color(src[src_linesize + x - 1], er, eg, eb, 4, 5); | |
| 416 | + if (1) src[src_linesize + x ] = dither_color(src[src_linesize + x ], er, eg, eb, 8, 5); | |
| 417 | + if (right) src[src_linesize + x + 1] = dither_color(src[src_linesize + x + 1], er, eg, eb, 4, 5); | |
| 418 | + if (right2) src[src_linesize + x + 2] = dither_color(src[src_linesize + x + 2], er, eg, eb, 2, 5); | |
| 419 | + } | |
| 420 | + | |
| 399 | 421 | } else { |
| 400 | 422 | const int color = color_get(s, src[x]); |
| 401 | 423 | |
| @@ -871,6 +893,7 @@ DEFINE_SET_FRAME(floyd_steinberg, DITHERING_FLOYD_STEINBERG) · 469 unmodified lines | ||
| 871 | 893 | DEFINE_SET_FRAME(sierra2, DITHERING_SIERRA2) |
| 872 | 894 | DEFINE_SET_FRAME(sierra2_4a, DITHERING_SIERRA2_4A) |
| 873 | 895 | DEFINE_SET_FRAME(sierra3, DITHERING_SIERRA3) |
| 896 | +DEFINE_SET_FRAME(burkes, DITHERING_BURKES) | |
| 874 | 897 | |
| 875 | 898 | static const set_frame_func set_frame_lut[NB_DITHERING] = { |
| 876 | 899 | set_frame_none, |
| @@ -880,6 +903,7 @@ static const set_frame_func set_frame_lut[NB_DITHERING] = { · 3 unmodified lines | ||
| 880 | 903 | set_frame_sierra2, |
| 881 | 904 | set_frame_sierra2_4a, |
| 882 | 905 | set_frame_sierra3, |
| 906 | + set_frame_burkes, | |
| 883 | 907 | }; |
| 884 | 908 | |
| 885 | 909 | static int dither_value(int p) |