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 12th April 2003, 05:04   #61  |  Link
Leuf
Registered User
 
Join Date: Apr 2002
Posts: 67
Code:
SimpleSample::SimpleSample(PClip _child, int _SquareSize, IScriptEnvironment* env) :
GenericVideoFilter(_child), SquareSize(_SquareSize) {
Could someone explain this to a poor C programmer who hasn't learned inheritance? I know enough to know it's inheritance, but the SquareSize(_SquareSize) has me stumped. I just need to understand well enough to add some more arguments, one of which is a string, the rest are all ints.
Leuf is offline   Reply With Quote
Old 12th April 2003, 11:09   #62  |  Link
Si
Simply me
 
Si's Avatar
 
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
Code:
class SimpleSample : public GenericVideoFilter {   
int SquareSize;
string parameter2;

public:
 
SimpleSample(PClip _child,	int _SquareSize,  string _parameter2, IScriptEnvironment* env);
 
SimpleSample::SimpleSample(PClip _child, int _SquareSize, IScriptEnvironment* env) :
	GenericVideoFilter(_child), SquareSize(_SquareSize), parameter2(_parameter2) {
...

AVSValue __cdecl Create_SimpleSample(AVSValue args, void* user_data, IScriptEnvironment* env) {
    return new SimpleSample(args[0].AsClip(),
		 args[1].AsInt(0),
		 args[2].AsString(""),
		 env);  
}


extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env) {
    env->AddFunction("SimpleSample", "c[SIZE]i[PARAM2]s", Create_SimpleSample, 0);

    return "`SimpleSample' SimpleSample plugin";
Should show how to introduce a 2nd parameter.

AFAIK the SquareSize(_SquareSize) is just one of the ways to intialise variables and isn't anything clever or complicated (or how else would I be able to use it )

regards
Simon

Last edited by Si; 12th April 2003 at 11:12.
Si is offline   Reply With Quote
Old 13th April 2003, 11:01   #63  |  Link
Leuf
Registered User
 
Join Date: Apr 2002
Posts: 67
Yep, I figured it out. I just moved the initializing into the constructor, since I have about 15 arguments the line was pretty ungodly.

I think the next logical step for the sample filter would be to modify the existing pixels rather than just overwrite them with a color. Something simple like add 10 to green, iirc the vdub sdk does something like that.
Leuf is offline   Reply With Quote
Old 13th April 2003, 13:24   #64  |  Link
Si
Simply me
 
Si's Avatar
 
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
Quote:
I think the next logical step for the sample filter would be to modify the existing pixels rather than just overwrite them with a color. Something simple like add 10 to green, iirc the vdub sdk does something like that.
Code:
...

if (vi.IsRGB24()) {		

   ...

   //Now enhance the greeness of a square in the middle of the frame

   dstp = dst->GetWritePtr();
   dstp = dstp + (dst_height/2 - SquareSize/2)*dst_pitch;

   for (h=0; h < SquareSize;h++) { 
      for (w = dst_width/2 - SquareSize*3/2; w < dst_width/2 + SquareSize*3/2; w+=3) { 

         *(dstp + w + 1) = max(255,*(dstp + w + 1) + 10); // Increase Green value by 10 limiting it to 255 (assumes src already copied to dst)
     }								
      dstp = dstp + dst_pitch; 
      srcp = srcp+ src_pitch; 
   }
}
(untested)

regards
Simon

Last edited by Si; 13th April 2003 at 13:27.
Si is offline   Reply With Quote
Old 18th April 2003, 00:22   #65  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
@Leuf

In the initialiser list (ie the list between : and { ) you must initialise superclasses (if there are any) and you can initialise members too.
If you don't initialise members there, they are default initialised.
For int and other primitives types, the default init is a no op so it's cost nothing more, but with classes it's generally better to use initialisers.
And sometimes, you have to use them : when the variable is not assignable (ie cannot use = ) like const objects and some objects where copy has no meaning.
Bidoche is offline   Reply With Quote
Old 1st May 2003, 20:29   #66  |  Link
Sigmatador
Guest
 
Posts: n/a
is there a way to add text (debug information) on a PVideoFrame ?
  Reply With Quote
Old 1st May 2003, 21:42   #67  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
The easiest way is to invoke the Subtitle filter.

IIRC the syntax is something like:

PClip result = env->Invoke(child, "Subtitle", AVSValue(text));
return result.GetFrame(n,env);

For more advanced output, have a look at Donalds fast and nice algorithm in Dup and Decomb.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 2nd May 2003, 14:20   #68  |  Link
Sigmatador
Guest
 
Posts: n/a
oki thx ^^ i'll try this.

another (stupid) question:
if i need some operation on 2D-matrix (FFT/iFFT,DCT/iDCT,sum,product)
is there in avisynth some functions for this or do i need to include library (do you know a good one ?)
  Reply With Quote
Old 2nd May 2003, 14:45   #69  |  Link
Bidoche
Avisynth 3.0 Developer
 
Join Date: Jan 2002
Location: France
Posts: 639
There are no such things in avisynth.

You can use boost/uBlas to provide matrix. Only sum and product I fear, you would have to make FFT and DCT yourself.
I don't know of any library who provide those as well.
Bidoche is offline   Reply With Quote
Old 2nd May 2003, 14:51   #70  |  Link
trbarry
Registered User
 
trbarry's Avatar
 
Join Date: Oct 2001
Location: Gainesville FL USA
Posts: 2,092
Quote:
if i need some operation on 2D-matrix (FFT/iFFT,DCT/iDCT,sum,product)
is there in avisynth some functions for this or do i need to include library (do you know a good one ?)
My DctFilter() works by doing an 8x8 DCT, modding the values, and then using iDCT, using functions pilfered from Xvid. So you might use the source as a basis for a new filter. See:

www.trbarry.com/DctFilter.zip (src & dll)

- Tom
trbarry is offline   Reply With Quote
Old 2nd May 2003, 15:41   #71  |  Link
Sigmatador
Guest
 
Posts: n/a
@Bidoche
I wrote the FFT function. it works fine but too sloooowwwww !! (so i didn't start to code the iFFT).
i heard that fftw is a higly optimized FFT library, but i don't undestand how to use it (i started c++ 2days ago... noob inside ^^)

@trbarry
thanks a million ^^

edit1: oops an error:
identifier "_aligned_malloc" is undefined
pWorkArea = (short * const) _aligned_malloc(8*8*2, 128);
edit1b: _aligned_malloc isn't defined in my malloc.h (VCPP6.0 SP5)

edit1c: replaced by malloc(8*8*2) and everythingrules ^^

edit2: oohhh your code is clean, nice to read ^^
edit3: i suppose sse2 optimization is disabled for the same reason than xvid.

Last edited by Sigmatador; 3rd May 2003 at 15:05.
  Reply With Quote
Old 3rd May 2003, 15:08   #72  |  Link
Sigmatador
Guest
 
Posts: n/a
@siwalters
your simplescript is a great educationnal tool ^^. Very easy to learn every colorspaces and spatial filtering.
What about a TemporalSimpleScript ? ^^ (i started to read sansgrip code)
  Reply With Quote
Old 3rd May 2003, 15:27   #73  |  Link
trbarry
Registered User
 
trbarry's Avatar
 
Join Date: Oct 2001
Location: Gainesville FL USA
Posts: 2,092
Quote:
edit1: oops an error:
identifier "_aligned_malloc" is undefined
pWorkArea = (short * const) _aligned_malloc(8*8*2, 128);
edit1b: _aligned_malloc isn't defined in my malloc.h (VCPP6.0 SP5)
I just had that same error when installing VS6 sp5 under on a new XP system. I think it was fixed by also installing the asm processor pack, PP5. It got fixed somehow. ?? Aligned malloc is needed if you do SSE2 specific code which gives errors when things are not 16 byte aligned.

- Tom
trbarry is offline   Reply With Quote
Old 29th May 2003, 10:29   #74  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Have a look at audio.cpp instead.

To make an audio filter, remove the GetFrame part and put in a
void __stdcall YourClass::GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env) function.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 31st May 2003, 03:26   #75  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
_aligned_malloc() is part of the platform SDK.
Guest is offline   Reply With Quote
Old 15th July 2003, 04:22   #76  |  Link
snowmoon
Registered User
 
Join Date: Dec 2002
Posts: 6
Geocities appears to be hating me... I can't download the sample .zip file. * GOT IT - You might want to link it off your site since geocities won't allow direct inking from this site *


Thanks

Last edited by snowmoon; 15th July 2003 at 04:25.
snowmoon is offline   Reply With Quote
Old 16th July 2003, 18:29   #77  |  Link
Si
Simply me
 
Si's Avatar
 
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
@Sigmatador (Sorry didn't realise thread had changed )
I was hoping someone else would do this

@wer
All the main source code is also available via Avisynth.org


regards
Simon
Si is offline   Reply With Quote
Old 9th August 2003, 22:04   #78  |  Link
cudmore
Registered User
 
Join Date: Aug 2003
Posts: 1
more than one clip in a filter ?

All the sample code is very helpful but I would like to write a filter that operates on more than one clip. Something like:

Dissolve(clip clip1, clip clip2 [,...], int overlap)

Does anyone have a pointer to sample code for writing a filter to operate on multiple clips?

I can't seem to be able to figure out how to access more than one clip in the GetFrame() method. All I can find are examples that operate on:

PVideoFrame src = child->GetFrame(n, env);

Where are the other clips when the filter takes multiple clips?

Thanks

Bob Cudmore
cudmore is offline   Reply With Quote
Old 29th August 2003, 00:43   #79  |  Link
Si
Simply me
 
Si's Avatar
 
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
SimpleSample 1.7 (2 clips at once)

@cudmore
I've given it a go and it seems I can get it to work.

So SimpleSample1.7 is available here (need to right-click and download as usual)

I've only modded the YUY2 code (cause 1 - I'm too lazy to do the YV12 and Avisynth doesn't work anymore in RGB on my computer )

regards
Simon
Si is offline   Reply With Quote
Old 18th November 2003, 18:55   #80  |  Link
bkam
Registered User
 
bkam's Avatar
 
Join Date: Nov 2002
Location: London
Posts: 115
I have been looking at this thread, and I am also interested in writing filters. I have very little coding knowledge, however, so little that I don't know how one would even go about compiling / what program to use etc. From what I gather this is C (that's right, I don't even know C, but I am determined). So if someone could tell the tools needed to get started with this (since this is a beginners sticky), it would be really cool, like what programs you are using to compile etc. I hope it doesn't seem pointless to explain if I have never coded anything really, but everyone starts somewhere right? And I have coded assembly language for TI calculators for fun a few years ago, this code looks much nicer than that . But still I am a coding n00b, so any help is appreciated! Thanks!
bkam 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 10:15.


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