[visual] move placey/placex into cell union

pull/1418/head
nick black 4 years ago committed by Nick Black
parent 70fb40ea5a
commit b282c2055b

@ -33,10 +33,9 @@ trilerp(uint32_t c0, uint32_t c1, uint32_t c2){
// Retarded RGBA blitter (ASCII only). // Retarded RGBA blitter (ASCII only).
static inline int static inline int
tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize, tria_blit_ascii(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs){ int leny, int lenx, const blitterargs* bargs){
//fprintf(stderr, "ASCII %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, placey, placex); //fprintf(stderr, "ASCII %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, bargs->cell.placey, bargs->cell.placex);
const int bpp = 32; const int bpp = 32;
int dimy, dimx, x, y; int dimy, dimx, x, y;
int total = 0; // number of cells written int total = 0; // number of cells written
@ -44,12 +43,12 @@ tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize,
// FIXME not going to necessarily be safe on all architectures hrmmm // FIXME not going to necessarily be safe on all architectures hrmmm
const unsigned char* dat = data; const unsigned char* dat = data;
int visy = begy; int visy = begy;
for(y = placey ; visy < (begy + leny) && y < dimy ; ++y, ++visy){ for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, ++visy){
if(ncplane_cursor_move_yx(nc, y, placex)){ if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
return -1; return -1;
} }
int visx = begx; int visx = begx;
for(x = placex ; visx < (begx + lenx) && x < dimx ; ++x, ++visx){ for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, ++visx){
const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * bpp / CHAR_BIT); const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * bpp / CHAR_BIT);
//fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]); //fprintf(stderr, "[%04d/%04d] bpp: %d lsize: %d %02x %02x %02x %02x\n", y, x, bpp, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]);
nccell* c = ncplane_cell_ref_yx(nc, y, x); nccell* c = ncplane_cell_ref_yx(nc, y, x);
@ -57,7 +56,7 @@ tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize,
// effective in that case anyway // effective in that case anyway
c->channels = 0; c->channels = 0;
c->stylemask = 0; c->stylemask = 0;
if(bargs->blendcolors){ if(bargs->cell.blendcolors){
cell_set_bg_alpha(c, CELL_ALPHA_BLEND); cell_set_bg_alpha(c, CELL_ALPHA_BLEND);
cell_set_fg_alpha(c, CELL_ALPHA_BLEND); cell_set_fg_alpha(c, CELL_ALPHA_BLEND);
} }
@ -82,10 +81,9 @@ tria_blit_ascii(ncplane* nc, int placey, int placex, int linesize,
// RGBA half-block blitter. Best for most images/videos. Full fidelity // RGBA half-block blitter. Best for most images/videos. Full fidelity
// combined with 1:1 pixel aspect ratio. // combined with 1:1 pixel aspect ratio.
static inline int static inline int
tria_blit(ncplane* nc, int placey, int placex, int linesize, tria_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs){ int leny, int lenx, const blitterargs* bargs){
//fprintf(stderr, "HALF %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, placey, placex); //fprintf(stderr, "HALF %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, begy, begx, data, bargs->cell.placey, bargs->cell.placex);
const int bpp = 32; const int bpp = 32;
int dimy, dimx, x, y; int dimy, dimx, x, y;
int total = 0; // number of cells written int total = 0; // number of cells written
@ -93,12 +91,12 @@ tria_blit(ncplane* nc, int placey, int placex, int linesize,
// FIXME not going to necessarily be safe on all architectures hrmmm // FIXME not going to necessarily be safe on all architectures hrmmm
const unsigned char* dat = data; const unsigned char* dat = data;
int visy = begy; int visy = begy;
for(y = placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 2){ for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 2){
if(ncplane_cursor_move_yx(nc, y, placex)){ if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
return -1; return -1;
} }
int visx = begx; int visx = begx;
for(x = placex ; visx < (begx + lenx) && x < dimx ; ++x, ++visx){ for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, ++visx){
const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * bpp / CHAR_BIT); const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * bpp / CHAR_BIT);
const unsigned char* rgbbase_down = zeroes; const unsigned char* rgbbase_down = zeroes;
if(visy < begy + leny - 1){ if(visy < begy + leny - 1){
@ -110,7 +108,7 @@ tria_blit(ncplane* nc, int placey, int placex, int linesize,
// effective in that case anyway // effective in that case anyway
c->channels = 0; c->channels = 0;
c->stylemask = 0; c->stylemask = 0;
if(bargs->blendcolors){ if(bargs->cell.blendcolors){
cell_set_bg_alpha(c, CELL_ALPHA_BLEND); cell_set_bg_alpha(c, CELL_ALPHA_BLEND);
cell_set_fg_alpha(c, CELL_ALPHA_BLEND); cell_set_fg_alpha(c, CELL_ALPHA_BLEND);
} }
@ -416,23 +414,22 @@ qtrans_check(nccell* c, unsigned blendcolors,
// quadrant blitter. maps 2x2 to each cell. since we only have two colors at // quadrant blitter. maps 2x2 to each cell. since we only have two colors at
// our disposal (foreground and background), we lose some fidelity. // our disposal (foreground and background), we lose some fidelity.
static inline int static inline int
quadrant_blit(ncplane* nc, int placey, int placex, int linesize, quadrant_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs){ int leny, int lenx, const blitterargs* bargs){
const int bpp = 32; const int bpp = 32;
int dimy, dimx, x, y; int dimy, dimx, x, y;
int total = 0; // number of cells written int total = 0; // number of cells written
ncplane_dim_yx(nc, &dimy, &dimx); ncplane_dim_yx(nc, &dimy, &dimx);
//fprintf(stderr, "quadblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, placey, placex); //fprintf(stderr, "quadblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->cell.placey, bargs->cell.placex);
// FIXME not going to necessarily be safe on all architectures hrmmm // FIXME not going to necessarily be safe on all architectures hrmmm
const unsigned char* dat = data; const unsigned char* dat = data;
int visy = begy; int visy = begy;
for(y = placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 2){ for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 2){
if(ncplane_cursor_move_yx(nc, y, placex)){ if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
return -1; return -1;
} }
int visx = begx; int visx = begx;
for(x = placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){ for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){
const unsigned char* rgbbase_tl = dat + (linesize * visy) + (visx * bpp / CHAR_BIT); const unsigned char* rgbbase_tl = dat + (linesize * visy) + (visx * bpp / CHAR_BIT);
const unsigned char* rgbbase_tr = zeroes; const unsigned char* rgbbase_tr = zeroes;
const unsigned char* rgbbase_bl = zeroes; const unsigned char* rgbbase_bl = zeroes;
@ -450,7 +447,7 @@ quadrant_blit(ncplane* nc, int placey, int placex, int linesize,
nccell* c = ncplane_cell_ref_yx(nc, y, x); nccell* c = ncplane_cell_ref_yx(nc, y, x);
c->channels = 0; c->channels = 0;
c->stylemask = 0; c->stylemask = 0;
const char* egc = qtrans_check(c, bargs->blendcolors, rgbbase_tl, rgbbase_tr, rgbbase_bl, rgbbase_br); const char* egc = qtrans_check(c, bargs->cell.blendcolors, rgbbase_tl, rgbbase_tr, rgbbase_bl, rgbbase_br);
if(egc == NULL){ if(egc == NULL){
uint32_t tl = 0, tr = 0, bl = 0, br = 0; uint32_t tl = 0, tr = 0, bl = 0, br = 0;
channel_set_rgb8(&tl, rgbbase_tl[0], rgbbase_tl[1], rgbbase_tl[2]); channel_set_rgb8(&tl, rgbbase_tl[0], rgbbase_tl[1], rgbbase_tl[2]);
@ -464,7 +461,7 @@ quadrant_blit(ncplane* nc, int placey, int placex, int linesize,
//fprintf(stderr, "%d/%d %08x/%08x\n", y, x, fg, bg); //fprintf(stderr, "%d/%d %08x/%08x\n", y, x, fg, bg);
cell_set_fchannel(c, fg); cell_set_fchannel(c, fg);
cell_set_bchannel(c, bg); cell_set_bchannel(c, bg);
if(bargs->blendcolors){ if(bargs->cell.blendcolors){
cell_set_bg_alpha(c, CELL_ALPHA_BLEND); cell_set_bg_alpha(c, CELL_ALPHA_BLEND);
cell_set_fg_alpha(c, CELL_ALPHA_BLEND); cell_set_fg_alpha(c, CELL_ALPHA_BLEND);
} }
@ -639,22 +636,21 @@ sex_trans_check(cell* c, const uint32_t rgbas[6], unsigned blendcolors){
// sextant blitter. maps 3x2 to each cell. since we only have two colors at // sextant blitter. maps 3x2 to each cell. since we only have two colors at
// our disposal (foreground and background), we lose some fidelity. // our disposal (foreground and background), we lose some fidelity.
static inline int static inline int
sextant_blit(ncplane* nc, int placey, int placex, int linesize, sextant_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs){ int leny, int lenx, const blitterargs* bargs){
const int bpp = 32; const int bpp = 32;
int dimy, dimx, x, y; int dimy, dimx, x, y;
int total = 0; // number of cells written int total = 0; // number of cells written
ncplane_dim_yx(nc, &dimy, &dimx); ncplane_dim_yx(nc, &dimy, &dimx);
//fprintf(stderr, "sexblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, placey, placex); //fprintf(stderr, "sexblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->cell.placey, bargs->cell.placex);
const unsigned char* dat = data; const unsigned char* dat = data;
int visy = begy; int visy = begy;
for(y = placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 3){ for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 3){
if(ncplane_cursor_move_yx(nc, y, placex)){ if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
return -1; return -1;
} }
int visx = begx; int visx = begx;
for(x = placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){ for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){
uint32_t rgbas[6] = { 0, 0, 0, 0, 0, 0 }; uint32_t rgbas[6] = { 0, 0, 0, 0, 0, 0 };
memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * bpp / CHAR_BIT)), sizeof(*rgbas)); memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * bpp / CHAR_BIT)), sizeof(*rgbas));
if(visx < begx + lenx - 1){ if(visx < begx + lenx - 1){
@ -675,9 +671,9 @@ sextant_blit(ncplane* nc, int placey, int placex, int linesize,
nccell* c = ncplane_cell_ref_yx(nc, y, x); nccell* c = ncplane_cell_ref_yx(nc, y, x);
c->channels = 0; c->channels = 0;
c->stylemask = 0; c->stylemask = 0;
const char* egc = sex_trans_check(c, rgbas, bargs->blendcolors); const char* egc = sex_trans_check(c, rgbas, bargs->cell.blendcolors);
if(egc == NULL){ if(egc == NULL){
egc = sex_solver(rgbas, &c->channels, bargs->blendcolors); egc = sex_solver(rgbas, &c->channels, bargs->cell.blendcolors);
cell_set_blitquadrants(c, 1, 1, 1, 1); cell_set_blitquadrants(c, 1, 1, 1, 1);
} }
//fprintf(stderr, "sex EGC: %s channels: %016lx\n", egc, c->channels); //fprintf(stderr, "sex EGC: %s channels: %016lx\n", egc, c->channels);
@ -708,8 +704,7 @@ fold_rgb8(unsigned* restrict r, unsigned* restrict g, unsigned* restrict b,
// visuals with only two colors in a given area, as it packs lots of // visuals with only two colors in a given area, as it packs lots of
// resolution. always transparent background. // resolution. always transparent background.
static inline int static inline int
braille_blit(ncplane* nc, int placey, int placex, int linesize, braille_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs){ int leny, int lenx, const blitterargs* bargs){
const int bpp = 32; const int bpp = 32;
int dimy, dimx, x, y; int dimy, dimx, x, y;
@ -718,12 +713,12 @@ braille_blit(ncplane* nc, int placey, int placex, int linesize,
// FIXME not going to necessarily be safe on all architectures hrmmm // FIXME not going to necessarily be safe on all architectures hrmmm
const unsigned char* dat = data; const unsigned char* dat = data;
int visy = begy; int visy = begy;
for(y = placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 4){ for(y = bargs->cell.placey ; visy < (begy + leny) && y < dimy ; ++y, visy += 4){
if(ncplane_cursor_move_yx(nc, y, placex)){ if(ncplane_cursor_move_yx(nc, y, bargs->cell.placex)){
return -1; return -1;
} }
int visx = begx; int visx = begx;
for(x = placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){ for(x = bargs->cell.placex ; visx < (begx + lenx) && x < dimx ; ++x, visx += 2){
const uint32_t* rgbbase_l0 = (const uint32_t*)(dat + (linesize * visy) + (visx * bpp / CHAR_BIT)); const uint32_t* rgbbase_l0 = (const uint32_t*)(dat + (linesize * visy) + (visx * bpp / CHAR_BIT));
const uint32_t* rgbbase_r0 = &zeroes32; const uint32_t* rgbbase_r0 = &zeroes32;
const uint32_t* rgbbase_l1 = &zeroes32; const uint32_t* rgbbase_l1 = &zeroes32;
@ -795,7 +790,7 @@ braille_blit(ncplane* nc, int placey, int placex, int linesize,
// effective in that case anyway // effective in that case anyway
c->channels = 0; c->channels = 0;
c->stylemask = 0; c->stylemask = 0;
if(bargs->blendcolors){ if(bargs->cell.blendcolors){
cell_set_fg_alpha(c, CELL_ALPHA_BLEND); cell_set_fg_alpha(c, CELL_ALPHA_BLEND);
} }
// FIXME for now, we just sample, color-wise, and always draw crap. // FIXME for now, we just sample, color-wise, and always draw crap.
@ -976,10 +971,13 @@ int ncblit_rgba(const void* data, int linesize, const struct ncvisual_options* v
return -1; return -1;
} }
blitterargs bargs = { blitterargs bargs = {
.blendcolors = (vopts->flags & NCVISUAL_OPTION_BLEND), .cell = {
.placey = vopts->y,
.placex = vopts->x,
.blendcolors = (vopts->flags & NCVISUAL_OPTION_BLEND),
},
}; };
return bset->blit(nc, vopts->y, vopts->x, linesize, data, begy, begx, return bset->blit(nc, linesize, data, begy, begx, leny, lenx, &bargs);
leny, lenx, &bargs);
} }
ncblitter_e ncvisual_media_defblitter(const notcurses* nc, ncscale_e scale){ ncblitter_e ncvisual_media_defblitter(const notcurses* nc, ncscale_e scale){

@ -524,7 +524,7 @@ ncdirectv* ncdirect_render_frame(ncdirect* n, const char* file,
}, },
}; };
if(ncvisual_blit(ncv, disprows, dispcols, ncdv, bset, if(ncvisual_blit(ncv, disprows, dispcols, ncdv, bset,
0, 0, 0, 0, leny, lenx, &bargs)){ 0, 0, leny, lenx, &bargs)){
ncvisual_destroy(ncv); ncvisual_destroy(ncv);
free_plane(ncdv); free_plane(ncdv);
return nullptr; return nullptr;

@ -398,7 +398,11 @@ typedef struct notcurses {
// cell vs pixel-specific arguments // cell vs pixel-specific arguments
typedef union { typedef union {
unsigned blendcolors; // for cells struct {
int placey; // placement within ncplane
int placex;
int blendcolors; // use CELL_ALPHA_BLEND
} cell; // for cells
struct { struct {
int celldimx; // horizontal pixels per cell int celldimx; // horizontal pixels per cell
int celldimy; // vertical pixels per cell int celldimy; // vertical pixels per cell
@ -406,9 +410,9 @@ typedef union {
} pixel; // for pixels } pixel; // for pixels
} blitterargs; } blitterargs;
typedef int (*blitter)(struct ncplane* n, int placey, int placex, typedef int (*blitter)(struct ncplane* n, int linesize, const void* data,
int linesize, const void* data, int begy, int begx, int begy, int begx, int leny, int lenx,
int leny, int lenx, const blitterargs* bargs); const blitterargs* bargs);
// a system for rendering RGBA pixels as text glyphs // a system for rendering RGBA pixels as text glyphs
struct blitset { struct blitset {
@ -864,8 +868,7 @@ ALLOC char* ncplane_vprintf_prep(const char* format, va_list ap);
// change the internals of the ncvisual. Uses oframe. // change the internals of the ncvisual. Uses oframe.
int ncvisual_blit(struct ncvisual* ncv, int rows, int cols, int ncvisual_blit(struct ncvisual* ncv, int rows, int cols,
ncplane* n, const struct blitset* bset, ncplane* n, const struct blitset* bset,
int placey, int placex, int begy, int begx, int begy, int begx, int leny, int lenx, const blitterargs* bargs);
int leny, int lenx, const blitterargs* bargs);
void nclog(const char* fmt, ...); void nclog(const char* fmt, ...);
@ -1214,12 +1217,10 @@ ncdirect_bg_default_p(const struct ncdirect* nc){
return channels_bg_default_p(ncdirect_channels(nc)); return channels_bg_default_p(ncdirect_channels(nc));
} }
int sixel_blit(ncplane* nc, int placey, int placex, int linesize, int sixel_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs); int leny, int lenx, const blitterargs* bargs);
int kitty_blit(ncplane* nc, int placey, int placex, int linesize, int kitty_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs); int leny, int lenx, const blitterargs* bargs);
int term_fg_rgb8(bool RGBflag, const char* setaf, int colors, FILE* out, int term_fg_rgb8(bool RGBflag, const char* setaf, int colors, FILE* out,
@ -1228,11 +1229,10 @@ int term_fg_rgb8(bool RGBflag, const char* setaf, int colors, FILE* out,
API const struct blitset* lookup_blitset(const tinfo* tcache, ncblitter_e setid, bool may_degrade); API const struct blitset* lookup_blitset(const tinfo* tcache, ncblitter_e setid, bool may_degrade);
static inline int static inline int
rgba_blit_dispatch(ncplane* nc, const struct blitset* bset, int placey, rgba_blit_dispatch(ncplane* nc, const struct blitset* bset,
int placex, int linesize, const void* data, int begy, int linesize, const void* data, int begy,
int begx, int leny, int lenx, const blitterargs* bargs){ int begx, int leny, int lenx, const blitterargs* bargs){
return bset->blit(nc, placey, placex, linesize, data, begy, begx, return bset->blit(nc, linesize, data, begy, begx, leny, lenx, bargs);
leny, lenx, bargs);
} }
static inline const struct blitset* static inline const struct blitset*
@ -1257,9 +1257,8 @@ typedef struct ncvisual_implementation {
int (*visual_init)(int loglevel); int (*visual_init)(int loglevel);
void (*visual_printbanner)(const struct notcurses* nc); void (*visual_printbanner)(const struct notcurses* nc);
int (*visual_blit)(struct ncvisual* ncv, int rows, int cols, ncplane* n, int (*visual_blit)(struct ncvisual* ncv, int rows, int cols, ncplane* n,
const struct blitset* bset, int placey, int placex, const struct blitset* bset, int begy, int begx,
int begy, int begx, int leny, int lenx, int leny, int lenx, const blitterargs* barg);
const blitterargs* barg);
struct ncvisual* (*visual_create)(void); struct ncvisual* (*visual_create)(void);
struct ncvisual* (*visual_from_file)(const char* fname); struct ncvisual* (*visual_from_file)(const char* fname);
// ncv constructors other than ncvisual_from_file() need to set up the // ncv constructors other than ncvisual_from_file() need to set up the

@ -142,13 +142,10 @@ int kitty_blit_inner(ncplane* nc, int linesize, int leny, int lenx,
} }
int kitty_blit(ncplane* nc, int placey, int placex, int linesize, int kitty_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs){ int leny, int lenx, const blitterargs* bargs){
(void)begy; (void)begy;
(void)begx; (void)begx;
(void)placey;
(void)placex;
//fprintf(stderr, "s=%d,v=%d\n", lenx, leny); //fprintf(stderr, "s=%d,v=%d\n", lenx, leny);
int r = kitty_blit_inner(nc, linesize, leny, lenx, data, bargs); int r = kitty_blit_inner(nc, linesize, leny, lenx, data, bargs);
if(r < 0){ if(r < 0){

@ -266,11 +266,8 @@ int sixel_blit_inner(ncplane* nc, int leny, int lenx, sixeltable* stab,
return 1; return 1;
} }
int sixel_blit(ncplane* nc, int placey, int placex, int linesize, int sixel_blit(ncplane* nc, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs){ int leny, int lenx, const blitterargs* bargs){
(void)placey;
(void)placex;
int sixelcount = (lenx - begx) * ((leny - begy + 5) / 6); int sixelcount = (lenx - begx) * ((leny - begy + 5) / 6);
sixeltable stable = { sixeltable stable = {
.data = malloc(MAXCOLORS * sixelcount), .data = malloc(MAXCOLORS * sixelcount),

@ -14,17 +14,16 @@ auto ncvisual_decode(ncvisual* nc) -> int {
} }
auto ncvisual_blit(ncvisual* ncv, int rows, int cols, ncplane* n, auto ncvisual_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
const struct blitset* bset, int placey, int placex, const struct blitset* bset, int begy, int begx,
int begy, int begx, int leny, int lenx, int leny, int lenx, const blitterargs* barg) -> int {
const blitterargs* barg) -> int {
int ret = -1; int ret = -1;
if(visual_implementation){ if(visual_implementation){
if(visual_implementation->visual_blit(ncv, rows, cols, n, bset, placey, placex, if(visual_implementation->visual_blit(ncv, rows, cols, n, bset,
begy, begx, leny, lenx, barg) >= 0){ begy, begx, leny, lenx, barg) >= 0){
ret = 0; ret = 0;
} }
}else{ }else{
if(rgba_blit_dispatch(n, bset, placey, placex, ncv->rowstride, ncv->data, if(rgba_blit_dispatch(n, bset, ncv->rowstride, ncv->data,
begy, begx, leny, lenx, barg) >= 0){ begy, begx, leny, lenx, barg) >= 0){
ret = 0; ret = 0;
} }
@ -472,9 +471,10 @@ auto ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const blitset* bset,
lenx = (lenx / (double)ncv->cols) * ((double)dispcols); lenx = (lenx / (double)ncv->cols) * ((double)dispcols);
//fprintf(stderr, "blit: %dx%d:%d+%d of %d/%d stride %u %p\n", begy, begx, leny, lenx, ncv->rows, ncv->cols, ncv->rowstride, ncv->data); //fprintf(stderr, "blit: %dx%d:%d+%d of %d/%d stride %u %p\n", begy, begx, leny, lenx, ncv->rows, ncv->cols, ncv->rowstride, ncv->data);
blitterargs bargs; blitterargs bargs;
bargs.blendcolors = blendcolors; bargs.cell.placey = placey;
if(ncvisual_blit(ncv, disprows, dispcols, n, bset, bargs.cell.placex = placex;
placey, placex, begy, begx, leny, lenx, &bargs)){ bargs.cell.blendcolors = blendcolors;
if(ncvisual_blit(ncv, disprows, dispcols, n, bset, begy, begx, leny, lenx, &bargs)){
ncplane_destroy(n); ncplane_destroy(n);
return nullptr; return nullptr;
} }
@ -483,8 +483,7 @@ auto ncvisual_render_cells(notcurses* nc, ncvisual* ncv, const blitset* bset,
auto ncvisual_render_pixels(tinfo* tcache, ncvisual* ncv, const blitset* bset, auto ncvisual_render_pixels(tinfo* tcache, ncvisual* ncv, const blitset* bset,
int placey, int placex, int begy, int begx, int placey, int placex, int begy, int begx,
ncplane* n, ncscale_e scaling, ncplane* stdn) ncplane* n, ncscale_e scaling, ncplane* stdn) -> ncplane* {
-> ncplane* {
int disprows, dispcols; int disprows, dispcols;
if(scaling == NCSCALE_NONE || scaling == NCSCALE_NONE_HIRES){ if(scaling == NCSCALE_NONE || scaling == NCSCALE_NONE_HIRES){
dispcols = ncv->cols; dispcols = ncv->cols;
@ -531,7 +530,7 @@ auto ncvisual_render_pixels(tinfo* tcache, ncvisual* ncv, const blitset* bset,
bargs.pixel.celldimy = ncplane_notcurses(stdn)->tcache.cellpixy; bargs.pixel.celldimy = ncplane_notcurses(stdn)->tcache.cellpixy;
bargs.pixel.colorregs = ncplane_notcurses(stdn)->tcache.color_registers; bargs.pixel.colorregs = ncplane_notcurses(stdn)->tcache.color_registers;
if(ncvisual_blit(ncv, disprows, dispcols, n, bset, if(ncvisual_blit(ncv, disprows, dispcols, n, bset,
placey, placex, begy, begx, disprows, dispcols, &bargs)){ begy, begx, disprows, dispcols, &bargs)){
ncplane_destroy(n); ncplane_destroy(n);
return nullptr; return nullptr;
} }

@ -468,8 +468,8 @@ int ffmpeg_decode_loop(ncvisual* ncv){
} }
int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n, int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
const struct blitset* bset, int placey, int placex, const struct blitset* bset, int begy, int begx,
int begy, int begx, int leny, int lenx, const blitterargs* bargs) { int leny, int lenx, const blitterargs* bargs) {
const AVFrame* inframe = ncv->details->oframe ? ncv->details->oframe : ncv->details->frame; const AVFrame* inframe = ncv->details->oframe ? ncv->details->oframe : ncv->details->frame;
//fprintf(stderr, "inframe: %p oframe: %p frame: %p\n", inframe, ncv->details->oframe, ncv->details->frame); //fprintf(stderr, "inframe: %p oframe: %p frame: %p\n", inframe, ncv->details->oframe, ncv->details->frame);
void* data = nullptr; void* data = nullptr;
@ -521,9 +521,8 @@ int ffmpeg_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
stride = ncv->rowstride; stride = ncv->rowstride;
data = ncv->data; data = ncv->data;
} }
//fprintf(stderr, "place: %d/%d rows/cols: %d/%d %d/%d+%d/%d\n", placey, placex, rows, cols, begy, begx, leny, lenx); //fprintf(stderr, "place: %d/%d rows/cols: %d/%d %d/%d+%d/%d\n", bargs->cell.placey, bargs->cell.placex, rows, cols, begy, begx, leny, lenx);
if(rgba_blit_dispatch(n, bset, placey, placex, stride, data, begy, begx, if(rgba_blit_dispatch(n, bset, stride, data, begy, begx, leny, lenx, bargs) < 0){
leny, lenx, bargs) < 0){
//fprintf(stderr, "rgba dispatch failed!\n"); //fprintf(stderr, "rgba dispatch failed!\n");
if(sframe){ if(sframe){
av_freep(sframe->data); av_freep(sframe->data);

@ -36,11 +36,10 @@ int none_resize(ncvisual* nc, int rows, int cols) {
int none_blit(struct ncvisual* ncv, int rows, int cols, int none_blit(struct ncvisual* ncv, int rows, int cols,
ncplane* n, const struct blitset* bset, ncplane* n, const struct blitset* bset,
int placey, int placex, int begy, int begx, int begy, int begx, int leny, int lenx, const blitterargs* bargs) {
int leny, int lenx, const blitterargs* bargs) {
(void)rows; (void)rows;
(void)cols; (void)cols;
if(rgba_blit_dispatch(n, bset, placey, placex, ncv->rowstride, ncv->data, if(rgba_blit_dispatch(n, bset, ncv->rowstride, ncv->data,
begy, begx, leny, lenx, bargs) >= 0){ begy, begx, leny, lenx, bargs) >= 0){
return 0; return 0;
} }

@ -5,10 +5,9 @@
#include "oiio.h" #include "oiio.h"
int oiio_blit_dispatch(struct ncplane* nc, const struct blitset* bset, int oiio_blit_dispatch(struct ncplane* nc, const struct blitset* bset,
int placey, int placex, int linesize, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx, int leny, int lenx, const blitterargs* bargs){
int leny, int lenx, const blitterargs* bargs){ if(rgba_blit_dispatch(nc, bset, linesize, data, begy, begx,
if(rgba_blit_dispatch(nc, bset, placey, placex, linesize, data, begy, begx,
leny, lenx, bargs) < 0){ leny, lenx, bargs) < 0){
return -1; return -1;
} }

@ -149,8 +149,7 @@ int oiio_resize(ncvisual* nc, int rows, int cols) {
int oiio_blit(struct ncvisual* ncv, int rows, int cols, int oiio_blit(struct ncvisual* ncv, int rows, int cols,
ncplane* n, const struct blitset* bset, ncplane* n, const struct blitset* bset,
int placey, int placex, int begy, int begx, int begy, int begx, int leny, int lenx, const blitterargs* bargs) {
int leny, int lenx, const blitterargs* bargs) {
//fprintf(stderr, "%d/%d -> %d/%d on the resize\n", ncv->rows, ncv->cols, rows, cols); //fprintf(stderr, "%d/%d -> %d/%d on the resize\n", ncv->rows, ncv->cols, rows, cols);
void* data = nullptr; void* data = nullptr;
int stride = 0; int stride = 0;
@ -171,8 +170,7 @@ int oiio_blit(struct ncvisual* ncv, int rows, int cols,
data = ncv->data; data = ncv->data;
stride = ncv->rowstride; stride = ncv->rowstride;
} }
return oiio_blit_dispatch(n, bset, placey, placex, stride, data, return oiio_blit_dispatch(n, bset, stride, data, begy, begx, leny, lenx, bargs);
begy, begx, leny, lenx, bargs);
return 0; return 0;
} }

@ -12,16 +12,14 @@ struct ncvisual_details* oiio_details_init(void);
void oiio_printbanner(const struct notcurses* nc); void oiio_printbanner(const struct notcurses* nc);
int oiio_blit(struct ncvisual* ncv, int rows, int cols, int oiio_blit(struct ncvisual* ncv, int rows, int cols,
struct ncplane* n, const struct blitset* bset, struct ncplane* n, const struct blitset* bset,
int placey, int placex, int begy, int begx, int begy, int begx, int leny, int lenx, const blitterargs* bargs);
int leny, int lenx, const blitterargs* bargs);
ncvisual* oiio_from_file(const char* filename); ncvisual* oiio_from_file(const char* filename);
void oiio_details_destroy(struct ncvisual_details* deets); void oiio_details_destroy(struct ncvisual_details* deets);
int oiio_decode_loop(ncvisual* ncv); int oiio_decode_loop(ncvisual* ncv);
int oiio_resize(ncvisual* nc, int rows, int cols); int oiio_resize(ncvisual* nc, int rows, int cols);
struct ncvisual* oiio_create(void); struct ncvisual* oiio_create(void);
int oiio_blit_dispatch(struct ncplane* nc, const struct blitset* bset, int oiio_blit_dispatch(struct ncplane* nc, const struct blitset* bset,
int placey, int placex, int linesize, int linesize, const void* data, int begy, int begx,
const void* data, int begy, int begx,
int leny, int lenx, const blitterargs* bargs); int leny, int lenx, const blitterargs* bargs);
#ifdef __cplusplus #ifdef __cplusplus

Loading…
Cancel
Save