Nevcairiel / LAVFilters

LAV Filters - Open-Source DirectShow Media Splitter and Decoders
GNU General Public License v2.0
7.53k stars 792 forks source link

Get stereo frame buffer when decoding H.264 MVC #601

Open CommanderLake opened 5 months ago

CommanderLake commented 5 months ago

I've been trying to figure out how i can get access to the stereo frame buffer when decoding H.264 MVC when using the video decoder in a graph in my application and decoding a ripped 3D blue ray, I know GetPointer3D in the IMediaSample3D interface gets the stereo frame pointer but I cant get access to it so how does MadVR for example get the stereo frame buffer?

Nevcairiel commented 5 months ago

LAV Video does not actually implement IMediaSample3D, rather it expects a renderer that supports 3D rendering to provide an allocator that implements it, and then just writes the samples into it.

This inversion of sample allocation is typical for the renderer <> decoder relationship, as renderers typically have certain requirements for their sample allocation and management. Practically all renderers provide their own allocator - and thus is the natural place to also require IMediaSample3D to be implemented. Once its implemented and exposed, LAV will use it to store the second view.

CommanderLake commented 5 months ago

Thanks but I'm still struggling with this, how does the allocation of the buffer work and when is it allocated, does the decoder allocate the memory? I'm so confused, is any of this documented?

clsid2 commented 5 months ago

You must implement the functions of the interface (and its parent interfaces) and allocate the buffer.

https://github.com/Nevcairiel/LAVFilters/blob/master/include/IMediaSample3D.h https://learn.microsoft.com/en-us/windows/win32/api/strmif/nn-strmif-imediasample2 https://learn.microsoft.com/en-us/windows/win32/api/strmif/nn-strmif-imediasample

CommanderLake commented 5 months ago

So I allocate the stereo frame buffer in GetPointer3D and that gets called only once? Or do I only allocate the frame buffer if it is not yet allocated and return it with subsequent calls? How do I get the required size of the frame buffer?

Thanks.