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

Unified Diff: modules/video_coding/codecs/test/videoprocessor.cc

Issue 3015703002: Splitting cl https://codereview.webrtc.org/3011373002 into two: updating v1.7 and adding unit tests… (Closed)
Patch Set: Created 3 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: modules/video_coding/codecs/test/videoprocessor.cc
diff --git a/modules/video_coding/codecs/test/videoprocessor.cc b/modules/video_coding/codecs/test/videoprocessor.cc
index af5b4b35b5e75465823f89dbf0aaa5416568db21..fc6260abee44b14287b47c04466cc8a4dc2ad917 100644
--- a/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/modules/video_coding/codecs/test/videoprocessor.cc
@@ -16,6 +16,7 @@
#include <memory>
#include <utility>
#include <vector>
+#include <algorithm>
#include "api/video/i420_buffer.h"
#include "common_types.h" // NOLINT(build/include)
@@ -108,6 +109,22 @@ void VerifyQpParser(const EncodedImage& encoded_frame,
EXPECT_EQ(encoded_frame.qp_, qp) << "Encoder QP != parsed bitstream QP.";
}
+size_t GetMaxNaluLength(const EncodedImage& encoded_frame,
+ const TestConfig& config) {
+ if (config.hw_encoder || config.codec_settings.codecType != kVideoCodecH264)
+ return 0;
+
+ std::vector<webrtc::H264::NaluIndex> nalu_indices =
+ webrtc::H264::FindNaluIndices(encoded_frame._buffer,
+ encoded_frame._length);
+
+ size_t maxLength = 0;
+ for (const webrtc::H264::NaluIndex& index : nalu_indices)
+ maxLength = std::max(maxLength, index.payload_size);
+
+ return maxLength;
+}
+
int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) {
int64_t diff_us = (stop_ns - start_ns) / rtc::kNumNanosecsPerMicrosec;
RTC_DCHECK_GE(diff_us, std::numeric_limits<int>::min());
@@ -351,6 +368,8 @@ void VideoProcessor::FrameEncoded(webrtc::VideoCodecType codec,
encoded_image._length / config_.networking_config.packet_size_in_bytes +
1;
+ frame_stat->max_nalu_length = GetMaxNaluLength(encoded_image, config_);
+
// Simulate packet loss.
bool exclude_this_frame = false;
if (encoded_image._frameType == kVideoFrameKey) {
« 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