Gavino
11th October 2009, 18:03
Sometimes plugins require to write text on a frame, either as part of their basic functionality (eg DVInfo), or for error reporting or diagnostics. This can be done using Subtitle (via env->Invoke) to write the text but is quite slow, especially if the text needs to vary from frame to frame.
It would be useful if plugin writers had access to the internal function ApplyMessage, used internally by Avisynth for this purpose. The question of making it available was asked as long ago as 2003 (see here), but was never answered.
I think it could be done by providing a new function within IScriptEnvironment in avisynth.h, eg
void ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,
int textcolor, int halocolor)
which would be a wrapper to call the 'real' ApplyMessage from new code in avisynth.cpp.
(Incidentally, the existing ApplyMessage has two arguments (bgcolor and env) which are not actually used.)
Currently, if you want to build your own ApplyMessage, you can use the relevant parts of the Avisynth source code in your plugin (subject to GPL of course), but this involves carving out parts of:
- text-overlay.h and .cpp : ApplyMessage, LoadFont and class Antialiaser
- convert.h : RGB2YUV
- internal.h : ScaledPixelClip, class _PixelClip, extern PixelClip
- focus.h : PixelClip definition (odd place for this to be!)
Being able to just write env->ApplyMessage(...) would be much more convenient.
I suppose one drawback is that plugins needing this prospective new function could not be used on earlier Avisynth versions, but by that argument you could never extend IScriptEnvronment at all.
It would be useful if plugin writers had access to the internal function ApplyMessage, used internally by Avisynth for this purpose. The question of making it available was asked as long ago as 2003 (see here), but was never answered.
I think it could be done by providing a new function within IScriptEnvironment in avisynth.h, eg
void ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,
int textcolor, int halocolor)
which would be a wrapper to call the 'real' ApplyMessage from new code in avisynth.cpp.
(Incidentally, the existing ApplyMessage has two arguments (bgcolor and env) which are not actually used.)
Currently, if you want to build your own ApplyMessage, you can use the relevant parts of the Avisynth source code in your plugin (subject to GPL of course), but this involves carving out parts of:
- text-overlay.h and .cpp : ApplyMessage, LoadFont and class Antialiaser
- convert.h : RGB2YUV
- internal.h : ScaledPixelClip, class _PixelClip, extern PixelClip
- focus.h : PixelClip definition (odd place for this to be!)
Being able to just write env->ApplyMessage(...) would be much more convenient.
I suppose one drawback is that plugins needing this prospective new function could not be used on earlier Avisynth versions, but by that argument you could never extend IScriptEnvronment at all.