Metal C++ MTL::Texture

I use ffmpeg to playback video with videotoolbox (hardware), how can I get MTL::Texture from Avframe when I receive hardware frame from function avcodec_receive_frame(avctx, avframe), there is few example with metal c++, and i can't find CVPixelBufferRef type in metal c++, I really confused with this.

You can normally freely cast you can from an MTLTexture to an MTL::Texture in your Objective C++ code. The only exception might be if ARC is enabled, where a __bridge_retained cast might be needed.

If you want avoid any ObjC code for C function, you can create prototypes with MTL::Texture in place of id<MTLTexture>. For instance, for CVMetalTextureGetTexture which looks like the following:

id<MTLTexture> CVMetalTextureGetTexture(CVMetalTextureRef image);

You could create the following prototype:

extern "C" MTL::Texture* CVMetalTextureGetTexture(CVMetalTextureRef image);
Metal C&#43;&#43; MTL::Texture
 
 
Q