View Full Version : How does nums dems works and affect on performance?


Dreamject
16th April 2019, 09:03
In SVP I saw it try to use simple and small Num den like 5 and 2. In doom9 I saw example like 23.976 = 24000/1001. But is it difference for cpu/ram between, for example, 3/2 and 30000/20000? In my case not, but may be I am wrong.

IMHO, there is no limit to write float number using den like 10^n. So, 23.976 can be written as 23976/1000 too. Is there any reason to write simple/small nums dens?

tebasuna51
16th April 2019, 09:49
There is not difference between 3/2 and 30000/20000 because both are the exact 1.5

But 24000/1001 is 23.9760239760239760239760239760... and is not exactly 23.976.
The difference is only 8 ms of duration in a movie of 200 000 frames but the exact value is 24000/1001

For instance, in a mkv container, the fps is stored like the 'Default duration' of a frame in nanoseconds, in a 24000/1001 movie (exact value) is 41708333 ns, in a 23.976 movie is 41708375, 42 ns bigger.

Dreamject
16th April 2019, 10:33
So, no difference in performance (only nanodifference) , only for nanoseconds?

tebasuna51
16th April 2019, 23:14
Performance?

AFAIK the SVP project create new interpolated frames and increase the fps, to obtain the same time when play (smoothly) and preserve the sync with audio.

You must preserve exactly constant the NumFrames/FPS to avoid async, it is not related with performance.

wonkey_monkey
16th April 2019, 23:22
When it comes to dividing one number by another, the size of the numbers makes no difference to the computer. It will take slightly longer to read and parse a longer decimal number, but when I say slightly I mean millionths, maybe even billionths, of a second. And it only has to do that part once.

johnmeyer
17th April 2019, 00:38
For accuracy I recommend always computing the NTSC color frame rates by multiplying the base number by 1000/1001, e.g.,

(1000/1001) * 30

and

(1000/1001) * 24

There is no difference in performance, other than the extremely negligible time it takes to do a couple of floating point calculations, but if you do it this way you avoid any minor issues that could happen if you just typed in "29.97" or "23.976".

Finally, I think most compilers create code that is faster if you use integers than if you use floating point, but that too is never going to be noticed so the difference between using 30 and using (1000/1001) * 30 is nothing you'll ever be able to measure.

Dreamject
17th April 2019, 10:54
Performance?
AFAIK the SVP project create new interpolated frames and increase the fps, to obtain the same time when play (smoothly) and preserve the sync with audio.

You must preserve exactly constant the NumFrames/FPS to avoid async, it is not related with performance.

Okay, I have same thoughts. Just when I asked SVP developer, he told me "bigger denumenator gives worse perfomance". I did not found any relation with num/den like 5/2 and 50/20. But I did not see any difference in perfomance with num/den like 25026/10000 vs 25/10 or 5/2 .

For accuracy I recommend always computing the NTSC color frame rates by multiplying the base number by 1000/1001, e.g.,

(1000/1001) * 30
Hmmm. There is variable "framerate" in avisynth (at least in potplayer) if I subtitle it, I see float only 23.976000.. , not something like 23,97602397602398

May be even avisynth worked with rounded value, or only "framerate" variable is rounded, or I see wrong videofiles?

Also as I know SVP and some framerate converters allow you to tell targetfps, like 24=24.0000000 and after that framerate value is exactly 24, without big frac. Is this smart searcher of num/den or veeeeery decimecal float inside like x.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx or just rounder on the end?

StainlessS
17th April 2019, 11:11
It depends upon whether or not you need to meet some specification, or need to eg join two clips, ie where must be same characteristics.
Of course you would never use anything like (1000/1001) * 30 in script as (1000/1001) = 0 remainder 1000 (integer divide).
EDIT: Even (1000.0/1001.0) * 30.0, is a badish idea and will lose precision, you need eg numerator=30000, denominator=1001, for correct result.

I asked SVP developer, he told me "bigger denumenator gives worse perfomance"
I imagine that he is talking about the interpolation step, maybe an itty-bitty slower but probably nothing to get yourself in a tizzy over.

Note, if converting from something like 24.0 to (24000.0/1001.0, about 23.976), then probably better to

c.AssumeFPS(24000,1001,sync_audio=true)
Resampleaudio(c.AudioRate)

where above just pretends that it is 0.1% slower instead of taking risk of producing bad interpolations with very little or probably zero benefit.
(ie just plays clip 0.1% slower, no frames at all affected).

EDIT: Note, when NTSC standards guys found that they could not fit color burst signal into original American TV 30FPS, they just slowed down video by 0.1%
and that gave them just enough room to fit in the color burst. So, above pretend slow down is exactly what they did, and in converting true 30.0[or 24.0] to NTSC, still do.

Emulgator
17th April 2019, 11:22
May be even avisynth worked with rounded value, or only "framerate" variable is rounded, or I see wrong videofiles?

Some framerate names are informal only and the real value should be derived within in the application
following the standards and not naming conventions.

For NTSC as johnmeyer said, mulitiplication by 1000, followed by a division by 1001.
P.S. Late Edit: Oh, I overlooked the variable type, see StainlessS,
I should have said & meant float numbers, and still: only type num/den delivers correctly...

Notations alone may be misleading.
For instance there will be misimplementation if somebody implements his software
following the .avi-internal notation literally.

(.avi has a Main Header (avih) parameter, DWORD dwMicroSecPerFrame. Truncates heavily.
Use these numbers from known files directly by inverting and you get wrong framerates.
Even Avisynth fell for that (and myself too.)). Here you need a lookup table.

The result of Stream header (strh) dwRate/dwScale should be correct though,
but will contradict dwMicroSecPerFrame in corner cases.

Oh, I couldn't resist today, late edits all over the place:
https://web.archive.org/web/20071013053751/http://www.pembers.freeserve.co.uk/World-TV-Standards/Line-Standards.html
A valuable vault for numbercrunching around TV norms collected by british TV engineer Alan Pemberton,
definitely worth a stickie here in doom9.

Dreamject
17th April 2019, 11:46
Some framerate names are informal only and the real value should be derived within in the application

Okay, I will read more, but anyway it's strange to see that framerate value is 23.97600, but after multiplication num=round(51*10000/framerate), den=10000 and subtitle framerate again it's not like 50,999000, it's like 50,9993496. If it's just informal before multiplication, why it becomes so accorate? By the way, is I get, float in avisynth has only 6 symbols after point like 0.000000, maybe it's just displayed format, maybenot

Dreamject
17th April 2019, 11:51
maybe not, cause in potplayer I did not get any frac, so 1000/1001 is equal as num 999001 den 1000000

zero=float(1000)/float(1001)
whoareyou=zero*10000000
debug==1? eval("""
Subtitle( \
"fps="+String(whoareyou)+"\n" + \
""+super_params+"\n" + \
""+part1+"\n" + \
""+part2+"\n" + \
"Source Aspect="+String(SourceAspect)+"\n" + \
""+resize_string+"\n" + \
""+smoothfps_params+"\n" + \
"Threads:"+String(threads)+"\n" + \
"Info:"+String(info)+"\n" + \
"PPcheck:"+String(PPcheck)+"\n", \
font="Comic Sans MS", size=40*width/1920, lsp=10)
""") : ("")

https://s16.directupload.net/images/190417/temp/t8ftnnnb.jpg (https://s16.directupload.net/images/190417/t8ftnnnb.jpg)

johnmeyer
17th April 2019, 21:30
(1000/1001) * 30 [/B] in script as (1000/1001) = 0 remainder 1000 (integer divide).
EDIT: Even (1000.0/1001.0) * 30.0, is a badish idea and will lose precision, you need eg numerator=30000, denominator=1001, for correct result. Gavino used to take me to task for my sloppy habits. I should know better for this one because I've gotten bit several times by forgetting to "type" these numbers as float by adding the decimal point.

I got my start programming in ALGOL and FORTRAN, and you had to explicitly type every variable before using. It was a pain, but you never had any surprises.

Thanks for correcting my error.

Dreamject
18th April 2019, 18:50
For accuracy I recommend always computing the NTSC color frame rates by multiplying the base number by 1000/1001, e.g.,

(1000/1001) * 30

and

(1000/1001) * 24

There is no difference in performance, other than the extremely negligible time it takes to do a couple of floating point calculations, but if you do it this way you avoid any minor issues that could happen if you just typed in "29.97" or "23.976".

Finally, I think most compilers create code that is faster if you use integers than if you use floating point, but that too is never going to be noticed so the difference between using 30 and using (1000/1001) * 30 is nothing you'll ever be able to measure.

Wait a second. I get why framerate is not correct, http://avisynth.nl/index.php/Clip_properties, cause it's FrameRateNumerator/FrameRateNumerator

But anyway avisynth wrote FrameRateNumerator=2997,FrameRateDenominator=125 , not 24000/1001 . Is it avisynth mistake or really nobody cares about 24000/1001 (I did not find any file with that num/den)?

StainlessS
18th April 2019, 19:29
2997 / 125 is exactly same as 23976 / 1000
Float(2997*8) / (125*8)

You can play with below

blankClip(fps=23.976)
#blankClip(fps=Float(24000)/1001)
#blankClip(fps=24000,fps_denominator=1001)
FR=FrameRate
FRN=FrameRateNumerator
FRD=FrameRateDenominator
S= String(FR,"FrameRate=%f\n") + String(FRN,"FrameRateNumerator=%.0f\n") + String(FRD,"FrameRateDenominator=%.0f\n")

Subtitle(S,lsp=0)


FrameRateNumerator and FrameRateDenominator have been calculated as ratio after first converting to 64 bit, then find ratio that best fits into 32 bit ints.
Float is a little imprecise and only has 24 bits for precision, the rest of bits for sign and magnitude of number.

EDIT: "and only has 24 bits for precision"
Actually, me seems to remember that uses really only 23 bits for precision, the 24th bit being an implied leading '1' bit (when mantissa 'normalised') except in special case where all bits are '0' ie 0.0.

wonkey_monkey
18th April 2019, 21:51
the 24th bit being an implied leading '1' bit (when mantissa 'normalised') except in special case where all bits are '0' ie 0.0.

The 24th bit is considered a zero in other cases as well, so that very small numbers can be represented:

https://en.wikipedia.org/wiki/Denormal_number

StainlessS
18th April 2019, 22:22
The 24th bit is considered a zero in other cases as well, so that very small numbers can be represented:
Agreed, but was I correct in what I said, when is normalised ? [the implied '1' bit, and 23 real bits = 24 bits altogether]
(is maybe 25+ years since I had anything whatever to do with that type stuff, dont even remember what/why I had reason to fiddle with individual bits in floating point format [and probably in MC68000 asm]).

EDIT: So the denormal state when implied bits are '0', would be when offsetted exponent = 0, I think, maybe, perhaps ?

EDIT: Just started play of Eccleston series 1, episodes 5 & 6 DVD, I only got 2 Dr DVD's. [started play just by chance, nothing to do with any Wonkey Dr fan]

Dreamject
19th April 2019, 03:44
2997 / 125 is exactly same as 23976 / 1000
Float(2997*8) / (125*8)

You can play with below

blankClip(fps=23.976)
#blankClip(fps=Float(24000)/1001)
#blankClip(fps=24000,fps_denominator=1001)
FR=FrameRate
FRN=FrameRateNumerator
FRD=FrameRateDenominator
S= String(FR,"FrameRate=%f\n") + String(FRN,"FrameRateNumerator=%.0f\n") + String(FRD,"FrameRateDenominator=%.0f\n")

Subtitle(S,lsp=0)


FrameRateNumerator and FrameRateDenominator have been calculated as ratio after first converting to 64 bit, then find ratio that best fits into 32 bit ints.
Float is a little imprecise and only has 24 bits for precision, the rest of bits for sign and magnitude of number.

EDIT: "and only has 24 bits for precision"
Actually, me seems to remember that uses really only 23 bits for precision, the 24th bit being an implied leading '1' bit (when mantissa 'normalised') except in special case where all bits are '0' ie 0.0.
It shows correct answer, even it mirrored and strange
in 1st case it shows 23,976 and equal to 23976/1000, in next cases, it's unreadable a little it shows different num/den, but it's still has digits after 976.
https://s16.directupload.net/images/190419/92vuf5ul.jpg

https://s16.directupload.net/images/190419/42lkzohw.jpg
I mean, if input file has anything looks like 24000/1001, it cant contain num/den like 2997/125..?

hello_hello
20th April 2019, 09:04
I guess the frame rate shown by Info() is rounded to 4 decimal places. Which is probably fair enough. The docs do say "framerate" is approximate.

Edit 1: There's always one mistake to fix.....

Edit 2: It seemed remiss not to make the clips 24 hours long to see how far Avisynth says they would have drifted apart.

https://i.postimg.cc/5ySQMGjz/framerate.gif

A = BlankClip(fps=23.976, length=2071529, color=$191919)
B = BlankClip(fps=24000.0/1001.0, length=2071529)
C = BlankClip(fps=24000, fps_denominator=1001, length=2071529)
FRA=A.FrameRate
FRNA=A.FrameRateNumerator
FRDA=A.FrameRateDenominator
SA= String(FRA,"FrameRate %.20f\n") + String(FRNA,"FrameRateNumerator %.0f\n") + \
String(FRDA,"FrameRateDenominator %.0f\n")
FRB=B.FrameRate
FRNB=B.FrameRateNumerator
FRDB=B.FrameRateDenominator
SB= String(FRB,"FrameRate %.20f\n") + String(FRNB,"FrameRateNumerator %.0f\n") + \
String(FRDB,"FrameRateDenominator %.0f\n")
FRC=C.FrameRate
FRNC=C.FrameRateNumerator
FRDC=C.FrameRateDenominator
SC= String(FRC,"FrameRate %.20f\n") + String(FRNC,"FrameRateNumerator %.0f\n") + \
String(FRDC,"FrameRateDenominator %.0f\n")

AA = A.Crop(0,0,-200,-100).Info().Subtitle("23.976\n\n"+SA,lsp=0, y=240)
BB = B.Crop(0,0,-200,-100).Info().Subtitle("24000.0 / 1001.0\n\n"+SB,lsp=0, y=240)
CC = C.Crop(0,0,-200,-100).Info().Subtitle("Num 24000 Den 1001\n\n"+SC,lsp=0, y=240)
DD = BlankClip(color=$191919, length=2071529).Crop(0,0,-200,-100)\
.Subtitle("24000.0 / 1001.0\n"+String(24000.0/1001.0, "%.20f")+\
"\n\n\n\nThe Real Number\n23.976023976023976023976023976024",lsp=0, Align=5, y=110)

StackVertical(StackHorizontal(AA,BB),StackHorizontal(CC,DD))

Dreamject
20th April 2019, 09:47
I guess the frame rate shown by Info() is rounded to 4 decimal places. Which is probably fair enough. The docs do say "framerate" is approximate.

Edit: There's always one mistake to fix.....

https://i.postimg.cc/c4qCHD0t/framerate.gif

A = blankClip(fps=23.976,color=$191919)
B = blankClip(fps=24000.0/1001.0)
C = blankClip(fps=24000,fps_denominator=1001)
FRA=A.FrameRate
FRNA=A.FrameRateNumerator
FRDA=A.FrameRateDenominator
SA= String(FRA,"FrameRate=%.20f\n") + String(FRNA,"FrameRateNumerator=%.0f\n") + \
String(FRDA,"FrameRateDenominator=%.0f\n")
FRB=B.FrameRate
FRNB=B.FrameRateNumerator
FRDB=B.FrameRateDenominator
SB= String(FRB,"FrameRate=%.20f\n") + String(FRNB,"FrameRateNumerator=%.0f\n") + \
String(FRDB,"FrameRateDenominator=%.0f\n")
FRC=C.FrameRate
FRNC=C.FrameRateNumerator
FRDC=C.FrameRateDenominator
SC= String(FRC,"FrameRate=%.20f\n") + String(FRNC,"FrameRateNumerator=%.0f\n") + \
String(FRDC,"FrameRateDenominator=%.0f\n")

AA = A.Crop(0,0,-200,-100).Info().Subtitle("23.976\n\n"+SA,lsp=0, y=240)
BB = B.Crop(0,0,-200,-100).Info().Subtitle("24000.0/1001.0\n\n"+SB,lsp=0, y=240)
CC = C.Crop(0,0,-200,-100).Info().Subtitle("num=24000 den=1001\n\n"+SC,lsp=0, y=240)
DD = BlankClip(,color=$191919).Crop(0,0,-200,-100)\
.Subtitle("The Real Number\n23.976023976023976023976023976024"+\
"\n\n\n\n24000.0/1001.0\n"+String(24000.0/1001.0, "%.20f"),lsp=0, Align=5, y=120)

StackVertical(StackHorizontal(AA,BB),StackHorizontal(CC,DD))
Okay, but what about real, not synthetic video? In my cases they all have 2997 / 125 num/den.

hello_hello
20th April 2019, 15:31
Okay, but what about real, not synthetic video? In my cases they all have 2997 / 125 num/den.

2997/125 is exactly 23.976

The Avisynth docs say "Video framerate is actually a ratio of two 32-bit integers". I assume there's no way 23.976 can be represented exactly as a floating point number.

It might not appear to be the case normally, as this gives you 23.97600

Subtitle(string(23.976))

but when you prevent the rounding, you get 23.97599983215332000000

Subtitle(string(23.976), "%.20f")

Therefore 23.976 as a frame rate doesn't give you 23976/1000 or 2997/125 as numerator and denominator.

I'm not clear on how you entered the frame rate, but it must have been in a way that could result in 2997/125.
There's workarounds, so Avisynth knows for certain what you mean by 23.976, although I don't think they work outside the frame rate filters.
http://avisynth.nl/index.php/AssumeFPS

This produces the same, not quite 24000/1001 floating point number as 24000.0/1001.0, but Num/Den should be 24000/1001.

FrameR = FrameRate(AssumeFPS("ntsc_film"))
Last.Subtitle(string(FrameR, "%.20f"))

"ntsc_round_film" should give you 2997/125.
Is there anything in one of the functions you use that might be fiddling with the frame rate a little after you've entered it?

Dreamject
20th April 2019, 19:51
>The Avisynth docs say "Video framerate is actually a ratio of two 32-bit integers". I assume there's no way 23.976 can be represented exactly as a floating point number.
It says "so for the precise number, use FrameRateNumerator and FrameRateDenominator." too...

But there is 23.976x60x60x2=172627,2 - frames in two hours
60x60x60x24/1.001=172627,37262737262737262737262737
The difference in 2 hours movie less than 1 FRAME, CARL . So there is no advantage to use clear 24000/1001, imho

# SuperSVP support vk.com/potplayerms t.me/supersvp


Try{ core=core }
catch(err){
fps= 45 #1..10 - 1..10X,>10 - target FPS. You can proportionally (targefps-originalfps) decrease CPU load reducing this value

Quality1= 0 Quality2=Quality1 #0-3 0-weakest, 3 - best. As I know, usually in original SVP Quality2=Quality1 , but you can control it manually
artefactremove = 0 BlockSize = 0 #artefactremove 0 - default, 50 - middle, 200 - strong. Bigger values gives less smoothing; BlockSize 0-8, 0-w32, ol0; 1-w32,ol1; 2-w32; 3-ol; 4-ol1; 5-default 16,ol2; 6-w8,ol0; 7-w8,ol1; 8-w8 . Bigger block faster and less noisy, but small have better smooth.
gpu= 1 # 0 - off | 1(11) - 1st GPU on 1st platform | 12 - 2nd GPU on 1st platform | 21 - 1st GPU on 2nd platform...
mode= 1 #1 - каждый ориг кадр используется один раз, остальное - расчётные кадры, 0 - из двух ориг кадров остаётся один, остальные расчётные (объясните, ЗАЧЕМ?! Ведь рассчётные хуже и доп нагрузка на ЦПУ), 2 - каждый ориг кадр дублируется (ЗАЧЕМ?! На выходе фейк уплавнение, нагрузка на ГПУ сильно возрастёт), 3 - по ситуации (дефолт), грузит ЦПУ примерно как 0. Я понимаю, что в сложных сценах может быть оправдан переход в 2 режим, но зачем он торчит в нулевом?!

pel= 1 # 2 is default, higher is slower. The accuracy of the motion estimation. 1 means a precision to the pixel, 2 means a precision to half a pixel, 4 - to quarter pixel (not recommended to use). But pel=1 is Okay
thsad="thsad:200"#200 default, 250 for better quality, 1000 for smooth animation, 65000 for... I do not know, but it used some time ago.
algo= "13" #13 algo for movies, 2 for animation. There is other algos, but they works bad, imho
debug=1 debugtimesec=99 #debug=0..2 0 disables messages, 1 shows message debugtimesec seconds, 2 shows them permanently

#KOSTYLI - they improve speed, may reduce quality
CoarseWidth="width:530,"#default 1050, higher is slower
weakgpu= 0 #if your GPU is overload, 1 means linear:false, 2 - cubic:0; 3 - cubic:0,linear:false . In modern version if SVP decides thay you have weak GPU, it paste only linear:false. Cubic:0 is for previous versions
SearchDistance="distance:0," #"distance:0," speeds up, but can looks good on GPU. Developers do not use it in script generator
#vectors= 3 #2 loads gpu less, but worse quality
SetMemoryMax(2700)
PPcheck=1#WIDTH
PPcheck==1? eval ("""
SetFilterMTMode("ffdshow_source",3)
ffdshow_source()
ConvertToYV12()
global threads=4 #for regular player
""") : eval ("""
global threads=round(1.83 * #CPUS) #valid only for PotPlayer. You can calculate and input numbers of CPU cores*2 manually
SetFilterMTMode("potplayer_source",3)
potplayer_source()
""")}

orignum=FrameRateNumerator
origdenom=FrameRateDenominator

super_override=""#like {scale:{up:0},gpu:1}
analyse_override=""
smoothfps_override=""


bit=GetProcessInfo()
Try{LoadPlugin(""+String(bit)+"\svpflow1.dll")
LoadPlugin(""+String(bit)+"\svpflow2.dll")}
catch(err){LoadPlugin("AviSynth\"+String(bit)+"\svpflow1.dll")
LoadPlugin("AviSynth\"+String(bit)+"\svpflow2.dll")}
#LoadPlugin("RoboCrop_x86.dll")
#LoadPlugin("C:\Program Files (x86)\SVP 4\plugins\svpflow1.dll")
#LoadPlugin("C:\Program Files (x86)\SVP 4\plugins\svpflow2.dll")
#LoadPlugin("C:\Program Files (x86)\SVP 4\plugins64\svpflow1.dll")
#LoadPlugin("C:\Program Files (x86)\SVP 4\plugins64\svpflow2.dll")
SetFilterMTMode("DEFAULT_MT_MODE",2)
SetFilterMTMode("SVSuper",1)
SetFilterMTMode("SVAnalyse",1)

denum=10000
origframerate=framerate
num=ceil(float(fps)*denum/Framerate)

fps <= 10 ? eval("""rate = "num:"+String(fps)+",den:1" """) : eval(""" rate = "num:"+String(num)+",den:"+String(denum)+",abs:false" """)

weakgpuparam= weakgpu==1? "linear:false," : weakgpu==2? "cubic:0," : weakgpu==3? "linear:false,cubic:0," : ""
gpuid = (gpu>1) ? "gpuid:"+String(gpu)+"," : ""



Quality1 == 0 ? eval("""
AnalyseMainSearchCoarse="satd:false,"
""") : Quality1 == 1 ? eval("""
AnalyseMainSearchCoarse="type:2,distance:-6,"
""") : Quality1 == 2 ? eval("""
AnalyseMainSearchCoarse="distance:-8,"
""") : Quality1 == -1 ? eval("""
AnalyseMainSearchCoarse="distance:-8,"#okay...
super_override=""#like {scale:{up:0},pel:1,gpu:1}
analyse_override="{block:{w:32,overlap:0},main:{search:{type:2,distance:0,coarse:{width:530,type:2,distance:-1,satd:false,bad:{range:0}}},refine:[{thsad:200,search:{type:2,distance:0}}]}}}"
smoothfps_override=""
""") : Quality1 == -2 ? eval("""
AnalyseMainSearchCoarse="distance:-8,"#okay...
super_override="{scale:{up:0,down:2},gpu:1,pel:1,full:false}"#like {scale:{up:0},gpu:1}
analyse_override="{block:{w:32,overlap:0},main:{search:{type:2,distance:0,coarse:{width:530,type:2,distance:-1,satd:false,bad:{range:0}}},refine:[{thsad:0,search:{type:2,distance:0}}]}}}"
smoothfps_override=""
""") : eval ("""
AnalyseMainSearchCoarse="distance:-12,"
""")

AnalyseMainQuality2=""

Quality2 == 0 ? eval("""
AnalyseMainQuality2="range:0"
""") : Quality2 == 1 ? eval("""
""") : Quality2 == 2 ? eval("""
AnalyseMainQuality2="sad:2000,range:24"
""") : eval ("""
AnalyseMainQuality2="sad:2000"
""")

pel < 2 ? eval("""
pelparams="pel:1,full:false"
""") : eval("""
pelparams="pel:"+String(pel)+""
""")
AnalyseBlock = BlockSize==0 ? "block:{w:32,overlap:0}," : BlockSize==1 ? "block:{w:32,overlap:1}," : BlockSize==2 ? "block:{w:32}," : BlockSize==3 ? "block:{overlap:0}," : BlockSize==4 ? "block:{overlap:1}," : BlockSize==5 ? "block:{}," : BlockSize==6 ? "block:{w:8,overlap:0}," : BlockSize==7 ? "block:{w:8,overlap:1}," : BlockSize==8 ? "block:{w:8}," : "block:{},"
gpuparams = gpu>0 ? "scale:{up:0},gpu:1" : "scale:{up:2},gpu:0"

#MultiplerW=width/DisplayW
#MultiplerH=height/DisplayH
##width*height<DisplayW*DisplayW? OverrideRes=0 : OverrideRes=1
#OverrideRes==1?eval(""" """)
#MultiplerW>MultiplerH? cropstring="width/MultiplerW,height/MultiplerH,c=0.75":cropstring=""

#RoboCrop()

global source_width = width
global source_height = height
global crop_string = ""
global resize_string = ""#BicubicResize(1366,768,b=0,c=0.75)"
global super_params = super_override=="" ? "{"+gpuparams+","+pelparams+"}" : super_override
#global analyse_params = "{"+AnalyseBlock+"main:{search:{type:2,"+SearchDistance+"coarse:{"+CoarseWidth+""+AnalyseMainSearchCoarse+" bad:{"+AnalyseMainQuality2+"}}},refine:[{"+thsad+"}]}}}"
part1="{"+AnalyseBlock+"main:{search:{"+SearchDistance+"coarse:{"+CoarseWidth+""+AnalyseMainSearchCoarse+""
part2="bad:{"+AnalyseMainQuality2+"}}},refine:[{"+thsad+",search:{}}]}}}"
global analyse_params = analyse_override == "" ? ""+part1+""+part2+"" : analyse_override
global smoothfps_params = smoothfps_override=="" ? "{"+weakgpuparam+"rate:{"+rate+"},"+gpuid+"algo:"+algo+",mask:{area:"+String(artefactremove)+"},scene:{mode:"+String(mode)+"}}" : smoothfps_override

global demo_mode=0
global stereo_type=0

########## BEGIN OF base.avs ##########
# This file is a part of SmoothVideo Project (SVP) ver.4
# This is NOT the full AVS script, all used variables are defined via
# JScript code that generates the full script text.


NewWidth = 1366
NewHeight = 768
SourceAspect = float(source_width) / float(source_height)
MyAspect = float(NewWidth) / float(NewHeight)
SourceAspect > MyAspect ? eval("""
ResizedWidth=NewWidth
ResizedHeight=round(float(source_height) * float(NewWidth) / float(source_width) / 2.0) * 2
""") : eval("""
ResizedHeight=NewHeight
ResizedWidth=round(float(source_width) * float(NewHeight) / float(source_height) / 2.0 ) * 2
""")
#resize_string="BicubicResize("+String(ResizedWidth)+","+String(ResizedHeight)+",b=0,c=0.75)"

function interpolate(clip src)
{
input = crop_string=="" ? src : eval("src."+crop_string)
input = resize_string=="" ? input : eval("input."+resize_string)

#MT-MODE-1 #do not remove this line!

super=SVSuper(input, super_params)
vectors=SVAnalyse(super, analyse_params, src=input)
smooth=SVSmoothFps(input, super, vectors, smoothfps_params, mt=threads, src=src)

#MT-MODE-2 #do not remove this line!

return demo_mode==0 ? smooth : demo(input,smooth)
}

input=last

stereo_type==0 ? eval(""" interpolate(input)
""") : stereo_type==1 ? eval("""
lf = interpolate(input.crop(0,0,input.width/2,0))
rf = interpolate(input.crop(input.width/2,0,0,0))
StackHorizontal(lf, rf)
""") : stereo_type==2 ? Eval("""
lf = interpolate(input.crop(0,0,0,input.height/2))
rf = interpolate(input.crop(0,input.height/2,0,0))
StackVertical(lf, rf)""") : input

########### END OF base.avs ###########

#override= analyse_override=="" || smoothfps_override=="" ||super_override=="" ? "" : "OVERRIDE MODE" WTF why dont works
override= analyse_override!="" ? "OVERRIDE MODE" : smoothfps_override!="" ? "OVERRIDE MODE" : super_override!="" ? "OVERRIDE MODE" : ""

SourceAspect = float(source_width) / float(source_height)
targetframerate=framerate
debugtime= debug==2? (Framecount-1) : round(float(FrameRateNumerator)*debugtimesec/FrameRateDenominator)
debug>0? eval("""
Subtitle( \
"SuperSVP support vk.com/potplayerms t.me/supersvp \n" + \
""+String(source_width)+"x"+String(source_height)+" "+String(SourceAspect)+":1 "+String(origframerate)+"*"+String(num)+"/"+String(denum)+"="+String(targetframerate)+"("+String(fps)+") "+override+"\n" + \
"Quality1="+String(Quality1)+"/3,Quality2="+String(Quality2)+"/3\n" + \
"artefactremove="+String(artefactremove)+",BlockSize="+String(BlockSize)+"/8\n" + \
"Orignumden="+String(orignum)+"/"+String(Origdenom)+"->"+String(FrameRateNumerator)+"/"+String(FrameRateDenominator)+"/8\n" + \
"gpu="+String(gpu)+",mode="+String(mode)+"/3\n" + \
"pel="+String(pel)+"/4,threads="+String(threads)+"\n" + \
"weakgpu="+String(weakgpu)+"/3,CoarseWidth="+String(CoarseWidth)+",SearchDistance="+String(SearchDistance)+"\n" + \
"debugtime="+String(debugtime)+",debugtimesec="+String(debugtimesec)+"\n" + \
"\n\n\n\n\n\n" + \
"PPcheck:"+String(PPcheck)+"\n" + \
""+super_params+"\n" + \
""+part1+"\n" + \
""+part2+"\n" + \
""+smoothfps_params+"\n", \
font="Comic Sans MS", size=40*width/1920, lsp=10, last_frame = debugtime )
""") : ("")

WriteFileStart("someinfo.txt", "analyse_params")




Prefetch(threads)