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

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

Issue 3014623002: Adding test for SingleNalUnit mode (Closed)
Patch Set: Addressed review notes 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..9daecbb43902cee550c586bca7877e466588e106 100644
--- a/modules/video_coding/codecs/test/videoprocessor.cc
+++ b/modules/video_coding/codecs/test/videoprocessor.cc
@@ -12,6 +12,7 @@
#include <string.h>
+#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
@@ -19,6 +20,7 @@
#include "api/video/i420_buffer.h"
#include "common_types.h" // NOLINT(build/include)
+#include "common_video/h264/h264_common.h"
#include "modules/video_coding/codecs/vp8/simulcast_rate_allocator.h"
#include "modules/video_coding/include/video_codec_initializer.h"
#include "modules/video_coding/utility/default_video_bitrate_allocator.h"
@@ -108,6 +110,22 @@ void VerifyQpParser(const EncodedImage& encoded_frame,
EXPECT_EQ(encoded_frame.qp_, qp) << "Encoder QP != parsed bitstream QP.";
}
+rtc::Optional<size_t> GetMaxNaluLength(const EncodedImage& encoded_frame,
+ const TestConfig& config) {
+ if (config.codec_settings.codecType != kVideoCodecH264)
+ return rtc::Optional<size_t>();
+
+ std::vector<webrtc::H264::NaluIndex> nalu_indices =
+ webrtc::H264::FindNaluIndices(encoded_frame._buffer,
+ encoded_frame._length);
hbos 2017/09/27 15:56:42 Should we return empty optional if nalu_indices is
ssilkin 2017/09/28 09:53:09 Added RTC_CHECK for empty nalu_indices. It is expe
hbos 2017/09/28 12:08:34 Is it safe to assume the encoded image is "correct
hbos 2017/09/28 12:10:45 Or is this only on frames we've encoded?
brandtr 2017/09/28 13:39:26 This is just test code, so I think it's OK to be l
+
+ size_t max_length = 0;
+ for (const webrtc::H264::NaluIndex& index : nalu_indices)
+ max_length = std::max(max_length, index.payload_size);
+
+ return rtc::Optional<size_t>(max_length);
+}
+
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 +369,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