Search code examples
windowsembeddedwindows-cedirectshow

DirectShow: How to get the physical address of delivery buffer return by IMediaSample::GetPointer method


I have written a decoder transform filter but it played the video slowly.

There are two memcpy operations. Copying from source media sample and then copied to destination delivery buffer of output pin. I cannot totally avoid the mem copies, but copied to output pin’s delivery buffer can be avoided.

It would help me avoid second mem copy if I get physical address of the output pin delivery buffer and directly assign this physical address to my hardware decoder register. By exploring the methods of “m_pOutput”, there is no any function that returns the physical address of the pointer return by IMediaSample::GetPointer method.

Please guide me how can I get this physical address? Any other way to achieve the same thing?


Solution

    1. You ask the address you anyway have by calling IMediaSample::GetPointer, so it appears that you already have what you ask for
    2. Output pin is responsible for memory allocator on the pin, so your decoder can use its own memory allocator with IMediaSample::GetPointer method in particular. You can use the buffers you allocate, and share with HW decoder implementation (also, you can have specific alignment there etc. or vice versa get the buffer from decoder for further use in DirectShow pipeline).
    3. I see it's Win CE, however anyway it does not seem very likely that excessive memcpy is visually slow, perhaps you have other bottlenecks as well.