Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor_integrationtest.h

Issue 2707023008: Step #2: Add batch mode to VideoProcessor integration tests. (Closed)
Patch Set: Nits. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC 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 10
(...skipping 10 matching lines...) Expand all
21 #include "webrtc/modules/video_coding/codecs/test/android_test_initializer.h" 21 #include "webrtc/modules/video_coding/codecs/test/android_test_initializer.h"
22 #include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h" 22 #include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h"
23 #include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h" 23 #include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h"
24 #elif defined(WEBRTC_IOS) 24 #elif defined(WEBRTC_IOS)
25 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h" 25 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h"
26 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h" 26 #include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h"
27 #endif 27 #endif
28 28
29 #include "webrtc/base/checks.h" 29 #include "webrtc/base/checks.h"
30 #include "webrtc/base/file.h" 30 #include "webrtc/base/file.h"
31 #include "webrtc/base/logging.h"
31 #include "webrtc/media/engine/webrtcvideodecoderfactory.h" 32 #include "webrtc/media/engine/webrtcvideodecoderfactory.h"
32 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" 33 #include "webrtc/media/engine/webrtcvideoencoderfactory.h"
33 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 34 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
34 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h" 35 #include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
35 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h" 36 #include "webrtc/modules/video_coding/codecs/test/videoprocessor.h"
36 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 37 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
37 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" 38 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
38 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 39 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
39 #include "webrtc/modules/video_coding/include/video_codec_interface.h" 40 #include "webrtc/modules/video_coding/include/video_codec_interface.h"
40 #include "webrtc/modules/video_coding/include/video_coding.h" 41 #include "webrtc/modules/video_coding/include/video_coding.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 int key_frame_interval; 78 int key_frame_interval;
78 bool error_concealment_on; 79 bool error_concealment_on;
79 bool denoising_on; 80 bool denoising_on;
80 bool frame_dropper_on; 81 bool frame_dropper_on;
81 bool spatial_resize_on; 82 bool spatial_resize_on;
82 83
83 float packet_loss_probability; // [0.0, 1.0]. 84 float packet_loss_probability; // [0.0, 1.0].
84 85
85 std::string filename; 86 std::string filename;
86 bool verbose_logging; 87 bool verbose_logging;
88
89 // In batch mode, the VideoProcessor is fed all the frames for processing
90 // before any metrics are calculated. This is useful for pipelining HW codecs,
91 // for which some calculated metrics otherwise would be incorrect. The
92 // downside with batch mode is that mid-test rate allocation is not supported.
93 bool batch_mode;
87 }; 94 };
88 95
89 // Thresholds for the quality metrics. 96 // Thresholds for the quality metrics.
90 struct QualityThresholds { 97 struct QualityThresholds {
91 double min_avg_psnr; 98 double min_avg_psnr;
92 double min_min_psnr; 99 double min_min_psnr;
93 double min_avg_ssim; 100 double min_avg_ssim;
94 double min_min_ssim; 101 double min_min_ssim;
95 }; 102 };
96 103
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 processor_.reset(new test::VideoProcessorImpl( 342 processor_.reset(new test::VideoProcessorImpl(
336 encoder_.get(), decoder_.get(), analysis_frame_reader_.get(), 343 encoder_.get(), decoder_.get(), analysis_frame_reader_.get(),
337 analysis_frame_writer_.get(), packet_manipulator_.get(), config_, 344 analysis_frame_writer_.get(), packet_manipulator_.get(), config_,
338 &stats_, source_frame_writer_.get(), encoded_frame_writer_.get(), 345 &stats_, source_frame_writer_.get(), encoded_frame_writer_.get(),
339 decoded_frame_writer_.get())); 346 decoded_frame_writer_.get()));
340 RTC_CHECK(processor_->Init()); 347 RTC_CHECK(processor_->Init());
341 } 348 }
342 349
343 // Reset quantities after each encoder update, update the target 350 // Reset quantities after each encoder update, update the target
344 // per-frame bandwidth. 351 // per-frame bandwidth.
345 void ResetRateControlMetrics(int num_frames) { 352 void ResetRateControlMetrics(int num_frames_to_hit_target) {
346 for (int i = 0; i < num_temporal_layers_; i++) { 353 for (int i = 0; i < num_temporal_layers_; i++) {
347 num_frames_per_update_[i] = 0; 354 num_frames_per_update_[i] = 0;
348 sum_frame_size_mismatch_[i] = 0.0f; 355 sum_frame_size_mismatch_[i] = 0.0f;
349 sum_encoded_frame_size_[i] = 0.0f; 356 sum_encoded_frame_size_[i] = 0.0f;
350 encoding_bitrate_[i] = 0.0f; 357 encoding_bitrate_[i] = 0.0f;
351 // Update layer per-frame-bandwidth. 358 // Update layer per-frame-bandwidth.
352 per_frame_bandwidth_[i] = static_cast<float>(bit_rate_layer_[i]) / 359 per_frame_bandwidth_[i] = static_cast<float>(bit_rate_layer_[i]) /
353 static_cast<float>(frame_rate_layer_[i]); 360 static_cast<float>(frame_rate_layer_[i]);
354 } 361 }
355 // Set maximum size of key frames, following setting in the VP8 wrapper. 362 // Set maximum size of key frames, following setting in the VP8 wrapper.
356 float max_key_size = kScaleKeyFrameSize * kOptimalBufferSize * frame_rate_; 363 float max_key_size = kScaleKeyFrameSize * kOptimalBufferSize * frame_rate_;
357 // We don't know exact target size of the key frames (except for first one), 364 // We don't know exact target size of the key frames (except for first one),
358 // but the minimum in libvpx is ~|3 * per_frame_bandwidth| and maximum is 365 // but the minimum in libvpx is ~|3 * per_frame_bandwidth| and maximum is
359 // set by |max_key_size_ * per_frame_bandwidth|. Take middle point/average 366 // set by |max_key_size_ * per_frame_bandwidth|. Take middle point/average
360 // as reference for mismatch. Note key frames always correspond to base 367 // as reference for mismatch. Note key frames always correspond to base
361 // layer frame in this test. 368 // layer frame in this test.
362 target_size_key_frame_ = 0.5 * (3 + max_key_size) * per_frame_bandwidth_[0]; 369 target_size_key_frame_ = 0.5 * (3 + max_key_size) * per_frame_bandwidth_[0];
363 num_frames_total_ = 0; 370 num_frames_total_ = 0;
364 sum_encoded_frame_size_total_ = 0.0f; 371 sum_encoded_frame_size_total_ = 0.0f;
365 encoding_bitrate_total_ = 0.0f; 372 encoding_bitrate_total_ = 0.0f;
366 perc_encoding_rate_mismatch_ = 0.0f; 373 perc_encoding_rate_mismatch_ = 0.0f;
367 num_frames_to_hit_target_ = num_frames; 374 num_frames_to_hit_target_ = num_frames_to_hit_target;
368 encoding_rate_within_target_ = false; 375 encoding_rate_within_target_ = false;
369 sum_key_frame_size_mismatch_ = 0.0; 376 sum_key_frame_size_mismatch_ = 0.0;
370 num_key_frames_ = 0; 377 num_key_frames_ = 0;
371 } 378 }
372 379
373 // For every encoded frame, update the rate control metrics. 380 // For every encoded frame, update the rate control metrics.
374 void UpdateRateControlMetrics(int frame_num, FrameType frame_type) { 381 void UpdateRateControlMetrics(int frame_number,
375 float encoded_size_kbits = processor_->EncodedFrameSize() * 8.0f / 1000.0f; 382 FrameType frame_type,
383 size_t encoded_frame_size) {
384 RTC_CHECK_GE(frame_number, 0);
385 int layer = LayerIndexForFrame(frame_number);
sprang_webrtc 2017/03/08 16:20:21 Not obvious to me which layer this refers to?
brandtr 2017/03/09 15:18:27 This function returns what TL this frame belongs t
386 float encoded_size_kbits = encoded_frame_size * 8.0f / 1000.0f;
387
376 // Update layer data. 388 // Update layer data.
377 // Update rate mismatch relative to per-frame bandwidth for delta frames. 389 // Update rate mismatch relative to per-frame bandwidth for delta frames.
378 if (frame_type == kVideoFrameDelta) { 390 if (frame_type == kVideoFrameDelta) {
379 // TODO(marpan): Should we count dropped (zero size) frames in mismatch? 391 // TODO(marpan): Should we count dropped (zero size) frames in mismatch?
380 sum_frame_size_mismatch_[layer_] += 392 sum_frame_size_mismatch_[layer] +=
381 fabs(encoded_size_kbits - per_frame_bandwidth_[layer_]) / 393 fabs(encoded_size_kbits - per_frame_bandwidth_[layer]) /
382 per_frame_bandwidth_[layer_]; 394 per_frame_bandwidth_[layer];
383 } else { 395 } else {
384 float target_size = (frame_num == 1) ? target_size_key_frame_initial_ 396 float target_size = (frame_number == 0) ? target_size_key_frame_initial_
385 : target_size_key_frame_; 397 : target_size_key_frame_;
386 sum_key_frame_size_mismatch_ += 398 sum_key_frame_size_mismatch_ +=
387 fabs(encoded_size_kbits - target_size) / target_size; 399 fabs(encoded_size_kbits - target_size) / target_size;
388 num_key_frames_ += 1; 400 num_key_frames_ += 1;
389 } 401 }
390 sum_encoded_frame_size_[layer_] += encoded_size_kbits; 402 sum_encoded_frame_size_[layer] += encoded_size_kbits;
391 // Encoding bitrate per layer: from the start of the update/run to the 403 // Encoding bit rate per layer: from the start of the update/run to the
392 // current frame. 404 // current frame.
393 encoding_bitrate_[layer_] = sum_encoded_frame_size_[layer_] * 405 encoding_bitrate_[layer] = sum_encoded_frame_size_[layer] *
394 frame_rate_layer_[layer_] / 406 frame_rate_layer_[layer] /
395 num_frames_per_update_[layer_]; 407 num_frames_per_update_[layer];
396 // Total encoding rate: from the start of the update/run to current frame. 408 // Total encoding rate: from the start of the update/run to current frame.
397 sum_encoded_frame_size_total_ += encoded_size_kbits; 409 sum_encoded_frame_size_total_ += encoded_size_kbits;
398 encoding_bitrate_total_ = 410 encoding_bitrate_total_ =
399 sum_encoded_frame_size_total_ * frame_rate_ / num_frames_total_; 411 sum_encoded_frame_size_total_ * frame_rate_ / num_frames_total_;
400 perc_encoding_rate_mismatch_ = 412 perc_encoding_rate_mismatch_ =
401 100 * fabs(encoding_bitrate_total_ - bit_rate_) / bit_rate_; 413 100 * fabs(encoding_bitrate_total_ - bit_rate_) / bit_rate_;
402 if (perc_encoding_rate_mismatch_ < kPercTargetvsActualMismatch && 414 if (perc_encoding_rate_mismatch_ < kPercTargetvsActualMismatch &&
403 !encoding_rate_within_target_) { 415 !encoding_rate_within_target_) {
404 num_frames_to_hit_target_ = num_frames_total_; 416 num_frames_to_hit_target_ = num_frames_total_;
405 encoding_rate_within_target_ = true; 417 encoding_rate_within_target_ = true;
406 } 418 }
407 } 419 }
408 420
409 // Verify expected behavior of rate control and print out data. 421 // Verify expected behavior of rate control and print out data.
410 void VerifyRateControlMetrics(int update_index, 422 void VerifyRateControlMetrics(int update_index,
423 int num_dropped_frames,
424 int num_resize_actions,
411 const RateControlThresholds& rc_expected) { 425 const RateControlThresholds& rc_expected) {
412 int num_dropped_frames = processor_->NumberDroppedFrames();
413 int num_resize_actions = processor_->NumberSpatialResizes();
414 printf( 426 printf(
415 "For update #: %d,\n" 427 "For update #: %d,\n"
416 " Target Bitrate: %d,\n" 428 " Target Bitrate: %d,\n"
417 " Encoding bitrate: %f,\n" 429 " Encoding bitrate: %f,\n"
418 " Frame rate: %d \n", 430 " Frame rate: %d \n",
419 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_); 431 update_index, bit_rate_, encoding_bitrate_total_, frame_rate_);
420 printf( 432 printf(
421 " Number of frames to approach target rate: %d, \n" 433 " Number of frames to approach target rate: %d, \n"
422 " Number of dropped frames: %d, \n" 434 " Number of dropped frames: %d, \n"
423 " Number of spatial resizes: %d, \n", 435 " Number of spatial resizes: %d, \n",
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } else if ((frame_number + 2) % 4 == 0) { 508 } else if ((frame_number + 2) % 4 == 0) {
497 layer = 1; 509 layer = 1;
498 } else if ((frame_number + 1) % 2 == 0) { 510 } else if ((frame_number + 1) % 2 == 0) {
499 layer = 2; 511 layer = 2;
500 } 512 }
501 break; 513 break;
502 default: 514 default:
503 RTC_NOTREACHED(); 515 RTC_NOTREACHED();
504 break; 516 break;
505 } 517 }
506
507 return layer; 518 return layer;
508 } 519 }
509 520
510 // Set the bitrate and frame rate per layer, for up to 3 layers. 521 // Set the bit rate and frame rate per layer, for up to 3 layers.
511 void SetLayerRates() { 522 void SetLayerRates() {
512 RTC_DCHECK_LE(num_temporal_layers_, kMaxNumTemporalLayers); 523 RTC_DCHECK_LE(num_temporal_layers_, kMaxNumTemporalLayers);
513 for (int i = 0; i < num_temporal_layers_; i++) { 524 for (int i = 0; i < num_temporal_layers_; i++) {
514 float bit_rate_ratio = 525 float bit_rate_ratio =
515 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i]; 526 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i];
516 if (i > 0) { 527 if (i > 0) {
517 float bit_rate_delta_ratio = 528 float bit_rate_delta_ratio =
518 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i] - 529 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i] -
519 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i - 1]; 530 kVp8LayerRateAlloction[num_temporal_layers_ - 1][i - 1];
520 bit_rate_layer_[i] = bit_rate_ * bit_rate_delta_ratio; 531 bit_rate_layer_[i] = bit_rate_ * bit_rate_delta_ratio;
(...skipping 23 matching lines...) Expand all
544 // Update the layers and the codec with the initial rates. 555 // Update the layers and the codec with the initial rates.
545 bit_rate_ = rate_profile.target_bit_rate[0]; 556 bit_rate_ = rate_profile.target_bit_rate[0];
546 frame_rate_ = rate_profile.input_frame_rate[0]; 557 frame_rate_ = rate_profile.input_frame_rate[0];
547 SetLayerRates(); 558 SetLayerRates();
548 // Set the initial target size for key frame. 559 // Set the initial target size for key frame.
549 target_size_key_frame_initial_ = 560 target_size_key_frame_initial_ =
550 0.5 * kInitialBufferSize * bit_rate_layer_[0]; 561 0.5 * kInitialBufferSize * bit_rate_layer_[0];
551 processor_->SetRates(bit_rate_, frame_rate_); 562 processor_->SetRates(bit_rate_, frame_rate_);
552 563
553 // Process each frame, up to |num_frames|. 564 // Process each frame, up to |num_frames|.
565 int frame_number = 0;
566 int update_index = 0;
554 int num_frames = rate_profile.num_frames; 567 int num_frames = rate_profile.num_frames;
555 int update_index = 0;
556 ResetRateControlMetrics( 568 ResetRateControlMetrics(
557 rate_profile.frame_index_rate_update[update_index + 1]); 569 rate_profile.frame_index_rate_update[update_index + 1]);
558 int frame_number = 0; 570
559 FrameType frame_type = kVideoFrameDelta; 571 if (process.batch_mode) {
560 while (processor_->ProcessFrame(frame_number) && 572 // In batch mode, we calculate the metrics for all frames after all frames
561 frame_number < num_frames) { 573 // have been sent for encoding.
562 // Get the layer index for the frame |frame_number|. 574
563 layer_ = LayerIndexForFrame(frame_number); 575 for (frame_number = 0; frame_number < num_frames; ++frame_number) {
åsapersson 2017/03/08 15:26:46 use frame_number <= num_frames and remove the Proc
sprang_webrtc 2017/03/08 16:20:21 Then the expect becomes a little more complicated
brandtr 2017/03/09 15:18:27 asapersson: Done. sprang: The last call to Proces
sprang_webrtc 2017/03/10 09:09:37 Acknowledged.
564 // Get the frame_type. 576 EXPECT_TRUE(processor_->ProcessFrame(frame_number));
565 frame_type = processor_->EncodedFrameType();
566 // Counter for whole sequence run.
567 ++frame_number;
568 // Counters for each rate update.
569 ++num_frames_per_update_[layer_];
570 ++num_frames_total_;
571 UpdateRateControlMetrics(frame_number, frame_type);
572 // If we hit another/next update, verify stats for current state and
573 // update layers and codec with new rates.
574 if (frame_number ==
575 rate_profile.frame_index_rate_update[update_index + 1]) {
576 VerifyRateControlMetrics(update_index, rc_thresholds[update_index]);
577 // Update layer rates and the codec with new rates.
578 ++update_index;
579 bit_rate_ = rate_profile.target_bit_rate[update_index];
580 frame_rate_ = rate_profile.input_frame_rate[update_index];
581 SetLayerRates();
582 ResetRateControlMetrics(
583 rate_profile.frame_index_rate_update[update_index + 1]);
584 processor_->SetRates(bit_rate_, frame_rate_);
585 } 577 }
578 processor_->ProcessFrame(frame_number);
579
580 // Release encoder and decoder to make sure they have finished processing.
581 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release());
582 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release());
583
584 for (frame_number = 0; frame_number < num_frames; ++frame_number) {
585 ++num_frames_per_update_[LayerIndexForFrame(frame_number)];
586 ++num_frames_total_;
587 FrameType frame_type = processor_->EncodedFrameType(frame_number);
588 size_t encoded_frame_size = processor_->EncodedFrameSize(frame_number);
589 UpdateRateControlMetrics(frame_number, frame_type, encoded_frame_size);
590 }
591 } else {
592 // In online mode, we calculate the metrics for a given frame right after
593 // it has been sent for encoding.
594
595 if (process.hw_codec) {
596 LOG(LS_WARNING) << "HW codecs should mostly be run in batch mode, "
597 "since they may be pipelining.";
598 }
599
600 while (frame_number < num_frames) {
601 EXPECT_TRUE(processor_->ProcessFrame(frame_number));
602
603 ++num_frames_per_update_[LayerIndexForFrame(frame_number)];
604 ++num_frames_total_;
605 FrameType frame_type = processor_->EncodedFrameType(frame_number);
606 size_t encoded_frame_size = processor_->EncodedFrameSize(frame_number);
åsapersson 2017/03/08 15:26:46 maybe get frame_type and encoded_frame_size in Upd
brandtr 2017/03/09 15:18:27 Done.
607 UpdateRateControlMetrics(frame_number, frame_type, encoded_frame_size);
608
609 ++frame_number;
610
611 // If we hit another/next update, verify stats for current state and
612 // update layers and codec with new rates.
613 if (frame_number ==
614 rate_profile.frame_index_rate_update[update_index + 1]) {
615 int num_dropped_frames = processor_->NumberDroppedFrames();
616 int num_resize_actions = processor_->NumberSpatialResizes();
åsapersson 2017/03/08 15:26:46 ditto
brandtr 2017/03/09 15:18:27 Done.
åsapersson 2017/03/10 08:43:27 Perhaps same here.
brandtr 2017/03/10 08:48:40 Sorry for missing that.. :/
617 VerifyRateControlMetrics(update_index, num_dropped_frames,
618 num_resize_actions,
619 rc_thresholds[update_index]);
620
621 // Update layer rates and the codec with new rates.
622 ++update_index;
623 bit_rate_ = rate_profile.target_bit_rate[update_index];
624 frame_rate_ = rate_profile.input_frame_rate[update_index];
625 SetLayerRates();
626 ResetRateControlMetrics(
627 rate_profile.frame_index_rate_update[update_index + 1]);
628 processor_->SetRates(bit_rate_, frame_rate_);
629 }
630 }
631 processor_->ProcessFrame(frame_number);
632
633 // Release encoder and decoder to make sure they have finished processing.
634 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release());
635 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release());
586 } 636 }
587 VerifyRateControlMetrics(update_index, rc_thresholds[update_index]); 637
638 // Verify rate control metrics for all frames (if in batch mode), or for all
639 // frames since the last rate update (if not in batch mode).
640 int num_dropped_frames = processor_->NumberDroppedFrames();
641 int num_resize_actions = processor_->NumberSpatialResizes();
642 VerifyRateControlMetrics(update_index, num_dropped_frames,
643 num_resize_actions, rc_thresholds[update_index]);
588 EXPECT_EQ(num_frames, frame_number); 644 EXPECT_EQ(num_frames, frame_number);
589 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size())); 645 EXPECT_EQ(num_frames + 1, static_cast<int>(stats_.stats_.size()));
590 646
591 // Release encoder and decoder to make sure they have finished processing:
592 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, encoder_->Release());
593 EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release());
åsapersson 2017/03/08 15:26:46 maybe make this change if needed in upcoming cl
brandtr 2017/03/09 15:18:27 Done.
594
595 // Close the analysis files before we use them for SSIM/PSNR calculations. 647 // Close the analysis files before we use them for SSIM/PSNR calculations.
596 analysis_frame_reader_->Close(); 648 analysis_frame_reader_->Close();
597 analysis_frame_writer_->Close(); 649 analysis_frame_writer_->Close();
598 650
599 // Close visualization files. 651 // Close visualization files.
600 if (source_frame_writer_) { 652 if (source_frame_writer_) {
601 source_frame_writer_->Close(); 653 source_frame_writer_->Close();
602 } 654 }
603 if (encoded_frame_writer_) { 655 if (encoded_frame_writer_) {
604 encoded_frame_writer_->Close(); 656 EXPECT_TRUE(encoded_frame_writer_->Close());
605 } 657 }
606 if (decoded_frame_writer_) { 658 if (decoded_frame_writer_) {
607 decoded_frame_writer_->Close(); 659 decoded_frame_writer_->Close();
608 } 660 }
609 661
610 // TODO(marpan): Should compute these quality metrics per SetRates update. 662 // TODO(marpan): Should compute these quality metrics per SetRates update.
611 test::QualityMetricsResult psnr_result, ssim_result; 663 test::QualityMetricsResult psnr_result, ssim_result;
612 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(), 664 EXPECT_EQ(0, test::I420MetricsFromFiles(config_.input_filename.c_str(),
613 config_.output_filename.c_str(), 665 config_.output_filename.c_str(),
614 config_.codec_settings->width, 666 config_.codec_settings->width,
(...skipping 18 matching lines...) Expand all
633 float packet_loss_probability, 685 float packet_loss_probability,
634 int key_frame_interval, 686 int key_frame_interval,
635 int num_temporal_layers, 687 int num_temporal_layers,
636 bool error_concealment_on, 688 bool error_concealment_on,
637 bool denoising_on, 689 bool denoising_on,
638 bool frame_dropper_on, 690 bool frame_dropper_on,
639 bool spatial_resize_on, 691 bool spatial_resize_on,
640 int width, 692 int width,
641 int height, 693 int height,
642 const std::string& filename, 694 const std::string& filename,
643 bool verbose_logging) { 695 bool verbose_logging,
696 bool batch_mode) {
644 process_settings->codec_type = codec_type; 697 process_settings->codec_type = codec_type;
645 process_settings->hw_codec = hw_codec; 698 process_settings->hw_codec = hw_codec;
646 process_settings->use_single_core = use_single_core; 699 process_settings->use_single_core = use_single_core;
647 process_settings->packet_loss_probability = packet_loss_probability; 700 process_settings->packet_loss_probability = packet_loss_probability;
648 process_settings->key_frame_interval = key_frame_interval; 701 process_settings->key_frame_interval = key_frame_interval;
649 process_settings->num_temporal_layers = num_temporal_layers, 702 process_settings->num_temporal_layers = num_temporal_layers,
650 process_settings->error_concealment_on = error_concealment_on; 703 process_settings->error_concealment_on = error_concealment_on;
651 process_settings->denoising_on = denoising_on; 704 process_settings->denoising_on = denoising_on;
652 process_settings->frame_dropper_on = frame_dropper_on; 705 process_settings->frame_dropper_on = frame_dropper_on;
653 process_settings->spatial_resize_on = spatial_resize_on; 706 process_settings->spatial_resize_on = spatial_resize_on;
654 process_settings->width = width; 707 process_settings->width = width;
655 process_settings->height = height; 708 process_settings->height = height;
656 process_settings->filename = filename; 709 process_settings->filename = filename;
657 process_settings->verbose_logging = verbose_logging; 710 process_settings->verbose_logging = verbose_logging;
711 process_settings->batch_mode = batch_mode;
658 } 712 }
659 713
660 static void SetCodecParams(CodecParams* process_settings, 714 static void SetCodecParams(CodecParams* process_settings,
661 VideoCodecType codec_type, 715 VideoCodecType codec_type,
662 bool hw_codec, 716 bool hw_codec,
663 bool use_single_core, 717 bool use_single_core,
664 float packet_loss_probability, 718 float packet_loss_probability,
665 int key_frame_interval, 719 int key_frame_interval,
666 int num_temporal_layers, 720 int num_temporal_layers,
667 bool error_concealment_on, 721 bool error_concealment_on,
668 bool denoising_on, 722 bool denoising_on,
669 bool frame_dropper_on, 723 bool frame_dropper_on,
670 bool spatial_resize_on) { 724 bool spatial_resize_on) {
671 SetCodecParams(process_settings, codec_type, hw_codec, use_single_core, 725 SetCodecParams(process_settings, codec_type, hw_codec, use_single_core,
672 packet_loss_probability, key_frame_interval, 726 packet_loss_probability, key_frame_interval,
673 num_temporal_layers, error_concealment_on, denoising_on, 727 num_temporal_layers, error_concealment_on, denoising_on,
674 frame_dropper_on, spatial_resize_on, kCifWidth, kCifHeight, 728 frame_dropper_on, spatial_resize_on, kCifWidth, kCifHeight,
675 kFilenameForemanCif, false /* verbose_logging */); 729 kFilenameForemanCif, false /* verbose_logging */,
730 false /* batch_mode */);
676 } 731 }
677 732
678 static void SetQualityThresholds(QualityThresholds* quality_thresholds, 733 static void SetQualityThresholds(QualityThresholds* quality_thresholds,
679 double min_avg_psnr, 734 double min_avg_psnr,
680 double min_min_psnr, 735 double min_min_psnr,
681 double min_avg_ssim, 736 double min_avg_ssim,
682 double min_min_ssim) { 737 double min_min_ssim) {
683 quality_thresholds->min_avg_psnr = min_avg_psnr; 738 quality_thresholds->min_avg_psnr = min_avg_psnr;
684 quality_thresholds->min_min_psnr = min_min_psnr; 739 quality_thresholds->min_min_psnr = min_min_psnr;
685 quality_thresholds->min_avg_ssim = min_avg_ssim; 740 quality_thresholds->min_avg_ssim = min_avg_ssim;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 float bit_rate_layer_[kMaxNumTemporalLayers]; 804 float bit_rate_layer_[kMaxNumTemporalLayers];
750 float frame_rate_layer_[kMaxNumTemporalLayers]; 805 float frame_rate_layer_[kMaxNumTemporalLayers];
751 int num_frames_total_; 806 int num_frames_total_;
752 float sum_encoded_frame_size_total_; 807 float sum_encoded_frame_size_total_;
753 float encoding_bitrate_total_; 808 float encoding_bitrate_total_;
754 float perc_encoding_rate_mismatch_; 809 float perc_encoding_rate_mismatch_;
755 int num_frames_to_hit_target_; 810 int num_frames_to_hit_target_;
756 bool encoding_rate_within_target_; 811 bool encoding_rate_within_target_;
757 int bit_rate_; 812 int bit_rate_;
758 int frame_rate_; 813 int frame_rate_;
759 int layer_;
760 float target_size_key_frame_initial_; 814 float target_size_key_frame_initial_;
761 float target_size_key_frame_; 815 float target_size_key_frame_;
762 float sum_key_frame_size_mismatch_; 816 float sum_key_frame_size_mismatch_;
763 int num_key_frames_; 817 int num_key_frames_;
764 float start_bitrate_; 818 float start_bitrate_;
765 int start_frame_rate_; 819 int start_frame_rate_;
766 820
767 // Codec and network settings. 821 // Codec and network settings.
768 float packet_loss_probability_; 822 float packet_loss_probability_;
769 int num_temporal_layers_; 823 int num_temporal_layers_;
770 }; 824 };
771 825
772 } // namespace test 826 } // namespace test
773 } // namespace webrtc 827 } // namespace webrtc
774 828
775 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_ 829 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_INTEGRATIONTES T_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698