GetProcAmpControl/GetProcAmpControlRange are zeroes in sample (DxText)

2014-03-25
2014-03-30
  • James Fogarty

    James Fogarty - 2014-03-25

    Hi, I was messing around with the DxText sample and based on another SF thread somewhere else, I tried to adjust the brightness/contrast in the filter. I added the following lines (the first and last lines are original code):

               // Get the default video renderer
               //ibfRenderer = (IBaseFilter) new VideoRendererDefault();
               ibfRenderer = (IBaseFilter)new VideoMixingRenderer9();
    
               IVMRFilterConfig9 v = (IVMRFilterConfig9)ibfRenderer;
               v.SetNumberOfStreams(1);
    
               //VMR9ProcAmpControl v2 = new VMR9ProcAmpControl();
               //v2.Brightness = 100000;
    
               IVMRMixerControl9 mixerControl = (IVMRMixerControl9)ibfRenderer;
    
               //mixerControl.SetProcAmpControl(0, v2);
    
               VMR9ProcAmpControlRange range = new VMR9ProcAmpControlRange();
               VMR9ProcAmpControl proc= new VMR9ProcAmpControl();
               mixerControl.GetProcAmpControl(1, ref proc);
               mixerControl.GetProcAmpControlRange(1, ref range);
    
               // Add it to the graph
               hr = m_FilterGraph.AddFilter( ibfRenderer, "Ds.NET VideoRendererDefault" );
    

    However, both getting the procamp control and the range give me back zeroes. This is a fairly powerful machine with up to date drivers. Any thoughts? The only thing I can think of is the dwStream is wrong, but since I had to do this:

               IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 1);
    

    to get it to work (note I replaced 0 with 1), I switched those. Switching them to 0 does not work.

     
  • snarfle

    snarfle - 2014-03-25

    Well, looking at the docs for IVMRMixerControl9::GetProcAmpControl, I see:

    Pointer to a VMR9ProcAmpControl structure that receives the image adjustment settings. When the method returns, the dwFlags field indicates which properties are supported by the graphics driver. Set the dwSize member in the structure before calling this method.

    But I don't see you setting the dwSize member. I also don't see you checking the return value for GetProcAmpControl or GetProcAmpControlRange, which might give you some idea about what's going wrong.

     
  • James Fogarty

    James Fogarty - 2014-03-27

    Gotcha - I made sure to set the dwSize with the following line:

    proc.dwSize = Marshal.SizeOf(proc);

    When I run it and check the result, if I set

    hr = mixerControl.GetProcAmpControl(0, ref proc);

    hr is -2147220983

    When I do

    hr = mixerControl.GetProcAmpControl(1, ref proc);

    hr is -2147024809

    The first one seems to indicate an invalid stream, which makes sense since my stream is 1, not 0. Any idea what the second error code is?

    By the way, I am checking the values by just hovering in Visual Studio. once the reference is returned.

    Also, I've been reading about pins but am still not sure why this combination in the sample:

    IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 1);
    iPinInFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);
    iPinOutFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Output, 0);

    works but not other combination of pins does. Am I using pin 0 or pin 1?

     
    Last edit: James Fogarty 2014-03-27
  • snarfle

    snarfle - 2014-03-27

    -2147024809 == 0x80070057 == E_INVALIDARG == "The parameter is incorrect." Reading the docs, this probably means:

    • The stream number is invalid
    • The value of dwSize in the VMR9ProcAmpControl structure is invalid.

    Assuming baseGrabFlt is the sample grabber, it only has 1 input and 1 output pin. What other values would you expect to work?

     
  • James Fogarty

    James Fogarty - 2014-03-29

    Gotcha, thanks - I've been reading about pins some more and trying to get more information on the VMR9ProcAmpControl. I guess where I am confused is the default code:

    IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);

    does not work, but changing it to

    IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 1);

    does work (the 0 changed to a 1). That value is "iIndex" and I can't find why it works, only that in some forum questions I've seen people change it. Also, you'll notice the other two lines:

    iPinInFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);
    iPinOutFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Output, 0);

    remain as 0 for iIndex - changing them to 1 causes errors. Looking at the docs, it appears that iIndex tells the DsFindPin where to start scanning, but why would it error out starting to scan at 0 instead of 1?

    And I get what you mean about the stream now, so obviously ProcAmpControl should be getting from stream 0, but the first error translates to hex 7FFBFDF7 which is not a defined error code I can find on the MSDN site. Thoughts? Thanks for all your help.

     
  • snarfle

    snarfle - 2014-03-30

    capFilter - I'm not clear on what filter is in your capFilter. I'm going to assume this is a camera.

    Now, lots of cameras only have a single output pin. This pin outputs the video from the camera. However, some cameras also have a pin for outputting "stills" (and some have pins for other things too). Now, if you use DsFindPin.ByDirection and ask for the first output pin (ie pin 0), will you get the "still" pin or the video pin? Well, it depends on who wrote the filter for the camera. And using the "still" pin probably won't work well for video streams...

    7FFBFDF7 - This sounds like you translated this to hex wrong. I would expect the error number to be negative, and this is a positive number.

    starting to scan at 0 instead of 1 - If a filter only has 1 pin, starting to scan at 1 (remember, this is zero-based), means you are starting to look after the last possible pin. This will cause DsFindPin to return null. Since you aren't checking for error returns, badness will likely ensue.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks