Log in

View Full Version : LSFmod [v1.9 - Update 2009/10/05]


Pages : 1 2 3 4 [5]

Budtz
18th January 2014, 18:17
I Use this sharpening algorithem. I use at script that includes the line :"ffdshow_source()". my understanding is that checking "Add ffdshow video source" does the same thing as this line in the script.

what would happen if i include the line as well as check "Add ffdshow video source" at the same time? seems this is more stable wich is strange.

Do these two acually do the same thing? if so why not just have one of them?

MysteryX
3rd July 2015, 14:47
I tried adding LSFmod sharpening to my script and am getting horribly slow performance. With AviSynth 2.6 MT, with 4 threads, CPU runs at 14%, and with 8 threads, CPU runs at 28%. Then there are also periods where CPU runs properly at 90-100%. What is causing this performance problem and how can I solve this?

I'm using the 2.6 version of MaskTools2 here, is this the right version?
http://avisynth.nl/index.php/MaskTools2

SetMTMode(3,0)
PluginPath = "C:\GitHub\NaturalGroundingPlayer\NaturalGroundingPlayer\bin\Debug\Encoder\"
AviSource("F:\NaturalGrounding\Temp\Preview.avi", audio=false, pixel_type="YV12")
SetMTMode(2)
LoadPlugin(PluginPath+"ColorMatrix.dll")
ColorMatrix(mode="Rec.601->Rec.709")
Crop(0, 0, -10, -0)
LoadPlugin(PluginPath+"FFT3DFilter.dll")
fft3dfilter(sigma=3, bt=5, bw=48, bh=48, ow=24, oh=24, sharpen=0.1, ncpu=8)
LoadPlugin(PluginPath+"masktools2.dll")
LoadPlugin(PluginPath+"RgTools.dll")
Import(PluginPath+"LSFmod.avsi")
LoadPlugin(PluginPath+"nnedi3.dll")
LoadPlugin(PluginPath+"eedi3.dll")
eedi3_rpow2 (2)
LSFmod(strength=10, defaults="slow")
nnedi3_rpow2 (2)
Spline36Resize(940, 720, 0, 4, -0, -4)
LoadPlugin(PluginPath+"svpflow1.dll")
LoadPlugin(PluginPath+"svpflow2.dll")
Import(PluginPath+"InterFrame2.avsi")
InterFrame(Cores=8, Tuning="Smooth", NewNum=60000, NewDen=1001, GPU=true)
LSFmod(strength=30, defaults="slow")
Distributor()

Groucho2004
3rd July 2015, 15:49
I tried adding LSFmod sharpening to my script and am getting horribly slow performance. With AviSynth 2.6 MT, with 4 threads, CPU runs at 14%, and with 8 threads, CPU runs at 28%. Then there are also periods where CPU runs properly at 90-100%. What is causing this performance problem and how can I solve this?

I'm using the 2.6 version of MaskTools2 here, is this the right version?
http://avisynth.nl/index.php/MaskTools2

Just gave that script a go with a SD (720 x 400) source, (non-MT AVS):
Without the 2 LSFMod calls:
[Runtime info]
Frames processed: 238 (0 - 237)
FPS (min | max | average): 1.335 | 66288 | 5.887
Memory usage (phys | virt): 511 | 556 MB
Thread count: 38
CPU usage (average): 81%
Time (elapsed): 00:00:40.426


With the 2 LSFMod calls:
[Runtime info]
Frames processed: 238 (0 - 237)
FPS (min | max | average): 0.854 | 132.5 | 4.669
Memory usage (phys | virt): 662 | 708 MB
Thread count: 38
CPU usage (average): 68%
Time (elapsed): 00:00:50.970


Look at the CPU utilization, you don't need AVS MT. The main CPU hogs are eedi3 and nnedi3 which are already internally multi-threaded.

Multi-threading internally multi-threaded filters and putting "Distributor()" at the end probably creates a few hundred threads which makes the whole setup very inefficient and consumes lots of memory (most likely too much for a 32 Bit address space).

Use AVSMeter from my signature to test your script. Start with a single threaded setup and add filters one by one.

I won't comment on how much sense that script makes, I find it rather bizarre how you're mixing filters but that's just me.

Edit - The script I used for this test:
ColorMatrix(mode="Rec.601->Rec.709")
Crop(0, 0, -10, -0)
fft3dfilter(sigma=3, bt=5, bw=48, bh=48, ow=24, oh=24, sharpen=0.1, ncpu=8)
eedi3_rpow2 (2)
LSFmod(strength=10, defaults="slow")
nnedi3_rpow2 (2)
Spline36Resize(940, 720, 0, 4, -0, -4)
InterFrame(Cores=1, Tuning="Smooth", NewNum=60000, NewDen=1001, GPU=true)
LSFmod(strength=30, defaults="slow")

Nevilne
3rd July 2015, 15:51
maybe he wants to warm up his room

MysteryX
3rd July 2015, 19:32
Hah! With 8 threads, it's actually running 684 threads (in Windows Task Manager).

As for how much sense the script makes, it does give a great output.

Source video (288p VCD) (https://www.spiritualselftransformation.com/files/media-encoder-old.mpg)
Output (720p) (https://www.spiritualselftransformation.com/files/media-encoder-new.mkv)
(this is without LSFmod)

Groucho2004
3rd July 2015, 19:41
Hah! With 8 threads, it's actually running 684 threads (in Windows Task Manager).
I rest my case. :D

MysteryX
3rd July 2015, 20:41
I rest my case. :D
Yet, without MT, it runs at about 60% CPU.

If I set MT to 2 threads and for filters taking CPU argument, set it to 1, I get this message repeating in the console.
Cache::getFrame: dgb1

Setting MT to 2 threads and CPU parameters to 2 runs at 70-80% with 94 threads.

Setting MT and CPU parameters to 4 works fine CPU 95-100% with 226 threads.

Replacing FF3DFilter sharpening with LSFmod, however, lowers CPU usage to 65-70%.

Groucho2004
3rd July 2015, 21:34
If I set MT to 2 threads and for filters taking CPU argument, set it to 1, I get this message repeating in the console.
Cache::getFrame: dgb1
Yes, I had the same problem when I tried your script with MT. I gave up on it because of this and, more importantly, it was still slower than single threaded Avisynth.

Setting MT to 2 threads and CPU parameters to 2 runs at 70-80% with 94 threads.

Setting MT and CPU parameters to 4 works fine CPU 95-100% with 226 threads.
It's a common misconception that high CPU usage equals high performance. I assure you, in your examples you're just producing heat.

Use AVSMeter and compare the speed.

MysteryX
3rd July 2015, 22:07
For my standard script, I'm getting 6.8fps with MT=4 and 5.4 with MT off.

If I instead use LSFmod, I get 6.0fps with MT=4 and 5.6 with MT off.

And from what I've seen, if I keep it running, there will be LONG phases where it runs on a single core and leave CPU usage at 14%. The script won't be done after a whole night.

MysteryX
4th July 2015, 09:37
OK I did further testing with AVSMeter. The errors were being thrown by InterFrame. The CPU argument must be the same as the MT thread count for it to work best. As for FF3DFilter, its CPU count must also be set to that same value for optimal performance. Otherwise it probably creates a bottleneck on whichever filter has the lowest thread count.

With all thread values set to 2, I get nearly the same performance as with all values set to 3 in terms of fps, but with 10% lower CPU usage! That's gives 94 threads. CPU usage is then only 75% but x264.exe further brings it up. I'm encoding a file right now and the CPU runs between 80-100%. That's good.

But that's without LSFmod. Whenever I add LSFmod into the mix, it creates a bottleneck.

Groucho2004
4th July 2015, 10:14
The errors were being thrown by InterFrame.
Yes, it's one of the svpflow*.dll plugins. Instead using "ThrowError()" in the plugin so a client application could catch and handle it, the developer decided to print the error directly to the console. It may not even be an error, maybe just some leftover debug code.

MysteryX
4th July 2015, 20:15
AVSMeter crashes on this script :)

PluginPath = "C:\GitHub\NaturalGroundingPlayer\NaturalGroundingPlayer\bin\Debug\Encoder\"
AviSource("F:\NaturalGrounding\Temp\Preview.avi", audio=false, pixel_type="YV12")
LoadPlugin(PluginPath+"eedi3.dll")
eedi3_rpow2 (2)
Spline36Resize(768, 576)


I've done more testing. EEDI3 has good internal multi-threading, and what works best is MT with 2 threads when using EEDI3. Perhaps EEDI3 alone would even work best on a single thread.

When using NNEDI3(2) or NNEDI3(4), however, it still benefits from 8 threads. The full script with NNEDI(4) runs at
- MT=1: 14.7fps with 46 threads and 16% CPU usage
- MT=4: 21.0fps with 160 threads and 54% CPU usage
- MT=6: 21.0fps with 259 threads and 56% CPU usage
- MT=8: 22.5fps with 352 threads and 64% CPU usage

LSFmod without the slow preset isn't as much of a bottleneck. Still, setting high values seems to make the image look much more artificial than when setting high values with FF3DFilter.

Groucho2004
4th July 2015, 21:15
AVSMeter crashes on this script :)
Define crash. No error message? What happens when you load the script in VirtualDub?

MysteryX
4th July 2015, 21:28
"AVSMeter - AviSynth Script Testing has stopped working. Windows can check online for a solution to the problem."

The script plays fine in MPC-HC

Yes, it's one of the svpflow*.dll plugins. Instead using "ThrowError()" in the plugin so a client application could catch and handle it, the developer decided to print the error directly to the console. It may not even be an error, maybe just some leftover debug code.
He said it's forgotten debug code.

Groucho2004
4th July 2015, 21:52
"AVSMeter - AviSynth Script Testing has stopped working. Windows can check online for a solution to the problem."
I think it's some race condition in eedi3's OpenMP code. It doesn't crash when you set "threads = 1" in the eedi3 call.

MysteryX
5th July 2015, 02:57
WOW! You're a genius. Setting Threads=1 on EEDI3 and NNEDI3, with 16 cores, almost doubles the overall performance!! Just got to test what is the optimal amount of cores to use.

12 cores gives 11fps with 207 threads and 62% CPU.

16 cores gives 13fps with 339 threads and 83% CPU.

That's compared to the 6fps I was previously getting.

16 cores by replacing 2x FF3DFilter with 2x LSFmod (without slow preset) gives 8.3fps with 338 threads and 64% CPU. It still causes a bottleneck.

The script that took 1h10 on last run is now running in 30 minutes. BUT, memory usage is 1710MB... getting dangerously close to 2GB.

Groucho2004
5th July 2015, 07:43
Setting Threads=1 on EEDI3 and NNEDI3, with 16 cores, almost doubles the overall performance!! Just got to test what is the optimal amount of cores to use.
I thought I covered that in my first reply to you (although I did not explicitly tell you to add "threads = 1" to these two filters):
Multi-threading internally multi-threaded filters and putting "Distributor()" at the end probably creates a few hundred threads which makes the whole setup very inefficient and consumes lots of memory (most likely too much for a 32 Bit address space).

BUT, memory usage is 1710MB... getting dangerously close to 2GB.
On 64 bit Windows you have up to 4GB for Avisynth. You can pipe the script to x264.
Have a look at this thread (http://forum.doom9.org/showthread.php?t=172300), the guy had very similar problems.

MysteryX
5th July 2015, 18:18
I didn't know about the Treads parameter of EEDI3/NNEDI3. So you're saying avs2yuv.exe is required to access up to 4GB? Otherwise what is the limit, 2GB?

Unfortunately the script froze in the middle with 25% CPU usage and it never completed after the whole night. Not sure if it's because of too high memory usage or what.

Setting 8 threads for MT, 4 for EEDI3 and 2 for NNEDI3 gives me 9.4fps with 281 threads and 83% CPU usage. Not the 13fps, but perhaps this one won't freeze.

Could the memory usage getting too high have caused that freeze?

Edit: Oh! I can use the 64-bit version of x264!! This will bring an additional performance bonus.

MysteryX
5th July 2015, 18:58
I'm getting this error with Avs2YUV
raw [error]: raw input requires a resolution.

Here's my command
avs2yuv.exe "Job1_Script.avs" -o - | x264-64bit.exe - --preset veryslow --crf 24 -o "Job1_Output.264"

Groucho2004
5th July 2015, 19:01
So you're saying avs2yuv.exe is required to access up to 4GB?No. Piping the script to the encoder means that Avisynth and x264 have their own address space of 4GB each (64 Bit x264 could obviously address much more memory).

You can feed the script directly to x264 but then Avisynth and x264 have to share an address space of 4GB.

Note that the above scenarios only apply 64 Bit OS and applications that were built with the LARGE_ADDRESS_AWARE linker flag, i.e. avs2yuv.
On 32 Bit Windows the user address space is limited to 2 GB. There are ways around that as well but this is not really relevant.

Unfortunately the script froze in the middle with 25% CPU usage and it never completed after the whole night. Not sure if it's because of too high memory usage or what.

Setting 8 threads for MT, 4 for EEDI3 and 2 for NNEDI3 gives me 9.4fps with 281 threads and 83% CPU usage. Not the 13fps, but perhaps this one won't freeze.

Could the memory usage getting too high have caused that freeze?
Yes. You can also try to play with SetMemoryMax().

Groucho2004
5th July 2015, 19:03
I'm getting this error with Avs2YUV
raw [error]: raw input requires a resolution.

Here's my command
avs2yuv.exe "Job1_Script.avs" -o - | x264-64bit.exe - --preset veryslow --crf 24 -o "Job1_Output.264"
The command line is not complete. The de-muxer has to be specified (--demuxer y4m).

MysteryX
5th July 2015, 20:37
Piping seems to considerably lower the performance, nullifying any advantage of switching to the 64-bit x264. I also lose the estimated time left as it doesn't know the total amount of frames.

Is the SetMemoryMax command necessary? Not sure what to set it to. It seems to lower the performance when I specify it.

It seems to work best when I use symmetrical thread values: 1, 2, 4, 8 or 16. Whenever I start using values like 3 or 6, I get lower performance.

I'll try with MT=8, EEDI3 with 4 threads and NNEDI3 with 4 threads. It seems to be what works best. While encoding with x264, I get 6.3fps, 326 threads, 1374MB memory and CPU between 95-100%.

Groucho2004
5th July 2015, 21:37
Piping seems to considerably lower the performance, nullifying any advantage of switching to the 64-bit x264.
When you pipe with avs2yuv, you have to put the Distributor() call at the end of the script.

I also lose the estimated time left as it doesn't know the total amount of frames.
You have to specify the number of frames on the x264 command line.

Is the SetMemoryMax command necessary? Not sure what to set it to. It seems to lower the performance when I specify it.
Anything between 600 and 3000. It's trial and error with AVS MT.


You should start reading the documentation of the tools you use. Spoon-feeding you all the information becomes tiresome.

MysteryX
5th July 2015, 21:49
When you pipe with avs2yuv, you have to put the Distributor() call at the end of the script.
It's there.

Edit: OK after doing more tests, performance may be the same after all. Found a way to hack around and extract the total frames count to pass it to x264. It's a hack but it works.

Edit2: After running the script, it still freezes at some point with 25-30% CPU usage. It's not because of memory usage.

SubJunk
30th May 2016, 07:44
Using soothe=false fixed the crashing for me

sys32768
12th February 2019, 20:55
I cannot seem to get any results from this mod. I can get it to run but cannot get a before/after result. Can someone using it please tell me the version of AVISYNTH/VDUB and plugins you're using to I can mimic it?

manolito
13th February 2019, 11:12
Here is an All-In-One package of LSFMod 1.9 which works for me under AVS 2.60 (or 2.61 Alpha) and the latest AVS+ 32-bit. Extract all files from the archive into the "Avisynth\Plugins" folder.

https://www.sendspace.com/file/dp73mb

Cheers
manolito

LeXXuz
4th July 2020, 12:04
Just out of curiousity.
What are the screenW and screenH parameters for?
And why are the (always?) set to 1280 by 1024 :confused:

StainlessS
4th July 2020, 14:39
Just out of curiousity.
What are the screenW and screenH parameters for?
And why are the (always?) set to 1280 by 1024 :confused:


### +-------+
### | DEBUG |
### +-------+
###
### show [bool]
### -----------
### Show debug clip & informations
###
### screenW ; screenH [int]
### -----------------------
### Screen resolution (for show clip)


Affects only debug, show info mode.

LeXXuz
14th July 2020, 12:52
Aw... man I should've guessed. :D Thanks StainlessS. :)

Treaties Of Warp
25th July 2020, 04:47
BUMP!

At some point, Smethod=5 was removed from LSFmod.avsi (http://latoninf.free.fr/d9/LM/LSFmod.v1.9.avsi):


449 Assert( ( Smethod >= 1 && Smethod <= 4 ) ? true : false, chr(10) + "'Smethod' have not a correct value! [1,2,3,4]" + chr(10))


According to the AviSynth Wiki (http://avisynth.nl/index.php/LSFmod#Syntax_and_Parameters), these should be the values for Smethod:


int Smethod = 2

Sharpening method: (not used for Smode=1&2)

1 : 3x3 Kernel
2 : Min/Max (original)
3 : Min/Max (enhanced)
4 : Min/Max (original) + 3x3 Kernel
5 : Min/Max (enhanced) + 3x3 Kernel

Are these Smethods still the same? Is it correct that Smethod=5 should be removed?

kuchikirukia
1st January 2022, 09:05
Should LSFMod really upscale by default for antialiasing? It introduces blurring, which seems to defeat the purpose.
If you're sharpening so much that it's aliasing, then you could set the supersampling. But it doesn't seem like such a lossy operation should be the default.

coolgit
20th October 2022, 23:12
Script error: Invalid arguments to function 'LSFM_Show'.
\StaxRip-v2.13.0-x64\Apps\Plugins\AVS\LSFmod\LSFmod.avsi, line 746)

FranceBB
21st October 2022, 11:00
Script error: Invalid arguments to function 'LSFM_Show'.
\StaxRip-v2.13.0-x64\Apps\Plugins\AVS\LSFmod\LSFmod.avsi, line 746)

we're gonna need a bit more info than that...

kedautinh12
21st October 2022, 11:44
You can try LSFplus
https://github.com/Dogway/Avisynth-Scripts/blob/master/MIX%20mods/LSFplus.avsi

Depen:
https://github.com/Dogway/Avisynth-Scripts/blob/1ee0b658c7532cd9189c73c7f9904d8dafe31f6f/MIX%20mods/LSFplus.avsi#L214

coolgit
21st October 2022, 13:55
we're gonna need a bit more info than that...

It happens when show=true.

Dogway
21st October 2022, 16:56
Change "int "undershoot2"" to "float "undershoot2"" in LSFM_Show()

coolgit
21st October 2022, 17:20
Change "int "undershoot2"" to "float "undershoot2"" in LSFM_Show()

That worked, thanks.

FranceBB
21st October 2022, 18:28
Thanks Dogway, as always! :)
We reported it to the maintainer on GitHub (https://github.com/realfinder/AVS-Stuff/issues/165) too, including your fix. ;)