Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

 
Filter Factory, Any language description
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
Cybermaus
Posted: Sep 2 2002, 06:50 AM


Unregistered









Hi there,

it being a long time since I programmed Windows, and lacking the Visual C++ product, I recently discovered Avery's "Filter Factory" . I actually managed to program a fairly decent "Subtitle locator and remover" filter in there.

But with no discription of the language, it is very hard. I never did manage to get the scan statement to work, and any variable set inside a for-loop seems to loose the content.

I got it to work, eventually, and I will try and find Visual C++, but does anyone have any docs or examples for the filter factory?

Cybermaus
 
  Top
avih
Posted: Sep 2 2002, 04:16 PM


Unregistered









iird, there's a sample filter that u can modify. (included with the filter sdk)
 
  Top
Cybermaus
Posted: Sep 2 2002, 08:30 PM


Unregistered









No there is not. The Filter SDK has an very understandable example how to program a real filter. And I will put that example to good use.

However, I was asking if anyone has any documentation about the "Filter factory" filter. The one that uses pseudo C without compiling. I found no example of that in the SDK.

So I repeat the question: Anyone has any documentation or examples for the "Filter factory" filter?
 
  Top
phaeron
Posted: Sep 4 2002, 04:04 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



Uh, well, you asked for it:

valid expression tokens:
+ add
- subtract, unary negation
* multiply
/ divide
~ unary bitwise invert
& bitwise and
| bitwise or
^ bitwise xor
< less than compare
> greater than compare
<= less-equal compare
>= greater-equal compare
== equality compare
!= inequality compare
&& logical and
|| logical or
++ preincrement, postincrement
-- predecrement, postdecrement
<< shift left
>> arithmetic shift right
>>> logical shift right
.r red channel extraction/insertion operator
.g green channel extraction/insertion operator
.b blue channel extraction/insertion operator
.w bitmap width operator
.h bitmap height operator
in scan source operator
out scan destination operator
#rrggbb constant pixel

ratty BNF-style grammar:

filter := function-def*
function-def := ('void' | type) function-name '(' formal-parameters ')' '{' statement* '}'
formal-parameters := formal-parameter | formal-parameters ',' formal-parameter
formal-parameter := type parameter-name
type := 'int' | 'pixel32' | 'pixel64' | 'bitmap'
statement := '{' statement* '}'
| 'scan' '(' bitmap-exp ')' statement /* scan using one bitmap as both in and out */
| 'scan' '(' bitmap-exp ',' bitmap-exp ')' statement /* scan over two bitmaps, one in and one out */
| 'if' '(' cond-exp ')' statement
| 'if' '(' cond-exp ')' statement 'else' statement
| 'while' '(' cond-exp ')' statement
| 'do' statement 'while' '(' cond-exp ')' ';'
| 'for' '(' statement_opt ';' statement_opt ';' statement_opt ')' /* regular C-style for statement */
| 'return' exp ';'
| type (id ',')* id ';' /* regular variable declaration */
| expression
| ';'

As you can see, the filter factory is very hard to use if you don't already know C. (It is, in fact, my first compiler.) Also, I think the version on my website
might be old and have some code generation bugs in it -- I need to update it. Drop me an email if you want the updated version.

 
    Top
Cybermaus
Posted: Sep 4 2002, 07:17 AM


Unregistered









Thanks.

actually, most of what is below I already had from the filter-factory-source. I was hoping for more, I guess, like a way to get X and Y automatically set inside the scan. But it is as basic as it seems.

Still, a nice piece of work. Takes me back to school, I had to write a compiler/parser then too. Don't think I could do it now.

Maybe you will find this low-priority, because I do not think many people use the factory, and I have my Visual C++ in back-order too, but I have some problems to report. Maybe you want to look at it, just for sake of getting the technology to work. (I am guessing that was a big drive in making the factory anyway.)
CODE

void run(bitmap dst, bitmap src) {
  int x, y;

  scan(dst, src) {
     out = ~in;
  }

  for (x=100; x<100; x++) for (y=100; y<100; y++) {
     dst[x,y]= src[x,y];
  }
}

CODE

void run(bitmap dst, bitmap src) {
  int x, y;

  scan(dst, src) {
     out = ~in;
  }

  x= 100;
  do {
     y=100;
     do {
        dst[x++,y++] = src;
     } while (y<100);
  } while (y<100);
}

Both above sources, to all my knowledge, should draw a 100by100 box non-inverted box on the screen. But they do not.
CODE

void run(bitmap dst, bitmap src) {
  int x, y, w, h;

  w= src.w;
  h= src.h;

  for (x=1; x<=w; x++) for (y=1; y<=h; y++) {
      dst[x,y]= src[x,y];
  }
}

Should the above source not "compile"? It tells me .w and .h are not possible.

In any case, I managed to work around the above, and some more issues. Look at it at your conveniance.

 
  Top
phaeron
Posted: Sep 15 2002, 10:27 PM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



Oops.... you can't use .w and .h because they aren't in the copy you have. Also, IIRC, one of the code generation errors is that everything after a scan() statement is dropped.

Realistically, the filter factory is too low-level for what it is supposed to do -- it really needs to be a matrix-oriented language like Matlab, where subrectangle extraction, assignment, and convolution are basic language primitives. Having stronger primitives also eliminates the need for a complex code generator; the factory is slow because it interprets unoptimized bytecode.
 
    Top
SynchronousArts
Posted: Sep 17 2002, 09:03 PM


Unregistered









QUOTE (phaeron @ Sep 15 2002, 02:27 PM)

Realistically, the filter factory is too low-level for what it is supposed to do -- it really needs to be a matrix-oriented language like Matlab, where subrectangle extraction, assignment, and convolution are basic language primitives. ...

How about Octave, a Matlab like math tool that is under the GPL?
 
  Top
phaeron
Posted: Sep 18 2002, 03:26 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



Probably not specialized enough for video -- most algorithms don't need pixels stored as three doubles (that's 24 bytes, not bits!). The last time I used MATLAB for processing images, it took several seconds per image. In my book, that's somewhere between annoying and unusable. There's a reason why as many filters are hard-coded and hand-coded in VirtualDub as they are -- I hate waiting.
 
    Top
SynchronousArts
Posted: Sep 19 2002, 01:48 AM


Unregistered









QUOTE (phaeron @ Sep 17 2002, 07:26 PM)
Probably not specialized enough for video -- ...

I agree, Double Precision Floating Point Calculations are more than overkill for 8 bit RGB or YUV Processing. I should have explained more i guess, if someone were to write Filter Factory 2, it might be worth looking at Octave as a guide to writing a Matlab style script processing engine. I'm not a programmer so i don't know the real issues involved, it was just a thought.

About 5 years ago i also did some processing with v4 Matlab and it was very very slow and used up all of the 64 MB of RAM in the system i was using, causing even more slowdown with virtual memory in the mix.
 
  Top
Cyberman
Posted: Jul 26 2003, 12:12 PM


Advanced Member


Group: Members
Posts: 2035
Member No.: 3477
Joined: 3-April 03



QUOTE (phaeron @ Sep 15 2002, 11:27 PM)
Oops.... you can't use .w and .h because they aren't in the copy you have. Also, IIRC, one of the code generation errors is that everything after a scan() statement is dropped.

Realistically, the filter factory is too low-level for what it is supposed to ...

Well, sorry to revive a long-dead thread, but - is there ever going to be an update on the Filter Factory?
Although it is quite hard to use, it still is useful. - Better than nothing, IŽd say.
I donŽt want to write a real filter(not yet anyway), so Filter Factory is just what I need.

--------------------
Matroska/MKV ?
 
    Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
9 replies since Sep 2 2002, 06:50 AM Track this topic | Email this topic | Print this topic

<< Back to VirtualDub Development Forum