summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2016-09-28 13:36:09 -0700
committerSean V Kelley <seanvk@posteo.de>2016-10-03 11:31:00 -0700
commit9dd60d7fc73e35207d629519102afdc4f6ff668d (patch)
tree668e481a7e30ec4c574845cf05758d07d3d746ee /test
parent6bf510f54b41dc9a4aca3d3ad921ec47d5fbfafe (diff)
test: jpeg/enc: return empty TestInput::Shared if fourcc not handled
Move JPEG::Encode::TestInput member initialization to its static "create" routine so that an empty/invalid Shared can be returned if the input fourcc is not handled/implemented. This will allow a caller/test to react appropriately. 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.cpp87
-rw-r--r--test/i965_jpeg_test_data.h2
2 files changed, 48 insertions, 41 deletions
diff --git a/test/i965_jpeg_test_data.cpp b/test/i965_jpeg_test_data.cpp
index c1ff627..da7d440 100644
--- a/test/i965_jpeg_test_data.cpp
+++ b/test/i965_jpeg_test_data.cpp
@@ -777,18 +777,53 @@ namespace Encode {
TestInput::Shared TestInput::create(
const unsigned fourcc, const unsigned w, const unsigned h)
{
- return Shared(new TestInput(fourcc, w, h));
+ Shared t(new TestInput);
+
+ switch(fourcc) {
+ case VA_FOURCC_I420:
+ t->planes = 3;
+ t->widths = {w + (w & 1), (w + 1) >> 1, (w + 1) >> 1};
+ t->heights = {h + (h & 1), (h + 1) >> 1, (h + 1) >> 1};
+ t->format = VA_RT_FORMAT_YUV420;
+ t->fourcc_output = VA_FOURCC_IMC3;
+ break;
+ case VA_FOURCC_NV12:
+ t->planes = 2;
+ t->widths = {w + (w & 1), w + (w & 1), 0};
+ t->heights = {h + (h & 1), (h + 1) >> 1, 0};
+ t->format = VA_RT_FORMAT_YUV420;
+ t->fourcc_output = VA_FOURCC_IMC3;
+ break;
+ default:
+ return Shared(); // fourcc is unsupported
+ }
+
+ t->fourcc = fourcc;
+ t->picture.picture_width = ALIGN(w, 2);
+ t->picture.picture_height = ALIGN(h, 2);
+
+ for (size_t i(0); i < t->planes; ++i)
+ t->sizes[i] = t->widths[i] * t->heights[i];
+
+ for (size_t i(1); i < t->planes; ++i)
+ t->offsets[i] = t->sizes[i - 1] + t->offsets[i - 1];
+
+ // Allocate bytes. Values are arbitrary. Caller is responsible for
+ // assigning byte values as appropriate.
+ t->bytes.resize(
+ std::accumulate(std::begin(t->sizes), std::end(t->sizes), 0u));
+
+ return t;
}
- TestInput::TestInput(
- const unsigned fourcc, const unsigned w, const unsigned h)
- : bytes() // caller must fill this in after instantiation
+ TestInput::TestInput()
+ : bytes()
, picture(defaultPictureParameter)
, matrix(defaultIQMatrix)
, huffman(defaultHuffmanTable)
, slice(defaultSliceParameter)
- , fourcc(fourcc)
- , fourcc_output(fourcc)
+ , fourcc(0)
+ , fourcc_output(0)
, format(0)
, planes(0)
, widths{0,0,0}
@@ -796,37 +831,7 @@ namespace Encode {
, offsets{0,0,0}
, sizes{0,0,0}
{
- picture.picture_width = ALIGN(w, 2);
- picture.picture_height = ALIGN(h, 2);
-
- switch(fourcc) {
- case VA_FOURCC_I420:
- planes = 3;
- widths = {w + (w & 1), (w + 1) >> 1, (w + 1) >> 1};
- heights = {h + (h & 1), (h + 1) >> 1, (h + 1) >> 1};
- format = VA_RT_FORMAT_YUV420;
- fourcc_output = VA_FOURCC_IMC3;
- break;
- case VA_FOURCC_NV12:
- planes = 2;
- widths = {w + (w & 1), w + (w & 1), 0};
- heights = {h + (h & 1), (h + 1) >> 1, 0};
- format = VA_RT_FORMAT_YUV420;
- fourcc_output = VA_FOURCC_IMC3;
- break;
- default:
- return;
- }
-
- for (size_t i(0); i < planes; ++i)
- sizes[i] = widths[i] * heights[i];
-
- 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));
+ return;
}
const unsigned TestInput::width() const
@@ -895,9 +900,11 @@ namespace Encode {
const std::array<unsigned, 2> res = getResolution();
TestInput::Shared input(TestInput::create(fourcc, res[0], res[1]));
- std::generate_n(
- std::begin(input->bytes), input->bytes.size(),
- RandomValueGenerator<uint8_t>(0x00, 0xff));
+ if (input.get()) {
+ std::generate_n(
+ std::begin(input->bytes), input->bytes.size(),
+ RandomValueGenerator<uint8_t>(0x00, 0xff));
+ }
return input;
}
diff --git a/test/i965_jpeg_test_data.h b/test/i965_jpeg_test_data.h
index 520c7f5..f29e579 100644
--- a/test/i965_jpeg_test_data.h
+++ b/test/i965_jpeg_test_data.h
@@ -424,7 +424,7 @@ namespace Encode {
std::array<size_t, 3> sizes;
private:
- TestInput(const unsigned, const unsigned, const unsigned);
+ TestInput();
};
class TestInputCreator