[Libva] [PATCH intel-driver 07/11] test: jpeg/enc: move YUV conversion to TestInput class
U. Artie Eoff
ullysses.a.eoff at intel.com
Wed Sep 28 20:36:07 UTC 2016
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 at intel.com>
---
test/i965_jpeg_encode_test.cpp | 26 ++------------------------
test/i965_jpeg_test_data.cpp | 25 +++++++++++++++++++++++++
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 25302888b81f..b45448491670 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 0cf3d23f1a55..0b0258a49689 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 698385ae3eea..520c7f5c0daa 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&);
--
2.4.11
More information about the Libva
mailing list