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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 30th June 2011, 13:39   #1  |  Link
xv
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);
Is something like this possible or is there another solution?
xv is offline   Reply With Quote
Old 30th June 2011, 14:04   #2  |  Link
Gavino
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.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 30th June 2011, 14:06   #3  |  Link
IanB
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; };
};
Doctor the GetFrame implementation to return the pixel data you require.

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);
....
IanB is offline   Reply With Quote
Old 1st July 2011, 12:49   #4  |  Link
xv
Registered User
 
Join Date: Mar 2010
Posts: 98
Thanks, I´ve used the subclass method, that was mostly copy&paste from avisynth.h.
xv is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:27.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.