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.

Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development
Register FAQ Today's Posts Search

Reply
 
Thread Tools Search this Thread
Old 22nd March 2004, 22:19   #1  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 541
can a filter return a value to the script?

Hello,

is it possible, that a filter returns a value to a script?
I'd like to code a keyframe-filter (with GUI) so you can set marks in the video (keyframes=KF). For every KF you can choose a filtersetting (=the value will be returned)

example:
i set two KF at frame 200 and 500 (clip is 1000f long):

KF1: frame=200, filtersetting 1
KF2: frame=500, filtersetting 2

my script:
Quote:
clip=AVISource("movie.avi")
setting=Keyframefilter(clip,"Keyframelist.txt",s0="do nothing",s1="blur",s2="sharpen")
if (setting=00) then v=clip
if (setting=01) then v=clip.blur(1.0)
if (setting=02) then v=clip.sharpen()
return v
So:
frame [000 - 199] stay untouched
frame [200 - 499] get blured
frame [500 - end] get sharper

hanfrunz
hanfrunz is offline   Reply With Quote
Old 22nd March 2004, 22:21   #2  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
ConditionalReader should do half of what you want.

ConditionalFilter should do the other half.
Code:
v = Xsource()
blurred = blur(v,1.0)
sharpened = blur(v,-1.0)
conditionalfilter(v,blurred,v,"blurmode", "=", "1")
conditionalfilter(last,sharpened,last,"blurmode", "=", "2")
conditionalreader("blursettings.txt", "blurmode")
blursettings.txt:
Code:
type int
default 0
R 200 499 1
R 500 1499 2
__________________
Regards, sh0dan // VoxPod

Last edited by sh0dan; 22nd March 2004 at 22:31.
sh0dan is offline   Reply With Quote
Old 22nd March 2004, 22:33   #3  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 541
okay i have to do the textfile thing...
mmh then my filter could generate a complete script.

maybe possible in a new version ?

hanfrunz
hanfrunz is offline   Reply With Quote
Old 22nd March 2004, 22:42   #4  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
... but doesn't it do exactly what you describe?
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 22nd March 2004, 22:49   #5  |  Link
hanfrunz
Registered User
 
hanfrunz's Avatar
 
Join Date: Feb 2002
Location: Germany
Posts: 541
yes of course it does, but will i see the changes immediately, when i shuttle through the video? Mmh is this done with my first idea? Or is it possible to put a avisynth-script in a filter (like in ffdshow)?

That would be interesting...
hanfrunz is offline   Reply With Quote
Old 5th April 2004, 05:51   #6  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,182
I have similar question.
Can a one filter (my own source) get some info about every frame from other my filter (or other instance of first filter)?
Not through a file.
Fizick is offline   Reply With Quote
Old 5th April 2004, 16:08   #7  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
@Fizick

You can code filters so one will directly (ie without script knowledge) get info from another one you made.
Bidoche is offline   Reply With Quote
Old 5th April 2004, 18:55   #8  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,182
I can... Good.
But how? any example or MORE detailed info, please.
Fizick is offline   Reply With Quote
Old 6th April 2004, 09:12   #9  |  Link
Si
Simply me
 
Si's Avatar
 
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
Have a look here

neuron2 invented a system for his Decomb package and I've also copied it for PFR to pass info to KernelDeInt.

All code is available at our sites.

regards

Simon
Si is offline   Reply With Quote
Old 6th April 2004, 14:16   #10  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
@Fizick

Neuron2 uses extra space in frame buffer to hold his own data, ... as a workaround for the lack of frame properties.
It works fine as long as there is no filter between which may alter your metadata. (Filters are NOT required to leave the extra space alone, and in fact they often write on it)

If that restriction is unacceptable to you, you can do it like this : (STL code)
Code:
#include <map>     //for map
#include <string>  //for string
#include <utility> //for pair

class InterrogatedFilter
{

  typedef std::map<pair<IScriptEnvironment *, std::string>, Clip *> InstanceMap;

  static InstanceMap map_;

  InterrogatedFilter(std::string const& identif, IScriptEnvironment *env) 
  {
     map_[ std::make_pair(env, identif) ] = this;  //reg self into map
  }

  ~InterrogatedFilter()
  {
     for(InstanceMap::iterator it = map_.begin(); it != map_.end(); ++it )
       if ( it->second == this )
       {
         map_.erase(it);
         break;
       }
     //remove the entry corresponding to this from the instance map
  } 

  static PClip FindInstance(std::string const& identif, IScriptEnvironment *env)
  {
    InstanceMap::iterator it = map_.find( std::make_pair(env, identif) );
    return it != map.end() ? PClip(it->second) : PClip();
  }

  //Clip methods and interrogation methods ....

};//InterrogatedFilter


class InterrogatingFilter
{
  //use InterrogatedFilter::FindInstance somewhere to fetch the (right) clip to interrogate...
  //that means you must have the same identif value here to use
};
NB: this is not perfect (not thread safe for example)
Bidoche is offline   Reply With Quote
Old 6th April 2004, 18:56   #11  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,182
Thanks!
I shall try that strange method.

Corrected: methodS.

Last edited by Fizick; 7th April 2004 at 21:19.
Fizick is offline   Reply With Quote
Old 7th April 2004, 15:19   #12  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
Well, I would have called using an instance map a classic solution.

Anyway, if you have trouble doing that, feel free to ask.
Bidoche is offline   Reply With Quote
Reply


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 20:27.


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