Skip to content

Conversation

@JustAMan
Copy link

This happens when e.g. subtitles are displayed simultaneously on top and at bottom.
Before the change subtitles were rendered in the whole bounding rect, which could end up taking the whole viewport.

Now I change this to splitted rendering (splitting the viewport in 3x3 grid and then merging intersecting rects). This reduces memory footprint and blending time for subtitles which have far spaced parts.

Notes

  • src/SubOctpInterface.cpp and src/SubOctpInterface.js are generated
  • renderBlendPart() is almost a cut-paste portion of renderBlend(), with pretty minimal changes inside

Copy link
Collaborator

@dmitrylyzo dmitrylyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost didn't look on blend itself, because I believe that you just moved it.

@JustAMan
Copy link
Author

@JustAMan JustAMan force-pushed the wind-gusts-ripping-canvas branch from 403ea49 to a87c702 Compare March 25, 2020 12:51
@dmitrylyzo
Copy link
Collaborator

dmitrylyzo commented Mar 25, 2020

https://github.com/jellyfin/JavascriptSubtitlesOctopus/pull/9/files#diff-a1bb6e1327d5352744b2f8253e342183R625-R651

Yeah, I looked this.
You search for biggest buffer to minimize allocation, right?
Suppose we have render chunks from smaller to bigger. Can't be that a smaller chunk will steal biggest buffer from next bigger chunk. In worst case, all buffers will be screen size, and this will become irrelevant. But maybe search for smallest bigger ("just enough size") and biggest smaller buffer.

Nm, I read it wrong.

@JustAMan
Copy link
Author

JustAMan commented Mar 25, 2020

Not exactly. I always search for smallest buffer, but actually detect two kinds of them: one (called bigBuffer) is big enough to hold the needed amount without growing it, and another (smallBuffer) is the smallest available (so that I don't take some bigger which could be re-used by other parts without growing that).

So the strategy is: take the smallest buffer which can hold desired memory without growing; if it doesn't exist, take just the smallest buffer to maximize the ability of other parts to re-use other buffers.

Essentially re-allocating the buffer should be avoided at all costs to minimize the work for GC IMHO. They're all small enough to not cause significant memory consumption compared to pre-rendered cache later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants