diff options
author | U. Artie Eoff <ullysses.a.eoff@intel.com> | 2016-09-28 13:36:07 -0700 |
---|---|---|
committer | Sean V Kelley <seanvk@posteo.de> | 2016-10-03 11:30:52 -0700 |
commit | 37a15c1e9e6bf67a37c8d664f93d5946ff2819ce (patch) | |
tree | 86e44e0768e776a17c653d1d29bc47dc666eb4f5 /test | |
parent | f6ee6933a9d1e7d922817dd1ef770e8939bdedb9 (diff) |
test: jpeg/enc: move YUV conversion to TestInput class
Let the ::JPEG::Encode::TestInput class deal with
converting from its input fourcc to its expected
output fourcc.
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_encode_test.cpp | 26 | ||||
-rw-r--r-- | test/i965_jpeg_test_data.cpp | 25 | ||||
-rw-r--r-- | test/i965_jpeg_test_data.h | 1 |
3 files changed, 28 insertions, 24 deletions
diff --git a/test/i965_jpeg_encode_test.cpp b/test/i965_jpeg_encode_test.cpp index 2530288..b454484 100644 --- a/test/i965_jpeg_encode_test.cpp +++ b/test/i965_jpeg_encode_test.cpp @@ -82,27 +82,6 @@ TEST_F(JPEGEncodeTest, Entrypoint) } } -const TestInput::Shared NV12toI420(const TestInput::SharedConst& nv12) -{ - TestInput::Shared i420( - TestInput::create(VA_FOURCC_I420, nv12->width(), nv12->height())); - - i420->bytes = nv12->bytes; - - size_t i(0); - auto predicate = [&i](const ByteData::value_type&) { - bool isu = ((i % 2) == 0) or (i == 0); - ++i; - return isu; - }; - - std::stable_partition( - i420->bytes.begin() + i420->offsets[1], - i420->bytes.end(), predicate); - - return i420; -} - class JPEGEncodeInputTest : public JPEGEncodeTest , public ::testing::WithParamInterface< @@ -372,9 +351,8 @@ protected: { // VerifyOutput only supports VA_FOURCC_IMC3 output, currently ASSERT_EQ(unsigned(VA_FOURCC_IMC3), input->fourcc_output); - TestInput::SharedConst expect = input; - if (input->fourcc == VA_FOURCC_NV12) - expect = NV12toI420(input); + TestInput::SharedConst expect = input->toOutputFourcc(); + ASSERT_PTR(expect.get()); ::JPEG::Decode::PictureData::SharedConst pd = ::JPEG::Decode::PictureData::make( diff --git a/test/i965_jpeg_test_data.cpp b/test/i965_jpeg_test_data.cpp index 0cf3d23..0b0258a 100644 --- a/test/i965_jpeg_test_data.cpp +++ b/test/i965_jpeg_test_data.cpp @@ -839,6 +839,31 @@ namespace Encode { return bytes.data() + offsets[i]; } + const TestInput::SharedConst TestInput::toOutputFourcc() const + { + TestInput::Shared result; + if (fourcc_output == VA_FOURCC_IMC3) { + if (fourcc == VA_FOURCC_I420) { + return shared_from_this(); + } else if (fourcc == VA_FOURCC_NV12) { + result = create(VA_FOURCC_I420, width(), height()); + std::copy( + std::begin(bytes), std::end(bytes), + std::back_inserter(result->bytes)); + size_t i(0); + auto predicate = [&i](const ByteData::value_type&) { + bool isu = ((i % 2) == 0) or (i == 0); + ++i; + return isu; + }; + std::stable_partition( + std::begin(result->bytes) + result->offsets[1], + std::end(result->bytes), predicate); + } + } + return result; + } + ::std::ostream& operator<<(::std::ostream& os, const TestInput& t) { return os diff --git a/test/i965_jpeg_test_data.h b/test/i965_jpeg_test_data.h index 698385a..520c7f5 100644 --- a/test/i965_jpeg_test_data.h +++ b/test/i965_jpeg_test_data.h @@ -403,6 +403,7 @@ namespace Encode { const unsigned width() const; const unsigned height() const; const uint8_t* plane(const size_t) const; + const SharedConst toOutputFourcc() const; friend ::std::ostream& operator<<(::std::ostream&, const TestInput&); friend ::std::ostream& operator<<(::std::ostream&, const Shared&); |