From 0c33a019a6622a0051bff1f87c0e049e984eca39 Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 26 Dec 2024 23:04:02 -0500 Subject: [PATCH 01/23] start in on unified hires blitter (sex/oct) --- CMakeLists.txt | 2 +- src/lib/blit.c | 33 +++++++++++++++++++++------------ src/lib/termdesc.c | 3 ++- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2974d8116..1aaba5e9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ endif() if(MSVC) add_compile_options(/W4) else() -add_compile_options(-Wall -Wextra -W -Wshadow -Wvla -Wstrict-aliasing=2) +add_compile_options(-Wall -Wextra -W -Wshadow -Wstrict-aliasing=2) # -ffast-math dies on NaNs we draw from libav (by -ffinite-math-only) add_compile_options(-fno-signed-zeros -fno-trapping-math -fassociative-math) add_compile_options(-fno-math-errno -freciprocal-math -funsafe-math-optimizations) diff --git a/src/lib/blit.c b/src/lib/blit.c index 26362dab0..a08c445b0 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -653,11 +653,12 @@ sex_trans_check(nccell* c, const uint32_t rgbas[6], unsigned blendcolors, return egc; } -// sextant blitter. maps 3x2 to each cell. since we only have two colors at -// our disposal (foreground and background), we lose some fidelity. +// sextant/octant blitter. maps 3x2 or 4x2 to each cell. since we only have two +// colors at our disposal (foreground and background), we generally lose some +// color fidelity. static inline int -sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, - const blitterargs* bargs){ +hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, + const blitterargs* bargs, int cellheight){ const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE; const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND; unsigned dimy, dimx, x, y; @@ -666,13 +667,15 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, //fprintf(stderr, "sexblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->u.cell.placey, bargs->u.cell.placex); const unsigned char* dat = data; int visy = bargs->begy; - for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 3){ + for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += cellheight){ if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){ return -1; } int visx = bargs->begx; for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){ - uint32_t rgbas[6] = { 0, 0, 0, 0, 0, 0 }; + uint32_t rgbas[cellheight * 2]; + memset(rgbas, 0, sizeof(rgbas)); + // FIXME need to handle this generally based off cellheight memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * 4)), sizeof(*rgbas)); if(visx < bargs->begx + lenx - 1){ memcpy(&rgbas[1], (dat + (linesize * visy) + ((visx + 1) * 4)), sizeof(*rgbas)); @@ -711,6 +714,18 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, return total; } +static inline int +sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, + const blitterargs* bargs){ + return hires_blit(nc, linesize, data, leny, lenx, bargs, 3); +} + +static inline int +octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, + const blitterargs* bargs){ + return hires_blit(nc, linesize, data, leny, lenx, bargs, 4); +} + // Bit is set where octant is present: // 0 1 // 2 3 @@ -932,12 +947,6 @@ braille_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, return blit_4x2(nc, linesize, data, leny, lenx, bargs, braille_egcs); } -static inline int -octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, - const blitterargs* bargs){ - return blit_4x2(nc, linesize, data, leny, lenx, bargs, octant_egcs); -} - // NCBLIT_DEFAULT is not included, as it has no defined properties. It ought // be replaced with some real blitter implementation by the calling widget. // The order of contents is critical for 'egcs': ncplane_as_rgba() uses these diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index 5a09c9801..a17bc226f 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -735,6 +735,7 @@ static const char* apply_kitty_heuristics(tinfo* ti, size_t* tablelen, size_t* tableused){ // see https://sw.kovidgoyal.net/kitty/protocol-extensions.html ti->bg_collides_default |= 0x1000000; + ti->caps.octants = true; ti->caps.sextants = true; // work since bugfix in 0.19.3 ti->caps.quadrants = true; ti->caps.rgb = true; @@ -1048,7 +1049,7 @@ apply_term_heuristics(tinfo* ti, const char* tname, queried_terminals_e qterm, } // run a wcwidth(๐œด€) to guarantee libc Unicode 16 support, independent of term if(wcwidth(L'๐œด€') < 0){ - ti->caps.octants = false; + // ti->caps.octants = false; } ti->termname = tname; return 0; From 0a896e3b14119144707c211e7ccc524636414f2e Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 27 Dec 2024 01:21:41 -0500 Subject: [PATCH 02/23] hires_blit: genericize rgb array prep --- src/lib/blit.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index a08c445b0..f25b495a2 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -673,28 +673,28 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, } int visx = bargs->begx; for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){ - uint32_t rgbas[cellheight * 2]; + uint32_t rgbas[cellheight * 2]; // row-major memset(rgbas, 0, sizeof(rgbas)); - // FIXME need to handle this generally based off cellheight memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * 4)), sizeof(*rgbas)); + // conditional looks at first column, begininng at the second row + for(int yoff = 1 ; yoff < cellheight ; ++yoff){ + if(visy < bargs->begy + leny - yoff){ + memcpy(&rgbas[yoff * 2], (dat + (linesize * (visy + yoff)) + (visx * 4)), sizeof(*rgbas)); + } + } + // conditional looks at second column, beginning at second row if(visx < bargs->begx + lenx - 1){ memcpy(&rgbas[1], (dat + (linesize * visy) + ((visx + 1) * 4)), sizeof(*rgbas)); - if(visy < bargs->begy + leny - 1){ - memcpy(&rgbas[3], (dat + (linesize * (visy + 1)) + ((visx + 1) * 4)), sizeof(*rgbas)); - if(visy < bargs->begy + leny - 2){ - memcpy(&rgbas[5], (dat + (linesize * (visy + 2)) + ((visx + 1) * 4)), sizeof(*rgbas)); + for(int yoff = 1 ; yoff < cellheight ; ++yoff){ + if(visy < bargs->begy + leny - yoff){ + memcpy(&rgbas[1 + yoff * 2], (dat + (linesize * (visy + yoff)) + ((visx + 1) * 4)), sizeof(*rgbas)); } } } - if(visy < bargs->begy + leny - 1){ - memcpy(&rgbas[2], (dat + (linesize * (visy + 1)) + (visx * 4)), sizeof(*rgbas)); - if(visy < bargs->begy + leny - 2){ - memcpy(&rgbas[4], (dat + (linesize * (visy + 2)) + (visx * 4)), sizeof(*rgbas)); - } - } nccell* c = ncplane_cell_ref_yx(nc, y, x); c->channels = 0; c->stylemask = 0; + // FIXME need genericize const char* egc = sex_trans_check(c, rgbas, blendcolors, bargs->transcolor, nointerpolate); if(egc == NULL){ // no transparency; run a full solver egc = sex_solver(rgbas, &c->channels, blendcolors, nointerpolate); From b5b1c82749728b32ba0c6ad241e0bd615798325d Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 27 Dec 2024 01:45:08 -0500 Subject: [PATCH 03/23] make hires_trans_check() generic across cellheights --- src/lib/blit.c | 50 ++++++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index f25b495a2..2c7a02304 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -598,27 +598,30 @@ sex_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, return sex[best]; } +// bit is *set* where sextant *is not* +// 32: bottom right 16: bottom left +// 8: middle right 4: middle left +// 2: upper right 1: upper left +static const char* sextrans[64] = { + "โ–ˆ", "๐Ÿฌป", "๐Ÿฌบ", "๐Ÿฌน", "๐Ÿฌธ", "๐Ÿฌท", "๐Ÿฌถ", "๐Ÿฌต", + "๐Ÿฌด", "๐Ÿฌณ", "๐Ÿฌฒ", "๐Ÿฌฑ", "๐Ÿฌฐ", "๐Ÿฌฏ", "๐Ÿฌฎ", "๐Ÿฌญ", + "๐Ÿฌฌ", "๐Ÿฌซ", "๐Ÿฌช", "๐Ÿฌฉ", "๐Ÿฌจ", "โ–", "๐Ÿฌง", "๐Ÿฌฆ", + "๐Ÿฌฅ", "๐Ÿฌค", "๐Ÿฌฃ", "๐Ÿฌข", "๐Ÿฌก", "๐Ÿฌ ", "๐ŸฌŸ", "๐Ÿฌž", + "๐Ÿฌ", "๐Ÿฌœ", "๐Ÿฌ›", "๐Ÿฌš", "๐Ÿฌ™", "๐Ÿฌ˜", "๐Ÿฌ—", "๐Ÿฌ–", + "๐Ÿฌ•", "๐Ÿฌ”", "โ–Œ", "๐Ÿฌ“", "๐Ÿฌ’", "๐Ÿฌ‘", "๐Ÿฌ", "๐Ÿฌ", + "๐ŸฌŽ", "๐Ÿฌ", "๐ŸฌŒ", "๐Ÿฌ‹", "๐ŸฌŠ", "๐Ÿฌ‰", "๐Ÿฌˆ", "๐Ÿฌ‡", + "๐Ÿฌ†", "๐Ÿฌ…", "๐Ÿฌ„", "๐Ÿฌƒ", "๐Ÿฌ‚", "๐Ÿฌ", "๐Ÿฌ€", " ", +}; + static const char* -sex_trans_check(nccell* c, const uint32_t rgbas[6], unsigned blendcolors, - uint32_t transcolor, unsigned nointerpolate){ - // bit is *set* where sextant *is not* - // 32: bottom right 16: bottom left - // 8: middle right 4: middle left - // 2: upper right 1: upper left - static const char* sex[64] = { - "โ–ˆ", "๐Ÿฌป", "๐Ÿฌบ", "๐Ÿฌน", "๐Ÿฌธ", "๐Ÿฌท", "๐Ÿฌถ", "๐Ÿฌต", - "๐Ÿฌด", "๐Ÿฌณ", "๐Ÿฌฒ", "๐Ÿฌฑ", "๐Ÿฌฐ", "๐Ÿฌฏ", "๐Ÿฌฎ", "๐Ÿฌญ", - "๐Ÿฌฌ", "๐Ÿฌซ", "๐Ÿฌช", "๐Ÿฌฉ", "๐Ÿฌจ", "โ–", "๐Ÿฌง", "๐Ÿฌฆ", - "๐Ÿฌฅ", "๐Ÿฌค", "๐Ÿฌฃ", "๐Ÿฌข", "๐Ÿฌก", "๐Ÿฌ ", "๐ŸฌŸ", "๐Ÿฌž", - "๐Ÿฌ", "๐Ÿฌœ", "๐Ÿฌ›", "๐Ÿฌš", "๐Ÿฌ™", "๐Ÿฌ˜", "๐Ÿฌ—", "๐Ÿฌ–", - "๐Ÿฌ•", "๐Ÿฌ”", "โ–Œ", "๐Ÿฌ“", "๐Ÿฌ’", "๐Ÿฌ‘", "๐Ÿฌ", "๐Ÿฌ", - "๐ŸฌŽ", "๐Ÿฌ", "๐ŸฌŒ", "๐Ÿฌ‹", "๐ŸฌŠ", "๐Ÿฌ‰", "๐Ÿฌˆ", "๐Ÿฌ‡", - "๐Ÿฌ†", "๐Ÿฌ…", "๐Ÿฌ„", "๐Ÿฌƒ", "๐Ÿฌ‚", "๐Ÿฌ", "๐Ÿฌ€", " ", - }; +hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, + uint32_t transcolor, unsigned nointerpolate, int cellheight, + const char** transegcs){ unsigned transstring = 0; unsigned r = 0, g = 0, b = 0; unsigned div = 0; - for(unsigned mask = 0 ; mask < 6 ; ++mask){ + // check each pixel for transparency + for(int mask = 0 ; mask < cellheight * 2 ; ++mask){ if(rgba_trans_p(rgbas[mask], transcolor)){ transstring |= (1u << mask); }else if(!nointerpolate || !div){ @@ -628,13 +631,14 @@ sex_trans_check(nccell* c, const uint32_t rgbas[6], unsigned blendcolors, ++div; } } + // transstring can only have 0x80 and/or 0x40 set if cellheight was 4 if(transstring == 0){ // there was no transparency return NULL; } nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); // there were some transparent pixels. since they get priority, the foreground // is just a general lerp across non-transparent pixels. - const char* egc = sex[transstring]; + const char* egc = transegcs[transstring]; nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); //fprintf(stderr, "transtring: %u egc: %s\n", transtring, egc); if(*egc == ' '){ // entirely transparent @@ -664,7 +668,7 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, unsigned dimy, dimx, x, y; int total = 0; // number of cells written ncplane_dim_yx(nc, &dimy, &dimx); -//fprintf(stderr, "sexblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->u.cell.placey, bargs->u.cell.placex); +//fprintf(stderr, "hiresblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->u.cell.placey, bargs->u.cell.placex); const unsigned char* dat = data; int visy = bargs->begy; for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += cellheight){ @@ -694,13 +698,15 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, nccell* c = ncplane_cell_ref_yx(nc, y, x); c->channels = 0; c->stylemask = 0; - // FIXME need genericize - const char* egc = sex_trans_check(c, rgbas, blendcolors, bargs->transcolor, nointerpolate); + // FIXME need genericize (need octtrans for last param, etc) + const char* egc = hires_trans_check(c, rgbas, blendcolors, bargs->transcolor, + nointerpolate, cellheight, sextrans); if(egc == NULL){ // no transparency; run a full solver + // FIXME need genericize to hires egc = sex_solver(rgbas, &c->channels, blendcolors, nointerpolate); cell_set_blitquadrants(c, 1, 1, 1, 1); } -//fprintf(stderr, "sex EGC: %s channels: %016lx\n", egc, c->channels); +//fprintf(stderr, "hires EGC: %s channels: %016lx\n", egc, c->channels); if(*egc){ if(pool_blit_direct(&nc->pool, c, egc, strlen(egc), 1) <= 0){ return -1; From 996f9c19a599459a7e606cf7b176316d0a2bd37f Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 27 Dec 2024 01:49:51 -0500 Subject: [PATCH 04/23] genericize geometry for hires_solver() --- src/lib/blit.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 2c7a02304..d858600ca 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -508,14 +508,16 @@ quadrant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, return total; } -// Solve for the cell rendered by this 3x2 sample. None of the input pixels may -// be transparent (that ought already have been handled). We use exhaustive -// search, which might be quite computationally intensive for the worst case -// (all six pixels are different colors). We want to solve for the 2-partition -// of pixels that minimizes total source distance from the resulting lerps. +// Solve for the cell rendered by this cellheightX2 sample. None of the input +// pixels may be transparent (that ought already have been handled). We use +// exhaustive search, which might be quite computationally intensive for the +// worst case (all pixels are different colors). We want to solve for the +// 2-partition of pixels that minimizes total source distance from the +// resulting lerps. static const char* -sex_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, - unsigned nointerpolate){ +hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, + unsigned nointerpolate, unsigned cellheight){ + // FIXME need genericize to hires // each element within the set of 64 has an inverse element within the set, // for which we would calculate the same total differences, so just handle // the first 32. the partition[] bit masks represent combinations of @@ -545,7 +547,7 @@ sex_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, unsigned bsum0 = 0, bsum1 = 0; int insum = 0; int outsum = 0; - for(unsigned mask = 0 ; mask < 6 ; ++mask){ + for(unsigned mask = 0 ; mask < cellheight * 2 ; ++mask){ if(partitions[glyph] & (1u << mask)){ if(!nointerpolate || !insum){ rsum0 += ncpixel_r(rgbas[mask]); @@ -566,7 +568,7 @@ sex_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, uint32_t l1 = generalerp(rsum1, gsum1, bsum1, outsum); //fprintf(stderr, "sum0: %06x sum1: %06x insum: %d\n", l0 & 0xffffffu, l1 & 0xffffffu, insum); uint32_t totaldiff = 0; - for(unsigned mask = 0 ; mask < 6 ; ++mask){ + for(unsigned mask = 0 ; mask < cellheight * 2 ; ++mask){ unsigned r, g, b; if(partitions[glyph] & (1u << mask)){ ncchannel_rgb8(l0, &r, &g, &b); @@ -702,8 +704,7 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const char* egc = hires_trans_check(c, rgbas, blendcolors, bargs->transcolor, nointerpolate, cellheight, sextrans); if(egc == NULL){ // no transparency; run a full solver - // FIXME need genericize to hires - egc = sex_solver(rgbas, &c->channels, blendcolors, nointerpolate); + egc = hires_solver(rgbas, &c->channels, blendcolors, nointerpolate, cellheight); cell_set_blitquadrants(c, 1, 1, 1, 1); } //fprintf(stderr, "hires EGC: %s channels: %016lx\n", egc, c->channels); From eec3ea3bb4b55037410bbce1b5f2655ed713d3f2 Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 27 Dec 2024 02:28:03 -0500 Subject: [PATCH 05/23] genericize hired_trans_check() on EGC set, start defining octtrans[] --- src/lib/blit.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index d858600ca..00a9c2f4b 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -592,7 +592,7 @@ hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, } } //fprintf(stderr, "solved for best: %d (%u)\n", best, mindiff); - assert(best >= 0 && best < 32); + assert(best >= 0 && best < 32); // FIXME adapt to oct if(blendcolors){ ncchannels_set_fg_alpha(channels, NCALPHA_BLEND); ncchannels_set_bg_alpha(channels, NCALPHA_BLEND); @@ -600,6 +600,7 @@ hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, return sex[best]; } +// FIXME replace both of these arrays of pointers with fixed-width matrices // bit is *set* where sextant *is not* // 32: bottom right 16: bottom left // 8: middle right 4: middle left @@ -615,6 +616,35 @@ static const char* sextrans[64] = { "๐Ÿฌ†", "๐Ÿฌ…", "๐Ÿฌ„", "๐Ÿฌƒ", "๐Ÿฌ‚", "๐Ÿฌ", "๐Ÿฌ€", " ", }; +// bit is *set* where octant *is not* +// 128: row 3 right 64: row 3 left +// 32: row 2 right 16: row 2 left +// 8: row 1 right 4: row 1 left +// 2: row 0 right 1: row 0 left +static const char* octtrans[256] = { + "โ–ˆ", // all eight set (255) (full block) + "\U00002584", // row 2/3 full (250) (lower half block) + // FIXME 127 here (all true octants) + "\U0001cea0", // lower right only (128) (right half lower one quarter) + // FIXME 63 here + "\U0001cea3", // lower left only (64) (left half lower one quarter) + // FIXME 31 here + "\U0001cd18", // row 2 right only (32) (o6) + // FIXME 15 here + "\U0001cd09", // row 2 left only (16) (o5) + "\U00002580", // row 0/1 full (15) (upper half block) + // FIXME 7 here + "\U0001cd03", // row 1 right only (8) (o4) + "\U0001cd02", // row 0 full row 1 left (7) (o123) + "\U0001cd04", // row 0 left row 1 right (6) (o14) + "\U00002598", // row 0/1 left only (5) (upper left quadrant) + "\U0001cd00", // row 1 left only (4) (o3) + "\U00002594", // top two (3) (upper one eighth) + "\U0001ceab", // upper right only (2) (right half upper one quarter) + "\U0001cea8", // upper left only (1) (left half upper one quarter) + " " // zero set +}; + static const char* hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, uint32_t transcolor, unsigned nointerpolate, int cellheight, @@ -652,6 +682,7 @@ hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, if(blendcolors){ nccell_set_fg_alpha(c, NCALPHA_BLEND); } + // FIXME genericize for hires cell_set_blitquadrants(c, !(transstring & 5u), !(transstring & 10u), !(transstring & 20u), !(transstring & 40u)); } @@ -664,7 +695,8 @@ hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, // color fidelity. static inline int hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, - const blitterargs* bargs, int cellheight){ + const blitterargs* bargs, int cellheight, + const char** transegcs){ const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE; const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND; unsigned dimy, dimx, x, y; @@ -700,9 +732,8 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, nccell* c = ncplane_cell_ref_yx(nc, y, x); c->channels = 0; c->stylemask = 0; - // FIXME need genericize (need octtrans for last param, etc) const char* egc = hires_trans_check(c, rgbas, blendcolors, bargs->transcolor, - nointerpolate, cellheight, sextrans); + nointerpolate, cellheight, transegcs); if(egc == NULL){ // no transparency; run a full solver egc = hires_solver(rgbas, &c->channels, blendcolors, nointerpolate, cellheight); cell_set_blitquadrants(c, 1, 1, 1, 1); @@ -724,13 +755,13 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, static inline int sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs){ - return hires_blit(nc, linesize, data, leny, lenx, bargs, 3); + return hires_blit(nc, linesize, data, leny, lenx, bargs, 3, sextrans); } static inline int octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs){ - return hires_blit(nc, linesize, data, leny, lenx, bargs, 4); + return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans); } // Bit is set where octant is present: From 37e6da2fa824aa3c6ae5142e5d76da1a3863c9cf Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 27 Dec 2024 02:29:44 -0500 Subject: [PATCH 06/23] we can just reverse oct_egcs --- src/lib/blit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 00a9c2f4b..a733a5d13 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -601,7 +601,7 @@ hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, } // FIXME replace both of these arrays of pointers with fixed-width matrices -// bit is *set* where sextant *is not* +// bit of index is *set* where sextant *is not* // 32: bottom right 16: bottom left // 8: middle right 4: middle left // 2: upper right 1: upper left @@ -616,13 +616,13 @@ static const char* sextrans[64] = { "๐Ÿฌ†", "๐Ÿฌ…", "๐Ÿฌ„", "๐Ÿฌƒ", "๐Ÿฌ‚", "๐Ÿฌ", "๐Ÿฌ€", " ", }; -// bit is *set* where octant *is not* +// bit of index is *set* where octant *is not* // 128: row 3 right 64: row 3 left // 32: row 2 right 16: row 2 left // 8: row 1 right 4: row 1 left // 2: row 0 right 1: row 0 left static const char* octtrans[256] = { - "โ–ˆ", // all eight set (255) (full block) + "\U00002588", // all eight set (255) (full block) "\U00002584", // row 2/3 full (250) (lower half block) // FIXME 127 here (all true octants) "\U0001cea0", // lower right only (128) (right half lower one quarter) From 20f3380fb1f69dc807e6ce8e51bcc79a5f531c45 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 06:39:13 -0500 Subject: [PATCH 07/23] continue building up octtrans literal array --- src/lib/blit.c | 201 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 135 insertions(+), 66 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index a733a5d13..0318e82f4 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -617,32 +617,142 @@ static const char* sextrans[64] = { }; // bit of index is *set* where octant *is not* -// 128: row 3 right 64: row 3 left -// 32: row 2 right 16: row 2 left -// 8: row 1 right 4: row 1 left -// 2: row 0 right 1: row 0 left +// 1: row 0 left 2: row 0 right +// 4: row 1 left 8: row 1 right +// 16: row 2 left 32: row 2 right +// 64: row 3 left 128: row 3 right static const char* octtrans[256] = { - "\U00002588", // all eight set (255) (full block) - "\U00002584", // row 2/3 full (250) (lower half block) - // FIXME 127 here (all true octants) - "\U0001cea0", // lower right only (128) (right half lower one quarter) - // FIXME 63 here - "\U0001cea3", // lower left only (64) (left half lower one quarter) - // FIXME 31 here - "\U0001cd18", // row 2 right only (32) (o6) - // FIXME 15 here - "\U0001cd09", // row 2 left only (16) (o5) - "\U00002580", // row 0/1 full (15) (upper half block) - // FIXME 7 here - "\U0001cd03", // row 1 right only (8) (o4) - "\U0001cd02", // row 0 full row 1 left (7) (o123) - "\U0001cd04", // row 0 left row 1 right (6) (o14) - "\U00002598", // row 0/1 left only (5) (upper left quadrant) - "\U0001cd00", // row 1 left only (4) (o3) - "\U00002594", // top two (3) (upper one eighth) - "\U0001ceab", // upper right only (2) (right half upper one quarter) - "\U0001cea8", // upper left only (1) (left half upper one quarter) - " " // zero set + "\U00002588", // โ–ˆ 255 all eight set (full) + "\U0001cde5", // ๐œทฅ 254 missing upper left (o2345678) + "\U0001cde4", // ๐œทค 253 missing upper right (o1345678) + "\U00002586", // โ–† 252 missing row 0 (lower three quarters) + "\U0001cde3", // ๐œทฃ 251 missing row 1 left (o1245678) + "\U0000259f", // โ–Ÿ 250 (q upper right and lower left and lower right) + "\U0001cde2", // ๐œทข 249 (o1245678) + "\U0001cde1", // ๐œทก 248 (o45678) + "\U0001cde0", // ๐œท  247 missing row 1 right (o1235678) + "\U0001cddf", // ๐œทŸ 246 missing 0 left 1 right (o235678) + "\U00002599", // โ–™ 245 missing 0/1 right (q upper left and lower left and lower right) + "\U0001cdde", // ๐œทž 244 + "\U0001cddd", // ๐œท 243 + "\U0001cddc", // ๐œทœ 242 + "\U0001cddb", // ๐œท› 241 (o15678) + "\U00002584", // โ–„ 240 2/3 full (lower half) + "\U0001cdda", // ๐œทš 239 (o1234678) + "\U0001cdd9", // ๐œท™ 238 (o234678) + "\U0001cdd8", // ๐œท˜ 237 (o134678) + "\U0001cdd7", // ๐œท— 236 (o34678) + "\U0001cdd6", // ๐œท– 235 (o124678) + "\U0001cdd5", // ๐œท• 234 (o24678) + "\U0001cdd4", // ๐œท” 233 (o14678) + "\U0001cdd3", // ๐œท“ 232 (o4678) + "\U0001cdd2", // ๐œท’ 231 + "\U0001cdd1", // ๐œท‘ 230 + "\U0001cdd0", // ๐œท 229 + "\U0001cdcf", // ๐œท 228 + "\U0001cdce", // ๐œทŽ 227 + "\U0001cdcd", // ๐œท 226 + "\U0001cdcc", // ๐œทŒ 225 + "\U0001cdcb", // ๐œท‹ 224 + /*"\U0001CDC3", "\U0001CDC4", "\U0001CDC5", "\U0001CDC6", "\U0001CDC7", "\U0001CDC8", "\U0001CDC9", "\U0001CDCA", + "\U0001CDBB", "\U0001CDBC", "\U0001CDBD", "\U0001CDBE", "\U0001CDBF", "\U0001CDC0", "\U0001CDC1", "\U0001CDC2", + "\U0001CDB3", "\U0001CDB4", "\U0001CDB5", "\U0001CDB6", "\U0001CDB7", "\U0001CDB8", "\U0001CDB9", "\U0001CDBA", + "\U00002582", "\U0001CDAC", "\U0001CDAD", "\U0001CDAE", "\U0001CDAF", "\U0001CDB0", "\U0001CDB1", "\U0001CDB2", + "\U0001CDA4", "\U0001CDA5", "\U0001CDA6", "\U0001CDA7", "\U0001CDA8", "\U0001CDA9", "\U0001CDAA", "\U0001CDAB", + "\U0001CDA3", + "\U0001CDA2", + "\U0001CDA1", + "\U0001CDA0", + "\U0001CD9F", + "\U0001CD9E", + "\U0001CD9D", + "\U0001CD9C",*/ + // 176 + /*"\U0001CEA0", "\U0001CD71", "\U0001CD72", "\U0001CD73", "\U0001CD74", "\U0001CD75", "\U0001CD76", "\U0001CD77", + "\U0001CD78", "\U0001CD79", "\U0001CD7A", "\U0001CD7B", "\U0001CD7C", "\U0001CD7D", "\U0001CD7E", "\U0001CD7F", + "\U0001CD80", "\U0001CD81", "\U0001CD82", "\U0001CD83", "\U0001CD84", "\U0001CD85", "\U0001CD86", "\U0001CD87", + "\U0001CD88", "\U0001CD89", "\U0001CD8A", "\U0001CD8B", "\U0001CD8C", "\U0001CD8D", "\U0001CD8E", "\U0001CD8F", + "\U00002597", "\U0001CD90", "\U0001CD91", "\U0001CD92", "\U0001CD93", "\U0000259A", "\U0001CD94", "\U0001CD95", + "\U0001CD96", "\U0001CD97", "\U00002590", "\U0001CD98", "\U0001CD99", "\U0001CD9A", "\U0001CD9B", "\U0000259C",*/ + + "\U0001cea0", // ๐œบ  128 lower right only (right half lower one quarter) + "\U0001cd70", // ๐œตฐ 127 missing lower right (u1234567) + + /*"\U0001CD69", "\U0001CD6A", "\U0001CD6B", "\U0001CD6C", "\U0001CD6D", "\U0001CD6E", "\U0001CD6F", "\U0001CD70", + "\U0001CD61", "\U0001CD62", "\U0001CD63", "\U0001CD64", "\U0001CD65", "\U0001CD66", "\U0001CD67", "\U0001CD68", + "\U0001CD59", "\U0001CD5A", "\U0001CD5B", "\U0001CD5C", "\U0001CD5D", "\U0001CD5E", "\U0001CD5F", "\U0001CD60", + "\U0001CD51", "\U0001CD52", "\U0001CD53", "\U0001CD54", "\U0001CD55", "\U0001CD56", "\U0001CD57", "\U0001CD58", + "\U0001CD4B", "\U0001CD4C", "\U0000259E", "\U0001CD4D", "\U0001CD4E", "\U0001CD4F", "\U0001CD50", "\U0000259B", + "\U00002596", "\U0001CD45", "\U0001CD46", "\U0001CD47", "\U0001CD48", "\U0000258C", "\U0001CD49", "\U0001CD4A", + "\U0001CD3D", "\U0001CD3E", "\U0001CD3F", "\U0001CD40", "\U0001CD41", "\U0001CD42", "\U0001CD43", "\U0001CD44", + "\U0001CEA3", "\U0001CD36", "\U0001CD37", "\U0001CD38", "\U0001CD39", "\U0001CD3A", "\U0001CD3B", "\U0001CD3C",*/ + + + "\U0001cea3", // ๐œบฃ 64 lower left only (left half lower one quarter) + "\U0001fb85", // ๐Ÿฎ… 63 row 0/1/2 full (upper three quarters) + "\U0001cd35", // ๐œดต 62 (o23456) + "\U0001cd34", // ๐œดด 61 (o13456) + "\U0001cd33", // ๐œดณ 60 (o3456) + "\U0001cd32", // ๐œดฒ 59 (o12456) + "\U0001cd31", // ๐œดฑ 58 (o2456) + "\U0001cd30", // ๐œดฐ 57 0 left 1 right 2 full (o1456) + "\U0001cd2f", // ๐œดฏ 56 (o456) + "\U0001cd2e", // ๐œดฎ 55 + "\U0001cd2d", // ๐œดญ 54 + "\U0001cd2c", // ๐œดฌ 53 + "\U0001cd2b", // ๐œดซ 52 + "\U0001cd2a", // ๐œดช 51 + "\U0001cd29", // ๐œดฉ 50 + "\U0001cd28", // ๐œดจ 49 + "\U0001cd27", // ๐œดง 48 + "\U0001cd26", // ๐œดฆ 47 (o12346) + "\U0001cd25", // ๐œดฅ 46 (o2346) + "\U0001cd24", // ๐œดค 45 (o1346) + "\U0001cd23", // ๐œดฃ 44 (o346) + "\U0001cd22", // ๐œดข 43 (o1246) + "\U0001cd21", // ๐œดก 42 (o246) + "\U0001cd20", // ๐œด  41 (o146) + "\U0001fbe7", // ๐Ÿฏง 40 (middle right one quarter) + "\U0001cd1f", // ๐œดŸ 39 (o1236) + "\U0001cd1e", // ๐œดž 38 (o236) + "\U0001cd1d", // ๐œด 37 (o136) + "\U0001cd1c", // ๐œดœ 36 (o36) + "\U0001cd1b", // ๐œด› 35 (o126) + "\U0001cd1a", // ๐œดš 34 (o26) + "\U0001cd19", // ๐œด™ 33 (o16) + "\U0001cd18", // ๐œด˜ 32 row 2 right only (o6) + "\U0001cd17", // ๐œด— 31 (o12345) + "\U0001cd16", // ๐œด– 30 (o2345) + "\U0001cd15", // ๐œด• 29 (o1345) + "\U0001cd14", // ๐œด” 28 (o345) + "\U0001cd13", // ๐œด“ 27 (o1245) + "\U0001cd12", // ๐œด’ 26 row 0/1 right row 2 l (o245) + "\U0001cd11", // ๐œด‘ 25 row 1/2 left row 1 r (o145) + "\U0001cd10", // ๐œด 24 row 1 right row 2 left (o45) + "\U0001cd0f", // ๐œด 23 row 0 full row 1/2 l (o1235) + "\U0001cd0e", // ๐œดŽ 22 row 1 right row 2/3 l (o235) + "\U0001cd0d", // ๐œด 21 row 0/1/2 left (o135) + "\U0001fbe6", // ๐Ÿฏฆ 20 row 1/2 left (middle left one quarter) + "\U0001cd0c", // ๐œดŒ 19 row 0 full row 2 left (o125) + "\U0001cd0b", // ๐œด‹ 18 row 0 right row 2 left (o25) + "\U0001cd0a", // ๐œดŠ 17 row 0 left row 2 left (o15) + "\U0001cd09", // ๐œด‰ 16 row 2 left only (o5) + "\U00002580", // โ–€ 15 row 0/1 full (upper half) + "\U0001cd08", // ๐œดˆ 14 row 0 right row 1 full (o234) + "\U0001cd07", // ๐œด‡ 13 row 0 left row 1 full (o134) + "\U0001cd06", // ๐œด† 12 row 1 full (o34) + "\U0001cd05", // ๐œด… 11 row 0 full row 1 right (o124) + "\U0000259d", // โ– 10 row 0/1 right only (upper right quadrant) + "\U0001cd04", // ๐œด„ 9 row 0 left row 1 right (o14) + "\U0001cd03", // ๐œดƒ 8 row 1 right only (o4) + "\U0001cd02", // ๐œด‚ 7 row 0 full row 1 left (o123) + "\U0001cd01", // ๐œด 6 row 0 right row 1 left (o23) + "\U00002598", // โ–˜ 5 row 0/1 left only (upper left quadrant) + "\U0001cd00", // ๐œด€ 4 row 1 left only (o3) + "\U0001f8b2", // ๐Ÿฎ‚ 3 row 0 (upper one quarter) + "\U0001ceab", // ๐œบซ 2 upper right only (right half upper one quarter) + "\U0001cea8", // ๐œบจ 1 upper left only (left half upper one quarter) + " " // 0 none set (space) }; static const char* @@ -764,47 +874,6 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans); } -// Bit is set where octant is present: -// 0 1 -// 2 3 -// 4 5 -// 6 7 -// Same as NCOCTBLOCKS but as array of fixed-width strings -static const char octant_egcs[256][5] = { - "\x20", "\U0001CEA8", "\U0001CEAB", "\U0001FB82", "\U0001CD00", "\U00002598", "\U0001CD01", "\U0001CD02", - "\U0001CD03", "\U0001CD04", "\U0000259D", "\U0001CD05", "\U0001CD06", "\U0001CD07", "\U0001CD08", "\U00002580", - "\U0001CD09", "\U0001CD0A", "\U0001CD0B", "\U0001CD0C", "\U0001FBE6", "\U0001CD0D", "\U0001CD0E", "\U0001CD0F", - "\U0001CD10", "\U0001CD11", "\U0001CD12", "\U0001CD13", "\U0001CD14", "\U0001CD15", "\U0001CD16", "\U0001CD17", - "\U0001CD18", "\U0001CD19", "\U0001CD1A", "\U0001CD1B", "\U0001CD1C", "\U0001CD1D", "\U0001CD1E", "\U0001CD1F", - "\U0001FBE7", "\U0001CD20", "\U0001CD21", "\U0001CD22", "\U0001CD23", "\U0001CD24", "\U0001CD25", "\U0001CD26", - "\U0001CD27", "\U0001CD28", "\U0001CD29", "\U0001CD2A", "\U0001CD2B", "\U0001CD2C", "\U0001CD2D", "\U0001CD2E", - "\U0001CD2F", "\U0001CD30", "\U0001CD31", "\U0001CD32", "\U0001CD33", "\U0001CD34", "\U0001CD35", "\U0001FB85", - "\U0001CEA3", "\U0001CD36", "\U0001CD37", "\U0001CD38", "\U0001CD39", "\U0001CD3A", "\U0001CD3B", "\U0001CD3C", - "\U0001CD3D", "\U0001CD3E", "\U0001CD3F", "\U0001CD40", "\U0001CD41", "\U0001CD42", "\U0001CD43", "\U0001CD44", - "\U00002596", "\U0001CD45", "\U0001CD46", "\U0001CD47", "\U0001CD48", "\U0000258C", "\U0001CD49", "\U0001CD4A", - "\U0001CD4B", "\U0001CD4C", "\U0000259E", "\U0001CD4D", "\U0001CD4E", "\U0001CD4F", "\U0001CD50", "\U0000259B", - "\U0001CD51", "\U0001CD52", "\U0001CD53", "\U0001CD54", "\U0001CD55", "\U0001CD56", "\U0001CD57", "\U0001CD58", - "\U0001CD59", "\U0001CD5A", "\U0001CD5B", "\U0001CD5C", "\U0001CD5D", "\U0001CD5E", "\U0001CD5F", "\U0001CD60", - "\U0001CD61", "\U0001CD62", "\U0001CD63", "\U0001CD64", "\U0001CD65", "\U0001CD66", "\U0001CD67", "\U0001CD68", - "\U0001CD69", "\U0001CD6A", "\U0001CD6B", "\U0001CD6C", "\U0001CD6D", "\U0001CD6E", "\U0001CD6F", "\U0001CD70", - "\U0001CEA0", "\U0001CD71", "\U0001CD72", "\U0001CD73", "\U0001CD74", "\U0001CD75", "\U0001CD76", "\U0001CD77", - "\U0001CD78", "\U0001CD79", "\U0001CD7A", "\U0001CD7B", "\U0001CD7C", "\U0001CD7D", "\U0001CD7E", "\U0001CD7F", - "\U0001CD80", "\U0001CD81", "\U0001CD82", "\U0001CD83", "\U0001CD84", "\U0001CD85", "\U0001CD86", "\U0001CD87", - "\U0001CD88", "\U0001CD89", "\U0001CD8A", "\U0001CD8B", "\U0001CD8C", "\U0001CD8D", "\U0001CD8E", "\U0001CD8F", - "\U00002597", "\U0001CD90", "\U0001CD91", "\U0001CD92", "\U0001CD93", "\U0000259A", "\U0001CD94", "\U0001CD95", - "\U0001CD96", "\U0001CD97", "\U00002590", "\U0001CD98", "\U0001CD99", "\U0001CD9A", "\U0001CD9B", "\U0000259C", - "\U0001CD9C", "\U0001CD9D", "\U0001CD9E", "\U0001CD9F", "\U0001CDA0", "\U0001CDA1", "\U0001CDA2", "\U0001CDA3", - "\U0001CDA4", "\U0001CDA5", "\U0001CDA6", "\U0001CDA7", "\U0001CDA8", "\U0001CDA9", "\U0001CDAA", "\U0001CDAB", - "\U00002582", "\U0001CDAC", "\U0001CDAD", "\U0001CDAE", "\U0001CDAF", "\U0001CDB0", "\U0001CDB1", "\U0001CDB2", - "\U0001CDB3", "\U0001CDB4", "\U0001CDB5", "\U0001CDB6", "\U0001CDB7", "\U0001CDB8", "\U0001CDB9", "\U0001CDBA", - "\U0001CDBB", "\U0001CDBC", "\U0001CDBD", "\U0001CDBE", "\U0001CDBF", "\U0001CDC0", "\U0001CDC1", "\U0001CDC2", - "\U0001CDC3", "\U0001CDC4", "\U0001CDC5", "\U0001CDC6", "\U0001CDC7", "\U0001CDC8", "\U0001CDC9", "\U0001CDCA", - "\U0001CDCB", "\U0001CDCC", "\U0001CDCD", "\U0001CDCE", "\U0001CDCF", "\U0001CDD0", "\U0001CDD1", "\U0001CDD2", - "\U0001CDD3", "\U0001CDD4", "\U0001CDD5", "\U0001CDD6", "\U0001CDD7", "\U0001CDD8", "\U0001CDD9", "\U0001CDDA", - "\U00002584", "\U0001CDDB", "\U0001CDDC", "\U0001CDDD", "\U0001CDDE", "\U00002599", "\U0001CDDF", "\U0001CDE0", - "\U0001CDE1", "\U0001CDE2", "\U0000259F", "\U0001CDE3", "\U00002586", "\U0001CDE4", "\U0001CDE5", "\U00002588", -}; - // Bit is set where Braille dot is present: // 0 1 // 2 3 From eef2f56f9c9740b0c0865c557df2ac293235b98b Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 07:06:12 -0500 Subject: [PATCH 08/23] finish octtrans EGC table --- src/lib/blit.c | 189 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 157 insertions(+), 32 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 0318e82f4..e56d6cafd 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -654,40 +654,165 @@ static const char* octtrans[256] = { "\U0001cdcd", // ๐œท 226 "\U0001cdcc", // ๐œทŒ 225 "\U0001cdcb", // ๐œท‹ 224 - /*"\U0001CDC3", "\U0001CDC4", "\U0001CDC5", "\U0001CDC6", "\U0001CDC7", "\U0001CDC8", "\U0001CDC9", "\U0001CDCA", - "\U0001CDBB", "\U0001CDBC", "\U0001CDBD", "\U0001CDBE", "\U0001CDBF", "\U0001CDC0", "\U0001CDC1", "\U0001CDC2", - "\U0001CDB3", "\U0001CDB4", "\U0001CDB5", "\U0001CDB6", "\U0001CDB7", "\U0001CDB8", "\U0001CDB9", "\U0001CDBA", - "\U00002582", "\U0001CDAC", "\U0001CDAD", "\U0001CDAE", "\U0001CDAF", "\U0001CDB0", "\U0001CDB1", "\U0001CDB2", - "\U0001CDA4", "\U0001CDA5", "\U0001CDA6", "\U0001CDA7", "\U0001CDA8", "\U0001CDA9", "\U0001CDAA", "\U0001CDAB", - "\U0001CDA3", - "\U0001CDA2", - "\U0001CDA1", - "\U0001CDA0", - "\U0001CD9F", - "\U0001CD9E", - "\U0001CD9D", - "\U0001CD9C",*/ - // 176 - /*"\U0001CEA0", "\U0001CD71", "\U0001CD72", "\U0001CD73", "\U0001CD74", "\U0001CD75", "\U0001CD76", "\U0001CD77", - "\U0001CD78", "\U0001CD79", "\U0001CD7A", "\U0001CD7B", "\U0001CD7C", "\U0001CD7D", "\U0001CD7E", "\U0001CD7F", - "\U0001CD80", "\U0001CD81", "\U0001CD82", "\U0001CD83", "\U0001CD84", "\U0001CD85", "\U0001CD86", "\U0001CD87", - "\U0001CD88", "\U0001CD89", "\U0001CD8A", "\U0001CD8B", "\U0001CD8C", "\U0001CD8D", "\U0001CD8E", "\U0001CD8F", - "\U00002597", "\U0001CD90", "\U0001CD91", "\U0001CD92", "\U0001CD93", "\U0000259A", "\U0001CD94", "\U0001CD95", - "\U0001CD96", "\U0001CD97", "\U00002590", "\U0001CD98", "\U0001CD99", "\U0001CD9A", "\U0001CD9B", "\U0000259C",*/ - + "\U0001cdca", + "\U0001cdc9", + "\U0001cdc8", + "\U0001cdc7", + "\U0001cdc6", + "\U0001cdc5", + "\U0001cdc4", + "\U0001cdc3", + "\U0001cdc2", + "\U0001cdc1", + "\U0001cdc0", + "\U0001cdbf", + "\U0001cdbe", + "\U0001cdbd", + "\U0001cdbc", + "\U0001cdbb", + "\U0001cdba", + "\U0001cdb9", + "\U0001cdb8", + "\U0001cdb7", + "\U0001cdb6", + "\U0001cdb5", + "\U0001cdb4", + "\U0001cdb3", + "\U0001cdb2", + "\U0001cdb1", + "\U0001cdb0", + "\U0001cdaf", + "\U0001cdae", + "\U0001cdad", + "\U0001cdac", + "\U00002582", // โ–‚ 196 (lower one quarter) + "\U0001cdab", + "\U0001cdaa", + "\U0001cda9", + "\U0001cda8", + "\U0001cda7", + "\U0001cda6", + "\U0001cda5", + "\U0001cda4", + "\U0001cda3", + "\U0001cda2", + "\U0001cda1", + "\U0001cda0", + "\U0001cd9f", + "\U0001cd9e", + "\U0001cd9d", + "\U0001cd9c", + "\U0000259c", // โ–œ 175 (q upper left and upper right and lower right) + "\U0001cd9b", + "\U0001cd9a", + "\U0001cd99", + "\U0001cd98", + "\U00002590", // โ– 170 (right half) + "\U0001cd97", + "\U0001cd96", + "\U0001cd95", + "\U0001cd94", + "\U0000259a", // โ–š (q upper left and lower right) + "\U0001cd93", + "\U0001cd92", + "\U0001cd91", + "\U0001cd90", + "\U00002597", // โ–— (q lower right) + "\U0001cd8f", + "\U0001cd8e", + "\U0001cd8d", + "\U0001cd8c", + "\U0001cd8b", + "\U0001cd8a", + "\U0001cd89", + "\U0001cd88", + "\U0001cd87", + "\U0001cd86", + "\U0001cd85", + "\U0001cd84", + "\U0001cd83", + "\U0001cd82", + "\U0001cd81", + "\U0001cd80", + "\U0001cd7f", + "\U0001cd7e", + "\U0001cd7d", + "\U0001cd7c", + "\U0001cd7b", + "\U0001cd7a", + "\U0001cd79", + "\U0001cd78", + "\U0001cd77", + "\U0001cd76", + "\U0001cd75", + "\U0001cd74", + "\U0001cd73", + "\U0001cd72", + "\U0001cd71", "\U0001cea0", // ๐œบ  128 lower right only (right half lower one quarter) "\U0001cd70", // ๐œตฐ 127 missing lower right (u1234567) - - /*"\U0001CD69", "\U0001CD6A", "\U0001CD6B", "\U0001CD6C", "\U0001CD6D", "\U0001CD6E", "\U0001CD6F", "\U0001CD70", - "\U0001CD61", "\U0001CD62", "\U0001CD63", "\U0001CD64", "\U0001CD65", "\U0001CD66", "\U0001CD67", "\U0001CD68", - "\U0001CD59", "\U0001CD5A", "\U0001CD5B", "\U0001CD5C", "\U0001CD5D", "\U0001CD5E", "\U0001CD5F", "\U0001CD60", - "\U0001CD51", "\U0001CD52", "\U0001CD53", "\U0001CD54", "\U0001CD55", "\U0001CD56", "\U0001CD57", "\U0001CD58", - "\U0001CD4B", "\U0001CD4C", "\U0000259E", "\U0001CD4D", "\U0001CD4E", "\U0001CD4F", "\U0001CD50", "\U0000259B", - "\U00002596", "\U0001CD45", "\U0001CD46", "\U0001CD47", "\U0001CD48", "\U0000258C", "\U0001CD49", "\U0001CD4A", - "\U0001CD3D", "\U0001CD3E", "\U0001CD3F", "\U0001CD40", "\U0001CD41", "\U0001CD42", "\U0001CD43", "\U0001CD44", - "\U0001CEA3", "\U0001CD36", "\U0001CD37", "\U0001CD38", "\U0001CD39", "\U0001CD3A", "\U0001CD3B", "\U0001CD3C",*/ - - + "\U0001cd6f", + "\U0001cd6e", + "\U0001cd6d", + "\U0001cd6c", + "\U0001cd6b", + "\U0001cd6a", + "\U0001cd69", + "\U0001cd68", + "\U0001cd67", + "\U0001cd66", + "\U0001cd65", + "\U0001cd64", + "\U0001cd63", + "\U0001cd62", + "\U0001cd61", + "\U0001cd60", + "\U0001cd5f", + "\U0001cd5e", + "\U0001cd5d", + "\U0001cd5c", + "\U0001cd5b", + "\U0001cd5a", + "\U0001cd59", + "\U0001cd58", + "\U0001cd57", + "\U0001cd56", + "\U0001cd55", + "\U0001cd54", + "\U0001cd53", + "\U0001cd52", + "\U0001cd51", + "\U0000259b", // โ–› 95 0/1 full 2/3 left (q upper left and upper right and lower left) + "\U0001cd50", + "\U0001cd4f", + "\U0001cd4e", + "\U0001cd4d", + "\U0000259e", // โ–ž 92 0/1 right 2/3 left (q upper right and lower left) + "\U0001cd4c", + "\U0001cd4b", + "\U0001cd4a", + "\U0001cd49", + "\U0000258c", // โ–Œ 85 0/1/2/3 left (left block) + "\U0001cd48", + "\U0001cd47", + "\U0001cd46", + "\U0001cd45", + "\U00002596", // โ–– 80 2/3 left (q lower left) + "\U0001cd44", + "\U0001cd43", + "\U0001cd42", + "\U0001cd41", + "\U0001cd40", + "\U0001cd3f", + "\U0001cd3e", + "\U0001cd3d", + "\U0001cd3c", + "\U0001cd3b", + "\U0001cd3a", + "\U0001cd39", + "\U0001cd38", + "\U0001cd37", // ๐œดท 66 0 right 3 left (o27) + "\U0001cd36", // ๐œดถ 65 0 left 3 left (o17) "\U0001cea3", // ๐œบฃ 64 lower left only (left half lower one quarter) "\U0001fb85", // ๐Ÿฎ… 63 row 0/1/2 full (upper three quarters) "\U0001cd35", // ๐œดต 62 (o23456) From 6e14eb0d55e38d159499c831539c9b02737e2d43 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 07:40:26 -0500 Subject: [PATCH 09/23] genericize hires call to cell_set_bitquadrant() --- src/lib/blit.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index e56d6cafd..a0159d573 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -891,20 +891,20 @@ hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, for(int mask = 0 ; mask < cellheight * 2 ; ++mask){ if(rgba_trans_p(rgbas[mask], transcolor)){ transstring |= (1u << mask); - }else if(!nointerpolate || !div){ + }else if(!nointerpolate || !div){ // force an initialization if nointerpolate r += ncpixel_r(rgbas[mask]); g += ncpixel_g(rgbas[mask]); b += ncpixel_b(rgbas[mask]); ++div; } } - // transstring can only have 0x80 and/or 0x40 set if cellheight was 4 if(transstring == 0){ // there was no transparency return NULL; } nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); // there were some transparent pixels. since they get priority, the foreground - // is just a general lerp across non-transparent pixels. + // is just a general lerp across non-transparent pixels. transstring can only + // have 0x80 and/or 0x40 set if cellheight was 4. const char* egc = transegcs[transstring]; nccell_set_bg_alpha(c, NCALPHA_TRANSPARENT); //fprintf(stderr, "transtring: %u egc: %s\n", transtring, egc); @@ -917,9 +917,13 @@ hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, if(blendcolors){ nccell_set_fg_alpha(c, NCALPHA_BLEND); } - // FIXME genericize for hires - cell_set_blitquadrants(c, !(transstring & 5u), !(transstring & 10u), - !(transstring & 20u), !(transstring & 40u)); + if(cellheight == 3){ + cell_set_blitquadrants(c, !(transstring & 0x5), !(transstring & 0xa), + !(transstring & 0x14), !(transstring & 0x28)); + }else{ + cell_set_blitquadrants(c, !(transstring & 0x5), !(transstring & 0xa), + !(transstring & 0x50), !(transstring & 0xa0)); + } } //fprintf(stderr, "SEX-BQ: 0x%x\n", cell_blittedquadrants(c)); return egc; From 2358cb9fa7bd613ccee1b3b8e7dd10c7e738a0b8 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 07:59:55 -0500 Subject: [PATCH 10/23] genericize hires_solver() by passing in egc/partition sets --- src/lib/blit.c | 77 +++++++++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index a0159d573..56cf80ffb 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -516,32 +516,15 @@ quadrant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, // resulting lerps. static const char* hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, - unsigned nointerpolate, unsigned cellheight){ - // FIXME need genericize to hires - // each element within the set of 64 has an inverse element within the set, - // for which we would calculate the same total differences, so just handle - // the first 32. the partition[] bit masks represent combinations of - // sextants, and their indices correspond to sex[]. - static const char* sex[32] = { - " ", "๐Ÿฌ€", "๐Ÿฌ", "๐Ÿฌƒ", "๐Ÿฌ‡", "๐Ÿฌ", "๐Ÿฌž", "๐Ÿฌ‚", // 0..7 - "๐Ÿฌ„", "๐Ÿฌˆ", "๐Ÿฌ", "๐ŸฌŸ", "๐Ÿฌ…", "๐Ÿฌ‰", "๐Ÿฌ‘", "๐Ÿฌ ", // 8..15 - "๐Ÿฌ‹", "๐Ÿฌ“", "๐Ÿฌข", "๐Ÿฌ–", "๐Ÿฌฆ", "๐Ÿฌญ", "๐Ÿฌ†", "๐ŸฌŠ", // 16..23 - "๐Ÿฌ’", "๐Ÿฌก", "๐ŸฌŒ", "โ–Œ", "๐Ÿฌฃ", "๐Ÿฌ—", "๐Ÿฌง", "๐Ÿฌฎ", // 24..31 - }; - static const unsigned partitions[32] = { - 0, // 1 way to arrange 0 - 1, 2, 4, 8, 16, 32, // 6 ways to arrange 1 - 3, 5, 9, 17, 33, 6, 10, 18, 34, 12, 20, 36, 24, 40, 48, // 15 ways for 2 - // 16 ways to arrange 3, *but* six of them are inverses, so 10 - 7, 11, 19, 35, 13, 21, 37, 25, 41, 49 // 10 + 15 + 6 + 1 == 32 - }; + unsigned nointerpolate, unsigned cellheight, const char** egcs, + const unsigned* partitions, unsigned parcount){ // we loop over the bitstrings, dividing the pixels into two sets, and then // taking a general lerp over each set. we then compute the sum of absolute // differences, and see if it's the new minimum. int best = -1; uint32_t mindiff = UINT_MAX; //fprintf(stderr, "%06x %06x\n%06x %06x\n%06x %06x\n", rgbas[0], rgbas[1], rgbas[2], rgbas[3], rgbas[4], rgbas[5]); - for(size_t glyph = 0 ; glyph < sizeof(partitions) / sizeof(*partitions) ; ++glyph){ + for(size_t glyph = 0 ; glyph < parcount ; ++glyph){ unsigned rsum0 = 0, rsum1 = 0; unsigned gsum0 = 0, gsum1 = 0; unsigned bsum0 = 0, bsum1 = 0; @@ -592,12 +575,12 @@ hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, } } //fprintf(stderr, "solved for best: %d (%u)\n", best, mindiff); - assert(best >= 0 && best < 32); // FIXME adapt to oct + assert(best >= 0 && best < (1u << (cellheight * 2) - 1)); if(blendcolors){ ncchannels_set_fg_alpha(channels, NCALPHA_BLEND); ncchannels_set_bg_alpha(channels, NCALPHA_BLEND); } - return sex[best]; + return egcs[best]; } // FIXME replace both of these arrays of pointers with fixed-width matrices @@ -605,7 +588,7 @@ hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, // 32: bottom right 16: bottom left // 8: middle right 4: middle left // 2: upper right 1: upper left -static const char* sextrans[64] = { +static const char* const sextrans[64] = { "โ–ˆ", "๐Ÿฌป", "๐Ÿฌบ", "๐Ÿฌน", "๐Ÿฌธ", "๐Ÿฌท", "๐Ÿฌถ", "๐Ÿฌต", "๐Ÿฌด", "๐Ÿฌณ", "๐Ÿฌฒ", "๐Ÿฌฑ", "๐Ÿฌฐ", "๐Ÿฌฏ", "๐Ÿฌฎ", "๐Ÿฌญ", "๐Ÿฌฌ", "๐Ÿฌซ", "๐Ÿฌช", "๐Ÿฌฉ", "๐Ÿฌจ", "โ–", "๐Ÿฌง", "๐Ÿฌฆ", @@ -621,7 +604,7 @@ static const char* sextrans[64] = { // 4: row 1 left 8: row 1 right // 16: row 2 left 32: row 2 right // 64: row 3 left 128: row 3 right -static const char* octtrans[256] = { +static const char* const octtrans[256] = { "\U00002588", // โ–ˆ 255 all eight set (full) "\U0001cde5", // ๐œทฅ 254 missing upper left (o2345678) "\U0001cde4", // ๐œทค 253 missing upper right (o1345678) @@ -883,7 +866,7 @@ static const char* octtrans[256] = { static const char* hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, uint32_t transcolor, unsigned nointerpolate, int cellheight, - const char** transegcs){ + const char* const* transegcs){ unsigned transstring = 0; unsigned r = 0, g = 0, b = 0; unsigned div = 0; @@ -935,7 +918,8 @@ hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, static inline int hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs, int cellheight, - const char** transegcs){ + const char* const* transegcs, const char **egcs, + const unsigned* partitions, unsigned parcount){ const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE; const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND; unsigned dimy, dimx, x, y; @@ -974,7 +958,8 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const char* egc = hires_trans_check(c, rgbas, blendcolors, bargs->transcolor, nointerpolate, cellheight, transegcs); if(egc == NULL){ // no transparency; run a full solver - egc = hires_solver(rgbas, &c->channels, blendcolors, nointerpolate, cellheight); + egc = hires_solver(rgbas, &c->channels, blendcolors, nointerpolate, + cellheight, egcs, partitions, parcount); cell_set_blitquadrants(c, 1, 1, 1, 1); } //fprintf(stderr, "hires EGC: %s channels: %016lx\n", egc, c->channels); @@ -994,13 +979,47 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, static inline int sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs){ - return hires_blit(nc, linesize, data, leny, lenx, bargs, 3, sextrans); + // each element within the set of 64 has an inverse element within the set, + // for which we would calculate the same total differences, so just handle + // the first 32. the sextition[] bit masks represent combinations of + // sextants, and their indices correspond to sex[]. + static const char* sex[32] = { + " ", "๐Ÿฌ€", "๐Ÿฌ", "๐Ÿฌƒ", "๐Ÿฌ‡", "๐Ÿฌ", "๐Ÿฌž", "๐Ÿฌ‚", // 0..7 + "๐Ÿฌ„", "๐Ÿฌˆ", "๐Ÿฌ", "๐ŸฌŸ", "๐Ÿฌ…", "๐Ÿฌ‰", "๐Ÿฌ‘", "๐Ÿฌ ", // 8..15 + "๐Ÿฌ‹", "๐Ÿฌ“", "๐Ÿฌข", "๐Ÿฌ–", "๐Ÿฌฆ", "๐Ÿฌญ", "๐Ÿฌ†", "๐ŸฌŠ", // 16..23 + "๐Ÿฌ’", "๐Ÿฌก", "๐ŸฌŒ", "โ–Œ", "๐Ÿฌฃ", "๐Ÿฌ—", "๐Ÿฌง", "๐Ÿฌ", // 24..31 + }; + static const unsigned sextitions[32] = { + 0, // 1 way to arrange 0 + 1, 2, 4, 8, 16, 32, // 6 ways to arrange 1 + 3, 5, 9, 17, 33, 6, 10, 18, 34, 12, 20, 36, 24, 40, 48, // 15 ways for 2 + // 16 ways to arrange 3, *but* six of them are inverses, so 10 + 7, 11, 19, 35, 13, 21, 37, 25, 41, 14 // 10 + 15 + 6 + 1 == 32 + }; + return hires_blit(nc, linesize, data, leny, lenx, bargs, 3, sextrans, + sex, sextitions, sizeof(sextitions) / sizeof(*sextitions)); } static inline int octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs){ - return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans); + // FIXME define octant sets + // each element within the set of 256 has an inverse element within the set, + // for which we would calculate the same total differences, so just handle + // the first 128. the octition[] bit masks represent combinations of + // octants, and their indices correspond to sex[]. + static const char* oct[128] = { + octtrans[255], + }; + static const unsigned octitions[] = { + 0, // 1 way to arrange 0 + 1, 2, 4, 8, 16, 32, 64, 128, // 8 ways to arrange 1 + // 28 ways for 2 FIXME + // 56 ways for 3 FIXME + // 70 ways for 4, but there are inverses among them FIXME + }; + return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans, + oct, octitions, sizeof(octitions) / sizeof(*octitions)); } // Bit is set where Braille dot is present: From cd7dfb7a77ab6fe0083912b41c9146b08f02e6f0 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 08:11:17 -0500 Subject: [PATCH 11/23] comment up octtrans table some more, meditating --- src/lib/blit.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 56cf80ffb..70ec99227 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -632,47 +632,47 @@ static const char* const octtrans[256] = { "\U0001cdd2", // ๐œท’ 231 "\U0001cdd1", // ๐œท‘ 230 "\U0001cdd0", // ๐œท 229 - "\U0001cdcf", // ๐œท 228 + "\U0001cdcf", // ๐œท 228 (o145678) "\U0001cdce", // ๐œทŽ 227 "\U0001cdcd", // ๐œท 226 "\U0001cdcc", // ๐œทŒ 225 - "\U0001cdcb", // ๐œท‹ 224 + "\U0001cdcb", // ๐œท‹ 224 (o678) "\U0001cdca", "\U0001cdc9", "\U0001cdc8", - "\U0001cdc7", + "\U0001cdc7", // ๐œท‡ 220 (o34578) "\U0001cdc6", "\U0001cdc5", "\U0001cdc4", - "\U0001cdc3", + "\U0001cdc3", // ๐œทƒ 216 (o4578) "\U0001cdc2", "\U0001cdc1", "\U0001cdc0", - "\U0001cdbf", + "\U0001cdbf", // ๐œถฟ 212 (o3578) "\U0001cdbe", "\U0001cdbd", "\U0001cdbc", - "\U0001cdbb", + "\U0001cdbb", // ๐œถป 208 (o578) "\U0001cdba", "\U0001cdb9", "\U0001cdb8", - "\U0001cdb7", + "\U0001cdb7", // ๐œถท 204 (o4578) "\U0001cdb6", "\U0001cdb5", "\U0001cdb4", - "\U0001cdb3", + "\U0001cdb3", // ๐œถณ 200 (o478) "\U0001cdb2", "\U0001cdb1", "\U0001cdb0", - "\U0001cdaf", + "\U0001cdaf", // ๐œถฏ 196 (o378) "\U0001cdae", "\U0001cdad", "\U0001cdac", - "\U00002582", // โ–‚ 196 (lower one quarter) + "\U00002582", // โ–‚ 192 (lower one quarter) "\U0001cdab", "\U0001cdaa", "\U0001cda9", - "\U0001cda8", + "\U0001cda8", // ๐œถจ 188 (o34568) "\U0001cda7", "\U0001cda6", "\U0001cda5", @@ -685,50 +685,50 @@ static const char* const octtrans[256] = { "\U0001cd9e", "\U0001cd9d", "\U0001cd9c", - "\U0000259c", // โ–œ 175 (q upper left and upper right and lower right) + "\U0000259c", // โ–œ 175 (q upper left and upper right and lower right) "\U0001cd9b", "\U0001cd9a", "\U0001cd99", "\U0001cd98", - "\U00002590", // โ– 170 (right half) + "\U00002590", // โ– 170 (right half) "\U0001cd97", "\U0001cd96", "\U0001cd95", "\U0001cd94", - "\U0000259a", // โ–š (q upper left and lower right) + "\U0000259a", // โ–š 165 (q upper left and lower right) "\U0001cd93", "\U0001cd92", "\U0001cd91", "\U0001cd90", - "\U00002597", // โ–— (q lower right) + "\U00002597", // โ–— 160 (q lower right) "\U0001cd8f", "\U0001cd8e", "\U0001cd8d", - "\U0001cd8c", + "\U0001cd8c", // ๐œถŒ 156 (u3458) "\U0001cd8b", "\U0001cd8a", "\U0001cd89", - "\U0001cd88", + "\U0001cd88", // ๐œถˆ 152 (u458) "\U0001cd87", "\U0001cd86", "\U0001cd85", - "\U0001cd84", + "\U0001cd84", // ๐œถ„ 148 (u358) "\U0001cd83", "\U0001cd82", "\U0001cd81", - "\U0001cd80", + "\U0001cd80", // ๐œถ€ 144 (u58) "\U0001cd7f", "\U0001cd7e", "\U0001cd7d", - "\U0001cd7c", + "\U0001cd7c", // ๐œตผ 140 (u348) "\U0001cd7b", "\U0001cd7a", "\U0001cd79", - "\U0001cd78", + "\U0001cd78", // ๐œตธ 136 (u48) "\U0001cd77", "\U0001cd76", "\U0001cd75", - "\U0001cd74", + "\U0001cd74", // ๐œตด 132 (u38) "\U0001cd73", "\U0001cd72", "\U0001cd71", @@ -860,7 +860,7 @@ static const char* const octtrans[256] = { "\U0001f8b2", // ๐Ÿฎ‚ 3 row 0 (upper one quarter) "\U0001ceab", // ๐œบซ 2 upper right only (right half upper one quarter) "\U0001cea8", // ๐œบจ 1 upper left only (left half upper one quarter) - " " // 0 none set (space) + " " // 0 none set (space) }; static const char* From a3db5f2e49c26ad9977862b01d4774dbab3aec8b Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 08:32:57 -0500 Subject: [PATCH 12/23] degenericize blit_4x2() -> braille_blit() --- src/lib/blit.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 70ec99227..611097b69 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -1074,14 +1074,10 @@ fold_rgb8(unsigned* restrict r, unsigned* restrict g, unsigned* restrict b, ++*foldcount; } -// generic 4x2 blitter, used for octant and Braille. maps 4x2 to each -// cell. since we only have one color at our disposal (foreground), we -// lose some fidelity. this is optimal for visuals with only two -// colors in a given area, as it packs lots of resolution. always -// transparent background. +// Braille maps 4x2 to each cell, always using a transparent background. static inline int -blit_4x2(ncplane* nc, int linesize, const void* data, int leny, int lenx, - const blitterargs* bargs, const char egcs[256][5]){ +braille_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, + const blitterargs* bargs){ const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND; unsigned dimy, dimx, x, y; int total = 0; // number of cells written @@ -1185,7 +1181,7 @@ blit_4x2(ncplane* nc, int linesize, const void* data, int leny, int lenx, if(blends){ nccell_set_fg_rgb8(c, r / blends, g / blends, b / blends); } - const char* egc = egcs[egcidx]; + const char* egc = braille_egcs[egcidx]; if(pool_blit_direct(&nc->pool, c, egc, strlen(egc), 1) <= 0){ return -1; } @@ -1196,12 +1192,6 @@ blit_4x2(ncplane* nc, int linesize, const void* data, int leny, int lenx, return total; } -static inline int -braille_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, - const blitterargs* bargs){ - return blit_4x2(nc, linesize, data, leny, lenx, bargs, braille_egcs); -} - // NCBLIT_DEFAULT is not included, as it has no defined properties. It ought // be replaced with some real blitter implementation by the calling widget. // The order of contents is critical for 'egcs': ncplane_as_rgba() uses these From 6252a3b2e656a5e45f3a3d06adb821d9f48c0d47 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 09:19:07 -0500 Subject: [PATCH 13/23] build out oct[] and octitions[] --- src/lib/blit.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 611097b69..4c319c132 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -1010,11 +1010,37 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, // octants, and their indices correspond to sex[]. static const char* oct[128] = { octtrans[255], + // one set + octtrans[254], + octtrans[253], + octtrans[251], + octrrans[247], + octtrans[239], + octtrans[223], + octtrans[191], + octtrans[127], + // two set (7 + 6 + 5 + 4 + 3 + 2 + 1) + octtrans[252], octtrans[250], octtrans[246], octtrans[238], octtrans[222], octtrans[190], octtrans[126], // 1+2 + octtrans[249], octtrans[245], octtrans[237], octtrans[221], octtrans[189], octtrans[125], // 2+3 + octtrans[243], octtrans[235], octtrans[219], octtrans[187], octtrans[123], // 3+4 + octtrans[231], octtrans[215], octtrans[183], octtrans[119], // 4+5 + octtrans[207], octtrans[175], octtrans[111], // 5+6 + octtrans[159], octtrans[95], // 6+7 + octtrans[63], // 7+8 + // FIXME three set + // FIXME four set }; static const unsigned octitions[] = { 0, // 1 way to arrange 0 1, 2, 4, 8, 16, 32, 64, 128, // 8 ways to arrange 1 - // 28 ways for 2 FIXME + // 28 ways for 2 + 3, 5, 9, 17, 33, 65, 129, + 6, 10, 18, 34, 66, 130, + 12, 20, 36, 68, 132, + 24, 40, 72, 136, + 48, 80, 144, + 96, 160, + 192 // 56 ways for 3 FIXME // 70 ways for 4, but there are inverses among them FIXME }; From c5f5e80863c57396387352cca6fc7fe1c26962f9 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 09:30:12 -0500 Subject: [PATCH 14/23] continue building up octitions --- src/lib/blit.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 4c319c132..15354318d 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -1027,21 +1027,25 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, octtrans[207], octtrans[175], octtrans[111], // 5+6 octtrans[159], octtrans[95], // 6+7 octtrans[63], // 7+8 - // FIXME three set + // three set (21 + 15 + 10 + 6 + 3 + 1) + // FIXME + octrrans[143], octtrans[47], // 5+6+7 + octtrans[31], // 6+7+8 // FIXME four set }; static const unsigned octitions[] = { 0, // 1 way to arrange 0 1, 2, 4, 8, 16, 32, 64, 128, // 8 ways to arrange 1 - // 28 ways for 2 3, 5, 9, 17, 33, 65, 129, 6, 10, 18, 34, 66, 130, 12, 20, 36, 68, 132, 24, 40, 72, 136, 48, 80, 144, 96, 160, - 192 - // 56 ways for 3 FIXME + 192, // 28 ways for 2 + // FIXME + 112, 208, + 224 // 56 ways for 3 // 70 ways for 4, but there are inverses among them FIXME }; return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans, From f29a3c3ad4b405d2558ef1f2c1779e888bef35bb Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 10:35:43 -0500 Subject: [PATCH 15/23] remaining octants --- src/lib/blit.c | 97 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 23 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 15354318d..0eeb0ed96 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -987,7 +987,7 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, " ", "๐Ÿฌ€", "๐Ÿฌ", "๐Ÿฌƒ", "๐Ÿฌ‡", "๐Ÿฌ", "๐Ÿฌž", "๐Ÿฌ‚", // 0..7 "๐Ÿฌ„", "๐Ÿฌˆ", "๐Ÿฌ", "๐ŸฌŸ", "๐Ÿฌ…", "๐Ÿฌ‰", "๐Ÿฌ‘", "๐Ÿฌ ", // 8..15 "๐Ÿฌ‹", "๐Ÿฌ“", "๐Ÿฌข", "๐Ÿฌ–", "๐Ÿฌฆ", "๐Ÿฌญ", "๐Ÿฌ†", "๐ŸฌŠ", // 16..23 - "๐Ÿฌ’", "๐Ÿฌก", "๐ŸฌŒ", "โ–Œ", "๐Ÿฌฃ", "๐Ÿฌ—", "๐Ÿฌง", "๐Ÿฌ", // 24..31 + "๐Ÿฌ’", "๐Ÿฌก", "๐ŸฌŒ", "โ–Œ", "๐Ÿฌฃ", "๐Ÿฌ—", "๐Ÿฌง", "๐Ÿฌฎ", // 24..31 }; static const unsigned sextitions[32] = { 0, // 1 way to arrange 0 @@ -1008,30 +1008,81 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, // for which we would calculate the same total differences, so just handle // the first 128. the octition[] bit masks represent combinations of // octants, and their indices correspond to sex[]. +#define T(sum) (255 - (sum)) +#define E(bits) (1u << (bits)) static const char* oct[128] = { - octtrans[255], + octtrans[T(0)], // one set - octtrans[254], - octtrans[253], - octtrans[251], - octrrans[247], - octtrans[239], - octtrans[223], - octtrans[191], - octtrans[127], - // two set (7 + 6 + 5 + 4 + 3 + 2 + 1) - octtrans[252], octtrans[250], octtrans[246], octtrans[238], octtrans[222], octtrans[190], octtrans[126], // 1+2 - octtrans[249], octtrans[245], octtrans[237], octtrans[221], octtrans[189], octtrans[125], // 2+3 - octtrans[243], octtrans[235], octtrans[219], octtrans[187], octtrans[123], // 3+4 - octtrans[231], octtrans[215], octtrans[183], octtrans[119], // 4+5 - octtrans[207], octtrans[175], octtrans[111], // 5+6 - octtrans[159], octtrans[95], // 6+7 - octtrans[63], // 7+8 - // three set (21 + 15 + 10 + 6 + 3 + 1) - // FIXME - octrrans[143], octtrans[47], // 5+6+7 - octtrans[31], // 6+7+8 - // FIXME four set + octtrans[T(E(0))], + octtrans[T(E(1))], + octtrans[T(E(2))], + octtrans[T(E(3))], + octtrans[T(E(4))], + octtrans[T(E(5))], + octtrans[T(E(6))], + octtrans[T(E(7))], + // two set (7 + 6 + 5 + 4 + 3 + 2 + 1 = 28) + octtrans[T(E(0) + E(1))], octtrans[T(E(0) + E(2))], octtrans[T(E(0) + E(3))], + octtrans[T(E(0) + E(4))], octtrans[T(E(0) + E(5))], octtrans[T(E(0) + E(6))], + octtrans[T(E(0) + E(7))], // 0 + 1... + octtrans[T(E(1) + E(2))], octtrans[T(E(1) + E(3))], octtrans[T(E(1) + E(4))], + octtrans[T(E(1) + E(5))], octtrans[T(E(1) + E(6))], octtrans[T(E(1) + E(7))], // 1 + 2... + octtrans[T(E(2) + E(3))], octtrans[T(E(2) + E(4))], octtrans[T(E(2) + E(5))], + octtrans[T(E(2) + E(6))], octtrans[T(E(2) + E(7))], // 2 + 3... + octtrans[T(E(3) + E(4))], octtrans[T(E(3) + E(5))], octtrans[T(E(3) + E(6))], + octtrans[T(E(3) + E(7))], // 3 + 4... + octtrans[T(E(4) + E(5))], octtrans[T(E(4) + E(6))], octtrans[T(E(4) + E(7))], // 4 + 5... + octtrans[T(E(5) + E(6))], octtrans[T(E(5) + E(7))], // 5 + 6... + octtrans[T(E(6) + E(7))], // 6 + 7 + // three set (21 + 15 + 10 + 6 + 3 + 1 = 56) + octtrans[T(E(0) + E(1) + E(2))], octtrans[T(E(0) + E(1) + E(3))], octtrans[T(E(0) + E(1) + E(4))], + octtrans[T(E(0) + E(1) + E(5))], octtrans[T(E(0) + E(1) + E(6))], octtrans[T(E(0) + E(1) + E(7))], // 0 + 1 + 2... + octtrans[T(E(0) + E(2) + E(3))], octtrans[T(E(0) + E(2) + E(4))], octtrans[T(E(0) + E(2) + E(5))], + octtrans[T(E(0) + E(2) + E(6))], octtrans[T(E(0) + E(2) + E(7))], // 0 + 2 + 3... + octtrans[T(E(0) + E(3) + E(4))], octtrans[T(E(0) + E(3) + E(5))], octtrans[T(E(0) + E(3) + E(6))], + octtrans[T(E(0) + E(3) + E(7))], // 3 + 4... + octtrans[T(E(0) + E(4) + E(5))], octtrans[T(E(0) + E(4) + E(6))], octtrans[T(E(0) + E(4) + E(7))], // 0 + 4 + 5... + octtrans[T(E(0) + E(5) + E(6))], octtrans[T(E(0) + E(5) + E(7))], // 0 + 5 + 6... + octtrans[T(E(0) + E(6) + E(7))], // 0 + 6 + 7 + octtrans[T(E(1) + E(2) + E(3))], octtrans[T(E(1) + E(2) + E(4))], octtrans[T(E(1) + E(2) + E(5))], + octtrans[T(E(1) + E(2) + E(6))], octtrans[T(E(1) + E(2) + E(7))], + octtrans[T(E(1) + E(3) + E(4))], octtrans[T(E(1) + E(3) + E(5))], octtrans[T(E(1) + E(3) + E(6))], + octtrans[T(E(1) + E(3) + E(7))], + octtrans[T(E(1) + E(4) + E(5))], octtrans[T(E(1) + E(4) + E(6))], octtrans[T(E(1) + E(4) + E(7))], + octtrans[T(E(1) + E(5) + E(6))], octtrans[T(E(1) + E(5) + E(7))], + octtrans[T(E(1) + E(6) + E(7))], + octtrans[T(E(2) + E(3) + E(4))], octtrans[T(E(2) + E(3) + E(5))], octtrans[T(E(2) + E(3) + E(6))], + octtrans[T(E(2) + E(3) + E(7))], + octtrans[T(E(2) + E(4) + E(5))], octtrans[T(E(2) + E(4) + E(6))], octtrans[T(E(2) + E(4) + E(7))], + octtrans[T(E(2) + E(5) + E(6))], octtrans[T(E(2) + E(5) + E(7))], + octtrans[T(E(2) + E(6) + E(7))], + octtrans[T(E(3) + E(4) + E(5))], octtrans[T(E(3) + E(4) + E(6))], octtrans[T(E(3) + E(4) + E(7))], + octtrans[T(E(3) + E(5) + E(6))], octtrans[T(E(3) + E(5) + E(7))], + octtrans[T(E(3) + E(6) + E(7))], + octtrans[T(E(4) + E(5) + E(6))], octtrans[T(E(4) + E(5) + E(7))], + octtrans[T(E(4) + E(6) + E(7))], + octtrans[T(E(5) + E(6) + E(7))], // 5 + 6 + 7 + // four set (15 + 10 + 6 + 3 + 1 = 35) + octtrans[T(E(0) + E(1) + E(2) + E(3))], octtrans[T(E(0) + E(1) + E(2) + E(4))], octtrans[T(E(0) + E(1) + E(2) + E(5))], + octtrans[T(E(0) + E(1) + E(2) + E(6))], octtrans[T(E(0) + E(1) + E(2) + E(7))], + octtrans[T(E(0) + E(1) + E(3) + E(4))], octtrans[T(E(0) + E(1) + E(3) + E(5))], octtrans[T(E(0) + E(1) + E(3) + E(6))], + octtrans[T(E(0) + E(1) + E(3) + E(7))], + octtrans[T(E(0) + E(1) + E(4) + E(5))], octtrans[T(E(0) + E(1) + E(4) + E(6))], octtrans[T(E(0) + E(1) + E(4) + E(7))], + octtrans[T(E(0) + E(1) + E(5) + E(6))], octtrans[T(E(0) + E(1) + E(5) + E(7))], + octtrans[T(E(0) + E(1) + E(6) + E(7))], + octtrans[T(E(0) + E(2) + E(3) + E(4))], octtrans[T(E(0) + E(2) + E(3) + E(5))], octtrans[T(E(0) + E(2) + E(3) + E(6))], + octtrans[T(E(0) + E(2) + E(3) + E(7))], + octtrans[T(E(0) + E(2) + E(4) + E(5))], octtrans[T(E(0) + E(2) + E(4) + E(6))], octtrans[T(E(0) + E(2) + E(4) + E(7))], + octtrans[T(E(0) + E(2) + E(5) + E(6))], octtrans[T(E(0) + E(2) + E(5) + E(7))], + octtrans[T(E(0) + E(2) + E(6) + E(7))], + octtrans[T(E(0) + E(3) + E(4) + E(5))], octtrans[T(E(0) + E(3) + E(4) + E(6))], octtrans[T(E(0) + E(3) + E(4) + E(7))], + octtrans[T(E(0) + E(3) + E(5) + E(6))], octtrans[T(E(0) + E(3) + E(5) + E(7))], + octtrans[T(E(0) + E(3) + E(6) + E(7))], + octtrans[T(E(0) + E(4) + E(5) + E(6))], octtrans[T(E(0) + E(4) + E(5) + E(7))], + octtrans[T(E(0) + E(4) + E(6) + E(7))], + octtrans[T(E(0) + E(5) + E(6) + E(7))], // 0 + 5 + 6 + 7 +#undef E +#undef T }; static const unsigned octitions[] = { 0, // 1 way to arrange 0 From 3f3d682a8d08abf2521e48c09676784c5294671c Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 10:38:21 -0500 Subject: [PATCH 16/23] octblitter: fix transposition for upper one quarter --- src/lib/blit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 0eeb0ed96..5981f750f 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -857,7 +857,7 @@ static const char* const octtrans[256] = { "\U0001cd01", // ๐œด 6 row 0 right row 1 left (o23) "\U00002598", // โ–˜ 5 row 0/1 left only (upper left quadrant) "\U0001cd00", // ๐œด€ 4 row 1 left only (o3) - "\U0001f8b2", // ๐Ÿฎ‚ 3 row 0 (upper one quarter) + "\U0001fb82", // ๐Ÿฎ‚ 3 row 0 (upper one quarter) "\U0001ceab", // ๐œบซ 2 upper right only (right half upper one quarter) "\U0001cea8", // ๐œบจ 1 upper left only (left half upper one quarter) " " // 0 none set (space) From ec8d28efb5a53500f714203b95d1c02cabfd58ca Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 11:17:35 -0500 Subject: [PATCH 17/23] more octitioins --- src/lib/blit.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 5981f750f..c808273fa 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -994,7 +994,7 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, 1, 2, 4, 8, 16, 32, // 6 ways to arrange 1 3, 5, 9, 17, 33, 6, 10, 18, 34, 12, 20, 36, 24, 40, 48, // 15 ways for 2 // 16 ways to arrange 3, *but* six of them are inverses, so 10 - 7, 11, 19, 35, 13, 21, 37, 25, 41, 14 // 10 + 15 + 6 + 1 == 32 + 7, 11, 19, 35, 13, 21, 37, 25, 41, 49 // 10 + 15 + 6 + 1 == 32 }; return hires_blit(nc, linesize, data, leny, lenx, bargs, 3, sextrans, sex, sextitions, sizeof(sextitions) / sizeof(*sextitions)); @@ -1081,10 +1081,9 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, octtrans[T(E(0) + E(4) + E(5) + E(6))], octtrans[T(E(0) + E(4) + E(5) + E(7))], octtrans[T(E(0) + E(4) + E(6) + E(7))], octtrans[T(E(0) + E(5) + E(6) + E(7))], // 0 + 5 + 6 + 7 -#undef E #undef T }; - static const unsigned octitions[] = { + static const unsigned octitions[128] = { 0, // 1 way to arrange 0 1, 2, 4, 8, 16, 32, 64, 128, // 8 ways to arrange 1 3, 5, 9, 17, 33, 65, 129, @@ -1094,10 +1093,19 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, 48, 80, 144, 96, 160, 192, // 28 ways for 2 + 3, 5, 9, 17, 33, 65, 129, + 6, 10, 18, 34, 66, 130, + 12, 20, 36, 68, 132, + 24, 40, 72, 136, + 48, 80, 144, + 96, 160, + 192, // 56 ways for 3 // FIXME 112, 208, 224 // 56 ways for 3 - // 70 ways for 4, but there are inverses among them FIXME + // 70 ways for 4, but there are 35 inverses among them + // FIXME +#undef E }; return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans, oct, octitions, sizeof(octitions) / sizeof(*octitions)); From 7977e6c3fc9b1311534172a7c363b9e3f9ebec17 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 11:28:15 -0500 Subject: [PATCH 18/23] complete octblitter --- src/lib/blit.c | 147 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 98 insertions(+), 49 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index c808273fa..29a4678fc 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -1045,66 +1045,115 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, octtrans[T(E(0) + E(5) + E(6))], octtrans[T(E(0) + E(5) + E(7))], // 0 + 5 + 6... octtrans[T(E(0) + E(6) + E(7))], // 0 + 6 + 7 octtrans[T(E(1) + E(2) + E(3))], octtrans[T(E(1) + E(2) + E(4))], octtrans[T(E(1) + E(2) + E(5))], - octtrans[T(E(1) + E(2) + E(6))], octtrans[T(E(1) + E(2) + E(7))], + octtrans[T(E(1) + E(2) + E(6))], octtrans[T(E(1) + E(2) + E(7))], octtrans[T(E(1) + E(3) + E(4))], octtrans[T(E(1) + E(3) + E(5))], octtrans[T(E(1) + E(3) + E(6))], - octtrans[T(E(1) + E(3) + E(7))], - octtrans[T(E(1) + E(4) + E(5))], octtrans[T(E(1) + E(4) + E(6))], octtrans[T(E(1) + E(4) + E(7))], - octtrans[T(E(1) + E(5) + E(6))], octtrans[T(E(1) + E(5) + E(7))], - octtrans[T(E(1) + E(6) + E(7))], + octtrans[T(E(1) + E(3) + E(7))], + octtrans[T(E(1) + E(4) + E(5))], octtrans[T(E(1) + E(4) + E(6))], octtrans[T(E(1) + E(4) + E(7))], + octtrans[T(E(1) + E(5) + E(6))], octtrans[T(E(1) + E(5) + E(7))], + octtrans[T(E(1) + E(6) + E(7))], octtrans[T(E(2) + E(3) + E(4))], octtrans[T(E(2) + E(3) + E(5))], octtrans[T(E(2) + E(3) + E(6))], - octtrans[T(E(2) + E(3) + E(7))], - octtrans[T(E(2) + E(4) + E(5))], octtrans[T(E(2) + E(4) + E(6))], octtrans[T(E(2) + E(4) + E(7))], - octtrans[T(E(2) + E(5) + E(6))], octtrans[T(E(2) + E(5) + E(7))], - octtrans[T(E(2) + E(6) + E(7))], - octtrans[T(E(3) + E(4) + E(5))], octtrans[T(E(3) + E(4) + E(6))], octtrans[T(E(3) + E(4) + E(7))], - octtrans[T(E(3) + E(5) + E(6))], octtrans[T(E(3) + E(5) + E(7))], - octtrans[T(E(3) + E(6) + E(7))], - octtrans[T(E(4) + E(5) + E(6))], octtrans[T(E(4) + E(5) + E(7))], - octtrans[T(E(4) + E(6) + E(7))], + octtrans[T(E(2) + E(3) + E(7))], + octtrans[T(E(2) + E(4) + E(5))], octtrans[T(E(2) + E(4) + E(6))], octtrans[T(E(2) + E(4) + E(7))], + octtrans[T(E(2) + E(5) + E(6))], octtrans[T(E(2) + E(5) + E(7))], + octtrans[T(E(2) + E(6) + E(7))], + octtrans[T(E(3) + E(4) + E(5))], octtrans[T(E(3) + E(4) + E(6))], octtrans[T(E(3) + E(4) + E(7))], + octtrans[T(E(3) + E(5) + E(6))], octtrans[T(E(3) + E(5) + E(7))], + octtrans[T(E(3) + E(6) + E(7))], + octtrans[T(E(4) + E(5) + E(6))], octtrans[T(E(4) + E(5) + E(7))], + octtrans[T(E(4) + E(6) + E(7))], octtrans[T(E(5) + E(6) + E(7))], // 5 + 6 + 7 // four set (15 + 10 + 6 + 3 + 1 = 35) octtrans[T(E(0) + E(1) + E(2) + E(3))], octtrans[T(E(0) + E(1) + E(2) + E(4))], octtrans[T(E(0) + E(1) + E(2) + E(5))], - octtrans[T(E(0) + E(1) + E(2) + E(6))], octtrans[T(E(0) + E(1) + E(2) + E(7))], + octtrans[T(E(0) + E(1) + E(2) + E(6))], octtrans[T(E(0) + E(1) + E(2) + E(7))], octtrans[T(E(0) + E(1) + E(3) + E(4))], octtrans[T(E(0) + E(1) + E(3) + E(5))], octtrans[T(E(0) + E(1) + E(3) + E(6))], - octtrans[T(E(0) + E(1) + E(3) + E(7))], - octtrans[T(E(0) + E(1) + E(4) + E(5))], octtrans[T(E(0) + E(1) + E(4) + E(6))], octtrans[T(E(0) + E(1) + E(4) + E(7))], - octtrans[T(E(0) + E(1) + E(5) + E(6))], octtrans[T(E(0) + E(1) + E(5) + E(7))], - octtrans[T(E(0) + E(1) + E(6) + E(7))], + octtrans[T(E(0) + E(1) + E(3) + E(7))], + octtrans[T(E(0) + E(1) + E(4) + E(5))], octtrans[T(E(0) + E(1) + E(4) + E(6))], octtrans[T(E(0) + E(1) + E(4) + E(7))], + octtrans[T(E(0) + E(1) + E(5) + E(6))], octtrans[T(E(0) + E(1) + E(5) + E(7))], + octtrans[T(E(0) + E(1) + E(6) + E(7))], octtrans[T(E(0) + E(2) + E(3) + E(4))], octtrans[T(E(0) + E(2) + E(3) + E(5))], octtrans[T(E(0) + E(2) + E(3) + E(6))], - octtrans[T(E(0) + E(2) + E(3) + E(7))], - octtrans[T(E(0) + E(2) + E(4) + E(5))], octtrans[T(E(0) + E(2) + E(4) + E(6))], octtrans[T(E(0) + E(2) + E(4) + E(7))], - octtrans[T(E(0) + E(2) + E(5) + E(6))], octtrans[T(E(0) + E(2) + E(5) + E(7))], - octtrans[T(E(0) + E(2) + E(6) + E(7))], - octtrans[T(E(0) + E(3) + E(4) + E(5))], octtrans[T(E(0) + E(3) + E(4) + E(6))], octtrans[T(E(0) + E(3) + E(4) + E(7))], - octtrans[T(E(0) + E(3) + E(5) + E(6))], octtrans[T(E(0) + E(3) + E(5) + E(7))], - octtrans[T(E(0) + E(3) + E(6) + E(7))], - octtrans[T(E(0) + E(4) + E(5) + E(6))], octtrans[T(E(0) + E(4) + E(5) + E(7))], - octtrans[T(E(0) + E(4) + E(6) + E(7))], + octtrans[T(E(0) + E(2) + E(3) + E(7))], + octtrans[T(E(0) + E(2) + E(4) + E(5))], octtrans[T(E(0) + E(2) + E(4) + E(6))], octtrans[T(E(0) + E(2) + E(4) + E(7))], + octtrans[T(E(0) + E(2) + E(5) + E(6))], octtrans[T(E(0) + E(2) + E(5) + E(7))], + octtrans[T(E(0) + E(2) + E(6) + E(7))], + octtrans[T(E(0) + E(3) + E(4) + E(5))], octtrans[T(E(0) + E(3) + E(4) + E(6))], octtrans[T(E(0) + E(3) + E(4) + E(7))], + octtrans[T(E(0) + E(3) + E(5) + E(6))], octtrans[T(E(0) + E(3) + E(5) + E(7))], + octtrans[T(E(0) + E(3) + E(6) + E(7))], + octtrans[T(E(0) + E(4) + E(5) + E(6))], octtrans[T(E(0) + E(4) + E(5) + E(7))], + octtrans[T(E(0) + E(4) + E(6) + E(7))], octtrans[T(E(0) + E(5) + E(6) + E(7))], // 0 + 5 + 6 + 7 #undef T }; static const unsigned octitions[128] = { - 0, // 1 way to arrange 0 - 1, 2, 4, 8, 16, 32, 64, 128, // 8 ways to arrange 1 - 3, 5, 9, 17, 33, 65, 129, - 6, 10, 18, 34, 66, 130, - 12, 20, 36, 68, 132, - 24, 40, 72, 136, - 48, 80, 144, - 96, 160, - 192, // 28 ways for 2 - 3, 5, 9, 17, 33, 65, 129, - 6, 10, 18, 34, 66, 130, - 12, 20, 36, 68, 132, - 24, 40, 72, 136, - 48, 80, 144, - 96, 160, - 192, // 56 ways for 3 - // FIXME - 112, 208, - 224 // 56 ways for 3 - // 70 ways for 4, but there are 35 inverses among them - // FIXME + 0, + // one set + E(0), + E(1), + E(2), + E(3), + E(4), + E(5), + E(6), + E(7), + // two set (7 + 6 + 5 + 4 + 3 + 2 + 1 = 28) + E(0) + E(1), E(0) + E(2), E(0) + E(3), + E(0) + E(4), E(0) + E(5), E(0) + E(6), + E(0) + E(7), // 0 + 1... + E(1) + E(2), E(1) + E(3), E(1) + E(4), + E(1) + E(5), E(1) + E(6), E(1) + E(7), // 1 + 2... + E(2) + E(3), E(2) + E(4), E(2) + E(5), + E(2) + E(6), E(2) + E(7), // 2 + 3... + E(3) + E(4), E(3) + E(5), E(3) + E(6), + E(3) + E(7), // 3 + 4... + E(4) + E(5), E(4) + E(6), E(4) + E(7), // 4 + 5... + E(5) + E(6), E(5) + E(7), // 5 + 6... + E(6) + E(7), // 6 + 7 + // three set (21 + 15 + 10 + 6 + 3 + 1 = 56) + E(0) + E(1) + E(2), E(0) + E(1) + E(3), E(0) + E(1) + E(4), + E(0) + E(1) + E(5), E(0) + E(1) + E(6), E(0) + E(1) + E(7), // 0 + 1 + 2... + E(0) + E(2) + E(3), E(0) + E(2) + E(4), E(0) + E(2) + E(5), + E(0) + E(2) + E(6), E(0) + E(2) + E(7), // 0 + 2 + 3... + E(0) + E(3) + E(4), E(0) + E(3) + E(5), E(0) + E(3) + E(6), + E(0) + E(3) + E(7), // 3 + 4... + E(0) + E(4) + E(5), E(0) + E(4) + E(6), E(0) + E(4) + E(7), // 0 + 4 + 5... + E(0) + E(5) + E(6), E(0) + E(5) + E(7), // 0 + 5 + 6... + E(0) + E(6) + E(7), // 0 + 6 + 7 + E(1) + E(2) + E(3), E(1) + E(2) + E(4), E(1) + E(2) + E(5), + E(1) + E(2) + E(6), E(1) + E(2) + E(7), + E(1) + E(3) + E(4), E(1) + E(3) + E(5), E(1) + E(3) + E(6), + E(1) + E(3) + E(7), + E(1) + E(4) + E(5), E(1) + E(4) + E(6), E(1) + E(4) + E(7), + E(1) + E(5) + E(6), E(1) + E(5) + E(7), + E(1) + E(6) + E(7), + E(2) + E(3) + E(4), E(2) + E(3) + E(5), E(2) + E(3) + E(6), + E(2) + E(3) + E(7), + E(2) + E(4) + E(5), E(2) + E(4) + E(6), E(2) + E(4) + E(7), + E(2) + E(5) + E(6), E(2) + E(5) + E(7), + E(2) + E(6) + E(7), + E(3) + E(4) + E(5), E(3) + E(4) + E(6), E(3) + E(4) + E(7), + E(3) + E(5) + E(6), E(3) + E(5) + E(7), + E(3) + E(6) + E(7), + E(4) + E(5) + E(6), E(4) + E(5) + E(7), + E(4) + E(6) + E(7), + E(5) + E(6) + E(7), // 5 + 6 + 7 + // four set (15 + 10 + 6 + 3 + 1 = 35) + E(0) + E(1) + E(2) + E(3), E(0) + E(1) + E(2) + E(4), E(0) + E(1) + E(2) + E(5), + E(0) + E(1) + E(2) + E(6), E(0) + E(1) + E(2) + E(7), + E(0) + E(1) + E(3) + E(4), E(0) + E(1) + E(3) + E(5), E(0) + E(1) + E(3) + E(6), + E(0) + E(1) + E(3) + E(7), + E(0) + E(1) + E(4) + E(5), E(0) + E(1) + E(4) + E(6), E(0) + E(1) + E(4) + E(7), + E(0) + E(1) + E(5) + E(6), E(0) + E(1) + E(5) + E(7), + E(0) + E(1) + E(6) + E(7), + E(0) + E(2) + E(3) + E(4), E(0) + E(2) + E(3) + E(5), E(0) + E(2) + E(3) + E(6), + E(0) + E(2) + E(3) + E(7), + E(0) + E(2) + E(4) + E(5), E(0) + E(2) + E(4) + E(6), E(0) + E(2) + E(4) + E(7), + E(0) + E(2) + E(5) + E(6), E(0) + E(2) + E(5) + E(7), + E(0) + E(2) + E(6) + E(7), + E(0) + E(3) + E(4) + E(5), E(0) + E(3) + E(4) + E(6), E(0) + E(3) + E(4) + E(7), + E(0) + E(3) + E(5) + E(6), E(0) + E(3) + E(5) + E(7), + E(0) + E(3) + E(6) + E(7), + E(0) + E(4) + E(5) + E(6), E(0) + E(4) + E(5) + E(7), + E(0) + E(4) + E(6) + E(7), + E(0) + E(5) + E(6) + E(7), // 0 + 5 + 6 + 7 #undef E }; return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans, From 765526c319f4a1f973149813ed5bb1c80cbcb807 Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 11:29:35 -0500 Subject: [PATCH 19/23] kill obsolete FIXME --- src/lib/blit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 29a4678fc..9114c8200 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -1003,7 +1003,6 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, static inline int octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs){ - // FIXME define octant sets // each element within the set of 256 has an inverse element within the set, // for which we would calculate the same total differences, so just handle // the first 128. the octition[] bit masks represent combinations of From cddd07a1c50f7e86b1f47671b6a5a27762d685fc Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 12:08:13 -0500 Subject: [PATCH 20/23] hires: drop duplicate egc sets from sex/oct. compute partition counts --- src/lib/blit.c | 617 +++++++++++++++++++++---------------------------- 1 file changed, 268 insertions(+), 349 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 9114c8200..fe042869d 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -516,8 +516,9 @@ quadrant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, // resulting lerps. static const char* hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, - unsigned nointerpolate, unsigned cellheight, const char** egcs, - const unsigned* partitions, unsigned parcount){ + unsigned nointerpolate, unsigned cellheight, + const char* const* transegcs, const unsigned* partitions){ + const unsigned parcount = 1u << (cellheight * 2 - 1); // we loop over the bitstrings, dividing the pixels into two sets, and then // taking a general lerp over each set. we then compute the sum of absolute // differences, and see if it's the new minimum. @@ -575,12 +576,13 @@ hires_solver(const uint32_t rgbas[6], uint64_t* channels, unsigned blendcolors, } } //fprintf(stderr, "solved for best: %d (%u)\n", best, mindiff); - assert(best >= 0 && best < (1u << (cellheight * 2) - 1)); if(blendcolors){ ncchannels_set_fg_alpha(channels, NCALPHA_BLEND); ncchannels_set_bg_alpha(channels, NCALPHA_BLEND); } - return egcs[best]; + best = parcount * 2 - 1 - partitions[best]; + assert(best >= 0 && best >= (1u << (cellheight * 2 - 1)) && best < (1u << (cellheight * 2))); + return transegcs[best]; } // FIXME replace both of these arrays of pointers with fixed-width matrices @@ -605,262 +607,262 @@ static const char* const sextrans[64] = { // 16: row 2 left 32: row 2 right // 64: row 3 left 128: row 3 right static const char* const octtrans[256] = { - "\U00002588", // โ–ˆ 255 all eight set (full) - "\U0001cde5", // ๐œทฅ 254 missing upper left (o2345678) - "\U0001cde4", // ๐œทค 253 missing upper right (o1345678) - "\U00002586", // โ–† 252 missing row 0 (lower three quarters) - "\U0001cde3", // ๐œทฃ 251 missing row 1 left (o1245678) - "\U0000259f", // โ–Ÿ 250 (q upper right and lower left and lower right) - "\U0001cde2", // ๐œทข 249 (o1245678) - "\U0001cde1", // ๐œทก 248 (o45678) - "\U0001cde0", // ๐œท  247 missing row 1 right (o1235678) - "\U0001cddf", // ๐œทŸ 246 missing 0 left 1 right (o235678) - "\U00002599", // โ–™ 245 missing 0/1 right (q upper left and lower left and lower right) - "\U0001cdde", // ๐œทž 244 - "\U0001cddd", // ๐œท 243 - "\U0001cddc", // ๐œทœ 242 - "\U0001cddb", // ๐œท› 241 (o15678) - "\U00002584", // โ–„ 240 2/3 full (lower half) - "\U0001cdda", // ๐œทš 239 (o1234678) - "\U0001cdd9", // ๐œท™ 238 (o234678) - "\U0001cdd8", // ๐œท˜ 237 (o134678) - "\U0001cdd7", // ๐œท— 236 (o34678) - "\U0001cdd6", // ๐œท– 235 (o124678) - "\U0001cdd5", // ๐œท• 234 (o24678) - "\U0001cdd4", // ๐œท” 233 (o14678) - "\U0001cdd3", // ๐œท“ 232 (o4678) - "\U0001cdd2", // ๐œท’ 231 - "\U0001cdd1", // ๐œท‘ 230 - "\U0001cdd0", // ๐œท 229 - "\U0001cdcf", // ๐œท 228 (o145678) - "\U0001cdce", // ๐œทŽ 227 - "\U0001cdcd", // ๐œท 226 - "\U0001cdcc", // ๐œทŒ 225 - "\U0001cdcb", // ๐œท‹ 224 (o678) - "\U0001cdca", - "\U0001cdc9", - "\U0001cdc8", - "\U0001cdc7", // ๐œท‡ 220 (o34578) - "\U0001cdc6", - "\U0001cdc5", - "\U0001cdc4", - "\U0001cdc3", // ๐œทƒ 216 (o4578) - "\U0001cdc2", - "\U0001cdc1", - "\U0001cdc0", - "\U0001cdbf", // ๐œถฟ 212 (o3578) - "\U0001cdbe", - "\U0001cdbd", - "\U0001cdbc", - "\U0001cdbb", // ๐œถป 208 (o578) - "\U0001cdba", - "\U0001cdb9", - "\U0001cdb8", - "\U0001cdb7", // ๐œถท 204 (o4578) - "\U0001cdb6", - "\U0001cdb5", - "\U0001cdb4", - "\U0001cdb3", // ๐œถณ 200 (o478) - "\U0001cdb2", - "\U0001cdb1", - "\U0001cdb0", - "\U0001cdaf", // ๐œถฏ 196 (o378) - "\U0001cdae", - "\U0001cdad", - "\U0001cdac", - "\U00002582", // โ–‚ 192 (lower one quarter) - "\U0001cdab", - "\U0001cdaa", - "\U0001cda9", - "\U0001cda8", // ๐œถจ 188 (o34568) - "\U0001cda7", - "\U0001cda6", - "\U0001cda5", - "\U0001cda4", - "\U0001cda3", - "\U0001cda2", - "\U0001cda1", - "\U0001cda0", - "\U0001cd9f", - "\U0001cd9e", - "\U0001cd9d", - "\U0001cd9c", - "\U0000259c", // โ–œ 175 (q upper left and upper right and lower right) - "\U0001cd9b", - "\U0001cd9a", - "\U0001cd99", - "\U0001cd98", - "\U00002590", // โ– 170 (right half) - "\U0001cd97", - "\U0001cd96", - "\U0001cd95", - "\U0001cd94", - "\U0000259a", // โ–š 165 (q upper left and lower right) - "\U0001cd93", - "\U0001cd92", - "\U0001cd91", - "\U0001cd90", - "\U00002597", // โ–— 160 (q lower right) - "\U0001cd8f", - "\U0001cd8e", - "\U0001cd8d", - "\U0001cd8c", // ๐œถŒ 156 (u3458) - "\U0001cd8b", - "\U0001cd8a", - "\U0001cd89", - "\U0001cd88", // ๐œถˆ 152 (u458) - "\U0001cd87", - "\U0001cd86", - "\U0001cd85", - "\U0001cd84", // ๐œถ„ 148 (u358) - "\U0001cd83", - "\U0001cd82", - "\U0001cd81", - "\U0001cd80", // ๐œถ€ 144 (u58) - "\U0001cd7f", - "\U0001cd7e", - "\U0001cd7d", - "\U0001cd7c", // ๐œตผ 140 (u348) - "\U0001cd7b", - "\U0001cd7a", - "\U0001cd79", - "\U0001cd78", // ๐œตธ 136 (u48) - "\U0001cd77", - "\U0001cd76", - "\U0001cd75", - "\U0001cd74", // ๐œตด 132 (u38) - "\U0001cd73", - "\U0001cd72", - "\U0001cd71", - "\U0001cea0", // ๐œบ  128 lower right only (right half lower one quarter) - "\U0001cd70", // ๐œตฐ 127 missing lower right (u1234567) - "\U0001cd6f", - "\U0001cd6e", - "\U0001cd6d", - "\U0001cd6c", - "\U0001cd6b", - "\U0001cd6a", - "\U0001cd69", - "\U0001cd68", - "\U0001cd67", - "\U0001cd66", - "\U0001cd65", - "\U0001cd64", - "\U0001cd63", - "\U0001cd62", - "\U0001cd61", - "\U0001cd60", - "\U0001cd5f", - "\U0001cd5e", - "\U0001cd5d", - "\U0001cd5c", - "\U0001cd5b", - "\U0001cd5a", - "\U0001cd59", - "\U0001cd58", - "\U0001cd57", - "\U0001cd56", - "\U0001cd55", - "\U0001cd54", - "\U0001cd53", - "\U0001cd52", - "\U0001cd51", - "\U0000259b", // โ–› 95 0/1 full 2/3 left (q upper left and upper right and lower left) - "\U0001cd50", - "\U0001cd4f", - "\U0001cd4e", - "\U0001cd4d", - "\U0000259e", // โ–ž 92 0/1 right 2/3 left (q upper right and lower left) - "\U0001cd4c", - "\U0001cd4b", - "\U0001cd4a", - "\U0001cd49", - "\U0000258c", // โ–Œ 85 0/1/2/3 left (left block) - "\U0001cd48", - "\U0001cd47", - "\U0001cd46", - "\U0001cd45", - "\U00002596", // โ–– 80 2/3 left (q lower left) - "\U0001cd44", - "\U0001cd43", - "\U0001cd42", - "\U0001cd41", - "\U0001cd40", - "\U0001cd3f", - "\U0001cd3e", - "\U0001cd3d", - "\U0001cd3c", - "\U0001cd3b", - "\U0001cd3a", - "\U0001cd39", - "\U0001cd38", - "\U0001cd37", // ๐œดท 66 0 right 3 left (o27) - "\U0001cd36", // ๐œดถ 65 0 left 3 left (o17) - "\U0001cea3", // ๐œบฃ 64 lower left only (left half lower one quarter) - "\U0001fb85", // ๐Ÿฎ… 63 row 0/1/2 full (upper three quarters) - "\U0001cd35", // ๐œดต 62 (o23456) - "\U0001cd34", // ๐œดด 61 (o13456) - "\U0001cd33", // ๐œดณ 60 (o3456) - "\U0001cd32", // ๐œดฒ 59 (o12456) - "\U0001cd31", // ๐œดฑ 58 (o2456) - "\U0001cd30", // ๐œดฐ 57 0 left 1 right 2 full (o1456) - "\U0001cd2f", // ๐œดฏ 56 (o456) - "\U0001cd2e", // ๐œดฎ 55 - "\U0001cd2d", // ๐œดญ 54 - "\U0001cd2c", // ๐œดฌ 53 - "\U0001cd2b", // ๐œดซ 52 - "\U0001cd2a", // ๐œดช 51 - "\U0001cd29", // ๐œดฉ 50 - "\U0001cd28", // ๐œดจ 49 - "\U0001cd27", // ๐œดง 48 - "\U0001cd26", // ๐œดฆ 47 (o12346) - "\U0001cd25", // ๐œดฅ 46 (o2346) - "\U0001cd24", // ๐œดค 45 (o1346) - "\U0001cd23", // ๐œดฃ 44 (o346) - "\U0001cd22", // ๐œดข 43 (o1246) - "\U0001cd21", // ๐œดก 42 (o246) - "\U0001cd20", // ๐œด  41 (o146) - "\U0001fbe7", // ๐Ÿฏง 40 (middle right one quarter) - "\U0001cd1f", // ๐œดŸ 39 (o1236) - "\U0001cd1e", // ๐œดž 38 (o236) - "\U0001cd1d", // ๐œด 37 (o136) - "\U0001cd1c", // ๐œดœ 36 (o36) - "\U0001cd1b", // ๐œด› 35 (o126) - "\U0001cd1a", // ๐œดš 34 (o26) - "\U0001cd19", // ๐œด™ 33 (o16) - "\U0001cd18", // ๐œด˜ 32 row 2 right only (o6) - "\U0001cd17", // ๐œด— 31 (o12345) - "\U0001cd16", // ๐œด– 30 (o2345) - "\U0001cd15", // ๐œด• 29 (o1345) - "\U0001cd14", // ๐œด” 28 (o345) - "\U0001cd13", // ๐œด“ 27 (o1245) - "\U0001cd12", // ๐œด’ 26 row 0/1 right row 2 l (o245) - "\U0001cd11", // ๐œด‘ 25 row 1/2 left row 1 r (o145) - "\U0001cd10", // ๐œด 24 row 1 right row 2 left (o45) - "\U0001cd0f", // ๐œด 23 row 0 full row 1/2 l (o1235) - "\U0001cd0e", // ๐œดŽ 22 row 1 right row 2/3 l (o235) - "\U0001cd0d", // ๐œด 21 row 0/1/2 left (o135) - "\U0001fbe6", // ๐Ÿฏฆ 20 row 1/2 left (middle left one quarter) - "\U0001cd0c", // ๐œดŒ 19 row 0 full row 2 left (o125) - "\U0001cd0b", // ๐œด‹ 18 row 0 right row 2 left (o25) - "\U0001cd0a", // ๐œดŠ 17 row 0 left row 2 left (o15) - "\U0001cd09", // ๐œด‰ 16 row 2 left only (o5) - "\U00002580", // โ–€ 15 row 0/1 full (upper half) - "\U0001cd08", // ๐œดˆ 14 row 0 right row 1 full (o234) - "\U0001cd07", // ๐œด‡ 13 row 0 left row 1 full (o134) - "\U0001cd06", // ๐œด† 12 row 1 full (o34) - "\U0001cd05", // ๐œด… 11 row 0 full row 1 right (o124) - "\U0000259d", // โ– 10 row 0/1 right only (upper right quadrant) - "\U0001cd04", // ๐œด„ 9 row 0 left row 1 right (o14) - "\U0001cd03", // ๐œดƒ 8 row 1 right only (o4) - "\U0001cd02", // ๐œด‚ 7 row 0 full row 1 left (o123) - "\U0001cd01", // ๐œด 6 row 0 right row 1 left (o23) - "\U00002598", // โ–˜ 5 row 0/1 left only (upper left quadrant) - "\U0001cd00", // ๐œด€ 4 row 1 left only (o3) - "\U0001fb82", // ๐Ÿฎ‚ 3 row 0 (upper one quarter) - "\U0001ceab", // ๐œบซ 2 upper right only (right half upper one quarter) - "\U0001cea8", // ๐œบจ 1 upper left only (left half upper one quarter) - " " // 0 none set (space) + u8"\U00002588", // โ–ˆ 255 all eight set (full) + u8"\U0001cde5", // ๐œทฅ 254 missing upper left (o2345678) + u8"\U0001cde4", // ๐œทค 253 missing upper right (o1345678) + u8"\U00002586", // โ–† 252 missing row 0 (lower three quarters) + u8"\U0001cde3", // ๐œทฃ 251 missing row 1 left (o1245678) + u8"\U0000259f", // โ–Ÿ 250 (q upper right and lower left and lower right) + u8"\U0001cde2", // ๐œทข 249 (o1245678) + u8"\U0001cde1", // ๐œทก 248 (o45678) + u8"\U0001cde0", // ๐œท  247 missing row 1 right (o1235678) + u8"\U0001cddf", // ๐œทŸ 246 missing 0 left 1 right (o235678) + u8"\U00002599", // โ–™ 245 missing 0/1 right (q upper left and lower left and lower right) + u8"\U0001cdde", // ๐œทž 244 + u8"\U0001cddd", // ๐œท 243 + u8"\U0001cddc", // ๐œทœ 242 + u8"\U0001cddb", // ๐œท› 241 (o15678) + u8"\U00002584", // โ–„ 240 2/3 full (lower half) + u8"\U0001cdda", // ๐œทš 239 (o1234678) + u8"\U0001cdd9", // ๐œท™ 238 (o234678) + u8"\U0001cdd8", // ๐œท˜ 237 (o134678) + u8"\U0001cdd7", // ๐œท— 236 (o34678) + u8"\U0001cdd6", // ๐œท– 235 (o124678) + u8"\U0001cdd5", // ๐œท• 234 (o24678) + u8"\U0001cdd4", // ๐œท” 233 (o14678) + u8"\U0001cdd3", // ๐œท“ 232 (o4678) + u8"\U0001cdd2", // ๐œท’ 231 + u8"\U0001cdd1", // ๐œท‘ 230 + u8"\U0001cdd0", // ๐œท 229 + u8"\U0001cdcf", // ๐œท 228 (o145678) + u8"\U0001cdce", // ๐œทŽ 227 + u8"\U0001cdcd", // ๐œท 226 + u8"\U0001cdcc", // ๐œทŒ 225 + u8"\U0001cdcb", // ๐œท‹ 224 (o678) + u8"\U0001cdca", + u8"\U0001cdc9", + u8"\U0001cdc8", + u8"\U0001cdc7", // ๐œท‡ 220 (o34578) + u8"\U0001cdc6", + u8"\U0001cdc5", + u8"\U0001cdc4", + u8"\U0001cdc3", // ๐œทƒ 216 (o4578) + u8"\U0001cdc2", + u8"\U0001cdc1", + u8"\U0001cdc0", + u8"\U0001cdbf", // ๐œถฟ 212 (o3578) + u8"\U0001cdbe", + u8"\U0001cdbd", + u8"\U0001cdbc", + u8"\U0001cdbb", // ๐œถป 208 (o578) + u8"\U0001cdba", + u8"\U0001cdb9", + u8"\U0001cdb8", + u8"\U0001cdb7", // ๐œถท 204 (o4578) + u8"\U0001cdb6", + u8"\U0001cdb5", + u8"\U0001cdb4", + u8"\U0001cdb3", // ๐œถณ 200 (o478) + u8"\U0001cdb2", + u8"\U0001cdb1", + u8"\U0001cdb0", + u8"\U0001cdaf", // ๐œถฏ 196 (o378) + u8"\U0001cdae", + u8"\U0001cdad", + u8"\U0001cdac", + u8"\U00002582", // โ–‚ 192 (lower one quarter) + u8"\U0001cdab", + u8"\U0001cdaa", + u8"\U0001cda9", + u8"\U0001cda8", // ๐œถจ 188 (o34568) + u8"\U0001cda7", + u8"\U0001cda6", + u8"\U0001cda5", + u8"\U0001cda4", + u8"\U0001cda3", + u8"\U0001cda2", + u8"\U0001cda1", + u8"\U0001cda0", + u8"\U0001cd9f", + u8"\U0001cd9e", + u8"\U0001cd9d", + u8"\U0001cd9c", + u8"\U0000259c", // โ–œ 175 (q upper left and upper right and lower right) + u8"\U0001cd9b", + u8"\U0001cd9a", + u8"\U0001cd99", + u8"\U0001cd98", + u8"\U00002590", // โ– 170 (right half) + u8"\U0001cd97", + u8"\U0001cd96", + u8"\U0001cd95", + u8"\U0001cd94", + u8"\U0000259a", // โ–š 165 (q upper left and lower right) + u8"\U0001cd93", + u8"\U0001cd92", + u8"\U0001cd91", + u8"\U0001cd90", + u8"\U00002597", // โ–— 160 (q lower right) + u8"\U0001cd8f", + u8"\U0001cd8e", + u8"\U0001cd8d", + u8"\U0001cd8c", // ๐œถŒ 156 (u3458) + u8"\U0001cd8b", + u8"\U0001cd8a", + u8"\U0001cd89", + u8"\U0001cd88", // ๐œถˆ 152 (u458) + u8"\U0001cd87", + u8"\U0001cd86", + u8"\U0001cd85", + u8"\U0001cd84", // ๐œถ„ 148 (u358) + u8"\U0001cd83", + u8"\U0001cd82", + u8"\U0001cd81", + u8"\U0001cd80", // ๐œถ€ 144 (u58) + u8"\U0001cd7f", + u8"\U0001cd7e", + u8"\U0001cd7d", + u8"\U0001cd7c", // ๐œตผ 140 (u348) + u8"\U0001cd7b", + u8"\U0001cd7a", + u8"\U0001cd79", + u8"\U0001cd78", // ๐œตธ 136 (u48) + u8"\U0001cd77", + u8"\U0001cd76", + u8"\U0001cd75", + u8"\U0001cd74", // ๐œตด 132 (u38) + u8"\U0001cd73", + u8"\U0001cd72", + u8"\U0001cd71", + u8"\U0001cea0", // ๐œบ  128 lower right only (right half lower one quarter) + u8"\U0001cd70", // ๐œตฐ 127 missing lower right (u1234567) + u8"\U0001cd6f", + u8"\U0001cd6e", + u8"\U0001cd6d", + u8"\U0001cd6c", + u8"\U0001cd6b", + u8"\U0001cd6a", + u8"\U0001cd69", + u8"\U0001cd68", + u8"\U0001cd67", + u8"\U0001cd66", + u8"\U0001cd65", + u8"\U0001cd64", + u8"\U0001cd63", + u8"\U0001cd62", + u8"\U0001cd61", + u8"\U0001cd60", + u8"\U0001cd5f", + u8"\U0001cd5e", + u8"\U0001cd5d", + u8"\U0001cd5c", + u8"\U0001cd5b", + u8"\U0001cd5a", + u8"\U0001cd59", + u8"\U0001cd58", + u8"\U0001cd57", + u8"\U0001cd56", + u8"\U0001cd55", + u8"\U0001cd54", + u8"\U0001cd53", + u8"\U0001cd52", + u8"\U0001cd51", + u8"\U0000259b", // โ–› 95 0/1 full 2/3 left (q upper left and upper right and lower left) + u8"\U0001cd50", + u8"\U0001cd4f", + u8"\U0001cd4e", + u8"\U0001cd4d", + u8"\U0000259e", // โ–ž 92 0/1 right 2/3 left (q upper right and lower left) + u8"\U0001cd4c", + u8"\U0001cd4b", + u8"\U0001cd4a", + u8"\U0001cd49", + u8"\U0000258c", // โ–Œ 85 0/1/2/3 left (left block) + u8"\U0001cd48", + u8"\U0001cd47", + u8"\U0001cd46", + u8"\U0001cd45", + u8"\U00002596", // โ–– 80 2/3 left (q lower left) + u8"\U0001cd44", + u8"\U0001cd43", + u8"\U0001cd42", + u8"\U0001cd41", + u8"\U0001cd40", + u8"\U0001cd3f", + u8"\U0001cd3e", + u8"\U0001cd3d", + u8"\U0001cd3c", + u8"\U0001cd3b", + u8"\U0001cd3a", + u8"\U0001cd39", + u8"\U0001cd38", + u8"\U0001cd37", // ๐œดท 66 0 right 3 left (o27) + u8"\U0001cd36", // ๐œดถ 65 0 left 3 left (o17) + u8"\U0001cea3", // ๐œบฃ 64 lower left only (left half lower one quarter) + u8"\U0001fb85", // ๐Ÿฎ… 63 row 0/1/2 full (upper three quarters) + u8"\U0001cd35", // ๐œดต 62 (o23456) + u8"\U0001cd34", // ๐œดด 61 (o13456) + u8"\U0001cd33", // ๐œดณ 60 (o3456) + u8"\U0001cd32", // ๐œดฒ 59 (o12456) + u8"\U0001cd31", // ๐œดฑ 58 (o2456) + u8"\U0001cd30", // ๐œดฐ 57 0 left 1 right 2 full (o1456) + u8"\U0001cd2f", // ๐œดฏ 56 (o456) + u8"\U0001cd2e", // ๐œดฎ 55 + u8"\U0001cd2d", // ๐œดญ 54 + u8"\U0001cd2c", // ๐œดฌ 53 + u8"\U0001cd2b", // ๐œดซ 52 + u8"\U0001cd2a", // ๐œดช 51 + u8"\U0001cd29", // ๐œดฉ 50 + u8"\U0001cd28", // ๐œดจ 49 + u8"\U0001cd27", // ๐œดง 48 + u8"\U0001cd26", // ๐œดฆ 47 (o12346) + u8"\U0001cd25", // ๐œดฅ 46 (o2346) + u8"\U0001cd24", // ๐œดค 45 (o1346) + u8"\U0001cd23", // ๐œดฃ 44 (o346) + u8"\U0001cd22", // ๐œดข 43 (o1246) + u8"\U0001cd21", // ๐œดก 42 (o246) + u8"\U0001cd20", // ๐œด  41 (o146) + u8"\U0001fbe7", // ๐Ÿฏง 40 (middle right one quarter) + u8"\U0001cd1f", // ๐œดŸ 39 (o1236) + u8"\U0001cd1e", // ๐œดž 38 (o236) + u8"\U0001cd1d", // ๐œด 37 (o136) + u8"\U0001cd1c", // ๐œดœ 36 (o36) + u8"\U0001cd1b", // ๐œด› 35 (o126) + u8"\U0001cd1a", // ๐œดš 34 (o26) + u8"\U0001cd19", // ๐œด™ 33 (o16) + u8"\U0001cd18", // ๐œด˜ 32 row 2 right only (o6) + u8"\U0001cd17", // ๐œด— 31 (o12345) + u8"\U0001cd16", // ๐œด– 30 (o2345) + u8"\U0001cd15", // ๐œด• 29 (o1345) + u8"\U0001cd14", // ๐œด” 28 (o345) + u8"\U0001cd13", // ๐œด“ 27 (o1245) + u8"\U0001cd12", // ๐œด’ 26 row 0/1 right row 2 l (o245) + u8"\U0001cd11", // ๐œด‘ 25 row 1/2 left row 1 r (o145) + u8"\U0001cd10", // ๐œด 24 row 1 right row 2 left (o45) + u8"\U0001cd0f", // ๐œด 23 row 0 full row 1/2 l (o1235) + u8"\U0001cd0e", // ๐œดŽ 22 row 1 right row 2/3 l (o235) + u8"\U0001cd0d", // ๐œด 21 row 0/1/2 left (o135) + u8"\U0001fbe6", // ๐Ÿฏฆ 20 row 1/2 left (middle left one quarter) + u8"\U0001cd0c", // ๐œดŒ 19 row 0 full row 2 left (o125) + u8"\U0001cd0b", // ๐œด‹ 18 row 0 right row 2 left (o25) + u8"\U0001cd0a", // ๐œดŠ 17 row 0 left row 2 left (o15) + u8"\U0001cd09", // ๐œด‰ 16 row 2 left only (o5) + u8"\U00002580", // โ–€ 15 row 0/1 full (upper half) + u8"\U0001cd08", // ๐œดˆ 14 row 0 right row 1 full (o234) + u8"\U0001cd07", // ๐œด‡ 13 row 0 left row 1 full (o134) + u8"\U0001cd06", // ๐œด† 12 row 1 full (o34) + u8"\U0001cd05", // ๐œด… 11 row 0 full row 1 right (o124) + u8"\U0000259d", // โ– 10 row 0/1 right only (upper right quadrant) + u8"\U0001cd04", // ๐œด„ 9 row 0 left row 1 right (o14) + u8"\U0001cd03", // ๐œดƒ 8 row 1 right only (o4) + u8"\U0001cd02", // ๐œด‚ 7 row 0 full row 1 left (o123) + u8"\U0001cd01", // ๐œด 6 row 0 right row 1 left (o23) + u8"\U00002598", // โ–˜ 5 row 0/1 left only (upper left quadrant) + u8"\U0001cd00", // ๐œด€ 4 row 1 left only (o3) + u8"\U0001fb82", // ๐Ÿฎ‚ 3 row 0 (upper one quarter) + u8"\U0001ceab", // ๐œบซ 2 upper right only (right half upper one quarter) + u8"\U0001cea8", // ๐œบจ 1 upper left only (left half upper one quarter) + u8" " // 0 none set (space) }; static const char* @@ -918,8 +920,7 @@ hires_trans_check(nccell* c, const uint32_t* rgbas, unsigned blendcolors, static inline int hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, const blitterargs* bargs, int cellheight, - const char* const* transegcs, const char **egcs, - const unsigned* partitions, unsigned parcount){ + const char* const* transegcs, const unsigned* partitions){ const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE; const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND; unsigned dimy, dimx, x, y; @@ -959,7 +960,7 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, nointerpolate, cellheight, transegcs); if(egc == NULL){ // no transparency; run a full solver egc = hires_solver(rgbas, &c->channels, blendcolors, nointerpolate, - cellheight, egcs, partitions, parcount); + cellheight, transegcs, partitions); cell_set_blitquadrants(c, 1, 1, 1, 1); } //fprintf(stderr, "hires EGC: %s channels: %016lx\n", egc, c->channels); @@ -982,13 +983,7 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, // each element within the set of 64 has an inverse element within the set, // for which we would calculate the same total differences, so just handle // the first 32. the sextition[] bit masks represent combinations of - // sextants, and their indices correspond to sex[]. - static const char* sex[32] = { - " ", "๐Ÿฌ€", "๐Ÿฌ", "๐Ÿฌƒ", "๐Ÿฌ‡", "๐Ÿฌ", "๐Ÿฌž", "๐Ÿฌ‚", // 0..7 - "๐Ÿฌ„", "๐Ÿฌˆ", "๐Ÿฌ", "๐ŸฌŸ", "๐Ÿฌ…", "๐Ÿฌ‰", "๐Ÿฌ‘", "๐Ÿฌ ", // 8..15 - "๐Ÿฌ‹", "๐Ÿฌ“", "๐Ÿฌข", "๐Ÿฌ–", "๐Ÿฌฆ", "๐Ÿฌญ", "๐Ÿฌ†", "๐ŸฌŠ", // 16..23 - "๐Ÿฌ’", "๐Ÿฌก", "๐ŸฌŒ", "โ–Œ", "๐Ÿฌฃ", "๐Ÿฌ—", "๐Ÿฌง", "๐Ÿฌฎ", // 24..31 - }; + // sextants, and their indices correspond to inverse sextrans[]. static const unsigned sextitions[32] = { 0, // 1 way to arrange 0 1, 2, 4, 8, 16, 32, // 6 ways to arrange 1 @@ -996,8 +991,7 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, // 16 ways to arrange 3, *but* six of them are inverses, so 10 7, 11, 19, 35, 13, 21, 37, 25, 41, 49 // 10 + 15 + 6 + 1 == 32 }; - return hires_blit(nc, linesize, data, leny, lenx, bargs, 3, sextrans, - sex, sextitions, sizeof(sextitions) / sizeof(*sextitions)); + return hires_blit(nc, linesize, data, leny, lenx, bargs, 3, sextrans, sextitions); } static inline int @@ -1006,82 +1000,8 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, // each element within the set of 256 has an inverse element within the set, // for which we would calculate the same total differences, so just handle // the first 128. the octition[] bit masks represent combinations of - // octants, and their indices correspond to sex[]. -#define T(sum) (255 - (sum)) + // octants, and their indices correspond to inverse octtrans[]. #define E(bits) (1u << (bits)) - static const char* oct[128] = { - octtrans[T(0)], - // one set - octtrans[T(E(0))], - octtrans[T(E(1))], - octtrans[T(E(2))], - octtrans[T(E(3))], - octtrans[T(E(4))], - octtrans[T(E(5))], - octtrans[T(E(6))], - octtrans[T(E(7))], - // two set (7 + 6 + 5 + 4 + 3 + 2 + 1 = 28) - octtrans[T(E(0) + E(1))], octtrans[T(E(0) + E(2))], octtrans[T(E(0) + E(3))], - octtrans[T(E(0) + E(4))], octtrans[T(E(0) + E(5))], octtrans[T(E(0) + E(6))], - octtrans[T(E(0) + E(7))], // 0 + 1... - octtrans[T(E(1) + E(2))], octtrans[T(E(1) + E(3))], octtrans[T(E(1) + E(4))], - octtrans[T(E(1) + E(5))], octtrans[T(E(1) + E(6))], octtrans[T(E(1) + E(7))], // 1 + 2... - octtrans[T(E(2) + E(3))], octtrans[T(E(2) + E(4))], octtrans[T(E(2) + E(5))], - octtrans[T(E(2) + E(6))], octtrans[T(E(2) + E(7))], // 2 + 3... - octtrans[T(E(3) + E(4))], octtrans[T(E(3) + E(5))], octtrans[T(E(3) + E(6))], - octtrans[T(E(3) + E(7))], // 3 + 4... - octtrans[T(E(4) + E(5))], octtrans[T(E(4) + E(6))], octtrans[T(E(4) + E(7))], // 4 + 5... - octtrans[T(E(5) + E(6))], octtrans[T(E(5) + E(7))], // 5 + 6... - octtrans[T(E(6) + E(7))], // 6 + 7 - // three set (21 + 15 + 10 + 6 + 3 + 1 = 56) - octtrans[T(E(0) + E(1) + E(2))], octtrans[T(E(0) + E(1) + E(3))], octtrans[T(E(0) + E(1) + E(4))], - octtrans[T(E(0) + E(1) + E(5))], octtrans[T(E(0) + E(1) + E(6))], octtrans[T(E(0) + E(1) + E(7))], // 0 + 1 + 2... - octtrans[T(E(0) + E(2) + E(3))], octtrans[T(E(0) + E(2) + E(4))], octtrans[T(E(0) + E(2) + E(5))], - octtrans[T(E(0) + E(2) + E(6))], octtrans[T(E(0) + E(2) + E(7))], // 0 + 2 + 3... - octtrans[T(E(0) + E(3) + E(4))], octtrans[T(E(0) + E(3) + E(5))], octtrans[T(E(0) + E(3) + E(6))], - octtrans[T(E(0) + E(3) + E(7))], // 3 + 4... - octtrans[T(E(0) + E(4) + E(5))], octtrans[T(E(0) + E(4) + E(6))], octtrans[T(E(0) + E(4) + E(7))], // 0 + 4 + 5... - octtrans[T(E(0) + E(5) + E(6))], octtrans[T(E(0) + E(5) + E(7))], // 0 + 5 + 6... - octtrans[T(E(0) + E(6) + E(7))], // 0 + 6 + 7 - octtrans[T(E(1) + E(2) + E(3))], octtrans[T(E(1) + E(2) + E(4))], octtrans[T(E(1) + E(2) + E(5))], - octtrans[T(E(1) + E(2) + E(6))], octtrans[T(E(1) + E(2) + E(7))], - octtrans[T(E(1) + E(3) + E(4))], octtrans[T(E(1) + E(3) + E(5))], octtrans[T(E(1) + E(3) + E(6))], - octtrans[T(E(1) + E(3) + E(7))], - octtrans[T(E(1) + E(4) + E(5))], octtrans[T(E(1) + E(4) + E(6))], octtrans[T(E(1) + E(4) + E(7))], - octtrans[T(E(1) + E(5) + E(6))], octtrans[T(E(1) + E(5) + E(7))], - octtrans[T(E(1) + E(6) + E(7))], - octtrans[T(E(2) + E(3) + E(4))], octtrans[T(E(2) + E(3) + E(5))], octtrans[T(E(2) + E(3) + E(6))], - octtrans[T(E(2) + E(3) + E(7))], - octtrans[T(E(2) + E(4) + E(5))], octtrans[T(E(2) + E(4) + E(6))], octtrans[T(E(2) + E(4) + E(7))], - octtrans[T(E(2) + E(5) + E(6))], octtrans[T(E(2) + E(5) + E(7))], - octtrans[T(E(2) + E(6) + E(7))], - octtrans[T(E(3) + E(4) + E(5))], octtrans[T(E(3) + E(4) + E(6))], octtrans[T(E(3) + E(4) + E(7))], - octtrans[T(E(3) + E(5) + E(6))], octtrans[T(E(3) + E(5) + E(7))], - octtrans[T(E(3) + E(6) + E(7))], - octtrans[T(E(4) + E(5) + E(6))], octtrans[T(E(4) + E(5) + E(7))], - octtrans[T(E(4) + E(6) + E(7))], - octtrans[T(E(5) + E(6) + E(7))], // 5 + 6 + 7 - // four set (15 + 10 + 6 + 3 + 1 = 35) - octtrans[T(E(0) + E(1) + E(2) + E(3))], octtrans[T(E(0) + E(1) + E(2) + E(4))], octtrans[T(E(0) + E(1) + E(2) + E(5))], - octtrans[T(E(0) + E(1) + E(2) + E(6))], octtrans[T(E(0) + E(1) + E(2) + E(7))], - octtrans[T(E(0) + E(1) + E(3) + E(4))], octtrans[T(E(0) + E(1) + E(3) + E(5))], octtrans[T(E(0) + E(1) + E(3) + E(6))], - octtrans[T(E(0) + E(1) + E(3) + E(7))], - octtrans[T(E(0) + E(1) + E(4) + E(5))], octtrans[T(E(0) + E(1) + E(4) + E(6))], octtrans[T(E(0) + E(1) + E(4) + E(7))], - octtrans[T(E(0) + E(1) + E(5) + E(6))], octtrans[T(E(0) + E(1) + E(5) + E(7))], - octtrans[T(E(0) + E(1) + E(6) + E(7))], - octtrans[T(E(0) + E(2) + E(3) + E(4))], octtrans[T(E(0) + E(2) + E(3) + E(5))], octtrans[T(E(0) + E(2) + E(3) + E(6))], - octtrans[T(E(0) + E(2) + E(3) + E(7))], - octtrans[T(E(0) + E(2) + E(4) + E(5))], octtrans[T(E(0) + E(2) + E(4) + E(6))], octtrans[T(E(0) + E(2) + E(4) + E(7))], - octtrans[T(E(0) + E(2) + E(5) + E(6))], octtrans[T(E(0) + E(2) + E(5) + E(7))], - octtrans[T(E(0) + E(2) + E(6) + E(7))], - octtrans[T(E(0) + E(3) + E(4) + E(5))], octtrans[T(E(0) + E(3) + E(4) + E(6))], octtrans[T(E(0) + E(3) + E(4) + E(7))], - octtrans[T(E(0) + E(3) + E(5) + E(6))], octtrans[T(E(0) + E(3) + E(5) + E(7))], - octtrans[T(E(0) + E(3) + E(6) + E(7))], - octtrans[T(E(0) + E(4) + E(5) + E(6))], octtrans[T(E(0) + E(4) + E(5) + E(7))], - octtrans[T(E(0) + E(4) + E(6) + E(7))], - octtrans[T(E(0) + E(5) + E(6) + E(7))], // 0 + 5 + 6 + 7 -#undef T - }; static const unsigned octitions[128] = { 0, // one set @@ -1155,8 +1075,7 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, E(0) + E(5) + E(6) + E(7), // 0 + 5 + 6 + 7 #undef E }; - return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans, - oct, octitions, sizeof(octitions) / sizeof(*octitions)); + return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans, octitions); } // Bit is set where Braille dot is present: From b1a0986f23974ab43314926f0e7a550244f9721a Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 12:58:34 -0500 Subject: [PATCH 21/23] undo debugging --- src/lib/termdesc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/termdesc.c b/src/lib/termdesc.c index a17bc226f..5a09c9801 100644 --- a/src/lib/termdesc.c +++ b/src/lib/termdesc.c @@ -735,7 +735,6 @@ static const char* apply_kitty_heuristics(tinfo* ti, size_t* tablelen, size_t* tableused){ // see https://sw.kovidgoyal.net/kitty/protocol-extensions.html ti->bg_collides_default |= 0x1000000; - ti->caps.octants = true; ti->caps.sextants = true; // work since bugfix in 0.19.3 ti->caps.quadrants = true; ti->caps.rgb = true; @@ -1049,7 +1048,7 @@ apply_term_heuristics(tinfo* ti, const char* tname, queried_terminals_e qterm, } // run a wcwidth(๐œด€) to guarantee libc Unicode 16 support, independent of term if(wcwidth(L'๐œด€') < 0){ - // ti->caps.octants = false; + ti->caps.octants = false; } ti->termname = tname; return 0; From 41b91f198972645cab80a7a095e9552884832dfd Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 13:01:32 -0500 Subject: [PATCH 22/23] eliminate rgbas[] VLA, restore -Wvla --- CMakeLists.txt | 2 +- src/lib/blit.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1aaba5e9c..2974d8116 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,7 +130,7 @@ endif() if(MSVC) add_compile_options(/W4) else() -add_compile_options(-Wall -Wextra -W -Wshadow -Wstrict-aliasing=2) +add_compile_options(-Wall -Wextra -W -Wshadow -Wvla -Wstrict-aliasing=2) # -ffast-math dies on NaNs we draw from libav (by -ffinite-math-only) add_compile_options(-fno-signed-zeros -fno-trapping-math -fassociative-math) add_compile_options(-fno-math-errno -freciprocal-math -funsafe-math-optimizations) diff --git a/src/lib/blit.c b/src/lib/blit.c index fe042869d..2ef54e98f 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -929,13 +929,14 @@ hires_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, //fprintf(stderr, "hiresblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->u.cell.placey, bargs->u.cell.placex); const unsigned char* dat = data; int visy = bargs->begy; + assert(cellheight <= 4); // due to rgbas[] array below for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += cellheight){ if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){ return -1; } int visx = bargs->begx; for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){ - uint32_t rgbas[cellheight * 2]; // row-major + uint32_t rgbas[8]; // row-major memset(rgbas, 0, sizeof(rgbas)); memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * 4)), sizeof(*rgbas)); // conditional looks at first column, begininng at the second row From 1393cc28ae38a261293165fa68319debc44444aa Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Dec 2024 13:07:24 -0500 Subject: [PATCH 23/23] clean up octitions --- src/lib/blit.c | 94 ++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 61 deletions(-) diff --git a/src/lib/blit.c b/src/lib/blit.c index 2ef54e98f..4761fcd98 100644 --- a/src/lib/blit.c +++ b/src/lib/blit.c @@ -1006,74 +1006,46 @@ octant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx, static const unsigned octitions[128] = { 0, // one set - E(0), - E(1), - E(2), - E(3), - E(4), - E(5), - E(6), - E(7), + E(0), E(1), E(2), E(3), E(4), E(5), E(6), E(7), // two set (7 + 6 + 5 + 4 + 3 + 2 + 1 = 28) - E(0) + E(1), E(0) + E(2), E(0) + E(3), - E(0) + E(4), E(0) + E(5), E(0) + E(6), - E(0) + E(7), // 0 + 1... - E(1) + E(2), E(1) + E(3), E(1) + E(4), - E(1) + E(5), E(1) + E(6), E(1) + E(7), // 1 + 2... - E(2) + E(3), E(2) + E(4), E(2) + E(5), - E(2) + E(6), E(2) + E(7), // 2 + 3... - E(3) + E(4), E(3) + E(5), E(3) + E(6), - E(3) + E(7), // 3 + 4... - E(4) + E(5), E(4) + E(6), E(4) + E(7), // 4 + 5... - E(5) + E(6), E(5) + E(7), // 5 + 6... - E(6) + E(7), // 6 + 7 + E(0) + E(1), E(0) + E(2), E(0) + E(3), E(0) + E(4), E(0) + E(5), E(0) + E(6), E(0) + E(7), + E(1) + E(2), E(1) + E(3), E(1) + E(4), E(1) + E(5), E(1) + E(6), E(1) + E(7), + E(2) + E(3), E(2) + E(4), E(2) + E(5), E(2) + E(6), E(2) + E(7), + E(3) + E(4), E(3) + E(5), E(3) + E(6), E(3) + E(7), + E(4) + E(5), E(4) + E(6), E(4) + E(7), + E(5) + E(6), E(5) + E(7), + E(6) + E(7), // three set (21 + 15 + 10 + 6 + 3 + 1 = 56) - E(0) + E(1) + E(2), E(0) + E(1) + E(3), E(0) + E(1) + E(4), - E(0) + E(1) + E(5), E(0) + E(1) + E(6), E(0) + E(1) + E(7), // 0 + 1 + 2... - E(0) + E(2) + E(3), E(0) + E(2) + E(4), E(0) + E(2) + E(5), - E(0) + E(2) + E(6), E(0) + E(2) + E(7), // 0 + 2 + 3... - E(0) + E(3) + E(4), E(0) + E(3) + E(5), E(0) + E(3) + E(6), - E(0) + E(3) + E(7), // 3 + 4... - E(0) + E(4) + E(5), E(0) + E(4) + E(6), E(0) + E(4) + E(7), // 0 + 4 + 5... - E(0) + E(5) + E(6), E(0) + E(5) + E(7), // 0 + 5 + 6... + E(0) + E(1) + E(2), E(0) + E(1) + E(3), E(0) + E(1) + E(4), E(0) + E(1) + E(5), + E(0) + E(1) + E(6), E(0) + E(1) + E(7), E(0) + E(2) + E(3), E(0) + E(2) + E(4), + E(0) + E(2) + E(5), E(0) + E(2) + E(6), E(0) + E(2) + E(7), E(0) + E(3) + E(4), + E(0) + E(3) + E(5), E(0) + E(3) + E(6), E(0) + E(3) + E(7), E(0) + E(4) + E(5), + E(0) + E(4) + E(6), E(0) + E(4) + E(7), E(0) + E(5) + E(6), E(0) + E(5) + E(7), E(0) + E(6) + E(7), // 0 + 6 + 7 - E(1) + E(2) + E(3), E(1) + E(2) + E(4), E(1) + E(2) + E(5), - E(1) + E(2) + E(6), E(1) + E(2) + E(7), - E(1) + E(3) + E(4), E(1) + E(3) + E(5), E(1) + E(3) + E(6), - E(1) + E(3) + E(7), - E(1) + E(4) + E(5), E(1) + E(4) + E(6), E(1) + E(4) + E(7), - E(1) + E(5) + E(6), E(1) + E(5) + E(7), - E(1) + E(6) + E(7), - E(2) + E(3) + E(4), E(2) + E(3) + E(5), E(2) + E(3) + E(6), - E(2) + E(3) + E(7), - E(2) + E(4) + E(5), E(2) + E(4) + E(6), E(2) + E(4) + E(7), - E(2) + E(5) + E(6), E(2) + E(5) + E(7), - E(2) + E(6) + E(7), - E(3) + E(4) + E(5), E(3) + E(4) + E(6), E(3) + E(4) + E(7), - E(3) + E(5) + E(6), E(3) + E(5) + E(7), - E(3) + E(6) + E(7), - E(4) + E(5) + E(6), E(4) + E(5) + E(7), - E(4) + E(6) + E(7), - E(5) + E(6) + E(7), // 5 + 6 + 7 + E(1) + E(2) + E(3), E(1) + E(2) + E(4), E(1) + E(2) + E(5), E(1) + E(2) + E(6), + E(1) + E(2) + E(7), E(1) + E(3) + E(4), E(1) + E(3) + E(5), E(1) + E(3) + E(6), + E(1) + E(3) + E(7), E(1) + E(4) + E(5), E(1) + E(4) + E(6), E(1) + E(4) + E(7), + E(1) + E(5) + E(6), E(1) + E(5) + E(7), E(1) + E(6) + E(7), + E(2) + E(3) + E(4), E(2) + E(3) + E(5), E(2) + E(3) + E(6), E(2) + E(3) + E(7), + E(2) + E(4) + E(5), E(2) + E(4) + E(6), E(2) + E(4) + E(7), E(2) + E(5) + E(6), + E(2) + E(5) + E(7), E(2) + E(6) + E(7), + E(3) + E(4) + E(5), E(3) + E(4) + E(6), E(3) + E(4) + E(7), E(3) + E(5) + E(6), + E(3) + E(5) + E(7), E(3) + E(6) + E(7), + E(4) + E(5) + E(6), E(4) + E(5) + E(7), E(4) + E(6) + E(7), + E(5) + E(6) + E(7), // four set (15 + 10 + 6 + 3 + 1 = 35) E(0) + E(1) + E(2) + E(3), E(0) + E(1) + E(2) + E(4), E(0) + E(1) + E(2) + E(5), - E(0) + E(1) + E(2) + E(6), E(0) + E(1) + E(2) + E(7), - E(0) + E(1) + E(3) + E(4), E(0) + E(1) + E(3) + E(5), E(0) + E(1) + E(3) + E(6), - E(0) + E(1) + E(3) + E(7), + E(0) + E(1) + E(2) + E(6), E(0) + E(1) + E(2) + E(7), E(0) + E(1) + E(3) + E(4), + E(0) + E(1) + E(3) + E(5), E(0) + E(1) + E(3) + E(6), E(0) + E(1) + E(3) + E(7), E(0) + E(1) + E(4) + E(5), E(0) + E(1) + E(4) + E(6), E(0) + E(1) + E(4) + E(7), - E(0) + E(1) + E(5) + E(6), E(0) + E(1) + E(5) + E(7), - E(0) + E(1) + E(6) + E(7), + E(0) + E(1) + E(5) + E(6), E(0) + E(1) + E(5) + E(7), E(0) + E(1) + E(6) + E(7), E(0) + E(2) + E(3) + E(4), E(0) + E(2) + E(3) + E(5), E(0) + E(2) + E(3) + E(6), - E(0) + E(2) + E(3) + E(7), - E(0) + E(2) + E(4) + E(5), E(0) + E(2) + E(4) + E(6), E(0) + E(2) + E(4) + E(7), - E(0) + E(2) + E(5) + E(6), E(0) + E(2) + E(5) + E(7), - E(0) + E(2) + E(6) + E(7), - E(0) + E(3) + E(4) + E(5), E(0) + E(3) + E(4) + E(6), E(0) + E(3) + E(4) + E(7), - E(0) + E(3) + E(5) + E(6), E(0) + E(3) + E(5) + E(7), - E(0) + E(3) + E(6) + E(7), - E(0) + E(4) + E(5) + E(6), E(0) + E(4) + E(5) + E(7), - E(0) + E(4) + E(6) + E(7), - E(0) + E(5) + E(6) + E(7), // 0 + 5 + 6 + 7 + E(0) + E(2) + E(3) + E(7), E(0) + E(2) + E(4) + E(5), E(0) + E(2) + E(4) + E(6), + E(0) + E(2) + E(4) + E(7), E(0) + E(2) + E(5) + E(6), E(0) + E(2) + E(5) + E(7), + E(0) + E(2) + E(6) + E(7), E(0) + E(3) + E(4) + E(5), E(0) + E(3) + E(4) + E(6), + E(0) + E(3) + E(4) + E(7), E(0) + E(3) + E(5) + E(6), E(0) + E(3) + E(5) + E(7), + E(0) + E(3) + E(6) + E(7), E(0) + E(4) + E(5) + E(6), E(0) + E(4) + E(5) + E(7), + E(0) + E(4) + E(6) + E(7), E(0) + E(5) + E(6) + E(7), #undef E }; return hires_blit(nc, linesize, data, leny, lenx, bargs, 4, octtrans, octitions);