OSDN Git Service

Remove useless frame dimension check for VP9
[android-x86/hardware-intel-common-vaapi.git] / test / i965_jpeg_test_data.cpp
index 0cf3d23..fe531c0 100644 (file)
@@ -28,6 +28,7 @@
 #include "test_utils.h"
 
 #include <algorithm>
+#include <numeric>
 
 namespace JPEG {
 namespace Decode {
@@ -776,76 +777,67 @@ 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);
+
+        t->image = YUVImage::create(fourcc, w, h);
+
+        if (not bool(t->image.get()))
+            return Shared();
+
+        t->picture.picture_width = t->image->width;
+        t->picture.picture_height = t->image->height;
+
+        if (VA_FOURCC_Y800 == fourcc)
+            t->picture.num_components = 1;
+
+        return t;
     }
 
-    TestInput::TestInput(
-        const unsigned fourcc, const unsigned w, const unsigned h)
-        : bytes() // caller must fill this in after instantiation
+    TestInput::TestInput()
+        : image()
         , 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);
+        return;
+    }
+
+    const YUVImage::SharedConst TestInput::toExpectedOutput() const
+    {
+        YUVImage::Shared result;
 
-        switch(fourcc) {
+        switch (image->fourcc) {
+        case VA_FOURCC_Y800:
+            return image;
         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;
+            result = YUVImage::create(VA_FOURCC_IMC3, image->width, image->height);
+            break;
+        case VA_FOURCC_UYVY:
+        case VA_FOURCC_YUY2:
+            result = YUVImage::create(VA_FOURCC_422H, image->width, image->height);
             break;
         default:
-            return;
+            break;
         }
 
-        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;
-    }
+        if (bool(result)) {
+            result->y() = image->y();
+            result->u() = image->u();
+            result->v() = image->v();
+        }
 
-    const uint8_t* TestInput::plane(const size_t i) const
-    {
-        return bytes.data() + offsets[i];
+        return result;
     }
 
     ::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::string((char*)(&t.image->fourcc), 4)
+            << " " << t.image->width << "x" << t.image->height
+            << " " << t.image->widths << " " << t.image->heights
+            << " " << t.image->sizes << " " << t.image->offsets
         ;
     }
 
@@ -865,13 +857,11 @@ namespace Encode {
         const std::array<unsigned, 2> res = getResolution();
 
         TestInput::Shared input(TestInput::create(fourcc, res[0], res[1]));
-        ByteData& bytes = input->bytes;
-
-        RandomValueGenerator<uint8_t> rg(0x00, 0xff);
-        for (size_t i(0); i < input->planes; ++i)
+        if (input.get()) {
             std::generate_n(
-                std::back_inserter(bytes), input->sizes[i],
-                [&rg]{ return rg(); });
+                std::begin(input->image->bytes), input->image->bytes.size(),
+                RandomValueGenerator<uint8_t>(0x00, 0xff));
+        }
         return input;
     }