Chromium Code Reviews| Index: talk/session/media/planarfunctions_unittest.cc |
| diff --git a/talk/session/media/planarfunctions_unittest.cc b/talk/session/media/planarfunctions_unittest.cc |
| index e7a666e0b42dc53e246f86c1bef85be0962696d7..bfa38fc4762512abfbfb79f8c96c502e72d32c45 100644 |
| --- a/talk/session/media/planarfunctions_unittest.cc |
| +++ b/talk/session/media/planarfunctions_unittest.cc |
| @@ -76,21 +76,21 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| // Initialize the color band for testing. |
| void InitializeColorBand() { |
| - testing_color_y_.reset(new uint8[kTestingColorNum]); |
| - testing_color_u_.reset(new uint8[kTestingColorNum]); |
| - testing_color_v_.reset(new uint8[kTestingColorNum]); |
| - testing_color_r_.reset(new uint8[kTestingColorNum]); |
| - testing_color_g_.reset(new uint8[kTestingColorNum]); |
| - testing_color_b_.reset(new uint8[kTestingColorNum]); |
| + testing_color_y_.reset(new uint8_t[kTestingColorNum]); |
| + testing_color_u_.reset(new uint8_t[kTestingColorNum]); |
| + testing_color_v_.reset(new uint8_t[kTestingColorNum]); |
| + testing_color_r_.reset(new uint8_t[kTestingColorNum]); |
| + testing_color_g_.reset(new uint8_t[kTestingColorNum]); |
| + testing_color_b_.reset(new uint8_t[kTestingColorNum]); |
| int color_counter = 0; |
| for (int i = 0; i < kTestingColorChannelResolution; ++i) { |
| - uint8 color_r = static_cast<uint8>( |
| - i * 255 / (kTestingColorChannelResolution - 1)); |
| + uint8_t color_r = |
| + static_cast<uint8_t>(i * 255 / (kTestingColorChannelResolution - 1)); |
| for (int j = 0; j < kTestingColorChannelResolution; ++j) { |
| - uint8 color_g = static_cast<uint8>( |
| + uint8_t color_g = static_cast<uint8_t>( |
| j * 255 / (kTestingColorChannelResolution - 1)); |
| for (int k = 0; k < kTestingColorChannelResolution; ++k) { |
| - uint8 color_b = static_cast<uint8>( |
| + uint8_t color_b = static_cast<uint8_t>( |
| k * 255 / (kTestingColorChannelResolution - 1)); |
| testing_color_r_[color_counter] = color_r; |
| testing_color_g_[color_counter] = color_g; |
| @@ -107,16 +107,20 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| } |
| // Simple and slow RGB->YUV conversion. From NTSC standard, c/o Wikipedia. |
| // (from lmivideoframe_unittest.cc) |
| - void ConvertRgbPixel(uint8 r, uint8 g, uint8 b, |
| - uint8* y, uint8* u, uint8* v) { |
| + void ConvertRgbPixel(uint8_t r, |
| + uint8_t g, |
| + uint8_t b, |
| + uint8_t* y, |
| + uint8_t* u, |
| + uint8_t* v) { |
| *y = ClampUint8(.257 * r + .504 * g + .098 * b + 16); |
| *u = ClampUint8(-.148 * r - .291 * g + .439 * b + 128); |
| *v = ClampUint8(.439 * r - .368 * g - .071 * b + 128); |
| } |
| - uint8 ClampUint8(double value) { |
| + uint8_t ClampUint8(double value) { |
| value = std::max(0., std::min(255., value)); |
| - uint8 uint8_value = static_cast<uint8>(value); |
| + uint8_t uint8_value = static_cast<uint8_t>(value); |
| return uint8_value; |
| } |
| @@ -127,11 +131,13 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| // c2 c3 c4 c5 ... |
| // ............... |
| // The size of each chrome block is (block_size) x (block_size). |
| - uint8* CreateFakeYuvTestingImage(int height, int width, int block_size, |
| - libyuv::JpegSubsamplingType subsample_type, |
| - uint8* &y_pointer, |
| - uint8* &u_pointer, |
| - uint8* &v_pointer) { |
| + uint8_t* CreateFakeYuvTestingImage(int height, |
| + int width, |
| + int block_size, |
| + libyuv::JpegSubsamplingType subsample_type, |
| + uint8_t*& y_pointer, |
| + uint8_t*& u_pointer, |
| + uint8_t*& v_pointer) { |
| if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } |
| int y_size = height * width; |
| int u_size, v_size; |
| @@ -156,13 +162,13 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| return NULL; |
| break; |
| } |
| - uint8* image_pointer = new uint8[y_size + u_size + v_size + kAlignment]; |
| + uint8_t* image_pointer = new uint8_t[y_size + u_size + v_size + kAlignment]; |
| y_pointer = ALIGNP(image_pointer, kAlignment); |
| u_pointer = ALIGNP(&image_pointer[y_size], kAlignment); |
| v_pointer = ALIGNP(&image_pointer[y_size + u_size], kAlignment); |
| - uint8* current_y_pointer = y_pointer; |
| - uint8* current_u_pointer = u_pointer; |
| - uint8* current_v_pointer = v_pointer; |
| + uint8_t* current_y_pointer = y_pointer; |
| + uint8_t* current_u_pointer = u_pointer; |
| + uint8_t* current_v_pointer = v_pointer; |
| for (int j = 0; j < height; ++j) { |
| for (int i = 0; i < width; ++i) { |
| int color = ((i / block_size) + (j / block_size)) % kTestingColorNum; |
| @@ -184,9 +190,11 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| // c2 c3 c4 c5 ... |
| // ............... |
| // The size of each chrome block is (block_size) x (block_size). |
| - uint8* CreateFakeInterleaveYuvTestingImage( |
| - int height, int width, int block_size, |
| - uint8* &yuv_pointer, FourCC fourcc_type) { |
| + uint8_t* CreateFakeInterleaveYuvTestingImage(int height, |
| + int width, |
| + int block_size, |
| + uint8_t*& yuv_pointer, |
| + FourCC fourcc_type) { |
| if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } |
| if (fourcc_type != FOURCC_YUY2 && fourcc_type != FOURCC_UYVY) { |
| LOG(LS_ERROR) << "Format " << static_cast<int>(fourcc_type) |
| @@ -196,9 +204,9 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| // Regularize the width of the output to be even. |
| int awidth = (width + 1) & ~1; |
| - uint8* image_pointer = new uint8[2 * height * awidth + kAlignment]; |
| + uint8_t* image_pointer = new uint8_t[2 * height * awidth + kAlignment]; |
| yuv_pointer = ALIGNP(image_pointer, kAlignment); |
| - uint8* current_yuv_pointer = yuv_pointer; |
| + uint8_t* current_yuv_pointer = yuv_pointer; |
| switch (fourcc_type) { |
| case FOURCC_YUY2: { |
| for (int j = 0; j < height; ++j) { |
| @@ -209,13 +217,15 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| kTestingColorNum; |
| current_yuv_pointer[0] = testing_color_y_[color1]; |
| if (i < width) { |
| - current_yuv_pointer[1] = static_cast<uint8>( |
| - (static_cast<uint32>(testing_color_u_[color1]) + |
| - static_cast<uint32>(testing_color_u_[color2])) / 2); |
| + current_yuv_pointer[1] = static_cast<uint8_t>( |
| + (static_cast<uint32_t>(testing_color_u_[color1]) + |
| + static_cast<uint32_t>(testing_color_u_[color2])) / |
| + 2); |
| current_yuv_pointer[2] = testing_color_y_[color2]; |
| - current_yuv_pointer[3] = static_cast<uint8>( |
| - (static_cast<uint32>(testing_color_v_[color1]) + |
| - static_cast<uint32>(testing_color_v_[color2])) / 2); |
| + current_yuv_pointer[3] = static_cast<uint8_t>( |
| + (static_cast<uint32_t>(testing_color_v_[color1]) + |
| + static_cast<uint32_t>(testing_color_v_[color2])) / |
| + 2); |
| } else { |
| current_yuv_pointer[1] = testing_color_u_[color1]; |
| current_yuv_pointer[2] = 0; |
| @@ -233,13 +243,15 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| int color2 = (((i + 1) / block_size) + (j / block_size)) % |
| kTestingColorNum; |
| if (i < width) { |
| - current_yuv_pointer[0] = static_cast<uint8>( |
| - (static_cast<uint32>(testing_color_u_[color1]) + |
| - static_cast<uint32>(testing_color_u_[color2])) / 2); |
| + current_yuv_pointer[0] = static_cast<uint8_t>( |
| + (static_cast<uint32_t>(testing_color_u_[color1]) + |
| + static_cast<uint32_t>(testing_color_u_[color2])) / |
| + 2); |
| current_yuv_pointer[1] = testing_color_y_[color1]; |
| - current_yuv_pointer[2] = static_cast<uint8>( |
| - (static_cast<uint32>(testing_color_v_[color1]) + |
| - static_cast<uint32>(testing_color_v_[color2])) / 2); |
| + current_yuv_pointer[2] = static_cast<uint8_t>( |
| + (static_cast<uint32_t>(testing_color_v_[color1]) + |
| + static_cast<uint32_t>(testing_color_v_[color2])) / |
| + 2); |
| current_yuv_pointer[3] = testing_color_y_[color2]; |
| } else { |
| current_yuv_pointer[0] = testing_color_u_[color1]; |
| @@ -263,16 +275,20 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| // c2 c3 c4 c5 ... |
| // ............... |
| // The size of each chrome block is (block_size) x (block_size). |
| - uint8* CreateFakeNV12TestingImage(int height, int width, int block_size, |
| - uint8* &y_pointer, uint8* &uv_pointer) { |
| + uint8_t* CreateFakeNV12TestingImage(int height, |
| + int width, |
| + int block_size, |
| + uint8_t*& y_pointer, |
| + uint8_t*& uv_pointer) { |
| if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } |
| - uint8* image_pointer = new uint8[height * width + |
| - ((height + 1) / 2) * ((width + 1) / 2) * 2 + kAlignment]; |
| + uint8_t* image_pointer = |
| + new uint8_t[height * width + |
| + ((height + 1) / 2) * ((width + 1) / 2) * 2 + kAlignment]; |
| y_pointer = ALIGNP(image_pointer, kAlignment); |
| uv_pointer = y_pointer + height * width; |
| - uint8* current_uv_pointer = uv_pointer; |
| - uint8* current_y_pointer = y_pointer; |
| + uint8_t* current_uv_pointer = uv_pointer; |
| + uint8_t* current_y_pointer = y_pointer; |
| for (int j = 0; j < height; ++j) { |
| for (int i = 0; i < width; ++i) { |
| int color = ((i / block_size) + (j / block_size)) % |
| @@ -299,14 +315,17 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| // c2 c3 c4 c5 ... |
| // ............... |
| // The size of each chrome block is (block_size) x (block_size). |
| - uint8* CreateFakeM420TestingImage( |
| - int height, int width, int block_size, uint8* &m420_pointer) { |
| + uint8_t* CreateFakeM420TestingImage(int height, |
| + int width, |
| + int block_size, |
| + uint8_t*& m420_pointer) { |
| if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } |
| - uint8* image_pointer = new uint8[height * width + |
| - ((height + 1) / 2) * ((width + 1) / 2) * 2 + kAlignment]; |
| + uint8_t* image_pointer = |
| + new uint8_t[height * width + |
| + ((height + 1) / 2) * ((width + 1) / 2) * 2 + kAlignment]; |
| m420_pointer = ALIGNP(image_pointer, kAlignment); |
| - uint8* current_m420_pointer = m420_pointer; |
| + uint8_t* current_m420_pointer = m420_pointer; |
| for (int j = 0; j < height; ++j) { |
| for (int i = 0; i < width; ++i) { |
| int color = ((i / block_size) + (j / block_size)) % |
| @@ -332,22 +351,25 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| // c2 c3 c4 c5 ... |
| // ............... |
| // The size of each chrome block is (block_size) x (block_size). |
| - uint8* CreateFakeArgbTestingImage(int height, int width, int block_size, |
| - uint8* &argb_pointer, FourCC fourcc_type) { |
| + uint8_t* CreateFakeArgbTestingImage(int height, |
| + int width, |
| + int block_size, |
| + uint8_t*& argb_pointer, |
| + FourCC fourcc_type) { |
| if (height <= 0 || width <= 0 || block_size <= 0) { return NULL; } |
| - uint8* image_pointer = NULL; |
| + uint8_t* image_pointer = NULL; |
| if (fourcc_type == FOURCC_ABGR || fourcc_type == FOURCC_BGRA || |
| fourcc_type == FOURCC_ARGB) { |
| - image_pointer = new uint8[height * width * 4 + kAlignment]; |
| + image_pointer = new uint8_t[height * width * 4 + kAlignment]; |
| } else if (fourcc_type == FOURCC_RAW || fourcc_type == FOURCC_24BG) { |
| - image_pointer = new uint8[height * width * 3 + kAlignment]; |
| + image_pointer = new uint8_t[height * width * 3 + kAlignment]; |
| } else { |
| LOG(LS_ERROR) << "Format " << static_cast<int>(fourcc_type) |
| << " is not supported."; |
| return NULL; |
| } |
| argb_pointer = ALIGNP(image_pointer, kAlignment); |
| - uint8* current_pointer = argb_pointer; |
| + uint8_t* current_pointer = argb_pointer; |
| switch (fourcc_type) { |
| case FOURCC_ARGB: { |
| for (int j = 0; j < height; ++j) { |
| @@ -422,8 +444,10 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| // Check if two memory chunks are equal. |
| // (tolerate MSE errors within a threshold). |
| - static bool IsMemoryEqual(const uint8* ibuf, const uint8* obuf, |
| - int osize, double average_error) { |
| + static bool IsMemoryEqual(const uint8_t* ibuf, |
| + const uint8_t* obuf, |
| + int osize, |
| + double average_error) { |
| double sse = cricket::ComputeSumSquareError(ibuf, obuf, osize); |
| double error = sse / osize; // Mean Squared Error. |
| double PSNR = cricket::ComputePSNR(sse, osize); |
| @@ -433,7 +457,7 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| } |
| // Returns the index of the first differing byte. Easier to debug than memcmp. |
| - static int FindDiff(const uint8* buf1, const uint8* buf2, int len) { |
| + static int FindDiff(const uint8_t* buf1, const uint8_t* buf2, int len) { |
| int i = 0; |
| while (i < len && buf1[i] == buf2[i]) { |
| i++; |
| @@ -442,12 +466,12 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| } |
| // Dump the result image (ARGB format). |
| - void DumpArgbImage(const uint8* obuf, int width, int height) { |
| + void DumpArgbImage(const uint8_t* obuf, int width, int height) { |
| DumpPlanarArgbTestImage(GetTestName(), obuf, width, height); |
| } |
| // Dump the result image (YUV420 format). |
| - void DumpYuvImage(const uint8* obuf, int width, int height) { |
| + void DumpYuvImage(const uint8_t* obuf, int width, int height) { |
| DumpPlanarYuvTestImage(GetTestName(), obuf, width, height); |
| } |
| @@ -462,16 +486,16 @@ class PlanarFunctionsTest : public testing::TestWithParam<int> { |
| int repeat_; |
| // Y, U, V and R, G, B channels of testing colors. |
| - rtc::scoped_ptr<uint8[]> testing_color_y_; |
| - rtc::scoped_ptr<uint8[]> testing_color_u_; |
| - rtc::scoped_ptr<uint8[]> testing_color_v_; |
| - rtc::scoped_ptr<uint8[]> testing_color_r_; |
| - rtc::scoped_ptr<uint8[]> testing_color_g_; |
| - rtc::scoped_ptr<uint8[]> testing_color_b_; |
| + rtc::scoped_ptr<uint8_t[]> testing_color_y_; |
| + rtc::scoped_ptr<uint8_t[]> testing_color_u_; |
| + rtc::scoped_ptr<uint8_t[]> testing_color_v_; |
| + rtc::scoped_ptr<uint8_t[]> testing_color_r_; |
| + rtc::scoped_ptr<uint8_t[]> testing_color_g_; |
| + rtc::scoped_ptr<uint8_t[]> testing_color_b_; |
| }; |
| TEST_F(PlanarFunctionsTest, I420Copy) { |
| - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; |
| + uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; |
|
tlegrand-webrtc
2015/10/05 13:49:01
Can you rewrite this, so that each variable is dec
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| int y_pitch = kWidth; |
| int u_pitch = (kWidth + 1) >> 1; |
| int v_pitch = (kWidth + 1) >> 1; |
| @@ -479,16 +503,15 @@ TEST_F(PlanarFunctionsTest, I420Copy) { |
| int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
| int block_size = 3; |
| // Generate a fake input image. |
| - rtc::scoped_ptr<uint8[]> yuv_input( |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, |
| - libyuv::kJpegYuv420, |
| - y_pointer, u_pointer, v_pointer)); |
| + rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, |
| + v_pointer)); |
| // Allocate space for the output image. |
| - rtc::scoped_ptr<uint8[]> yuv_output( |
| - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment]); |
| - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); |
| - uint8 *u_output_pointer = y_output_pointer + y_size; |
| - uint8 *v_output_pointer = u_output_pointer + uv_size; |
| + rtc::scoped_ptr<uint8_t[]> yuv_output( |
| + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment]); |
| + uint8_t* y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); |
| + uint8_t* u_output_pointer = y_output_pointer + y_size; |
| + uint8_t* v_output_pointer = u_output_pointer + uv_size; |
| for (int i = 0; i < repeat_; ++i) { |
| libyuv::I420Copy(y_pointer, y_pitch, |
| @@ -508,7 +531,7 @@ TEST_F(PlanarFunctionsTest, I420Copy) { |
| } |
| TEST_F(PlanarFunctionsTest, I422ToI420) { |
| - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; |
| + uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; |
|
tlegrand-webrtc
2015/10/05 13:49:01
Same as above.
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| int y_pitch = kWidth; |
| int u_pitch = (kWidth + 1) >> 1; |
| int v_pitch = (kWidth + 1) >> 1; |
| @@ -516,23 +539,21 @@ TEST_F(PlanarFunctionsTest, I422ToI420) { |
| int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
| int block_size = 2; |
| // Generate a fake input image. |
| - rtc::scoped_ptr<uint8[]> yuv_input( |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, |
| - libyuv::kJpegYuv422, |
| - y_pointer, u_pointer, v_pointer)); |
| + rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv422, y_pointer, u_pointer, |
| + v_pointer)); |
| // Allocate space for the output image. |
| - rtc::scoped_ptr<uint8[]> yuv_output( |
| - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment]); |
| - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); |
| - uint8 *u_output_pointer = y_output_pointer + y_size; |
| - uint8 *v_output_pointer = u_output_pointer + uv_size; |
| + rtc::scoped_ptr<uint8_t[]> yuv_output( |
| + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment]); |
| + uint8_t* y_output_pointer = ALIGNP(yuv_output.get(), kAlignment); |
| + uint8_t* u_output_pointer = y_output_pointer + y_size; |
| + uint8_t* v_output_pointer = u_output_pointer + uv_size; |
| // Generate the expected output. |
| - uint8 *y_expected_pointer = NULL, *u_expected_pointer = NULL, |
| - *v_expected_pointer = NULL; |
| - rtc::scoped_ptr<uint8[]> yuv_output_expected( |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, |
| - libyuv::kJpegYuv420, |
| - y_expected_pointer, u_expected_pointer, v_expected_pointer)); |
| + uint8_t* y_expected_pointer = NULL, * u_expected_pointer = NULL, |
| + * v_expected_pointer = NULL; |
|
tlegrand-webrtc
2015/10/05 13:49:01
Again
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| + rtc::scoped_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, |
| + u_expected_pointer, v_expected_pointer)); |
| for (int i = 0; i < repeat_; ++i) { |
| libyuv::I422ToI420(y_pointer, y_pitch, |
| @@ -556,7 +577,7 @@ TEST_F(PlanarFunctionsTest, I422ToI420) { |
| TEST_P(PlanarFunctionsTest, M420ToI420) { |
| // Get the unalignment offset |
| int unalignment = GetParam(); |
| - uint8 *m420_pointer = NULL; |
| + uint8_t* m420_pointer = NULL; |
| int y_pitch = kWidth; |
| int m420_pitch = kWidth; |
| int u_pitch = (kWidth + 1) >> 1; |
| @@ -565,21 +586,21 @@ TEST_P(PlanarFunctionsTest, M420ToI420) { |
| int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
| int block_size = 2; |
| // Generate a fake input image. |
| - rtc::scoped_ptr<uint8[]> yuv_input( |
| + rtc::scoped_ptr<uint8_t[]> yuv_input( |
| CreateFakeM420TestingImage(kHeight, kWidth, block_size, m420_pointer)); |
| // Allocate space for the output image. |
| - rtc::scoped_ptr<uint8[]> yuv_output( |
| - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); |
| - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment) + unalignment; |
| - uint8 *u_output_pointer = y_output_pointer + y_size; |
| - uint8 *v_output_pointer = u_output_pointer + uv_size; |
| + rtc::scoped_ptr<uint8_t[]> yuv_output( |
| + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); |
| + uint8_t* y_output_pointer = |
| + ALIGNP(yuv_output.get(), kAlignment) + unalignment; |
| + uint8_t* u_output_pointer = y_output_pointer + y_size; |
| + uint8_t* v_output_pointer = u_output_pointer + uv_size; |
| // Generate the expected output. |
| - uint8 *y_expected_pointer = NULL, *u_expected_pointer = NULL, |
| - *v_expected_pointer = NULL; |
| - rtc::scoped_ptr<uint8[]> yuv_output_expected( |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, |
| - libyuv::kJpegYuv420, |
| - y_expected_pointer, u_expected_pointer, v_expected_pointer)); |
| + uint8_t* y_expected_pointer = NULL, * u_expected_pointer = NULL, |
| + * v_expected_pointer = NULL; |
|
tlegrand-webrtc
2015/10/05 13:49:01
...and here.
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| + rtc::scoped_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, |
| + u_expected_pointer, v_expected_pointer)); |
| for (int i = 0; i < repeat_; ++i) { |
| libyuv::M420ToI420(m420_pointer, m420_pitch, |
| @@ -600,7 +621,7 @@ TEST_P(PlanarFunctionsTest, M420ToI420) { |
| TEST_P(PlanarFunctionsTest, NV12ToI420) { |
| // Get the unalignment offset |
| int unalignment = GetParam(); |
| - uint8 *y_pointer = NULL, *uv_pointer = NULL; |
| + uint8_t* y_pointer = NULL, * uv_pointer = NULL; |
|
tlegrand-webrtc
2015/10/05 13:49:01
Here
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| int y_pitch = kWidth; |
| int uv_pitch = 2 * ((kWidth + 1) >> 1); |
| int u_pitch = (kWidth + 1) >> 1; |
| @@ -609,22 +630,21 @@ TEST_P(PlanarFunctionsTest, NV12ToI420) { |
| int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
| int block_size = 2; |
| // Generate a fake input image. |
| - rtc::scoped_ptr<uint8[]> yuv_input( |
| - CreateFakeNV12TestingImage(kHeight, kWidth, block_size, |
| - y_pointer, uv_pointer)); |
| + rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeNV12TestingImage( |
| + kHeight, kWidth, block_size, y_pointer, uv_pointer)); |
| // Allocate space for the output image. |
| - rtc::scoped_ptr<uint8[]> yuv_output( |
| - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); |
| - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment) + unalignment; |
| - uint8 *u_output_pointer = y_output_pointer + y_size; |
| - uint8 *v_output_pointer = u_output_pointer + uv_size; |
| + rtc::scoped_ptr<uint8_t[]> yuv_output( |
| + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); |
| + uint8_t* y_output_pointer = |
| + ALIGNP(yuv_output.get(), kAlignment) + unalignment; |
| + uint8_t* u_output_pointer = y_output_pointer + y_size; |
| + uint8_t* v_output_pointer = u_output_pointer + uv_size; |
| // Generate the expected output. |
| - uint8 *y_expected_pointer = NULL, *u_expected_pointer = NULL, |
| - *v_expected_pointer = NULL; |
| - rtc::scoped_ptr<uint8[]> yuv_output_expected( |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, |
| - libyuv::kJpegYuv420, |
| - y_expected_pointer, u_expected_pointer, v_expected_pointer)); |
| + uint8_t* y_expected_pointer = NULL, * u_expected_pointer = NULL, |
| + * v_expected_pointer = NULL; |
|
tlegrand-webrtc
2015/10/05 13:49:01
Here
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| + rtc::scoped_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, |
| + u_expected_pointer, v_expected_pointer)); |
| for (int i = 0; i < repeat_; ++i) { |
| libyuv::NV12ToI420(y_pointer, y_pitch, |
| @@ -644,50 +664,48 @@ TEST_P(PlanarFunctionsTest, NV12ToI420) { |
| } |
| // A common macro for testing converting YUY2/UYVY to I420. |
| -#define TEST_YUVTOI420(SRC_NAME, MSE, BLOCK_SIZE) \ |
| -TEST_P(PlanarFunctionsTest, SRC_NAME##ToI420) { \ |
| - /* Get the unalignment offset.*/ \ |
| - int unalignment = GetParam(); \ |
| - uint8 *yuv_pointer = NULL; \ |
| - int yuv_pitch = 2 * ((kWidth + 1) & ~1); \ |
| - int y_pitch = kWidth; \ |
| - int u_pitch = (kWidth + 1) >> 1; \ |
| - int v_pitch = (kWidth + 1) >> 1; \ |
| - int y_size = kHeight * kWidth; \ |
| - int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); \ |
| - int block_size = 2; \ |
| - /* Generate a fake input image.*/ \ |
| - rtc::scoped_ptr<uint8[]> yuv_input( \ |
| - CreateFakeInterleaveYuvTestingImage(kHeight, kWidth, BLOCK_SIZE, \ |
| - yuv_pointer, FOURCC_##SRC_NAME)); \ |
| - /* Allocate space for the output image.*/ \ |
| - rtc::scoped_ptr<uint8[]> yuv_output( \ |
| - new uint8[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); \ |
| - uint8 *y_output_pointer = ALIGNP(yuv_output.get(), kAlignment) + \ |
| - unalignment; \ |
| - uint8 *u_output_pointer = y_output_pointer + y_size; \ |
| - uint8 *v_output_pointer = u_output_pointer + uv_size; \ |
| - /* Generate the expected output.*/ \ |
| - uint8 *y_expected_pointer = NULL, *u_expected_pointer = NULL, \ |
| - *v_expected_pointer = NULL; \ |
| - rtc::scoped_ptr<uint8[]> yuv_output_expected( \ |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, \ |
| - libyuv::kJpegYuv420, \ |
| - y_expected_pointer, u_expected_pointer, v_expected_pointer)); \ |
| - for (int i = 0; i < repeat_; ++i) { \ |
| - libyuv::SRC_NAME##ToI420(yuv_pointer, yuv_pitch, \ |
| - y_output_pointer, y_pitch, \ |
| - u_output_pointer, u_pitch, \ |
| - v_output_pointer, v_pitch, \ |
| - kWidth, kHeight); \ |
| - } \ |
| - /* Compare the output frame with what is expected.*/ \ |
| - /* Note: MSE should be set to a larger threshold if an odd block width*/ \ |
| - /* is used, since the conversion will be lossy.*/ \ |
| - EXPECT_TRUE(IsMemoryEqual(y_output_pointer, y_expected_pointer, \ |
| - I420_SIZE(kHeight, kWidth), MSE)); \ |
| - if (dump_) { DumpYuvImage(y_output_pointer, kWidth, kHeight); } \ |
| -} \ |
| +#define TEST_YUVTOI420(SRC_NAME, MSE, BLOCK_SIZE) \ |
| + TEST_P(PlanarFunctionsTest, SRC_NAME##ToI420) { \ |
| + /* Get the unalignment offset.*/ \ |
| + int unalignment = GetParam(); \ |
| + uint8_t* yuv_pointer = NULL; \ |
| + int yuv_pitch = 2 * ((kWidth + 1) & ~1); \ |
| + int y_pitch = kWidth; \ |
| + int u_pitch = (kWidth + 1) >> 1; \ |
| + int v_pitch = (kWidth + 1) >> 1; \ |
| + int y_size = kHeight * kWidth; \ |
| + int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); \ |
| + int block_size = 2; \ |
| + /* Generate a fake input image.*/ \ |
| + rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeInterleaveYuvTestingImage( \ |
| + kHeight, kWidth, BLOCK_SIZE, yuv_pointer, FOURCC_##SRC_NAME)); \ |
| + /* Allocate space for the output image.*/ \ |
| + rtc::scoped_ptr<uint8_t[]> yuv_output( \ |
| + new uint8_t[I420_SIZE(kHeight, kWidth) + kAlignment + unalignment]); \ |
| + uint8_t* y_output_pointer = \ |
| + ALIGNP(yuv_output.get(), kAlignment) + unalignment; \ |
| + uint8_t* u_output_pointer = y_output_pointer + y_size; \ |
| + uint8_t* v_output_pointer = u_output_pointer + uv_size; \ |
| + /* Generate the expected output.*/ \ |
| + uint8_t* y_expected_pointer = NULL, * u_expected_pointer = NULL, \ |
| + * v_expected_pointer = NULL; \ |
|
tlegrand-webrtc
2015/10/05 13:49:01
Declare separately.
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| + rtc::scoped_ptr<uint8_t[]> yuv_output_expected(CreateFakeYuvTestingImage( \ |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_expected_pointer, \ |
| + u_expected_pointer, v_expected_pointer)); \ |
| + for (int i = 0; i < repeat_; ++i) { \ |
| + libyuv::SRC_NAME##ToI420(yuv_pointer, yuv_pitch, y_output_pointer, \ |
| + y_pitch, u_output_pointer, u_pitch, \ |
| + v_output_pointer, v_pitch, kWidth, kHeight); \ |
| + } \ |
| + /* Compare the output frame with what is expected.*/ \ |
| + /* Note: MSE should be set to a larger threshold if an odd block width*/ \ |
| + /* is used, since the conversion will be lossy.*/ \ |
| + EXPECT_TRUE(IsMemoryEqual(y_output_pointer, y_expected_pointer, \ |
| + I420_SIZE(kHeight, kWidth), MSE)); \ |
| + if (dump_) { \ |
| + DumpYuvImage(y_output_pointer, kWidth, kHeight); \ |
| + } \ |
| + } |
|
tlegrand-webrtc
2015/10/05 13:49:01
Clang format here was unfortunate, since it's diff
pbos-webrtc
2015/10/06 09:14:59
Acknowledged.
|
| // TEST_P(PlanarFunctionsTest, YUV2ToI420) |
| TEST_YUVTOI420(YUY2, 1.e-6, 2); |
| @@ -695,37 +713,36 @@ TEST_YUVTOI420(YUY2, 1.e-6, 2); |
| TEST_YUVTOI420(UYVY, 1.e-6, 2); |
| // A common macro for testing converting I420 to ARGB, BGRA and ABGR. |
| -#define TEST_YUVTORGB(SRC_NAME, DST_NAME, JPG_TYPE, MSE, BLOCK_SIZE) \ |
| -TEST_F(PlanarFunctionsTest, SRC_NAME##To##DST_NAME) { \ |
| - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; \ |
| - uint8 *argb_expected_pointer = NULL; \ |
| - int y_pitch = kWidth; \ |
| - int u_pitch = (kWidth + 1) >> 1; \ |
| - int v_pitch = (kWidth + 1) >> 1; \ |
| - /* Generate a fake input image.*/ \ |
| - rtc::scoped_ptr<uint8[]> yuv_input( \ |
| - CreateFakeYuvTestingImage(kHeight, kWidth, BLOCK_SIZE, JPG_TYPE, \ |
| - y_pointer, u_pointer, v_pointer)); \ |
| - /* Generate the expected output.*/ \ |
| - rtc::scoped_ptr<uint8[]> argb_expected( \ |
| - CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ |
| - argb_expected_pointer, FOURCC_##DST_NAME)); \ |
| - /* Allocate space for the output.*/ \ |
| - rtc::scoped_ptr<uint8[]> argb_output( \ |
| - new uint8[kHeight * kWidth * 4 + kAlignment]); \ |
| - uint8 *argb_pointer = ALIGNP(argb_expected.get(), kAlignment); \ |
| - for (int i = 0; i < repeat_; ++i) { \ |
| - libyuv::SRC_NAME##To##DST_NAME(y_pointer, y_pitch, \ |
| - u_pointer, u_pitch, \ |
| - v_pointer, v_pitch, \ |
| - argb_pointer, \ |
| - kWidth * 4, \ |
| - kWidth, kHeight); \ |
| - } \ |
| - EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ |
| - kHeight * kWidth * 4, MSE)); \ |
| - if (dump_) { DumpArgbImage(argb_pointer, kWidth, kHeight); } \ |
| -} |
| +#define TEST_YUVTORGB(SRC_NAME, DST_NAME, JPG_TYPE, MSE, BLOCK_SIZE) \ |
| + TEST_F(PlanarFunctionsTest, SRC_NAME##To##DST_NAME) { \ |
| + uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; \ |
|
tlegrand-webrtc
2015/10/05 13:49:01
And here
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| + uint8_t* argb_expected_pointer = NULL; \ |
| + int y_pitch = kWidth; \ |
| + int u_pitch = (kWidth + 1) >> 1; \ |
| + int v_pitch = (kWidth + 1) >> 1; \ |
| + /* Generate a fake input image.*/ \ |
| + rtc::scoped_ptr<uint8_t[]> yuv_input( \ |
| + CreateFakeYuvTestingImage(kHeight, kWidth, BLOCK_SIZE, JPG_TYPE, \ |
| + y_pointer, u_pointer, v_pointer)); \ |
| + /* Generate the expected output.*/ \ |
| + rtc::scoped_ptr<uint8_t[]> argb_expected( \ |
| + CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ |
| + argb_expected_pointer, FOURCC_##DST_NAME)); \ |
| + /* Allocate space for the output.*/ \ |
| + rtc::scoped_ptr<uint8_t[]> argb_output( \ |
| + new uint8_t[kHeight * kWidth * 4 + kAlignment]); \ |
| + uint8_t* argb_pointer = ALIGNP(argb_expected.get(), kAlignment); \ |
| + for (int i = 0; i < repeat_; ++i) { \ |
| + libyuv::SRC_NAME##To##DST_NAME(y_pointer, y_pitch, u_pointer, u_pitch, \ |
| + v_pointer, v_pitch, argb_pointer, \ |
| + kWidth * 4, kWidth, kHeight); \ |
| + } \ |
| + EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ |
| + kHeight* kWidth * 4, MSE)); \ |
| + if (dump_) { \ |
| + DumpArgbImage(argb_pointer, kWidth, kHeight); \ |
| + } \ |
| + } |
| // TEST_F(PlanarFunctionsTest, I420ToARGB) |
| TEST_YUVTORGB(I420, ARGB, libyuv::kJpegYuv420, 3., 2); |
| @@ -738,34 +755,33 @@ TEST_YUVTORGB(I422, ARGB, libyuv::kJpegYuv422, 3., 2); |
| // TEST_F(PlanarFunctionsTest, I444ToARGB) |
| TEST_YUVTORGB(I444, ARGB, libyuv::kJpegYuv444, 3., 3); |
| // Note: an empirical MSE tolerance 3.0 is used here for the probable |
| -// error from float-to-uint8 type conversion. |
| +// error from float-to-uint8_t type conversion. |
| TEST_F(PlanarFunctionsTest, I400ToARGB_Reference) { |
| - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; |
| + uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; |
|
tlegrand-webrtc
2015/10/05 13:49:01
Here
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| int y_pitch = kWidth; |
| int u_pitch = (kWidth + 1) >> 1; |
| int v_pitch = (kWidth + 1) >> 1; |
| int block_size = 3; |
| // Generate a fake input image. |
| - rtc::scoped_ptr<uint8[]> yuv_input( |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, |
| - libyuv::kJpegYuv420, |
| - y_pointer, u_pointer, v_pointer)); |
| + rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, |
| + v_pointer)); |
| // As the comparison standard, we convert a grayscale image (by setting both |
| // U and V channels to be 128) using an I420 converter. |
| int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
| - rtc::scoped_ptr<uint8[]> uv(new uint8[uv_size + kAlignment]); |
| + rtc::scoped_ptr<uint8_t[]> uv(new uint8_t[uv_size + kAlignment]); |
| u_pointer = v_pointer = ALIGNP(uv.get(), kAlignment); |
| memset(u_pointer, 128, uv_size); |
| // Allocate space for the output image and generate the expected output. |
| - rtc::scoped_ptr<uint8[]> argb_expected( |
| - new uint8[kHeight * kWidth * 4 + kAlignment]); |
| - rtc::scoped_ptr<uint8[]> argb_output( |
| - new uint8[kHeight * kWidth * 4 + kAlignment]); |
| - uint8 *argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); |
| - uint8 *argb_pointer = ALIGNP(argb_output.get(), kAlignment); |
| + rtc::scoped_ptr<uint8_t[]> argb_expected( |
| + new uint8_t[kHeight * kWidth * 4 + kAlignment]); |
| + rtc::scoped_ptr<uint8_t[]> argb_output( |
| + new uint8_t[kHeight * kWidth * 4 + kAlignment]); |
| + uint8_t* argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); |
| + uint8_t* argb_pointer = ALIGNP(argb_output.get(), kAlignment); |
| libyuv::I420ToARGB(y_pointer, y_pitch, |
| u_pointer, u_pitch, |
| @@ -787,35 +803,34 @@ TEST_F(PlanarFunctionsTest, I400ToARGB_Reference) { |
| TEST_P(PlanarFunctionsTest, I400ToARGB) { |
| // Get the unalignment offset |
| int unalignment = GetParam(); |
| - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; |
| + uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; |
|
tlegrand-webrtc
2015/10/05 13:49:01
Here
pbos-webrtc
2015/10/06 09:14:59
Done.
|
| int y_pitch = kWidth; |
| int u_pitch = (kWidth + 1) >> 1; |
| int v_pitch = (kWidth + 1) >> 1; |
| int block_size = 3; |
| // Generate a fake input image. |
| - rtc::scoped_ptr<uint8[]> yuv_input( |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, |
| - libyuv::kJpegYuv420, |
| - y_pointer, u_pointer, v_pointer)); |
| + rtc::scoped_ptr<uint8_t[]> yuv_input(CreateFakeYuvTestingImage( |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, |
| + v_pointer)); |
| // As the comparison standard, we convert a grayscale image (by setting both |
| // U and V channels to be 128) using an I420 converter. |
| int uv_size = ((kHeight + 1) >> 1) * ((kWidth + 1) >> 1); |
| // 1 byte extra if in the unaligned mode. |
| - rtc::scoped_ptr<uint8[]> uv(new uint8[uv_size * 2 + kAlignment]); |
| + rtc::scoped_ptr<uint8_t[]> uv(new uint8_t[uv_size * 2 + kAlignment]); |
| u_pointer = ALIGNP(uv.get(), kAlignment); |
| v_pointer = u_pointer + uv_size; |
| memset(u_pointer, 128, uv_size); |
| memset(v_pointer, 128, uv_size); |
| // Allocate space for the output image and generate the expected output. |
| - rtc::scoped_ptr<uint8[]> argb_expected( |
| - new uint8[kHeight * kWidth * 4 + kAlignment]); |
| + rtc::scoped_ptr<uint8_t[]> argb_expected( |
| + new uint8_t[kHeight * kWidth * 4 + kAlignment]); |
| // 1 byte extra if in the misalinged mode. |
| - rtc::scoped_ptr<uint8[]> argb_output( |
| - new uint8[kHeight * kWidth * 4 + kAlignment + unalignment]); |
| - uint8 *argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); |
| - uint8 *argb_pointer = ALIGNP(argb_output.get(), kAlignment) + unalignment; |
| + rtc::scoped_ptr<uint8_t[]> argb_output( |
| + new uint8_t[kHeight * kWidth * 4 + kAlignment + unalignment]); |
| + uint8_t* argb_expected_pointer = ALIGNP(argb_expected.get(), kAlignment); |
| + uint8_t* argb_pointer = ALIGNP(argb_output.get(), kAlignment) + unalignment; |
| libyuv::I420ToARGB(y_pointer, y_pitch, |
| u_pointer, u_pitch, |
| @@ -839,22 +854,20 @@ TEST_P(PlanarFunctionsTest, ARGBToI400) { |
| // Get the unalignment offset |
| int unalignment = GetParam(); |
| // Create a fake ARGB input image. |
| - uint8 *y_pointer = NULL, *u_pointer = NULL, *v_pointer = NULL; |
| - uint8 *argb_pointer = NULL; |
| + uint8_t* y_pointer = NULL, * u_pointer = NULL, * v_pointer = NULL; |
| + uint8_t* argb_pointer = NULL; |
| int block_size = 3; |
| // Generate a fake input image. |
| - rtc::scoped_ptr<uint8[]> argb_input( |
| - CreateFakeArgbTestingImage(kHeight, kWidth, block_size, |
| - argb_pointer, FOURCC_ARGB)); |
| + rtc::scoped_ptr<uint8_t[]> argb_input(CreateFakeArgbTestingImage( |
| + kHeight, kWidth, block_size, argb_pointer, FOURCC_ARGB)); |
| // Generate the expected output. Only Y channel is used |
| - rtc::scoped_ptr<uint8[]> yuv_expected( |
| - CreateFakeYuvTestingImage(kHeight, kWidth, block_size, |
| - libyuv::kJpegYuv420, |
| - y_pointer, u_pointer, v_pointer)); |
| + rtc::scoped_ptr<uint8_t[]> yuv_expected(CreateFakeYuvTestingImage( |
| + kHeight, kWidth, block_size, libyuv::kJpegYuv420, y_pointer, u_pointer, |
| + v_pointer)); |
| // Allocate space for the Y output. |
| - rtc::scoped_ptr<uint8[]> y_output( |
| - new uint8[kHeight * kWidth + kAlignment + unalignment]); |
| - uint8 *y_output_pointer = ALIGNP(y_output.get(), kAlignment) + unalignment; |
| + rtc::scoped_ptr<uint8_t[]> y_output( |
| + new uint8_t[kHeight * kWidth + kAlignment + unalignment]); |
| + uint8_t* y_output_pointer = ALIGNP(y_output.get(), kAlignment) + unalignment; |
| for (int i = 0; i < repeat_; ++i) { |
| libyuv::ARGBToI400(argb_pointer, kWidth * 4, y_output_pointer, kWidth, |
| @@ -862,7 +875,7 @@ TEST_P(PlanarFunctionsTest, ARGBToI400) { |
| } |
| // Check if the output matches the input Y channel. |
| // Note: an empirical MSE tolerance 2.0 is used here for the probable |
| - // error from float-to-uint8 type conversion. |
| + // error from float-to-uint8_t type conversion. |
| EXPECT_TRUE(IsMemoryEqual(y_output_pointer, y_pointer, |
| kHeight * kWidth, 2.)); |
| if (dump_) { DumpArgbImage(argb_pointer, kWidth, kHeight); } |
| @@ -870,31 +883,32 @@ TEST_P(PlanarFunctionsTest, ARGBToI400) { |
| // A common macro for testing converting RAW, BG24, BGRA, and ABGR |
| // to ARGB. |
| -#define TEST_ARGB(SRC_NAME, FC_ID, BPP, BLOCK_SIZE) \ |
| -TEST_P(PlanarFunctionsTest, SRC_NAME##ToARGB) { \ |
| - int unalignment = GetParam(); /* Get the unalignment offset.*/ \ |
| - uint8 *argb_expected_pointer = NULL, *src_pointer = NULL; \ |
| - /* Generate a fake input image.*/ \ |
| - rtc::scoped_ptr<uint8[]> src_input( \ |
| - CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ |
| - src_pointer, FOURCC_##FC_ID)); \ |
| - /* Generate the expected output.*/ \ |
| - rtc::scoped_ptr<uint8[]> argb_expected( \ |
| - CreateFakeArgbTestingImage(kHeight, kWidth, BLOCK_SIZE, \ |
| - argb_expected_pointer, FOURCC_ARGB)); \ |
| - /* Allocate space for the output; 1 byte extra if in the unaligned mode.*/ \ |
| - rtc::scoped_ptr<uint8[]> argb_output( \ |
| - new uint8[kHeight * kWidth * 4 + kAlignment + unalignment]); \ |
| - uint8 *argb_pointer = ALIGNP(argb_output.get(), kAlignment) + unalignment; \ |
| - for (int i = 0; i < repeat_; ++i) { \ |
| - libyuv:: SRC_NAME##ToARGB(src_pointer, kWidth * (BPP), argb_pointer, \ |
| - kWidth * 4, kWidth, kHeight); \ |
| - } \ |
| - /* Compare the result; expect identical.*/ \ |
| - EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ |
| - kHeight * kWidth * 4, 1.e-6)); \ |
| - if (dump_) { DumpArgbImage(argb_pointer, kWidth, kHeight); } \ |
| -} |
| +#define TEST_ARGB(SRC_NAME, FC_ID, BPP, BLOCK_SIZE) \ |
| + TEST_P(PlanarFunctionsTest, SRC_NAME##ToARGB) { \ |
| + int unalignment = GetParam(); /* Get the unalignment offset.*/ \ |
| + uint8_t* argb_expected_pointer = NULL, * src_pointer = NULL; \ |
| + /* Generate a fake input image.*/ \ |
| + rtc::scoped_ptr<uint8_t[]> src_input(CreateFakeArgbTestingImage( \ |
| + kHeight, kWidth, BLOCK_SIZE, src_pointer, FOURCC_##FC_ID)); \ |
| + /* Generate the expected output.*/ \ |
| + rtc::scoped_ptr<uint8_t[]> argb_expected(CreateFakeArgbTestingImage( \ |
| + kHeight, kWidth, BLOCK_SIZE, argb_expected_pointer, FOURCC_ARGB)); \ |
| + /* Allocate space for the output; 1 byte extra if in the unaligned mode.*/ \ |
| + rtc::scoped_ptr<uint8_t[]> argb_output( \ |
| + new uint8_t[kHeight * kWidth * 4 + kAlignment + unalignment]); \ |
| + uint8_t* argb_pointer = \ |
| + ALIGNP(argb_output.get(), kAlignment) + unalignment; \ |
| + for (int i = 0; i < repeat_; ++i) { \ |
| + libyuv::SRC_NAME##ToARGB(src_pointer, kWidth*(BPP), argb_pointer, \ |
| + kWidth * 4, kWidth, kHeight); \ |
| + } \ |
| + /* Compare the result; expect identical.*/ \ |
| + EXPECT_TRUE(IsMemoryEqual(argb_expected_pointer, argb_pointer, \ |
| + kHeight* kWidth * 4, 1.e-6)); \ |
| + if (dump_) { \ |
| + DumpArgbImage(argb_pointer, kWidth, kHeight); \ |
| + } \ |
| + } |
| TEST_ARGB(RAW, RAW, 3, 3); // TEST_P(PlanarFunctionsTest, RAWToARGB) |
| TEST_ARGB(BG24, 24BG, 3, 3); // TEST_P(PlanarFunctionsTest, BG24ToARGB) |