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.

Pages: (19) [1] 2 3 ... Last » ( Go to first unread post )
VirtualDub File Input Filter, how to create one
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
fccHandler
Posted: Sep 25 2007, 05:43 AM


Administrator n00b


Group: Moderators
Posts: 3961
Member No.: 280
Joined: 13-September 02



As an experiment, I'm going to try to create a simple VirtualDub file input filter for the old Autodesk FLIC animation format. (If this filter is successful, I'll set my goals higher in the future; ultimately I'm aiming for full-blown WMV and MPEG-2 input filters...) cool.gif

I'm running into some gray areas though. The 128-byte FLIC signature begins with the size of the file (which is unpredictable), so apparently I need to set the "kFlagCustomSignature" bit, so my driver will be able to verify each signature in its "DetectBySignature()" function.

This scenario seems unclear in the docs. For example, what should be the values of "mpSignature" and "mSignatureLength" in this case? I want the host to NOT check for a signature at all. Should my driver set the values to NULL and 0 respectively?

Or, can I set "mpSignature" to NULL, and "mSignatureLength" > 0 to request a specific header size be sent to "DetectBySignature()"? (That would be sweet.)

Thanks for any help.


EDIT: Oh, another curious thing... The MOCRAP example filter sets the "kFlagSupportsVideo" bit, but it doesn't set "kFlagSupportsAudio". Yet when I build the filter and play the MOCRAP sample, it does indeed produce audio.

This post has been edited by fccHandler on Sep 25 2007, 06:01 AM

--------------------
May the FOURCC be with you...
 
     Top
phaeron
Posted: Sep 26 2007, 03:54 AM


Virtualdub Developer


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



Yeah, docs aren't quite finished yet.

The signature is an array of pairs of bytes, where the first byte contains bits to match and the second byte is a mask. The mask selects which bits are significant for the comparison. This means you can skip the first four bytes by using 4 x (0,0). You can also indeed set it to (NULL, 0) and just rely on the custom signature match function. When both are present, both must pass, so you can use the signature as a first-strike test before doing the heavy lifting.

The SupportsVideo/SupportsAudio flags are used to control the contexts in which the plugin in used -- specifically, whether it's available for the open video / open audio dialogs. I don't think the audio flag is used yet.

 
    Top
fccHandler
Posted: Sep 27 2007, 05:16 AM


Administrator n00b


Group: Moderators
Posts: 3961
Member No.: 280
Joined: 13-September 02



QUOTE (phaeron @ Sep 25 2007, 11:54 PM)
The signature is an array of pairs of bytes, where the first byte contains bits to match and the second byte is a mask. The mask selects which bits are significant for the comparison.

Ah, I hadn't noticed that. That's pretty ingenious.

QUOTE
The SupportsVideo/SupportsAudio flags are used to control the contexts in which the plugin in used -- specifically, whether it's available for the open video / open audio dialogs. I don't think the audio flag is used yet.

I see. So that means we may someday be able to write audio import filters too? Very cool!

Thanks for your help.

--------------------
May the FOURCC be with you...
 
     Top
fccHandler
Posted: Sep 29 2007, 12:42 AM


Administrator n00b


Group: Moderators
Posts: 3961
Member No.: 280
Joined: 13-September 02



My FLIC filter is up and running now. But I've run into one problem I haven't been able to figure out...

It seems to me that FLIC is a perfect candidate for using the I/P video decoding model which the host provides automatically, but it doesn't seem to work. I could only get the frames to decode correctly by rolling a custom video decoding model.

So my question is, has the built-in I/P video decoding model actually been tested? I can't quite tell whether it's really bugged, or whether I'm simply doing something wrong.

Here is the main.cpp and a dancer.fli:
http://fcchandler.home.comcast.net/flic.zip (188K)

--------------------
May the FOURCC be with you...
 
     Top
phaeron
Posted: Sep 29 2007, 05:09 AM


Virtualdub Developer


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



Aha, the default I/P model is busted -- I broke it when I was reworking and simplifying the API. 1.7.5 will have that fixed and I'll also be bumping the API version to V2.

The FLIC plugin works... cool!
 
    Top
Moitah
Posted: Sep 29 2007, 07:11 AM


Advanced Member


Group: Members
Posts: 210
Member No.: 8955
Joined: 20-February 04



What about something like ASF... certainly you wouldn't write a custom video decoder for that right? How would you access VirtualDub's built-in VFW video decoder?
 
      Top
fccHandler
Posted: Sep 29 2007, 05:48 PM


Administrator n00b


Group: Moderators
Posts: 3961
Member No.: 280
Joined: 13-September 02



I don't think you can. It looks like filters must always handle the decompression themselves. But assuming a VFW codec is involved, we can just ask the system (VCM) for a decompressor.

On the other hand, we also have the choice to implement a custom decompressor which doesn't use VCM, and that could be a very powerful thing.

Make no mistake; an ASF or MPEG-2 filter is going to involve a HUGE amount of work. I've already started an MPEG-2 filter project, and the scale of it (compared to FLIC) is pretty frightening.

--------------------
May the FOURCC be with you...
 
     Top
phaeron
Posted: Sep 29 2007, 06:02 PM


Virtualdub Developer


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



VirtualDub doesn't have much in the way of built-in decompression services. Currently it has MPEG-1, MJPEG, DV, and some uncompressed image formats, and a few audio formats will be joining that in a future version. Everything else goes through VFW, and all that VirtualDub has there is a bunch of workarounds for broken codecs. Didn't think this was worth exposing, but I'm open to suggestions.
 
    Top
Moitah
Posted: Sep 29 2007, 06:26 PM


Advanced Member


Group: Members
Posts: 210
Member No.: 8955
Joined: 20-February 04



The workarounds were precisely the reason why I thought it would be a good idea to be able to use VirtualDub's internal VFW decompressor. You've already got it figured out and stable, why should other input plugins that decode via VFW have to reimplement all that stuff. Although, I suppose a lot of the workarounds are for codecs that are only typically used in AVI, but still having the workaround for reliably locating a decompressor even when some codecs falsely report they can decompress everything is useful, for example. And I mentioned ASF already, but actually the one I really had in mind that I might want to write someday is for FLV smile.gif (VFW would be used for decompression).
 
      Top
ale5000
Posted: Sep 30 2007, 05:05 PM


Advanced Member


Group: Members
Posts: 1114
Member No.: 22180
Joined: 30-September 07



Edit: Removed

--------------------
New VirtualDub forum
VirtualDub AIO (All-in-One installer for VirtualDub and plugins)
Codec Toolbox RS (A tool to read/change merit of codecs and many other things)
Input plugins for VirtualDub / ACM codecs / VFW codecs
 
     Top
neuron2
Posted: Sep 30 2007, 05:54 PM


Advanced Member


Group: Members
Posts: 1244
Member No.: 5294
Joined: 18-July 03



.
 
    Top
fccHandler
Posted: Sep 30 2007, 07:51 PM


Administrator n00b


Group: Moderators
Posts: 3961
Member No.: 280
Joined: 13-September 02



Phaeron: Thank you for VirtualDub 1.7.5.

I have a skeleton of an MPEG-2 plugin up and running now, but there is one problem. VirtualDub is grabbing the ".mpg" extension by default, and I can't make it give my plugin priority for MPEG files. I need it to do so, because VirtualDub doesn't detect MPEG-2 until it's too late, at which time its parser fails.

I can force my plugin to be chosen by selecting "MPEG-2 files" in the dropdown menu, so at least that gives me an alternate way to invoke it. FWIW, here is the code I'm currently testing:

CODE

const uint8 MPEG2_sig[] = {
   0x00, 0xFF,
   0x00, 0xFF,
   0x01, 0xFF,
   0xB2, 0xF6    // either 0x1B3 or 0x1BA
};

const VDInputDriverDefinition mpeg2_input = {
   sizeof(VDInputDriverDefinition),
   VDInputDriverDefinition::kFlagSupportsVideo,
   1,        // priority?
   sizeof(MPEG2_sig),
   MPEG2_sig,
   L"*.mpg",
   L"MPEG-2 files (*.mpg)|*.mpg",
   L"MPEG-2",
   mpeg2_create
};


I've tried priority values of -1, 0, 1, and 0x7FFFFFFF, but it doesn't make a difference. I'm not using a custom signature just yet. (Trying to keep it simple right now.)

--------------------
May the FOURCC be with you...
 
     Top
phaeron
Posted: Oct 1 2007, 01:44 AM


Virtualdub Developer


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



Hmm... I just hacked that signature and priority into your FLIC plugin, and it seemed to work fine. Did you remember to change the custom check routine? If the priority value is working, the plugin should move up and down in the filter list in the Open dialog.
 
    Top
fccHandler
Posted: Oct 1 2007, 02:12 AM


Administrator n00b


Group: Moderators
Posts: 3961
Member No.: 280
Joined: 13-September 02



When I set priority = 1, it does move to the top of the list (or rather, just under "All supported"). Still, when I try to open an MPEG-2 file with the extension .mpg, I get the familiar "MPEG Import Filter: invalid pack..." error from VirtualDub's internal driver.

Right now, my "DetectBySignature()" function consists of only the line "return 1." Placing a breakpoint there shows that it's never called by VirtualDub (which is the behavior I would expect, since I didn't set the custom signature flag in the driver definition).

FWIW, here is a very experimental build of my MPEG-2 plugin with priority = 1. It's far from being finished, but it does actually work:

http://fcchandler.home.comcast.net/MPEG2.zip (82K)

To repro, try to open an MPEG-2 file with the extension ".mpg" and you'll see what I mean. You can only do it by explicitly choosing "MPEG-2" from the dropdown list.


EDIT: Since posting the above, I've discovered two additional bits of info:

If I go ahead and implement the DetectBySignature() function, and set the custom signature flag in the driver description, then it solves my problem.

If I don't set the custom signature flag, then VirtualDub's internal MPEG import filter always takes precedence, even when the file has a .vob extension! ohmy.gif

--------------------
May the FOURCC be with you...
 
     Top
ale5000
Posted: Oct 1 2007, 09:15 AM


Advanced Member


Group: Members
Posts: 1114
Member No.: 22180
Joined: 30-September 07



Can you add .mpeg additionally to .mpg in your plug-in?
Try to open a vob crash VirtualDub.

--------------------
New VirtualDub forum
VirtualDub AIO (All-in-One installer for VirtualDub and plugins)
Codec Toolbox RS (A tool to read/change merit of codecs and many other things)
Input plugins for VirtualDub / ACM codecs / VFW codecs
 
     Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
281 replies since Sep 25 2007, 05:43 AM Track this topic | Email this topic | Print this topic
Pages: (19) [1] 2 3 ... Last »
<< Back to VirtualDub Filters and Filter Development