Expand image decoding to allow for YUV and NV12

This commit is contained in:
Georg Hagen
2025-01-18 20:21:22 +01:00
parent 498b737322
commit 45ca54feb7
2 changed files with 71 additions and 18 deletions

View File

@@ -22,9 +22,21 @@ namespace OpenVulkano::AR::Playback
struct ColorImg
{
std::shared_ptr<uint8_t> dataPtr;
uint8_t* data;
int cols, rows, channels;
enum ChannelCount { GRAY = 1, RGBA = 4, YUV = 2, NV12 = -2 };
std::unique_ptr<uint8_t[]> dataPtr;
uint8_t* data = nullptr;
uint8_t* dataUV = nullptr;
int cols = 0, rows = 0, channels = 0;
void Allocate()
{
if (data) throw std::runtime_error("Data already set!");
dataPtr.reset(new uint8_t[cols * rows * abs(channels)]);
data = dataPtr.get();
}
bool UseRGB() const { return channels == RGBA; }
};
class ArPlaybackReader final
@@ -55,7 +67,15 @@ namespace OpenVulkano::AR::Playback
return std::move(m_archiveMetadata.GetNextFile()->second);
}
ColorImg ReadColorImage();
ColorImg ReadColorImage()
{
ColorImg img;
img.channels = ColorImg::RGBA; // TODO test if defaulting to NV12
ReadColorImage(img);
return img;
}
void ReadColorImage(ColorImg& img);
DepthImage ReadDepthImage()
{