PDA

View Full Version : How to store data in Avisynth plugin?? Varying of fps?


Walda
10th February 2003, 00:24
Hi,

I´m just finishing new version of very simple "smart" Logo - off plugin. ( Only because the Logo masters don´t have enough enthusiasm to convert their great RGB filters to YUY2 ot UV12).
The plugins is working ( for me good), but I´m not satisfied with the architecture of it.

The question is - how to store buffer with data, which are proccesed only once when loading the plugin, and when proccessing every frame it is only reading from this buffer. And how to free ( delete) memory for this buffer after encoding is done?
The storing data in some file and repeatedly reading of it for every frame seems to me slightly unhappy solution.

// Logo.cpp : Defines the entry point for the DLL application.

#include .....

unsigned char* smart = new unsigned char[255*255];

class Logo : public GenericVideoFilter
{

public:
Logo(PClip _child, int _fix, int _fiy, int _f_width, int _f_height, int _c, const char * _fileName, IScriptEnvironment* env) : GenericVideoFilter(_child), fix(_fix), fiy(_fiy), f_width(_f_width), f_height(_f_height), c(_c), fileName(_fileName)
{
here is smart proccessing
}
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env);
};

PVideoFrame __stdcall Logo::GetFrame(int n, IScriptEnvironment* env) {
Here is only reading from smart
}
AVSValue ...
extern "C" ...

The second question - when using Avisynth with some plugin, there is varying of fps when encoding ( in my case between 2-8fps.) Is it normal??

Zdenek W.

sh0dan
11th February 2003, 17:32
The question is - how to store buffer with data, which are proccesed only once when loading the plugin, and when proccessing every frame it is only reading from this buffer.


What's wrong with you current method - storing the data as a class member?? This is how it's done anywhere else.

Adding:
Logo::~Logo(void)
{
if (smart) delete[] smart;
}

Should solve your problems, and properly deallocate the data.

Is there a specific reason why you have a fixed size on your data - will it always be contained within 255*255 bytes?

The second question - when using Avisynth with some plugin, there is varying of fps when encoding ( in my case between 2-8fps.) Is it normal??

Well - some filters (like temporalsoften for instance) varies in speed depending on the data it recieves, but most filters take the same processing time. What might be the root of the problem is that virtual dub has two separate threads for reading and writing (encoding) data. That makes the fps jump, as the threads doesn't always get the same amount of frames done within a time-sample period (the time between fps measures).

Use xvid with "null transform mode" - this will disable encoding, and therefore give a more stable image of the framerate.