Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to reduce time during pin connection on vista ultimate using RenderStream function...?

31 views
Skip to first unread message

mahantesh

unread,
Nov 7, 2008, 11:43:19 PM11/7/08
to
Dear All,


I am using c++/directx 9.0, I am using RenderStream and
IGraphBuilder::Connect function in xp system their is no difference in
time for connecting pin using these two methods,
But on vista home edition IGraphBuilder::Connect function taking less
time compared to RenderStream, now my question on vista ultimate both
are taking same time how to reduce the time in pin connection, I am
using CSourceStream, CSourceSeeking base class for connecting pins how
to solve this problem.


Regards
Mahantesh.

mahantesh

unread,
Nov 24, 2008, 12:26:36 AM11/24/08
to
On Nov 8, 9:43 am, mahantesh <mahantagoudae...@gmail.com> wrote:
> Dear All,
>
> I amusingc++/directx 9.0, I amusingRenderStreamand
> IGraphBuilder::Connectfunctionin xp system their is no difference intimefor connectingpinusingthese two methods,

> But onvistahome edition IGraphBuilder::Connectfunctiontaking lesstimecompared toRenderStream, now my question onvistaultimateboth
> are taking sametimehow toreducethetimeinpinconnection, I amusingCSourceStream, CSourceSeeking base class for connecting pins how

> to solve this problem.
>
> Regards
> Mahantesh.

Please tell me any one known how to reduce the time between filter pin
connection in directshow, now I have used IGraphBuilder::Connect and
RenderStream function for connecting pins but still I want reduce time
any one known other methods using any method we can reduce the time
during the time of pin connection.

Thore Karlsen [DShow MVP]

unread,
Nov 24, 2008, 1:39:05 AM11/24/08
to

The quickest way to connect filters is to use ConnectDirect() instead
of Connect() or any of the render functions. ConnectDirect() will not
allow DirectShow to try any intermediate filters, which is what is
slowing down your graph building process. On the other hand, if you do
it this hand you have to know exactly which filters go in the graph
and you have to add them manually, which may not be ideal.

As to why Connect/RenderStream takes more or less time on some systems
it could be because they have different sets of filters installed and
there are some filters that slow down the graph building process on
one system.

--
Be seeing you.

Roman Ryl...

unread,
Nov 24, 2008, 2:19:50 AM11/24/08
to
mahantesh,

> As to why Connect/RenderStream takes more or less time on some systems
> it could be because they have different sets of filters installed and
> there are some filters that slow down the graph building process on
> one system.

Additionally to Thore's explanation, you can step your code using
debugger and check debug output log entries added while you are
stepping over your ::Connect( call. A list of loaded DLLs will give
you an idea about filters tried:

...
'graphedt.exe': Loaded 'C:\WINDOWS\system32\qdvd.dll', Symbols loaded
(source information stripped).
'graphedt.exe': Loaded 'C:\WINDOWS\system32\ddraw.dll', Symbols loaded
(source information stripped).
'graphedt.exe': Loaded 'C:\WINDOWS\system32\dciman32.dll', Symbols
loaded (source information stripped).
...

and if you notice something unusual such as for example a delay
immediately after a third party DLL loaded, you can find a guilty
filter.

Roman

mahantesh

unread,
Nov 24, 2008, 5:21:38 AM11/24/08
to
On Nov 24, 11:39 am, "Thore Karlsen [DShow MVP]" <s...@6581.com>
wrote:

> On Sun, 23 Nov 2008 21:26:36 -0800 (PST), mahantesh
>
>
>
>
>
> <mahantagoudae...@gmail.com> wrote:
> >> Dear All,
>
> >> I amusingc++/directx 9.0, I amusingRenderStreamand
> >> IGraphBuilder::Connectfunctionin xp system their is no difference intimefor connectingpinusingthese two methods,
> >> But onvistahome edition IGraphBuilder::Connectfunctiontaking lesstimecompared toRenderStream, now my question onvistaultimateboth
> >> are taking sametimehow toreducethetimeinpinconnection, I amusingCSourceStream, CSourceSeeking base class for connecting pins how
> >> to solve this problem.
>
> >> Regards
> >> Mahantesh.
> >Please tell me any one known how to reduce thetimebetweenfilterpin
> >connectionin directshow, now I have used IGraphBuilder::Connect and

> >RenderStream function for connecting pins but still I want reducetime
> >any one known other methods using any method we can reduce thetime
> >during thetimeofpinconnection.
>
> The quickest way to connect filters is to use ConnectDirect() instead
> of Connect() or any of the render functions. ConnectDirect() will not
> allow DirectShow to try any intermediate filters, which is what is
> slowing down your graph building process. On the other hand, if you do
> it this hand you have to know exactly which filters go in the graph
> and you have to add them manually, which may not be ideal.
>
> As to why Connect/RenderStream takes more or lesstimeon some systems

> it could be because they have different sets of filters installed and
> there are some filters that slow down the graph building process on
> one system.
>
> --
> Be seeing you.- Hide quoted text -
>
> - Show quoted text -

Thank you for replying

I constructed the graph Source->Video_mixing_renderer9 and I
connected the filter using IGraphBuilder::Connect function, and in the
graph I saw that it is adding AVI Decompressor filter to make the
connection between source and renderer filter and then I tryed to
connect the filter using DirectConnect method what you told sir, but
is giving error value and not making the connection between the
filters, and in the graph edit I tryed to disconnect the AVI
Decompressor and tryed to connect source with vmr9 filter but there
also it is not connecting..

Tell me whether I am connecting pins correctly or not ?,
and why it not connecting using ConnectDirect function and I given
third parameter has NULL to this function.

Roman Ryl...

unread,
Nov 24, 2008, 5:34:49 AM11/24/08
to
Hi,

> I constructed the graph   Source->Video_mixing_renderer9 and I
> connected the filter using IGraphBuilder::Connect function, and in the
> graph I saw that it is adding    AVI Decompressor filter to make the
> connection between source and renderer filter and then I tryed to
> connect the filter using DirectConnect method what you told sir, but
> is giving error value and not making the connection between the
> filters, and in the graph edit I tryed to disconnect the AVI
> Decompressor and tryed to connect source with vmr9 filter but there
> also it is not connecting..
>
> Tell me whether I am connecting pins correctly or not ?,
> and why it not connecting using ConnectDirect function and I given
> third parameter has NULL to this function.

What is the media type on your source filter? Most likely VMR does not
support it directly and AVI decompressor is inserted to perform the
necessary conversion.

Roman

mahantesh

unread,
Nov 24, 2008, 6:00:58 AM11/24/08
to
On Nov 24, 3:34 pm, "Roman Ryl..." <rylt...@gmail.com> wrote:
> Hi,
>
> > I constructed the graph   Source->Video_mixing_renderer9 and I
> > connected the filter using IGraphBuilder::Connect function, and in the
> > graph I saw that it is adding    AVI Decompressor filter to make the
> >connectionbetweensource and renderer filter and then I tryed to

> > connect the filter using DirectConnect method what you told sir, but
> > is giving error value and not making theconnectionbetweenthe
> > filters, and in the graph edit I tryed to disconnect the AVI
> > Decompressor and tryed to connect source with vmr9 filter but there
> > also it is not connecting..
>
> > Tell me whether I am connecting pins correctly or not ?,
> > and why it not connecting using ConnectDirect function and I given
> > third parameter has NULL to this function.
>
> What is the media type on your source filter? Most likely VMR does not
> support it directly and AVI decompressor is inserted to perform the
> necessary conversion.
>
> Roman

The media type I am using is major type is MEDIATYPE_Video, format
type is mediatype->formattype == FORMAT_VideoInfo and setting subtype
as RGB24 for this I am getting colour space converter as intermediate
filter, and if I use I420 AVI Decompressor filter gets inserted.

Roman Ryl...

unread,
Nov 24, 2008, 6:56:06 AM11/24/08
to
Hi,

> The media type I am using is major type is MEDIATYPE_Video, format
> type is mediatype->formattype == FORMAT_VideoInfo and setting subtype
> as RGB24 for this I am getting colour space converter as intermediate
> filter, and if I use I420 AVI Decompressor filter gets inserted.

So, this is just fine, as expected. If you implement support for
extended strides, you will be able to eliminate Color Space Converter,
and I420 is probably no supported on VMR so AVI Decompresor is
required. Improper timing might be caused by a third party filter e.g.
regged under unreasonably high merit.

Roman

mahantesh

unread,
Nov 24, 2008, 7:04:45 AM11/24/08
to

Thank you for reply sir,


Tell me how to check the time taken for the pin connection, Is their
any way to speed up the pin connection.

Roman Ryl...

unread,
Nov 24, 2008, 7:17:11 AM11/24/08
to
Hi,

> Tell me how to check the time taken for the pin connection, Is their
> any way to speed up the pin connection.

Take a look at my message higher in this post about stepping over
Connect call in debugger. Paste here debug output log appended while
stepping over slow Connect.

Roman

mahantesh

unread,
Nov 24, 2008, 11:15:32 AM11/24/08
to
On Nov 24, 5:17 pm, "Roman Ryl..." <rylt...@gmail.com> wrote:
> Hi,
>
> > Tell me how tocheckthetimetaken for thepinconnection, Is their

> > any way to speed up thepinconnection.
>
> Take a look at my message higher in this post about stepping over
> Connect call in debugger. Paste here debug output log appended while
> stepping over slow Connect.
>
> Roman

Tell me is their any other method that is used to connect filters so
that it will reduce time will pin connection is taking place.

Thore Karlsen

unread,
Nov 24, 2008, 11:26:11 AM11/24/08
to
mahantesh wrote:

>> Hi,
>>
>>> Tell me how tocheckthetimetaken for thepinconnection, Is their
>>> any way to speed up thepinconnection.
>> Take a look at my message higher in this post about stepping over
>> Connect call in debugger. Paste here debug output log appended while
>> stepping over slow Connect.
>>
>> Roman

> Tell me is their any other method that is used to connect filters so
> that it will reduce time will pin connection is taking place.

Like I said, ConnectDirect(). But you'll have to insert the AVI
decompressor manually, and connect your source filter to it, then
connect the AVI decompressor to the renderer.

mahantesh

unread,
Nov 25, 2008, 5:11:51 AM11/25/08
to
On Nov 24, 9:26 pm, Thore Karlsen <s...@6581.com> wrote:
> mahantesh wrote:
> >> Hi,
>
> >>> Tell me how tocheckthetimetaken for thepinconnection, Is their
> >>> any way to speed up thepinconnection.
> >> Take a look at my message higher in this post about stepping over
> >> Connect call in debugger. Paste here debug output log appended while
> >> stepping over slow Connect.
>
> >> Roman
> > Tell me is their any other method that is used to connect filters so
> > that it will reducetimewillpinconnectionis taking place.

>
> Like I said, ConnectDirect(). But you'll have to insert the AVI
> decompressor manually, and connect your source filter to it, then
> connect the AVI decompressor to the renderer.

I have did the pin connection as you told I inserted the AVI
Decompressor manually But during the source and avi filter connection
it giving error as -2147220897 tell me why it is not getting connected
I sent the code what I written

// Obtain the input pin of avi decompressor.
IPin *pIn;
hr = ptr_builder->FindPin(ptr_avi_dec, PINDIR_INPUT, 0, 0,
TRUE, 0, &pIn);
if (hr != S_OK) {
printf("input pin of avi decompressor is not obtained");
}

// Make connection between source and avi decompressor
hr = ptr_filter_graph->ConnectDirect(pOut, pIn, NULL);
if (hr != S_OK) {
printf("connection between two pins is not done");
}


// Obtain the output pin of avi decompressor tee.
IPin *pOut1;
hr = ptr_builder->FindPin(ptr_avi_dec, PINDIR_OUTPUT, 0, 0,
TRUE, 0,
&pOut1);
if (hr != S_OK) {
printf("output pin of avi decompressor is not obtained");
}

// Obtain the input pin of vmr filter.
IPin *pIn1;
hr = ptr_builder->FindPin(ptr_vmr, PINDIR_INPUT, 0, 0, TRUE,
0, &pIn1);
if (hr != S_OK) {
printf("input pin of vmr filter is not obtained");
}

// Make connection between avi decompressor and vmr filter
hr = ptr_filter_graph->ConnectDirect(pOut1, pIn1, NULL);
if (hr != S_OK) {
printf("connection between two pins is not done");
}

Roman Ryl...

unread,
Nov 25, 2008, 6:06:28 AM11/25/08
to
Hi,

> I have did the pin connection as you told I inserted the AVI
> Decompressor manually But during the source and avi filter connection
> it giving error as -2147220897 tell me why it is not getting connected
> I sent the code what I written

= VFW_E_NOT_IN_GRAPH

You forgot to AddFilter one of the filters to the graph before you are
trying to connect its pin.

Roman

mahantesh

unread,
Nov 25, 2008, 6:38:44 AM11/25/08
to
On Nov 25, 4:06 pm, "Roman Ryl..." <rylt...@gmail.com> wrote:
> Hi,
>
> > I have did thepinconnectionas you told I inserted the AVI

I am sending sample code where I tryed using IGraphBuilder::Connect
method and IFilterGraph::ConnectDirect method, Ihave run these two
methods for first method it is running and I am getting the out put
but for second I am not getting the out let me known what I made
wrong.

int main() {

HRESULT hr = S_OK;
long evcode;

IBaseFilter *p_vedio_input_filter = NULL;
IBaseFilter *ptr_vmr = NULL; // IBaseFilter
interface.
IMediaEvent *ptr_event = NULL; // IMediaEvent
interface.
IGraphBuilder *ptr_graph = NULL; // IGraphBuilder
inteface.
IMediaControl *ptr_mediacontrol = NULL; // IMediaControl
interface.
ICaptureGraphBuilder2 *ptr_builder = NULL;
IVMRFilterConfig9 *ptr_config = NULL; // Pointer to a
created object.

// Initialize the COM library.
hr = CoInitialize(NULL);
if (hr != S_OK) {
printf("Could not initialize COM library.");
}

// To create the Filter Graph Manager and query for interfaces.
hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,
CLSCTX_INPROC_SERVER,
IID_ICaptureGraphBuilder2, (void **)
&ptr_builder);
if (hr != S_OK) {
printf("Could not create the Filter Graph Manager.");
if (ptr_builder != NULL) {
delete(ptr_builder);
ptr_builder = NULL;
}
}

IFilterGraph *ptr_filter_graph = NULL;

// To create the Filter Graph Manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL,
CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)
&ptr_filter_graph);
if (hr != S_OK) {
printf("Could not create the Filter Graph Manager.");
if (ptr_builder != NULL) {
delete(ptr_builder);
ptr_builder = NULL;
}
}


// To create the Filter Graph Manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL,
CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&ptr_graph);
if (hr != S_OK) {
printf("Could not create the Filter Graph Manager.");
if (ptr_graph != NULL) {
delete(ptr_graph);
ptr_graph = NULL;
}
}

// To create the media control object.
hr = ptr_graph->QueryInterface(IID_IMediaControl,
(void **)&ptr_mediacontrol);
if (hr != S_OK) {
printf("Could not create the Media Control object");
ptr_mediacontrol->Release();
CoUninitialize();
}

// To create the media event object.
hr = ptr_graph->QueryInterface(IID_IMediaEvent, (void **)
&ptr_event);
if (hr != S_OK) {
printf("Could not create the Media Event object");
ptr_event->Release();
CoUninitialize();
}


hr = ptr_graph->AddSourceFilter(L"ruby.avi", L"source",
&p_vedio_input_filter);
if (hr != S_OK) {
printf("source filter is not created and added to graph\n");
}


IBaseFilter *ptr_avi_dec = NULL;

// To create the Filter Graph Manager and query for interfaces.
hr = CoCreateInstance(CLSID_AVIDec, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, (void **)&ptr_avi_dec);
if (hr != S_OK) {
printf("Could not create the Filter Graph Manager\n");
if (ptr_avi_dec != NULL) {
delete(ptr_avi_dec);
ptr_avi_dec = NULL;
}
}

// Add the vedio capture filter to the filter graph.
hr = ptr_graph->AddFilter(ptr_avi_dec, L"avi_decompressor");
if (hr != S_OK) {
printf("avi decompressor os not added the graph\n");
}

// Creates and add the vedio mixing render object.
hr = CoCreateInstance (CLSID_VideoMixingRenderer9, NULL,
CLSCTX_INPROC,
IID_IBaseFilter, (void**)&ptr_vmr);
if (hr != S_OK) {
printf("vedio mixing renderer instance is not created\n");
delete(ptr_vmr);
ptr_vmr = NULL;
}

hr = ptr_graph->AddFilter (ptr_vmr, L"Vedio Mixing Renderer\n");

// Checks whether that interface is avaliable or not.
hr = ptr_vmr->QueryInterface (IID_IVMRFilterConfig9, (void**)
&ptr_config);


//Sets the no of streams.
hr = ptr_config->SetNumberOfStreams (1);

// Sets the rendering mode.
hr = ptr_config->SetRenderingMode (VMRMode_Windowed);

//hr = ptr_vmr->QueryInterface(IID_IVMRWindowlessControl9, (void
**)&ptr_wc);


// Obtain the output pin of source filter.
IPin *pOut;
hr = ptr_builder->FindPin(p_vedio_input_filter, PINDIR_OUTPUT, 0,
0, TRUE, 0,
&pOut);
if (hr != S_OK) {
printf("output pin of source filter is not obtained\n");
}

// Obtain the input pin of avi decompressor.
IPin *pIn;
hr = ptr_builder->FindPin(ptr_avi_dec, PINDIR_INPUT, 0, 0, TRUE,
0, &pIn);
if (hr != S_OK) {

printf("input pin of avi decompressor is not obtained\n");
}


// Make connection between source and avi decompressor

hr = ptr_graph->Connect(pOut, pIn);

//hr = ptr_graph->ConnectDirect(pOut, pIn, NULL);
//hr = ptr_filter_graph->ConnectDirect(pOut, pIn, NULL);
if (hr != S_OK) {
printf("connection between two pins is not done\n");
}

// Obtain the output pin of avi decompressor .


IPin *pOut1;
hr = ptr_builder->FindPin(ptr_avi_dec, PINDIR_OUTPUT, 0, 0, TRUE,
0,
&pOut1);
if (hr != S_OK) {

printf("output pin of avi decompressor is not obtained\n");
}

// Obtain the input pin of vmr filter.
IPin *pIn1;
hr = ptr_builder->FindPin(ptr_vmr, PINDIR_INPUT, 0, 0, TRUE, 0,
&pIn1);
if (hr != S_OK) {

printf("input pin of vmr filter is not obtained\n");
}

// Make connection between avi decompressor and vmr filter

hr = ptr_graph->Connect(pOut1, pIn1);

//hr = ptr_graph->ConnectDirect(pOut1, pIn1, NULL);
//hr = ptr_filter_graph->ConnectDirect(pOut1, pIn1, NULL);
if (hr != S_OK) {
printf("connection between two pins is not done\n");
}

// Play the files.
hr = ptr_mediacontrol->Run();

//// Wait untill the completion file.
ptr_event->WaitForCompletion (INFINITE, &evcode);
//ptr_mediacontrol->Stop();

ptr_vmr->Release();
ptr_graph->Release();
p_vedio_input_filter->Release();
ptr_builder->Release();
ptr_config->Release();

return 0;
}

I am readingfrom the file please run the code and where I have made
mistake,

mahantesh

unread,
Nov 25, 2008, 6:59:29 AM11/25/08
to
>     // Obtain the outputpinof source filter.

>     IPin *pOut;
>     hr = ptr_builder->FindPin(p_vedio_input_filter, PINDIR_OUTPUT, 0,
> 0, TRUE, 0,
>                               &pOut);
>     if (hr != S_OK) {
>         printf("outputpinof source filter is not obtained\n");
>     }
>
>     // Obtain the inputpinof avi decompressor.

>     IPin *pIn;
>     hr = ptr_builder->FindPin(ptr_avi_dec, PINDIR_INPUT, 0, 0, TRUE,
> 0, &pIn);
>     if (hr != S_OK) {
>         printf("inputpinof avi decompressor is not obtained\n");
>     }
>
>    // Makeconnectionbetweensource and avi decompressor

>     hr = ptr_graph->Connect(pOut,pIn);
>
>     //hr = ptr_graph->ConnectDirect(pOut,pIn, NULL);
>     //hr = ptr_filter_graph->ConnectDirect(pOut,pIn, NULL);
>     if (hr != S_OK) {
>         printf("connectionbetweentwo pins is not done\n");
>     }
>
>     // Obtain the outputpinof avi decompressor .

>     IPin *pOut1;
>     hr = ptr_builder->FindPin(ptr_avi_dec, PINDIR_OUTPUT, 0, 0, TRUE,
> 0,
>                               &pOut1);
>     if (hr != S_OK) {
>         printf("outputpinof avi decompressor is not obtained\n");
>     }
>
>     // Obtain the inputpinof vmr filter.

>     IPin *pIn1;
>     hr = ptr_builder->FindPin(ptr_vmr, PINDIR_INPUT, 0, 0, TRUE, 0,
> &pIn1);
>     if (hr != S_OK) {
>         printf("inputpinof vmr filter is not obtained\n");
>     }
>
>     // Makeconnectionbetweenavi decompressor and vmr filter

>     hr = ptr_graph->Connect(pOut1, pIn1);
>
>     //hr = ptr_graph->ConnectDirect(pOut1, pIn1, NULL);
>     //hr = ptr_filter_graph->ConnectDirect(pOut1, pIn1, NULL);
>     if (hr != S_OK) {
>         printf("connectionbetweentwo pins is not done\n");

>     }
>
>         // Play the files.
>     hr = ptr_mediacontrol->Run();
>
>     //// Wait untill the completion file.
>     ptr_event->WaitForCompletion (INFINITE, &evcode);
>     //ptr_mediacontrol->Stop();
>
>     ptr_vmr->Release();
>     ptr_graph->Release();
>     p_vedio_input_filter->Release();
>     ptr_builder->Release();
>     ptr_config->Release();
>
>     return 0;
>
> }
>
> I am readingfrom the file please run the code and where I have made
> mistake,

There are two ConnectDirect methods one is IFilterGraph::ConnectDirect
and another one is IGraphBuilder::COnnectDirect method, which one I
should use.

Roman Ryl...

unread,
Nov 25, 2008, 7:08:22 AM11/25/08
to
Hi,

1. You don't need two instances of Filter Graph Manager, you need just
one. The VFW_E_NOT_IN_GRAPH problem was because you added filter to
one graph and called ConnectDirect of the other graph.

2. I recommend that you use smart interface pointer templates
CComPtr<> to write shorter and more reliable code.

3. The code in your post works for me, provided that I replaced .avi
file name with full path to well known clock.avi

Roman

Roman Ryl...

unread,
Nov 25, 2008, 7:16:11 AM11/25/08
to
4. Your hr = ptr_graph->ConnectDirect(pOut1, pIn1, NULL); would not
work because these filters cannot connect directly, there should be an
AVI splitter between them.

mahantesh

unread,
Nov 25, 2008, 7:30:01 AM11/25/08
to

I constructed the graph using AVI Splitter graph, it is showing the
out put now, and i used GetTickCount to known how much time it is
taken between the pin connection, when I use Connect method it is
taking around 15 or 16 millisec, and if I use ConnectDirect function
it is also taking same time I am not getting any difference.

And one think I observed that for different format the time taken for
pin connection is different.

0 new messages