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 Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd August 2005, 13:07   #21  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
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
left kernel, or more exactly the right one. First one would be sufficient (and faster), me thinks.
__________________
- 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.
Didée is offline   Reply With Quote
Old 23rd August 2005, 19:48   #22  |  Link
Manao
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 )
You will find it here

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.
Manao is offline   Reply With Quote
Old 23rd August 2005, 21:16   #23  |  Link
kassandro
Registered User
 
Join Date: May 2003
Location: Germany
Posts: 502
Quote:
Originally Posted by Didée
Okay ... here my little suggestion for inpand and expand:

As noted, it would be nice to have the possibility to in/expand only horizontally, or only vertically. When working e.g. with comb masks, or horizontal-only/vertical-only edgemasks, the advantages are obvious.

Plus there's one thing more behind it. When internal code for one-dimensional in/expanding is available, then an additional operation could be implemented: a merging of [normal expand] + [horizontal+vertical expand].
Why? to get "round corner" expanding. Currently, a chain of 10*expand() will turn e.g. a point into a 21*21 square. With "round corner" expanding, one would get a circle of diameter 21. There are cases where this would be desireable, because the "distance" of the filtering is of equal length in all directions, then. For simple expanding, there is a distance deviation of sqrt(2) - - too long in diagonal direction.
The following filters can be implemented:
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")
Here Yshape is a string containing pairs of numbers describing a shape. This shape is then translated from (0,0) to any point in the frame, then for each point the maximum over the translated shape is taken to calculate the pixel values of ShapeMax. ShapeMin and ShapeAverage are similar. Of course, for pixels near the boundary not all points of the translated shift are inside the frame. Execution time increases linearily with the number of points of the shape.
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)
which returns a shape string for a circle with radius R.
kassandro is offline   Reply With Quote
Old 24th August 2005, 06:51   #24  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
oooh, that looks interesting. i spy a bokeh-blur filter coming
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 25th August 2005, 20:27   #25  |  Link
Manao
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
As you can see, lots of fixing. My bad...
Manao is offline   Reply With Quote
Old 25th August 2005, 21:35   #26  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
what about adding support for infix expressions instead of only the reverse polish notation?
tsp is offline   Reply With Quote
Old 25th August 2005, 21:48   #27  |  Link
mg262
Clouded
 
mg262's Avatar
 
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.
mg262 is offline   Reply With Quote
Old 25th August 2005, 22:10   #28  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Quote:
what about adding support for infix expressions instead of only the reverse polish notation?
Make the parser and the expression builder, i'll include it. But i'll keep using reverse polonese, i don't like parenthesis that much

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.
Manao is offline   Reply With Quote
Old 25th August 2005, 22:37   #29  |  Link
kassandro
Registered User
 
Join Date: May 2003
Location: Germany
Posts: 502
Quote:
Originally Posted by Manao
Make the parser and the expression builder, i'll include it. But i'll keep using reverse polonese, i don't like parenthesis that much
Avisynth has already a C like expression parser (with brackets, of course). Thus, if YV12LUTxy is incorporated into the Avisynth core, then we could use this expression parser to fill the LUTs. Then I could become a lutmaniac as well. The inverse polish notation really drives me nuts.
kassandro is offline   Reply With Quote
Old 25th August 2005, 22:45   #30  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
Quote:
Originally Posted by Manao
Make the parser and the expression builder, i'll include it. But i'll keep using reverse polonese, i don't like parenthesis that much
Sure I will do that. BTW is your favorit calculator a Hewlett Packard
tsp is offline   Reply With Quote
Old 25th August 2005, 22:53   #31  |  Link
mg262
Clouded
 
mg262's Avatar
 
Join Date: Jul 2003
Location: Cambridge, UK
Posts: 1,148
This is a very quick way to build a parser:

http://www.boost.org/libs/spirit/doc/introduction.html
__________________
a.k.a. Clouded. Come and help by making sure your favourite AVISynth filters and scripts are listed.
mg262 is offline   Reply With Quote
Old 26th August 2005, 07:04   #32  |  Link
Manao
Registered User
 
Join Date: Jan 2002
Location: France
Posts: 2,856
Alpha 4

Changelog ( short )
Code:
 * added : custom modes for inpand / expand
Edit : boost is great, but I did write my reverse polonese 'parser' faster than I failed my attempt to compile spirit. And i don't even want to think at the time the project will take to compile if i use spirit as a parser.

Last edited by Manao; 26th August 2005 at 07:06.
Manao is offline   Reply With Quote
Old 26th August 2005, 09:14   #33  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
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.
Didée is offline   Reply With Quote
Old 26th August 2005, 09:19   #34  |  Link
Manao
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"))
Manao is offline   Reply With Quote
Old 26th August 2005, 11:18   #35  |  Link
Leak
ffdshow/AviSynth wrangler
 
Leak's Avatar
 
Join Date: Feb 2003
Location: Austria
Posts: 2,441
Quote:
Originally Posted by Manao
polonese
You keep using this word... are you sure it means what you think it means?

Polonese vs. RPN

*grins, ducks & runs*
Leak is offline   Reply With Quote
Old 26th August 2005, 11:26   #36  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
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
Mug Funky is offline   Reply With Quote
Old 26th August 2005, 13:13   #37  |  Link
kassandro
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
A prefix parser would have been almost as easy to implement, but much more brain friendly. On the other hand infix is really the way to go.
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.
kassandro is offline   Reply With Quote
Old 26th August 2005, 20:30   #38  |  Link
tsp
Registered User
 
tsp's Avatar
 
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;
}
tsp is offline   Reply With Quote
Old 26th August 2005, 20:36   #39  |  Link
mg262
Clouded
 
mg262's Avatar
 
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.
mg262 is offline   Reply With Quote
Old 26th August 2005, 20:47   #40  |  Link
tsp
Registered User
 
tsp's Avatar
 
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.
tsp 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 21:28.


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