From 9c9d92ae3a7c70adff71e04bae14a1e1394693f5 Mon Sep 17 00:00:00 2001 From: clang-format Date: Thu, 4 Aug 2016 19:28:34 -0700 Subject: [PATCH] test: apply clang-tidy google-readability-braces-around-statements applied against a x86_64 configure with and without --enable-vp9-highbitdepth clang-tidy-3.7.1 \ -checks='-*,google-readability-braces-around-statements' \ -header-filter='.*' -fix + clang-format afterward Change-Id: Ia2993ec64cf1eb3505d3bfb39068d9e44cfbce8d --- test/active_map_refresh_test.cc | 3 ++- test/avg_test.cc | 6 +++-- test/blockiness_test.cc | 5 ++-- test/convolve_test.cc | 39 ++++++++++++++++++++------------ test/datarate_test.cc | 8 ++++--- test/dct16x16_test.cc | 15 ++++++++---- test/dct32x32_test.cc | 9 +++++--- test/decode_perf_test.cc | 6 +++-- test/decode_test_driver.cc | 3 ++- test/encode_perf_test.cc | 7 +++--- test/encode_test_driver.cc | 29 +++++++++++++++--------- test/error_resilience_test.cc | 16 ++++++++----- test/fdct4x4_test.cc | 3 ++- test/fdct8x8_test.cc | 28 +++++++++++++++-------- test/idct8x8_test.cc | 6 +++-- test/idct_test.cc | 15 ++++++++---- test/keyframe_test.cc | 6 +++-- test/partial_idct_test.cc | 3 ++- test/sad_test.cc | 3 ++- test/sixtap_predict_test.cc | 6 +++-- test/test_libvpx.cc | 6 +++-- test/util.h | 3 ++- test/video_source.h | 5 ++-- test/vp8_fdct4x4_test.cc | 25 ++++++++++++-------- test/vp9_arf_freq_test.cc | 10 ++++---- test/vp9_encoder_parms_get_to_decoder.cc | 3 ++- test/vp9_end_to_end_test.cc | 5 ++-- test/yuv_video_source.h | 3 ++- 28 files changed, 177 insertions(+), 99 deletions(-) diff --git a/test/active_map_refresh_test.cc b/test/active_map_refresh_test.cc index 6ebab91..d893635 100644 --- a/test/active_map_refresh_test.cc +++ b/test/active_map_refresh_test.cc @@ -37,8 +37,9 @@ int CheckMb(const vpx_image_t ¤t, const vpx_image_t &previous, int mb_r, for (; r < r_top; ++r) { for (int c = c0; c < c_top; ++c) { if (current.planes[plane][current.stride[plane] * r + c] != - previous.planes[plane][previous.stride[plane] * r + c]) + previous.planes[plane][previous.stride[plane] * r + c]) { return 1; + } } } } diff --git a/test/avg_test.cc b/test/avg_test.cc index 4a5d325..867a77a 100644 --- a/test/avg_test.cc +++ b/test/avg_test.cc @@ -55,15 +55,17 @@ class AverageTestBase : public ::testing::Test { // Sum Pixels unsigned int ReferenceAverage8x8(const uint8_t *source, int pitch) { unsigned int average = 0; - for (int h = 0; h < 8; ++h) + for (int h = 0; h < 8; ++h) { for (int w = 0; w < 8; ++w) average += source[h * pitch + w]; + } return ((average + 32) >> 6); } unsigned int ReferenceAverage4x4(const uint8_t *source, int pitch) { unsigned int average = 0; - for (int h = 0; h < 4; ++h) + for (int h = 0; h < 4; ++h) { for (int w = 0; w < 4; ++w) average += source[h * pitch + w]; + } return ((average + 8) >> 4); } diff --git a/test/blockiness_test.cc b/test/blockiness_test.cc index d20b9a6..2fa1019 100644 --- a/test/blockiness_test.cc +++ b/test/blockiness_test.cc @@ -100,10 +100,11 @@ class BlockinessTestBase : public ::testing::Test { void FillCheckerboard(uint8_t *data, int stride) { for (int h = 0; h < height_; h += 4) { for (int w = 0; w < width_; w += 4) { - if (((h / 4) ^ (w / 4)) & 1) + if (((h / 4) ^ (w / 4)) & 1) { FillConstant(data + h * stride + w, stride, 255, 4, 4); - else + } else { FillConstant(data + h * stride + w, stride, 0, 4, 4); + } } } } diff --git a/test/convolve_test.cc b/test/convolve_test.cc index 2befe61..432d1b0 100644 --- a/test/convolve_test.cc +++ b/test/convolve_test.cc @@ -346,17 +346,19 @@ class ConvolveTest : public ::testing::TestWithParam { virtual void SetUp() { UUT_ = GET_PARAM(2); #if CONFIG_VP9_HIGHBITDEPTH - if (UUT_->use_highbd_ != 0) + if (UUT_->use_highbd_ != 0) { mask_ = (1 << UUT_->use_highbd_) - 1; - else + } else { mask_ = 255; + } #endif /* Set up guard blocks for an inner block centered in the outer block */ for (int i = 0; i < kOutputBufferSize; ++i) { - if (IsIndexInBorder(i)) + if (IsIndexInBorder(i)) { output_[i] = 255; - else + } else { output_[i] = 0; + } } ::libvpx_test::ACMRandom prng; @@ -535,11 +537,12 @@ TEST_P(ConvolveTest, Copy) { CheckGuardBlocks(); - for (int y = 0; y < Height(); ++y) + for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) ASSERT_EQ(lookup(out, y * kOutputStride + x), lookup(in, y * kInputStride + x)) << "(" << x << "," << y << ")"; + } } TEST_P(ConvolveTest, Avg) { @@ -553,13 +556,14 @@ TEST_P(ConvolveTest, Avg) { CheckGuardBlocks(); - for (int y = 0; y < Height(); ++y) + for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) ASSERT_EQ(lookup(out, y * kOutputStride + x), ROUND_POWER_OF_TWO(lookup(in, y * kInputStride + x) + lookup(out_ref, y * kOutputStride + x), 1)) << "(" << x << "," << y << ")"; + } } TEST_P(ConvolveTest, CopyHoriz) { @@ -574,11 +578,12 @@ TEST_P(ConvolveTest, CopyHoriz) { CheckGuardBlocks(); - for (int y = 0; y < Height(); ++y) + for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) ASSERT_EQ(lookup(out, y * kOutputStride + x), lookup(in, y * kInputStride + x)) << "(" << x << "," << y << ")"; + } } TEST_P(ConvolveTest, CopyVert) { @@ -593,11 +598,12 @@ TEST_P(ConvolveTest, CopyVert) { CheckGuardBlocks(); - for (int y = 0; y < Height(); ++y) + for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) ASSERT_EQ(lookup(out, y * kOutputStride + x), lookup(in, y * kInputStride + x)) << "(" << x << "," << y << ")"; + } } TEST_P(ConvolveTest, Copy2D) { @@ -612,11 +618,12 @@ TEST_P(ConvolveTest, Copy2D) { CheckGuardBlocks(); - for (int y = 0; y < Height(); ++y) + for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) ASSERT_EQ(lookup(out, y * kOutputStride + x), lookup(in, y * kInputStride + x)) << "(" << x << "," << y << ")"; + } } const int kNumFilterBanks = 4; @@ -690,13 +697,14 @@ TEST_P(ConvolveTest, MatchesReferenceSubpixelFilter) { CheckGuardBlocks(); - for (int y = 0; y < Height(); ++y) + for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) ASSERT_EQ(lookup(ref, y * kOutputStride + x), lookup(out, y * kOutputStride + x)) << "mismatch at (" << x << "," << y << "), " << "filters (" << filter_bank << "," << filter_x << "," << filter_y << ")"; + } } } } @@ -767,13 +775,14 @@ TEST_P(ConvolveTest, MatchesReferenceAveragingSubpixelFilter) { CheckGuardBlocks(); - for (int y = 0; y < Height(); ++y) + for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) ASSERT_EQ(lookup(ref, y * kOutputStride + x), lookup(out, y * kOutputStride + x)) << "mismatch at (" << x << "," << y << "), " << "filters (" << filter_bank << "," << filter_x << "," << filter_y << ")"; + } } } } @@ -828,10 +837,11 @@ TEST_P(ConvolveTest, FilterExtremes) { #endif if (axis) seed_val++; } - if (axis) + if (axis) { seed_val -= 8; - else + } else { seed_val++; + } } if (axis) seed_val += 8; @@ -860,13 +870,14 @@ TEST_P(ConvolveTest, FilterExtremes) { in, kInputStride, out, kOutputStride, kInvalidFilter, 0, kInvalidFilter, 0, Width(), Height())); - for (int y = 0; y < Height(); ++y) + for (int y = 0; y < Height(); ++y) { for (int x = 0; x < Width(); ++x) ASSERT_EQ(lookup(ref, y * kOutputStride + x), lookup(out, y * kOutputStride + x)) << "mismatch at (" << x << "," << y << "), " << "filters (" << filter_bank << "," << filter_x << "," << filter_y << ")"; + } } } } diff --git a/test/datarate_test.cc b/test/datarate_test.cc index 9b49544..b424b75 100644 --- a/test/datarate_test.cc +++ b/test/datarate_test.cc @@ -46,8 +46,9 @@ class DatarateTestLarge virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, ::libvpx_test::Encoder *encoder) { - if (video->frame() == 0) + if (video->frame() == 0) { encoder->Control(VP8E_SET_NOISE_SENSITIVITY, denoiser_on_); + } if (denoiser_offon_test_) { ASSERT_GT(denoiser_offon_period_, 0) @@ -476,10 +477,11 @@ TEST_P(DatarateTestVP9Large, BasicRateTargetingVBRLagNonZero) { cfg_.rc_end_usage = VPX_VBR; // For non-zero lag, rate control will work (be within bounds) for // real-time mode. - if (deadline_ == VPX_DL_REALTIME) + if (deadline_ == VPX_DL_REALTIME) { cfg_.g_lag_in_frames = 15; - else + } else { cfg_.g_lag_in_frames = 0; + } ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, 30, 1, 0, 300); diff --git a/test/dct16x16_test.cc b/test/dct16x16_test.cc index 2990e54..f9745ed 100644 --- a/test/dct16x16_test.cc +++ b/test/dct16x16_test.cc @@ -386,8 +386,9 @@ class Trans16x16TestBase { for (int i = 0; i < count_test_block; ++i) { // Initialize a test block with input range [-mask_, mask_]. - for (int j = 0; j < kNumCoeffs; ++j) + for (int j = 0; j < kNumCoeffs; ++j) { input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); + } fwd_txfm_ref(input_block, output_ref_block, pitch_, tx_type_); ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, pitch_)); @@ -447,10 +448,12 @@ class Trans16x16TestBase { for (int j = 0; j < kNumCoeffs; ++j) { input_extreme_block[j] = rnd.Rand8() % 2 ? mask_ : -mask_; } - if (i == 0) + if (i == 0) { for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = mask_; - if (i == 1) + } + if (i == 1) { for (int j = 0; j < kNumCoeffs; ++j) input_extreme_block[j] = -mask_; + } fwd_txfm_ref(input_extreme_block, output_ref_block, pitch_, tx_type_); @@ -464,8 +467,9 @@ class Trans16x16TestBase { // quantization with maximum allowed step sizes output_ref_block[0] = (output_ref_block[0] / dc_thred) * dc_thred; - for (int j = 1; j < kNumCoeffs; ++j) + for (int j = 1; j < kNumCoeffs; ++j) { output_ref_block[j] = (output_ref_block[j] / ac_thred) * ac_thred; + } if (bit_depth_ == VPX_BITS_8) { inv_txfm_ref(output_ref_block, ref, pitch_, tx_type_); ASM_REGISTER_STATE_CHECK(RunInvTxfm(output_ref_block, dst, pitch_)); @@ -518,8 +522,9 @@ class Trans16x16TestBase { } reference_16x16_dct_2d(in, out_r); - for (int j = 0; j < kNumCoeffs; ++j) + for (int j = 0; j < kNumCoeffs; ++j) { coeff[j] = static_cast(round(out_r[j])); + } if (bit_depth_ == VPX_BITS_8) { ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst, 16)); diff --git a/test/dct32x32_test.cc b/test/dct32x32_test.cc index 667e9f2..a168e69 100644 --- a/test/dct32x32_test.cc +++ b/test/dct32x32_test.cc @@ -37,8 +37,9 @@ void reference_32x32_dct_1d(const double in[32], double out[32]) { const double kInvSqrt2 = 0.707106781186547524400844362104; for (int k = 0; k < 32; k++) { out[k] = 0.0; - for (int n = 0; n < 32; n++) + for (int n = 0; n < 32; n++) { out[k] += in[n] * cos(kPi * (2 * n + 1) * k / 64.0); + } if (k == 0) out[k] = out[k] * kInvSqrt2; } } @@ -174,8 +175,9 @@ TEST_P(Trans32x32Test, CoeffCheck) { DECLARE_ALIGNED(16, tran_low_t, output_block[kNumCoeffs]); for (int i = 0; i < count_test_block; ++i) { - for (int j = 0; j < kNumCoeffs; ++j) + for (int j = 0; j < kNumCoeffs; ++j) { input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); + } const int stride = 32; vpx_fdct32x32_c(input_block, output_ref_block, stride); @@ -266,8 +268,9 @@ TEST_P(Trans32x32Test, InverseAccuracy) { } reference_32x32_dct_2d(in, out_r); - for (int j = 0; j < kNumCoeffs; ++j) + for (int j = 0; j < kNumCoeffs; ++j) { coeff[j] = static_cast(round(out_r[j])); + } if (bit_depth_ == VPX_BITS_8) { ASM_REGISTER_STATE_CHECK(inv_txfm_(coeff, dst, 32)); #if CONFIG_VP9_HIGHBITDEPTH diff --git a/test/decode_perf_test.cc b/test/decode_perf_test.cc index 33a2c13..53594ae 100644 --- a/test/decode_perf_test.cc +++ b/test/decode_perf_test.cc @@ -154,8 +154,9 @@ class VP9NewEncodeDecodePerfTest virtual void EndPassHook() { if (outfile_ != NULL) { - if (!fseek(outfile_, 0, SEEK_SET)) + if (!fseek(outfile_, 0, SEEK_SET)) { ivf_write_file_header(outfile_, &cfg_, VP9_FOURCC, out_frames_); + } fclose(outfile_); outfile_ = NULL; } @@ -165,8 +166,9 @@ class VP9NewEncodeDecodePerfTest ++out_frames_; // Write initial file header if first frame. - if (pkt->data.frame.pts == 0) + if (pkt->data.frame.pts == 0) { ivf_write_file_header(outfile_, &cfg_, VP9_FOURCC, out_frames_); + } // Write frame header and data. ivf_write_frame_header(outfile_, out_frames_, pkt->data.frame.sz); diff --git a/test/decode_test_driver.cc b/test/decode_test_driver.cc index 3417e57..ea31c0d 100644 --- a/test/decode_test_driver.cc +++ b/test/decode_test_driver.cc @@ -97,8 +97,9 @@ void DecoderTest::RunLoop(CompressedVideoSource *video, const vpx_image_t *img = NULL; // Get decompressed data - while ((img = dec_iter.Next())) + while ((img = dec_iter.Next())) { DecompressedFrameHook(*img, video->frame_number()); + } } delete decoder; } diff --git a/test/encode_perf_test.cc b/test/encode_perf_test.cc index 5ea93a0..53dd29a 100644 --- a/test/encode_perf_test.cc +++ b/test/encode_perf_test.cc @@ -126,11 +126,12 @@ TEST_P(VP9EncodePerfTest, PerfTest) { for (size_t j = 0; j < NELEMENTS(kEncodePerfTestSpeeds); ++j) { for (size_t k = 0; k < NELEMENTS(kEncodePerfTestThreads); ++k) { if (kVP9EncodePerfTestVectors[i].width < 512 && - kEncodePerfTestThreads[k] > 1) + kEncodePerfTestThreads[k] > 1) { continue; - else if (kVP9EncodePerfTestVectors[i].width < 1024 && - kEncodePerfTestThreads[k] > 2) + } else if (kVP9EncodePerfTestVectors[i].width < 1024 && + kEncodePerfTestThreads[k] > 2) { continue; + } set_threads(kEncodePerfTestThreads[k]); SetUp(); diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc index 6154d3e..7822361 100644 --- a/test/encode_test_driver.cc +++ b/test/encode_test_driver.cc @@ -52,10 +52,11 @@ void Encoder::InitEncoder(VideoSource *video) { } void Encoder::EncodeFrame(VideoSource *video, const unsigned long frame_flags) { - if (video->img()) + if (video->img()) { EncodeFrameInternal(*video, frame_flags); - else + } else { Flush(); + } // Handle twopass stats CxDataIterator iter = GetCxData(); @@ -115,10 +116,11 @@ void EncoderTest::SetMode(TestMode mode) { default: ASSERT_TRUE(false) << "Unexpected mode " << mode; } - if (mode == kTwoPassGood || mode == kTwoPassBest) + if (mode == kTwoPassGood || mode == kTwoPassBest) { passes_ = 2; - else + } else { passes_ = 1; + } } // The function should return "true" most of the time, therefore no early // break-out is implemented within the match checking process. @@ -129,23 +131,26 @@ static bool compare_img(const vpx_image_t *img1, const vpx_image_t *img2) { const unsigned int width_y = img1->d_w; const unsigned int height_y = img1->d_h; unsigned int i; - for (i = 0; i < height_y; ++i) + for (i = 0; i < height_y; ++i) { match = (memcmp(img1->planes[VPX_PLANE_Y] + i * img1->stride[VPX_PLANE_Y], img2->planes[VPX_PLANE_Y] + i * img2->stride[VPX_PLANE_Y], width_y) == 0) && match; + } const unsigned int width_uv = (img1->d_w + 1) >> 1; const unsigned int height_uv = (img1->d_h + 1) >> 1; - for (i = 0; i < height_uv; ++i) + for (i = 0; i < height_uv; ++i) { match = (memcmp(img1->planes[VPX_PLANE_U] + i * img1->stride[VPX_PLANE_U], img2->planes[VPX_PLANE_U] + i * img2->stride[VPX_PLANE_U], width_uv) == 0) && match; - for (i = 0; i < height_uv; ++i) + } + for (i = 0; i < height_uv; ++i) { match = (memcmp(img1->planes[VPX_PLANE_V] + i * img1->stride[VPX_PLANE_V], img2->planes[VPX_PLANE_V] + i * img2->stride[VPX_PLANE_V], width_uv) == 0) && match; + } return match; } @@ -163,12 +168,13 @@ void EncoderTest::RunLoop(VideoSource *video) { for (unsigned int pass = 0; pass < passes_; pass++) { last_pts_ = 0; - if (passes_ == 1) + if (passes_ == 1) { cfg_.g_pass = VPX_RC_ONE_PASS; - else if (pass == 0) + } else if (pass == 0) { cfg_.g_pass = VPX_RC_FIRST_PASS; - else + } else { cfg_.g_pass = VPX_RC_LAST_PASS; + } BeginPassHook(pass); testing::internal::scoped_ptr encoder( @@ -182,8 +188,9 @@ void EncoderTest::RunLoop(VideoSource *video) { unsigned long dec_init_flags = 0; // NOLINT // Use fragment decoder if encoder outputs partitions. // NOTE: fragment decoder and partition encoder are only supported by VP8. - if (init_flags_ & VPX_CODEC_USE_OUTPUT_PARTITION) + if (init_flags_ & VPX_CODEC_USE_OUTPUT_PARTITION) { dec_init_flags |= VPX_CODEC_USE_INPUT_FRAGMENTS; + } testing::internal::scoped_ptr decoder( codec_->CreateDecoder(dec_cfg, dec_init_flags, 0)); bool again; diff --git a/test/error_resilience_test.cc b/test/error_resilience_test.cc index 1970b17..4c7ede8 100644 --- a/test/error_resilience_test.cc +++ b/test/error_resilience_test.cc @@ -152,23 +152,27 @@ class ErrorResilienceTestLarge } void SetErrorFrames(int num, unsigned int *list) { - if (num > kMaxErrorFrames) + if (num > kMaxErrorFrames) { num = kMaxErrorFrames; - else if (num < 0) + } else if (num < 0) { num = 0; + } error_nframes_ = num; - for (unsigned int i = 0; i < error_nframes_; ++i) + for (unsigned int i = 0; i < error_nframes_; ++i) { error_frames_[i] = list[i]; + } } void SetDroppableFrames(int num, unsigned int *list) { - if (num > kMaxDroppableFrames) + if (num > kMaxDroppableFrames) { num = kMaxDroppableFrames; - else if (num < 0) + } else if (num < 0) { num = 0; + } droppable_nframes_ = num; - for (unsigned int i = 0; i < droppable_nframes_; ++i) + for (unsigned int i = 0; i < droppable_nframes_; ++i) { droppable_frames_[i] = list[i]; + } } unsigned int GetMismatchFrames() { return mismatch_nframes_; } diff --git a/test/fdct4x4_test.cc b/test/fdct4x4_test.cc index 3277936..1270dae 100644 --- a/test/fdct4x4_test.cc +++ b/test/fdct4x4_test.cc @@ -170,8 +170,9 @@ class Trans4x4TestBase { for (int i = 0; i < count_test_block; ++i) { // Initialize a test block with input range [-mask_, mask_]. - for (int j = 0; j < kNumCoeffs; ++j) + for (int j = 0; j < kNumCoeffs; ++j) { input_block[j] = (rnd.Rand16() & mask_) - (rnd.Rand16() & mask_); + } fwd_txfm_ref(input_block, output_ref_block, pitch_, tx_type_); ASM_REGISTER_STATE_CHECK(RunFwdTxfm(input_block, output_block, pitch_)); diff --git a/test/fdct8x8_test.cc b/test/fdct8x8_test.cc index 994dab1..3ac73c1 100644 --- a/test/fdct8x8_test.cc +++ b/test/fdct8x8_test.cc @@ -51,8 +51,9 @@ void reference_8x8_dct_1d(const double in[8], double out[8]) { const double kInvSqrt2 = 0.707106781186547524400844362104; for (int k = 0; k < 8; k++) { out[k] = 0.0; - for (int n = 0; n < 8; n++) + for (int n = 0; n < 8; n++) { out[k] += in[n] * cos(kPi * (2 * n + 1) * k / 16.0); + } if (k == 0) out[k] = out[k] * kInvSqrt2; } } @@ -149,17 +150,19 @@ class FwdTrans8x8TestBase { for (int i = 0; i < count_test_block; ++i) { // Initialize a test block with input range [-255, 255]. - for (int j = 0; j < 64; ++j) + for (int j = 0; j < 64; ++j) { test_input_block[j] = ((rnd.Rand16() >> (16 - bit_depth_)) & mask_) - ((rnd.Rand16() >> (16 - bit_depth_)) & mask_); + } ASM_REGISTER_STATE_CHECK( RunFwdTxfm(test_input_block, test_output_block, pitch_)); for (int j = 0; j < 64; ++j) { - if (test_output_block[j] < 0) + if (test_output_block[j] < 0) { ++count_sign_block[j][0]; - else if (test_output_block[j] > 0) + } else if (test_output_block[j] > 0) { ++count_sign_block[j][1]; + } } } @@ -178,17 +181,19 @@ class FwdTrans8x8TestBase { for (int i = 0; i < count_test_block; ++i) { // Initialize a test block with input range [-mask_ / 16, mask_ / 16]. - for (int j = 0; j < 64; ++j) + for (int j = 0; j < 64; ++j) { test_input_block[j] = ((rnd.Rand16() & mask_) >> 4) - ((rnd.Rand16() & mask_) >> 4); + } ASM_REGISTER_STATE_CHECK( RunFwdTxfm(test_input_block, test_output_block, pitch_)); for (int j = 0; j < 64; ++j) { - if (test_output_block[j] < 0) + if (test_output_block[j] < 0) { ++count_sign_block[j][0]; - else if (test_output_block[j] > 0) + } else if (test_output_block[j] > 0) { ++count_sign_block[j][1]; + } } } @@ -399,8 +404,9 @@ class FwdTrans8x8TestBase { } reference_8x8_dct_2d(in, out_r); - for (int j = 0; j < kNumCoeffs; ++j) + for (int j = 0; j < kNumCoeffs; ++j) { coeff[j] = static_cast(round(out_r[j])); + } if (bit_depth_ == VPX_BITS_8) { ASM_REGISTER_STATE_CHECK(RunInvTxfm(coeff, dst, pitch_)); @@ -436,13 +442,15 @@ class FwdTrans8x8TestBase { double out_r[kNumCoeffs]; // Initialize a test block with input range [-mask_, mask_]. - for (int j = 0; j < kNumCoeffs; ++j) + for (int j = 0; j < kNumCoeffs; ++j) { in[j] = rnd.Rand8() % 2 == 0 ? mask_ : -mask_; + } RunFwdTxfm(in, coeff, pitch_); reference_8x8_dct_2d(in, out_r); - for (int j = 0; j < kNumCoeffs; ++j) + for (int j = 0; j < kNumCoeffs; ++j) { coeff_r[j] = static_cast(round(out_r[j])); + } for (int j = 0; j < kNumCoeffs; ++j) { const int32_t diff = coeff[j] - coeff_r[j]; diff --git a/test/idct8x8_test.cc b/test/idct8x8_test.cc index ee75805..7951bb9 100644 --- a/test/idct8x8_test.cc +++ b/test/idct8x8_test.cc @@ -28,8 +28,9 @@ void reference_dct_1d(double input[8], double output[8]) { const double kInvSqrt2 = 0.707106781186547524400844362104; for (int k = 0; k < 8; k++) { output[k] = 0.0; - for (int n = 0; n < 8; n++) + for (int n = 0; n < 8; n++) { output[k] += input[n] * cos(kPi * (2 * n + 1) * k / 16.0); + } if (k == 0) output[k] = output[k] * kInvSqrt2; } } @@ -70,8 +71,9 @@ TEST(VP9Idct8x8Test, AccuracyCheck) { for (int j = 0; j < 64; ++j) input[j] = src[j] - dst[j]; reference_dct_2d(input, output_r); - for (int j = 0; j < 64; ++j) + for (int j = 0; j < 64; ++j) { coeff[j] = static_cast(round(output_r[j])); + } vpx_idct8x8_64_add_c(coeff, dst, 8); for (int j = 0; j < 64; ++j) { const int diff = dst[j] - src[j]; diff --git a/test/idct_test.cc b/test/idct_test.cc index 39db3e4..f54f2c0 100644 --- a/test/idct_test.cc +++ b/test/idct_test.cc @@ -43,11 +43,12 @@ class IDCTTest : public ::testing::TestWithParam { TEST_P(IDCTTest, TestGuardBlocks) { int i; - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { if ((i & 0xF) < 4 && i < 64) EXPECT_EQ(0, output[i]) << i; else EXPECT_EQ(255, output[i]); + } } TEST_P(IDCTTest, TestAllZeros) { @@ -55,11 +56,12 @@ TEST_P(IDCTTest, TestAllZeros) { ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16)); - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { if ((i & 0xF) < 4 && i < 64) EXPECT_EQ(0, output[i]) << "i==" << i; else EXPECT_EQ(255, output[i]) << "i==" << i; + } } TEST_P(IDCTTest, TestAllOnes) { @@ -68,11 +70,12 @@ TEST_P(IDCTTest, TestAllOnes) { input[0] = 4; ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16)); - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { if ((i & 0xF) < 4 && i < 64) EXPECT_EQ(1, output[i]) << "i==" << i; else EXPECT_EQ(255, output[i]) << "i==" << i; + } } TEST_P(IDCTTest, TestAddOne) { @@ -82,11 +85,12 @@ TEST_P(IDCTTest, TestAddOne) { input[0] = 4; ASM_REGISTER_STATE_CHECK(UUT(input, predict, 16, output, 16)); - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { if ((i & 0xF) < 4 && i < 64) EXPECT_EQ(i + 1, output[i]) << "i==" << i; else EXPECT_EQ(255, output[i]) << "i==" << i; + } } TEST_P(IDCTTest, TestWithData) { @@ -96,7 +100,7 @@ TEST_P(IDCTTest, TestWithData) { ASM_REGISTER_STATE_CHECK(UUT(input, output, 16, output, 16)); - for (i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { if ((i & 0xF) > 3 || i > 63) EXPECT_EQ(255, output[i]) << "i==" << i; else if (i == 0) @@ -107,6 +111,7 @@ TEST_P(IDCTTest, TestWithData) { EXPECT_EQ(3, output[i]) << "i==" << i; else EXPECT_EQ(0, output[i]) << "i==" << i; + } } INSTANTIATE_TEST_CASE_P(C, IDCTTest, ::testing::Values(vp8_short_idct4x4llm_c)); diff --git a/test/keyframe_test.cc b/test/keyframe_test.cc index 03cdedc..38bd923 100644 --- a/test/keyframe_test.cc +++ b/test/keyframe_test.cc @@ -35,10 +35,12 @@ class KeyframeTest virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video, ::libvpx_test::Encoder *encoder) { - if (kf_do_force_kf_) + if (kf_do_force_kf_) { frame_flags_ = (video->frame() % 3) ? 0 : VPX_EFLAG_FORCE_KF; - if (set_cpu_used_ && video->frame() == 1) + } + if (set_cpu_used_ && video->frame() == 1) { encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_); + } } virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) { diff --git a/test/partial_idct_test.cc b/test/partial_idct_test.cc index 953bb71..de6ff4a 100644 --- a/test/partial_idct_test.cc +++ b/test/partial_idct_test.cc @@ -100,9 +100,10 @@ TEST_P(PartialIDctTest, RunQuantCheck) { // quantization with maximum allowed step sizes test_coef_block1[0] = (output_ref_block[0] / 1336) * 1336; - for (int j = 1; j < last_nonzero_; ++j) + for (int j = 1; j < last_nonzero_; ++j) { test_coef_block1[vp9_default_scan_orders[tx_size_].scan[j]] = (output_ref_block[j] / 1828) * 1828; + } } ASM_REGISTER_STATE_CHECK(full_itxfm_(test_coef_block1, dst1, size)); diff --git a/test/sad_test.cc b/test/sad_test.cc index e1f164a..837b08f 100644 --- a/test/sad_test.cc +++ b/test/sad_test.cc @@ -114,9 +114,10 @@ class SADTestBase : public ::testing::TestWithParam { uint8_t *GetReference(int block_idx) const { #if CONFIG_VP9_HIGHBITDEPTH - if (use_high_bit_depth_) + if (use_high_bit_depth_) { return CONVERT_TO_BYTEPTR(CONVERT_TO_SHORTPTR(reference_data_) + block_idx * kDataBlockSize); + } #endif // CONFIG_VP9_HIGHBITDEPTH return reference_data_ + block_idx * kDataBlockSize; } diff --git a/test/sixtap_predict_test.cc b/test/sixtap_predict_test.cc index b9bc375..31a6044 100644 --- a/test/sixtap_predict_test.cc +++ b/test/sixtap_predict_test.cc @@ -146,10 +146,11 @@ TEST_P(SixtapPredictTest, TestWithPresetData) { ASM_REGISTER_STATE_CHECK(sixtap_predict_(&src[kSrcStride * 2 + 2 + 1], kSrcStride, 2, 2, dst_, kDstStride)); - for (int i = 0; i < height_; ++i) + for (int i = 0; i < height_; ++i) { for (int j = 0; j < width_; ++j) ASSERT_EQ(expected_dst[i * kDstStride + j], dst_[i * kDstStride + j]) << "i==" << (i * width_ + j); + } } using libvpx_test::ACMRandom; @@ -172,10 +173,11 @@ TEST_P(SixtapPredictTest, TestWithRandomData) { kSrcStride, xoffset, yoffset, dst_, kDstStride)); - for (int i = 0; i < height_; ++i) + for (int i = 0; i < height_; ++i) { for (int j = 0; j < width_; ++j) ASSERT_EQ(dst_c_[i * kDstStride + j], dst_[i * kDstStride + j]) << "i==" << (i * width_ + j); + } } } } diff --git a/test/test_libvpx.cc b/test/test_libvpx.cc index 120e0e1..8a70b4e 100644 --- a/test/test_libvpx.cc +++ b/test/test_libvpx.cc @@ -45,10 +45,12 @@ int main(int argc, char **argv) { if (!(simd_caps & HAS_SSE)) append_negative_gtest_filter(":SSE.*:SSE/*"); if (!(simd_caps & HAS_SSE2)) append_negative_gtest_filter(":SSE2.*:SSE2/*"); if (!(simd_caps & HAS_SSE3)) append_negative_gtest_filter(":SSE3.*:SSE3/*"); - if (!(simd_caps & HAS_SSSE3)) + if (!(simd_caps & HAS_SSSE3)) { append_negative_gtest_filter(":SSSE3.*:SSSE3/*"); - if (!(simd_caps & HAS_SSE4_1)) + } + if (!(simd_caps & HAS_SSE4_1)) { append_negative_gtest_filter(":SSE4_1.*:SSE4_1/*"); + } if (!(simd_caps & HAS_AVX)) append_negative_gtest_filter(":AVX.*:AVX/*"); if (!(simd_caps & HAS_AVX2)) append_negative_gtest_filter(":AVX2.*:AVX2/*"); #endif // ARCH_X86 || ARCH_X86_64 diff --git a/test/util.h b/test/util.h index 0ef2ad8..1f2540e 100644 --- a/test/util.h +++ b/test/util.h @@ -28,12 +28,13 @@ inline double compute_psnr(const vpx_image_t *img1, const vpx_image_t *img2) { unsigned int i, j; int64_t sqrerr = 0; - for (i = 0; i < height_y; ++i) + for (i = 0; i < height_y; ++i) { for (j = 0; j < width_y; ++j) { int64_t d = img1->planes[VPX_PLANE_Y][i * img1->stride[VPX_PLANE_Y] + j] - img2->planes[VPX_PLANE_Y][i * img2->stride[VPX_PLANE_Y] + j]; sqrerr += d * d; } + } double mse = static_cast(sqrerr) / (width_y * height_y); double psnr = 100.0; if (mse > 0.0) { diff --git a/test/video_source.h b/test/video_source.h index 94a95ce..424bb2c 100644 --- a/test/video_source.h +++ b/test/video_source.h @@ -218,10 +218,11 @@ class RandomVideoSource : public DummyVideoSource { // than holding previous frames to encourage keyframes to be thrown. virtual void FillFrame() { if (img_) { - if (frame_ % 30 < 15) + if (frame_ % 30 < 15) { for (size_t i = 0; i < raw_sz_; ++i) img_->img_data[i] = rnd_.Rand8(); - else + } else { memset(img_->img_data, 0, raw_sz_); + } } } diff --git a/test/vp8_fdct4x4_test.cc b/test/vp8_fdct4x4_test.cc index 5def9a1..da4f0ca 100644 --- a/test/vp8_fdct4x4_test.cc +++ b/test/vp8_fdct4x4_test.cc @@ -80,24 +80,27 @@ TEST(VP8FdctTest, SignBiasCheck) { for (int i = 0; i < count_test_block; ++i) { // Initialize a test block with input range [-255, 255]. - for (int j = 0; j < 16; ++j) + for (int j = 0; j < 16; ++j) { test_input_block[j] = rnd.Rand8() - rnd.Rand8(); + } vp8_short_fdct4x4_c(test_input_block, test_output_block, pitch); for (int j = 0; j < 16; ++j) { - if (test_output_block[j] < 0) + if (test_output_block[j] < 0) { ++count_sign_block[j][0]; - else if (test_output_block[j] > 0) + } else if (test_output_block[j] > 0) { ++count_sign_block[j][1]; + } } } bool bias_acceptable = true; - for (int j = 0; j < 16; ++j) + for (int j = 0; j < 16; ++j) { bias_acceptable = bias_acceptable && (abs(count_sign_block[j][0] - count_sign_block[j][1]) < 10000); + } EXPECT_EQ(true, bias_acceptable) << "Error: 4x4 FDCT has a sign bias > 1% for input range [-255, 255]"; @@ -106,24 +109,27 @@ TEST(VP8FdctTest, SignBiasCheck) { for (int i = 0; i < count_test_block; ++i) { // Initialize a test block with input range [-15, 15]. - for (int j = 0; j < 16; ++j) + for (int j = 0; j < 16; ++j) { test_input_block[j] = (rnd.Rand8() >> 4) - (rnd.Rand8() >> 4); + } vp8_short_fdct4x4_c(test_input_block, test_output_block, pitch); for (int j = 0; j < 16; ++j) { - if (test_output_block[j] < 0) + if (test_output_block[j] < 0) { ++count_sign_block[j][0]; - else if (test_output_block[j] > 0) + } else if (test_output_block[j] > 0) { ++count_sign_block[j][1]; + } } } bias_acceptable = true; - for (int j = 0; j < 16; ++j) + for (int j = 0; j < 16; ++j) { bias_acceptable = bias_acceptable && (abs(count_sign_block[j][0] - count_sign_block[j][1]) < 100000); + } EXPECT_EQ(true, bias_acceptable) << "Error: 4x4 FDCT has a sign bias > 10% for input range [-15, 15]"; @@ -140,8 +146,9 @@ TEST(VP8FdctTest, RoundTripErrorCheck) { int16_t test_output_block[16]; // Initialize a test block with input range [-255, 255]. - for (int j = 0; j < 16; ++j) + for (int j = 0; j < 16; ++j) { test_input_block[j] = rnd.Rand8() - rnd.Rand8(); + } const int pitch = 8; vp8_short_fdct4x4_c(test_input_block, test_temp_block, pitch); diff --git a/test/vp9_arf_freq_test.cc b/test/vp9_arf_freq_test.cc index 0799bca..48a4ca7 100644 --- a/test/vp9_arf_freq_test.cc +++ b/test/vp9_arf_freq_test.cc @@ -68,10 +68,11 @@ const int kMinArfVectors[] = { int is_extension_y4m(const char *filename) { const char *dot = strrchr(filename, '.'); - if (!dot || dot == filename) + if (!dot || dot == filename) { return 0; - else + } else { return !strcmp(dot, ".y4m"); + } } class ArfFreqTest @@ -161,13 +162,14 @@ class ArfFreqTest int GetMinVisibleRun() const { return min_run_; } int GetMinArfDistanceRequested() const { - if (min_arf_requested_) + if (min_arf_requested_) { return min_arf_requested_; - else + } else { return vp9_rc_get_default_min_gf_interval( test_video_param_.width, test_video_param_.height, (double)test_video_param_.framerate_num / test_video_param_.framerate_den); + } } TestVideoParam test_video_param_; diff --git a/test/vp9_encoder_parms_get_to_decoder.cc b/test/vp9_encoder_parms_get_to_decoder.cc index a089555..b5ca1a3 100644 --- a/test/vp9_encoder_parms_get_to_decoder.cc +++ b/test/vp9_encoder_parms_get_to_decoder.cc @@ -87,8 +87,9 @@ class VpxEncoderParmsGetToDecoder encoder->Control(VP8E_SET_ARNR_MAXFRAMES, 7); encoder->Control(VP8E_SET_ARNR_STRENGTH, 5); encoder->Control(VP8E_SET_ARNR_TYPE, 3); - if (encode_parms.render_size[0] > 0 && encode_parms.render_size[1] > 0) + if (encode_parms.render_size[0] > 0 && encode_parms.render_size[1] > 0) { encoder->Control(VP9E_SET_RENDER_SIZE, encode_parms.render_size); + } } } diff --git a/test/vp9_end_to_end_test.cc b/test/vp9_end_to_end_test.cc index e82320f..168368f 100644 --- a/test/vp9_end_to_end_test.cc +++ b/test/vp9_end_to_end_test.cc @@ -67,10 +67,11 @@ const int kCpuUsedVectors[] = { 1, 2, 3, 5, 6 }; int is_extension_y4m(const char *filename) { const char *dot = strrchr(filename, '.'); - if (!dot || dot == filename) + if (!dot || dot == filename) { return 0; - else + } else { return !strcmp(dot, ".y4m"); + } } class EndToEndTestLarge diff --git a/test/yuv_video_source.h b/test/yuv_video_source.h index 2cc81a0..71ad2ab 100644 --- a/test/yuv_video_source.h +++ b/test/yuv_video_source.h @@ -45,8 +45,9 @@ class YUVVideoSource : public VideoSource { input_file_ = OpenTestDataFile(file_name_); ASSERT_TRUE(input_file_ != NULL) << "Input file open failed. Filename: " << file_name_; - if (start_) + if (start_) { fseek(input_file_, static_cast(raw_size_) * start_, SEEK_SET); + } frame_ = start_; FillFrame(); -- 2.7.4