[Libva] [PATCH intel-driver 04/11] test: jpeg/enc: move TestInput impl to compilation unit

U. Artie Eoff ullysses.a.eoff at intel.com
Wed Sep 28 20:36:04 UTC 2016


Move the implementation of JPEG::Encode::TestInput to the
compilation unit file (.cpp).  This helps reduce the number
of include headers needed in the header file.

Signed-off-by: U. Artie Eoff <ullysses.a.eoff at intel.com>
---
 test/i965_jpeg_encode_test.cpp |   2 +
 test/i965_jpeg_test_data.cpp   |  89 ++++++++++++++++++++++++++++++++++++
 test/i965_jpeg_test_data.h     | 101 +++--------------------------------------
 test/i965_test_fixture.h       |   1 -
 4 files changed, 98 insertions(+), 95 deletions(-)

diff --git a/test/i965_jpeg_encode_test.cpp b/test/i965_jpeg_encode_test.cpp
index a196c209ee55..c587643e1f32 100644
--- a/test/i965_jpeg_encode_test.cpp
+++ b/test/i965_jpeg_encode_test.cpp
@@ -23,6 +23,8 @@
  */
 
 #include "i965_jpeg_test_data.h"
+#include "i965_streamable.h"
+#include "i965_test_fixture.h"
 #include "test_utils.h"
 
 #include <algorithm>
diff --git a/test/i965_jpeg_test_data.cpp b/test/i965_jpeg_test_data.cpp
index 7f327a588d2f..84316a8355c9 100644
--- a/test/i965_jpeg_test_data.cpp
+++ b/test/i965_jpeg_test_data.cpp
@@ -23,6 +23,8 @@
  */
 
 #include "i965_jpeg_test_data.h"
+#include "i965_drv_video.h"
+#include "i965_streamable.h"
 
 namespace JPEG {
 namespace Decode {
@@ -764,3 +766,90 @@ namespace Decode {
 
 } // namespace Decode
 } // namespace JPEG
+
+namespace JPEG {
+namespace Encode {
+
+    TestInput::TestInput(
+        const unsigned fourcc, const unsigned w, const unsigned h)
+        : bytes() // caller must fill this in after instantiation
+        , picture(defaultPictureParameter)
+        , matrix(defaultIQMatrix)
+        , huffman(defaultHuffmanTable)
+        , slice(defaultSliceParameter)
+        , fourcc(fourcc)
+        , fourcc_output(fourcc)
+        , format(0)
+        , planes(0)
+        , widths{0,0,0}
+        , heights{0,0,0}
+        , 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];
+    }
+
+    const unsigned TestInput::width() const
+    {
+        return picture.picture_width;
+    }
+
+    const unsigned TestInput::height() const
+    {
+        return picture.picture_height;
+    }
+
+    const uint8_t* TestInput::plane(const size_t i) const
+    {
+        return bytes.data() + offsets[i];
+    }
+
+    ::std::ostream& operator<<(::std::ostream& os, const TestInput& t)
+    {
+        return os
+            << std::string((char*)(&t.fourcc), 4)
+            << " " << t.width() << "x" << t.height()
+            << " " << t.widths << " " << t.heights
+            << " " << t.sizes << " " << t.offsets
+        ;
+    }
+
+    ::std::ostream& operator<<(::std::ostream& os, const TestInput::Shared& t)
+    {
+        return os << *t;
+    }
+
+    ::std::ostream& operator<<(
+        ::std::ostream& os, const TestInput::SharedConst& t)
+    {
+        return os << *t;
+    }
+
+} // namespace Encode
+} // namespace JPEG
diff --git a/test/i965_jpeg_test_data.h b/test/i965_jpeg_test_data.h
index 64d5254cd959..5f4802e7dd93 100644
--- a/test/i965_jpeg_test_data.h
+++ b/test/i965_jpeg_test_data.h
@@ -25,8 +25,6 @@
 #ifndef I965_JPEG_TEST_DATA_H
 #define I965_JPEG_TEST_DATA_H
 
-#include "i965_test_fixture.h"
-
 #include <array>
 #include <iostream>
 #include <map>
@@ -399,98 +397,15 @@ namespace Encode {
         typedef std::shared_ptr<TestInput> Shared;
         typedef std::shared_ptr<const TestInput> SharedConst;
 
-        TestInput(const unsigned fourcc, const unsigned w, const unsigned h)
-            : bytes() // caller must fill this in after instantiation
-            , picture(defaultPictureParameter)
-            , matrix(defaultIQMatrix)
-            , huffman(defaultHuffmanTable)
-            , slice(defaultSliceParameter)
-            , fourcc(fourcc)
-            , fourcc_output(fourcc)
-            , format(0)
-            , planes(0)
-            , widths{0,0,0}
-            , heights{0,0,0}
-            , 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('I', '4', '2', '0'):
-                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] += offsets[i - 1];
-            }
-        }
-
-        const unsigned width() const
-        {
-            return picture.picture_width;
-        }
-
-        const unsigned height() const
-        {
-            return picture.picture_height;
-        }
+        TestInput(const unsigned, const unsigned, const unsigned);
 
-        const uint8_t* plane(const size_t i) const
-        {
-            return bytes.data() + offsets[i];
-        }
+        const unsigned width() const;
+        const unsigned height() const;
+        const uint8_t* plane(const size_t) const;
 
-        friend ::std::ostream& operator<<(::std::ostream& os, const TestInput& t)
-        {
-            return os
-                << std::string((char*)(&t.fourcc), 4)
-                << " " << t.width() << "x" << t.height()
-                << " " << t.widths << " " << t.heights
-                << " " << t.sizes << " " << t.offsets
-            ;
-        }
-
-        friend ::std::ostream& operator<<(::std::ostream& os, const Shared& t)
-        {
-            return os << *t;
-        }
+        friend ::std::ostream& operator<<(::std::ostream&, const TestInput&);
+        friend ::std::ostream& operator<<(::std::ostream&, const Shared&);
+        friend ::std::ostream& operator<<(::std::ostream&, const SharedConst&);
 
         ByteData            bytes;
         PictureParameter    picture;
@@ -506,8 +421,6 @@ namespace Encode {
         std::array<size_t, 3> offsets;
         std::array<size_t, 3> sizes;
     };
-
-
 } // namespace Encode
 } // namespace JPEG
 
diff --git a/test/i965_test_fixture.h b/test/i965_test_fixture.h
index c805b359e19f..dc6f6c40bd83 100644
--- a/test/i965_test_fixture.h
+++ b/test/i965_test_fixture.h
@@ -27,7 +27,6 @@
 
 #include "test.h"
 #include "i965_internal_decl.h"
-#include "i965_streamable.h"
 
 #include <string>
 #include <vector>
-- 
2.4.11



More information about the Libva mailing list