| Index: webrtc/common_video/libyuv/libyuv_unittest.cc
|
| diff --git a/webrtc/common_video/libyuv/libyuv_unittest.cc b/webrtc/common_video/libyuv/libyuv_unittest.cc
|
| index 1ed72df584feacd895c16a10432e1c692515b406..87cd03714c22d5836e418956e80c43f702fb87fd 100644
|
| --- a/webrtc/common_video/libyuv/libyuv_unittest.cc
|
| +++ b/webrtc/common_video/libyuv/libyuv_unittest.cc
|
| @@ -15,6 +15,7 @@
|
|
|
| #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
| #include "webrtc/test/frame_utils.h"
|
| +#include "webrtc/test/gmock.h"
|
| #include "webrtc/test/gtest.h"
|
| #include "webrtc/test/testsupport/fileutils.h"
|
| #include "webrtc/video_frame.h"
|
| @@ -253,4 +254,54 @@ TEST_F(TestLibYuv, RotateTest) {
|
| rotated_res_i420_buffer.get()));
|
| }
|
|
|
| +static uint8_t Average(int a, int b, int c, int d) {
|
| + return (a + b + c + d + 2) / 4;
|
| +}
|
| +
|
| +TEST_F(TestLibYuv, NV12Scale2x2to2x2) {
|
| + const std::vector<uint8_t> src_y = {0, 1,
|
| + 2, 3};
|
| + const std::vector<uint8_t> src_uv = {0, 1};
|
| + std::vector<uint8_t> dst_y(4);
|
| + std::vector<uint8_t> dst_uv(2);
|
| +
|
| + std::vector<uint8_t> tmp_buffer;
|
| + NV12Scale(&tmp_buffer,
|
| + src_y.data(), 2,
|
| + src_uv.data(), 2,
|
| + 2, 2,
|
| + dst_y.data(), 2,
|
| + dst_uv.data(), 2,
|
| + 2, 2);
|
| +
|
| + EXPECT_THAT(dst_y, ::testing::ContainerEq(src_y));
|
| + EXPECT_THAT(dst_uv, ::testing::ContainerEq(src_uv));
|
| +}
|
| +
|
| +TEST_F(TestLibYuv, NV12Scale4x4to2x2) {
|
| + const uint8_t src_y[] = { 0, 1, 2, 3,
|
| + 4, 5, 6, 7,
|
| + 8, 9, 10, 11,
|
| + 12, 13, 14, 15};
|
| + const uint8_t src_uv[] = {0, 1, 2, 3,
|
| + 4, 5, 6, 7};
|
| + std::vector<uint8_t> dst_y(4);
|
| + std::vector<uint8_t> dst_uv(2);
|
| +
|
| + std::vector<uint8_t> tmp_buffer;
|
| + NV12Scale(&tmp_buffer,
|
| + src_y, 4,
|
| + src_uv, 4,
|
| + 4, 4,
|
| + dst_y.data(), 2,
|
| + dst_uv.data(), 2,
|
| + 2, 2);
|
| +
|
| + EXPECT_THAT(dst_y, ::testing::ElementsAre(
|
| + Average(0, 1, 4, 5), Average(2, 3, 6, 7),
|
| + Average(8, 9, 12, 13), Average(10, 11, 14, 15)));
|
| + EXPECT_THAT(dst_uv,
|
| + ::testing::ElementsAre(Average(0, 2, 4, 6), Average(1, 3, 5, 7)));
|
| +}
|
| +
|
| } // namespace webrtc
|
|
|