Log in

View Full Version : Avisynth+


Pages : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 [38] 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112

pinterf
27th June 2016, 15:08
The VDub destructor bug isn't so easy to fix; but shouldn't be hard for someone who understands the code better.


// VDubFilter.cpp
void CallEndProc() {
if (fd->endProc) {
int result = fd->endProc(&fa, &g_filterFuncs);
if (result != 0) {
throw AvisynthError("VirtualdubFilterProxy: error calling endProc");
}
}
}


Basically, Deshaker's EndProc is trying to access "something" within fa that is no longer accessible at that time.

Commenting both of these lines does solve the problem, but I doubt it is the right fix

// in FilterAdd
fm->env->AtExit(FreeFilterDefinition, fd);

// in LoadVirtualdubPlugin
env->AtExit(FreeFilterModule, fm);


The destructor needs to be called before these 2 functions.

I'll let you fix it before I start adding a "release timer" to fix the sequence :)
Did you checked the last commit? It is not yet in the last pfmod release, there were changes integrated from classic avs regarding "Fix VDub plugin race on cleanup"

MysteryX
27th June 2016, 15:10
Pinterf, I took your branch.

The destruction sequence is the problem. This is something to be very careful about so it's better if I don't touch it; it touches the core of AVS and will affect every plugin.


ScriptEnvironment::~ScriptEnvironment() {

closing = true;

// Before we start to pull the world apart
// give every one their last wish.
at_exit.Execute(this);


Here it wants to execute these functions before pulling the world apart, and with VDubFilter we must call the destructor before calling these functions.

MysteryX
27th June 2016, 15:17
Did you checked the last commit? It is not yet in the last pfmod release, there were changes integrated from classic avs regarding "Fix VDub plugin race on cleanup"
I see, I forgot to manually select the right branch after downloading the code.

Now it compiles fine right away. The VDub bug is still the same. Good luck Pinterf.

pinterf
27th June 2016, 21:16
Let's look at this silly code fragment
lsmashvideosource(film, stacked=true, format="YUV444P16")
# Open Prores422 10 bit as YUV444P16
ConvertStackedToNative()
Spline64Resize(400,300)
Crop(9,7,-9,-7)
FlipHorizontal().FlipVertical()
TurnLeft().TurnRight().Turn180()
PointResize(3200,2400)
GrayScale()
BilinearResize(1600,1200)
ConvertNativeToStacked()
source1=last
...

Nothing special, we are in 2016, UHD era, with 14-16 bit linear uncompressed raw in cameras. I was a bit surprized when this very basic 16 bit workflow started to work on my bench. Funny last minute techdemo from Avisynth. A kind of Second Reality :)
For everything else there's DitherTools.

Chikuzen
27th June 2016, 22:51
lsmashvideosource(film, stacked=false, format="YUV444P16")
# Open Prores422 10 bit as YUV444P16
Spline64Resize(400,300)
...


Why do you take a side trip and waste your time?
You can open the source as NativeFormat:p

LigH
27th June 2016, 22:52
A kind of Second Reality :)

You might know that Smash Designs created a C=64 version of the Future Crew PC VGA demo. Maybe that's how we used to feel with only 8 bits per component... ;)

real.finder
27th June 2016, 23:04
lsmashvideosource(film, stacked=false, format="YUV444P16", dr=true)
# Open Prores422 10 bit as YUV444P16
Spline64Resize(400,300)
...


Why do you take a side trip and waste your time?
You can open the source as NativeFormat:p

We discussed this in #avs-plus@irc.rizon.net

Currently lsmashvideosource without stacked will out in interleavexbit not in NativeFormat, so this will need something like ConvertInterleaved16ToNative() and ConvertNativeToInterleaved16()

Interleaved16 will be like the clip that out from dither_out()

more clearly details in flash3kyuu_deband.txt, input_mode and output_mode and stacked bool in f3kdb_dither

MysteryX
28th June 2016, 03:33
VDub destructor crash fixed

Fixed crash on exit due to FreeFilterModule being called before VirtualdubFilterProxy's destructor

diff --git a/plugins/VDubFilter/VDubFilter.cpp b/plugins/VDubFilter/VDubFilter.cpp
index df512ee..7d97fef 100644
--- a/plugins/VDubFilter/VDubFilter.cpp
+++ b/plugins/VDubFilter/VDubFilter.cpp
@@ -365,10 +365,11 @@ typedef struct FilterDefinition {

class FilterDefinitionList {
public:
+ FilterModule* fm;
FilterDefinition* fd;
FilterDefinitionList* fdl;

- FilterDefinitionList(FilterModule* fm, FilterDefinition* _fd) : fd(_fd), fdl(fm->fdl) { };
+ FilterDefinitionList(FilterModule* _fm, FilterDefinition* _fd) : fm(_fm), fd(_fd), fdl(fm->fdl) { };
};

//////////
@@ -575,6 +576,7 @@ public:
class VirtualdubFilterProxy : public GenericVideoFilter {
PVideoFrame src, dst, last;
VFBitmap vbSrc, vbDst, vbLast;
+ FilterDefinitionList* const fdl;
FilterDefinition* const fd;
FilterStateInfo fsi;
FilterActivation fa;
@@ -602,9 +604,11 @@ class VirtualdubFilterProxy : public GenericVideoFilter {
}

public:
- VirtualdubFilterProxy(PClip _child, FilterDefinition* _fd, AVSValue args, IScriptEnvironment* env)
- : GenericVideoFilter(_child), fd(_fd), fa(vbDst, vbSrc, &vbLast)
+ VirtualdubFilterProxy(PClip _child, FilterDefinitionList* _fdl, AVSValue args, IScriptEnvironment* env)
+ : GenericVideoFilter(_child), fdl(_fdl), fd(_fdl->fd), fa(vbDst, vbSrc, &vbLast)
{
+ if (!fd)
+ env->ThrowError("VirtualdubFilterProxy: No FilterDefinition structure!");
if (!vi.IsRGB32())
throw AvisynthError("VirtualdubFilterProxy: only RGB32 supported for VirtualDub filters");

@@ -763,16 +767,29 @@ public:

~VirtualdubFilterProxy() {
CallEndProc();
+ FreeFilterModule(fdl->fm);
if (vbSrc.hdc)
ReleaseDC(NULL, vbSrc.hdc);
}

+ void __cdecl FreeFilterModule(FilterModule* fm) {
+ for (FilterDefinitionList* fdl = fm->fdl; fdl; fdl = fdl->fdl) {
+ delete fdl->fd;
+ fdl->fd = 0;
+ }
+
+ fm->deinitProc(fm, &g_filterFuncs);
+ FreeLibrary(fm->hInstModule);
+ if (fm->prev)
+ fm->prev->next = fm->next;
+ if (fm->next)
+ fm->next->prev = fm->prev;
+ delete fm;
+ }
+
static AVSValue __cdecl Create(AVSValue args, void* user_data, IScriptEnvironment* env) {
FilterDefinitionList* fdl = (FilterDefinitionList*)user_data;
-
- if (!fdl->fd) env->ThrowError("VirtualdubFilterProxy: No FilterDefinition structure!");
-
- return new VirtualdubFilterProxy(args[0].AsClip(), fdl->fd, args, env);
+ return new VirtualdubFilterProxy(args[0].AsClip(), fdl, args, env);
}
};

@@ -803,24 +820,6 @@ FilterDefinition *VDcall FilterAdd(FilterModule *fm, FilterDefinition *pfd, int
}


-void __cdecl FreeFilterModule(void* user_data, IScriptEnvironment* env) {
- FilterModule* fm = (FilterModule*)user_data;
-
- for (FilterDefinitionList* fdl = fm->fdl; fdl; fdl = fdl->fdl) {
- delete fdl->fd;
- fdl->fd = 0;
- }
-
- fm->deinitProc(fm, &g_filterFuncs);
- FreeLibrary(fm->hInstModule);
- if (fm->prev)
- fm->prev->next = fm->next;
- if (fm->next)
- fm->next->prev = fm->prev;
- delete fm;
-}
-
-
AVSValue __cdecl LoadVirtualdubPlugin(AVSValue args, void*, IScriptEnvironment* env) {
const char* const szModule = args[0].AsString();
const char* const avisynth_function_name = args[1].AsString();
@@ -879,7 +878,6 @@ AVSValue __cdecl LoadVirtualdubPlugin(AVSValue args, void*, IScriptEnvironment*
fm->next->prev = fm;

env->SetGlobalVar("$LoadVirtualdubPlugin$", (const char*)fm);
- env->AtExit(FreeFilterModule, fm);

return AVSValue();
}


Git isn't allowing me to push the changes; is there something I'm doing wrong or you just have to add those changes yourself?

git.exe push -v --progress "origin" master:MT-pfmod

remote: Permission to pinterf/AviSynthPlus.git denied to mysteryx93.
fatal: unable to access 'https://github.com/pinterf/AviSynthPlus.git/': The requested URL returned error: 403
Pushing to https://github.com/pinterf/AviSynthPlus.git

qyot27
28th June 2016, 05:41
Git isn't allowing me to push the changes; is there something I'm doing wrong or you just have to add those changes yourself?

git.exe push -v --progress "origin" master:MT-pfmod

remote: Permission to pinterf/AviSynthPlus.git denied to mysteryx93.
fatal: unable to access 'https://github.com/pinterf/AviSynthPlus.git/': The requested URL returned error: 403
Pushing to https://github.com/pinterf/AviSynthPlus.git

You have to have your own account on Github, use Github's tools* to spawn your own AviSynthPlus repo, and then push up to your own account. You can then open a pull request through Github to have the change integrated.

*well, technically you don't need to use Github's tools to do it so long as the SSH remotes are correct and you've authenticated your keys on your Github account, but it won't show up on the Network graph.

MysteryX
28th June 2016, 06:20
You have to have your own account on Github, use Github's tools* to spawn your own AviSynthPlus repo, and then push up to your own account. You can then open a pull request through Github to have the change integrated.

*well, technically you don't need to use Github's tools to do it so long as the SSH remotes are correct and you've authenticated your keys on your Github account, but it won't show up on the Network graph.
OK I created a new Fork into my account, but MT-pfmod doesn't show up in the list of branches

qyot27
28th June 2016, 06:44
OK I created a new Fork into my account, but MT-pfmod doesn't show up in the list of branches
This is where git's remotes come in:
git remote add pinterf git://github.com/pinterf/AviSynthPlus.git
git fetch pinterf
git checkout MT-pfmod (or git checkout -b MT-pfmod pinterf/MT-pfmod if it doesn't let you do it with just the branch name)

tormento
28th June 2016, 08:12
@pinterf

So, it is a bug of AVS+ you will fix or a bug of the script that appears in AVS+ only? :)

jpsdr
28th June 2016, 08:37
VDub destructor crash fixed
....


I hope Wilbert follow this thread, because maybe this issue is also in standard avisynth 2.6, and this fix should also be include within.

MysteryX
28th June 2016, 08:42
This is where git's remotes come in:
git remote add pinterf git://github.com/pinterf/AviSynthPlus.git
git fetch pinterf
git checkout MT-pfmod (or git checkout -b MT-pfmod pinterf/MT-pfmod if it doesn't let you do it with just the branch name)
Ah! After toying around with it, I finally got it. There you go Pinterf, you can merge the changes with a single click :)

Wilbert
28th June 2016, 12:32
Here's another bug. I tried using Deshaker.
http://www.guthspot.se/video/deshaker.htm

Here's a script that will run the first pass and generate a log file to be used for the second pass.

P="Encoder\"
LoadVirtualDubPlugin(P+"deshaker.vdf", "deshaker", preroll=0)
LoadPlugin(P+"LSMASHSource.dll")
file="Source.MOV"
LWLibavVideoSource(file, cache=True)
ConvertToRGB32()
deshaker("19|1|30|4|1|0|1|0|640|640|1|2|1000|1000|1000|1000|4|1|3|2|8|30|300|4|Preview_Deshaker.log|0|0|0|0|0|0|0|0|0|0|0|0|0|1|15|15|5|15|0|0|30|30|0|0|0|0|1|0|0|10|1000|1|88|1|1|20|5000|100|20|1|0")
PointResize(8,8)


To run the second pass, re-insert the deshaker line in your full script wherever you want and change the 2nd argument from 1 to 2 to run the 2nd pass from that log file.

With AviSynth 2.6 it works fine. With AviSynth+, I get a crash in the destructor. Whenever I close the preview I get a crash.

Deshaker doesn't seem to work with MT but a single thread tops all 8 CPU cores anyway.
Could you give a link to an AviSynth+ version where this results in a crash?

MysteryX
28th June 2016, 13:08
Could you give a link to an AviSynth+ version where this results in a crash?
I'm using Pinterf's latest version. I fixed the crash already and the changes have been merged into MT-pfmod branch

ryrynz
28th June 2016, 13:35
Next build will be official?

Wilbert
28th June 2016, 13:39
I'm not able to crash AviSynth v2.61a1 like you do with Deshaker, but it hasn't your changes. If i close VirtualDub during or at the end of the second pass it just exists without crashing.

avsplus-r1858-pfmod doesn't have the fix right? If i install the XP_x86 (yes still running that on my laptop) and run Version.avs it complains: 'AVI Import Filter error'. Anyone?

Guess i need to turn my pc on and try again.

MysteryX
28th June 2016, 13:47
v2.6 works fine, only AVS+ crashes.

The fix is here
https://github.com/pinterf/AviSynthPlus/pull/4/commits/78efa4e1dfbee153b05b669f9cacacb7b7661f37

If you want the updated VDubFilter.dll now (x86), I uploaded it here (https://mega.nz/#!DYJhwCqZ!fSc2UcKWynczGCIYaAJGi1jq75oLb6rKBnutpGhk0Y0) (compiled with VS2015)

Deshaker is complicated to use; so that's a good reason to integrate it into my Media Encoder software

Wilbert
28th June 2016, 13:59
Let me reword it. I don't understand why it crashed in AVS+ and it works fine in v2.61a1. I guess it must have something to do with VDubFilter being a plugin in AVS+ and part of the core in v2.61a1?

@pinterf, any ideas?

MysteryX
28th June 2016, 14:23
The plugin code has been altered since v2.6. Just looking at the code history, there has been quite a few changes over time.

pinterf
28th June 2016, 20:57
@Wilbert: no idea, nor have I deeper insight on this area

ultim
28th June 2016, 22:58
Next build will be official?

pinterf and I will consult (it seems we might be able to do that IRL), and his changes will be merged. Until then, just overwrite the avisynth dll from the official installer package with pinterf's version, there is nothing wrong with doing that.

Wilbert
29th June 2016, 14:10
@pinterf,

I can't get your fork to work: https://github.com/pinterf/AviSynthPlus/releases (x86).
I copied your dll over the regular avisynth+ version (AviSynthPlus-r1576.exe). The regular version works fine, but when overwriting it by your dll i get 'AVI Import Filter error' when opening Version.avs in 32-bit Virtualdub (Win7).

edit: Guess i needed Microsoft Visual C++ 2015 Redistributable.

pinterf
29th June 2016, 14:34
@pinterf,

I can't get your fork to work: https://github.com/pinterf/AviSynthPlus/releases (x86).
I copied your dll over the regular avisynth+ version (AviSynthPlus-r1576.exe). The regular version works fine, but when overwriting it by your dll i get 'AVI Import Filter error' when opening Version.avs in 32-bit Virtualdub (Win7).
Do you have VS 2015 Redistributables installed?
edit: I see, O.K. - at least I found again where my virtualdub folder is :)

pinterf
30th June 2016, 09:29
@pinterf

So, it is a bug of AVS+ you will fix or a bug of the script that appears in AVS+ only? :)
Still couldn't identify which part works differently, but the modified SMDegrain script (http://forum.doom9.org/showthread.php?p=1771735#post1771735) with TV_range parameter solves the problem (does not call rebuild luma if TV_range false)

pinterf
30th June 2016, 09:31
this with TV_range bool http://pastebin.com/vz6Ewuvv

try first

SMDegrain (tr=4,PreFilter=prefilter4,TV_range=false,thSAD=400,contrasharp=false,refinemotion=false,plane=4,chroma=true,lsb=true,mode=6)
Prefetch(8)


then try

SMDegrain (tr=4,PreFilter=prefilter4.SmoothCustom16("Y>60160?y:y","u>61440?u:u","v>61440?v:v",limiter=true),thSAD=400,contrasharp=false,refinemotion=false,plane=4,chroma=true,lsb=true,mode=6)
Prefetch(8)


and

SMDegrain (tr=4,PreFilter=prefilter4.Ditherpost(mode=6,ampn=0.0,staticnoise=false).Limiter(),thSAD=400,contrasharp=false,refinemotion=false,plane=4,chroma=true,lsb=true,mode=6)
Prefetch(8)

The one with the new TV_range=true parameter is O.K.
The other two clips are corrupted.
What is the conclusion? The second method receives a limited prefiltered clip, still it shows garbage

tormento
30th June 2016, 10:18
Still couldn't identify which part works differently, but the modified SMDegrain script (http://forum.doom9.org/showthread.php?p=1771735#post1771735) with TV_range parameter solves the problem (does not call rebuild luma if TV_range false)



Ok... Anyway understanding why AVS+ works differently would be better :)

What does that modified scripts do exactly? If reduces color range is no go...

ultim
30th June 2016, 13:45
It turns out pinterf and I live close to each other, so we took advantage of this and met up in person. We talked about many things, like introductions ofc, what we do for a living, how we got into Avisynth. We also looked at various parts of the code, some parts he still needed to look into, and others that I needed to refresh my own memory about. We also spoke about how important it is that when we get a bug report, we receive a sample video and a minimalistic script to reproduce it. We both felt compelled to point out that a script which has only two lines, but in one of them calls a multi-hundred-line script, is not minimal. We know there are a multiple things to improve and many wishes, but neither of us have the resources to make everything come true, so we need to aggressively prioritize.

pinterf has a lot of development experience, though he only recently started using C++, so he is still experimenting a lot. There are also some other things he's been working on, all related to Avisynth, so you can expect more goodies from him soon :) As for me, I have taken home a list of stuff for me to investigate/debug. I'd say once I catch up to this list, pinterf's changes, and Avs 2.6.1, I'll feel comfortable to do another release. Pinterf will probably release other builds earlier.

Of course we went into a lot more detail on each of these topics, but I think this gives you a basic overview of the things we talked about.

LigH
30th June 2016, 15:12
It turns out pinterf and I live close to each other, so we took advantage of this and met up in person.

Rare occasion... I hope you had http://cosgan.de/images/smilie/nahrung/a015.gif

pinterf
30th June 2016, 15:25
Rare occasion... I hope you had http://cosgan.de/images/smilie/nahrung/a015.gif

Cola vs Beer :)

real.finder
30th June 2016, 16:33
The one with the new TV_range=true parameter is O.K.
The other two clips are corrupted.
What is the conclusion? The second method receives a limited prefiltered clip, still it shows garbage

something in Dither_Luma_Rebuild not like avs+, did you try something else? like prefilter 1 and 2 and 3?

tormento
30th June 2016, 17:37
something in Dither_Luma_Rebuild not like avs+, did you try something else? like prefilter 1 and 2 and 3?

Only prefilter=4 (knl) gives corruption.

real.finder
30th June 2016, 18:03
Only prefilter=4 (knl) gives corruption.

try this then


SetFilterMTMode("DEFAULT_MT_MODE", 2)
SetFilterMTMode("lsmashvideosource", 3)
lsmashvideosource("13HoursCUT.mp4", format="YUV420P8")
Crop(0, 140, 0, -140)
# In a more lucid state I could probably have laid out this block much better... or not...
NL_in = Dither_convert_8_to_16()
NL_W = width(NL_in)
U8 = UToY8(NL_in)
V8 = VToY8(NL_in)
NL_lsb = StackVertical(StackVertical(Dither_get_msb(u8),Dither_get_msb(v8)),StackVertical(Dither_get_lsb(u8),Dither_get_lsb(v8)))

Y8 = StackHorizontal(ConvertToY8(NL_in),NL_lsb)

Y8 = Y8.KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")

u_h = u8.height()/2
v_h = v8.height()/2

u16 = StackVertical(Dither_get_msb(Y8).crop(NL_W,0,0,-v_h),Dither_get_lsb(Y8).crop(NL_W,0,0,-v_h))
v16 = StackVertical(Dither_get_msb(Y8).crop(NL_W,u_h, 0,0),Dither_get_lsb(Y8).crop(NL_W,u_h, 0,0))

prefilter4 = YToUV(u16,v16,Y8.crop(0,0,-u8.width(),0))

SMDegrain (tr=4,PreFilter=prefilter4.SmoothLevels16(preset="tv2pc"),TV_range=false,thSAD=400,contrasharp=false,refinemotion=false,plane=4,chroma=true,lsb=true,mode=6)
Prefetch(8)


+ this one http://pastebin.com/JtWFN124 (not tested enough)

SMDegrain (tr=4,PreFilter=4,thSAD=400,contrasharp=false,refinemotion=false,plane=4,chroma=true,lsb=false,mode=6)
Prefetch(8)

yes, use it with no lsb for testing purpose

tormento
1st July 2016, 05:47
try this then

+ this one http://pastebin.com/JtWFN124 (not tested enough)



Both works. No corruption.

pinterf
1st July 2016, 08:47
Weird.

Replaced the one-pass combined YUV KNLMeans path

NL_in = Dither_convert_8_to_16()
NL_W = width(NL_in)
U8 = UToY8(NL_in)
V8 = VToY8(NL_in)
NL_lsb = StackVertical(StackVertical(Dither_get_msb(u8),Dither_get_msb(v8)),StackVertical(Dither_get_lsb(u8),Dither_get_lsb(v8)))

Y8 = StackHorizontal(ConvertToY8(NL_in),NL_lsb)

Y8 = Y8.KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")

u_h = u8.height()/2
v_h = v8.height()/2

u16 = StackVertical(Dither_get_msb(Y8).crop(NL_W,0,0,-v_h),Dither_get_lsb(Y8).crop(NL_W,0,0,-v_h))
v16 = StackVertical(Dither_get_msb(Y8).crop(NL_W,u_h, 0,0),Dither_get_lsb(Y8).crop(NL_W,u_h, 0,0))

prefilter4 = YToUV(u16,v16,Y8.crop(0,0,-u8.width(),0))


With a 3 pass KNLMeans path (distinct Y, U, V)

NL_in = Dither_convert_8_to_16()
U8 = UToY8(NL_in)
V8 = VToY8(NL_in)
Y8 = ConvertToY8(NL_in)
U16 = U8.KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
V16 = V8.KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
Y16 = ConvertToY8(NL_in).KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
prefilter4 = YToUV(u16,v16,Y16)

Result is:
KNLMeansCL: fatal error!

No MT.

Then I tried with different avisynth DLLs I have:
Classic AVS 2.6: no error
Avisynth+ r1576: no error
From Avisynth r1689 on: KNLMeansCL: fatal error!

When omitting KNLMeans calculation for clip V16, it works again.
U8 = UToY8(NL_in)
V8 = VToY8(NL_in)
Y8 = ConvertToY8(NL_in)
U16 = U8.KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
V16 = U16 #V8.KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
Y16 = ConvertToY8(NL_in).KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
prefilter4 = YToUV(u16,v16,Y16)

Could you try if it works or not for you?

MysteryX
1st July 2016, 08:52
Ultim, Pinter said that making AviSynth+ cross-platform-compatible wasn't his area of expertise and someone would have to do that. Is that something you'll handle or we'll have to wait until someone else volunteers?

tormento
1st July 2016, 09:02
When omitting KNLMeans calculation for clip V16, it works again.
U8 = UToY8(NL_in)
V8 = VToY8(NL_in)
Y8 = ConvertToY8(NL_in)
U16 = U8.KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
V16 = U16 #V8.KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
Y16 = ConvertToY8(NL_in).KNLMeansCL(D=1, A=1, h=7.0,lsb_inout=true,device_type="GPU")
prefilter4 = YToUV(u16,v16,Y16)

Could you try if it works or not for you?

Works.

P.S: When I say it "works", it is corruption related. I am not doing any analysis about quality of output.

pinterf
1st July 2016, 09:17
Works.

P.S: When I say it "works", it is corruption related. I am not doing any analysis about quality of output.

Just to make sure, I suppose you tried with the non-uncommented V16 line (the quote is the commented one)?

tormento
1st July 2016, 09:25
Just to make sure, I suppose you tried with the non-uncommented V16 line (the quote is the commented one)?

The "works" is for the commented one.

The uncommented works with Prefetch(6) instead of Prefetch(8) because otherwise GPU memory requirements goes beyond my 2GB card.

Groucho2004
1st July 2016, 10:01
@tormento, pinterf
You guys realize that using Prefetch(8) will use 8 times the GPU memory, right? I ran a little test and ran out of memory at Prefetch(4). I do however only have 1G graphics memory.

Use AVSMeter with the -gpu switch to check GPU memory usage.

When you run out of GPU memory you'll get this:
KNLMeansCL: fatal error! (AviSynthGetFrame)

tormento
1st July 2016, 10:14
Use AVSMeter with the -gpu switch to check GPU memory usage.

When you run out of GPU memory you'll get this:
KNLMeansCL: fatal error! (AviSynthGetFrame)

You are right. I have 2 GB on my GPU and the "uncommented script" with Prefetch(6) works, with following stats:

[Runtime info]
Frames processed: 107 (0 - 106)
FPS (min | max | average): 0.362 | 830086 | 8.244
Memory usage (phys | virt): 1272 | 2775 MiB
Thread count: 171
CPU usage (average): 54%
GPU usage (average): 29%
Video engine load (average): 15%
GPU memory usage: 1741 MiB
Time (elapsed): 00:00:12.980

With Prefetch(8), it goes to 1920 MB and then KNL crashes.

tormento
1st July 2016, 10:17
Just to make sure, I suppose you tried with the non-uncommented V16 line (the quote is the commented one)?

As I wrote, the uncommented works with Prefetch(6) and no corruption too.

pinterf
1st July 2016, 10:23
@tormento, pinterf
You guys realize that using Prefetch(8) will use 8 times the GPU memory, right? I ran a little test and ran out of memory at Prefetch(4). I do however only have 1G graphics memory.

Use AVSMeter with the -gpu switch to check GPU memory usage.

When you run out of GPU memory you'll get this:
KNLMeansCL: fatal error! (AviSynthGetFrame)
No MT mode here

MysteryX
1st July 2016, 10:28
The author of KNLMeansCL explicitely recommended NOT to use MT with KNLMeans, and if you use, set it to MT mode=3. A single instance of it then gets created.

pinterf
1st July 2016, 11:05
Weird.

Replaced the one-pass combined YUV KNLMeans path
...
With a 3 pass KNLMeans path (distinct Y, U, V)

NL_in = Dither_convert_8_to_16()
U8 = UToY8(NL_in)
V8 = VToY8(NL_in)
Y8 = ConvertToY8(NL_in)
U16 = U8.KNLMeansCL(D=0, A=1, h=7.0,lsb_inout=true,device_type="GPU")
V16 = V8.KNLMeansCL(D=0, A=1, h=7.0,lsb_inout=true,device_type="GPU")
Y16 = ConvertToY8(NL_in).KNLMeansCL(D=0, A=1, h=7.0,lsb_inout=true,device_type="GPU")
prefilter4 = YToUV(u16,v16,Y16)


With D=0 it works. (tried before without success: GPU/CPU, lsb_inout=false,h=1.0)
Still no MT. Maybe we should pass the problem to the right forum.

Groucho2004
1st July 2016, 11:10
With D=0 it works. (tried before without success: GPU/CPU, lsb_inout=false,h=1.0)
Still no MT. Maybe we should pass the problem to the right forum.
"d=0" uses less gpu memory.
What graphics card do you have? How much memory? Have you tried monitoring the GPU memory usage?

pinterf
1st July 2016, 11:57
AMD 7570, 1G RAM. 385 MB Dedicated, 98 MB Dynamic.
With classic AVS and Avs+ 1576 there is no problem.

tormento
1st July 2016, 12:11
Still no MT. Maybe we should pass the problem to the right forum.

+1

Let's stay on image corruption topic.

pinterf
1st July 2016, 14:26
1.) Image corruption solved*

Avisynth.dll compiled for Debug has no corruption.
Release version has.

2.) KNLMeansCL fatal error (3*call in a sequence + SMDegrain) solved**

Avisynth.dll compiled for Debug has no fatal error.
Release version has.

Programmers' dream: debug the release.

*, **not solved