#include "D3D11Render.h"
#include "libyuv.h"
#include <assert.h>
#pragma comment(lib, "libyuv.lib")
#define SAFE_RELEASE(p) { if((p)){ (p)->Release(); (p) = nullptr; }}
#define USE_I420
const D3D11_INPUT_ELEMENT_DESC D3D11Render::VertexPosColor::inputLayout[2] = {
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}
};
void LogErrorText(HRESULT hr)
{
WCHAR strBufferError[300];
FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr, hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
strBufferError, 256, nullptr);
std::cout << strBufferError << std::endl;
}
uint64_t get_timestamp1()
{
// struct timeval tm;
// gettimeofday(&tm, NULL);
// return (uint64_t)(tm.tv_sec*1000+tm.tv_usec/1000);
LARGE_INTEGER counter;
static LARGE_INTEGER freq = { 0 };
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&counter);
return (counter.QuadPart * 1000) / (freq.QuadPart);
}
D3D11Render::D3D11Render() : m_width(0), m_height(0), m_orientation(0), m_fps(30), m_run(false), render_thread_(nullptr),
m_renderBuffer(nullptr), m_Enable4xMsaa(false), m_hwnd(nullptr)
{
}
D3D11Render::D3D11Render(int width, int height, char filepath[100]) : m_width(width), m_height(height), m_orientation(0), m_fps(30), m_run(false), render_thread_(nullptr),
m_renderBuffer(nullptr), m_Enable4xMsaa(false), m_hwnd(nullptr)
{
memcpy(path, filepath, 100);
}
D3D11Render::~D3D11Render()
{
if (m_renderBuffer != nullptr) free(m_renderBuffer);
if (m_pd3dImmediateContex) {
m_pd3dImmediateContex->ClearState(); //恢复D3D设备上下文到默认状态
}
}
//int D3D11Render::InputMediaFrame(uint8_t* pFrame, int length, int width, int height, int orientation)
//{
// if (pFrame == nullptr) {
// std::cout << "pFrame is NULL." << std::endl;
// return -1;
// }
// if (width <= 0 || height <= 0) {
// std::cout << "width is:" << width << " height is:" << height << std::endl;
// return -1;
// }
// uint8_t* frame = nullptr;
// frame = new uint8_t[width * height * 3 / 2];
// std::unique_lock<std::mutex> sbguard1(m_Mutex);
// if (frame == nullptr) {
// return -1;
// }
// else {
// if (width != m_width || height != m_height) {
// int ret = OnResize();
// if (ret != 0) {
// std::cout << "OnResize failed." << std::endl;
// return -1;
// }
// while (!data.empty()) {
// uint8_t* frame = data.front();
// data.pop_front();
// delete frame;
// frame = nullptr;
// }
// m_width = width;
// m_height = height;
// m_orientation = orientation;
// memcpy(frame, pFrame, width * height * 3 / 2);
// data.push_back(frame);
// return 0;
// }
// else {
// memcpy(frame, pFrame, width * height * 3 / 2);
// data.push_back(frame);
// return 0;
// }
// }
// return 0;
//}
int D3D11Render::InputMediaFrame1(uint8_t* pFrame, int length, int width, int height, int q_num)
{
if (pFrame == nullptr) {
std::cout << "pFrame is NULL." << std::endl;
return -1;
}
if (width <= 0 || height <= 0) {
std::cout << "width is:" << width << " height is:" << height << std::endl;
return -1;
}
std::unique_lock<std::mutex> sbguard(m_Mutex[0]);
uint8_t* frame = new uint8_t[width * height * 3 / 2];
if (frame == nullptr) {
return -1;
}
if (data[0].size() > 0) {
while (data[0].size() > 15) {
uint8_t* pd = data[0].front();
data[0].pop_front();
delete pd;
pd = nullptr;
}
}
memcpy(frame, pFrame, width * height * 3 / 2);
data[0].push_back(frame);
m_hasdata = true;
return 0;
}
int D3D11Render::InputMediaFrame2(uint8_t* pFrame, int length, int width, int height, int q_num)
{
if (pFrame == nullptr) {
std::cout << "pFrame is NULL." << std::endl;
return -1;
}
if (width <= 0 || height <= 0) {
std::cout << "width is:" << width << " height is:" << height << std::endl;
return -1;
}
std::unique_lock<std::mutex> sbguard(m_Mutex[1]);
uint8_t* frame = new uint8_t[width * height * 3 / 2];
if (frame == nullptr) {
return -1;
}
if (data[1].size() > 0) {
while (data[1].size() > 15) {
uint8_t* pd = data[1].front();
data[1].pop_front();
delete pd;
pd = nullptr;
}
}
memcpy(frame, pFrame, width * height * 3 / 2);
data[1].push_back(frame);
m_hasdata = true;
return 0;
}
int D3D11Render::InputMediaFrame3(uint8_t* pFrame, int length, int width, int height, int q_num)
{
if (pFrame == nullptr) {
std::cout << "pFrame is NULL." << std::endl;
return -1;
}
if (width <= 0 || height <= 0) {
std::cout << "width is:" << width << " height is:" << height << std::endl;
return -1;
}
std::unique_lock<std::mutex> sbguard(m_Mutex[2]);
uint8_t* frame = new uint8_t[width * height * 3 / 2];
if (frame == nullptr) {
return -1;
}
if (data[2].size() > 0) {
while (data[2].size() > 15) {
uint8_t* pd = data[2].front();
data[2].pop_front();
delete pd;
pd = nullptr;
}
}
memcpy(frame, pFrame, width * height * 3 / 2);
data[2].push_back(frame);
m_hasdata = true;
return 0;
}
int D3D11Render::InputMediaFrame4(uint8_t* pFrame, int length, int width, int height, int q_num)
{
if (pFrame == nullptr) {
std::cout << "pFrame is NULL." << std::endl;
return -1;
}
if (width <= 0 || height <= 0) {
std::cout << "width is:" << width << " height is:" << height << std::endl;
return -1;
}
std::unique_lock<std::mutex> sbguard(m_Mutex[3]);
uint8_t* frame = new uint8_t[width * height * 3 / 2];
if (frame == nullptr) {
return -1;
}
if (data[3].size() > 0) {
while (data[3].size() > 15) {
uint8_t* pd = data[3].front();
data[3].pop_front();
delete pd;
pd = nullptr;
}
}
memcpy(frame, pFrame, width * height * 3 / 2);
data[3].push_back(frame);
m_hasdata = true;
return 0;
}
int D3D11Render::InputMediaFrame5(uint8_t* pFrame, int length, int width, int height, int q_num)
{
if (pFrame == nullptr) {
std::cout << "pFrame is NULL." << std::endl;
return -1;
}
if (width <= 0 || height <= 0) {
std::cout << "width is:" << width << " height is:" << height << std::endl;
return -1;
}
std::unique_lock<std::mutex> sbguard(m_Mutex[4]);
uint8_t* frame = new uint8_t[width * height * 3 / 2];
if (frame == nullptr) {
return -1;
}
if (data[4].size() > 0) {
while (data[4].size() > 15) {
uint8_t* pd = data[4].front();
data[4].pop_front();
delete pd;
pd = nullptr;
}
}
memcpy(frame, pFrame, width * height * 3 / 2);
data[4].push_back(frame);
m_hasdata = true;
return 0;
}
int D3D11Render::InputMediaFrame6(uint8_t* pFrame, int length, int width, int height, int q_num)
{
if (pFrame == nullptr) {
std::cout << "pFrame is NULL." << std::endl;
return -1;
}
if (width <= 0 || height <= 0) {
std::cout << "width is:" << width << " height is:" << height << std::endl;
return -1;
}
std::unique_lock<std::mutex> sbguard(m_Mutex[5]);
uint8_t* frame = new uint8_t[width * height * 3 / 2];
if (frame == nullptr) {
return -1;
}
if (data[5].size() > 0) {
while (data[5].size() > 15) {
uint8_t* pd = data[5].front();
data[5].pop_front();
delete pd;
pd = nullptr;
}
}
memcpy(frame, pFrame, width * height * 3 / 2);
data[5].push_back(frame);
m_hasdata = true;
return 0;
}
int D3D11Render::InputMediaFrame7(uint8_t* pFrame, int length, int width, int height, int q_num)
{
if (pFrame == nullptr) {
std::cout << "pFrame is NULL." << std::endl;
return -1;
}
if (width <= 0 || height <= 0) {
std::cout << "width is:" << width << " height is:" << height << std::endl;
return -1;
}
std::unique_lock<std::mutex> sbguard(m_Mutex[6]);
uint8_t* frame = new uint8_t[width * height * 3 / 2];
if (frame == nullptr) {
return -1;
}
if (data[6].size() > 0) {
while (data[6].size() > 15
没有合适的资源?快使用搜索试试~ 我知道了~
D3D11直接渲染YUV
共119个文件
h:27个
tlog:26个
ipch:12个
5星 · 超过95%的资源 需积分: 50 61 下载量 165 浏览量
2022-07-27
14:29:16
上传
评论
收藏 254.8MB ZIP 举报
温馨提示
采取三纹理方式使D3D可以直接渲染YUV数据
资源详情
资源评论
资源推荐
收起资源包目录
D3D11直接渲染YUV (119个子文件)
Direct3D11Render.aps 95KB
D3D11Render.cpp 45KB
Direct3D11Render.cpp 24KB
MediaFoundationCapture.cpp 17KB
MediaInterface.cpp 789B
Triangle_PS.cso 1KB
Triangle_PS.cso 1KB
Triangle_VS.cso 604B
Triangle_VS.cso 604B
Browse.VC.db 56.25MB
Direct3D11Render.exe 3.32MB
Direct3D11Render.exe 1.08MB
Direct3D11Render.vcxproj.filters 3KB
row.h 78KB
planar_functions.h 16KB
scale_row.h 14KB
convert.h 10KB
convert_argb.h 8KB
video_common.h 6KB
convert_from.h 6KB
mjpeg_decoder.h 6KB
format_conversion.h 6KB
convert_from_argb.h 5KB
D3D11Render.h 4KB
rotate.h 4KB
MediaFoundationCapture.h 3KB
basic_types.h 3KB
scale.h 3KB
cpu_id.h 3KB
compare.h 2KB
scale_argb.h 2KB
libyuv.h 1KB
rotate_argb.h 1003B
Resource.h 768B
version.h 578B
framework.h 392B
MediaInterface.h 357B
MediaDef.h 354B
targetver.h 300B
Direct3D11Render.h 39B
Triangle_PS.hlsl 3KB
Triangle_VS.hlsl 795B
small.ico 45KB
Direct3D11Render.ico 45KB
vc141.idb 827KB
Direct3D11Render.ilk 12.21MB
Direct3D11Render.iobj 1.51MB
MEDIAFOUNDATIONCAPTURE.ipch 112.13MB
MEDIAINTERFACE.ipch 112MB
MEDIAFOUNDATIONCAPTURE.ipch 111.88MB
MEDIAINTERFACE.ipch 110.88MB
MEDIAINTERFACE.ipch 110.88MB
DIRECT3D11RENDER.ipch 101.44MB
DIRECT3D11RENDER.ipch 101.25MB
D3D11RENDER.ipch 98.63MB
D3D11RENDER.ipch 98.38MB
D3D11RENDER.ipch 82.38MB
D3D11RENDER.ipch 81MB
DIRECT3D11RENDER.ipch 23.75MB
Direct3D11Render.ipdb 415KB
Direct3D11Render.lastbuildstate 209B
Direct3D11Render.lastbuildstate 207B
Direct3D11Render.exe.lastcodeanalysissucceeded 0B
libyuv.lib 1.71MB
Direct3D11Render.Build.CppClean.log 3KB
Direct3D11Render.Build.CppClean.log 2KB
Direct3D11Render.log 570B
Direct3D11Render.log 280B
D3D11Render.obj 2.21MB
Direct3D11Render.obj 2.1MB
MediaFoundationCapture.obj 2.06MB
MediaInterface.obj 2.05MB
D3D11Render.obj 1.38MB
MediaInterface.obj 890KB
Direct3D11Render.obj 653KB
MediaFoundationCapture.obj 566KB
Direct3D11Render.pdb 18.32MB
Direct3D11Render.pdb 9.43MB
vc141.pdb 956KB
vc141.pdb 948KB
i420.rar 2KB
Direct3D11Render.rc 7KB
Direct3D11Render.res 92KB
Direct3D11Render.res 92KB
Direct3D11Render.sln 1KB
.suo 66KB
CL.read.1.tlog 208KB
CL.read.1.tlog 208KB
Direct3D11Render.write.1u.tlog 16KB
link.read.1.tlog 7KB
link.read.1.tlog 7KB
CL.write.1.tlog 4KB
CL.command.1.tlog 4KB
CL.command.1.tlog 4KB
rc.read.1.tlog 3KB
rc.read.1.tlog 3KB
CL.write.1.tlog 3KB
link.command.1.tlog 2KB
link.command.1.tlog 2KB
fxc.command.1.tlog 1KB
共 119 条
- 1
- 2
小小菜鸟少少烦恼
- 粉丝: 1
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 聊天系统(java+applet).zip
- 毕业设计:基于SSM的mysql-高校学生请假管理系统(源码 + 数据库 + 说明文档)
- 博客系统(struts+hibernate+spring).rar
- c语言学生成绩管理系统源码.zip
- 毕业设计:基于SSM的mysql-网约车用户服务平台(源码 + 数据库 + 说明文档)
- 内容管理系统(hibernate3+struts2+spring2)130224.rar
- 基于Java的班级管理系统课程设计源码
- 内容管理系统(hibernate3+struts2+spring2).rar
- 路由器刷breed Web控制台助手v5.8版本.rar
- Java 在 JEP 12 提供的特性预览
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论2