Add initial AR playback support
This commit is contained in:
60
openVulkanoCpp/AR/Provider/Playback/ArPlaybackReader.cpp
Normal file
60
openVulkanoCpp/AR/Provider/Playback/ArPlaybackReader.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "ArPlaybackReader.hpp"
|
||||
|
||||
#if __has_include("turbojpeg.h")
|
||||
#include <turbojpeg.h>
|
||||
|
||||
namespace openVulkanoCpp::AR::Playback
|
||||
{
|
||||
ColorImg ArPlaybackReader::ReadColorImage()
|
||||
{
|
||||
ColorImg img;
|
||||
auto file = m_archiveColor.GetNextFile();
|
||||
|
||||
long unsigned int jpegSize = file->second.Size();
|
||||
unsigned char* compressedImage = reinterpret_cast<uint8_t*>(file->second.Data());
|
||||
|
||||
int jpegSubsamp;
|
||||
tjhandle jpegDecompressor = tjInitDecompress();
|
||||
tjDecompressHeader2(jpegDecompressor, compressedImage, jpegSize, &img.cols, &img.rows, &jpegSubsamp);
|
||||
|
||||
img.channels = 3;
|
||||
img.dataPtr = std::shared_ptr<uint8_t>(new uint8_t[img.cols * img.rows * 3]);
|
||||
img.data = img.dataPtr.get();
|
||||
|
||||
//TODO is it better to not map to rgb? to keep the same pipeline as on device
|
||||
tjDecompress2(jpegDecompressor, compressedImage, jpegSize, img.data, img.cols, 0/*pitch*/, img.rows, TJPF_RGB, TJFLAG_FASTDCT);
|
||||
//tjDecompressToYUV2(jpegDecompressor, compressedImage, jpegSize, img.data, img.cols, img.rows, 1, TJFLAG_FASTDCT);
|
||||
tjDestroy(jpegDecompressor);
|
||||
|
||||
//auto buff = new uint8_t[img.cols * img.rows * 3];
|
||||
|
||||
//YuvUtils::NV12FromChromaPlanes(buff, img.data + (img.cols * img.rows), img.cols * img.rows / 4);
|
||||
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include <stb_image.h>
|
||||
|
||||
namespace openVulkanoCpp::AR::Playback
|
||||
{
|
||||
ColorImg ArPlaybackReader::ReadColorImage()
|
||||
{
|
||||
ColorImg img;
|
||||
auto file = m_archiveColor.GetNextFile();
|
||||
img.dataPtr = std::shared_ptr<uint8_t>(
|
||||
stbi_load_from_memory(reinterpret_cast<stbi_uc*>(file->second.Data()), file->second.Size(), &img.cols, &img.rows, &img.channels, 3),
|
||||
&stbi_image_free);
|
||||
img.data = img.dataPtr.get();
|
||||
return img;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user