Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smarter merging with octrees #2516

Closed
dankamongmen opened this issue Jan 1, 2022 · 5 comments
Closed

smarter merging with octrees #2516

dankamongmen opened this issue Jan 1, 2022 · 5 comments
Assignees
Labels
bitmaps bitmapped graphics (sixel, kitty, mmap) enhancement New feature or request perf sweet sweet perf
Milestone

Comments

@dankamongmen
Copy link
Owner

The new octree implementation (see #2503) has a tres shitty merger (we always merge to the most popular, a terrible merger). Improve it, ideally improving performance at the same time somehow, heh. This is not as big a deal as #2515, as this kind of image is fairly rare.

@dankamongmen dankamongmen added enhancement New feature or request perf sweet sweet perf bitmaps bitmapped graphics (sixel, kitty, mmap) labels Jan 1, 2022
@dankamongmen dankamongmen added this to the 4.0.0 milestone Jan 1, 2022
@dankamongmen dankamongmen self-assigned this Jan 1, 2022
@dankamongmen
Copy link
Owner Author

we're likely going to need this in the 3.0.x timeframe, since #2515 is going to put a lot more pressure on our color allocation.

@dankamongmen
Copy link
Owner Author

ok, here's how we do this in O(N):

  • start with two values, "hi" and "lo", initialized to -1.
  • start iterating over the qnodes. we'll be hitting them all, but only through the static 1000. idx is z.
  • A: if node is empty, proceed to next
  • if node is chosen, node replaces "lo"
  • if node is populated but unchosen, and hi is less than z, we need find the next lowest chosen one by walking up from z. if there is no next lowest, hi is reset to -1. otherwise, set hi.
  • once we have the new hi > z, determine which of hi and lo are closer to z (discount -1 values), and link the closer one to z
  • goto A

simple. the only wrinkle is that iterating over the qnodes means:

  • is qnode an onode? if so, iterate over elements of onode
  • otherwise, just look at qnode
  • each toplevel qnode is worth 8. each second level qnode is worth 1.

dankamongmen added a commit that referenced this issue Jan 10, 2022
@dankamongmen
Copy link
Owner Author

w000t!

old:
1214400px Δr 106936936 (88.1) Δg 94246853 (77.6) Δb 122570434 (101)
avg diff per pixel: 267
done with /media/chungus/images/allrgb/balloon.png in 1180.116ms.
2022-01-10-084518_884x1415_scrot

new:
1214400px Δr 104101608 (85.7) Δg 95135210 (78.3) Δb 116463896 (95.9)
avg diff per pixel: 260
done with /media/chungus/images/allrgb/balloon.png in 1220.229ms.
2022-01-10-084524_884x1415_scrot

that's MUCH better quality and only a little bit of slowdown, huzzah! this slowdown will only happen when we have more colors than we do color registers.

@dankamongmen
Copy link
Owner Author

this is ready to go bitches! what a nice win for a monday morning!

you'd better eat your wheaties

@dankamongmen
Copy link
Owner Author

closed via #2545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bitmaps bitmapped graphics (sixel, kitty, mmap) enhancement New feature or request perf sweet sweet perf
Projects
None yet
Development

No branches or pull requests

1 participant