Commit 01236769 authored by James Zern's avatar James Zern Committed by Gerrit Code Review

Merge "datarate_test: fix some type conversions"

parents 2c60f875 cac85f82
...@@ -55,21 +55,22 @@ class DatarateTest : public ::libvpx_test::EncoderTest, ...@@ -55,21 +55,22 @@ class DatarateTest : public ::libvpx_test::EncoderTest,
duration = 1; duration = 1;
// Add to the buffer the bits we'd expect from a constant bitrate server. // Add to the buffer the bits we'd expect from a constant bitrate server.
bits_in_buffer_model_ += duration * timebase_ * cfg_.rc_target_bitrate bits_in_buffer_model_ += static_cast<int64_t>(
* 1000; duration * timebase_ * cfg_.rc_target_bitrate * 1000);
/* Test the buffer model here before subtracting the frame. Do so because /* 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 * 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 * 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 * 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. */ * 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) { if (!key_frame) {
ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame " ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame "
<< pkt->data.frame.pts; << 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. // Subtract from the buffer the bits associated with a played back frame.
bits_in_buffer_model_ -= frame_size_in_bits; bits_in_buffer_model_ -= frame_size_in_bits;
...@@ -93,7 +94,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest, ...@@ -93,7 +94,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest,
virtual void EndPassHook(void) { virtual void EndPassHook(void) {
if (bits_total_) { 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_; duration_ = (last_pts_ + 1) * timebase_;
...@@ -106,7 +107,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest, ...@@ -106,7 +107,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest,
} }
vpx_codec_pts_t last_pts_; vpx_codec_pts_t last_pts_;
int bits_in_buffer_model_; int64_t bits_in_buffer_model_;
double timebase_; double timebase_;
int frame_number_; int frame_number_;
vpx_codec_pts_t first_drop_; vpx_codec_pts_t first_drop_;
...@@ -114,7 +115,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest, ...@@ -114,7 +115,7 @@ class DatarateTest : public ::libvpx_test::EncoderTest,
double duration_; double duration_;
double file_datarate_; double file_datarate_;
double effective_datarate_; double effective_datarate_;
int bits_in_last_frame_; size_t bits_in_last_frame_;
}; };
TEST_P(DatarateTest, BasicBufferModel) { TEST_P(DatarateTest, BasicBufferModel) {
...@@ -216,14 +217,14 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest, ...@@ -216,14 +217,14 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest,
vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_; 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. // Add to the buffer the bits we'd expect from a constant bitrate server.
bits_in_buffer_model_ += duration * timebase_ * cfg_.rc_target_bitrate bits_in_buffer_model_ += static_cast<int64_t>(
* 1000; duration * timebase_ * cfg_.rc_target_bitrate * 1000);
// Buffer should not go negative. // Buffer should not go negative.
ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame " ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame "
<< pkt->data.frame.pts; << 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; bits_total_ += frame_size_in_bits;
// If first drop not set and we have a drop set it to this time. // 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, ...@@ -232,7 +233,7 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest,
// Update the number of frame drops. // Update the number of frame drops.
if (duration > 1) { if (duration > 1) {
num_drops_+= (duration - 1); num_drops_ += static_cast<int>(duration - 1);
} }
// Update the most recent pts. // Update the most recent pts.
...@@ -255,8 +256,8 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest, ...@@ -255,8 +256,8 @@ class DatarateTestVP9 : public ::libvpx_test::EncoderTest,
double duration_; double duration_;
double effective_datarate_; double effective_datarate_;
int set_cpu_used_; int set_cpu_used_;
int bits_in_buffer_model_; int64_t bits_in_buffer_model_;
int first_drop_; vpx_codec_pts_t first_drop_;
int num_drops_; int num_drops_;
}; };
...@@ -305,7 +306,7 @@ TEST_P(DatarateTestVP9, ChangingDropFrameThresh) { ...@@ -305,7 +306,7 @@ TEST_P(DatarateTestVP9, ChangingDropFrameThresh) {
30, 1, 0, 140); 30, 1, 0, 140);
const int kDropFrameThreshTestStep = 30; const int kDropFrameThreshTestStep = 30;
int last_drop = 140; vpx_codec_pts_t last_drop = 140;
int last_num_drops = 0; int last_num_drops = 0;
for (int i = 10; i < 100; i += kDropFrameThreshTestStep) { for (int i = 10; i < 100; i += kDropFrameThreshTestStep) {
cfg_.rc_dropframe_thresh = i; cfg_.rc_dropframe_thresh = i;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment