summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2016-09-28 13:36:08 -0700
committerSean V Kelley <seanvk@posteo.de>2016-10-03 11:30:56 -0700
commit6bf510f54b41dc9a4aca3d3ad921ec47d5fbfafe (patch)
treee5a515878c486080916d5eb1450985dc3afb379d /test
parent37a15c1e9e6bf67a37c8d664f93d5946ff2819ce (diff)
test: jpeg/enc: improve random YUV data initialization
Make initialization of YUV input for jpeg encode a little faster, esp. for larger resolution. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com> Reviewed-by: Sean V Kelley <seanvk@posteo.de>
Diffstat (limited to 'test')
-rw-r--r--test/i965_jpeg_test_data.cpp17
-rw-r--r--test/test_utils.h2
2 files changed, 10 insertions, 9 deletions
diff --git a/test/i965_jpeg_test_data.cpp b/test/i965_jpeg_test_data.cpp
index 0b0258a..c1ff627 100644
--- a/test/i965_jpeg_test_data.cpp
+++ b/test/i965_jpeg_test_data.cpp
@@ -28,6 +28,7 @@
#include "test_utils.h"
#include <algorithm>
+#include <numeric>
namespace JPEG {
namespace Decode {
@@ -822,6 +823,10 @@ namespace Encode {
for (size_t i(1); i < planes; ++i)
offsets[i] = sizes[i - 1] + offsets[i - 1];
+
+ // Allocate bytes. Values are arbitrary.
+ bytes.resize(
+ std::accumulate(std::begin(sizes), std::end(sizes), 0u));
}
const unsigned TestInput::width() const
@@ -849,7 +854,7 @@ namespace Encode {
result = create(VA_FOURCC_I420, width(), height());
std::copy(
std::begin(bytes), std::end(bytes),
- std::back_inserter(result->bytes));
+ std::begin(result->bytes));
size_t i(0);
auto predicate = [&i](const ByteData::value_type&) {
bool isu = ((i % 2) == 0) or (i == 0);
@@ -890,13 +895,9 @@ namespace Encode {
const std::array<unsigned, 2> res = getResolution();
TestInput::Shared input(TestInput::create(fourcc, res[0], res[1]));
- ByteData& bytes = input->bytes;
-
- RandomValueGenerator<uint8_t> rg(0x00, 0xff);
- for (size_t i(0); i < input->planes; ++i)
- std::generate_n(
- std::back_inserter(bytes), input->sizes[i],
- [&rg]{ return rg(); });
+ std::generate_n(
+ std::begin(input->bytes), input->bytes.size(),
+ RandomValueGenerator<uint8_t>(0x00, 0xff));
return input;
}
diff --git a/test/test_utils.h b/test/test_utils.h
index ee84f7b..0076677 100644
--- a/test/test_utils.h
+++ b/test/test_utils.h
@@ -38,7 +38,7 @@ public:
const T operator()()
{
static std::random_device rd;
- static std::mt19937 gen(rd());
+ static std::default_random_engine gen(rd());
return dis(gen);
}