Hum... By decimate, we agree you want to change the frame rate, and so you'll remove frames according a proper repetive pattern, you'll not create a total thing. Maybe if you'll explain within a few lines what exactly your decimate filter do (and very roughly the algorithm if choice have to be made) or what you want to do ?
If there is parameters, you can explain to me with an exemple of a fixed value.
Don't forget that you can request previous and next frames also. For exemple, if you want to decimate by 4, choosing to output a mix of the current and previous frames. You'll do the following :
Code: Select all
uint32 YOURFILTER::GetParams()
{
const VDXPixmapLayout& pxsrc = *fa->src.mpPixmapLayout;
VDXPixmapLayout& pxdst = *fa->dst.mpPixmapLayout;
int64_t frame_count_h,frame_count_l;
VDFraction fr(fa->dst.mFrameRateHi, fa->dst.mFrameRateLo);
fr *= VDFraction(1,4);
fa->dst.mFrameRateHi = fr.getHi();
fa->dst.mFrameRateLo = fr.getLo();
frame_count_h=fa->dst.mFrameCount/4;
frame_count_l=((fa->dst.mFrameCount%4)>=2) ? 1:0;
fa->dst.mFrameCount=frame_count_h+frame_count_l; <- Here, you'll tell how number of total frame you'll output, changing the value
return(FILTERPARAM_SUPPORTS_ALTFORMATS);
}
bool YOURFILTER::Prefetch2(sint64 frame, IVDXVideoPrefetcher *prefetcher)
{
prefetcher->PrefetchFrame(0,(frame << 2)+3 ,0); <- Here, you tell what input number frame you want for the oupout.
prefetcher->PrefetchFrame(0,(frame << 2)+2,0); <- Here, you tell that you'll want also the previous frame.
return(true);
}
So, in
Getparams, you'll tell that you'll reduce the number of frame by 4. Your 100 frames video, will be 25 frames.
In
Prefetch2, you'll tell, what input number frame you want for what ouput. VDub will first run
Prefetch2 will all the values of
frame to build a table i think.
So, here, you're saying that for output frame number 0, you want input number 3, and 2. For output frame 1 you want 7 and 6, etc...
So, in your
Run function, when you'll process your ouput frame number 0, you'll have in the buffer the input frame 2 and 3, etc...
So, if we stay like this, VDub will find that it only needs the frames 2,3,6,7,10,11, etc...
So, the previous filters in the filter chain will only receive the frames 2,3,6,7,10,11, etc... The frames 0,1,4,5 etc... will never be send to the process chain, beacause VDub identified that they were not needed (assuming all the other filters in the filter chain before and after the decimation are "nice" filters needing only the current frame, and don't change frame rate or anything else, to keep the exemple simple and clear).