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

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

Issue 2709613005: Add QP statistics to VideoProcessorIntegrationTest. (Closed)
Patch Set: rebase Created 3 years, 10 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 "webrtc/modules/video_coding/codecs/test/stats.h" 11 #include "webrtc/modules/video_coding/codecs/test/stats.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <stdio.h> 14 #include <stdio.h>
15 15
16 #include <algorithm> // min_element, max_element 16 #include <algorithm> // min_element, max_element
17 17
18 #include "webrtc/base/format_macros.h" 18 #include "webrtc/base/format_macros.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 namespace test { 21 namespace test {
22 22
23 FrameStatistic::FrameStatistic() 23 FrameStatistic::FrameStatistic()
24 : encoding_successful(false), 24 : encoding_successful(false),
25 decoding_successful(false), 25 decoding_successful(false),
26 encode_return_code(0), 26 encode_return_code(0),
27 decode_return_code(0), 27 decode_return_code(0),
28 encode_time_in_us(0), 28 encode_time_in_us(0),
29 decode_time_in_us(0), 29 decode_time_in_us(0),
30 qp(-1),
30 frame_number(0), 31 frame_number(0),
31 packets_dropped(0), 32 packets_dropped(0),
32 total_packets(0), 33 total_packets(0),
33 bit_rate_in_kbps(0), 34 bit_rate_in_kbps(0),
34 encoded_frame_length_in_bytes(0), 35 encoded_frame_length_in_bytes(0),
35 frame_type(kVideoFrameDelta) {} 36 frame_type(kVideoFrameDelta) {}
36 37
37 Stats::Stats() {} 38 Stats::Stats() {}
38 39
39 Stats::~Stats() {} 40 Stats::~Stats() {}
(...skipping 25 matching lines...) Expand all
65 void Stats::PrintSummary() { 66 void Stats::PrintSummary() {
66 printf("Processing summary:\n"); 67 printf("Processing summary:\n");
67 if (stats_.size() == 0) { 68 if (stats_.size() == 0) {
68 printf("No frame statistics have been logged yet.\n"); 69 printf("No frame statistics have been logged yet.\n");
69 return; 70 return;
70 } 71 }
71 72
72 // Calculate min, max, average and total encoding time 73 // Calculate min, max, average and total encoding time
73 int total_encoding_time_in_us = 0; 74 int total_encoding_time_in_us = 0;
74 int total_decoding_time_in_us = 0; 75 int total_decoding_time_in_us = 0;
76 int total_qp = 0;
77 int total_qp_count = 0;
75 size_t total_encoded_frames_lengths = 0; 78 size_t total_encoded_frames_lengths = 0;
76 size_t total_encoded_key_frames_lengths = 0; 79 size_t total_encoded_key_frames_lengths = 0;
77 size_t total_encoded_nonkey_frames_lengths = 0; 80 size_t total_encoded_nonkey_frames_lengths = 0;
78 size_t nbr_keyframes = 0; 81 size_t nbr_keyframes = 0;
79 size_t nbr_nonkeyframes = 0; 82 size_t nbr_nonkeyframes = 0;
80 83
81 for (FrameStatisticsIterator it = stats_.begin(); it != stats_.end(); ++it) { 84 for (FrameStatisticsIterator it = stats_.begin(); it != stats_.end(); ++it) {
82 total_encoding_time_in_us += it->encode_time_in_us; 85 total_encoding_time_in_us += it->encode_time_in_us;
83 total_decoding_time_in_us += it->decode_time_in_us; 86 total_decoding_time_in_us += it->decode_time_in_us;
84 total_encoded_frames_lengths += it->encoded_frame_length_in_bytes; 87 total_encoded_frames_lengths += it->encoded_frame_length_in_bytes;
85 if (it->frame_type == webrtc::kVideoFrameKey) { 88 if (it->frame_type == webrtc::kVideoFrameKey) {
86 total_encoded_key_frames_lengths += it->encoded_frame_length_in_bytes; 89 total_encoded_key_frames_lengths += it->encoded_frame_length_in_bytes;
87 nbr_keyframes++; 90 nbr_keyframes++;
88 } else { 91 } else {
89 total_encoded_nonkey_frames_lengths += it->encoded_frame_length_in_bytes; 92 total_encoded_nonkey_frames_lengths += it->encoded_frame_length_in_bytes;
90 nbr_nonkeyframes++; 93 nbr_nonkeyframes++;
91 } 94 }
95 if (it->qp >= 0) {
96 total_qp += it->qp;
97 ++total_qp_count;
98 }
92 } 99 }
93 100
94 FrameStatisticsIterator frame; 101 FrameStatisticsIterator frame;
95 102
96 // ENCODING 103 // ENCODING
97 printf("Encoding time:\n"); 104 printf("Encoding time:\n");
98 frame = std::min_element(stats_.begin(), stats_.end(), LessForEncodeTime); 105 frame = std::min_element(stats_.begin(), stats_.end(), LessForEncodeTime);
99 printf(" Min : %7d us (frame %d)\n", frame->encode_time_in_us, 106 printf(" Min : %7d us (frame %d)\n", frame->encode_time_in_us,
100 frame->frame_number); 107 frame->frame_number);
101 108
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // BIT RATE 170 // BIT RATE
164 printf("Bit rates:\n"); 171 printf("Bit rates:\n");
165 frame = std::min_element(stats_.begin(), stats_.end(), LessForBitRate); 172 frame = std::min_element(stats_.begin(), stats_.end(), LessForBitRate);
166 printf(" Min bit rate: %7d kbps (frame %d)\n", frame->bit_rate_in_kbps, 173 printf(" Min bit rate: %7d kbps (frame %d)\n", frame->bit_rate_in_kbps,
167 frame->frame_number); 174 frame->frame_number);
168 175
169 frame = std::max_element(stats_.begin(), stats_.end(), LessForBitRate); 176 frame = std::max_element(stats_.begin(), stats_.end(), LessForBitRate);
170 printf(" Max bit rate: %7d kbps (frame %d)\n", frame->bit_rate_in_kbps, 177 printf(" Max bit rate: %7d kbps (frame %d)\n", frame->bit_rate_in_kbps,
171 frame->frame_number); 178 frame->frame_number);
172 179
180 int avg_qp = (total_qp_count > 0) ? (total_qp / total_qp_count) : -1;
181 printf("Average QP: %d\n", avg_qp);
182
173 printf("\n"); 183 printf("\n");
174 printf("Total encoding time : %7d ms.\n", total_encoding_time_in_us / 1000); 184 printf("Total encoding time : %7d ms.\n", total_encoding_time_in_us / 1000);
175 printf("Total decoding time : %7d ms.\n", total_decoding_time_in_us / 1000); 185 printf("Total decoding time : %7d ms.\n", total_decoding_time_in_us / 1000);
176 printf("Total processing time: %7d ms.\n", 186 printf("Total processing time: %7d ms.\n",
177 (total_encoding_time_in_us + total_decoding_time_in_us) / 1000); 187 (total_encoding_time_in_us + total_decoding_time_in_us) / 1000);
178 } 188 }
179 189
180 } // namespace test 190 } // namespace test
181 } // namespace webrtc 191 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/test/stats.h ('k') | webrtc/modules/video_coding/codecs/test/videoprocessor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698