64-bit deflicker

Support for my VirtualDub filters
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: 64-bit deflicker

Post by admin »

jpsdr wrote: Phaeron choose this way of doing things to optimize/reduce the process time. It's a waste of time to process a frame, if it has do be finaly discarded in the chain. Seeing like this, it makes perfect sense. 99.9999% of the time, there will be no unwanted effect.
Thanks for the clarification, but a reasonable decimate filter is going to want to decide based on the previous processing of a frame whether or not it should be decimated. So it still looks brain-dead to me. Please clarify matters if I am wrong about it.
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: 64-bit deflicker

Post by jpsdr »

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).
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: 64-bit deflicker

Post by admin »

There is no fixed pattern other than that I know the desired output frame rate. For example, I want to remove n frames out of every m frames and I determine which n frames to remove by comparing every frame to its preceding frame (before decimation).
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: 64-bit deflicker

Post by jpsdr »

You want to remove 2 frames each 5 frames.
The input is 20 frames :
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Can you tell me how you'll process the 20 frames, what number you'll compare with for each frame, and what will be the ouput criteria ?
How do you limit ? Are you working by "package" ? In that case, for exemple are you doing frames 0 to 4, then 5 to 9, etc...?
Something like this :
Input Frame : 0
Compare 0 and 1, and if Ok ouput 0 else ouput nothing.
Input Frame 1 :
Compare 0 and 1 and 2 and if Ok ouput 1 else ouput nothing.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: 64-bit deflicker

Post by admin »

Something like that. For my Avisynth Decimate filter, n is fixed to 1 and m is variable. For tritical's TDecimate filter, both n and m are variable. Either way, the n frames closest to duplicates are removed. This requires every frame to be examined.
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: 64-bit deflicker

Post by jpsdr »

admin wrote:Something like that.
... Well, you have the exemple i've described, as i said, you can request several previous/next frames when you process a frame (allowing to cover all the frames), so it's absolutely possible to do your decimate filter. For exemple, just by going by pack of m frames. I assume that in each m frames pack, you allways remove n frames. You're not realy totaly random, you're not for exemple removing no frames during 3*m frames, and suddenly removing 3*n frames in continous.
So, you'll have to think a little how to do according the way it works in VDub, but it's totaly possible.
Can't give more precise advices with just "Something like that"... ;)
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: 64-bit deflicker

Post by admin »

I did specify exactly what I wanted. The "something like that" was to denote that it didn't match exactly what you described.

Given what you said, I would have to ask if you are sure that VirtualDub will cache M frames, so that they need not be recalculated. Do you know the answer?

I'm not seriously intending to implement this, but I am interested theoretically.
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: 64-bit deflicker

Post by jpsdr »

admin wrote:Given what you said, I would have to ask if you are sure that VirtualDub will cache M frames, so that they need not be recalculated. Do you know the answer?
I don't know how internaly VDub does things, so, no...
Post Reply