mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Refactor conv op to use slightly safer std::vector
Inspired by similar change to recomb op in commit 60c5c50
This commit is contained in:
parent
60c5c5083d
commit
2f0bbebfc9
@ -164,10 +164,10 @@ namespace sharp {
|
||||
*/
|
||||
VImage Convolve(VImage image, int const width, int const height,
|
||||
double const scale, double const offset,
|
||||
std::unique_ptr<double[]> const &kernel_v
|
||||
std::vector<double> const &kernel_v
|
||||
) {
|
||||
VImage kernel = VImage::new_from_memory(
|
||||
kernel_v.get(),
|
||||
static_cast<void*>(const_cast<double*>(kernel_v.data())),
|
||||
width * height * sizeof(double),
|
||||
width,
|
||||
height,
|
||||
|
@ -53,7 +53,7 @@ namespace sharp {
|
||||
* Convolution with a kernel.
|
||||
*/
|
||||
VImage Convolve(VImage image, int const width, int const height,
|
||||
double const scale, double const offset, std::unique_ptr<double[]> const &kernel_v);
|
||||
double const scale, double const offset, std::vector<double> const &kernel_v);
|
||||
|
||||
/*
|
||||
* Sharpen flat and jagged areas. Use sigma of -1.0 for fast sharpen.
|
||||
|
@ -1606,7 +1606,7 @@ Napi::Value pipeline(const Napi::CallbackInfo& info) {
|
||||
baton->convKernelScale = sharp::AttrAsDouble(kernel, "scale");
|
||||
baton->convKernelOffset = sharp::AttrAsDouble(kernel, "offset");
|
||||
size_t const kernelSize = static_cast<size_t>(baton->convKernelWidth * baton->convKernelHeight);
|
||||
baton->convKernel = std::unique_ptr<double[]>(new double[kernelSize]);
|
||||
baton->convKernel.resize(kernelSize);
|
||||
Napi::Array kdata = kernel.Get("kernel").As<Napi::Array>();
|
||||
for (unsigned int i = 0; i < kernelSize; i++) {
|
||||
baton->convKernel[i] = sharp::AttrAsDouble(kdata, i);
|
||||
|
@ -197,7 +197,7 @@ struct PipelineBaton {
|
||||
std::unordered_map<std::string, std::string> withExif;
|
||||
bool withExifMerge;
|
||||
int timeoutSeconds;
|
||||
std::unique_ptr<double[]> convKernel;
|
||||
std::vector<double> convKernel;
|
||||
int convKernelWidth;
|
||||
int convKernelHeight;
|
||||
double convKernelScale;
|
||||
|
Loading…
x
Reference in New Issue
Block a user