diff --git a/modules/video_coding/codecs/test/videoprocessor.cc b/modules/video_coding/codecs/test/videoprocessor.cc index b1b038f455..7e1047f458 100644 --- a/modules/video_coding/codecs/test/videoprocessor.cc +++ b/modules/video_coding/codecs/test/videoprocessor.cc @@ -29,6 +29,7 @@ namespace webrtc { namespace test { namespace { +const int kMsToRtpTimestamp = kVideoPayloadTypeFrequency / 1000; std::unique_ptr CreateBitrateAllocator( TestConfig* config) { @@ -156,17 +157,16 @@ void VideoProcessor::ProcessFrame() { rtc::scoped_refptr buffer( analysis_frame_reader_->ReadFrame()); RTC_CHECK(buffer) << "Tried to read too many frames from the file."; - // Use the frame number as the basis for timestamp to identify frames. Let the - // first timestamp be non-zero, to not make the IvfFileWriter believe that we - // want to use capture timestamps in the IVF files. - // TODO(asapersson): Time stamps jump back if framerate increases. - const size_t rtp_timestamp = (frame_number + 1) * kVideoPayloadTypeFrequency / - config_.codec_settings.maxFramerate; - const int64_t render_time_ms = (frame_number + 1) * rtc::kNumMillisecsPerSec / - config_.codec_settings.maxFramerate; - input_frames_[frame_number] = - rtc::MakeUnique(buffer, static_cast(rtp_timestamp), - render_time_ms, webrtc::kVideoRotation_0); + + size_t rtp_timestamp = + (frame_number > 0) ? input_frames_[frame_number - 1]->timestamp() : 0; + rtp_timestamp += + kVideoPayloadTypeFrequency / config_.codec_settings.maxFramerate; + + input_frames_[frame_number] = rtc::MakeUnique( + buffer, static_cast(rtp_timestamp), + static_cast(rtp_timestamp / kMsToRtpTimestamp), + webrtc::kVideoRotation_0); std::vector frame_types = config_.FrameTypeForFrame(frame_number); diff --git a/modules/video_coding/codecs/test/videoprocessor_unittest.cc b/modules/video_coding/codecs/test/videoprocessor_unittest.cc index ff00fc2e23..6f3373366d 100644 --- a/modules/video_coding/codecs/test/videoprocessor_unittest.cc +++ b/modules/video_coding/codecs/test/videoprocessor_unittest.cc @@ -19,12 +19,10 @@ #include "test/gmock.h" #include "test/gtest.h" #include "test/testsupport/mock/mock_frame_reader.h" -#include "test/testsupport/unittest_utils.h" #include "test/video_codec_settings.h" #include "typedefs.h" // NOLINT(build/include) using ::testing::_; -using ::testing::ElementsAre; using ::testing::Property; using ::testing::Return; @@ -110,6 +108,7 @@ TEST_F(VideoProcessorTest, ProcessFrames_FixedFramerate) { TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) { const int kBitrateKbps = 456; const int kStartFramerateFps = 27; + const int kStartTimestamp = 90000 / kStartFramerateFps; EXPECT_CALL(encoder_mock_, SetRateAllocation(_, kStartFramerateFps)) .Times(1) .WillOnce(Return(0)); @@ -117,9 +116,8 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) { EXPECT_CALL(frame_reader_mock_, ReadFrame()) .WillRepeatedly(Return(I420Buffer::Create(kWidth, kHeight))); - EXPECT_CALL(encoder_mock_, Encode(Property(&VideoFrame::timestamp, - 1 * 90000 / kStartFramerateFps), - _, _)) + EXPECT_CALL(encoder_mock_, + Encode(Property(&VideoFrame::timestamp, kStartTimestamp), _, _)) .Times(1); video_processor_->ProcessFrame(); @@ -129,9 +127,10 @@ TEST_F(VideoProcessorTest, ProcessFrames_VariableFramerate) { .WillOnce(Return(0)); video_processor_->SetRates(kBitrateKbps, kNewFramerateFps); - EXPECT_CALL(encoder_mock_, Encode(Property(&VideoFrame::timestamp, - 2 * 90000 / kNewFramerateFps), - _, _)) + EXPECT_CALL(encoder_mock_, + Encode(Property(&VideoFrame::timestamp, + kStartTimestamp + 90000 / kNewFramerateFps), + _, _)) .Times(1); video_processor_->ProcessFrame();