digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: Little optimizations in optimal script (http://www.digitalfaq.com/archives/avisynth/4269-avisynth-little-optimizations.html)

Dialhot 07-01-2003 05:09 AM

Little optimizations in optimal script
 
Hello guys,

The optimal script does a really good job, but it can do it a little faster :!:

ORIGINAL
Code:

MaxTreshold = 1.50
nf =  0 # Current frame.

Mpeg2Source("Your_D2V_Source_Here")

undot()
Limiter()
asharp(2, 4)
GripCrop(Your_GripCrop_Parameters_Here)
GripSize(resizer="BicubicResize")
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(MaxTreshold))
MergeLuma(blur(0.2))

ScriptClip("nf = YDifferenceToNext()"+chr(13)+ "nf > 2 ? \
unfilter( -(fmin(round((nf/0.5)), 100)), -(fmin(round((nf/0.5)), 100)) ) : \
TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")

GripBorders()
#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!
Limiter()

function fmin(float f1, float f2) {
  return (f1<f2) ? f1 : f2
}

OPTIMIZED
Code:

nf =  0 # Current frame.

Mpeg2Source("Your_D2V_Source_Here")

undot()
Limiter()
asharp(2, 4)
GripCrop(Your_GripCrop_Parameters_Here)
GripSize(resizer="BicubicResize")
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(1.50))
MergeLuma(blur(0.2))

ScriptClip("nf = round(YDifferenceToNext())"+chr(13)+ "nf > 2 ? \
unfilter( -(fmin(nf*2, 100)), -(fmin(nf*2, 100)) ) : \
TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")

GripBorders()
#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!
Limiter()

function fmin(int f1, int f2) {
  return (f1<f2) ? f1 : f2
}

1/ "nf*2" is equivalent to "nf/0.5" but is faster as we use only int
2/ fmin is called only with int values so why declare f1 and f2 as float ?

My tests on a 5 min video : 31'28s for encoding with the "original" script, 31'04s with the new one

I also made test with temporalcleaner insteed of temporalsoften, and is A LOT faster : 20'27s for encoding the same video.
(sample size was quite the same)

I used this parameters :
Code:

temporalcleaner(fmin(3+nf,7),fmin(8+nf,15))
I'm opened to suggestion on the visual result obtained with this filter :idea: [/code]

Jellygoose 07-01-2003 06:45 AM

Can you post the full script made with TemporalCleaner please? I'd like to test it against the current optimal script!

Dialhot 07-01-2003 07:06 AM

Quote:

Originally Posted by Jellygoose
Can you post the full script made with TemporalCleaner please? I'd like to test it against the current optimal script!

Code:

nf =  0 # Current frame.

Mpeg2Source("Your_D2V_Source_Here")

undot()
Limiter()
asharp(2, 4)
GripCrop(Your_GripCrop_Parameters_Here)
GripSize(resizer="BicubicResize")
STMedianFilter(8, 32, 0, 0 )
MergeChroma(blur(1.50))
MergeLuma(blur(0.2))

ScriptClip("nf = round(YDifferenceToNext())"+chr(13)+ "nf > 2 ? \
unfilter( -(fmin(nf*2, 100)), -(fmin(nf*2, 100)) ) : \
temporalcleaner(fmin(3+nf,7),fmin(8+nf,15)) ")

GripBorders()
#LetterBox( Your_Values_Here ) # Depends on situation. Use MovieStacker!
Limiter()

function fmin(int f1, int f2) {
  return (f1<f2) ? f1 : f2
}


kwag 07-01-2003 09:10 AM

Hi Dialhot,

Thanks for the update :)
Yep, you sure got that right :!:
I'm updating the script now with your changes:
Code:

ScriptClip("nf = round(YDifferenceToNext())"+chr(13)+ "nf > 2 ? \
unfilter( -(fmin(nf*2, 100)), -(fmin(nf*2, 100)) ) : \
TemporalSoften(4, round(1/nf) , round(3/nf) ,0, 2) ")

But I'll hold back on the temporalcleaner until I make more tests to see if prediction is not changed, and also if it does weird interactions like the problems I had before with the mergeluma, etc., when they were set with adaptive (dinamic) values.

-kwag

audi2honda 07-01-2003 10:41 AM

Kwag I noticed you didn't change the functions to integer instead of float like in dialhots example. In the sticky you only changed the adaptive portion. Did you mean to do this?

jorel 07-01-2003 11:18 AM

audi2honda my friend,
Kwag is testing the news like me.

i trust in Phil and Kwag too,
he only do tests cos he want to show the best for us all.
he will post precise results :!:

:wink:

ovg64 07-01-2003 11:33 AM

Quote:

Originally Posted by audi2honda
Kwag I noticed you didn't change the functions to integer instead of float like in dialhots example. In the sticky you only changed the adaptive portion. Did you mean to do this?

Yes I see it to but not in the sticky: Latest Script :roll:

kwag 07-01-2003 11:37 AM

Quote:

Originally Posted by audi2honda
Kwag I noticed you didn't change the functions to integer instead of float like in dialhots example. In the sticky you only changed the adaptive portion. Did you mean to do this?

No, I forgot :oops:
Doing it now :!:

Thanks and thanks ovg64 for the PM too ;)
-kwag

audioslave 07-01-2003 12:26 PM

WOW! 8O
I tested to run a full prediction just to see the speed improvement. AMAZING! The prediction used to take about 7 minutes for this movie (I Spy) and with this new optimization it only takes 3.5 minutes!!! I couldn't believe my eyes! :D

kwag 07-01-2003 12:31 PM

Yep, there's a BIG difference in speed between floating point to integer math :wink:

To Dialhot:
Have a beer :mrgreen:

-kwag

jorel 07-01-2003 12:37 PM

8O

yeah, jet script!
:)

editing:
predictions..

old script:
Tries : 6
Total Time For Predicition: 00:04:04

new script:
Tries : 7
Total Time For Predicition: 00:03:49

one more "try" and with less total time.
:)

audi2honda 07-01-2003 01:21 PM

I'm only about 15 minutes into a new encode, but according to the time counter in TMPGEnc my encode has gone from 3 hours to 2:15 with the latest integer changes :!: :!:

And the remaining time clock is decreasing faster then real time. 8O 8O :D

ovg64 07-01-2003 01:38 PM

Yes encoding right now n have 2hrs.50 min. to the goal,
looks like we may have to raise the max speed limit again :!: :mrgreen:

plautzer 07-01-2003 02:55 PM

how is that possible??
Ok, I got a 1,4 ghz amd, but it takes at least 10 hr to encode muvie!!
Do u think that tuning could help me out??

Plautzer

audi2honda 07-01-2003 03:38 PM

Well my encode just finished and this was using a 70% film 30% NTSC video hybrid source with telecide and decimate. I used 48 frame samples and 2 samples per minute which slowed down prediction a lot, but with this hybrid source I thought it might help.

Well the results are in :!: With the latest Optimal script today with the int variables I got 100% accuracy on my prediciton that when muxed came to exactly 795MB 8O 8O :!: :!: :!: :D

Oh and not to mention it ran blazingly fast

Plautzer. my times are for a P4 2.8ghz machine with ddr266.

I also have a 1.8ghz machine at home that takes about 5 hours. Yours should be faster. Is it a P4?

ovg64 07-01-2003 04:10 PM

Quote:

Originally Posted by plautzer
how is that possible??
Ok, I got a 1,4 ghz amd, but it takes at least 10 hr to encode muvie!!
Do u think that tuning could help me out??

Plautzer

Well my Deal here is an Athlon xp which gets up to 1.46Gigs with out clocking it, this encode when finish is going to be 4hrs. 6min. long... :mrgreen: , Monsters Inc. 93 min Toon.

plautzer 07-01-2003 04:10 PM

I got a AMD athlon 1600 xp+!!
I guess a gotta upgrade it soon!!
I encode it on 2 cds, i guess it take that double es as long!!

plautzer

ARAGORN 07-01-2003 04:11 PM

Hi

There's no difference for me in speed :(

I've got an athlon 2400, 512M0 DRR and windows xp

Kwag, what's the problem here

I'm using pal

Another question: when i encode with tok the dc component precision is set to 9 in tmpgenc. I'm using your settins tab for tok. Should not be 8?

ARAGORN

audi2honda 07-01-2003 04:14 PM

Quote:

Originally Posted by plautzer
I got a AMD athlon 1600 xp+!!
I guess a gotta upgrade it soon!!
I encode it on 2 cds, i guess it take that double es as long!!

plautzer

The number of CDs shouldn't have much of an impact on encoding time.

kwag 07-01-2003 04:14 PM

Quote:

Originally Posted by ARAGORN

Another question: when i encode with tok the dc component precision is set to 9 in tmpgenc. I'm using your settins tab for tok. Should not be 8?

If you are encoding MPEG-1, it's always 8 bits. The DC component will be shadowed.

-kwag


All times are GMT -5. The time now is 03:33 AM  —  vBulletin © Jelsoft Enterprises Ltd

Site design, images and content © 2002-2024 The Digital FAQ, www.digitalFAQ.com
Forum Software by vBulletin · Copyright © 2024 Jelsoft Enterprises Ltd.