PDA

View Full Version : Humbly requested: Filter SDK / Easy filter sample


Belgabor
9th March 2003, 23:59
This is kinda a bump on some facts in this old thread (http://forum.doom9.org/showthread.php?s=&threadid=40106&highlight=avisynth+sdk). So far I wasn't tempted to program a avisynth filter, but now I am ;)

The problem is I can't find an easy to understand sample source for an AviSynth filter, most sources are just too complicated to understand for a video filter programming newbie like me.

What I'm thinking of is a sample working in all colorspaces that manipulates the frame in some simple way (like drawing a centered square on it), perhaps in a future version samples for doing temporal stuff and an source filter.

I also would appreciate being pointed to already existing source code fulfilling this conditions (being simple, but for now YUY2 and YV12 would be enough for colorspaces).

Thanks in advance
Belgabor

Si
10th March 2003, 00:33
If you can wait a few days- I'll write one for you.

I guarantee it will be simple :)

regards

Simon

neuron2
10th March 2003, 00:37
I am so tempted to say "Simple Simon".

Isn't there the Invert sample at avisynth.org, or was it sh0dan's home page? That's where everyone starts. After that, there is SO MUCH source available for study.

Richard Berg
10th March 2003, 05:00
If you want to peek at the implementation of some of the core filters, I'd suggest starting with levels.cpp/h. All the colorspaces are demonstrated* and the algorithms are simple (lookup tables).

*Don't depend on these filters to learn everything, though. There are nuances like RGB being "upside-down" and YV12's alignment issues.

@neuron2 - I think the sample you're referring to is actually still on Ben's page.

trbarry
10th March 2003, 05:10
Belgabor -

Also see the Avisynth 2.5 alpha (http://cultact-server.novi.dk/kpo/avisynth/avisynth_alpha.html) page. This has a link to the converted Invert filter sample source.

- Tom

sh0dan
10th March 2003, 08:39
I put up some stuff (Ben's and my own) on the FilterSDK (http://www.avisynth.org/index.php?page=FilterSDK) page on avisynth.org - you are of course free to ask if you need further information.

Belgabor
10th March 2003, 12:41
Yay! Thanks so much guys. I will look into it when I get back home this evening :)

Si
10th March 2003, 21:39
Here is first one. (available at
http://www.geocities.com/siwalters_uk/simplesample10.zip (please right-click to download from a geocities site) because I seem to have lost the ability/privliges to attach to either this or the Usuage forum :()


All it does is, well, nothing really.

It just takes the input and copies it to the output.

It doesn't work with YV12 but should work with all other colourspaces (cause its so simple :) )

The next one will put a square in the middle!

regards
Simon

sh0dan
11th March 2003, 00:12
Minor plea for change: Move colorspace checks to the constructor:

class SimpleSample : public GenericVideoFilter {

public:
SimpleSample(PClip _child) : GenericVideoFilter(_child);
}

PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};


SimpleSample(PClip _child) : GenericVideoFilter(_child) {
if (vi.IsPlanar()) // is input not planar
env->ThrowError("SimpleSample: input to filter must be in YUY2 or RGB");
}


(Also changed YV12 to planar, so that possible future planar formats also will fail). You should perhaps also do a planar version :)

RGB formats do actually work with the code you've made!

The planar implementation is actually quite easy - you can remove the colorspace check, and do:

[...]
const int dst_pitch = dst->GetPitch();
const int dst_width = dst->GetRowSize();
const int dst_height = dst->GetHeight();
const int src_pitch = src->GetPitch();
const int src_width = src->GetRowSize();
const int src_height = src->GetHeight();

int w, h;

//Copy src to dst
srcp = src->GetReadPtr();
dstp = dst->GetWritePtr();

for (h=0; h < src_height;h++) {
for (w = 0; w < src_width; w++)
*(dstp + w) = *(srcp + w);
srcp = srcp + src_pitch;
dstp = dstp + dst_pitch;
}
// end copy src to dst

const int dst_pitchUV = dst->GetPitch(PLANAR_U);
const int dst_widthUV = dst->GetRowSize(PLANAR_U);
const int dst_heightUV = dst->GetHeight(PLANAR_U);
const int src_pitchUV = src->GetPitch(PLANAR_U);
const int src_widthUV = src->GetRowSize(PLANAR_U);
const int src_heightUV = src->GetHeight(PLANAR_U);

//Copy U plane src to dst
srcp = src->GetReadPtr(PLANAR_U);
dstp = dst->GetWritePtr(PLANAR_U);

for (h=0; h < src_heightUV;h++) {
for (w = 0; w < src_widthUV; w++)
*(dstp + w) = *(srcp + w);
srcp = srcp + src_pitchUV;
dstp = dstp + dst_pitchUV;
}
// end copy src to dst

//Copy V plane src to dst
srcp = src->GetReadPtr(PLANAR_V);
dstp = dst->GetWritePtr(PLANAR_V);

for (h=0; h < src_heightUV;h++) {
for (w = 0; w < src_widthUV; w++)
*(dstp + w) = *(srcp + w);
srcp = srcp + src_pitchUV;
dstp = dstp + dst_pitchUV;
}
// end copy src to dst
[...]


As GetRowSize(PLANAR_U) will return 0 on non-planar images, nothing will be done in these loops, if the image is interleaved (RGB or YUY2).

Si
11th March 2003, 00:43
@sh0dan

Whoa :)

Your code

class SimpleSample : public GenericVideoFilter {

public:
SimpleSample(PClip _child) : GenericVideoFilter(_child);
}

PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};


SimpleSample(PClip _child) : GenericVideoFilter(_child) {
if (vi.IsPlanar()) // is input not planar
env->ThrowError("SimpleSample: input to filter must be in YUY2 or RGB");
}


doesn't compile on my system.
Is it wrong? or is there an problem with my compiler.

I normally put the colourspace code "near the beginning" (my speak for somewhere in the constructor bit :) ) but it wouldn't work with the filter having no parameters :confused: . So I temporarily moved it.

I know it works with RGB :)

I'll stick your code in for YV12 in the next version.

sh0dan
11th March 2003, 08:32
Sorry - a but quick there - env was missing:

public:
SimpleSample(PClip _child, IScriptEnvironment* env);

PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};


SimpleSample::SimpleSample(PClip _child, IScriptEnvironment* env) : GenericVideoFilter(_child) {
if (vi.IsPlanar()) // is input not planar
env->ThrowError("SimpleSample: input to filter must be in YUY2 or RGB");
}


and

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


You know when it is a contructor, because it is called the same as the class you are modifying, and it does return any values (not even void).

Si
11th March 2003, 09:28
@sh0dan
Thanks for correction - maybe you could tell(PM if you want to) me me why we have to have 2 constructor definitions (as least it looks that way to me :confused: ) and why you can get away with 1 in other filters as long as it uses parameters :confused: :confused:

So a version 1.0a incorporating the correct colourspace checking now available at
http://www.geocities.com/siwalters_uk/simplesample10a.zip

regards

Simon

Acaila
11th March 2003, 10:41
Like Belgabor I've also wanted to try my hand at Avisynth filters now and then and like him I've also found it difficult to start because there are hardly any simple examples around.

Now the code that siwalters/sh0dan posted here looks simple enough, but I think what would be useful for a lot of newbie would-be filter writers are comments. And lots of 'em. Mainly why certain things are handled the way they are. Ben's original example is a good one but it only covers a very very small part of Avisynth's internal workings (and I bet a lot of it is outdated by now).

I for one am not very good at reading code and understanding what it does right away yet. So comments would help a lot in understanding.

sh0dan
11th March 2003, 11:45
I put in very detailed comments to the code.
SimpleSample 1.0b (http://cultact-server.novi.dk/kpo/avisynth/SimpleSample10b.zip).

No code changes - only thing changed is two redundant pointer requests where removed.

Acaila
11th March 2003, 12:02
Thank you, sh0dan. This helps a lot :)

Si
11th March 2003, 21:20
@sh0dan
SimpleSample1.0b - Brilliant :D

Do you want to carry on or are you happy for me to do the basics and then you provide the professional touches?

regards
Simon

Si
12th March 2003, 00:11
V1.1 now incorporates sh0dan's planar colourspace code.
Available here
http://www.geocities.com/siwalters_uk/simplesample11.zip


Changelog
Colourspace check removed from constructor as its not needed.

Minor changes to comments (mainly just highlighted the differences between pitch and width.

sh0dan
12th March 2003, 00:22
Nice - nothing to add from here :)

Wilbert
12th March 2003, 10:39
Available here (...)
Results in page not available?

sh0dan
12th March 2003, 11:47
Copy the URL into a new browser window.

Wilbert
12th March 2003, 11:56
:D Thanks!

Si
13th March 2003, 00:19
Here is Version 1.2 which puts a white square in the middle of the frame - wow :)

It reverts to just handling RGB24 colourspace for simplicity.

http://www.geocities.com/siwalters_uk/simplesample12.zip

The next version will have variable parameters and then I'll add in the code for the other colourspaces.

regards
Simon

@Wilbert
Or just right-click and use Save Target As

Leuf
13th March 2003, 07:49
I've written quite a few vdub filters, and I've looked at the avisynth sdk a couple of times and what has me stumped is where are the equivalents to start/end proc that you have in vdub? An example that does some basic buffering would be helpful, specifically as to where should you allocate/free memory.

Si
13th March 2003, 08:56
@Leuf
I asked a very similar question just a few days ago and the answer was that any static variables are defined in the constructor but I'm in the middle of porting my PFR filter and haven't yet debugged it so I can't tell whether I've got it right yet.

Once I have I'll point out how I did it :)

regards
Simon

sh0dan
13th March 2003, 10:35
Added destructor, and some member variables:

class SimpleSample : public GenericVideoFilter {
// SimpleSample defines the name of your filter class.
// This name is only used internally, and does not affect the name of your filter or similar.
// This filter extends GenericVideoFilter, which incorporates basic functionality.
// All functions present in the filter must also be present here.

public:
// This defines that these functions are present in your class.
// These functions must be that same as those actually implemented.
// Since the functions are "public" they are accessible to other classes.
// Otherwise they can only be called from functions within the class itself.

SimpleSample(PClip _child, IScriptEnvironment* env);
// This is the constructor. It does not return eny value, and is always used,
// when an instance of the class is created.
// Since there is no code in this, this is the definition.
~SimpleSample();
// The is the destructor. This is called when the filter is destroyed.

PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
// This is the function that AviSynth calls to get a given frame.
// So when this functions gets called, the filter is supposed to return frame n.

private:
// This is where you put the class variables.
int box_width;
int box_height;
int box_x, box_y;

};

/***************************
* The following is the implementation
* of the defined functions.
***************************/

SimpleSample::SimpleSample(PClip _child, IScriptEnvironment* env) : GenericVideoFilter(_child) {
// This is the implementation of the constructor.
// The child clip (source clip) is inherited by the GenericVideoFilter,
// where the following variables gets defined:
// PClip child; // Contains the source clip.
// VideoInfo vi; // Contains videoinfo on the source clip.
if (!vi.IsRGB24()) // is input not RGB24
env->ThrowError("SimpleSample: input to filter must be in RGB24 colourspace");
}

SimpleSample::~SimpleSample() {
// This is where you can deallocate any memory you might have used.
}

Bidoche
13th March 2003, 10:52
Beware of the confusion between static variables (defined with the word static) and normal member variables.

static variables are kinda global variables, but in the namespace and scope of the class.
They are called static because they don't depend of the existence of class instances to exist.
They always exist and are unique, you write :
myClass::myStaticVar and not MyObject.myVar

You can use static in definition code too, it is used to define vars with global lifetime without worrying about polluting the :: namespace. (don't have to woory about choosing a smart name who won't be confused..)
exemple :
int CallCount() { //named as it does
static int count = 0; //this init is done once at the lodaing of the code
return ++count;
}
This could have been with count global but then it risk external modifications :/
Better programming to limit access to the good guy by putting it in the right place, that's the same idea with static var in class.


As for constructor/destructor its a symetric process.
Constructor builds members, create objects via new (new char[] for memory alloc generally).
Detructor destroys members (implicitly) and delete object created by new.

Btw implicit destuction is much safer :
if the constructor fails due to an exception, construction is ended, all members will be correctly destroyed, but pointers won't be deleted but leaked... :/
If you throw the exception yourself, you may explicitly destroy what must (but it's annoying and you may forget (ie one day you will)).
But if the exception is thrown by a called method (maybe you don't even know it can happen) you are ******.
To avoid that, one can use smart ptr class (who automatically delete the ptr they hold when leaving context) like std::auto_ptr


Edit: crossposted with sh0dan :p

jonny
13th March 2003, 11:04
I think this thread is great for programmers entering in the AviSynth development side for the first time (i'm one of these ^^')

What about make it sticky?

Si
14th March 2003, 01:21
Here is SimpleSample 1.3
http://www.geocities.com/siwalters_uk/simplesample13.zip

It just adds in one parameter to vary the size of the square.
Syntax:
SimpleSample(clip,[size])

I intend to just plod on with now modifying it for extra colourspaces before trying to introduce any advanced stuff about global/static variables, buffering etc - remember, it is called SimpleSample ;)

@shOdan
I've added in the bits from your last post about the destructor but not the private member variables.

The code I've used to use a parameter is a combination of the code I normally use but modified in the light of what I'm learning from this thread about constructors. I'd welcome any comments (to put in a 1.3a version) and real comments to me about the way I've done it,which is just to copy the way I see others have done :o .

@Bidoche
Good information and one day I hope to understand more than the 10% of it that I do at the moment :o

Bidoche
14th March 2003, 12:13
@siwalters

Rome was not built in one day. :p

Btw, maybe you could precise that pitch must always be fetched after the read/write ptr.
I am not totally sure for 2.0/2.5 but in 3.0 a GetWritePtr may reallocate the picture and change the pitch.

sh0dan
14th March 2003, 19:22
Pitch only has to be refreshed after an env->NewVideoFrame().
GetWritePtr() cannot modify pitch in 2.0/2.5!

Si
15th March 2003, 01:57
Oops Bugfix release :o
Version 1.3a available here
http://www.geocities.com/siwalters_uk/simplesample13a.zip

The change is from

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

to

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


The first version worked for some reason but proved to be wrong when I tried modifying it for use with RGB32 :o

regards
Simon

Si
15th March 2003, 03:01
Version 1.4 available here
http://www.geocities.com/siwalters_uk/simplesample14.zip

Simply adds in RGB32 code.

regards
Simon

Si
15th March 2003, 20:08
V1.5 with YUY2 colourspace code - 1 more to go :)

http://www.geocities.com/siwalters_uk/simplesample15.zip

regards

Simon

sh0dan
15th March 2003, 21:34
You could use vi->BytesFromPixels(1) instead of having separate loops for RGB24 and RGB32.
Much cleaner, and demonstrates more of the capabilities IMO.

vhelp
15th March 2003, 22:02
Hi siwalters.. sh0dan and Belgabor and others..

Just wanted to say THANKS for the idea of this thread. Something I've ben
looking for, for a long time.

siwalters, great idea and approach, how you build-on as you go. Nice and
slow. Great! Thanks.
Maybe some day, I'll return w/ a filter or too to share.

Please continue to keep up the good work.
-vhelp

Si
16th March 2003, 09:28
@sh0dan
vi->BytesFromPixels(1) :confused:

So I went looking through the FilterSDK (http://www.avisynth.org/index.php?page=AviSynthTwoFiveSDK) until I found this (http://www.avisynth.org/index.php?page=WorkingWithImages) :)

Is this information/code new to 2.5 or has it always been around? :o

And therefore does it mean there is a GetRowWidth() function that can be called? :o :o :o

And could you give me/us an example of using vi->BytesFromPixels(1) please?

regards
Simon

Bidoche
16th March 2003, 12:23
// This will return the position of the upperleft pixel in YUY2 images,
// and return the lower-left pixel in RGB.

Arghhh... I didn't take this into account in the 3.0 code, and it won't be easily fixed (an ugly hack maybe)
Is it really vital ?

sh0dan
16th March 2003, 12:42
BytesFromPixels(int n) has always been around. Have a look at avisynth.h to see the funtions you can use.

Example (from fliphorizontal)

int bpp = vi.BytesFromPixels(1);
for (int y=0; y<h;y++) { // Loop for RGB and planar luma.
for (int x=0; x<row_size; x+=bpp) {
for (int i=0;i<bpp;i++) {
dstp[x+i] = srcp[-x+i];
}
}
srcp += src_pitch;
dstp += dst_pitch;
}


This is to avoid having separate loops for RGB24, RGB32 and YV12 (YUY2 is different due to the chroma placement).

@Bidoche: RGB is always flipped in AviSynth, and every filter processes it as such.

Bidoche
16th March 2003, 13:47
@sh0dan

Are you saying that it is necessary to be flipped, or that the code update cost will be too much ?

Acaila
16th March 2003, 15:36
Hi,

Something is not entirely clear to me in the following piece of code that deals with YUY2 colorspace.
dstp = dst->GetWritePtr(); // reset the destination pointer to the top, left pixel. (YUY2 colourspace only)
dstp = dstp + (dst_height/2 - SquareSize/2)*dst_pitch; // move pointer to SquareSize/2 lines from the middle of the frame;

int woffset = dst_width/8 - SquareSize/4; // lets precalulate the width offset like we do for the lines.
for (h=0; h < SquareSize;h++) { // only scan SquareSize number of lines
for (w = 0; w < SquareSize/2; w+=1) { // only scans the middle SquareSize pixels of a line
*((unsigned int *)dstp + woffset + w) = 0x80FB80FB; // Set Y1 and Y2 to max, U and V to no colour.
} // LSB = Y1, MSB = V
dstp = dstp + dst_pitch;
}

This is probably a newbie question, but then I am a newbie at coding so I hope you'll forgive me. According to this (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwmt/html/YUVFormats.asp) page Y has a range of 16-235. However to make the square white you're setting it to FB (=251), why aren't you setting it to EB (=235) instead?

Si
16th March 2003, 19:37
Just checking to see that your paying attention :o
(And it shows you can exceed the Y limits without causing an error ;))

Version 1.5a here
http://www.geocities.com/siwalters_uk/simplesample15a.zip

regards
Simon

sh0dan
16th March 2003, 20:37
@Bidoche: The data is flipped on input, and all RGB<->YUV conversion flip the data. So RGB is always flipped internally in AviSynth.

Si
16th March 2003, 23:12
What I'm thinking of is a sample working in all colorspaces that manipulates the frame in some simple way (like drawing a centered square on it)

Done :D
Version 1.6 of SimpleSample here
http://www.geocities.com/siwalters_uk/simplesample16.zip

Thanks to everyone in helping me/us/we in getting there :)

@sh0dan
I didn't do anything with the vi.BytesFromPixels(1) as I haven't got my mind around it yet (being a bit slow and dim :) ) and I deliberately wanted to keep all colourspace code separate.

Now we've done the basic requirement do you (or someone else) want to optimise it?

Or add in some assembler, then MMX then SSE and all those other toyes you clever ones play with :)

regards
Simon

neuron2
17th March 2003, 01:33
Originally posted by siwalters
Or add in some assembler, then MMX then SSE and all those other toys you clever ones play with :)It would then no longer be "SimpleSample". It seems to me you have reached the appropriate stopping point.

Bidoche
17th March 2003, 01:54
A bit unclear to have the four codepaths in one method.
Now maybe the time to replace those ifs by polymorphism


@sh0dan

we can reverse blit on input if we want, will be more consistent and I won't have to do this ***** hack

Richard Berg
17th March 2003, 04:38
@Bidoche -- that would break all filters that currently assume RGB is upside-down. Can you point out where the conflict arises in 3.0?

Bidoche
17th March 2003, 11:27
All GetReadPtr and GetWritePtr simply forward calls to BufferWindow methods of the same name (which returns top left corner).

Change cannot be down at BufferWindow level without ugliness (it doesn't have to know its RGB).
But it should work redefining GetWritePtr and GetReadPtr in the RGBVideoFrame class. (in videoframe.h)

sh0dan
17th March 2003, 18:15
I don't see the problem. The only difference is that the pointer points to lower-left of picture in "screenspace". Bufferwise it looks exactly like YUY2/YV12.
The picture is made the same way as all other - the only difference is that the lowest line is displayed as the upper line.
The pointer will still point to the first byte in the allocated array.

Bidoche
17th March 2003, 20:55
Hum, didn't understand it like that. So there is nothing to change.

And I have found a (minor) problem : if we add an alpha plane to each colorspace (besides rgb32), we won't be able to share it in the copy...

Si
17th March 2003, 22:21
...perhaps in a future version samples for doing temporal stuff ...
Anyone fancy doing this bit then?


Simon

Bidoche
19th March 2003, 00:18
@sh0dan

From the videoframe client perspective, is it a difference between starting at top left with positive pitch and starting at bottom left with a negative pitch ?

If current code can feed from that, RGB don't to have to be really flipped (just appear it is)

sh0dan
19th March 2003, 13:01
Negative pitch is a no-no internally in AviSynth - at least - much assembler would have to be rewritten. Let's just keep RGB bottom-up, with positive pitch - there is no need to make things more complicated than that.

Bidoche
20th March 2003, 22:40
@sh0dan

As expected, it's not possible... :'(

@siwalters

Here is the OOP version I promised...
... in 3.0 style, but besides it allowed me to skip the copy part, it don't change much.


class SimpleSampleParent : public GenericVideoFilter {
public:
SimpleSampleParent(PClip _child, int _SquareSize) : GenericVideoFilter(_child), SquareSize(_SquareSize) { }

virtual CPVideoFrame _stdcall GetFrame(int n)
//in 3.0 there is a distinction from CPVideoFrame and PVideoFrame
//C stands for const, those cannot be modified
{
PVideoFrame frame = chid->GetFrame(n);
//conversion a CPVideoFrame to a PVideoFrame
//does what is needed to allow modifications
//(I can develop if you want)

Process(frame); //call the filling method

return frame; //implicit cast from PVideoFrame to CPVideoFrame
}

protected:
// define the parameter variable
const int SquareSize;

virtual void _stdcall Process(PVideoFrame frame) = 0;

void _stdcall ByteSquareFill(BYTE * dstp, int pitch, int width, int height, BYTE fillPattern)
//method to fill a rect with a BYTE value
//used in RGB and YV12
{
for(int h = height; h --> 0; dstp += pitch)
for(int w = width; w --> 0; )
*(dstp + w) = fillPattern;
}

BYTE * _stdcall FindSquareLeftCorner(PVideoFrame frame, Plane plane, int BpP, int scaleFactor = 1)
{
Byte * result = frame->GetWritePtr(plane);
result += (frame->GetHeight(plane)>>1 - SquareSize>>1/scaleFactor) * frame->GetPitch(plane);
result += frame->GetRowSize(plane)>>1 - SquareSize>>1/scaleFactor * BpP;
return result;
}
};


class SimpleSampleRGB : public SimpleSampleParent {
//no distinction between RGB24 and RGB32
//I fill alpha with 255 too
//if that is unwanted make a special version for RGB32

public:
SimpleSampleRGB(PClip _child, int _SquareSize) : SimpleSampleParent(_child, _SquareSize) { }

protected:
virtual void _stdcall Process(PVideoFrame frame)
{
int BpP = vi.IsRGB32()? 4 : 3;
ByteSquareFill(FindSquareLeftCorner(frame, NOT_PLANAR, BpP), frame->GetPitch(), BpP*SquareSize, SquareSize, 255));
}
};


class SimpleSampleYUY2 : public SimpleSampleParent {
public:
SimpleSampleYUY2(PClip _child, int _SquareSize) : SimpleSampleInterleaved(_child, _SquareSize) { }

protected:
virtual void _stdcall Process(PVideoFrame frame)
{
BYTE * dstp = FindSquareLeftCorner(frame, NOT_PLANAR, 2);
int pitch = frame->GetPitch(NOT_PLANAR);
for(int h = SquareSize; h --> 0; dstp += pitch)
for(int w = SquareSize>>1; w --> 0; )
*((unsigned int *)dstp + w) = 0x80EB80EB;
}
};

class SimpleSampleYV12 : SimpleSampleParent {
public:
SimpleSampleYV12(PClip _child, int _SquareSize) : SimpleSampleParent(_child, _SquareSize) { }

protected:
virtual void _stdcall Process(PVideoFrame frame)
{
static const BYTE fillPatterns[] = { 235, 128, 128 };
static const int scaleFactor[] = { 1, 2, 2 };

for(int i = 3; i --> 0; )
Plane p = VideoFrame::IndexToPlane(i);
int s = scaleFactor[i];
ByteSquareFill(FindSquareLeftCorner(frame, p, 1, s), frame->GetPitch(), SquareSize/s, SquareSize/s, fillPatterns[i]);
}
}
};


AVSValue __cdecl Create_SimpleSample(const vector<AVSValue>& args) {

PClip clip = args[0]; //implicit conversions
int sq = args[1];
switch(clip->GetVideoInfo().GetColorSpace().id)
{
case I_RGB24:
case I_RGB32:
return new SimpleSampleRGB(clip, sq);
case I_YUY2:
return new SimpleSampleYUY2(clip, sq);
case I_YV12:
return new SimpleSampleYV12(clip, sq);
}
}

Si
21st March 2003, 18:55
Very interesting - if only I understood it :o

I had a go at trying to hack it to work in 2.5 but didn't get any where - is it possible to do it?

I mean can it be done at all? (or do you need the 3.0 enviroment to make SimpleSample OOP friendly?)

regards
Simon

Bidoche
22nd March 2003, 01:20
@siwalters

It is possible to do it with 2.5, but the code is longer and I am not as used to it.
And I didn't not wanted to copy the frames by myself (in fact I could have blitted them :p), 3.0 does it automatically (and I like automatic things (if you don't, you should)).

Please point to what you don't understand and I will try to provide explanations (please don't say everything, it won't get us anywhere :p)

Edit:

It occured to me that we can use BitBlit to fill the squares provided we fill a BYTE raw somewhere with the good pattern (and a 0 pitch).
This way RGB and YUY2 can even be more merged together.

Will see it tomorrow, it's getting kinda late here :p

@sh0dan

Please don't tell me 0 pitch is forbidden.

Si
22nd March 2003, 11:42
I won't say everything :o .

I didn't mean to distract you from 3.0 - please just ignore my request.

regards
Simon

Bidoche
22nd March 2003, 12:17
I can do it, no problem.
And besides sometimes I can use the distraction. :)

Bidoche
24th March 2003, 17:05
Well let's do some comments... :)

In the above code, I made two kind of transformations:
- one is the transformation of the original class into a parent class and some subclasses (ie using OOP legacy/polymorphism)
- the other is just a factorisation of the code, with the functions ByteSquareFill and FindSquareLeftCorner(which I am not so happy about it :/).

To perform the first, used the natural colorspace hierarchy :General --- Interleaved --- RGB --- RGB24
\ \ \-- RGB32
\- YV12 \- YUY2I guess everyone will agree that how colorspace are naturally grouped
(sometimes YV12 and YUY2 are better seen siblings but not often)

Looking at your code, you search for similitude :
- RGB24 and RGB32 both fill a memory rectangle with 255, then the fill code can be shared and each just need its own rectangle coordinates calculation .

- YUY2 and RGB (24 & 32) both fill a memory rectangle with a specified pattern (FFFFFFFF for RGB, I forgot for YUY2).
Then if I make sych a method it can be shared (and called by the RGB 255 fill method)

- YV12 fills memory blocks like RGB so I can reuse its method (factorisation)

so you have (in pseudo-code)
class parent {
void patternFill(some memory coordinates, pattern); //a factorisation
pattern bytePattern(int patternlength, byte ToMakeThePatternWith) //same thing
};

class interleaved {
virtual pattern makePattern(int length) = 0;
};

class interleaved {
virtual PVideoFrame GetFrame()... //getFrame imple
//relies on BitPerPixels(colorspace) to get memory coordinates right
//and call patternFill(makePattern)
};

class yuy2, rgb24, rgb32 {
virtual pattern makePattern(int length) //implementation
//if we set rgb32 alpha to 255 we merge rgb32 and rgb24 (I did this)
//use of the factorised bytePattern in rgb24 (and maybe 32)
};

class yv12 {
virtual PVideoFrame GetFrame...
//planes coordinates calcul
//call PatternFill(..., bytePattern) on each plane)
};

Is that better ?

Si
25th March 2003, 19:54
Cough Cough:)
Obviously a moderator and a 3.0 developer can do what they want :) but have you thought about putting this in a separate thread?

says Simon who then runs away to hide from a thunderbolt from above :)

sh0dan
25th March 2003, 21:53
@siwalters: Being moderator makes it possible to fix these things. :)

For discussions related to frametypes in Avs 3.0 - see this thread (http://forum.doom9.org/showthread.php?s=&threadid=49555).

Leuf
12th April 2003, 06:04
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.

Si
12th April 2003, 12:09
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

Leuf
13th April 2003, 12:01
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.

Si
13th April 2003, 14:24
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.


...

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

Bidoche
18th April 2003, 01:22
@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.

Sigmatador
1st May 2003, 21:29
is there a way to add text (debug information) on a PVideoFrame ?

sh0dan
1st May 2003, 22:42
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.

Sigmatador
2nd May 2003, 15:20
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 ?)

Bidoche
2nd May 2003, 15:45
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.

trbarry
2nd May 2003, 15:51
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

Sigmatador
2nd May 2003, 16:41
@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 (http://www.fftw.org) 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)
:confused::confused::confused::confused:
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.

Sigmatador
3rd May 2003, 16:08
@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)

trbarry
3rd May 2003, 16:27
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

sh0dan
29th May 2003, 11:29
Have a look at audio.cpp (http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/avisynth2/avisynth/audio.cpp?rev=1.16&only_with_tag=MAIN&sortby=date&content-type=text/vnd.viewcvs-markup) 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.

neuron2
31st May 2003, 04:26
_aligned_malloc() is part of the platform SDK.

snowmoon
15th July 2003, 05:22
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

Si
16th July 2003, 19:29
@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 (http://www.avisynth.org/index.php?page=FilterSDK)


regards
Simon

cudmore
9th August 2003, 23:04
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

Si
29th August 2003, 01:43
@cudmore
I've given it a go and it seems I can get it to work.

So SimpleSample1.7 is available here (http://www.geocities.com/siwalters_uk/simplesample17.zip) (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 :o and Avisynth doesn't work anymore in RGB on my computer :( )

regards
Simon

bkam
18th November 2003, 18:55
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 :D. But still I am a coding n00b, so any help is appreciated! Thanks!

Si
19th November 2003, 00:15
I use Microsoft Visual C++ to compile filters.

You probably can compile them with some flavour of MS .net but I've no experience with this (Hopefully someone else can comment)

You can't use any known free compiler, so unfortunately you'll have to fork out some money to start.:(



regards
Simon

MrTibs
26th January 2004, 17:03
I'm having trouble with this sample code. The code compiles fine but I can't load the finished DLL. So far, it seems to be caused by the avisynth.h file. I'm testing with Avisynth 2.5.0, is that the reason?
I'm using MSVC 5.0.

P.S. Thanks for the excellent example, it has been VERY helpful.

Si
26th January 2004, 21:55
AFAIK you need MSVC 6 or later to make Avisynth filters

regards
Simon

MrTibs
5th February 2004, 04:43
First I would like to thank everyone who have worked on the SimpleSample. It is helping a lot. However, considering that I don't own MASC 6, would it be possible to have a SimpleSample with the C interface using the YV12 color space?

morsa
15th February 2004, 07:30
Hello everyone,
I´m trying to make my first avisynth filter and I have a big stupid problem.I just can´t figure out how to define a destination frame with 2x the original width and height.I've been looking into many filter sources but, no way I can't understand how the new dimensions are set.
Anybody could help me?
Take note I'm really dumb about coding C++ and using Avisynth code.
Thanks.

Si
15th February 2004, 15:58
See if the stuff in this thread helps - if not - come back :)

http://forum.doom9.org/showthread.php?s=&postid=392435#post392435

regards
Simon

morsa
18th February 2004, 03:53
It seems that vi.width = vi.width*2; vi.height = vi.height*2; isn´t working for me.I can´t get a double size.
In fact I used simplesample as framework and changed silly things but nothing happens.

tempetai
18th February 2004, 07:15
I believed they are read only properties. Why don't you use

Simpleresize(vi.width*2,vi.height*2)

morsa
18th February 2004, 08:46
We´re not talking about scripting but coding in C++.
By this time I'm trying to make an Scale2x implementation for Avisynth for testing purposes (I'm thinking about coupling it with some kind of pre-prosesing filter or a mixture of algos) but I'm really stuck with this problem.I know it may sound trivial for most people here, but the lack of documentation and full examples is driving me nuts!
Thank you.



P.S: BTW what´s the use of Subframe??

vcmohan
19th February 2004, 04:08
I had used Siwalters simple Sample to develop my transition plugins and am greatful to him. However the example of a square box removes all complexities involved in coding a YV12 frame. I am trying to resize such a frame and find in a hopeless situation as it is becoming more and more approx. Can the YV12 be more lucidly demonstrated

Si
20th February 2004, 07:04
@vcmohan
What sort of operation do you want an example of ?

regards
Simon

sh0dan
20th February 2004, 12:52
Originally posted by vcmohan
I am trying to resize such a frame and find in a hopeless situation as it is becoming more and more approx.

There is a thread about the topic. YV12 is no different than other colorspaces in regard to resizing.

Can the YV12 be more lucidly demonstrated
There is a bunch of stuff about ColorSpaces (http://www.avisynth.org/index.php?page=ColorSpaces) , Working with images (http://www.avisynth.org/index.php?page=WorkingWithImages), Data Storage in AviSynth (http://www.avisynth.org/index.php?page=DataStorageInAviSynth) and Planar Image formats (http://www.avisynth.org/index.php?page=PlanarImageFormat) at avisynth.org. There is also a wide variety of filters available with source - not to speak of all the internal filters. If you provided a clearer description of your problems it might be easier for us to help you.

vcmohan
21st February 2004, 03:26
Originally posted by siwalters
What sort of operation do you want an example of ?
Simon [/B]

I do reductions and rotatios. While reducing in x or y axis the adjacent pixels may be from different positions of original, the u and v values which as I understand are one value for two pixels entails re computing the original RGB values and re composing as Y U and V values. This I find as cumbersome, and a tedium of coding. May be I understood wrongly the format.

Si
21st February 2004, 20:26
This I find as cumbersome, and a tedium of coding

YV12 (and YUY2) aren't as simple and neat as RGB32 for simple pixel manipulation.

The advantage of working in YV12 or YUY2 comes when you just want to manipulate Y values and therefore you don't have to translate from RGB to Y and back again.

If your source is YV12 (e.g MPEG-2) or analog YUY2 capture then your filter can run a lot faster beacuse there are less bytes to process.

Once you start doing manipulation like your's maybe the speed gains are totally offset by the complexity involved.

regards
Simon

morsa
24th February 2004, 07:23
..

vcmohan
25th February 2004, 02:38
Originally posted by morsa
..
Is something missing? There was no text here

morsa
25th February 2004, 12:38
Could someone show me what's the way to copy YUY2 U and V planes from a source to a 2X destination frame.I lack the experience, can't find an example that works for my dead brain and I'm going nuts........................HeLp:D

Si
25th February 2004, 20:26
You could have a look at my ShowPixelValues filter (which is basically a type of point resize filter)

the code where I translate YUY2 to YUV is here
// Separate Y1 and Y2 values into their own 32bit "pixels"
// i.e double 16 130 18 131 becomes 16 130 16 131 18 130 18 131
for (h=0;h < (src_height);h++) {
for (w = ((src_width>>6)<<2)-4;w>=0;w-=4) {

*(dstp + (w*2) + 7 + (h * dst_pitch)) = *(dstp +w + 3 + (h * dst_pitch));
*(dstp + (w*2) + 6 + (h * dst_pitch)) = *(dstp +(w+2) + (h * dst_pitch));
*(dstp + (w*2) + 5 + (h * dst_pitch)) = *(dstp +w + 1 + (h * dst_pitch));
*(dstp + (w*2) + 4 + (h * dst_pitch)) = *(dstp +(w+2) + (h * dst_pitch));
*(dstp + (w*2) + 3 + (h * dst_pitch)) = *(dstp +w + 3 + (h * dst_pitch));
*(dstp + (w*2) + 2 + (h * dst_pitch)) = *(dstp +w + (h * dst_pitch));
*(dstp + (w*2) + 1 + (h * dst_pitch)) = *(dstp +w + 1 + (h * dst_pitch));
*(dstp + (w*2) + (h * dst_pitch)) = *(dstp + w + (h * dst_pitch));


}
}


regards
Simon

morsa
26th February 2004, 00:00
Thanks Simon, really!!!!
Another question, what is >>6 and <<2??

Si
26th February 2004, 08:49
>> is the binary shift right operator and << the left one.
So x<<1 == x=x*2 and x>>1 == x=x div 2.
and x<<2 == x=x*4 and x>>2 == x=x div 4 etc.
therefore x>>6 == x=x div 64.


regards
Simon

pieter1976
18th March 2004, 20:02
Can someone help me with a delphi(5) example of a filter plugin?
This because i have very little C++ experience and I don't have the tools to compile at home.


I hoop nobody minds me asking this question at this tread.

Si
18th March 2004, 23:27
In practical terms, what you ask for is not possible.:(

AFAIK no-one has ever made a plugin using anything other than MS VC++.

On the other hand, I'm sure a super-whizz programmer in another language could make one because nothing's impossible in the programming world and people always like challenges :)

regards
Simon

morsa
18th March 2004, 23:51
wrong!! :D

Kevin atkinson made his filters using C, also Fizick and....
Remember LoadCPlugin?

Si
19th March 2004, 07:57
I nearly used the phrase "normal plugin" but I thought, no-need, everyone will know what I mean :p

Simon

Longinus
28th May 2004, 22:34
Would it be possible to make a wrapper or something, to be able to use .Net languages like VB.net and C#?? I know very little about C++, not enough to do anything... But It would be much easier to play with a .Net implementation... It probably would be slow, but a solution for the simple mortals among us... and maybe a nice test bed for new plugins...

bill_baroud
16th July 2004, 20:38
it would be a lot more easier to learn c++ than writing a wrapper ;)

ambrotos
22nd June 2005, 10:10
did someone could compile under dev-c++ (mingW)?
just a question because, if I could avoid to use a cracked version of visual studio...

in fact I do compile but the dll, if I try to use it, return : there is no function named simplesample ...

neuron2
22nd June 2005, 14:06
What do you mean by "cracked version of visual studio"?

Fizick
22nd June 2005, 18:02
(cracked=pirated)
But you can use free MS VC Toolkit 2003 (I use it) or 2005.

neuron2
22nd June 2005, 20:21
@ambrotos

Do not discuss or mention warez here. It's against forum rules.

ambrotos
23rd June 2005, 05:40
:eek: ooops I'm sorry ^^

I was just saying that I do not intend to use a warez version ^^
I don't even more intend to receive tips to crak it :)
on the contrary i'm trying to develop only with opensource tools

@fizick :thanks:
(but about mingW ? no positive feedback ?)

Fizick
23rd June 2005, 20:46
I used MinGW for Avisynth_C plugins only.

ShinSan
25th July 2006, 18:11
I just want to say thanks to sh0dan for making those sample scripts (of course props goes out to the avisynth devs as well). I've looked at a few filter tutorials and just got daunted at the explanation and for some reason the sample scripts for avisynth made everything click.

Fizick
28th October 2006, 14:12
I try collect FilterSDK for v2.5.7 offline documentation.
Am I correctly understand, that SimpleSample license is strictly GPL, and not under exception of 'avisynth.h' ?
So any plugin based on SimpleSample must be open source.

IanB
28th October 2006, 16:30
Everything related to or derived from Ben's original Avisynth is strictly GPL apart from his avisynth.h exception.

The goal is to encourage others to contribute to the open source community, the exception clause is to allow authors to choose the licence terms for their work, hopefully they do the community spirited thing and release their source code.

Everything I have contributed is strictly GPL. I believe (hope)the other contributors also support this ideal.

Obeiwan got it wrong, he should have said "Luke use the Source.... "

Fizick
28th October 2006, 21:44
It is not easy question.

Here is Ben's words about plugins license:
http://forum.doom9.org/showthread.php?p=176734#post176734
Here's my view on this. When AVISource() opens an AVI file, it loads
appropriate audio and video codecs and asks them to decode the data in the file. For all practical purposes it's using the codecs as plug-ins. Clearly I can't require those codecs to be open source, even if they were written after Avisynth was. I think this applies equally to so-called "Avisynth plugins." They are not really part of Avisynth in any meaningful way; there just happens to be an Avisynth command which instructs Avisynth to load one of them and talk to it in a certain way. So regardless of my moral/ethical views, I don't think I have any legal basis for restricting the licensing terms of these plugins (and I never intended to do so).

I won't relicense Avisynth under the LGPL, but I will sign off on a
statement (or write one myself) to the effect that my license should not be construed as placing any restriction on plugin licenses, provided that Avisynth is not modified to *automatically* load a closed-source plugin and then bundled with that plugin (which is the situation the FSF is rightly concerned about). You should probably get a similar statement from Avery, because Avisynth proper contains VirtualDub code. Also, I hereby release avisynth.h (all versions created by me) into the public domain, although I'm not sure it qualified for copyright protection in the first place.

So, IMO, the various Ben's "Invert" plugins codes from Avisynth SDK is not strictly GPL (and all other Ben's examples).
The sh0dan's v2.5 "Invert" is probably too:
http://forum.doom9.org/showthread.php?p=176183#post176183

- Plugins do not need to be GPL. It's the author (and the users) own loss.
- All internal Avisynth should be GPL. I will not accept any avisynth that is distributed without source. No excuses here.
- If anyone releases a payware plugin. Let them. Let the users decide if they want to pay. I will not!
- If anyone can prove that a plugin uses code from GPL plugins, I will stand by your side, to help you get the source opened on such thieves.

But SimpleSample was firstly created by Simon Walters (v.1.0) under GPL as is noted in the head of source,
then was commented by sh0dan (v1.0b) without license change, and so on.

I do not know about various assembler parts by Avery and others (these parts have no any copyright notices and license).

IMHO, whole AviSynth Filter SDK must have one type of license, the same as avisynth.h.

But now part of code in AviSynth Filter SDK is under GPL.
May be we may ask Simon Walters re-release SimpleSample (may be some versions, for example 1.0b) under other license (the same as avisynth.h) for avisynth SDK?

Si
29th October 2006, 02:24
What is the problem with the SimpleSamples being GPL?

regards

Simon

Fizick
29th October 2006, 09:07
Hi, Simon,
SimpleSample as a real plugin must (may) be GPL without any problem.
But if SimpleSample is considered as 'official' part of Avisynth FilterSDK, than I see some license conflict.
For example if somebody take SimpleSample 1.1 as a base for you own (advanced) plugin, this plugin automatically must be GPL.
But SimpleSample does not contains many differences from Ben's Invert code (which is not strictly GPL, see above).

For example, the only different line of SimpleSample 1.0b from Ben's Invert is:

*(dstp + w) = *(srcp + w); // Copy each byte from source to destination.

Are you really has copyright on this statement ? :)
Any program with this line must be GPL? :)

As I understand, the SimpleSample was created for the purposes of illustration of using avisynth plugins interface,
with some basic commands.
It is exactly aim of Avisynth FilterSDK.

Simon, may you give (as an exception) a permission to use SimpleSample code as a part of AviSynth FilterSDK solely for creation of AviSynth plugins under any license?

I do not force you to change the license. And I very like GPL. I simply try make some things more clear to me and others.

Here is my current free interpretation (may be wrong):
1. Avisynth Filter SDK (avisynth.h, information, examples) may be used for creation of any software under GPL license.
2. Avisynth Filter SDK may be used for creation of AviSynth plugins (3rd-party filters, import and export plugins, or graphical user interfaces) under license of your choice.
3 (not 4). Avisynth Filter SDK may NOT be used for creation of any other non-GPL host program which is linked to (i.e. can directly call) AviSynth or AviSynth GPL plugins.
4. Avisynth Filter SDK may NOT be used for creation of non-GPL plugins for any program besides AviSynth.
5. AviSynth community friendly suggest to create any AviSynth plugin under GPL and will help in its development and improving.

IanB
29th October 2006, 14:09
Having the sample code GPL is a very good thing. It means that anyone who uses the sample code as a basis for a plugin is obliged to also release the source to that plugin under GPL and I think that is quite fair. They have used somebody else work. The same applies to any plugin that use avisynth internal source code or is based in avisynth internal source code.

It is the same case for most of the code for AviSource() It is straight from VirtualDub and as such conforms to that licence.

Now those who develope a plugin from scatch are entitled to do whatever they like. I don't have a problem with this, it's their work so their's to copyright as they see fit. And Ben's avisynth.h exception supports this model, and he is just being fair, after all it is pretty hard to write a plugin without using avisynth.h in your source.
Here is my current free interpretation (may be wrong):
1. Avisynth Filter SDK (avisynth.h, information, examples) may be used for creation of any software under GPL license.True. This is the straight forward case. GPL -> more GPL :D
2. Avisynth Filter SDK may be used for creation of AviSynth plugins (3rd-party filters, import and export plugins, or graphical user interfaces) under license of your choice.True. This is because of the avisynth.h exception and applies as long as no GPL code is used in it. The new original source belongs to the author.
3. Avisynth Filter SDK may NOT be used for creation of any other non-GPL host program which is linked to (i.e. can directly call) AviSynth or AviSynth GPL plugins.Half true. While definitly outside the avisynth.h exception, there is nothing to stop any program loading avisynth.dll and poking at the entry points. Even greyer is a program using avisynth plugins directly. It is against the spirit but is probably unenforcable. :(
4. Avisynth Filter SDK may NOT be used for creation of non-GPL plugins for any program besides AviSynth.Half true. Here intent is very hard to prove. E.G. Yes it is an original unique avisynth plugin, plus, yes it is NOT GPL. Is the author of this plugin in violation when a 3rd party uses it with a non GPL program. Probably not.
5. AviSynth community friendly suggest to create any AviSynth plugin under GPL and will help in its development and improving.This has nothing to do with GPL licencing other than being a very desirable goal.

Fizick
29th October 2006, 17:18
IanB,
thanks for fixing my enumeration bug! :)

A little corrected item 3:
3. Avisynth Filter SDK may NOT be used for creation of any other non-GPL host program which is linked to (i.e. can directly call) AviSynth or AviSynth plugins.

If it outside the avisynth.h exception, it is not legal,
especially if we explicitly write this text to FilterSDK doc (you are avisynth copyholder too).
And I say not only about avisynth.h, but about Invert plugin and other samples included in Avisynth FilterSDK.
I was really annoyed when I see some closesource VirtualDuB-compatible program (or module of some big program) which can load VirtualDub plugins. :(

About item 4:
I say about creating plugins for example for Adobe Premier, with using some code of SDK.

Item 5:
O.K., I will remuve its enumeration :)

Si
29th October 2006, 21:09
Its my opinion that the Invert and SimpleSample plugins are GPL.

As is the whole of Avisynth except for avisynth.h.

But I'm not a lawyer and I only do this for fun :-)

regards

Simon

Si
30th October 2006, 00:57
Fizick is PM'ing me with questions and suggestions that I am having great trouble in understanding :confused:

So I'd like to have this discussion in public (IF Fizick doesn't mind)

I think he wants to change the example plugins from GPL to the special license type that Ben granted to avisynth.h

I don't want to do this for the SimpleSample plugins because I don't understand the need for change or the repercussions if I did.

(And IMO they were a community created resource anyway - I just was the one that edited them :-) - without Shodan's comments they'd have been worthless :-) )

Help!!!!

regards
Simon

IanB
30th October 2006, 01:46
I am not sure what Fizick wants to achieve, perhaps he should restate his objectives or thoughts with regards to GPL restrictions.

I still stand by my opinion :-
All the resources to do with the filter SDK and example code should be full GPL!

Letting closed source shops freely reuse sample code is just not on.

Wilbert
30th October 2006, 20:10
@IanB,

I agree with the examples SimpleSample and Invert being GPL, but how can the other code snippets be GPL? It's just basic stuff which is used in almost very plugin. Since we allow plugins to be non-GPL, this implies that those code snippets can't be GPL.

Fizick
30th October 2006, 21:14
I do not want nothing besides clarity.
And sorry my poor English below:
I wanted to add FilterSDK to offline Avisynth.doc.
I start with page http://www.avisynth.org/FilterSDK
It is not available now - it is one of reasons to have off-line SDK.
really I start with this link:
http://www.avisynth.org/warpenterprises/avisynth_org_20050408.rar
I remove non-SDK files. Here is stripped SDK pages (temporary link):
http://avisynth.org.ru/FilterSDK0/FilterSDK.html
I reformated SDK a little, and added some information (about what it contains and compilers).
Then I begin think about: what is license of the SDK?
I thinked, that it was single (uni) license for all its parts.
Not I understand, that it is wrong.
Every parts of the SDK has own license.

Here is the parts list:

A. Header file avisynth.h
License: GPL with exception (to develop AviSynth plugins under license your choise), see avisynth.h.

B. Ben's "Writing Avisynth plugins" page,
see mirror at http://www.neuron2.net/www.math.berkeley.edu/benrg/avisynth-extensions.html
It contains 'Invert' plugin sample code and many comments on its every line.
This code is trivial and contains only basic calls. All them are contained in avisynth.h
No any plugin can be created for example without line PVideoFrame src = child->GetFrame(n, env);
and similar.
This page does not contain any license notes.
As we can read from later Ben's letter, he never say that plugins must be GPL.
The 'Invert' plugin was never existed (released) as a plugin (unlike SimpleSample).
Therefore, all Ben's code plugin samples and 'Invert' code is under the exception too.

C. 'TwoFiveInvert' sample code (for avisynth 2.5 with YV12).
probably by sh0dan.
The code is without comments and license notes.

D. SimpleSample source codes (various versions) by Simon Walters.
They all have clear license notes about GPL.


I. various topics about colorspaces, Changes framefrates,
how to invoke internall functions, with small fragments of code.

J. Assembler Optimizing part with many basic examples (various ? authors, in particular phaeron).
The code is very fragmentary.
No any license notes.
In my opinion, this part is very (very!) useful, but is not directly related to FilterSDK (but to general programming).
Probably it may be not included to FilterSDK.
(or be included, but as a separate non-official supplement)

And I forget about K parts: extra files like avisynth.lib, avisytnth.def, avisynth.map
Probably they are under GPL.

So, my (today) conclusion:
First: We must ask sh0dan separately about parts C, I and J.

Second: We must clearly to say, what is license for every parts of FilterSDK. The plugin authors must clearly know, what they can do, to not wake-up with "Oops! I am in GPL catched by IanB!" :) And probably we must not force them to say "No-no, I did not use SimpleSample for my closed source plugin"
(that is why I asked Simon - but let's forget about it).

In my opinion, the core part of SDK must give to authors the freedom to write any plugins for AviSynth (the more plugins, the better), but protect FilterSDK code fragments and samples from using in non-Avisynth programs (besides GPL-compatible programs).

IanB
31st October 2006, 06:13
@Wilbert, I express myself badly. I am not saying everything is GPL, I am stating my opinion that everything substantial contributed to the new Filter SDK documentation bundle be put under GPL, certainly anything I contribute will be under GPL, all I can hope is others do likewise.

Yes trivial coding expresions like PVideoFrame src = child->GetFrame(n, env); can never be under any sort of copyright for similar reasons that the wheel cannot be. There is nothing new, innovative or novel there to protect, it is simply general public information. I suppose if people are worried the copyright on the actual documentation can either explicitly allow free use of code snippets (assuming some ownership claim is valid) or more simply disclaim ownership because they are so generic that no-one could lay claim.

@Fizick, yes you are getting there ;)B. ...
Therefore, all Ben's code plugin samples and 'Invert' code is under the exception too.I think this is a wishful stretch, you really cannot say one way or the other. I think you are right that Ben might probably see it this way, but we cannot state this with any certainty. Best we simply acknowledge this as Ben's work and let anyone involved with an at risk commercial enterprise get a professional legal opinion.

C. 'TwoFiveInvert' sample codeThis is fairly obviously work based on the original Ben example. So sh0dan (the author) gets to say any extra copyright conditions but the core conditions must comply with those of the original work.

J. ...
Probably it may be not included to FilterSDK.Why??? We are conforming to the appropriate conditions. Subsequent use is not our problem. By all means get the attributions corrrect so it is easy to trace ownership, beyond that not our problem.

Fizick
31st October 2006, 22:03
IanB,
I do not see any problem with new contributions to SDK. Simply add license notice your choice to your text.
I see problem with existent content without license notice.
So waiting sh0dan :)

In my opinion above, the implied license of current SDK is the same as license of avisynth.h

Here is the my next draft of license block at the top of Ben's documentation page:
-------------------------------------------------------------------------------------------------------------
This is the original documentation written for AviSynth 1.0 by Ben Rudiak-Gould
(creator and developer of Avisynth up to v1.0beta3) - copied from
http://math.berkeley.edu/~benrg/avisynth-extensions.html
The current mirror is at:
http://www.neuron2.net/www.math.berkeley.edu/benrg/avisynth-extensions.html

License notes.
The original documentation page has no any special license statement.
AviSynth 1.0 was created and developed under GNU GPL license.
Here is Ben's words about AviSynth plugins license:
"...regardless of my moral/ethical views, I don't think I have any legal basis for restricting
the licensing terms of these plugins (and I never intended to do so)."
See http://forum.doom9.org/showthread.php?p=176734#post176734
We suppose that the license of plugin code samples in this page may be considered the same as
the license of the header file avisynth.h.
-----------------------------------------------------------------------------------------------------------
it is not clear, but probably it is what we have.

Fizick
1st November 2006, 20:13
Today I think, that the text above is too long :)
Next version of License notes (about Ben's article):
The original documentation page has no explicit license statement.
We believe that contained on this page code samples
that illustrate the syntax of interfaces defined in avisynth.h
are under GNU GPL plus license exception declared in avisynth.h.
-----------------------------
While waiting shodan, I try create GPL drafts of AviSynth FilterSDK license text
(partially taken from virtualDub filter SDK):
-------------------------------------------------------------------------------------------
The AviSynth external filter SDK is Copyright(c)2000 Ben Rudiak-Gould,
and Copyright(c)2002-2006 Klaus Post et al, All Right Reserved.
It is released with NO WARRANTY and freely usable/
distributable under the terms of the GNU General Public License (GPL).
It should have been included; if not, you may receive a copy by writing
to the Free Software Foundation, Inc., 675 Mass Ave., Cambridge, MA 02139,
USA.

Some files in this package (in particular avisynth.h)
contain license exeptions giving you additional permissions
besides those granted in the GNU General Public License.
Consult the license block at the top of files for information.

Fragments of AviSynth FilterSDK code samples
that illustrate the syntax of interfaces defined in avisynth.h only
are also under license exceptions declared in avisynth.h.

Any trademarks mentioned here are the property of their owners. To the
our knowledge no trademark or patent infringement exists in this
document or this distribution; any such infringement is purely
unintentional.

We suggest you to create and distrubute your plugins also under
GNU GPL license in the spirit of open source AviSynth project.
Whole AviSynth community will help you in plugin development and improving.
To do it, simply place your copyright statement and GNU GPL license
comment block at the top of your souce code (see SimpleSample code for example)
and release your plugin with the source code included.
(You may not act differently if your plugin contains some source code under GNU GPL.)
-----------------------------------------------------------------------------------------

Please correct my English.

Wilbert
1st November 2006, 22:40
That formulation is fine with me.

IanB
2nd November 2006, 04:32
As these documents are to be long lived :) I suggest things like this be date referenced. It help down the track when trying to trace the history of something.The current mirror is at:The mirror as at November 2006 is at:
-------------------------------
In my opinion above, the implied license of current SDK is the same as license of avisynth.hWe suppose that the license of plugin code samples in this page may be considered the same as the license of the header file avisynth.h.We believe that contained on this page code samples that illustrate the syntax of interfaces defined in avisynth.h are under GNU GPL plus license exception declared in avisynth.h.Fragments of AviSynth FilterSDK code samples that illustrate the syntax of interfaces defined in avisynth.h only are also under license exceptions declared in avisynth.h.@Fizick,

Do you have some reason for needing the sample code to be explitly usable by closed source shops?

The forms above are all your opinion, yes, I do happen to agree with your opinion, BUT that does not make it fact.

We should not be encouraging people to risk using the sample code in a non GPL manner unless we have documented proof positive that it is in fact exempt. If we did have explicit documentation then these clauses would not be necessary, we would just include it.

The form text stands quite fine without including the guess. Apart from that the revisions are very good.

If you are still seriously worried, make the recomendation that those at risk should seek professional legal advice.

stickboy
3rd November 2006, 19:56
I have some somewhat recent contact information for BenRG. I'll send him an email.

Fizick
4th November 2006, 08:35
stickboy,
may be we can invite him to AviSynth development this way?

my next wording version:
As a special exception, you may copy and modify
some portions of contained in this documentation code samples
and distribute such modifications
(independent modules that communicate with Avisynth
solely through the interfaces defined in avisynth.h)
under license terms declared in avisynth.h,
provided that these portions solely illustrate the syntax
of interfaces defined in avisynth.h.


And I discover one more implicit part of AviSynth SDK with code fragments: postings of various user to this forum. Licenses is various probably.

Finally, i have a suggestion to add a function 'bool IsPluginGPL() ' to Avisynth and give to plugin more cache memory if return value is 'true'. ;)

IanB
5th November 2006, 06:43
Again, @Fizick,

Do you have some reason for needing the sample code to be explitly usable by closed source shops?

Fizick
5th November 2006, 07:43
IanB,
Right now I try undersand license terms of existant SDK documentation, firstly from Ben.
As I write above, IMHO no any close source plugin can be written without using some fragments of code samples,
at least from Ben's 'Invert' plugin description.
So, my latest proposal above is related to existant (Ben's ?) part of SDK.
But may besome of these parts is public domain (remember Ben's word about avisynth.h) or strictly GPL. Will wait answer from Ben, then from sh0dan.

IMHO, the voluntary releasing of source is much more good thing than forced by 'PVideoFrame src->GetReadPtr()' copyright. But if you think, that this small fragments is trivial,
we can do not write general exception to new SDK.

IanB
5th November 2006, 09:22
If you get statements from Ben and sh0dan, then the problem is solved. If not, just fall back on advising to seek professional legal advise.

We can really see how all this legal crap can gum up the works. For all this time and effort a really nice SDK doco bundle could have been made now. ;)

Fizick
5th November 2006, 17:35
IanB,
Yes, I almost completely with you here
(regarging Ben, but sh0dan's part is not completely sh0dan's work)
And really I secretly work under its real content too ;)

EDIT: I put draft version to CVS tree. Developers can edit it :)


By the way, anybody has backup copy of the page from SDK:
http://www.avisynth.org/GettingStartedWithAudio
(I do not have it).
And who wrote it and under which license? :)

photoguy123
14th November 2006, 02:31
Hate to interrupt the legal discussions, but a quick question:

Is 1.7 still considered the most recent SimpleSample version?

Link to SimpleSample 1.7 Code (http://www.geocities.com/siwalters_uk/simplesample17.zip)

And I assume it's still one of the best simple samples out there for new plug-in writers?

Just wanted to clarify as this thread is pretty old now.

Si
14th November 2006, 19:28
Yes - SimpleSample 1.7 was the last one.

I wouldn't describe it as the best - the different versions are there to show how to progress from a very very simple operation to a simple one :-)

I would recommend looking at the (debugged and commented) previous versions first.

regards

Simon

Fizick
22nd November 2006, 21:23
Response to my e-mail:

> you (at 2003) posted at www.avisynth.org WiKi some short
> articles about assembler opimization with small code fragments.
> What is license terms of this articles? May we re-distribute them in
> off-line AviSynth filter SDK at GPL (or GPL-compatible) license ?


You may consider the text added by me to that article to be freely
available for any use.

--
Avery Lee

Fizick
23rd November 2006, 11:32
Here is an unforeseen (for me) result of our discussion about various aspects of VirtualDub SDK and Avisynth SDK (from next e-mail):

...
> May I (we) now ask your special permission to distribute code fragments
> of VirtualDub contained in Avisynth v.2.5.6 with any version of
> Avisynth under current license terms of Avisynth (with exception
> declared in avisynth.h)?

Yes, of course. I will authorize use of the existing VirtualDub-derived
elements in Avisynth under the current Avisynth license, which is GPL plus
a special exemption.

Note that use of any more VirtualDub code in Avisynth will require
additional permission.


--
Avery Lee

IanB
24th November 2006, 05:40
Poking sleeping bears has problems! :D

Fizick
24th November 2006, 06:50
Not all bears are hungry and angry :)

redfordxx
10th December 2006, 16:36
Why is all this etc. in the getframe fucntion?
const int dst_pitch = dst->GetPitch();
const int dst_width = dst->GetRowSize();
const int dst_height = dst->GetHeight();

That is like I am asking for every frame, how big is it. Is it enough in constructor? Or can it somehow change in Avisynth?

squid_80
10th December 2006, 18:32
Pitch can definitely have different values for different frames (for input frames at least). Width and height I'm not so sure about...

redfordxx
21st December 2006, 16:06
_aligned_malloc() is part of the platform SDK.
That means I should download this?
Microsoft ® Windows Server® 2003 R2 Platform SDK Web Install (http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en)

I have WinXP, VS6 C++ SP6... does that match?

I definitely won't spend money to upgrade from VS6 to VS2005, but I read Fizick's recommendation to use the free VS2005Express.
Can anybody tell, whether is better to stick with "old full version" VS6 or "new lite version" VS2005Express

redfordxx
21st December 2006, 16:21
I have to add a "thanks" for the simplesample too.
It raised my C++ knowledge from 0 to... something nonzero.;)

Could you add an explanation how adding optional parameters for the filter with default values?
And AsString comes like *BYTE?

Fizick
21st December 2006, 20:17
redfordxx,
this MS links says:
1. "The last SDK that will work with VC 6.0 is the February 2003 Edition".
And of course no download link for old version.
Nice M$ !
For 10$ you can get CD at
http://www.qmedia.ca/launch/psdk.htm
(or from some friend :) )
My recommedation was VC2005? No. It was option only!
Other free option is vctoolkit2003 (with your vc 6 IDE)
http://www.google.com/search?&q=vctoolkitsetup.exe
Every choice is subjective.

2. Download as many plugins with source code as you can and try read them. ;)

redfordxx
22nd December 2006, 13:11
My recommedation was VC2005? No. It was option only!
Sorry for the wording;)
Other free option is vctoolkit2003
I understand Express is the next version of Toolkit
(with your vc 6 IDE)
IDE??? - You probably don't mean hard drive. What does it mean?
Every choice is subjective.
Of course, but any remarks what is missing or bothering compred to full VS (at least what's important for filters development)

redfordxx
22nd December 2006, 14:03
"The last SDK that will work with VC 6.0 is the February 2003 Edition".
And of course no download link for old version.
Nice M$
This is it...(?)
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
It is full, so probably mostly unnecessary (because only few C++ header files / includes or how is it called etc. needed), but at least something...
Only I wonder that there is written "Update"... It means I need something before?

neuron2
22nd December 2006, 14:45
If you don't want to go through the hassle of getting and installing the platform SDK just to get the aligned malloc/free, then you can use the code for those functions to be found in the file alloc.cpp contained in the DGDecode source zip (part of DGMPGDec).

redfordxx
22nd December 2006, 16:43
If you don't want to go through the hassle of getting and installing the platform SDK just to get the aligned malloc/free, then you can use the code for those functions to be found in the file alloc.cpp contained in the DGDecode source zip (part of DGMPGDec).

:thanks:
That will work better than my first attempt:
First (2weeks ago) I wanted to download the new malloc include file. But it wanted another include and that one another... so I stopped after certain recursion depth;)

Fizick
22nd December 2006, 17:12
redfordxx,
no, at http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
is NEW SDK not-compatible (officially) with VC6.

redfordxx
22nd December 2006, 20:29
redfordxx,
no, at http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
is NEW SDK not-compatible (officially) with VC6.

Are you sure?
Because the new "Windows® Server 2003 R2 Platform SDK Full Download" is supposed to be 400MB and this is 323MB. And the last update date says February 2003.

Fizick
22nd December 2006, 21:03
No, I am NOT sure :)
Probably you a right.

redfordxx
23rd December 2006, 03:24
Neuron2,
I want to use your alloc.cpp.
However, after copying into project dir, adding to project source files, on compiling it writes
error C2065: 'aligned_malloc' : undeclared identifier
I see it in the workspace class view.
#include won't help because then it writes that the declarations are twice...
And same for my other functions.

What's wrong?

neuron2
23rd December 2006, 04:03
You need a prototype for the function for any code that wants to call it. Put this in your global header file or make sure that any code that wants to call aligned_malloc() sees this prototype:

extern "C" void *aligned_malloc(size_t size, size_t alignment);

You'll also need a prototype for aligned_free().

Your C/C++ skills need brushing up if you don't know about function prototypes.

redfordxx
23rd December 2006, 04:29
Thanks!

BTW...there is nothing to brush up, that's why I am in the simplesample thread:p

redfordxx
1st January 2007, 05:44
If you don't want to go through the hassle of getting and installing the platform SDK just to get the aligned malloc/free, then you can use the code for those functions to be found in the file alloc.cpp contained in the DGDecode source zip (part of DGMPGDec).

As I looked at alloc.h, I also looked at the functionYV12PICT* create_YV12PICT(int height, int width, int chroma_format)
{
YV12PICT* pict;
pict = (YV12PICT*)malloc(sizeof(YV12PICT));
int uvwidth, uvheight;
if (chroma_format == 1) // 4:2:0
{
uvwidth = width>>1;
uvheight = height>>1;
}
else if (chroma_format == 2) // 4:2:2
{
uvwidth = width>>1;
uvheight = height;
}
else // 4:4:4
{
uvwidth = width;
uvheight = height;
}
int uvpitch = (((uvwidth+15)>>4)<<4);
int ypitch = uvpitch*2;
pict->y = (unsigned char*)aligned_malloc(height*ypitch,32);
pict->u = (unsigned char*)aligned_malloc(uvheight*uvpitch,16);
pict->v = (unsigned char*)aligned_malloc(uvheight*uvpitch,16);
pict->ypitch = ypitch;
pict->uvpitch = uvpitch;
pict->ywidth = width;
pict->uvwidth = uvwidth;
pict->yheight = height;
pict->uvheight = uvheight;
return pict;
}I am sorry with my small knowledge if I miss something, but...
Isn't bug there that in case 4:4:4 is wrong pitch and incorrect malloc?

Sorry it's off topic here but it is kinda reply to a post here.
I will delete it if you consider it suitable.

neuron2
1st January 2007, 05:53
Why do you think it is wrong?

redfordxx
1st January 2007, 05:58
uvwidth = width;
int uvpitch = (((uvwidth+15)>>4)<<4);
int ypitch = uvpitch*2;

that means?

int ypitch = (((width+15)>>4)<<4)*2;

redfordxx
1st January 2007, 06:05
maybe could be


YV12PICT* create_YV12PICT(int height, int width, int chroma_format)
{
YV12PICT* pict;
pict = (YV12PICT*)malloc(sizeof(YV12PICT));
int uvwidth, uvheight,hshift,vshift;
if (chroma_format == 1) // 4:2:0
{
hshift = 1;
vshift = 1;
}
else if (chroma_format == 2) // 4:2:2
{
hshift = 1;
vshift = 0;
}
else // 4:4:4
{
hshift = 0;
vshift = 0;
}
uvwidth = width>>hshift;
uvheight = height>>vshift;
int uvpitch = (((uvwidth+15)>>4)<<4);
int ypitch = uvpitch<<hshift;
pict->y = (unsigned char*)aligned_malloc(height*ypitch,16<<hshift);
pict->u = (unsigned char*)aligned_malloc(uvheight*uvpitch,16);
pict->v = (unsigned char*)aligned_malloc(uvheight*uvpitch,16);
pict->ypitch = ypitch;
pict->uvpitch = uvpitch;
pict->ywidth = width;
pict->uvwidth = uvwidth;
pict->yheight = height;
pict->uvheight = uvheight;
return pict;
}

... If I know correctly what does << and >>

neuron2
1st January 2007, 06:06
Yes, you are correct. I don't think it's a bug per se, however, because it apparently doesn't break anything. It just allocates more memory than it needs to. I'll try to check that, but I don't have any 4:4:4 source material and I don't know who wrote that code, although I know tritical modified it.

redfordxx
1st January 2007, 06:11
Yes, you are correct. I don't think it's a bug per se, however, because it apparently doesn't break anything. It just allocates more memory than it needs to. I'll try to check that, but I don't have any 4:4:4 source material and I don't know who wrote that code, although I know tritical modified it.
Yes doesnot break...but it could double slow down the speed of processing luma if there is some cycle for (i=0;i<pict->ypitch...

Richard Berg
18th January 2007, 03:58
Hi,

I prepare draft version of avisynth license text, and after some discussion with IanB I put it to CVS tree at docs/english/license.htm

Please look and comment/edit.

The most unclear for me is documentation status (offline and online).
Can I ask, why you select Attribution-NonCommercial-ShareAlike 2.5 for wiki? (and not GNU FDL for example)

I hope, we will see avisynth.org soon.
The revised avisynth license looks great.

--------------------------------------------------------

The SDK license looks technically correct -- it gives the proper license for each part. But I think the overall intent is very hard for users to discern. All they want to know is: does my plugin have to be GPL? Right now it's hard to answer without poring over the details of the various sub-licenses.

My personal opinion is we shouldn't restrict plugin developers at all. I'd be fine with the SDK in the public domain or very liberally licensed (BSD style), so long as we keep the friendly "please consider our community" section at the bottom. If truly we want SDK users -- including companies -- to follow the GPL, we should use persuasion instead of force. Sell them on the merits of free software. Encourage them to share the code here so we can answer questions. Convince them that the contributions they'll receive from others are worth giving up some control. And if they still want to keep it closed after all that, so be it: a closed plugin is better than nothing. Ben & Avery seem to share this viewpoint.

In reality, it looks like SimpleSample, IanB's contributions, and (possibly) the avisynth 1.0 documentation are GPL. What does that mean for plugin developers? I'm not sure. There is no apparent boundary line between the SDK documentation text and the SDK sample code, so it's very hard to know what is allowed. I propose we separate the text vs code licenses, then write a new preamble that makes the answers clear.

----

SDK text should be Attribution-NonCommercial-ShareAlike. Why not GFDL?
(a) The CC licenses are very simple. Virtually everything you need to know is in the name. GNU licenses are complicated and carry a lot of baggage (both ideology and perception -- it turns off many people who dislike Stallman/GNU project for whatever reason).
(b) MediaWiki uses CC.
(c) I like Larry Lessig a lot more than Richard Stallman.

Result: anyone can read the SDK text and do whatever they want with that info. Only if they are modifying or redistributing the text itself do they need to attribute the authors, not be commercial, and redistribute their changes under CC. [this summary, or something like it, should go in the license preamble]

-----

SDK code needs a license. For consistency & sanity we should re-license and distribute all SDK code under the same license. Ideally that would be BSD. However, there is lots of GPL code in it already, and some of you disagree, so for that to happen we'd need a lot of discussion. The path of least resistance would be to apply the GPL + avisynth.h exception to everything.

Assuming we go down that path, the result: plugin developers who modify or redistribute the SDK code obviously need to contribute their changes back to us and make them GPL. As for plugin developers who want to paste parts of the SDK code into their own code, they would have to consult a lawyer to see whether the parts they copy are copyrightable or trivial. [this summary, or something like it, should go in the license preamble]

Having worked in commercial software for awhile, here's how I see the GPL scenario playing out. Large companies will not touch the SDK with a 10ft pole; no matter what they do, the chance of being sued is too high. Small companies won't bother to consult a lawyer; they'll simply copy/paste at will. Since the SDK code is so fundamental they know they won't be caught (bits generated by SDK code look the same as bits generated by virtually any other plugin that follows the avisynth.h interface) -- and if they are caught, they'll claim they only copied parts that are trivial/uncopyrightable. Hopefully you can see why I don't consider GPLing the code to be helpful.

Fizick
18th January 2007, 19:28
Richard Berg,
thanks for answer and for restoring of avisynth.org today! :)
At least I know text of "GettingStartedWithAudio" article from FilterSDK (but I still do not know who wrote it, probably sh0dan?)
----------------------
Generally I agree with most part of your opinion.
(preable could be useful).

Here is my "disagree" part:

1) IMO, SDK may be free for Avisynth plugin developers, but not for complitely "any use".
We must not permit freely use the SDK for non-avisynth (e.g. photoshop, etc) plugins
or to create some close source host aplication instead of avisynth (using avisynth plugins).
---------------------------------
2) I do not see any reason to put SDK text under some additional complex (CC or other) license.
It may be under GPL (if somebody want) or "free for any use", BSD (like sh0dan and Avery say).
main rule: whole SDK content must be GPL-compatible.
It is very closely related to avisynth code.

And certainly SDK text should NOT be Attribution-NonCommercial-ShareAlike!

Big question is "NonCommercial. You may not use this work for commercial purposes."
1. Suppose somebody put Avisynth 2.5.7 distribution package to magazine CD and sell it.
It may do it with avisynth, but it can not do it with "CC-noncommercial" portions.
2. Suppose somebody use Avisynth for commercial film-production. He may use avisynth for this,
but he may not "use" (read ?, citate) Avisynth and FilterSDK documentation?
3. Suppose someboby publishes an review article (electronic or on paper), he cited some avisynth doc text there.
He can not get royalties for his article?
General opinion, that Non-Commercial is NOT FREE license.

MediaWiki uses CC.
You say about wikimedia.org or Avisynth.org MediaWiki?
If you say about compatibility with Avisynth.org MediaWiki, here is my opinion:
current Attribution-NonCommercial-ShareAlike license is wrongly declared. :(

We at least could use "Attribution-ShareAlike 2.5" license for Avisynth.org MediaWiki, which permits commercial usage. Or "Attribution-By", or GNU FDL.

And any of CreativeCommon license is not simple.
Full text of license is very complex:
http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode
So called human-readable summary is not license, but some kind of preamble.
http://creativecommons.org/licenses/by-nc-sa/2.5/

This topic was discussed at another thread though (in usage forum).
http://forum.doom9.org/showthread.php?t=105205&page=5
My suggestion is to change mediwiki declared license to more appropriate (and correct). From my private and public discussion, it is be GNU Free Documentation License (used in wikipedia).
I do not like GNU FDL though. It is complex to use.
I know about more simpler draft:
http://gplv3.fsf.org/comments/gsfdl-draft-1.html
But it seems, various CC licenses are more useful for media (phonerecord, movie, photo images, etc) created by artists.
GNU FDL is more useful for text documents. Both SDK and whole avisynth documentation is mainly text, not images.
And this images are used for illustration only, not as creatve work - DVD or other capture frames is usually not under our copyright :).

Some CC license could be useful, if we use some content from other wiki (under CC) or put some content to it.
Bu I do not see any such case.
Most text wiki (like wikipedia) is under GNU FDL (without invariant sections, cover text, ...)
May be more approriate is some sort of CC Atribution-BY (rather complex, see http://creativecommons.org/licenses/by/2.5/legalcode) or BSD-like "any use" license for Avisynth doc.
It must be decision of all avisynth documentation authors,
of course.

Richard Berg
18th January 2007, 20:49
1) good point. I don't know how we can fit that requirement into GPL, BSD, or other existing licenses though. We may need to abandon them and just write a new one that says exactly what we want.

2) you're right, we definitely need to remove NonCommercial. I have not read the GFDL in a long time, my memory of it may be bad (I thought it was more restrictive than CC), will investigate.

Wilbert
18th January 2007, 21:35
At least I know text of "GettingStartedWithAudio" article from FilterSDK (but I still do not know who wrote it, probably sh0dan?)
Yes, it's Sh0dan who wrote this.

@Richard,
2) you're right, we definitely need to remove NonCommercial. I have not read the GFDL in a long time, my memory of it may be bad (I thought it was more restrictive than CC), will investigate.
1) Declaring it CC is not allowed without everyone's (every contributer) approval. This must be cleared up. We should get the approval of the main contributers or change the license.

2) Sh0dan (at least that's what i understood from Fizick) and I prefer GNU FDL as the documentation license. So we would like to get everyone's opinion about this.

GSFDL look also fine too me:

http://gplv3.fsf.org/sfdl-draft-2006-09-26.html (at least at first sight, i didn't read everything thouroghly)

Fizick
18th January 2007, 22:33
Richard Berg,
The current "avisynth.h" license is probably fine ?
But I an not lawyer.

Wilbert,
GSFDL is still in draft.

my (and IanB) opinion: we (you) must decide,
1) what are we want to permit, and what to do not.
2) Are we need in some inter-change with others (wikipedia, etc). or not.
Then we can select approriate license.

May be different part of documentation may have diferent licenses.
(core filters, syntax - more strict to preserve,
faq, scripts at WiKi - more free to change by users).
We (and users) generally need in not in free but in correct documentation.

Fizick
19th January 2007, 19:01
When I discuss (FilterSDK doc) with sh0dan, he said, that for documentation he prefer less restrictive license than GPL, and say about FDL.
But I am not shure that he ever read whole FDL text. :)
It has many restrictions too.

Generaly,
CC Attribution-ShareAlike, GNU FDL and GNU GPL are very similar in a spirit (free, copyleft) but different in details.

Richard Berg
20th January 2007, 00:58
I like the GSFDL.

Fizick
20th January 2007, 03:20
There is also draft of new GNU FDL v.2 license
http://gplv3.fsf.org/comments/gfdl-draft-1.html
with section:


8a. SFDL RELICENSING

If the Work has no Cover Texts and no Invariant Sections
then you may relicense the Work under the GNU Simpler Free Documentation License.

8b. WIKI RELICENSING
If the Work was previously published, with no Cover Texts, no Invariant Sections,
and no Acknowledgements or Dedications or Endorsements section,
in a system for massive public collaboration under version 1.2 of this License,
and if all the material in the Work was either initially developed
in that collaboration system or had been imported into it before 1 June 2006,
then you may relicense the Work under the GNU Wiki License.


Secret Gnu Wiki license was not published and may be will not.

new CreatioveCommons v.3.0 exist in draft too.
But they all are not legally compatible.

I repeat the question:
Are we need in compatibility with some sites under some specific licenses? Like technical review, etc.
Seems "Advanced Topics" only (possible).

Wilbert
20th January 2007, 14:44
I repeat the question:
Are we need in compatibility with some sites under some specific licenses? Like technical review, etc.
Seems "Advanced Topics" only (possible).
Could you elaborate a bit on what you mean here? Are you referring to some quoted stuff in some of these articles (quoted pieces from other websites)?

my (and IanB) opinion: we (you) must decide,
1) what are we want to permit, and what to do not.
(...)
May be different part of documentation may have diferent licenses.
(core filters, syntax - more strict to preserve,
faq, scripts at WiKi - more free to change by users).
We (and users) generally need in not in free but in correct documentation.

In my opinion everyone should be allowed to edit the documentation. Precisely because of the reason you say ... "correct documentation". I've seen a lot of useful corrections in the past by anonymous people.

2) Are we need in some inter-change with others (wikipedia, etc). or not.
Then we can select approriate license.
Yes that's a good one. Some issues (note that I haven't thought about this very well ...):

1) Users should be able to freely use and quote scripts from the official documentation. So scripts shouldn't and can't be licensed, because we "borrowed" many of them from the community.

2) As far as i know, there is no inter-change between wikipedia and official documentation. So it shouldn't be a problem if these licenses are not compatible. Of course there are problems with other sites (Japanese (avisynth.info) and Russian translation for example). I guess those need to be licensed too?

Fizick
20th January 2007, 18:52
Could you elaborate a bit on what you mean here? Are you referring to some quoted stuff in some of these articles (quoted pieces from other websites)?
...
As far as i know, there is no inter-change between wikipedia and official documentation. So it shouldn't be a problem if these licenses are not compatible.


Sorry my wrong wording.
Yes, in both cases I say about sites like wikipedia here.
Generally, some "standard" license give us compatibility (by quoting, and to be quoted) with some video-related sites.


2) Of course there are problems with other sites (Japanese (avisynth.info) and Russian translation for example). I guess those need to be licensed too?

Re-licensed?
Japanese (translate from mediaWiki) is currently under CC Attribution-NonCommercial-ShareAlike,
Russian (translated from off-line doc) is under GNU GPL :rolleyes:

If we try find some common, it is only BSD-type all-permission attribution license (or public domain).


In my opinion everyone should be allowed to edit the documentation. Precisely because of the reason you say ... "correct documentation". I've seen a lot of useful corrections in the past by anonymous people.


Of course, all doc parts may have the same free license.
IMHO: But some (core) parts may be editable at Avisynth Wiki by more limited number of people (developers).
These parts may be freely (under license) qouted-edited-distributed somewhere else, at forums, some other (not-official) sites and in articles.


1) Users should be able to freely use and quote scripts from the official documentation. So scripts shouldn't and can't be licensed, because we "borrowed" many of them from the community.


Lets try to analyze...
Scripts are generally published here at doom9 and similar forums and in plugins documentation.
Forum posting here (at doom9) is not under any license, so scripts are just copyrighed ?
But all scripts may be free used by anybody under "fair use" rule (for education, discussion, etc) without any additional license.
Some complex scripts and its decription are not (generally) "public domain", and we must ask its authors to reproduce and distribute (with attribution) them under new license. The best case if author put it to Wiki himself.
But on the other hand, all scripts usually :) consist of avisynth core and plugin functions calls, so they are (probably) may be considered as derivative works from avisynth, plugins and its documentation, and must be under same license (copyleft, shareAlike rule).
So, we (avisynth developers) may distribute these scripts under this license.
We need in users opinion here.
But I hope they will agree with any smart license.

IMHO, new avisynth documentation license must be set as a default license for wiki (and CVS off-line doc?), but some portions may be under other explicit license (for example, FilterSDK, some plugins documentation, etc).

Richard Berg
20th January 2007, 20:57
Forum posting here (at doom9) is not under any license, so scripts are just copyrighed ?

On most forums, when you sign up you agree that either your posts become (c) owned by the forum, or you have to grant the forum a perpetual license.

But on the other hand, all scripts usually consist of avisynth core and plugin functions calls, so they are (probably) may be considered as derivative works from avisynth, plugins and its documentation, and must be under same license (copyleft, shareAlike rule).

This is definitely not true. If I write a Python script I don't have to license it under the Python license.

Fizick
21st January 2007, 00:23
Richard Berg,
may be it is true on some forums, but not at forum.doom9.org,
I do not know any rule for license grant to this forum.

Registration to this forum is free! We do insist that you abide by the rules and policies detailed below. If you agree to the terms, please check the 'I agree' checkbox and press the 'Register' button below. If you would like to cancel the registration, click here to return to the forums index.

Although the administrators and moderators of Doom9's Forum will attempt to keep all objectionable messages off this forum, it is impossible for us to review all messages. All messages express the views of the author, and neither the owners of Doom9's Forum, nor Jelsoft Enterprises Ltd. (developers of vBulletin) will be held responsible for the content of any message.

By agreeing to these rules, you warrant that you will not post any messages that are obscene, vulgar, sexually-oriented, hateful, threatening, or otherwise violative of any laws.

The owners of Doom9's Forum reserve the right to remove, edit, move or close any thread for any reason.


About scripts. It is important question.
I do not know about Python. Probably AvsP editor is written with Python. AvsP code is released under GNU GPL.
What if you use some other script (copyrighted under some copyleft license) as a base for your script?
Usually compilators (like Python or VisualC) have a license permission to create user program under any license (but user can not redistribute documentation).

davidhorman
17th June 2007, 14:32
Could someone post step-by-step instructions on compiling simplesample 1.0b with VC++ 2005 Express Edition? There are some at http://avisynth.org/mediawiki/Filter_SDK/Compiling_instructions but they seem to be out of date, since there is no "file->new->win32 dynamic link library" in VC++ 2005 EE.

I've installed VC++ 2005 EE and the Platform SDK, but when trying to build simplesample (after making some educated guesses on how to get to that point), it can't find windows.h, which is in the Platform SDK - do I have to copy it from somewhere to somewhere else?

Alternatively, since I don't really know C++ but have passable knowledge of C, is there such a thing as a simplesample for C plugins?

David

Fizick
17th June 2007, 16:13
david, please create this step-by step instruction yourself!
It will be useful.
But here is some draft.

Install VC 2005 Express
Enable Win32 C code project options by editing some option files with notepad. see procedure at Miscrosoft VC Express page - http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

Install Platform SDK.



Ther are two ways to compile plugin:
1. Start from existant vc6.0 project and convert it to VC8 project. Siply open SimpleSample.dsw and agree to convert.
2. Start from scratch.

Consider second option: start from scratch.

Start VC express.
Menu: fiIe -> Create new project.
Select Win32 console appication.
Enter name of your new project and press OK.
You will in Win32 Appcilation Wizard.
Press Application Settings (left panel).
Select Application Type as DLL (but it may be console too).
At Additional options select "Empty project"
Add or create files (avisynth.h, simplesample.cpp).

Get to menu: Tools - Options. Open section "Project and solutions", select "VC++ directories".
See list "Show directories for":
Add new items
C:\Program Files\Microsoft SDK\Bin to "Executable files",
C:\Program Files\Microsoft SDK\Include to "Include files"
C:\Program Files\Microsoft SDK\Lib to "Library files"

davidhorman
17th June 2007, 17:50
Thanks Fizick, I'm now able to compile simplesample into a working DLL :cool:

:thanks:

David

Fizick
17th June 2007, 19:43
I updated http://avisynth.org/mediawiki/Filter_SDK/Compiling_instructions a little
please check/correct/ask
I do not use VC8 for plugins. I can use crazy config with VC2005 shell but with vc2003 compler (I hate manifest).
(I added a dirs, and remove unicode options for project service files)

davidhorman
17th June 2007, 22:18
I didn't perform this step:

Update the corewin_express.vsprops file.

But was able to compile SimpleSample with no problems.

David

Fizick
18th June 2007, 06:49
do you convert simplesample.dsw file or create new project?

davidhorman
18th June 2007, 10:54
Ah, I started a new project, it seemed to be the neatest thing to do.

David

davidhorman
9th October 2009, 00:31
So I'm back to developing Avisynth plugins after a long absence, which meant a new install of VC++ 2008 Express.

http://avisynth.org/mediawiki/Filter_SDK/Compiling_instructions is a slightly confusing page, but it indicates (as does http://avisynth.org/mediawiki/Filter_SDK/SDK_necessaries) that the Microsoft Platform SDK (now superceded by Windows SDK for Windows Server 2008 and .NET Framework 3.5) is necessary. As it's a 100mb+ download I decided to give it a try without, and was able to compile simplesample just fine.

Was whatever was needed included in the VC++ 2008 download, or is simplesample so simple that it isn't necessary?

David