Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 3rd December 2008, 16:48   #1021  |  Link
halsboss
likes to tinker
 
Join Date: Jan 2004
Location: girt by sea
Posts: 635
Hmm, no success until I tried L6 and L7 - both of which work whereas L4 and L5 don't. Not sure why.
Code:
SetMTmode(mode=5,threads=1) # start with mode=5 forAVIsource http://forum.doom9.org/showthread.php?p=1067216#post1067216 
SetMemoryMax(256)  
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-xxx\AGC.dll")  
AviSource("G:\HDTV\capt\capt-type1.08-11-30_20-39.00.avi", audio=false) 
AssumeFPS(25) 
AssumeBFF()  

original=LAST
#L1 = original.SeparateFields().HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0).Weave()
#L2 = original.MTi("HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0)")
#L3 = original.SeparateFields()
#L3e = L3.SelectEven().AGCiEmbedded()
#L3o = L3.SelectOdd().AGCiEmbedded()
#L3 = Interleave(L3e,L3o).Weave()
#L4 = original.MTi("AGCiEmbedded()")
#L5 = original.MTi("Gavino()")
#L6 = original.AssumeBFF().MTi("Gavino()")
L7 = original.AssumeBFF().MTi("AGCiEmbedded()")
#L1
#L2
#L3
#L4
#L5
#L6
L7

function Gavino(clip srcclp) { 
   return srcclp.HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0) 
}
function AGCiEmbedded(clip srcclp) { 
   inpclp = srcclp 
   # other processing
   inpclp=inpclp.HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0) 
   return inpclp 
}
halsboss is offline   Reply With Quote
Old 3rd December 2008, 18:00   #1022  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,406
Curiouser and curiouser. In principle, they should all behave the same.

Perhaps it's a threading/timing problem within MTi.
Gavino is offline   Reply With Quote
Old 4th December 2008, 07:50   #1023  |  Link
halsboss
likes to tinker
 
Join Date: Jan 2004
Location: girt by sea
Posts: 635
this works too
Code:
original=LAST.assumebff()
L8 = original.MTi("AGCiEmbedded()")
L8
halsboss is offline   Reply With Quote
Old 4th December 2008, 12:04   #1024  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,406
And is the failure always the same - 'Invalid arguments to function "HDRAGC" '?

That suggests that 'srcclp' is not a clip, but if that's the case I would expect 'Invalid arguments to function AGCiEmbedded' instead and the function would never be called.

What happens if you replace HDRAGC by something else?
(Perhaps even a dummy function with the same interface.)

I suspected a threading problem but I have had a quick look at the source code of Mti and it looks like this bit (setting up the parallel filter chains) is single-threaded. Can anyone familiar with the internal workings of MT shed some light on what is going on?
Gavino is offline   Reply With Quote
Old 4th December 2008, 14:05   #1025  |  Link
halsboss
likes to tinker
 
Join Date: Jan 2004
Location: girt by sea
Posts: 635
Quote:
Originally Posted by Gavino View Post
And is the failure always the same - 'Invalid arguments to function "HDRAGC" '?
yes, it is.

It sort of seems like minor data corruption or omission about remembering xFF setting when a clip variable hasn't had an explicit AssumexFF() and when it gets fed into MTi. When a clip variable has an AssumexFF() applied to it, then it seems to follow though into MTi OK.
halsboss is offline   Reply With Quote
Old 4th December 2008, 18:41   #1026  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
What if you remove this first line:
SetMTmode(mode=5,threads=1)
?
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 4th December 2008, 22:08   #1027  |  Link
seggitek
Interested Newbie
 
Join Date: Jun 2007
Location: Sopron, Hungary
Posts: 37
Quote:
SetMTMode() place this at the first line in the avs file to enable temporal (that is more than one frame is processed at the same time) multithreading. MTi() that creates two threads and let each thread process one frame before interleaving them.
Does this mean that MTi is the same as SetMTMode(..., threads=2) with the only difference that MTi enables mutlithreading only for the filter passed to it?

Quote:
MTsource() that are used to run source filters multithreaded.
What are source filters?
seggitek is offline   Reply With Quote
Old 4th December 2008, 22:40   #1028  |  Link
thetoof
Sleepy overworked fellow
 
Join Date: Feb 2008
Location: Maple syrup's homeland
Posts: 933
Quote:
Originally Posted by seggitek View Post
What are source filters?
Avisource, mpeg2source, whateversource
__________________
AnimeIVTC() - v2.00
-http://boinc.berkeley.edu/-
Let all geeks use their incredibly powerful comps for the greater good (no, no, it won't slow your filtering/encoding :p)
thetoof is offline   Reply With Quote
Old 5th December 2008, 00:32   #1029  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,406
Quote:
Originally Posted by seggitek View Post
Does this mean that MTi is the same as SetMTMode(..., threads=2) with the only difference that MTi enables mutlithreading only for the filter passed to it?
No.

SetMTMode: more than one frame is processed at the same time.

MT/MTi: different parts of the same frame are processed at the same time (and then joined together).
Gavino is offline   Reply With Quote
Old 5th December 2008, 16:00   #1030  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,406
@halsboss

Can you consistently reproduce your problem?
I tried (using the latest MT and special Avisynth) and was unable to do so. Everything worked as it should.

Is it possible that your failures were done with the function having an optional clip parameter?
Code:
function AGCiEmbedded(clip "srcclp") { ...
That would be an inappropriate function to pass to MTi and would produce the error you saw.
Gavino is offline   Reply With Quote
Old 5th December 2008, 22:56   #1031  |  Link
halsboss
likes to tinker
 
Join Date: Jan 2004
Location: girt by sea
Posts: 635
Hi and thanks for looking at it. Post 1021 http://forum.doom9.org/showpost.php?...postcount=1021 was a snipped version of the the actual script, no quotes in
Code:
function AGCiEmbedded(clip srcclp) {
It was consistently reproducible across reboots. It's a .DV source, and the latest ffdshow codec although that shouldn't make any difference. Avisynth v 2.57 tsp MT version 5, build:Mar 1 2007. No special s/w, a fairly clean PC with the latest h/w drivers and all MS patches and Trend 2008 internet security, I'm not one for installing a lot of junk How can I edit out a 1-sec part of the .AVI to load that too ?

I'll check on the latest download of HDRAGC and try it again.

Last edited by halsboss; 5th December 2008 at 23:15.
halsboss is offline   Reply With Quote
Old 5th December 2008, 23:24   #1032  |  Link
halsboss
likes to tinker
 
Join Date: Jan 2004
Location: girt by sea
Posts: 635
That's got me. It failed across reboots then. Now the script below works !! And it looks the same to me as the above. Nothing changed in the meantime except that Trend internet security updated itself and I had to recreate the script below.

I guarantee that I swapped back and forth between L5,L6 and L7,L8 etc a number of times to check it and got the error in one and not the other. I'l terribly upset about it.

Code:
SetMTmode(mode=5,threads=1) # start with mode=5 forAVIsource http://forum.doom9.org/showthread.php?p=1067216#post1067216 
SetMemoryMax(256)  
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins-xxx\AGC.dll") 
AviSource("G:\HDTV\capt\capt-type1.08-11-30_20-39.00.avi", audio=false) 
AssumeFPS(25) 
AssumeBFF()  
original=LAST

#L1 = original.SeparateFields().HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0).Weave()
#L2 = original.MTi("HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0)")
#L3 = original.SeparateFields()
#L3e = L3.SelectEven().AGCiEmbedded()
#L3o = L3.SelectOdd().AGCiEmbedded()
#L3 = Interleave(L3e,L3o).Weave()
#L4 = original.MTi("AGCiEmbedded()")
L5 = original.MTi("Gavino()")
#L6 = original.AssumeBFF().MTi("Gavino()")
#L7 = original.AssumeBFF().MTi("AGCiEmbedded()")
#original=LAST.assumebff()
#L8 = original.MTi("AGCiEmbedded()")
#L1
#L2
#L3
#L4
L5
#L6
#L7
#L8

function Gavino(clip srcclp) { 
   return srcclp.HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0) 
}
function AGCiEmbedded(clip srcclp) { 
   inpclp = srcclp 
   # other processing
   inpclp=inpclp.HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=0.75, corrector=0.8, reducer=2.0, black_clip=1.0) 
   return inpclp 
}

Last edited by halsboss; 5th December 2008 at 23:58.
halsboss is offline   Reply With Quote
Old 6th December 2008, 00:05   #1033  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,406
Quote:
Originally Posted by halsboss View Post
That's got me. It failed across reboots then. Now the script below works !! And it looks the same to me as the above. Nothing changed in the meantime except that Trend internet security updated itself and I had to recreate the script below.
If you're quite sure about that, then it looks like the worst sort of bug - a randomly occurring one.
Memory corruption, uninitialised data, timing dependency, etc.

I doubt that the nature of your source file or even the version of HDRAGC is a factor, since the error in question is produced at 'compile-time' by the Avisynth script interpreter (no frames have yet been requested) and the evidence suggests it never gets as far as entering HDRAGC.

The problem possibly lies in the modifications to the parser for the MT version of Avisynth. Did you try Fizick's suggestion of removing SetMTMode altogether?
Gavino is offline   Reply With Quote
Old 6th December 2008, 00:54   #1034  |  Link
halsboss
likes to tinker
 
Join Date: Jan 2004
Location: girt by sea
Posts: 635
Yes, I am sure. I really can't believe it. I'll be testing it every day for a while. I'll try the setmtmode removal and see what happens. Next time I have an anomalous encounter I'll test it out on a second PC.

EDIT tried with and without setmtode, all works fine every time. Still can't believe it.

Last edited by halsboss; 6th December 2008 at 04:00.
halsboss is offline   Reply With Quote
Old 6th December 2008, 20:06   #1035  |  Link
seggitek
Interested Newbie
 
Join Date: Jun 2007
Location: Sopron, Hungary
Posts: 37
Quote:
Originally Posted by Gavino View Post
No.

SetMTMode: more than one frame is processed at the same time.

MT/MTi: different parts of the same frame are processed at the same time (and then joined together).
Are you sure? The first page says "MTi() that creates two threads and let each thread process one frame before interleaving them. ".
seggitek is offline   Reply With Quote
Old 6th December 2008, 21:03   #1036  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,406
Quote:
Originally Posted by seggitek View Post
Are you sure? The first page says "MTi() that creates two threads and let each thread process one frame before interleaving them. ".
No, it says "let each thread process one field before interleaving them", a field of course being half a frame.

MTi is like MT, except that the frames, instead of being split in half vertically or horizontally, are separated into fields.

A very good pictorial description of the differences between SetMtMode and MT can be found here.
For MTi, the picture would be different because of what I just said, but the principle is the same.
Gavino is offline   Reply With Quote
Old 8th December 2008, 09:43   #1037  |  Link
Adub
Fighting spam with a fish
 
Adub's Avatar
 
Join Date: Sep 2005
Posts: 2,686
Okay, I am a little unsure about posting this here, but I have discovered a "bug". The reason I use quotes is I am, again, a little unsure about the circumstances.

I originally discovered it while converting a Blu ray to DVD. I indexed the source m2ts using DGAVCindex, and created an avs file containing this:
Quote:
#setmtmode(2)
avcsource("main movie.dga")
crop(0,140,0,-140)
Spline36resize(720,480)
Notice the comment on setmtmode? This is because, when I uncomment it, and drop the file into MPC, the screen flashes a little green, starts playing the file for around 3 seconds and then I get this:


Two error windows pop up as you can see.

It took a me a little while, but I did narrow it down. It seems the problem lies with DGAVCIndex, and it partner dll. When I load a file indexed with DGAVCindex, and use Setmtmode(), I get the crash. This is immediately apparent when HD material is used.

On SD material, it is a little more isolated, but if you job around on the seek bar, it happens as well.

I do not know the exact cause of the error, or which program is at fault. So I thought I would post it here to start out.

This is on Windows XP SP3 x86, stock Q6600, 4gb ram.
__________________
FAQs:Bond's AVC/H.264 FAQ
Site:Adubvideo
Adub is offline   Reply With Quote
Old 8th December 2008, 14:54   #1038  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,406
Here's an odd thing. Run this script
Code:
function f(clip c) {
  global n = n+1
  return c
}

SetMTMode(1, 3)
global n = 0
BlankClip()
MTi("f()")
Subtitle((string(n))
and you will find that n=4, showing the function f is called four times.

It's not surprising it is called more than once, as that is what MTi() is advertised to do, but I would expect n=2.
The result is independent of the parameters passed to SetMTMode - again, to be expected since MT is documented as always setting MT mode temporarily to 5. But removing the SetMTMode altogether produces the 'expected' result n=2.
(Calling f directly instead of via MTi gives n=1, independent of SetMTMode settings.)

If the MTi line is changed to MT("f()", k) for any integer k, the function is called 2*k times instead of the expected k.

I'm not sure if this is a bug or a feature, but it's certainly surprising.
It may or may not have anything to do with the problem reported by halsboss (post #1021), but at least it shows that strange things can happen with user functions and MT/MTi when SetMTMode is also used.
Gavino is offline   Reply With Quote
Old 8th December 2008, 17:40   #1039  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
Merlin7777,
report to author of avcsource.
Fizick is offline   Reply With Quote
Old 8th December 2008, 20:01   #1040  |  Link
Adub
Fighting spam with a fish
 
Adub's Avatar
 
Join Date: Sep 2005
Posts: 2,686
Okay, I'll send him a PM.
__________________
FAQs:Bond's AVC/H.264 FAQ
Site:Adubvideo
Adub is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:47.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.