kenygia / xy-vsfilter

Automatically exported from code.google.com/p/xy-vsfilter fork:xy-vsfilter-2015-05-04-rc
GNU General Public License v2.0
0 stars 0 forks source link

Rendering fonts with extremely complex TrueType outlines causes lag #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm sorry, if the title isn't very descriptive.
I just didn't know how to describe the problem briefly, as I don't really know 
the cause of the problem itself.

Right before the subtitle line appears (link to the video provided below), the 
video lags for a very short time.

I checked the subtitle Karaoke effect, and noticed that each subtitle line is 
made of about 30 distinct entries, but since only 2 entries are active at the 
same time, it seems unlikely that the lag is caused by rendering all these 30 
entries at the same time.

The video itself doesn't lag.
When "No Subtitle" is selected, or when the subtitle is removed from the video, 
the lags do not occur.

Interestingly, the lags also don't occur, when the "Hide Subtitles" option is 
checked.
It's possible, that the lag isn't caused by the rendering process itself.

Also noteworthy is, that if the fonts included in the video are removed, the 
lags also do NOT occur.
This implies, that the lag may be caused when loading the fonts from the 
container.
On a related note, the same video without the Karaoke effects (only the text) 
does NOT lag.
I assume that the lags are caused, because xy-vsfilter tries to load the same 
fonts 30 times over a very short period of time from within the container.
This is odd, however, because xy-vsfilter should be loading the fonts when 
"Hide Subtitles" is active as well, shouldn't it?

The lags mentioned above have been experienced while viewing this video (size: 
147 MB | duration: 00:01:35): http://www.mediafire.com/?yqcac1ayqy0uyoa
on Windows 7 Professional (64 bit)
with the newest stable release of xy-vsfilter (2011_12_26), though older 
releases may have the same lagging issue.
I had L1 and L2 Cache set to 1024 and L3 and L4 Cache to 512.
Increasing all Caches to 2048 didn't change anything.
By the way: What is the unit for the Cache? kB?

The video provided with the mediafire link contains everything required to 
reproduce the lags (video, audio, subtitle and fonts)

This may be useful (or it may not be):
The Karaoke effect is made of 2 subtitle lines, one for the lyrics and one for 
the english translation. Both lines use a different font.
The line for the lyrics is made of about 29 extremely short entries, all using 
the same design but with a different position (and with a length of less than 1 
second) to simulate a flickering effect.

Don't worry if the audio or video seems to have artifacts.
The artifacts are intentional and already present in the original.

If more information is required, I'll do my best to provide them.

Original issue reported on code.google.com by Nolo...@gmail.com on 3 Jan 2012 at 8:06

GoogleCodeExporter commented 9 years ago
The good news is that xy-VSFilter around 2x faster than VSFilter 2.40 with the 
sample.

The bad news is there is still indeed a lag, which appears to be caused by 
rendering the extremely complex TrueType outlines of those fonts. Even 
previewing those fonts in Windows caused around a second of lag. 

I suspect something like a font cache would help, but even libass w/ it's font 
cache seems to lag on the very first line when the fonts are initially loaded. 
As of right now, YuZhuoHuang his no current plans implement a font cache, see 
Issue #39 , but I've forwarded your sample to him. Maybe the outline cache 
could be tweaked, who knows.

Workaround:

Use a video renderer like EVR-CP or madVR which can buffer frames.

With EVR-CP setting the EVR Buffers to 12 frames in MPC-HC seems to hide the 
lagging effects.

With madVR, setting CPU Queue somewhere between 24 to 32 should hide the 
lagging effects.

Depending on your system speed, you may need to tweak these numbers to fine the 
optimal values.

> By the way: What is the unit for the Cache? kB?

It's the number of cache entries allowed. Amount of memory used by each cache 
entry will vary based on what is being stored in the cache. The default values 
should be fine for most people, unless you are working with complex karaoke 
scripts made up of tens of thousands of lines. With the caches, a little goes a 
long ways. When you increase the caches values, memory load will increase, so 
it's not recommended to use really high values unless you notice a positive 
effect from doing so.

Original comment by cyber.sp...@gmail.com on 4 Jan 2012 at 4:38