public Nv12Texture exportNv12(iGlesRenderDevice gles, VideoDevice device, ref sPixelFormatMP pixelFormat, ref ColorFormat colorFormat) { device.file.call(eControlCode.QUERYBUF, ref buffer); sDmaBuffer dma = exportOutputBuffer(device, ref pixelFormat); ITexture texture = gles.importNv12Texture(ref dma, ref colorFormat); // Logger.logVerbose( "Exported NV12 texture: {0}", dma ); return(new Nv12Texture(texture)); }
public sDmaBuffer exportOutputBuffer(VideoDevice device, ref sPixelFormatMP pixelFormat) { sExportBuffer eb = device.exportOutputBuffer(bufferIndex); sPlanePixelFormat planeFormat = pixelFormat.getPlaneFormat(0); sDmaBuffer dma = new sDmaBuffer() { fd = eb.fd, offset = 0, stride = planeFormat.bytesPerLine, imageSize = planeFormat.bytesPerLine * pixelFormat.size.cy, sizePixels = pixelFormat.size, bufferIndex = bufferIndex }; return(dma); }
public VideoTextures exportTextures(iGlesRenderDevice gles, VideoDevice device, ref sPixelFormatMP pixelFormat) { sExportBuffer eb = new sExportBuffer() { type = eBufferType.VideoCaptureMPlane, index = bufferIndex, plane = 0, flags = eFileFlags.O_RDONLY | eFileFlags.O_CLOEXEC }; device.file.call(eControlCode.EXPBUF, ref eb); sPlanePixelFormat planeFormat = pixelFormat.getPlaneFormat(0); sDmaBuffer dma = new sDmaBuffer() { fd = eb.fd, offset = 0, stride = planeFormat.bytesPerLine, imageSize = planeFormat.bytesPerLine * pixelFormat.size.cy, sizePixels = pixelFormat.size, bufferIndex = bufferIndex }; ITexture luma = gles.importLumaTexture(ref dma); Logger.logVerbose("Exported luma texture: {0}", dma); // I asked V4L2 for 2 planes, however QUERYBUF returned a single plane, with the complete NV12 image in it. // No big deal, we have EGL_DMA_BUF_PLANE0_OFFSET_EXT for that; that's where the sDmaBuffer.offset field goes. dma.offset = dma.imageSize; dma.sizePixels = chromaSize(pixelFormat.size); dma.imageSize = dma.stride * dma.sizePixels.cy; ITexture chroma = gles.importChromaTexture(ref dma); Logger.logVerbose("Exported chroma texture: {0}", dma); return(new VideoTextures(luma, chroma)); }