• Question

  • I am reading samples from a camera IMFMediaSource and extracting image byte arrays which are sent to an image processing algorithm. However, these images are inverted:

    When I read a sample from a camera

    m_imageAcquisition->ReadASample(capturedImage, &imageInfo);

    if I zero the first 5 lines of the image:

    memset(capturedImage, 0, imageInfo.m_width * (imageInfo.m_bitCount / 8) * 5);

    I get a black bar at the bottom of the image instead of at the top

    Now the customer does not want to iterate over the byte array, they want WMF to handle this automatically.

    according to http://msdn.microsoft.com/en-us/library/windows/desktop/aa473780(v=vs.85).aspx 

    there are two ways that an image can be arranged in memory. In a top-down image, the top row of pixels in the image appears first in memory. In a bottom-up image, the last row of pixels appears first in memory.

    When I dump the IMFAttributes from my source reader , I see that MF_MT_DEFAULT_STRIDE is -1920 

    according to http://msdn.microsoft.com/en-us/library/windows/desktop/ms698965(v=vs.85).aspx

    I should be able to get and set this value to its absolute value: 1920

    // get source media type
    	CComPtr<IMFMediaType> ppMediaType;
    	hr = m_reader->GetCurrentMediaType(0,&ppMediaType);
    	if (FAILED(hr)) 
    		LOG_ERROR("GetSourceMediaType failed - " << hr);			
    	UINT32 stride = 0;
    	hr = ppMediaType->GetUINT32(MF_MT_DEFAULT_STRIDE, &stride);
    	stride = (UINT32) ABS((int)stride); 
    	hr = ppMediaType->SetUINT32(MF_MT_DEFAULT_STRIDE, stride);
    	hr = m_reader->SetCurrentMediaType(0,0, ppMediaType);
    	if (FAILED(hr)) 

    However, SetCurrentMediaType returns a HRESULT: MF_E_TOPO_CODEC_NOT_FOUND

    Is this supported?

    How can I make it work?

    Sunday, June 3, 2012 1:53 PM

All replies

  • anyone?
    Tuesday, June 5, 2012 2:46 AM
  • could you do an mftrace to get some more information?
    Tuesday, June 5, 2012 8:08 AM
  • C:\program files\Microsoft SDKs\Windows\v7.1\Bin> MFTrace –a "multiclientmanagersample.exe"  -o "c:\temp\wmftrace.log" –v

    Trying to capture some info regarding inability to change stride to a positive value: (between 2 breakpoints surrounding the above code)


    PID, TID    Time (UTC)    TraceMessage
    --------- --------------  ------------

    I get an empty trace log!
    Sunday, June 10, 2012 10:49 AM