summaryrefslogtreecommitdiff
path: root/test/i965_jpeg_test_data.cpp
diff options
context:
space:
mode:
authorU. Artie Eoff <ullysses.a.eoff@intel.com>2016-09-28 13:36:04 -0700
committerSean V Kelley <seanvk@posteo.de>2016-10-03 11:30:39 -0700
commit034440cd4cee59f76ad211cb80108c1566561d10 (patch)
tree865bb6f5ccaec3d0d3c7bf4ad4062e401d2e0403 /test/i965_jpeg_test_data.cpp
parent393019134cfe9bde212b87f04362be4ad649e42c (diff)
downloadlibva-intel-driver-034440cd4cee59f76ad211cb80108c1566561d10.tar.gz
test: jpeg/enc: move TestInput impl to compilation unit
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@intel.com> Reviewed-by: Sean V Kelley <seanvk@posteo.de>
Diffstat (limited to 'test/i965_jpeg_test_data.cpp')
-rw-r--r--test/i965_jpeg_test_data.cpp89
1 files changed, 89 insertions, 0 deletions
diff --git a/test/i965_jpeg_test_data.cpp b/test/i965_jpeg_test_data.cpp
index 7f327a58..84316a83 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