trying to optimize
This commit is contained in:
@@ -118,8 +118,8 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "1" << "width: " << width <<
|
||||
"height: " << height << "frame count: " << fps << std::endl;
|
||||
// std::cout << "1" << "width: " << width <<
|
||||
// "height: " << height << "frame count: " << fps << std::endl;
|
||||
|
||||
// Validate frame sizes
|
||||
size_t expectedFrameSize = width * height * 3;
|
||||
@@ -129,13 +129,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "2" << std::endl;
|
||||
// std::cout << "2" << std::endl;
|
||||
// Create directory if needed
|
||||
if (!createDirectoryIfNeeded(filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cout << "3" << std::endl;
|
||||
// std::cout << "3" << std::endl;
|
||||
std::ofstream file(filename, std::ios::binary);
|
||||
if (!file) {
|
||||
return false;
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
uint32_t frameSize = rowSize * height;
|
||||
uint32_t totalDataSize = frameCount * frameSize;
|
||||
|
||||
std::cout << "4" << std::endl;
|
||||
// std::cout << "4" << std::endl;
|
||||
// RIFF AVI header
|
||||
RIFFChunk riffHeader;
|
||||
riffHeader.chunkId = 0x46464952; // 'RIFF'
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
uint32_t hdrlListStart = static_cast<uint32_t>(file.tellp());
|
||||
writeList(file, 0x6C726468, nullptr, 0); // 'hdrl' - we'll fill size later
|
||||
|
||||
std::cout << "5" << std::endl;
|
||||
// std::cout << "5" << std::endl;
|
||||
// avih chunk
|
||||
AVIMainHeader mainHeader;
|
||||
mainHeader.microSecPerFrame = microSecPerFrame;
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
|
||||
writeChunk(file, 0x68697661, &mainHeader, sizeof(mainHeader)); // 'avih'
|
||||
|
||||
std::cout << "6" << std::endl;
|
||||
// std::cout << "6" << std::endl;
|
||||
// strl list
|
||||
uint32_t strlListStart = static_cast<uint32_t>(file.tellp());
|
||||
writeList(file, 0x6C727473, nullptr, 0); // 'strl' - we'll fill size later
|
||||
@@ -226,7 +226,7 @@ public:
|
||||
|
||||
writeChunk(file, 0x66727473, &bitmapInfo, sizeof(bitmapInfo)); // 'strf'
|
||||
|
||||
std::cout << "7" << std::endl;
|
||||
// std::cout << "7" << std::endl;
|
||||
// Update strl list size
|
||||
uint32_t strlListEnd = static_cast<uint32_t>(file.tellp());
|
||||
file.seekp(strlListStart + 4);
|
||||
@@ -234,7 +234,7 @@ public:
|
||||
file.write(reinterpret_cast<const char*>(&strlListSize), 4);
|
||||
file.seekp(strlListEnd);
|
||||
|
||||
std::cout << "8" << std::endl;
|
||||
// std::cout << "8" << std::endl;
|
||||
// Update hdrl list size
|
||||
uint32_t hdrlListEnd = static_cast<uint32_t>(file.tellp());
|
||||
file.seekp(hdrlListStart + 4);
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
file.write(reinterpret_cast<const char*>(&hdrlListSize), 4);
|
||||
file.seekp(hdrlListEnd);
|
||||
|
||||
std::cout << "9" << std::endl;
|
||||
// std::cout << "9" << std::endl;
|
||||
// movi list
|
||||
uint32_t moviListStart = static_cast<uint32_t>(file.tellp());
|
||||
writeList(file, 0x69766F6D, nullptr, 0); // 'movi' - we'll fill size later
|
||||
@@ -254,7 +254,7 @@ public:
|
||||
for (uint32_t i = 0; i < frameCount; ++i) {
|
||||
uint32_t frameStart = static_cast<uint32_t>(file.tellp()) - moviListStart - 4;
|
||||
|
||||
std::cout << "10-" << i << std::endl;
|
||||
// std::cout << "10-" << i << std::endl;
|
||||
// Create padded frame data (BMP-style bottom-to-top with padding)
|
||||
std::vector<uint8_t> paddedFrame(frameSize, 0);
|
||||
const auto& frame = frames[i];
|
||||
@@ -268,7 +268,7 @@ public:
|
||||
// Padding bytes remain zeros
|
||||
}
|
||||
|
||||
std::cout << "11-" << i << std::endl;
|
||||
// std::cout << "11-" << i << std::endl;
|
||||
// Write frame as '00db' chunk
|
||||
writeChunk(file, 0x62643030, paddedFrame.data(), frameSize); // '00db'
|
||||
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
indexEntries.push_back(entry);
|
||||
}
|
||||
|
||||
std::cout << "12" << std::endl;
|
||||
// std::cout << "12" << std::endl;
|
||||
// Update movi list size
|
||||
uint32_t moviListEnd = static_cast<uint32_t>(file.tellp());
|
||||
file.seekp(moviListStart + 4);
|
||||
@@ -289,7 +289,7 @@ public:
|
||||
file.write(reinterpret_cast<const char*>(&moviListSize), 4);
|
||||
file.seekp(moviListEnd);
|
||||
|
||||
std::cout << "13" << std::endl;
|
||||
// std::cout << "13" << std::endl;
|
||||
// idx1 chunk - index
|
||||
uint32_t idx1Size = static_cast<uint32_t>(indexEntries.size() * sizeof(AVIIndexEntry));
|
||||
writeChunk(file, 0x31786469, indexEntries.data(), idx1Size); // 'idx1'
|
||||
@@ -300,7 +300,7 @@ public:
|
||||
uint32_t riffSize = fileEnd - riffStartPos - 8;
|
||||
file.write(reinterpret_cast<const char*>(&riffSize), 4);
|
||||
|
||||
std::cout << "14" << std::endl;
|
||||
// std::cout << "14" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user