balapradeepswork / d3d11nv12rendering Goto Github PK
View Code? Open in Web Editor NEWRendering uncompressed NV12 frames using D3D11.
Rendering uncompressed NV12 frames using D3D11.
D3D11_TEXTURE2D_DESC const texDesc = CD3D11_TEXTURE2D_DESC(
DXGI_FORMAT_NV12, // HoloLens PV camera format, common for video sources
m_width, // Width of the video frames
m_height, // Height of the video frames
1, // Number of textures in the array
1, // Number of miplevels in each texture
D3D11_BIND_SHADER_RESOURCE, // We read from this texture in the shader
D3D11_USAGE_DYNAMIC, // Because we'll be copying from CPU memory
D3D11_CPU_ACCESS_WRITE // We only need to write into the texture
);
void WriteNV12ToTexture(NV12Frame *nv12Frame)
{
// Copy from CPU access texture to bitmap buffer
D3D11_MAPPED_SUBRESOURCE resource;
UINT subresource = D3D11CalcSubresource(0, 0, 0);
OutMgr.m_DeviceContext->Map(OutMgr.m_texture, subresource, D3D11_MAP_WRITE_DISCARD, 0, &resource);
BYTE* dptr = reinterpret_cast<BYTE*>(resource.pData);
for (int i = 0; i < nv12Frame->height; i++)
{
memcpy(dptr + resource.RowPitch * i, nv12Frame->Y + nv12Frame->pitch * i, nv12Frame->pitch);
}
for (int i = 0; i < nv12Frame->height / 2; i++)
{
memcpy(dptr + resource.RowPitch *(nv12Frame->height + i), nv12Frame->UV + nv12Frame->pitch * i, nv12Frame->pitch);
}
OutMgr.m_DeviceContext->Unmap(OutMgr.m_texture, subresource);
}
if nv12Frame->height
is greater than m_height
, it will coredump.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.