Commit 05613217 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Performance: avoid allocations by std::vector in up/down band generator.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 5c6b2c83
...@@ -247,19 +247,20 @@ class UpDownGen ...@@ -247,19 +247,20 @@ class UpDownGen
{ {
Random::Stream random_stream; Random::Stream random_stream;
Random random; Random random;
vector<int> bands_reorder;
public: public:
UpDownGen (Random::Stream random_stream) : UpDownGen (Random::Stream random_stream) :
random_stream (random_stream), random_stream (random_stream),
random (0, random_stream) random (0, random_stream),
bands_reorder (Params::max_band - Params::min_band + 1)
{ {
} }
void void
get (int f, vector<int>& up, vector<int>& down) get (int f, vector<int>& up, vector<int>& down)
{ {
vector<int> bands_reorder; for (size_t i = 0; i < bands_reorder.size(); i++)
for (int i = Params::min_band; i <= Params::max_band; i++) bands_reorder[i] = Params::min_band + i;
bands_reorder.push_back (i);
random.seed (f, random_stream); // use per frame random seed random.seed (f, random_stream); // use per frame random seed
random.shuffle (bands_reorder); random.shuffle (bands_reorder);
...@@ -720,6 +721,11 @@ add_watermark (const string& infile, const string& outfile, const string& bits) ...@@ -720,6 +721,11 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
int ab = 0; int ab = 0;
vector<float> samples; vector<float> samples;
for (int j = 0; j < 100; j++)
{
vector<vector<FrameDelta>> frame_mod_vec;
init_frame_mod_vec (frame_mod_vec, 0, bitvec_a);
}
vector<vector<FrameDelta>> frame_mod_vec_a, frame_mod_vec_b;; vector<vector<FrameDelta>> frame_mod_vec_a, frame_mod_vec_b;;
init_frame_mod_vec (frame_mod_vec_a, 0, bitvec_a); init_frame_mod_vec (frame_mod_vec_a, 0, bitvec_a);
while (true) while (true)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment