Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit b0d516f

Browse files
Optimize Recorder
1 parent 6b6e17e commit b0d516f

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

pong/includes.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@
1010
#include <atomic>
1111
#include <filesystem>
1212
#include "ffmpegImports.h"
13-
14-
#include <fstream>
13+
#include <queue>

pong/pong.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,9 @@ void renderThreadp(
290290
bool* record = nullptr,
291291
Shape* dn = nullptr) {
292292
//PREPARE RECORD
293-
const char recordOutput[]{ "./tmp" };
294-
if (!std::filesystem::exists(recordOutput)) {
295-
std::filesystem::create_directory(recordOutput);
296-
}
297293
bool preco = (record != nullptr ? *record : false),
298294
featureRec = record != nullptr;
299-
std::vector<Texture> records;
295+
std::queue<Texture> records;
300296
//END PREPARE RECORD
301297

302298
//GL CONTEXT
@@ -316,12 +312,13 @@ void renderThreadp(
316312
window->setFramerateLimit(fps[preco ? 0 : 1]);
317313
}
318314
if (preco) {
319-
if (records.max_size() >= records.size() + 1) {
315+
if (10000 >= records.size() + 1) {
320316
sf::Vector2u windowSize = window->getSize();
321317
sf::Texture texture;
322318
texture.create(windowSize.x, windowSize.y);
323319
texture.update(*window);
324-
records.push_back(texture);
320+
records.push(texture);
321+
//records.push_back(texture);
325322
}
326323
else
327324
*record = false;
@@ -361,8 +358,9 @@ void renderThreadp(
361358
unsigned char* calced = (unsigned char*)malloc(sizevid * 3);
362359
VideoCapture vc;
363360
vc.Init(size[0], size[1], 24, 400000);
364-
for (unsigned int x{ 0 }; x < records.size(); x++) {
365-
Image i = records[x].copyToImage();
361+
while (records.size() > 0) {
362+
Image i = records.front().copyToImage();
363+
records.pop();
366364
const unsigned char* ux = i.getPixelsPtr();
367365
//RGBA TO RGB:
368366
for (size_t xr{ 0 }, xct{ 0 }, srx{ 0 }; xr < (sizevid * 4); xr++) {

0 commit comments

Comments
 (0)