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.

 
Filters And Frame Cutting
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
hwahlberg
Posted: Sep 29 2014, 10:01 PM


Newbie


Group: Members
Posts: 3
Member No.: 38297
Joined: 29-September 14



Hi.

Experimenting with ExoticPan (my slightly improved ExoticPan has just vensyhttp://rationalqm.us/board/viewtopic.php?f=10&t=381) it appears that the filter is fed the raw frame numbers.
(in case of cutting out frames, VDub shows the output frame numbers in the status line)

I can't give good arguments whether ExoticPan should use raw or output frame numbers. But now it uses the Raw ones.
(One advantage is that the ExoticPan setup in not thrown off in case you cut out some frames, after setting up ExoticPan)

A slight problem in that context is, that when cutting out frames and setting up ExoticPan interactively, you loose track of the raw frame number.

My question is, which API can I use from the filter configuration dialog, to read the current raw and output frame number?

/henik..
 
     Top
dloneranger
Posted: Sep 30 2014, 12:56 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



Simple answer, you can't

Long answer, even if you try to keep track of the output number yourself, virtualdub may request frames out of order and multiple times (depending on other filters in the chain)

--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
hwahlberg
Posted: Sep 30 2014, 06:57 PM


Newbie


Group: Members
Posts: 3
Member No.: 38297
Joined: 29-September 14



Hi dloneranger.

Thank you.
A clarification please, your statement puzzles me.
Please disregard filters with random frame behavior, for which i don't see any practical purpose.

When can I experience a situation where there is not a one to one mapping from output frame to input frame number?
Is this documented somewhere I can look up?

Best regards Henrik.
 
     Top
dloneranger
Posted: Sep 30 2014, 08:52 PM


Moderator


Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07



Any filter that modifies the frame rate or removes frames
Virtualdubs IVTC filter for instance (when reducing frame rate)
For each output frame, it reads surrounding frames and skips the 1-in-5 that's most likely a duplicate
In this case if your filter was before or after the IVTC filter you'd get different behaviour as well

What I meant to get at though was that you couldn't keep track of the real output frame number yourself by doing something like setting an int64 to 0 in the filter's init code and then just adding 1 to that in the filters run code
It may work in simple testing, but fail in real world usage when virtualdub calls the run code many times for the same frame
If there's an IVTC filter in the chain the run code could be called a lot of times for each frame
Virtualdubs multithreading and process ahead code also complicates attempts at keeping a count yourself

[edit]
Also, as this can be done by plugin filters as well you have to expect the oddest things to happen eg I might write an IVTC type filter that prefetches the groups of frames to compare in a backwards order or possibly center frame, +1-1,+2-2, +3-3 etc
If you're before that in the chain, you're doomed ;-)


--------------------
MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask
Windows7/8 Codec Chooser
All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3
 
    Top
jpsdr
Posted: Oct 1 2014, 07:13 AM


Advanced Member


Group: Members
Posts: 335
Member No.: 20490
Joined: 23-December 06



I don't know if it's what you're lookig for :
CODE

const VDXFBitmap& pxsrc2 = *fa->mpSourceFrames[0];

pxsrc2.mFrameNumber

You'll have the current frame number.
But, as dloneranger said, if you have in filter chain a filter that remove frame, it's a little tricky.
If for exemple, you have a filter in your chain which remove frame n°2 each 5 frames.
Input is 10 frames, 0 to 9 : 0,1,2,3,4,5,6,7,8,9
What will happen ??? In fact, it's tricky.

Before filter which remove frames :
- Case 1 : Filter which remove frames doesn't prefecth other frames.
All the filters in the chain will process only 8 frames. So, all the filters before the one removing frames (and itself also), will process frames : 0,1,3,4,5,6,8,9. And, these are the values you will get with pxsrc2.mFrameNumber.
- Case 2 : Filter which remove frames prefecth other frames.
All the filters before it (and including it) will probably process between 8 to 10 frames, according which frames are prefetched. You'll get their value as described before.

After filter which remove frames :
All filters will process only 8 frames, and frames a re-numbered, and you will get with pxsrc2.mFrameNumber : 0,1,2,3,4,5,6,7.
 
     Top
hwahlberg
Posted: Oct 1 2014, 09:58 PM


Newbie


Group: Members
Posts: 3
Member No.: 38297
Joined: 29-September 14



Hi jpsdr.

My problem is that I would like to show the currently selected frame in the setup dialog.
So i did this:
CODE

static BOOL APIENTRY resizeDlgProc( HWND hDlg, UINT message, UINT wParam, LONG lParam) {
       MyFilterData *mfd = (struct MyFilterData *)GetWindowLong(hDlg, DWL_USER);
       SetDlgItemInt(hDlg, IDC_lCurrentFrame, mfd->lCurrentFrame, TRUE);

So in the callback for frame handling:
CODE

static int resize_run(const FilterActivation *fa, const FilterFunctions *ff) {
      MyFilterData *mfd = (MyFilterData *)fa->filter_data;
      mfd->lCurrentFrame = fa->pfsi->lCurrentFrame;

This shows the output frame that I wish, not the raw frame as VDUB shows in the status line.
Then it may calculate wrong in some filter situations, like dloneranger points out, but in most cases will give good usability biggrin.gif
Also, when adding this filter, callback has not been called yet, so it shows 0.

If using the preview pane, i need to repeat the SetDlgItemInt() when the slider is moved. Thinking a timer can be used.

Thanks for pointing me in this direction wink.gif

Best regards Henrik.
 
     Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
5 replies since Sep 29 2014, 10:01 PM Track this topic | Email this topic | Print this topic

<< Back to VirtualDub Filters and Filter Development