Thread: Vapoursynth
View Single Post
Old 2nd May 2018, 14:16   #3075  |  Link
ChaosKing
Registered User
 
Join Date: Dec 2005
Location: Germany
Posts: 1,795
@Myrsloik
Ok, thx.
I found a strange behaviour while playing with FrameEval func.

The very same function gives different output if it's called within FrameEval.
Is it a bug or did I miss something?
Here's an animated gif of my problem (correct output is in the middle):


And my script (You'll need also Single Precision MVTools https://github.com/IFeelBloated/vapo...h-mvtools-sf):
Code:
import sys
import os

import functools
import vapoursynth as vs

import mvsfunc as mvf #https://github.com/HomeOfVapourSynthEvolution/mvsfunc/blob/master/mvsfunc.py
import havsfunc as haf
import mvmulti as mv #https://github.com/IFeelBloated/vapoursynth-mvtools-sf/blob/master/src/mvmulti.py
import fvsfunc as fvf #https://github.com/Irrational-Encoding-Wizardry/fvsfunc/blob/master/fvsfunc.py

core = vs.get_core()

def myFilter(clip):
	pre = haf.SMDegrain(clip, tr=2, pel=2, contrasharp=False, thSAD = 1200, thSADC = 1200, prefilter=2)
	pre = pre.flux.SmoothT(temporal_threshold=6)
	pre = haf.DitherLumaRebuild(pre, s0=1)
	pre = fvf.Depth(pre, 32, range_in=1)
	
	clip = mvf.Depth(clip, 32)
	
	super = core.mvsf.Super(pre,16,16,1,0)
	vectors = mv.Analyze(super, blksize=16, overlap=8, search=4, tr=6)
	super = core.mvsf.Super(clip,16,16,1,1)
	blur_clip = mv.DegrainN(clip, super, vectors, thsad=600, tr=6)
	
	grain = blur_clip.grain.Add(var=1200.0, constant=True)#.std.BoxBlur(hradius=1, hpasses=1, vradius=1, vpasses=1)
	#return grain
	diff_clip = core.std.Expr([clip, blur_clip], 'x y - abs').std.Inflate(threshold=200/255).std.Inflate(threshold=200/255)
	mask_clip = diff_clip.std.Binarize(threshold=[3.3/219, 3.3/224], v0=0, v1=80/255)
		
	clip = core.std.MaskedMerge(clipa=blur_clip, clipb=grain, mask=mask_clip)
	
	return mvf.Depth(clip, 8)
	
	

clip = core.std.BlankClip(format=vs.YUV420P8, width=120*2, height=80*2, length=100, color=[206,235,135])
g_static  = clip.grain.Add(var=100.0, constant=True)
g_dynamic = clip.grain.Add(var=100.0, constant=False)


clip = core.std.StackHorizontal([
	core.std.StackVertical([g_static, g_static]), 
	core.std.StackVertical([g_static, g_dynamic])
	])
goal = core.std.StackHorizontal([
	core.std.StackVertical([g_static, g_static]), 
	core.std.StackVertical([g_static, g_static])
	])
orig=clip




def asd(n, c):
	return myFilter(c)
	
feval = clip.std.FrameEval(functools.partial(asd, c=clip))

def comp(a, b, crop=0):
	return core.std.StackHorizontal([
		core.std.CropRel(a, crop,crop,0,0), \
		core.std.CropRel(b, crop,crop,0,0), \
		])
		
nofeval = myFilter(clip)

clip = comp(feval.text.Text("Function inside FrameEval").std.AddBorders(right=2), nofeval.text.Text("No FrameEval").std.AddBorders(right=2), crop=0)
clip = comp(clip, orig.text.Text("unfiltered"), crop=0)

clip.set_output()
__________________
AVSRepoGUI // VSRepoGUI - Package Manager for AviSynth // VapourSynth
VapourSynth Portable FATPACK || VapourSynth Database

Last edited by ChaosKing; 2nd May 2018 at 14:22.
ChaosKing is offline   Reply With Quote