From: James Zern Date: Thu, 19 Dec 2013 00:58:43 +0000 (-0800) Subject: datarate_test: fix some type conversions X-Git-Tag: v1.4.0~2696^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cac85f82c5b6358b1e411bbff2a77eaa1d978538;p=platform%2Fupstream%2Flibvpx.git datarate_test: fix some type conversions Change-Id: I9840dfab644b0c75ff667174f8005dece005e700 --- diff --git a/test/datarate_test.cc b/test/datarate_test.cc index 40a968c..0b4ddae 100644 --- a/test/datarate_test.cc +++ b/test/datarate_test.cc @@ -55,21 +55,22 @@ class DatarateTest : public ::libvpx_test::EncoderTest, duration = 1; // Add to the buffer the bits we'd expect from a constant bitrate server. - bits_in_buffer_model_ += duration * timebase_ * cfg_.rc_target_bitrate - * 1000; + bits_in_buffer_model_ += static_cast( + duration * timebase_ * cfg_.rc_target_bitrate * 1000); /* Test the buffer model here before subtracting the frame. Do so because * the way the leaky bucket model works in libvpx is to allow the buffer to * empty - and then stop showing frames until we've got enough bits to * show one. As noted in comment below (issue 495), this does not currently * apply to key frames. For now exclude key frames in condition below. */ - bool key_frame = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) ? true: false; + const bool key_frame = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) + ? true: false; if (!key_frame) { ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame " << pkt->data.frame.pts; } - const int frame_size_in_bits = pkt->data.frame.sz * 8; + const size_t frame_size_in_bits = pkt->data.frame.sz * 8; // Subtract from the buffer the bits associated with a played back frame. bits_in_buffer_model_ -= frame_size_in_bits; @@ -93,7 +94,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest, virtual void EndPassHook(void) { if (bits_total_) { - const double file_size_in_kb = bits_total_ / 1000; /* bits per kilobit */ + const double file_size_in_kb = bits_total_ / 1000.; // bits per kilobit duration_ = (last_pts_ + 1) * timebase_; @@ -106,7 +107,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest, } vpx_codec_pts_t last_pts_; - int bits_in_buffer_model_; + int64_t bits_in_buffer_model_; double timebase_; int frame_number_; vpx_codec_pts_t first_drop_; @@ -114,7 +115,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest, double duration_; double file_datarate_; double effective_datarate_; - int bits_in_last_frame_; + size_t bits_in_last_frame_; }; TEST_P(DatarateTest, BasicBufferModel) { @@ -216,14 +217,14 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest, vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_; // Add to the buffer the bits we'd expect from a constant bitrate server. - bits_in_buffer_model_ += duration * timebase_ * cfg_.rc_target_bitrate - * 1000; + bits_in_buffer_model_ += static_cast( + duration * timebase_ * cfg_.rc_target_bitrate * 1000); // Buffer should not go negative. ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame " << pkt->data.frame.pts; - const int frame_size_in_bits = pkt->data.frame.sz * 8; + const size_t frame_size_in_bits = pkt->data.frame.sz * 8; bits_total_ += frame_size_in_bits; // If first drop not set and we have a drop set it to this time. @@ -232,7 +233,7 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest, // Update the number of frame drops. if (duration > 1) { - num_drops_+= (duration - 1); + num_drops_ += static_cast(duration - 1); } // Update the most recent pts. @@ -255,8 +256,8 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest, double duration_; double effective_datarate_; int set_cpu_used_; - int bits_in_buffer_model_; - int first_drop_; + int64_t bits_in_buffer_model_; + vpx_codec_pts_t first_drop_; int num_drops_; }; @@ -305,7 +306,7 @@ TEST_P(DatarateTestVP9, ChangingDropFrameThresh) { 30, 1, 0, 140); const int kDropFrameThreshTestStep = 30; - int last_drop = 140; + vpx_codec_pts_t last_drop = 140; int last_num_drops = 0; for (int i = 10; i < 100; i += kDropFrameThreshTestStep) { cfg_.rc_dropframe_thresh = i;