OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #include "test/encode_test_driver.h" | 10 #include "test/encode_test_driver.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 if (last_pts_ == 0) | 52 if (last_pts_ == 0) |
53 duration = 1; | 53 duration = 1; |
54 | 54 |
55 // Add to the buffer the bits we'd expect from a constant bitrate server. | 55 // Add to the buffer the bits we'd expect from a constant bitrate server. |
56 bits_in_buffer_model_ += duration * timebase_ * cfg_.rc_target_bitrate | 56 bits_in_buffer_model_ += duration * timebase_ * cfg_.rc_target_bitrate |
57 * 1000; | 57 * 1000; |
58 | 58 |
59 /* Test the buffer model here before subtracting the frame. Do so because | 59 /* Test the buffer model here before subtracting the frame. Do so because |
60 * the way the leaky bucket model works in libvpx is to allow the buffer to | 60 * the way the leaky bucket model works in libvpx is to allow the buffer to |
61 * empty - and then stop showing frames until we've got enough bits to | 61 * empty - and then stop showing frames until we've got enough bits to |
62 * show one. As noted in comment below (issue 495), this does not currently | 62 * show one. */ |
63 * apply to key frames. For now exclude key frames in condition below. */ | 63 ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame " |
64 bool key_frame = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) ? true: false; | 64 << pkt->data.frame.pts; |
65 if (!key_frame) { | |
66 ASSERT_GE(bits_in_buffer_model_, 0) << "Buffer Underrun at frame " | |
67 << pkt->data.frame.pts; | |
68 } | |
69 | 65 |
70 const int frame_size_in_bits = pkt->data.frame.sz * 8; | 66 const int frame_size_in_bits = pkt->data.frame.sz * 8; |
71 | 67 |
72 // Subtract from the buffer the bits associated with a played back frame. | 68 // Subtract from the buffer the bits associated with a played back frame. |
73 bits_in_buffer_model_ -= frame_size_in_bits; | 69 bits_in_buffer_model_ -= frame_size_in_bits; |
74 | 70 |
75 // Update the running total of bits for end of test datarate checks. | 71 // Update the running total of bits for end of test datarate checks. |
76 bits_total_ += frame_size_in_bits ; | 72 bits_total_ += frame_size_in_bits ; |
77 | 73 |
78 // If first drop not set and we have a drop set it to this time. | 74 // If first drop not set and we have a drop set it to this time. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 cfg_.rc_end_usage = VPX_CBR; | 118 cfg_.rc_end_usage = VPX_CBR; |
123 // 2 pass cbr datarate control has a bug hidden by the small # of | 119 // 2 pass cbr datarate control has a bug hidden by the small # of |
124 // frames selected in this encode. The problem is that even if the buffer is | 120 // frames selected in this encode. The problem is that even if the buffer is |
125 // negative we produce a keyframe on a cutscene. Ignoring datarate | 121 // negative we produce a keyframe on a cutscene. Ignoring datarate |
126 // constraints | 122 // constraints |
127 // TODO(jimbankoski): ( Fix when issue | 123 // TODO(jimbankoski): ( Fix when issue |
128 // http://code.google.com/p/webm/issues/detail?id=495 is addressed. ) | 124 // http://code.google.com/p/webm/issues/detail?id=495 is addressed. ) |
129 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, | 125 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288, |
130 30, 1, 0, 140); | 126 30, 1, 0, 140); |
131 | 127 |
132 // There is an issue for low bitrates in real-time mode, where the | 128 for (int i = 70; i < 700; i += 200) { |
133 // effective_datarate slightly overshoots the target bitrate. | |
134 // This is same the issue as noted about (#495). | |
135 // TODO(jimbankoski/marpan): Update test to run for lower bitrates (< 100), | |
136 // when the issue is resolved. | |
137 for (int i = 100; i < 800; i += 200) { | |
138 cfg_.rc_target_bitrate = i; | 129 cfg_.rc_target_bitrate = i; |
139 ResetModel(); | 130 ResetModel(); |
140 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); | 131 ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); |
141 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_) | 132 ASSERT_GE(cfg_.rc_target_bitrate, effective_datarate_) |
142 << " The datarate for the file exceeds the target!"; | 133 << " The datarate for the file exceeds the target!"; |
143 | 134 |
144 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3) | 135 ASSERT_LE(cfg_.rc_target_bitrate, file_datarate_ * 1.3) |
145 << " The datarate for the file missed the target!"; | 136 << " The datarate for the file missed the target!"; |
146 } | 137 } |
147 } | 138 } |
(...skipping 21 matching lines...) Expand all Loading... |
169 ASSERT_LE(first_drop_, last_drop) | 160 ASSERT_LE(first_drop_, last_drop) |
170 << " The first dropped frame for drop_thresh " << i | 161 << " The first dropped frame for drop_thresh " << i |
171 << " > first dropped frame for drop_thresh " | 162 << " > first dropped frame for drop_thresh " |
172 << i - kDropFrameThreshTestStep; | 163 << i - kDropFrameThreshTestStep; |
173 last_drop = first_drop_; | 164 last_drop = first_drop_; |
174 } | 165 } |
175 } | 166 } |
176 | 167 |
177 INSTANTIATE_TEST_CASE_P(AllModes, DatarateTest, ALL_TEST_MODES); | 168 INSTANTIATE_TEST_CASE_P(AllModes, DatarateTest, ALL_TEST_MODES); |
178 } // namespace | 169 } // namespace |
OLD | NEW |