Skip to content

Commit bec7bab

Browse files
Material Engcopybara-github
authored andcommitted
Reduce stack size for QuantizeWu (C++).
PiperOrigin-RevId: 576903498
1 parent 6e0f5e1 commit bec7bab

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

cpp/quantize/wu.cc

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@
1818

1919
#include <stdlib.h>
2020

21-
#include <array>
2221
#include <cassert>
2322
#include <cstdint>
2423
#include <cstdio>
25-
#include <iostream>
26-
#include <ostream>
2724
#include <vector>
2825

2926
#include "cpp/utils/utils.h"
@@ -51,8 +48,8 @@ constexpr int kIndexCount = ((1 << kIndexBits) + 1);
5148
constexpr int kTotalSize = (kIndexCount * kIndexCount * kIndexCount);
5249
constexpr int kMaxColors = 256;
5350

54-
using IntArray = std::array<int64_t, kTotalSize>;
55-
using DoubleArray = std::array<double, kTotalSize>;
51+
using IntArray = std::vector<int64_t>;
52+
using DoubleArray = std::vector<double>;
5653

5754
int GetIndex(int r, int g, int b) {
5855
return (r << (kIndexBits * 2)) + (r << (kIndexBits + 1)) + (g << kIndexBits) +
@@ -298,11 +295,11 @@ std::vector<Argb> QuantizeWu(const std::vector<Argb>& pixels,
298295
return std::vector<Argb>();
299296
}
300297

301-
IntArray weights = {};
302-
IntArray moments_red = {};
303-
IntArray moments_green = {};
304-
IntArray moments_blue = {};
305-
DoubleArray moments = {};
298+
IntArray weights(kTotalSize, 0);
299+
IntArray moments_red(kTotalSize, 0);
300+
IntArray moments_green(kTotalSize, 0);
301+
IntArray moments_blue(kTotalSize, 0);
302+
DoubleArray moments(kTotalSize, 0.0);
306303
ConstructHistogram(pixels, weights, moments_red, moments_green, moments_blue,
307304
moments);
308305
ComputeMoments(weights, moments_red, moments_green, moments_blue, moments);

0 commit comments

Comments
 (0)