Coder Social home page Coder Social logo

d3d11nv12rendering's People

Contributors

balapradeepswork avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

d3d11nv12rendering's Issues

display green!

image

and i want to display ffmpeg decoded frame(i got a ID3D111Texture2D pointer),do you know how can i direct render and display it?i don`t want to copy it to cpu memory.

thank you so much!

When the height of the nv12 file is greater than the height of the window, a segmentation fault will occur!

	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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.