private void CopyCpuData(VarjoBufferMetadata metadata, IntPtr cpuBuffer, bool invertRowOrder)
        {
            int height    = (int)metadata.height;
            int rowStride = (int)metadata.rowStride;
            int byteSize  = (int)metadata.byteSize;

            if (invertRowOrder)
            {
                for (int srcRow = 0; srcRow < height; ++srcRow)
                {
                    long srcOffset  = cpuBuffer.ToInt64() + srcRow * rowStride;
                    int  destOffset = (height - srcRow - 1) * rowStride;
                    Marshal.Copy(new IntPtr(srcOffset), data, destOffset, rowStride);
                }

                // YUV422 contains a second plane for UV.
                if (metadata.textureFormat == VarjoTextureFormat.YUV422)
                {
                    for (int srcRow = 0; srcRow < height; ++srcRow)
                    {
                        long srcOffset  = cpuBuffer.ToInt64() + (srcRow + height) * rowStride;
                        int  destOffset = (2 * height - srcRow - 1) * rowStride;
                        Marshal.Copy(new IntPtr(srcOffset), data, destOffset, rowStride);
                    }
                }
            }
            else
            {
                Marshal.Copy(cpuBuffer, data, 0, byteSize);
            }
        }
 internal static bool GetBufferMetadata(long id, out VarjoBufferMetadata metadata)
 {
     if (!IsMRReady())
     {
         metadata = new VarjoBufferMetadata();
         return(false);
     }
     metadata = varjo_GetBufferMetadata(GetVarjoSession(), id);
     return(CheckError());
 }