Fix backward jump in timestamp if framerate increases in video processor tests.
Bug: none Change-Id: Id905eb5ea546d5cf8a2fee70f3e262155e293f4e Reviewed-on: https://webrtc-review.googlesource.com/43360 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Commit-Queue: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21756}
This commit is contained in:
@ -29,6 +29,7 @@ namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
namespace {
|
||||
const int kMsToRtpTimestamp = kVideoPayloadTypeFrequency / 1000;
|
||||
|
||||
std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
|
||||
TestConfig* config) {
|
||||
@ -156,17 +157,16 @@ void VideoProcessor::ProcessFrame() {
|
||||
rtc::scoped_refptr<I420BufferInterface> 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<VideoFrame>(buffer, static_cast<uint32_t>(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<VideoFrame>(
|
||||
buffer, static_cast<uint32_t>(rtp_timestamp),
|
||||
static_cast<int64_t>(rtp_timestamp / kMsToRtpTimestamp),
|
||||
webrtc::kVideoRotation_0);
|
||||
|
||||
std::vector<FrameType> frame_types = config_.FrameTypeForFrame(frame_number);
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user