aviwriter has been wrong this whole time. fixed it. also fixed lack of alpha. and broke ratio. its decent now.
This commit is contained in:
@@ -157,29 +157,29 @@ private:
|
||||
break;
|
||||
case frame::colormap::RGBA:
|
||||
for (uint32_t x = 0; x < width; ++x) {
|
||||
dstRow[x * 3] = srcRow[x * 4]; // R
|
||||
dstRow[x * 3 + 2] = srcRow[x * 4 + 0]; // R
|
||||
dstRow[x * 3 + 1] = srcRow[x * 4 + 1]; // G
|
||||
dstRow[x * 3 + 2] = srcRow[x * 4 + 2]; // B
|
||||
dstRow[x * 3 + 0] = srcRow[x * 4 + 2]; // B
|
||||
}
|
||||
break;
|
||||
case frame::colormap::BGR:
|
||||
for (uint32_t x = 0; x < width; ++x) {
|
||||
dstRow[x * 3] = srcRow[x * 3 + 2]; // R
|
||||
dstRow[x * 3 + 2] = srcRow[x * 3 + 2]; // R
|
||||
dstRow[x * 3 + 1] = srcRow[x * 3 + 1]; // G
|
||||
dstRow[x * 3 + 2] = srcRow[x * 3]; // B
|
||||
dstRow[x * 3 + 0] = srcRow[x * 3 + 0]; // B
|
||||
}
|
||||
break;
|
||||
case frame::colormap::BGRA:
|
||||
for (uint32_t x = 0; x < width; ++x) {
|
||||
dstRow[x * 3] = srcRow[x * 4 + 2]; // R
|
||||
dstRow[x * 3 + 2] = srcRow[x * 4 + 2]; // R
|
||||
dstRow[x * 3 + 1] = srcRow[x * 4 + 1]; // G
|
||||
dstRow[x * 3 + 2] = srcRow[x * 4]; // B
|
||||
dstRow[x * 3 + 0] = srcRow[x * 4 + 0]; // B
|
||||
}
|
||||
break;
|
||||
case frame::colormap::B:
|
||||
for (uint32_t x = 0; x < width; ++x) {
|
||||
uint8_t gray = srcRow[x];
|
||||
dstRow[x * 3] = gray; // R
|
||||
dstRow[x * 3 + 0] = gray; // R
|
||||
dstRow[x * 3 + 1] = gray; // G
|
||||
dstRow[x * 3 + 2] = gray; // B
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include "../vectorlogic/vec3.hpp"
|
||||
#include "frame.hpp"
|
||||
|
||||
class BMPWriter {
|
||||
private:
|
||||
@@ -137,6 +138,10 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool saveBMP(const std::string& filename, frame& frame) {
|
||||
return saveBMP(filename, frame.getData(), frame.getWidth(), frame.getHeight());
|
||||
}
|
||||
|
||||
private:
|
||||
static bool saveBMP(const std::string& filename, const std::vector<std::vector<Vec3>>& pixels, int width, int height) {
|
||||
// Create directory if needed
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <future>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include "../timing_decorator.hpp"
|
||||
|
||||
class frame {
|
||||
private:
|
||||
@@ -47,10 +48,11 @@ public:
|
||||
colormap colorFormat = colormap::RGB;
|
||||
compresstype cformat = compresstype::RAW;
|
||||
|
||||
size_t getWidth() {
|
||||
const size_t& getWidth() {
|
||||
return width;
|
||||
}
|
||||
size_t getHeight() {
|
||||
|
||||
const size_t& getHeight() {
|
||||
return height;
|
||||
}
|
||||
frame() {};
|
||||
@@ -73,6 +75,8 @@ public:
|
||||
_compressedData.clear();
|
||||
_compressedData.shrink_to_fit();
|
||||
overheadmap.clear();
|
||||
sourceSize = data.size();
|
||||
|
||||
}
|
||||
|
||||
const std::vector<uint8_t>& getData() const {
|
||||
@@ -221,9 +225,6 @@ public:
|
||||
// Get compressed size including dictionary overhead
|
||||
size_t getTotalCompressedSize() const {
|
||||
size_t baseSize = getCompressedDataSize();
|
||||
if (cformat == compresstype::LZ78) {
|
||||
baseSize += getDictionarySize();
|
||||
}
|
||||
return baseSize;
|
||||
}
|
||||
|
||||
@@ -237,7 +238,7 @@ public:
|
||||
}
|
||||
|
||||
size_t getCompressedDataSize() const {
|
||||
return _compressedData.size();
|
||||
return _compressedData.size() * 2;
|
||||
}
|
||||
|
||||
void printCompressionInfo() const {
|
||||
@@ -274,16 +275,9 @@ public:
|
||||
}
|
||||
|
||||
void printCompressionStats() const {
|
||||
if (cformat == compresstype::LZ78) {
|
||||
std::cout << "[" << getCompressionTypeString() << "] "
|
||||
<< "Source Size: " << getSourceSize() << " bytes"
|
||||
<< getTotalCompressedSize() << "B "
|
||||
<< "(ratio: " << getCompressionRatio() << ":1)" << std::endl;
|
||||
} else {
|
||||
std::cout << "[" << getCompressionTypeString() << "] "
|
||||
<< getSourceSize() << "B -> " << getTotalCompressedSize() << "B "
|
||||
<< "(ratio: " << getCompressionRatio() << ":1)" << std::endl;
|
||||
}
|
||||
std::cout << "[" << getCompressionTypeString() << "] "
|
||||
<< getSourceSize() << "B -> " << getTotalCompressedSize() << "B "
|
||||
<< "(ratio: " << getCompressionRatio() << ":1)" << std::endl;
|
||||
}
|
||||
|
||||
// Get compression type as string
|
||||
@@ -318,8 +312,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
//moving decompression to private to prevent breaking stuff from external calls
|
||||
|
||||
std::vector<std::vector<uint8_t>> sortvecs(std::vector<std::vector<uint8_t>> source) {
|
||||
std::sort(source.begin(), source.end(), [](const std::vector<uint8_t> & a, const std::vector<uint8_t> & b) {return a.size() > b.size();});
|
||||
return source;
|
||||
|
||||
Reference in New Issue
Block a user