Skip to content

Commit

Permalink
[what] 适配 YUV420P 显示
Browse files Browse the repository at this point in the history
  • Loading branch information
HR1025 committed Sep 20, 2024
1 parent 3cd917b commit 6987627
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Core
Submodule Core updated 55 files
+3 −3 .gitmodules
+0 −9 CMake/spriv_cross.cmake
+4 −2 CMakeLists.txt
+2 −0 Codec/CMakeLists.txt
+12 −0 Codec/CodecFactory.cpp
+55 −0 Codec/CodecUtil.cpp
+26 −0 Codec/CodecUtil.h
+6 −0 Codec/D3D11/D3D11Common.cpp
+5 −0 Codec/D3D11/D3D11Common.h
+6 −0 Codec/D3D11/D3D11Decoder.cpp
+11 −0 Codec/D3D11/D3D11H264Decoder.cpp
+1 −1 Codec/H264
+89 −3 Codec/openh264/OpenH264Decoder.cpp
+4 −0 Codec/openh264/OpenH264Decoder.h
+0 −1 Extension/SPIRV-Cross
+1 −0 Extension/glslang
+0 −1 GPU/CMakeLists.txt
+7 −1 GPU/GL/CMakeLists.txt
+2 −2 GPU/GL/D3D11/D3D11Contex.cpp
+3 −3 GPU/GL/D3D11/D3D11Contex.h
+14 −14 GPU/GL/D3D11/D3D11DrawContex.cpp
+2 −2 GPU/GL/D3D11/D3D11DrawContex.h
+40 −0 GPU/GL/GLCommon.cpp
+23 −1 GPU/GL/GLCommon.h
+1 −1 GPU/GL/GLContex.h
+2 −2 GPU/GL/GLDrawContex.h
+5 −5 GPU/GL/OpenGL/OpenGLContex.cpp
+6 −6 GPU/GL/OpenGL/OpenGLContex.h
+8 −8 GPU/GL/OpenGL/OpenGLDrawContex.cpp
+2 −2 GPU/GL/OpenGL/OpenGLDrawContex.h
+6 −6 GPU/GL/OpenGL/OpenGLTranslator.cpp
+1 −1 GPU/GL/OpenGL/OpenGLTranslator.h
+52 −12 GPU/GL/Vulkan/VulkanContex.cpp
+19 −17 GPU/GL/Vulkan/VulkanContex.h
+110 −22 GPU/GL/Vulkan/VulkanDrawContex.cpp
+2 −2 GPU/GL/Vulkan/VulkanDrawContex.h
+2 −2 GPU/GL/Vulkan/VulkanGLTexture.cpp
+17 −5 GPU/GL/Vulkan/VulkanTranslator.cpp
+3 −1 GPU/GL/Vulkan/VulkanTranslator.h
+11 −11 GPU/PG/Scene/SceneItemImpl.cpp
+11 −11 GPU/PG/Scene/SceneLayerImpl.cpp
+2 −2 GPU/PG/Transition/TemplateTransition.cpp
+107 −13 GPU/PG/Transition/TransitionUtility.cpp
+3 −3 GPU/PG/Transition/TransitionUtility.h
+0 −34 GPU/SL/AbstractSLConverter.h
+0 −0 GPU/SL/AbstractSLFactory.cpp
+0 −15 GPU/SL/AbstractSLFactory.h
+0 −36 GPU/SL/CMakeLists.txt
+0 −51 GPU/SL/SLCommon.cpp
+0 −50 GPU/SL/SLCommon.h
+1,016 −0 LICENSES/GLSLANG_LICENSE
+18 −0 LICENSES/SDL_LICENSE
+0 −202 LICENSES/SPIRV_Cross_LICENSE
+5 −1 README.md
+4 −0 README_en.md
19 changes: 19 additions & 0 deletions source/DisplaySDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ bool DisplaySDL::Open(PixelsInfo info)
{
format = SDL_PIXELFORMAT_NV12;
}
else if (info.format == PixelFormat::YUV420P)
{
format = SDL_PIXELFORMAT_IYUV;
}
else
{
DISPLAY_LOG_ERROR << "Unsupport pixel format, pixel format is: " << _format;
Expand Down Expand Up @@ -198,6 +202,21 @@ void DisplaySDL::UpdateWindow(const uint32_t* frameBuffer, PixelsInfo info)
SDL_UpdateTexture(_texture, NULL, reinterpret_cast<const void*>(frameBuffer), sizeof(uint32_t)*_windowWidth);
break;
}
case PixelFormat::YUV420P:
{
uint8_t* yData = (uint8_t*)frameBuffer;
uint8_t* uData = yData + (info.virStride * info.horStride);
uint8_t* vData = uData + (info.virStride * info.horStride / 4);
SDL_Rect rect;
{
rect.x = 0;
rect.y = 0;
rect.w = info.width;
rect.h = info.height;
}
SDL_UpdateYUVTexture(_texture, &rect, yData, info.horStride, uData, info.horStride/2, vData, info.horStride/2);
break;
}
default:
{
return;
Expand Down
13 changes: 7 additions & 6 deletions test_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Common/AbstractLogger.h"
#include "Common/LogMessage.h"
#include "Common/ThreadPool.h"
#include "Codec/StreamPack.h"
#include "Codec/StreamFrame.h"
#include "Codec/CodecConfig.h"
#include "Codec/CodecFactory.h"
Expand All @@ -25,7 +26,7 @@ class H26XFileByteReader
explicit H26XFileByteReader(const std::string& path);
~H26XFileByteReader();
public:
NormalPack::ptr GetNalUint();
Codec::StreamPack::ptr GetNalUint();
public:
size_t Read(void* data, size_t bytes);
bool Seek(size_t offset);
Expand All @@ -40,7 +41,7 @@ class H26XFileByteReader
uint32_t _len;
};

NormalPack::ptr H26XFileByteReader::GetNalUint()
Codec::StreamPack::ptr H26XFileByteReader::GetNalUint()
{
std::vector<uint8_t> bufs;
bufs.reserve(1024 * 1024);
Expand Down Expand Up @@ -79,7 +80,7 @@ NormalPack::ptr H26XFileByteReader::GetNalUint()
}
std::shared_ptr<ImmutableVectorAllocateMethod<uint8_t>> alloc = std::make_shared<ImmutableVectorAllocateMethod<uint8_t>>();
alloc->container.swap(bufs);
return std::make_shared<NormalPack>(alloc->container.size(), alloc);
return std::make_shared<Codec::StreamPack>(Codec::CodecType::H264, alloc->container.size(), alloc);
}

H26XFileByteReader::H26XFileByteReader(const std::string& path)
Expand Down Expand Up @@ -219,7 +220,7 @@ void App::displayHelp()
helpFormatter.format(ss);
ss << std::endl;
ss << "Available Decoder Info" << std::endl;
std::vector<Codec::CodecDescription> descriptions = Codec::DecoderFactory::DecoderFactory().GetDecoderDescriptions();
std::vector<Codec::CodecDescription> descriptions = Codec::DecoderFactory::DefaultFactory().GetDecoderDescriptions();
for (auto& description : descriptions)
{
ss << "-- CodecType(" << description.codecType << ") CodecProcessType(" << description.processType
Expand Down Expand Up @@ -366,7 +367,7 @@ int App::main(const ArgVec& args)
display->Init();
}
std::shared_ptr<H26XFileByteReader> byteReader = std::make_shared<H26XFileByteReader>(inputFile);
NormalPack::ptr pack = nullptr;
Codec::StreamPack::ptr pack = nullptr;

//
// Input File Read -> VDEC PUSH
Expand Down Expand Up @@ -396,7 +397,7 @@ int App::main(const ArgVec& args)
}
if (display)
{
display->UpdateWindow((const uint32_t*)streamFrame->GetData(0));
display->UpdateWindow((const uint32_t*)streamFrame->GetData(0), streamFrame->info);
if (intervalMs > sw.elapsed() / 1000)
{
std::this_thread::sleep_for(std::chrono::milliseconds(intervalMs - sw.elapsed() / 1000));
Expand Down

0 comments on commit 6987627

Please sign in to comment.