|
|
| aleksas |
| Posted: Feb 10 2011, 03:00 PM |
 |
|
Newbie

Group: Members
Posts: 4
Member No.: 29895
Joined: 10-February 11

|
I stumbled upon several issues while writing a video filter...
* Writing a tool-like filter that stores different data per frame. Data is to be controlled through filter settings window. Problem here is that filter interface doesn't provide any callback for preview frame change event needed to update picture within settings window. To partially solve this problem I've made a window-hook to listen for WM_NOTIFY message, which is not good. Is there currently any other way to listen for frame change in preview window?
* Next issue: Since filter holds data per video frame it's absolutely vital to know if video source file has changed to know when to reset filter data. Would be great to have appropriate callback or some kind of indicator for source change.
* Not an issue but rather a question. Wouldn't it be good to have standard VirualDub controls like slider accessible through Plugin SDK? |
 |
| dloneranger |
| Posted: Feb 10 2011, 10:57 PM |
 |
|
Moderator
  
Group: Moderators
Posts: 2366
Member No.: 22158
Joined: 26-September 07

|
I've read this a few times and I'm not even sure I know what it is you're after
| QUOTE | | Writing a tool-like filter that stores different data per frame. Data is to be controlled through filter settings window. Problem here is that filter interface doesn't provide any callback for preview frame change event needed to update picture within settings window. To partially solve this problem I've made a window-hook to listen for WM_NOTIFY message, which is not good. Is there currently any other way to listen for frame change in preview window? |
What kind of event are you after?
When you make a change in a filter settings windows you do something like if ( mpPreview ) mpPreview->RedoFrame(); That causes the preview window to be redrawn (calling your runproc)
When the preview window does something like move forwards 1 frame, runproc gets called for the new frame (unless the frame is already buffered)
Those are the only 2 events I can think of Maybe you could explain what you mean in more detail?
-------------------- MultiAdjust JoinWav WavNormalize FFMPeg Input Plugin v1827 UnSharpMask Windows7/8 Codec Chooser All FccHandlers Stuff inc. Installers for acm codecs AAC, AC3, LameMp3 |
 |
| phaeron |
| Posted: Feb 13 2011, 10:37 PM |
 |
|

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

|
| QUOTE | | Writing a tool-like filter that stores different data per frame. Data is to be controlled through filter settings window. Problem here is that filter interface doesn't provide any callback for preview frame change event needed to update picture within settings window. To partially solve this problem I've made a window-hook to listen for WM_NOTIFY message, which is not good. Is there currently any other way to listen for frame change in preview window? |
Currently, no. You will get requests to generate frames, but with frame caching it's possible for the filter to be skipped. I've been meaning to expand the filter preview API at some point.
| QUOTE | | Next issue: Since filter holds data per video frame it's absolutely vital to know if video source file has changed to know when to reset filter data. Would be great to have appropriate callback or some kind of indicator for source change |
I assume you're talking about settings, because if it's derived data, this already exists: you're not supposed to assume anything about the source across different start/end brackets or across a call to eventProc with the InvalidateCaches event.
For settings, that's a bit trickier. For instance, should the data be invalidated if an upstream filter is removed and the filter is now receiving a stream at double the frame rate?
| QUOTE | | Not an issue but rather a question. Wouldn't it be good to have standard VirualDub controls like slider accessible through Plugin SDK? |
I intentionally don't do this, in order to keep the API manageable and to make it easier to upgrade the controls without having to worry about backwards compatibility. |
 |
| aleksas |
| Posted: Feb 14 2011, 10:20 AM |
 |
|
Newbie

Group: Members
Posts: 4
Member No.: 29895
Joined: 10-February 11

|
| QUOTE | | Currently, no. You will get requests to generate frames, but with frame caching it's possible for the filter to be skipped. I've been meaning to expand the filter preview API at some point. |
Managed to solve it without hooking. Just by posting custom message to settings window on each Run call. Much better even with skipping some frames due to cache.
| QUOTE | I assume you're talking about settings, because if it's derived data, this already exists: you're not supposed to assume anything about the source across different start/end brackets or across a call to eventProc with the InvalidateCaches event.
For settings, that's a bit trickier. For instance, should the data be invalidated if an upstream filter is removed and the filter is now receiving a stream at double the frame rate? |
Could you explain in little bit more detail about InvalidateCaches. |
 |
| aleksas |
| Posted: Feb 14 2011, 11:30 AM |
 |
|
Newbie

Group: Members
Posts: 4
Member No.: 29895
Joined: 10-February 11

|
One more issue arose. I was reordering my code and tried to rearrange filter initialization. Somehow it happens that Filter constructor and init function is called only when filter library is loaded. Filter class destructor besides when VirtualDub program is being closed is called also when filter is disabled or enabled - every time without calling constructor first. How it is even possible?
Situation is that for me it is not clear how to handle filter initialization and deinitialization. Am I missing something? |
 |
| phaeron |
| Posted: Feb 19 2011, 09:54 PM |
 |
|

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

|
Check whether you have a copy constructor (copyProc). If you are implementing your filter manually, i.e. without VDXFrame from the Plugin SDK, and you do not implement copyProc, then you can get two deinits on your filter with only one init. The way this occurs is that VirtualDub has copied your filter and is then destroying the two copies. You override copyProc to specify that you need to do initialization on the copy, just like a copy constructor on a C++ class. If you are using VDXFrame, then the VDXVideoFilter class automatically maps the C++ ctor, copy ctor, and dtor to the initProc, copyProc, and deinitProc entry points. |
 |
| aleksas |
| Posted: Feb 23 2011, 06:56 AM |
 |
|
Newbie

Group: Members
Posts: 4
Member No.: 29895
Joined: 10-February 11

|
Yes, that was the problem - copy constructor. But current behavior is not obvious, that is when managing filter settings actually you are managing the copy of original filter. While changing settings filter copy is used for processing frames. If user clicks OK then the copy becomes THE filter and the old one is deleted. Am I correct? |
 |
| phaeron |
| Posted: Feb 27 2011, 09:31 PM |
 |
|

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

|
What you've said is correct, but this is not part of the API and an implementation detail that's subject to change. There is no guarantee about which copy is used for which, or that only one copy will be used at a time. For instance, I've been thinking of adding a mode where spatial filters can be cloned and run in parallel to reduce threading bottlenecks. What you are guaranteed is that:
- If copyProc/copyProc2 is specified, it will be used to create copies.
- If no copy constructor is specified, a bitwise copy will be performed.
- deinitProc, if present is called for each copy.
- initProc is NOT called for a copy.
- For sampling and preview within a filter instance's configure dialog, the filter instance used for the preview or sampling operation is the same one that's currently being configured.
|
 |