Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
30th June 2011, 13:39 | #1 | Link |
Registered User
Join Date: Mar 2010
Posts: 98
|
Filter SDK: How to create new PClip of PVideoFrames?
I want to invoke a internal filter (resizer) and feed it with two temporary images I created.
Since I cannot invoke a filter with PVideoFrame, I need to create a new PClip with my two PVideoFrames, how can I do that? I looking for something like this: Code:
PClip tmpin, tmpout; PVideoFrame inA, inB, outA, outB; tmpin = env->NewClip(vi); ... tmpin->AddFrame(inA); tmpin->AddFrame(inB); AVSValue args[...] = { tmpin, ... }; tmpout = env->Invoke("Resize",AVSValue(args,...)).AsClip(); outA = tmpout->GetFrame(0,env); outB = tmpout->GetFrame(1,env); |
30th June 2011, 14:04 | #2 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Define a new subclass of IClip whose GetFrame() returns inA for frame 0 and inB for frame 1, then create an instance of it. inA and inB could be made parameters of the constructor. You will also have to provide appropriate implementations of the other virtual functions of IClip in your new class - see GenericVideoFilter in avisynth.h for a guide.
|
30th June 2011, 14:06 | #3 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
You want to create a source filter. Have a look at how BlankClip works (avisynth\src\sources\source.cpp). Its a bit messy with all the argument parsing code, just ignore that part.
Code:
class StaticImage : public IClip { const VideoInfo vi; const PVideoFrame frame; bool parity; public: StaticImage(const VideoInfo& _vi, const PVideoFrame& _frame, bool _parity) : vi(_vi), frame(_frame), parity(_parity) {} PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) { return frame; } void __stdcall GetAudio(void* buf, __int64 start, __int64 count, IScriptEnvironment* env) { memset(buf, 0, (size_t)vi.BytesFromAudioSamples(count)); } const VideoInfo& __stdcall GetVideoInfo() { return vi; } bool __stdcall GetParity(int n) { return (vi.IsFieldBased() ? (n&1) : false) ^ parity; } int __stdcall SetCacheHints(int cachehints,int frame_range) { return 0; }; }; Fill out a VideoInfo structure to represent your clip. Code:
static AVSValue __cdecl Create_BlankClip(AVSValue args, void*, IScriptEnvironment* env) { VideoInfo vi_default; memset(&vi_default, 0, sizeof(VideoInfo)); VideoInfo vi = vi_default; vi_default.fps_denominator=1; vi_default.fps_numerator=24; vi_default.height=480; vi_default.pixel_type=VideoInfo::CS_BGR32; vi_default.num_frames=240; vi_default.width=640; vi_default.audio_samples_per_second=44100; vi_default.nchannels=1; vi_default.num_audio_samples=44100*10; vi_default.sample_type=SAMPLE_INT16; vi_default.SetFieldBased(false); .... |
|
|