Beispiel #1
0
        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));
        }
Beispiel #2
0
        /// <summary>Export all buffers from V4L2, import them into GLES in Diligent Engine</summary>
        public void exportTextures(IRenderDevice renderDevice, VideoDevice device, ref sPixelFormatMP pixelFormat, ref ColorFormat color)
        {
            iGlesRenderDevice gles = ComLightCast.cast <iGlesRenderDevice>(renderDevice);

            textures = new Nv12Texture[buffers.Length];
            for (int i = 0; i < buffers.Length; i++)
            {
                textures[i] = buffers[i].exportNv12(gles, device, ref pixelFormat, ref color);
            }
        }
Beispiel #3
0
        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));
        }