Optional: Use nullopt and implicit construction in /modules/video_coding
Changes places where we explicitly construct an Optional to instead use nullopt or the requisite value type only. This CL was uploaded by git cl split. Bug: None Change-Id: Iedebf4dc56a973306e7d7e7649525879808dc72b Reviewed-on: https://webrtc-review.googlesource.com/23578 Commit-Queue: Oskar Sundbom <ossu@webrtc.org> Reviewed-by: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20878}
This commit is contained in:
committed by
Commit Bot
parent
56d460902e
commit
6bd39025ec
@ -47,7 +47,7 @@ std::unique_ptr<VideoBitrateAllocator> CreateBitrateAllocator(
|
||||
rtc::Optional<size_t> GetMaxNaluLength(const EncodedImage& encoded_frame,
|
||||
const TestConfig& config) {
|
||||
if (config.codec_settings.codecType != kVideoCodecH264)
|
||||
return rtc::Optional<size_t>();
|
||||
return rtc::nullopt;
|
||||
|
||||
std::vector<webrtc::H264::NaluIndex> nalu_indices =
|
||||
webrtc::H264::FindNaluIndices(encoded_frame._buffer,
|
||||
@ -59,7 +59,7 @@ rtc::Optional<size_t> GetMaxNaluLength(const EncodedImage& encoded_frame,
|
||||
for (const webrtc::H264::NaluIndex& index : nalu_indices)
|
||||
max_length = std::max(max_length, index.payload_size);
|
||||
|
||||
return rtc::Optional<size_t>(max_length);
|
||||
return max_length;
|
||||
}
|
||||
|
||||
int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) {
|
||||
|
||||
@ -132,7 +132,7 @@ class ScreenshareLayerTest : public ::testing::Test {
|
||||
// FrameEncoded() call will be omitted and needs to be done by the caller.
|
||||
// Returns the flags for the last frame.
|
||||
int SkipUntilTl(int layer) {
|
||||
return SkipUntilTlAndSync(layer, rtc::Optional<bool>());
|
||||
return SkipUntilTlAndSync(layer, rtc::nullopt);
|
||||
}
|
||||
|
||||
// Same as SkipUntilTl, but also waits until the sync bit condition is met.
|
||||
@ -583,7 +583,7 @@ TEST_F(ScreenshareLayerTest, 2LayersSyncAtOvershootDrop) {
|
||||
EXPECT_TRUE(RunGracePeriod());
|
||||
|
||||
// Move ahead until we have a sync frame in TL1.
|
||||
EXPECT_EQ(kTl1SyncFlags, SkipUntilTlAndSync(1, rtc::Optional<bool>(true)));
|
||||
EXPECT_EQ(kTl1SyncFlags, SkipUntilTlAndSync(1, true));
|
||||
ASSERT_TRUE(vp8_info_.layerSync);
|
||||
|
||||
// Simulate overshoot of this frame.
|
||||
|
||||
@ -108,7 +108,7 @@ class DecodedImageCallbackTestImpl : public webrtc::DecodedImageCallback {
|
||||
EXPECT_GT(frame.width(), 0);
|
||||
EXPECT_GT(frame.height(), 0);
|
||||
EXPECT_TRUE(qp);
|
||||
frame_ = rtc::Optional<VideoFrame>(frame);
|
||||
frame_ = frame;
|
||||
qp_ = qp;
|
||||
complete_ = true;
|
||||
}
|
||||
|
||||
@ -1234,8 +1234,7 @@ int VP8DecoderImpl::ReturnFrame(const vpx_image_t* img,
|
||||
|
||||
VideoFrame decoded_image(buffer, timestamp, 0, kVideoRotation_0);
|
||||
decoded_image.set_ntp_time_ms(ntp_time_ms);
|
||||
decode_complete_callback_->Decoded(decoded_image, rtc::Optional<int32_t>(),
|
||||
rtc::Optional<uint8_t>(qp));
|
||||
decode_complete_callback_->Decoded(decoded_image, rtc::nullopt, qp);
|
||||
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
@ -983,8 +983,7 @@ int VP9DecoderImpl::ReturnFrame(const vpx_image_t* img,
|
||||
0 /* render_time_ms */, webrtc::kVideoRotation_0);
|
||||
decoded_image.set_ntp_time_ms(ntp_time_ms);
|
||||
|
||||
decode_complete_callback_->Decoded(decoded_image, rtc::Optional<int32_t>(),
|
||||
rtc::Optional<uint8_t>(qp));
|
||||
decode_complete_callback_->Decoded(decoded_image, rtc::nullopt, qp);
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -167,8 +167,8 @@ rtc::Optional<RTPVideoTypeHeader> RtpFrameObject::GetCodecHeader() const {
|
||||
rtc::CritScope lock(&packet_buffer_->crit_);
|
||||
VCMPacket* packet = packet_buffer_->GetPacket(first_seq_num_);
|
||||
if (!packet)
|
||||
return rtc::Optional<RTPVideoTypeHeader>();
|
||||
return rtc::Optional<RTPVideoTypeHeader>(packet->video_header.codecHeader);
|
||||
return rtc::nullopt;
|
||||
return packet->video_header.codecHeader;
|
||||
}
|
||||
|
||||
} // namespace video_coding
|
||||
|
||||
@ -58,8 +58,8 @@ int32_t VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
|
||||
int64_t decode_time_ms) {
|
||||
Decoded(decodedImage,
|
||||
decode_time_ms >= 0 ? rtc::Optional<int32_t>(decode_time_ms)
|
||||
: rtc::Optional<int32_t>(),
|
||||
rtc::Optional<uint8_t>());
|
||||
: rtc::nullopt,
|
||||
rtc::nullopt);
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
@ -85,8 +85,7 @@ void VCMDecodedFrameCallback::Decoded(VideoFrame& decodedImage,
|
||||
|
||||
const int64_t now_ms = _clock->TimeInMilliseconds();
|
||||
if (!decode_time_ms) {
|
||||
decode_time_ms =
|
||||
rtc::Optional<int32_t>(now_ms - frameInfo->decodeStartTimeMs);
|
||||
decode_time_ms = now_ms - frameInfo->decodeStartTimeMs;
|
||||
}
|
||||
_timing->StopDecodeTimer(decodedImage.timestamp(), *decode_time_ms, now_ms,
|
||||
frameInfo->renderTimeMs);
|
||||
|
||||
@ -116,9 +116,9 @@ bool PacketBuffer::InsertPacket(VCMPacket* packet) {
|
||||
UpdateMissingPackets(packet->seqNum);
|
||||
|
||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
last_received_packet_ms_ = rtc::Optional<int64_t>(now_ms);
|
||||
last_received_packet_ms_ = now_ms;
|
||||
if (packet->frameType == kVideoFrameKey)
|
||||
last_received_keyframe_packet_ms_ = rtc::Optional<int64_t>(now_ms);
|
||||
last_received_keyframe_packet_ms_ = now_ms;
|
||||
|
||||
found_frames = FindFrames(seq_num);
|
||||
}
|
||||
@ -458,7 +458,7 @@ int PacketBuffer::Release() const {
|
||||
|
||||
void PacketBuffer::UpdateMissingPackets(uint16_t seq_num) {
|
||||
if (!newest_inserted_seq_num_)
|
||||
newest_inserted_seq_num_ = rtc::Optional<uint16_t>(seq_num);
|
||||
newest_inserted_seq_num_ = seq_num;
|
||||
|
||||
const int kMaxPaddingAge = 1000;
|
||||
if (AheadOf(seq_num, *newest_inserted_seq_num_)) {
|
||||
|
||||
@ -28,9 +28,9 @@ rtc::Optional<int> MovingAverage::GetAverage() const {
|
||||
|
||||
rtc::Optional<int> MovingAverage::GetAverage(size_t num_samples) const {
|
||||
if (num_samples > size() || num_samples == 0)
|
||||
return rtc::Optional<int>();
|
||||
return rtc::nullopt;
|
||||
int sum = sum_ - sum_history_[(count_ - num_samples) % sum_history_.size()];
|
||||
return rtc::Optional<int>(sum / static_cast<int>(num_samples));
|
||||
return sum / static_cast<int>(num_samples);
|
||||
}
|
||||
|
||||
void MovingAverage::Reset() {
|
||||
|
||||
Reference in New Issue
Block a user