ref: 01236769abb3081a7e69ad8f03a1de9c83fe7756
parent: 2c60f8750686ee8460d625ee5cac30887082d79b
parent: cac85f82c5b6358b1e411bbff2a77eaa1d978538
author: James Zern <[email protected]>
date: Sat Jan 11 07:38:36 EST 2014
Merge "datarate_test: fix some type conversions"
--- a/test/datarate_test.cc
+++ b/test/datarate_test.cc
@@ -55,8 +55,8 @@
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<int64_t>(
+ 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
@@ -63,13 +63,14 @@
* 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 @@
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 @@
}
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 @@
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 @@
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<int64_t>(
+ 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 @@
// Update the number of frame drops.
if (duration > 1) {
- num_drops_+= (duration - 1);
+ num_drops_ += static_cast<int>(duration - 1);
}
// Update the most recent pts.
@@ -255,8 +256,8 @@
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 @@
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;