Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use placement new and explicit destructor for tf #222

Merged
merged 5 commits into from
Mar 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/background-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <memory>
#include <exception>
#include <fstream>
#include <new>

#include "plugin-macros.generated.h"
#include "models/ModelSINET.h"
Expand Down Expand Up @@ -56,7 +57,6 @@ struct background_removal_filter {
std::vector<std::vector<int64_t>> outputDims;
std::vector<std::vector<float>> outputTensorValues;
std::vector<std::vector<float>> inputTensorValues;
Ort::MemoryInfo memoryInfo;
float threshold = 0.5f;
cv::Scalar backgroundColor{0, 0, 0, 0};
float contourFilter = 0.05f;
Expand Down Expand Up @@ -290,8 +290,8 @@ static void filter_update(void *data, obs_data_t *settings)

static void *filter_create(obs_data_t *settings, obs_source_t *source)
{
struct background_removal_filter *tf = reinterpret_cast<background_removal_filter *>(
bzalloc(sizeof(struct background_removal_filter)));
void *data = bmalloc(sizeof(struct background_removal_filter));
struct background_removal_filter *tf = new (data) background_removal_filter();

tf->source = source;
tf->texrender = gs_texrender_create(GS_BGRA, GS_ZS_NONE);
Expand All @@ -316,6 +316,7 @@ static void filter_destroy(void *data)
gs_stagesurface_destroy(tf->stagesurface);
}
obs_leave_graphics();
tf->~background_removal_filter();
bfree(tf);
}
}
Expand Down