View Full Version : complete noob to C++... need some guidance in coding a filter.
tedkunich
23rd August 2004, 19:47
Forgive this simplest of questions, but as I know nothing of C++, I'm kinda stumped on a problem. I would like to read in the contents of a file indicating which frame to perform a function on. Is there a way to setup and reserve a block of memory in the filter where I can load the file's contents only once so I do not have to reload and parse it with every frame? I know enough C to be able to modify SimpleSample and a few other snippets of code to compile my filter. Any thoughts???
Also, any thoughts on what would be the most effecient way of substituting a frame with a BMP or PNG within my filter? convert the source video to RGB prior to passing it to the filter, or convert the BMP to YV12 and then replace the Y, U, and V planes? I was looking at ReadImage and WriteImage source for inspiration, but did not see a easy route to the second option - I would like to remain in the YUV color space without converting to RGB if possible.
Thanks
T
Fizick
23rd August 2004, 23:24
1. In constructor you must allocate memory block (declared as public), and read file here. (not in GetFrame).
2. It is not simple question. I wonder, if you do not see two thread:
http://forum.doom9.org/showthread.php?s=&threadid=80859
http://forum.doom9.org/showthread.php?s=&threadid=81022
tedkunich
24th August 2004, 04:55
Originally posted by Fizick
1. In constructor you must allocate memory block (declared as public), and read file here. (not in GetFrame).
2. It is not simple question. I wonder, if you do not see two thread:
http://forum.doom9.org/showthread.php?s=&threadid=80859
http://forum.doom9.org/showthread.php?s=&threadid=81022
Thanks Fizick.
I am aware of those threads, but I see that effort getting a bit more involved than what my needs are - hanfrunz's filter currently does not read in the still frames and weave them into a clip... his focus is on being able to export and edit frames in pseudo realtime. That is a worthy undertaking, but not what I need for my project, thus the effort to write my own. I took a look at the source for XLogo and it has given me plenty of direction.
Thanks
T
PS wanted to also express thanks to you for your Despot filter it works great most of the time. My filter is toward the remaining 5% that your filter has trouble with... it work a little TOO well - like deleting star fields :D
Bidoche
24th August 2004, 11:57
1. You probably better should use a data structure from the standard lib and fill it with your parsed data. (a vector ?)
I realize they may look intimidating for a C++ newbie, but they are worth the learning time.
2. Can't you use Invoke to spawn ImageReader and ConvertToY12 ?
tedkunich
24th August 2004, 16:23
Originally posted by Bidoche
1. You probably better should use a data structure from the standard lib and fill it with your parsed data. (a vector ?)
I realize they may look intimidating for a C++ newbie, but they are worth the learning time.
2. Can't you use Invoke to spawn ImageReader and ConvertToY12 ?
@ Bidoche
Thanks for the pointers. Any hints as to what/where examples of these structures would reside? I have not perused the entire source sode for the 2.5 build - I went direct to the Imageread/write source.
As to invoke - I saw that in the XLogo source. It it as simple to use as it looks? would certainly be nice to not have to reinvent the wheel for the image reader/decoder.
Thanks
T
Wilbert
24th August 2004, 16:28
Here's an example with Invoke:
http://www.avisynth.org/EnvInvoke
Bidoche
25th August 2004, 11:38
@tedkunich
http://www.sgi.com/tech/stl/table_of_contents.html
Here is the STL reference I am using, it doesn't include nor tutorials nor examples, but I am sure google knows about lots of them.
Here is a small sample of code using vector, which is probably what you need :
class MyFilter : ...
std::vector<int> frameList_;
//constructor
MyFilter( ...
{
while( ... there are ints ... )
{
... parse val from the file
frameList_.push_back(val); //add at end of the vector
}
}
virtual PVideoFrame GetFrame(int n, ...
{
//search if n is in the vector (check doc for find for details)
if ( std::find(frameList_.begin(), frameList_.end(), n) != frameList_.end() )
... do something
...
}
...
};
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.