Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

 
Frame Rate Doubling Using Sdk, Best Practice?
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
xinu
Posted: Nov 24 2009, 08:50 PM


Newbie


Group: Members
Posts: 2
Member No.: 26503
Joined: 24-November 09



Hi,

I'd like to double the output frame rate only using VDPluginSDK-1.1, deriving from the VDXVideoFilter class.

I've tried the following in the GetParams() method, after perusing the internal fieldbob2 source code:
CODE

fa->dst.mFrameRateHi *= 2;
if (fa->dst.mFrameCount >= 0)
 fa->dst.mFrameCount *= 2;


But the fa->src->mFrameNumber in the Run() method keeps incrementing by 1 per call. I expected the Run() to be called twice per dst (?)

What is the recommended way to handle this?

Cheers!
 
     Top
phaeron
Posted: Nov 25 2009, 06:20 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



Hmm, I can't reproduce this. Here's my hacky test filter:
CODE

#include <crtdbg.h>
#include <vd2/VDXFrame/VideoFilter.h>
#include <vd2/VDXFrame/VideoFilterEntry.h>

class Filt : public VDXVideoFilter {
public:
uint32 GetParams() {
 fa->dst.mFrameRateHi *= 2;
 if (fa->dst.mFrameCount >= 0)
  fa->dst.mFrameCount *= 2;
 return 0;
}

void Run() {
 _RPT2(0, "frame %d -> %d\n", (int)fa->src.mFrameNumber, (int)fa->dst.mFrameNumber);
}
};

VDXVideoFilterDefinition<Filt> g_filter("double", "foo", "bar");

VDX_DECLARE_VFMODULE()

VDXFilterDefinition *VDXGetVideoFilterDefinition(int index) {
if (!index--) { return &g_filter; }
return NULL;
}


This is the output it produces when I step through frames:

CODE

frame 0 -> 0
frame 0 -> 1
frame 1 -> 2
frame 1 -> 3
frame 2 -> 4
frame 2 -> 5
frame 3 -> 6
frame 3 -> 7
frame 4 -> 8
frame 4 -> 9
frame 5 -> 10
frame 5 -> 11
frame 6 -> 12
frame 6 -> 13

 
    Top
xinu
Posted: Nov 25 2009, 08:21 AM


Newbie


Group: Members
Posts: 2
Member No.: 26503
Joined: 24-November 09



Thanks, but when using Prefetch2, it appears I need to override the Prefetch too (the GetParams is as you specified):

CODE

sint64 MyFilter::Prefetch(sint64 frame)
{
   return frame >> 1; // This does the trick of framerate doubling with Prefetch2
}

bool MyFilter::Prefetch2(sint64 frame, IVDXVideoPrefetcher *prefetcher)
{
prefetcher->PrefetchFrame(0, Prefetch(frame) - 1, 0); // Prev
prefetcher->PrefetchFrame(0, Prefetch(frame), 0); // Curr
prefetcher->PrefetchFrame(0, Prefetch(frame) + 1, 0); // Next
return true;
}

void MyFilter::Run()
{
   logMessage(str(format("  prev=%d") % fa->mpSourceFrames[0]->mFrameNumber));
   logMessage(str(format("  curr=%d") % fa->mpSourceFrames[1]->mFrameNumber));
   logMessage(str(format("  next=%d") % fa->mpSourceFrames[2]->mFrameNumber));
   logMessage(str(format("  dest=%d") % fa->dst.mFrameNumber));
}


Is this by design? (using version 1.9.7)
 
     Top
phaeron
Posted: Nov 26 2009, 03:33 AM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



No, you only need to override Prefetch2. You also shouldn't need to call Prefetch() from Prefetch2(), which if you were doing before would have been the source of your problem. Prefetch() is a routine you optionally provide, and if you were calling it, you were invoking the stub implementation in VDXVideoFilter instead.
 
    Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
3 replies since Nov 24 2009, 08:50 PM Track this topic | Email this topic | Print this topic

<< Back to VirtualDub Filters and Filter Development