现在的位置: 首页 > 综合 > 正文

How DirectShow Decides Which Filters to Use

2013年01月18日 ⁄ 综合 ⁄ 共 2220字 ⁄ 字号 评论关闭

How DirectShow Decides Which Filters to Use

MC supports a number of audio file types natively. When you play
back a MP3 file, for example, MC uses it's own internal high-quality
filters to split and decode the file and send it to the appropriate
output device (sound card). When you attempt to play a file back in MC
that it doesn't support natively, MC tries a number of different things
to get the file to play. The first step is to attempt to render the
file using DirectShow.

By default, if you haven't modified the DirectShow playback
configuration options in MC, and you play a file back, it simply asks
Windows to build the regular DirectShow graph. This works the same as
Windows Media Player and any other DirectShow player does when playing
back a file.

Illustration of how Filters get selected. In the example, even though all of the filters support MP4 playback, DirectShow will use the Haali filter because it has the highest Merit Score.
Enlarge

Illustration
of how Filters get selected. In the example, even though all of the
filters support MP4 playback, DirectShow will use the Haali filter
because it has the highest Merit Score.

The default graph is built based on two factors: a) each individual
filter "tells" DirectShow what kinds of media streams it is able to
render, and b) DirectShow assigns (or more precisely, the filters
assign to themselves when you install them) a priority number called
its "merit score".

When you play a file, DirectShow attempts to build a chain of
filters capable of decoding the content based on these two pieces of
information. It tries filters matching the stream type, in the order of
which filter has the highest priority first. If the "render" fails,
then it tries the next highest priority set, and so on and so forth
until it runs out of options or succeeds. Just because it "works"
doesn't mean it's necessarily finding the "best" filter graph. It just
uses whichever one it "bumbles" into that works first.

MC's DirectShow Playback settings dialog overrides the priority
part of this sequence of events. If you select one or more of those
filters, it overrides the normal merit score system (perhaps by
temporarily elevating them to the highest possible Merit -- I'm not
sure of the details of this mechanism). So, you can force it to "try"
to use a different filter to play a file back, but you can't force it
to use one or fail outright. If that graph fails (the output pins can't
connect to the input pins to build a complete render graph) then it
either ignores certain selected filters, or it fails over completely to
the default graph. (MC's DirectShow Playback Settings dialog provides
essentially identical functionality to ZoomPlayer's "Smart Play"
feature.)

I've simplified this a bit for the sake of explanation, but
that's the general idea of what happens when you try to play a file
back via DirectShow.

抱歉!评论已关闭.