blob: 182547bdfaa1d3d3e8dbe0c49ed790106ba01512 [file] [log] [blame]
Adrian Grangecc017ca2012-10-02 12:16:27 -07001/*
Frank Galligan38536f62013-12-12 08:36:34 -08002 * Copyright (c) 2013 The WebM project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080010
Adrian Grangecc017ca2012-10-02 12:16:27 -070011#include "third_party/googletest/src/include/gtest/gtest.h"
John Koleszar706cafe2013-01-18 11:51:12 -080012#include "test/codec_factory.h"
Adrian Grangecc017ca2012-10-02 12:16:27 -070013#include "test/encode_test_driver.h"
14#include "test/i420_video_source.h"
John Koleszar706cafe2013-01-18 11:51:12 -080015#include "test/util.h"
Adrian Grangecc017ca2012-10-02 12:16:27 -070016
17namespace {
18
Marco Paniconif61b9622014-02-24 18:14:50 -080019const int kMaxErrorFrames = 12;
20const int kMaxDroppableFrames = 12;
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080021
Jim Bankoskia0b5ed62014-03-12 08:13:16 -070022class ErrorResilienceTestLarge : public ::libvpx_test::EncoderTest,
John Koleszar706cafe2013-01-18 11:51:12 -080023 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
Adrian Grangecc017ca2012-10-02 12:16:27 -070024 protected:
Jim Bankoskia0b5ed62014-03-12 08:13:16 -070025 ErrorResilienceTestLarge()
26 : EncoderTest(GET_PARAM(0)),
27 psnr_(0.0),
28 nframes_(0),
29 mismatch_psnr_(0.0),
30 mismatch_nframes_(0),
31 encoding_mode_(GET_PARAM(1)) {
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080032 Reset();
33 }
John Koleszar706cafe2013-01-18 11:51:12 -080034
Jim Bankoskia0b5ed62014-03-12 08:13:16 -070035 virtual ~ErrorResilienceTestLarge() {}
Adrian Grangecc017ca2012-10-02 12:16:27 -070036
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080037 void Reset() {
38 error_nframes_ = 0;
39 droppable_nframes_ = 0;
40 }
41
Adrian Grangecc017ca2012-10-02 12:16:27 -070042 virtual void SetUp() {
43 InitializeConfig();
44 SetMode(encoding_mode_);
45 }
46
47 virtual void BeginPassHook(unsigned int /*pass*/) {
48 psnr_ = 0.0;
49 nframes_ = 0;
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080050 mismatch_psnr_ = 0.0;
51 mismatch_nframes_ = 0;
Adrian Grangecc017ca2012-10-02 12:16:27 -070052 }
53
Adrian Grangecc017ca2012-10-02 12:16:27 -070054 virtual void PSNRPktHook(const vpx_codec_cx_pkt_t *pkt) {
55 psnr_ += pkt->data.psnr.psnr[0];
56 nframes_++;
57 }
58
Marco8fd55252014-10-29 15:34:18 -070059 //
60 // Frame flags and layer id for temporal layers.
61 // For two layers, test pattern is:
62 // 1 3
63 // 0 2 .....
64 // LAST is updated on base/layer 0, GOLDEN updated on layer 1.
65 int SetFrameFlags(int frame_num, int num_temp_layers) {
66 int frame_flags = 0;
67 if (num_temp_layers == 2) {
68 if (frame_num % 2 == 0) {
69 // Layer 0: predict from L and ARF, update L.
70 frame_flags = VP8_EFLAG_NO_REF_GF |
71 VP8_EFLAG_NO_UPD_GF |
72 VP8_EFLAG_NO_UPD_ARF;
73 } else {
74 // Layer 1: predict from L, GF, and ARF, and update GF.
75 frame_flags = VP8_EFLAG_NO_UPD_ARF |
76 VP8_EFLAG_NO_UPD_LAST;
77 }
78 }
79 return frame_flags;
80 }
81
82 virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
83 ::libvpx_test::Encoder *encoder) {
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080084 frame_flags_ &= ~(VP8_EFLAG_NO_UPD_LAST |
85 VP8_EFLAG_NO_UPD_GF |
86 VP8_EFLAG_NO_UPD_ARF);
Marco8fd55252014-10-29 15:34:18 -070087 // For temporal layer case.
88 if (cfg_.ts_number_layers > 1) {
89 frame_flags_ = SetFrameFlags(video->frame(), cfg_.ts_number_layers);
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080090 for (unsigned int i = 0; i < droppable_nframes_; ++i) {
Deb Mukherjee0d8723f2013-08-19 14:16:26 -070091 if (droppable_frames_[i] == video->frame()) {
Marco8fd55252014-10-29 15:34:18 -070092 std::cout << "Encoding droppable frame: "
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080093 << droppable_frames_[i] << "\n";
Deb Mukherjee01cafaa2013-01-15 06:43:35 -080094 }
95 }
Marco8fd55252014-10-29 15:34:18 -070096 } else {
97 if (droppable_nframes_ > 0 &&
98 (cfg_.g_pass == VPX_RC_LAST_PASS || cfg_.g_pass == VPX_RC_ONE_PASS)) {
99 for (unsigned int i = 0; i < droppable_nframes_; ++i) {
100 if (droppable_frames_[i] == video->frame()) {
101 std::cout << "Encoding droppable frame: "
102 << droppable_frames_[i] << "\n";
103 frame_flags_ |= (VP8_EFLAG_NO_UPD_LAST |
104 VP8_EFLAG_NO_UPD_GF |
105 VP8_EFLAG_NO_UPD_ARF);
106 return;
107 }
108 }
109 }
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800110 }
111 }
112
Adrian Grangecc017ca2012-10-02 12:16:27 -0700113 double GetAveragePsnr() const {
114 if (nframes_)
115 return psnr_ / nframes_;
116 return 0.0;
117 }
118
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800119 double GetAverageMismatchPsnr() const {
120 if (mismatch_nframes_)
121 return mismatch_psnr_ / mismatch_nframes_;
122 return 0.0;
123 }
124
125 virtual bool DoDecode() const {
126 if (error_nframes_ > 0 &&
127 (cfg_.g_pass == VPX_RC_LAST_PASS || cfg_.g_pass == VPX_RC_ONE_PASS)) {
128 for (unsigned int i = 0; i < error_nframes_; ++i) {
129 if (error_frames_[i] == nframes_ - 1) {
130 std::cout << " Skipping decoding frame: "
131 << error_frames_[i] << "\n";
132 return 0;
133 }
134 }
135 }
136 return 1;
137 }
138
139 virtual void MismatchHook(const vpx_image_t *img1,
140 const vpx_image_t *img2) {
141 double mismatch_psnr = compute_psnr(img1, img2);
142 mismatch_psnr_ += mismatch_psnr;
143 ++mismatch_nframes_;
144 // std::cout << "Mismatch frame psnr: " << mismatch_psnr << "\n";
145 }
146
147 void SetErrorFrames(int num, unsigned int *list) {
148 if (num > kMaxErrorFrames)
149 num = kMaxErrorFrames;
150 else if (num < 0)
151 num = 0;
152 error_nframes_ = num;
153 for (unsigned int i = 0; i < error_nframes_; ++i)
154 error_frames_[i] = list[i];
155 }
156
157 void SetDroppableFrames(int num, unsigned int *list) {
158 if (num > kMaxDroppableFrames)
159 num = kMaxDroppableFrames;
160 else if (num < 0)
161 num = 0;
162 droppable_nframes_ = num;
163 for (unsigned int i = 0; i < droppable_nframes_; ++i)
164 droppable_frames_[i] = list[i];
165 }
166
167 unsigned int GetMismatchFrames() {
168 return mismatch_nframes_;
169 }
170
Adrian Grangecc017ca2012-10-02 12:16:27 -0700171 private:
172 double psnr_;
173 unsigned int nframes_;
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800174 unsigned int error_nframes_;
175 unsigned int droppable_nframes_;
176 double mismatch_psnr_;
177 unsigned int mismatch_nframes_;
178 unsigned int error_frames_[kMaxErrorFrames];
179 unsigned int droppable_frames_[kMaxDroppableFrames];
Adrian Grangecc017ca2012-10-02 12:16:27 -0700180 libvpx_test::TestMode encoding_mode_;
181};
182
Jim Bankoskia0b5ed62014-03-12 08:13:16 -0700183TEST_P(ErrorResilienceTestLarge, OnVersusOff) {
Adrian Grangecc017ca2012-10-02 12:16:27 -0700184 const vpx_rational timebase = { 33333333, 1000000000 };
185 cfg_.g_timebase = timebase;
186 cfg_.rc_target_bitrate = 2000;
Deb Mukherjee0d8723f2013-08-19 14:16:26 -0700187 cfg_.g_lag_in_frames = 10;
Adrian Grangecc017ca2012-10-02 12:16:27 -0700188
189 init_flags_ = VPX_CODEC_USE_PSNR;
190
191 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
192 timebase.den, timebase.num, 0, 30);
193
194 // Error resilient mode OFF.
195 cfg_.g_error_resilient = 0;
196 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
197 const double psnr_resilience_off = GetAveragePsnr();
198 EXPECT_GT(psnr_resilience_off, 25.0);
199
200 // Error resilient mode ON.
201 cfg_.g_error_resilient = 1;
202 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
203 const double psnr_resilience_on = GetAveragePsnr();
204 EXPECT_GT(psnr_resilience_on, 25.0);
205
206 // Test that turning on error resilient mode hurts by 10% at most.
207 if (psnr_resilience_off > 0.0) {
208 const double psnr_ratio = psnr_resilience_on / psnr_resilience_off;
209 EXPECT_GE(psnr_ratio, 0.9);
210 EXPECT_LE(psnr_ratio, 1.1);
211 }
212}
213
Marco Paniconif61b9622014-02-24 18:14:50 -0800214// Check for successful decoding and no encoder/decoder mismatch
215// if we lose (i.e., drop before decoding) a set of droppable
216// frames (i.e., frames that don't update any reference buffers).
217// Check both isolated and consecutive loss.
Jim Bankoskia0b5ed62014-03-12 08:13:16 -0700218TEST_P(ErrorResilienceTestLarge, DropFramesWithoutRecovery) {
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800219 const vpx_rational timebase = { 33333333, 1000000000 };
220 cfg_.g_timebase = timebase;
John Koleszarc0490a52013-05-07 12:58:32 -0700221 cfg_.rc_target_bitrate = 500;
Deb Mukherjee0d8723f2013-08-19 14:16:26 -0700222 // FIXME(debargha): Fix this to work for any lag.
223 // Currently this test only works for lag = 0
224 cfg_.g_lag_in_frames = 0;
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800225
226 init_flags_ = VPX_CODEC_USE_PSNR;
227
228 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
Marco Paniconif61b9622014-02-24 18:14:50 -0800229 timebase.den, timebase.num, 0, 40);
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800230
231 // Error resilient mode ON.
232 cfg_.g_error_resilient = 1;
Marco Paniconif61b9622014-02-24 18:14:50 -0800233 cfg_.kf_mode = VPX_KF_DISABLED;
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800234
Marco Paniconif61b9622014-02-24 18:14:50 -0800235 // Set an arbitrary set of error frames same as droppable frames.
236 // In addition to isolated loss/drop, add a long consecutive series
237 // (of size 9) of dropped frames.
238 unsigned int num_droppable_frames = 11;
239 unsigned int droppable_frame_list[] = {5, 16, 22, 23, 24, 25, 26, 27, 28,
240 29, 30};
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800241 SetDroppableFrames(num_droppable_frames, droppable_frame_list);
242 SetErrorFrames(num_droppable_frames, droppable_frame_list);
243 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
244 // Test that no mismatches have been found
245 std::cout << " Mismatch frames: "
246 << GetMismatchFrames() << "\n";
247 EXPECT_EQ(GetMismatchFrames(), (unsigned int) 0);
248
Marco Paniconif61b9622014-02-24 18:14:50 -0800249 // Reset previously set of error/droppable frames.
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800250 Reset();
251
John Koleszar9fba0342013-05-07 13:02:45 -0700252#if 0
253 // TODO(jkoleszar): This test is disabled for the time being as too
254 // sensitive. It's not clear how to set a reasonable threshold for
255 // this behavior.
256
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800257 // Now set an arbitrary set of error frames that are non-droppable
258 unsigned int num_error_frames = 3;
259 unsigned int error_frame_list[] = {3, 10, 20};
260 SetErrorFrames(num_error_frames, error_frame_list);
261 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
John Koleszar9fba0342013-05-07 13:02:45 -0700262
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800263 // Test that dropping an arbitrary set of inter frames does not hurt too much
264 // Note the Average Mismatch PSNR is the average of the PSNR between
265 // decoded frame and encoder's version of the same frame for all frames
266 // with mismatch.
267 const double psnr_resilience_mismatch = GetAverageMismatchPsnr();
268 std::cout << " Mismatch PSNR: "
269 << psnr_resilience_mismatch << "\n";
270 EXPECT_GT(psnr_resilience_mismatch, 20.0);
John Koleszar9fba0342013-05-07 13:02:45 -0700271#endif
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800272}
273
Marco8fd55252014-10-29 15:34:18 -0700274// Check for successful decoding and no encoder/decoder mismatch
275// if we lose (i.e., drop before decoding) the enhancement layer frames for a
276// two layer temporal pattern. The base layer does not predict from the top
277// layer, so successful decoding is expected.
278TEST_P(ErrorResilienceTestLarge, 2LayersDropEnhancement) {
279 const vpx_rational timebase = { 33333333, 1000000000 };
280 cfg_.g_timebase = timebase;
281 cfg_.rc_target_bitrate = 500;
282 cfg_.g_lag_in_frames = 0;
283
284 cfg_.rc_end_usage = VPX_CBR;
285 // 2 Temporal layers, no spatial layers, CBR mode.
286 cfg_.ss_number_layers = 1;
287 cfg_.ts_number_layers = 2;
288 cfg_.ts_rate_decimator[0] = 2;
289 cfg_.ts_rate_decimator[1] = 1;
290 cfg_.ts_periodicity = 2;
291 cfg_.ts_target_bitrate[0] = 60 * cfg_.rc_target_bitrate / 100;
292 cfg_.ts_target_bitrate[1] = cfg_.rc_target_bitrate;
293
294 init_flags_ = VPX_CODEC_USE_PSNR;
295
296 libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
297 timebase.den, timebase.num, 0, 40);
298
299 // Error resilient mode ON.
300 cfg_.g_error_resilient = 1;
301 cfg_.kf_mode = VPX_KF_DISABLED;
302
303 // The odd frames are the enhancement layer for 2 layer pattern, so set
304 // those frames as droppable. Drop the last 7 frames.
305 unsigned int num_droppable_frames = 7;
306 unsigned int droppable_frame_list[] = {27, 29, 31, 33, 35, 37, 39};
307 SetDroppableFrames(num_droppable_frames, droppable_frame_list);
308 SetErrorFrames(num_droppable_frames, droppable_frame_list);
309 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
310 // Test that no mismatches have been found
311 std::cout << " Mismatch frames: "
312 << GetMismatchFrames() << "\n";
313 EXPECT_EQ(GetMismatchFrames(), (unsigned int) 0);
314
315 // Reset previously set of error/droppable frames.
316 Reset();
317}
318
Marcoaf898b52014-11-10 13:07:05 -0800319class ErrorResilienceTestLargeCodecControls : public ::libvpx_test::EncoderTest,
320 public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
321 protected:
322 ErrorResilienceTestLargeCodecControls()
323 : EncoderTest(GET_PARAM(0)),
324 encoding_mode_(GET_PARAM(1)) {
325 Reset();
326 }
Deb Mukherjee01cafaa2013-01-15 06:43:35 -0800327
Marcoaf898b52014-11-10 13:07:05 -0800328 virtual ~ErrorResilienceTestLargeCodecControls() {}
329
330 void Reset() {
331 last_pts_ = 0;
332 tot_frame_number_ = 0;
333 // For testing up to 3 layers.
334 for (int i = 0; i < 3; ++i) {
335 bits_total_[i] = 0;
336 }
337 duration_ = 0.0;
338 }
339
340 virtual void SetUp() {
341 InitializeConfig();
342 SetMode(encoding_mode_);
343 }
344
345 //
346 // Frame flags and layer id for temporal layers.
347 //
348
349 // For two layers, test pattern is:
350 // 1 3
351 // 0 2 .....
352 // For three layers, test pattern is:
353 // 1 3 5 7
354 // 2 6
355 // 0 4 ....
356 // LAST is always update on base/layer 0, GOLDEN is updated on layer 1,
357 // and ALTREF is updated on top layer for 3 layer pattern.
358 int SetFrameFlags(int frame_num, int num_temp_layers) {
359 int frame_flags = 0;
360 if (num_temp_layers == 2) {
361 if (frame_num % 2 == 0) {
362 // Layer 0: predict from L and ARF, update L.
363 frame_flags = VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_UPD_GF |
364 VP8_EFLAG_NO_UPD_ARF;
365 } else {
366 // Layer 1: predict from L, G and ARF, and update G.
367 frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
368 VP8_EFLAG_NO_UPD_ENTROPY;
369 }
370 } else if (num_temp_layers == 3) {
371 if (frame_num % 4 == 0) {
372 // Layer 0: predict from L, update L.
373 frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF |
374 VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF;
375 } else if ((frame_num - 2) % 4 == 0) {
376 // Layer 1: predict from L, G, update G.
377 frame_flags = VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_UPD_LAST |
378 VP8_EFLAG_NO_REF_ARF;
379 } else if ((frame_num - 1) % 2 == 0) {
380 // Layer 2: predict from L, G, ARF; update ARG.
381 frame_flags = VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_LAST;
382 }
383 }
384 return frame_flags;
385 }
386
387 int SetLayerId(int frame_num, int num_temp_layers) {
388 int layer_id = 0;
389 if (num_temp_layers == 2) {
390 if (frame_num % 2 == 0) {
391 layer_id = 0;
392 } else {
393 layer_id = 1;
394 }
395 } else if (num_temp_layers == 3) {
396 if (frame_num % 4 == 0) {
397 layer_id = 0;
398 } else if ((frame_num - 2) % 4 == 0) {
399 layer_id = 1;
400 } else if ((frame_num - 1) % 2 == 0) {
401 layer_id = 2;
402 }
403 }
404 return layer_id;
405 }
406
407 virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
408 libvpx_test::Encoder *encoder) {
409 if (cfg_.ts_number_layers > 1) {
410 int layer_id = SetLayerId(video->frame(), cfg_.ts_number_layers);
411 int frame_flags = SetFrameFlags(video->frame(), cfg_.ts_number_layers);
412 if (video->frame() > 0) {
413 encoder->Control(VP8E_SET_TEMPORAL_LAYER_ID, layer_id);
414 encoder->Control(VP8E_SET_FRAME_FLAGS, frame_flags);
415 }
416 const vpx_rational_t tb = video->timebase();
417 timebase_ = static_cast<double>(tb.num) / tb.den;
418 duration_ = 0;
419 return;
420 }
421 }
422
423 virtual void FramePktHook(const vpx_codec_cx_pkt_t *pkt) {
424 // Time since last timestamp = duration.
425 vpx_codec_pts_t duration = pkt->data.frame.pts - last_pts_;
426 if (duration > 1) {
427 // Update counter for total number of frames (#frames input to encoder).
428 // Needed for setting the proper layer_id below.
429 tot_frame_number_ += static_cast<int>(duration - 1);
430 }
431 int layer = SetLayerId(tot_frame_number_, cfg_.ts_number_layers);
432 const size_t frame_size_in_bits = pkt->data.frame.sz * 8;
433 // Update the total encoded bits. For temporal layers, update the cumulative
434 // encoded bits per layer.
435 for (int i = layer; i < static_cast<int>(cfg_.ts_number_layers); ++i) {
436 bits_total_[i] += frame_size_in_bits;
437 }
438 // Update the most recent pts.
439 last_pts_ = pkt->data.frame.pts;
440 ++tot_frame_number_;
441 }
442
443 virtual void EndPassHook(void) {
444 duration_ = (last_pts_ + 1) * timebase_;
445 if (cfg_.ts_number_layers > 1) {
446 for (int layer = 0; layer < static_cast<int>(cfg_.ts_number_layers);
447 ++layer) {
448 if (bits_total_[layer]) {
449 // Effective file datarate:
450 effective_datarate_[layer] = (bits_total_[layer] / 1000.0) / duration_;
451 }
452 }
453 }
454 }
455
456 double effective_datarate_[3];
457 private:
458 libvpx_test::TestMode encoding_mode_;
459 vpx_codec_pts_t last_pts_;
460 double timebase_;
461 int64_t bits_total_[3];
462 double duration_;
463 int tot_frame_number_;
464 };
465
466// Check two codec controls used for:
467// (1) for setting temporal layer id, and (2) for settings encoder flags.
468// This test invokes those controls for each frame, and verifies encoder/decoder
469// mismatch and basic rate control response.
470// TODO(marpan): Maybe move this test to datarate_test.cc.
471TEST_P(ErrorResilienceTestLargeCodecControls, CodecControl3TemporalLayers) {
472 cfg_.rc_buf_initial_sz = 500;
473 cfg_.rc_buf_optimal_sz = 500;
474 cfg_.rc_buf_sz = 1000;
475 cfg_.rc_dropframe_thresh = 1;
476 cfg_.rc_min_quantizer = 2;
477 cfg_.rc_max_quantizer = 56;
478 cfg_.rc_end_usage = VPX_CBR;
479 cfg_.rc_dropframe_thresh = 1;
480 cfg_.g_lag_in_frames = 0;
481 cfg_.kf_mode = VPX_KF_DISABLED;
482 cfg_.g_error_resilient = 1;
483
484 // 3 Temporal layers. Framerate decimation (4, 2, 1).
485 cfg_.ts_number_layers = 3;
486 cfg_.ts_rate_decimator[0] = 4;
487 cfg_.ts_rate_decimator[1] = 2;
488 cfg_.ts_rate_decimator[2] = 1;
489 cfg_.ts_periodicity = 4;
490 cfg_.ts_layer_id[0] = 0;
491 cfg_.ts_layer_id[1] = 2;
492 cfg_.ts_layer_id[2] = 1;
493 cfg_.ts_layer_id[3] = 2;
494
495 ::libvpx_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
496 30, 1, 0, 200);
497 for (int i = 200; i <= 800; i += 200) {
498 cfg_.rc_target_bitrate = i;
499 Reset();
500 // 40-20-40 bitrate allocation for 3 temporal layers.
501 cfg_.ts_target_bitrate[0] = 40 * cfg_.rc_target_bitrate / 100;
502 cfg_.ts_target_bitrate[1] = 60 * cfg_.rc_target_bitrate / 100;
503 cfg_.ts_target_bitrate[2] = cfg_.rc_target_bitrate;
504 ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
505 for (int j = 0; j < static_cast<int>(cfg_.ts_number_layers); ++j) {
506 ASSERT_GE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 0.75)
507 << " The datarate for the file is lower than target by too much, "
508 "for layer: " << j;
509 ASSERT_LE(effective_datarate_[j], cfg_.ts_target_bitrate[j] * 1.25)
510 << " The datarate for the file is greater than target by too much, "
511 "for layer: " << j;
512 }
513 }
514}
515
516VP8_INSTANTIATE_TEST_CASE(ErrorResilienceTestLarge, ONE_PASS_TEST_MODES);
517VP8_INSTANTIATE_TEST_CASE(ErrorResilienceTestLargeCodecControls,
518 ONE_PASS_TEST_MODES);
519VP9_INSTANTIATE_TEST_CASE(ErrorResilienceTestLarge, ONE_PASS_TEST_MODES);
Adrian Grangecc017ca2012-10-02 12:16:27 -0700520} // namespace