PDA

View Full Version : avisynth, feature request


jmac698
1st March 2006, 04:01
First,
now that I've written some filters I can really appreciate this program. It's so easy now to play with algorithm ideas that it opens up a whole new world. This is a remarkable program, it's very powerful and seems to be quite mature.

There are some things that frustrate me as a filter writer. I want basic operations, unimpeded, as 8bit numbers and independently and between all planes. This seems to be only possible in rgb. Most functions are inherently video-oriented, trying using brightness to multiply by a value, and you'll have to calculate logs.

What I would like to see is basic operations directly on all colorspaces, like and/not/xor,+,-,*,/, then I would be happy.

My other problem is with precision. Many times I wish I had even 9bit numbers, or signed numbers, as an intermediate format.

Here's an example. I had to calculate Y-U, Y is a positive value, U is a signed value in offset128. I can't subtract them directly, so I do
prp=rgbadjust(pr,rb=-128,gb=-128,bb=-128)
prn=rgbadjust(pr.invert(),rb=-127,gb=-127,bb=-127)

and then I do it in two steps:
ypb=overlay(y,pbp,mode="add",pc_range=true)
ypb=overlay(y,pbn,mode="subtract",pc_range=true)


Yes, I could use C in one line, but it's beyond me right now. Script is *so* much more accessible, quicker, less learning curve.

Documentation:
I would like to see documentation of the exact operations each function does. I had to figure out the hard way that merge does a*(1-w)+b*w, or that brightness uses a log function, or that rgbadjust seems to round up on x.5 numbers.

IanB
1st March 2006, 08:19
Sorry, no support for other than 8 bit any time soon.

This is an open source project, so you can read how something is implemented.

Wilbert is always looking for volunteers to help with the doco.

Manao
1st March 2006, 10:29
Did you ever have a look at the masktools ? They work on yv12 only, but they do what you want.

jmac698
1st March 2006, 22:28
@IanB
Thanks for your response. I will be brief on your valuable time;

Pixel access, eg color=POINT(clip,x,y) , PSET as well, can't be too hard?

The benefits :
-Autocrop,
-Autocalibrate, or if ColorYUV(analye=true) could return the info as scalar variables.
-Comparing frames, finding and correcting pixel dust. I could use this right now for a project.

Opensource is great, but I'm not personally in a position to work on avisynth, I can always beg you instead :)

@Wilbert: do you have a list of doco needs you need help with?

@Manao: mvtools is great! yv12LUT seems to meet many of my requirements. I'm still stuck on the precision issue, and I still have no way to access pixels in script. I have a requirement right now to read pixels, subtract from co-location in another file, to create a calibration value for my filter.

foxyshadis
1st March 2006, 23:44
Document help: http://forum.doom9.org/showthread.php?t=105205

Touching individual pixels really sounds like a plugin-level issue. You can always get c++ express 2005 from microsoft and simplesample to get started making a quick and dirty plugin. Even if you could hack it into conditionals, it would run at seconds per frame or more, to read and touch each pixel, there's so much overhead between the script and video, compared to c++ filters.

In fact, an autocrop plugin exists, and several attempts at whitebalancing (ie, autocalibration).

jmac698
2nd March 2006, 17:15
@foxyshadis:
There may be autocrop plugins, but autowhite is not the same as reading colorbars and determining saturation, contrast, brightness, and hue, as Dscaler does. In this case I only need to read the average value of an area of pixels on a plane. That's pretty fast. Think how convient it would be to check MSE, noise, color values, aspect, etc. with one or two tests.
But if I can't convince you, I'll have to write it myself. I'm not too hopeful however, and the point is that several scripts will be lost because of the barrier to entry. Look at a recent comment by MOD, she/he said they starting writing scripts because it was so easy. Under General Discussion, help me with mediawiki, 3rd page. Heck, Component4All is an idea I had years ago, and only avisynth allowed me to test it.

There was a recent article on /. as well about bringing coding to the masses with scripting power. I'll find these references if it might convince you :) Unless some other coder out there wants to put it in a plugin... mvtools *wink* I think area(clip,x1,y1,w,h,plane,op) (op=avg, variance..?) would be nice.

Wilbert
2nd March 2006, 17:24
Don't forget to read about the other attempts: http://forum.doom9.org/showthread.php?t=106196!

Fizick
5th March 2006, 18:42
And don't confuse mvtools with masktools. :)

hanfrunz
6th March 2006, 20:48
Pixel access, eg color=POINT(clip,x,y) , PSET as well, can't be too hard?


Is this really possible with a plugin? How can i return an integer or byte? my filters always return a clip. Can somebody give me a hint? I don't know if we really need this filter, but it sounds very interesting.

thanks,
hanfrunz

jmac698
6th March 2006, 21:12
@wilbert: thanks that was useful.
@hunfrunz: perhaps I could survey and see if anyone else can think of a need. I do know that I'm stuck now and there's lots of things I want to write but I can't. I've done extensive research into calibration and test signals and now I am in a good position to implement my knowledge, otherwise, it will fall out of my head until some years from now maybe someone else has the same idea.
Knowing the average value of pixels in a rectangular area, per plane in rgb, would help me right now.
If you could do this, I will write autocrop, aspect ratio, colorbar calibrations, multi-cap calibrations.

ps could you measure the PLUGE and -I, Q areas on smpte eg1 1990 colorbars for me?

hanfrunz
6th March 2006, 21:24
ps could you measure the PLUGE and -I, Q areas on smpte eg1 1990 colorbars for me?

-I an Q? Uhh that's NTSC stuff :) I check if i find some NTSC testpatter-generator... i live in the PAL-world...

jmac698
6th March 2006, 22:52
Ok,
well thanks for your previous measurements, they are exact to the standard and quite helpful.

jmac698
8th March 2006, 02:36
@hanfrunz,
here is how to return some strings:
/** GetSystemEnv
*
* Retrieves the value of the specified environment variable.
*
* Callback passed to the scripting environment.
*
* PARAMETERS:
* args - The array of arguments passed to this filter
* from the script.
* See filter documentation for details.
* IN/OUT userDataP - (unused)
* IN/OUT envP - Pointer to the AviSynth scripting environment.
*
* RETURNS:
* The string associated with the specified environment variable.
* If not found, returns the "undefined" AviSynth value.
*/
static AVSValue __cdecl GetSystemEnv(AVSValue args, void* /* userDataP */, IScriptEnvironment* envP)
{
const char* varName = args[0].AsString();
const char* val = getenv(varName);
return (val == NULL) ? AVSValue()
: AVSValue(envP->SaveString(val, strlen(val)));
}
That's almost complete gibberish to me, I can sorta read it but I know I couldn't write it. Thanks for the help, but I know there's no way I can write the filter I want.

And attached is how to read pixelvalues. There's just a few lines you have to change, from writing a string to a file to writing a string to an avisynth variable.

There's a major limitation in avisynth, there's no way to get external data into a script - if I could do a ReadFile() into a string, I could even get by, by saving BMPs and parsing them back, or reading the DumpPixelValues filters' file.

Wilbert
8th March 2006, 11:14
There's a major limitation in avisynth, there's no way to get external data into a script - if I could do a ReadFile() into a string, I could even get by, by saving BMPs and parsing them back, or reading the DumpPixelValues filters' file.
Perhaps ConditionalReader (http://www.avisynth.org/ConditionalReader) can help you here.

jmac698
8th March 2006, 15:43
conditionalreader is very restrictive. I need to read this:
D:\test\colors.log
DumpPixelValues for YUV: (100,100),(300,200),(600,50)
3A/6F/B1 74/A7/5F D7/7A/79
3A/6F/B1 74/A7/5F D7/7A/79

While conditionalreader will accept this:
Type float
Default 3.45567

R 45 300 76.5654
2 -671.454
72 -671.454

Wilbert
8th March 2006, 15:58
If you have 6 values per frame (Ymin, Ymax, Umin, ...), you need to use ConditionalReader six times in your script, assigning them different variables. Thus

BlankClip()
ScriptClip("subtitle(string(Ymin)+string(Ymax))") # or something like that
ConditionalReader("Ymax.txt", "Ymax", false)
ConditionalReader("Ymin.txt", "Ymin", false)

----------

Ymax.txt:

Type int
Default 235

0 200
1 201
2 202
R 3 10 235
11 200
...

----------

Ymin.txt:

Type int
Default 16

0 200
...

----------

Of course, it's easier if you make a plugin instead of a script.

jmac698
8th March 2006, 17:04
that doesn't help. The output of dumppixelvalues filter is something I can't change. Since it outputs as hex, there is no space between numbers, and I can't input a string, there's nothing I can do.. unless I could rewrite dumpixel.
ps, Groetjes :)

hanfrunz
8th March 2006, 21:52
i am playing with a new filter right now.

I plan to implement these functions:

PixelInfoGUI() - shows Info of a pixel, you can move a cursor in the video to select a pixel (external GUI)

PSET(x,y,color) - Set color of a pixel
PGET(x,y) - Get pixel color

DrawLine(x1,y1,x2,y2,color) - draw a line

other functions may follow :)

latest infos will be posted in a new thread, if a have the first version working.

jmac698
8th March 2006, 23:19
That's a great announcement, I'm looking forward to it ;)
Please see http://www.avisynth.org/warpenterprises/files/dumppixelvalues_25_dll_20040223.zip
Most of the code is written for you.
In a few days I should have a test version of my script which could use your filter, a real calibration. Plans are to automatically detect crop, and also to tell you how to set your adjustment sliders. It will detect the model of changing, auto detect the colorbars you are using (100/75 or 75/75 or SMTPE) and even tell you if you officially pass the standard for accurate adjustments.
I also found a way to generate accurate colorbars, most chips have this function internally and it is exactly accurate.

There's other uses for reading pixels, VBI data. I could decode these to captions in realtime, unless vsfilter can do that.

hanfrunz
13th March 2006, 12:25
the announced filter can be found here (http://forum.doom9.org/showthread.php?t=108602). Please discuss it in the new thread.