Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 21st March 2016, 14:49   #1  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
minsharp

so I just wrote my very first plugin, like, a simple one that can do a simple 3x3 blurring (linear or non-linear) or sharpening, designed for easy use

https://github.com/IFeelBloated/minsrp
binary: https://github.com/IFeelBloated/minsrp/releases/tag/r4

supported formats:
colorspace: YUV 4:4:4, Gray or RGB, subsampled stuff are not supported
bitdepth: 8-16bits fixed point, 32bits floating point, half precision is not supported
interlaced vids are not supported

parameters:
str, array that takes up to 3 elements, filtering strength of each plane, positive value = sharpening, negative value = blurring, default = 1.0

mode, filtering mode for each plane,
0 = no filtering
1 = gaussian filter (linear)
2 = median filter (non-linear)
3 = hybrid, picking the result of either gaussian or median, whichever has the smaller difference compared to the input clip
default = 3

sigh, python scripting is 100000000 times easier than c++ filter writing..

LOG:
r4:
speed boost yet again, did some insane and incomprehensible opts, the expensive cost of frequent memory allocation is now gone.
r3:
code opt, speed boost
r2:
new parameter linear, linearity of sharpening amplification for each plane
default = False
r1 amplifies the sharpening/blurring difference linearly, and just looks dumb to me, the cheesy algorithm tends to over sharpen/blur stuff like.. whatever
with linear = False, sharpening/blurring gets much smarter, it only filters where actually needs filtering with variable strength.
set linear=True if you wanna linear amplification.

non-linear amplification algorithm (shamelessly) copied from http://forum.doom9.org/showthread.ph...17#post1547017

Last edited by feisty2; 30th March 2016 at 16:43.
feisty2 is offline   Reply With Quote
Old 24th March 2016, 16:40   #2  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
r2:
new parameter linear, linearity of sharpening amplification for each plane
default = False
r1 amplifies the sharpening/blurring difference linearly, and just looks dumb to me, the cheesy algorithm tends to over sharpen/blur stuff like.. whatever
with linear = False, sharpening/blurring gets much smarter, it only filters where actually needs filtering with variable strength.
set linear=True if you wanna linear amplification.

non-linear amplification algorithm (shamelessly) copied from http://forum.doom9.org/showthread.ph...17#post1547017

Last edited by feisty2; 24th March 2016 at 16:49.
feisty2 is offline   Reply With Quote
Old 24th March 2016, 17:37   #3  |  Link
Myrsloik
Professional Code Monkey
 
Myrsloik's Avatar
 
Join Date: Jun 2003
Location: Kinnarps Chair
Posts: 2,548
Since you asked in the other thread. You code is basically written in the simplest way possible which is horrible for cpus to actually execute. All those small loads every pixel quickly adds up. You're also creating and destroying a vector every pixel. That also adds up.

For example:
https://github.com/IFeelBloated/mins...Kernel.hpp#L92

You should use a fixed size 9 element array here. std::vector is just slow if you have a small fixed size allocation.

The rest mostly comes down to the fact that you're doing many small loads. That's costly. For example see the recreated removegrains for examples on how to do things in a speedier way:
https://github.com/vapoursynth/vapou...rainvs.cpp#L39

That code is a bit convoluted with macros and stuff but hopefully you'll get the idea.
__________________
VapourSynth - proving that scripting languages and video processing isn't dead yet
Myrsloik is offline   Reply With Quote
Old 27th March 2016, 07:33   #4  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
r3:
code opt, speed boost
A LOT faster now, I don't wanna see vector like no more
feisty2 is offline   Reply With Quote
Old 27th March 2016, 14:03   #5  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
r2: ~70fps at 640x480 GrayS on i7-4790k
r3: ~230fps at 640x480 GrayS on i7-4790k
feisty2 is offline   Reply With Quote
Old 30th March 2016, 16:36   #6  |  Link
feisty2
I'm Siri
 
feisty2's Avatar
 
Join Date: Oct 2012
Location: void
Posts: 2,633
r4: speed boost yet again, did some insane and incomprehensible opts, the expensive cost of frequent memory allocation is now gone.

Last edited by feisty2; 30th March 2016 at 16:42.
feisty2 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 21:45.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.