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

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

Issue 3014623002: Adding test for SingleNalUnit mode (Closed)
Patch Set: Added codec_globals_headers to deps of video_codecs_test_framework Created 3 years, 2 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
11 #include "modules/video_coding/codecs/test/videoprocessor.h" 11 #include "modules/video_coding/codecs/test/videoprocessor.h"
12 12
13 #include <string.h> 13 #include <string.h>
14 14
15 #include <algorithm>
15 #include <limits> 16 #include <limits>
16 #include <memory> 17 #include <memory>
17 #include <utility> 18 #include <utility>
18 #include <vector> 19 #include <vector>
19 20
20 #include "api/video/i420_buffer.h" 21 #include "api/video/i420_buffer.h"
21 #include "common_types.h" // NOLINT(build/include) 22 #include "common_types.h" // NOLINT(build/include)
23 #include "common_video/h264/h264_common.h"
22 #include "modules/video_coding/codecs/vp8/simulcast_rate_allocator.h" 24 #include "modules/video_coding/codecs/vp8/simulcast_rate_allocator.h"
23 #include "modules/video_coding/include/video_codec_initializer.h" 25 #include "modules/video_coding/include/video_codec_initializer.h"
24 #include "modules/video_coding/utility/default_video_bitrate_allocator.h" 26 #include "modules/video_coding/utility/default_video_bitrate_allocator.h"
25 #include "rtc_base/checks.h" 27 #include "rtc_base/checks.h"
26 #include "rtc_base/logging.h" 28 #include "rtc_base/logging.h"
27 #include "rtc_base/timeutils.h" 29 #include "rtc_base/timeutils.h"
28 #include "system_wrappers/include/cpu_info.h" 30 #include "system_wrappers/include/cpu_info.h"
29 #include "test/gtest.h" 31 #include "test/gtest.h"
30 32
31 namespace webrtc { 33 namespace webrtc {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (config.codec_settings.codecType == kVideoCodecVP8) { 103 if (config.codec_settings.codecType == kVideoCodecVP8) {
102 ASSERT_TRUE(vp8::GetQp(encoded_frame._buffer, encoded_frame._length, &qp)); 104 ASSERT_TRUE(vp8::GetQp(encoded_frame._buffer, encoded_frame._length, &qp));
103 } else if (config.codec_settings.codecType == kVideoCodecVP9) { 105 } else if (config.codec_settings.codecType == kVideoCodecVP9) {
104 ASSERT_TRUE(vp9::GetQp(encoded_frame._buffer, encoded_frame._length, &qp)); 106 ASSERT_TRUE(vp9::GetQp(encoded_frame._buffer, encoded_frame._length, &qp));
105 } else { 107 } else {
106 return; 108 return;
107 } 109 }
108 EXPECT_EQ(encoded_frame.qp_, qp) << "Encoder QP != parsed bitstream QP."; 110 EXPECT_EQ(encoded_frame.qp_, qp) << "Encoder QP != parsed bitstream QP.";
109 } 111 }
110 112
113 rtc::Optional<size_t> GetMaxNaluLength(const EncodedImage& encoded_frame,
114 const TestConfig& config) {
115 if (config.codec_settings.codecType != kVideoCodecH264)
116 return rtc::Optional<size_t>();
117
118 std::vector<webrtc::H264::NaluIndex> nalu_indices =
119 webrtc::H264::FindNaluIndices(encoded_frame._buffer,
120 encoded_frame._length);
121
122 RTC_CHECK(!nalu_indices.empty());
123
124 size_t max_length = 0;
125 for (const webrtc::H264::NaluIndex& index : nalu_indices)
126 max_length = std::max(max_length, index.payload_size);
127
128 return rtc::Optional<size_t>(max_length);
129 }
130
111 int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) { 131 int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) {
112 int64_t diff_us = (stop_ns - start_ns) / rtc::kNumNanosecsPerMicrosec; 132 int64_t diff_us = (stop_ns - start_ns) / rtc::kNumNanosecsPerMicrosec;
113 RTC_DCHECK_GE(diff_us, std::numeric_limits<int>::min()); 133 RTC_DCHECK_GE(diff_us, std::numeric_limits<int>::min());
114 RTC_DCHECK_LE(diff_us, std::numeric_limits<int>::max()); 134 RTC_DCHECK_LE(diff_us, std::numeric_limits<int>::max());
115 return static_cast<int>(diff_us); 135 return static_cast<int>(diff_us);
116 } 136 }
117 137
118 } // namespace 138 } // namespace
119 139
120 const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e) { 140 const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e) {
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 frame_stat->encoding_successful = true; 364 frame_stat->encoding_successful = true;
345 frame_stat->encoded_frame_size_bytes = encoded_image._length; 365 frame_stat->encoded_frame_size_bytes = encoded_image._length;
346 frame_stat->frame_type = encoded_image._frameType; 366 frame_stat->frame_type = encoded_image._frameType;
347 frame_stat->qp = encoded_image.qp_; 367 frame_stat->qp = encoded_image.qp_;
348 frame_stat->bitrate_kbps = static_cast<int>( 368 frame_stat->bitrate_kbps = static_cast<int>(
349 encoded_image._length * config_.codec_settings.maxFramerate * 8 / 1000); 369 encoded_image._length * config_.codec_settings.maxFramerate * 8 / 1000);
350 frame_stat->total_packets = 370 frame_stat->total_packets =
351 encoded_image._length / config_.networking_config.packet_size_in_bytes + 371 encoded_image._length / config_.networking_config.packet_size_in_bytes +
352 1; 372 1;
353 373
374 frame_stat->max_nalu_length = GetMaxNaluLength(encoded_image, config_);
375
354 // Simulate packet loss. 376 // Simulate packet loss.
355 bool exclude_this_frame = false; 377 bool exclude_this_frame = false;
356 if (encoded_image._frameType == kVideoFrameKey) { 378 if (encoded_image._frameType == kVideoFrameKey) {
357 // Only keyframes can be excluded. 379 // Only keyframes can be excluded.
358 switch (config_.exclude_frame_types) { 380 switch (config_.exclude_frame_types) {
359 case kExcludeOnlyFirstKeyFrame: 381 case kExcludeOnlyFirstKeyFrame:
360 if (!first_key_frame_has_been_excluded_) { 382 if (!first_key_frame_has_been_excluded_) {
361 first_key_frame_has_been_excluded_ = true; 383 first_key_frame_has_been_excluded_ = true;
362 exclude_this_frame = true; 384 exclude_this_frame = true;
363 } 385 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (decoded_frame_writer_) { 499 if (decoded_frame_writer_) {
478 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength()); 500 RTC_DCHECK_EQ(extracted_length, decoded_frame_writer_->FrameLength());
479 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data())); 501 RTC_CHECK(decoded_frame_writer_->WriteFrame(extracted_buffer.data()));
480 } 502 }
481 503
482 last_decoded_frame_buffer_ = std::move(extracted_buffer); 504 last_decoded_frame_buffer_ = std::move(extracted_buffer);
483 } 505 }
484 506
485 } // namespace test 507 } // namespace test
486 } // namespace webrtc 508 } // namespace webrtc
OLDNEW
« no previous file with comments | « modules/video_coding/codecs/test/videoprocessor.h ('k') | modules/video_coding/codecs/test/videoprocessor_integrationtest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698