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. |
23rd August 2005, 13:07 | #21 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
If the plugin will run faster than above function by the same percentage as your post was shorter than mine, then it's OK
Oh, the longer part was about the Code:
1 2 1 3 4 3 2 2 2 4 4 4 1 2 1 3 4 3
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 23rd August 2005 at 13:10. |
23rd August 2005, 19:48 | #22 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
Code:
Changes from alpha 1 to alpha 2 : * added functions to luts : sin, abs, cos, tan, exp, log, acos, atan, asin * added "vertical", "horizontal" and "both" mode to mt_inpand / mt_expand * added mt_convolution * fixed mt_merge behavior for y, u, v = 2. * added y, u, v = 4, for mt_merge : copy the second clip channel. It's usable for any two clips input filters. * internal changes ( code reorganization ) Didee : weights for morphologic operators won't be implemented ( it would complicate to much the filter, and the speed gain in comparison to other means wouldn't be worth the complication ). Last edited by Manao; 23rd August 2005 at 19:58. |
23rd August 2005, 21:16 | #23 | Link | |
Registered User
Join Date: May 2003
Location: Germany
Posts: 502
|
Quote:
Code:
ShapeMax(clip input, string "Yshape", string "Ushape", string "Vshape") ShapeMin(clip input, string "Yshape", string "Ushape", string "Vshape") ShapeAverage(clip input, string "Yshape", string "Ushape", string "Vshape") While shape strings can be written by hand, it is convenient to have generating function for such strings. It is easy to implement functions like Code:
Circle(R) |
|
25th August 2005, 20:27 | #25 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
New version up : Alpha 3
Changelog : Code:
* Fixed : mt_invert, mt_binarize, mt_lutxy, which weren't working properly anymore * Fixed : offset created by incorrect rounding in mt_convolution * Fixed : mmx version of edges filters ( soft thresholding, and roberts ) * Fixed : mmx version of motion edge ( soft thresholding ) * added : mt_mappedblur |
25th August 2005, 21:48 | #27 | Link |
Clouded
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
|
An alternative is to allow a 256-sized (or 65536-sized) array stuffed inside a AVSValue as an argument... then people could define functions which operated on such arguments to produce new arrays, and you would have the infix "for free".
(I don't particularly want this method... I'm just throwing it in as an idea.)
__________________
a.k.a. Clouded. Come and help by making sure your favourite AVISynth filters and scripts are listed. |
25th August 2005, 22:10 | #28 | Link | |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
Quote:
mg262 : would work, if somebody can overload operators in avisynth script parser, which can't be done without hacking avisynth itself. So won't work. But I liked the idea. Tomorrow morning : custom 'matrices' for inpand / expand. |
|
25th August 2005, 22:37 | #29 | Link | |
Registered User
Join Date: May 2003
Location: Germany
Posts: 502
|
Quote:
|
|
25th August 2005, 22:45 | #30 | Link | |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
Quote:
|
|
25th August 2005, 22:53 | #31 | Link |
Clouded
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
|
__________________
a.k.a. Clouded. Come and help by making sure your favourite AVISynth filters and scripts are listed. |
26th August 2005, 07:04 | #32 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
Alpha 4
Changelog ( short ) Code:
* added : custom modes for inpand / expand Last edited by Manao; 26th August 2005 at 07:06. |
26th August 2005, 09:14 | #33 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
Friends, christmas is very early this year - Very nice stuff. Everything is highly appreciated.
Oh, and I definetly vote for keeping reverse polish notation for the expressions. Working with them IMO is really easy ... and honestly said: a regular expression with 8 nested levels of parantheses, written "in one line", might give way more headaches than reverse polish ...
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 26th August 2005 at 09:22. |
26th August 2005, 09:19 | #34 | Link |
Registered User
Join Date: Jan 2002
Location: France
Posts: 2,856
|
What i'll do once i manage to compile spirit, or if somebody gives me a parser, is to make a filter that converts infix notation to polonese one. So you'll use mt_lut like that : mt_lut(yexpr = ConvertToPolonese("expr"))
|
26th August 2005, 11:26 | #36 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
how about "polish remover"... hehe.
i sorta like inverse-polish too. when you get the hang of it it's quite easy (i never used a hp calculator btw, but they look cool).
__________________
sucking the life out of your videos since 2004 |
26th August 2005, 13:13 | #37 | Link |
Registered User
Join Date: May 2003
Location: Germany
Posts: 502
|
While it is easy to write parsers with postfix notation, Polish notation is against the human brain. Nobody would use Avisynth with scripts like this
Code:
16 8 -8 -32 align true = crop In the early eighties FORTH was regarded as the programming language of the future. It did use postfix notation and never ever a serious application was developed with it. It didn't wonder me at all. |
26th August 2005, 20:30 | #38 | Link |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
Kassandro good to see that I'm not the only one who thinks postfix notation is not the most readable format for humans.
Manao here is a small function you can include in masktools for the infix to postfix conversion: Code:
// ConvertToPostfix Copyright 2005 Tonny Petersen // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit // http://www.gnu.org/copyleft/gpl.html . #include "avisynth.h" #include <string> #include <sstream> #include <stack> using namespace std; AVSValue __cdecl ConvertToPostfix(AVSValue args, void* user_data, IScriptEnvironment* env) { const string numerics("0123456789xy"); string input = args[0].AsString(); string temp; stringstream output; stack<string> stringstack; int pos=0; int lastpos=pos; int poplast=0; while(string::npos!=(pos=input.find_first_of(' ',lastpos))){ temp = input.substr(lastpos,pos-lastpos); lastpos=pos+1; //find right parenthesis while(string::npos !=(pos=temp.find(')'))){ poplast++; temp.erase(pos,1); } //delete spaces and left paranthesis while(string::npos !=(pos=temp.find_first_of("( "))){ temp.erase(pos,1); } //if number output it if(string::npos != (numerics.find_first_of(temp)) ) { if(string::npos != temp.find_first_of("xy")&&temp.length()>1) stringstack.push(temp); else { output<<temp<<" "; } } //else push it else stringstack.push(temp); //pop from stack while(poplast) { poplast--; output<<stringstack.top()<<" "; stringstack.pop(); } } temp = input.substr(lastpos,input.length()-lastpos); //find right parenthesis while(string::npos !=(pos=temp.find(')'))){ poplast++; temp.erase(pos,1); } //delete spaces and left paranthesis while(string::npos !=(pos=temp.find_first_of("( "))){ temp.erase(pos,1); } //if number output it if(string::npos != (numerics.find_first_of(temp)) ) { if(string::npos != temp.find_first_of("xy")&&temp.length()>1) stringstack.push(temp); else { output<<temp; if(stringstack.size()>0) output<<" "; } } //else push it else stringstack.push(temp); //pop all operators from stack while(stringstack.size()) { poplast--; output<<stringstack.top(); if(stringstack.size()>1) output<<" "; stringstack.pop(); } input=output.str(); return env->SaveString(input.c_str(),input.length()); } extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) { env->AddFunction("ConvertToPostfix","s", ConvertToPostfix, 0); return 0; } |
26th August 2005, 20:36 | #39 | Link |
Clouded
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
|
@tsp,
Can I ask how the function deals with precedence?
__________________
a.k.a. Clouded. Come and help by making sure your favourite AVISynth filters and scripts are listed. |
26th August 2005, 20:47 | #40 | Link |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
It don't manao's parser handles that. It just converts the infix expression to a postfix expression. If that was what you meant. Ie
Contverttopostfix("20 + 1 * 10") returns "20 1 10 * +" and it's mf_lut's responsebility to get the right result out of it. Also before each number/x/y there most be a space (except the first character in the string) so "sin( 2 *( 29 + 5)) is okay but "sin(2 *(29 + 5))" is not. |
|
|