digitalFAQ.com Forums [Archives]

digitalFAQ.com Forums [Archives] (http://www.digitalfaq.com/archives/)
-   Avisynth Scripting (http://www.digitalfaq.com/archives/avisynth/)
-   -   Avisynth: MA script for interlaced sources? (http://www.digitalfaq.com/archives/avisynth/6120-avisynth-ma-script.html)

Peter1234 03-30-2004 09:11 PM

Thanks Dialhot,
I suspected that, but I wasn't sure so I just used two functions. I was not sure if AviSynth would properly keep track of multilple variables with the same name. It is great to have experts like you helping out.

Dialhot 03-30-2004 09:15 PM

Quote:

Originally Posted by Peter1234
I was not sure if AviSynth would properly keep track of multilple variables with the same name

Actually there you are not instanciating a variable, but a parameter. And for sure, that is why function are made for : don't have to repeat something used more than one time.

Peter1234 03-30-2004 09:46 PM

Ok. This seems to work also. Thanks Dialhot.

### for interlaced source only
### DV codec required if AVI is DV

LoadPlugin("C:\Filters25\undot.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\Convolution3DYV12.dll")

AVISource("C:\Documents and Settings\user\Desktop\type2.avi")
ConvertToYV12
Levels(0,0.94,255,0,255)

SeparateFields()
odd=SelectOdd().Kwag_MA()
even=SelectEven().Kwag_MA()
Interleave(even,odd)
Weave()

Function Kwag_MA(clip input) {
undot(input)
Limiter(input)
STMedianFilter(input,3, 3, 1, 1 )
MergeChroma(input,blur(1.5))
MergeLuma(input,blur(0.1))
ScriptClip(" nf = YDifferenceToNext()" +chr(13)+
\ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2,
\ 100)) ).TemporalSoften( fmin( round(2/nf), 6),
\ round(1/nf) , round(3/nf) , 1, 1) ")
Convolution3D(input,preset="movieLQ")
Limiter(input)}

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

EDIT: Do not actually use the above script. Concept is correct but function is not correct. The corrected script follows:

### for AviSynth 2.5
### for interlaced source only
### DV codec required if AVI is DV

LoadPlugin("C:\Filters25\undot.dll")
LoadPlugin("C:\Filters25\asharp.dll")
LoadPlugin("C:\Filters25\UnFilter.dll")
LoadPlugin("C:\Filters25\STMedianFilter.dll")
LoadPlugin("C:\Filters25\Convolution3DYV12.dll")

AVISource("C:\Documents and Settings\user\Desktop\type2.avi")
ConvertToYV12

SeparateFields()
odd=SelectOdd().Kwag_MA()
even=SelectEven().Kwag_MA()
Interleave(odd,even)
Weave()

Function Kwag_MA(clip input) {
undot(input)
Limiter()
asharp(1, 4)
STMedianFilter(3, 3, 1, 1 )
MergeChroma(blur(1.5))
MergeLuma(blur(0.1))
ScriptClip(" nf = YDifferenceToNext()" +chr(13)+
\ "unfilter( -(fmin(round(nf)*2, 100)), -(fmin(round(nf)*2,
\ 100)) ).TemporalSoften( fmin( round(2/nf), 6),
\ round(1/nf) , round(3/nf) , 1, 1) ")
Convolution3D(preset="movieLQ")
Limiter()}

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

cweb 04-02-2004 12:43 PM

I had tried this interlaced MA script with Incredible's modifications (suggested in this thread). The result was ok though I didn't think it was any better than the classic fixed script. My final CQ was still low (around 34) so I just went for a higher CQ anyway.

incredible 04-02-2004 01:27 PM

Quote:

Originally Posted by cweb
My final CQ was still low (around 34) so I just went for a higher CQ anyway.

Thats cause of interlacing encoding! Interlaced mpeg2 needs much more bitrate!

Peter1234 04-02-2004 07:31 PM

The following

Kwag_MA()

was used in palce of

SeparateFields()
odd=SelectOdd().Kwag_MA()
even=SelectEven().Kwag_MA()
Interleave(even,odd)
Weave()

in my corrected script above to produce an output file using Kwag's original script at CQ70 (from an interlaced DV test clip). This file was then compared to a file generated using CQ70 and the corrected scrlpt above. Both files looked the same visually to my non-expert eyes, but the file generated using separated fields was 5.7% smaller. My conclusion is that it is better to use the script with separated fields for interlaced inputs. I assume that this is because the 1/2 frame image from separated fields is smoother since it does not have the inconsistencies between adjacent rows that the non-separated full frame has and therefore can be compressed using less bits. But, I am not an expert. Does that seem reasonable to anyone else?

Dialhot 04-02-2004 08:03 PM

Quote:

Originally Posted by Peter1234
I assume that this is because the 1/2 frame image from separated fields is smoother since it does not have the inconsistencies between adjacent rows that the non-separated full frame has and therefore can be compressed using less bits. But, I am not an expert. Does that seem reasonable to anyone else?

I think the reason is elsewhere : the "YDifferenceToNext" can't work correcly when "next frame" is in fact "half frame from current frame + half frame from next frame" (that is what interlacing is, isn't it ?).

Thus, the MA part of the script is less efficient.

Peter1234 04-02-2004 09:08 PM

Dialhot,
I think you must be correct. My theory does not make sense because the fields are recombined again before encoding. Therefore the difference must be something in Kwag's MA script. Thanks for your answer.

kwag 04-02-2004 09:13 PM

The MA script, as is, was never intended for interlaced sources :!:

-kwag

Peter1234 04-02-2004 09:46 PM

Kwag,
Doesn't separating the fields get around the problems MA has with interlaced sources? With separated fields, doesn't the MA script only see non-interlaced source and so it be happy?

kwag 04-02-2004 10:04 PM

Yes, but fields are different, and the encoder will see artifacts (jagged lines, etc.). So the results will be a mess :!:

-kwag

incredible 04-03-2004 07:36 AM

The problem with separate fields is the "temporalSmoother" and also teh Temporal component of StmedianFilter(xx,1,1)! Means ... by just separating the fields, the temporal radius "reference" would just compare to the next field which isnt correct .... he should compare with every second field.

Thats why boulder posted some time ago the MA-interlaced modding .. where fields will be treated by selectodd/seelecteven and afterwards being interleaved.

Peter1234 04-03-2004 02:47 PM

incredible,
I thought what I posted was just another version of that, at least that was the intent. Apparently, Kwag is saying that is still not a good thing to do. Am I missing something?


All times are GMT -5. The time now is 12:06 PM  —  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.