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

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.cc

Issue 2903163002: Add unit tests for qp parser. (Closed)
Patch Set: Fix test failure. Created 3 years, 6 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 encoded_frame_writer_(encoded_frame_writer), 140 encoded_frame_writer_(encoded_frame_writer),
141 decoded_frame_writer_(decoded_frame_writer), 141 decoded_frame_writer_(decoded_frame_writer),
142 bit_rate_factor_(config.codec_settings->maxFramerate * 0.001 * 8), 142 bit_rate_factor_(config.codec_settings->maxFramerate * 0.001 * 8),
143 initialized_(false), 143 initialized_(false),
144 last_encoded_frame_num_(-1), 144 last_encoded_frame_num_(-1),
145 last_decoded_frame_num_(-1), 145 last_decoded_frame_num_(-1),
146 first_key_frame_has_been_excluded_(false), 146 first_key_frame_has_been_excluded_(false),
147 last_decoded_frame_buffer_(0, analysis_frame_reader->FrameLength()), 147 last_decoded_frame_buffer_(0, analysis_frame_reader->FrameLength()),
148 stats_(stats), 148 stats_(stats),
149 num_dropped_frames_(0), 149 num_dropped_frames_(0),
150 num_spatial_resizes_(0) { 150 num_spatial_resizes_(0),
151 qp_encoder_(0),
152 qp_bitstream_(0) {
151 RTC_DCHECK(encoder); 153 RTC_DCHECK(encoder);
152 RTC_DCHECK(decoder); 154 RTC_DCHECK(decoder);
153 RTC_DCHECK(packet_manipulator); 155 RTC_DCHECK(packet_manipulator);
154 RTC_DCHECK(analysis_frame_reader); 156 RTC_DCHECK(analysis_frame_reader);
155 RTC_DCHECK(analysis_frame_writer); 157 RTC_DCHECK(analysis_frame_writer);
156 RTC_DCHECK(stats); 158 RTC_DCHECK(stats);
157 159
158 frame_infos_.reserve(num_frames_); 160 frame_infos_.reserve(num_frames_);
159 } 161 }
160 162
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 frame_stat->encoding_successful = true; 355 frame_stat->encoding_successful = true;
354 frame_stat->encoded_frame_length_in_bytes = encoded_image._length; 356 frame_stat->encoded_frame_length_in_bytes = encoded_image._length;
355 frame_stat->frame_number = frame_number; 357 frame_stat->frame_number = frame_number;
356 frame_stat->frame_type = encoded_image._frameType; 358 frame_stat->frame_type = encoded_image._frameType;
357 frame_stat->qp = encoded_image.qp_; 359 frame_stat->qp = encoded_image.qp_;
358 frame_stat->bit_rate_in_kbps = encoded_image._length * bit_rate_factor_; 360 frame_stat->bit_rate_in_kbps = encoded_image._length * bit_rate_factor_;
359 frame_stat->total_packets = 361 frame_stat->total_packets =
360 encoded_image._length / config_.networking_config.packet_size_in_bytes + 362 encoded_image._length / config_.networking_config.packet_size_in_bytes +
361 1; 363 1;
362 364
365 // Get qp from the encoder and the parser.
366 qp_encoder_ = encoded_image.qp_;
brandtr 2017/05/26 07:18:45 Move to after line 351, and add to |frame_info| in
jianj 2017/05/26 18:20:27 Done.
367 if (codec == kVideoCodecVP8) {
368 vp8::GetQp(encoded_image._buffer, encoded_image._length, &qp_bitstream_);
brandtr 2017/05/26 07:18:45 These too :)
jianj 2017/05/26 18:20:27 Done.
369 } else if (codec == kVideoCodecVP9) {
370 vp9::GetQp(encoded_image._buffer, encoded_image._length, &qp_bitstream_);
371 }
372
363 // Simulate packet loss. 373 // Simulate packet loss.
364 bool exclude_this_frame = false; 374 bool exclude_this_frame = false;
365 if (encoded_image._frameType == kVideoFrameKey) { 375 if (encoded_image._frameType == kVideoFrameKey) {
366 // Only keyframes can be excluded. 376 // Only keyframes can be excluded.
367 switch (config_.exclude_frame_types) { 377 switch (config_.exclude_frame_types) {
368 case kExcludeOnlyFirstKeyFrame: 378 case kExcludeOnlyFirstKeyFrame:
369 if (!first_key_frame_has_been_excluded_) { 379 if (!first_key_frame_has_been_excluded_) {
370 first_key_frame_has_been_excluded_ = true; 380 first_key_frame_has_been_excluded_ = true;
371 exclude_this_frame = true; 381 exclude_this_frame = true;
372 } 382 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 analysis_frame_writer_->WriteFrame(last_decoded_frame_buffer_.data())); 426 analysis_frame_writer_->WriteFrame(last_decoded_frame_buffer_.data()));
417 if (decoded_frame_writer_) { 427 if (decoded_frame_writer_) {
418 RTC_DCHECK_EQ(last_decoded_frame_buffer_.size(), 428 RTC_DCHECK_EQ(last_decoded_frame_buffer_.size(),
419 decoded_frame_writer_->FrameLength()); 429 decoded_frame_writer_->FrameLength());
420 RTC_CHECK( 430 RTC_CHECK(
421 decoded_frame_writer_->WriteFrame(last_decoded_frame_buffer_.data())); 431 decoded_frame_writer_->WriteFrame(last_decoded_frame_buffer_.data()));
422 } 432 }
423 } 433 }
424 } 434 }
425 435
436 int VideoProcessorImpl::GetQpFromEncoder() {
brandtr 2017/05/26 07:18:45 After moving the declarations in the .h file, plea
jianj 2017/05/26 18:20:27 Done.
437 return qp_encoder_;
438 }
439
440 int VideoProcessorImpl::GetQpFromBitstream() {
441 return qp_bitstream_;
442 }
443
426 void VideoProcessorImpl::FrameDecoded(const VideoFrame& image) { 444 void VideoProcessorImpl::FrameDecoded(const VideoFrame& image) {
427 // For the highest measurement accuracy of the decode time, the start/stop 445 // For the highest measurement accuracy of the decode time, the start/stop
428 // time recordings should wrap the Decode call as tightly as possible. 446 // time recordings should wrap the Decode call as tightly as possible.
429 int64_t decode_stop_ns = rtc::TimeNanos(); 447 int64_t decode_stop_ns = rtc::TimeNanos();
430 448
431 // Update frame information and statistics. 449 // Update frame information and statistics.
432 int frame_number = TimestampToFrameNumber(image.timestamp()); 450 int frame_number = TimestampToFrameNumber(image.timestamp());
433 RTC_DCHECK_LT(frame_number, frame_infos_.size()); 451 RTC_DCHECK_LT(frame_number, frame_infos_.size());
434 FrameInfo* frame_info = &frame_infos_[frame_number]; 452 FrameInfo* frame_info = &frame_infos_[frame_number];
435 frame_info->decoded_width = image.width(); 453 frame_info->decoded_width = image.width();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 if (decoded_frame_writer_) { 515 if (decoded_frame_writer_) {
498 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); 516 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength());
499 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); 517 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data()));
500 } 518 }
501 519
502 last_decoded_frame_buffer_ = std::move(extracted_buffer); 520 last_decoded_frame_buffer_ = std::move(extracted_buffer);
503 } 521 }
504 522
505 } // namespace test 523 } // namespace test
506 } // namespace webrtc 524 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698