Use Abseil container algorithms in video/
Bug: None Change-Id: Ia1419e14004d4a849dc0960a0501c25e6e50aeee Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/129560 Reviewed-by: Åsa Persson <asapersson@webrtc.org> Commit-Queue: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27362}
This commit is contained in:
parent
91c2606ca1
commit
bd631a00c0
@ -110,6 +110,7 @@ rtc_static_library("video") {
|
||||
"../system_wrappers",
|
||||
"../system_wrappers:field_trial",
|
||||
"../system_wrappers:metrics",
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
@ -211,6 +212,7 @@ rtc_source_set("video_stream_encoder_impl") {
|
||||
"../rtc_base/system:fallthrough",
|
||||
"../rtc_base/task_utils:repeating_task",
|
||||
"../system_wrappers:field_trial",
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
@ -282,6 +284,7 @@ if (rtc_include_tests) {
|
||||
"../test:test_support_test_artifacts",
|
||||
"../test:video_test_common",
|
||||
"../test:video_test_support",
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
]
|
||||
|
||||
@ -580,6 +583,7 @@ if (rtc_include_tests) {
|
||||
"../test:test_support",
|
||||
"../test:video_test_common",
|
||||
"//testing/gtest",
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "modules/utility/include/process_thread.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/location.h"
|
||||
@ -158,8 +159,7 @@ void CallStats::RegisterStatsObserver(CallStatsObserver* observer) {
|
||||
TemporaryDeregistration deregister(this, process_thread_,
|
||||
process_thread_running_);
|
||||
|
||||
auto it = std::find(observers_.begin(), observers_.end(), observer);
|
||||
if (it == observers_.end())
|
||||
if (!absl::c_linear_search(observers_, observer))
|
||||
observers_.push_back(observer);
|
||||
}
|
||||
|
||||
|
||||
@ -18,9 +18,13 @@
|
||||
#include "modules/video_coding/codecs/vp8/include/vp8.h"
|
||||
#include "test/call_test.h"
|
||||
#include "test/field_trial.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/rtcp_packet_parser.h"
|
||||
|
||||
using ::testing::Contains;
|
||||
using ::testing::Not;
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
enum : int { // The first valid value is 1.
|
||||
@ -416,8 +420,7 @@ TEST_F(FecEndToEndTest, ReceivedUlpfecPacketsNotNacked) {
|
||||
test::RtcpPacketParser rtcp_parser;
|
||||
rtcp_parser.Parse(packet, length);
|
||||
const std::vector<uint16_t>& nacks = rtcp_parser.nack()->packet_ids();
|
||||
EXPECT_TRUE(std::find(nacks.begin(), nacks.end(),
|
||||
ulpfec_sequence_number_) == nacks.end())
|
||||
EXPECT_THAT(nacks, Not(Contains(ulpfec_sequence_number_)))
|
||||
<< "Got nack for ULPFEC packet";
|
||||
if (!nacks.empty() &&
|
||||
IsNewerSequenceNumber(nacks.back(), ulpfec_sequence_number_)) {
|
||||
|
||||
@ -17,8 +17,11 @@
|
||||
#include "modules/video_coding/codecs/vp8/include/vp8.h"
|
||||
#include "modules/video_coding/codecs/vp9/include/vp9.h"
|
||||
#include "test/call_test.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
using ::testing::Contains;
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
constexpr int kWidth = 1280;
|
||||
@ -98,9 +101,7 @@ class FrameObserver : public test::RtpRtcpObserver,
|
||||
// Verifies that all sent frames are decoded and rendered.
|
||||
void OnFrame(const VideoFrame& rendered_frame) override {
|
||||
rtc::CritScope lock(&crit_);
|
||||
EXPECT_NE(std::find(sent_timestamps_.begin(), sent_timestamps_.end(),
|
||||
rendered_frame.timestamp()),
|
||||
sent_timestamps_.end());
|
||||
EXPECT_THAT(sent_timestamps_, Contains(rendered_frame.timestamp()));
|
||||
|
||||
// Remove old timestamps too, only the newest decoded frame is rendered.
|
||||
num_rendered_frames_ +=
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/test/simulated_network.h"
|
||||
#include "api/test/video/function_video_encoder_factory.h"
|
||||
@ -370,8 +371,8 @@ void RetransmissionEndToEndTest::DecodesRetransmittedFrame(bool enable_rtx,
|
||||
// This should be the only dropped packet.
|
||||
EXPECT_EQ(0u, retransmitted_timestamp_);
|
||||
retransmitted_timestamp_ = header.timestamp;
|
||||
if (std::find(rendered_timestamps_.begin(), rendered_timestamps_.end(),
|
||||
retransmitted_timestamp_) != rendered_timestamps_.end()) {
|
||||
if (absl::c_linear_search(rendered_timestamps_,
|
||||
retransmitted_timestamp_)) {
|
||||
// Frame was rendered before last packet was scheduled for sending.
|
||||
// This is extremly rare but possible scenario because prober able to
|
||||
// resend packet before it was send.
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/test/simulated_network.h"
|
||||
#include "api/test/video/function_video_encoder_factory.h"
|
||||
@ -628,8 +629,7 @@ TEST_F(StatsEndToEndTest, VerifyNackStats) {
|
||||
test::RtcpPacketParser rtcp_parser;
|
||||
rtcp_parser.Parse(packet, length);
|
||||
const std::vector<uint16_t>& nacks = rtcp_parser.nack()->packet_ids();
|
||||
if (!nacks.empty() && std::find(nacks.begin(), nacks.end(),
|
||||
dropped_rtp_packet_) != nacks.end()) {
|
||||
if (!nacks.empty() && absl::c_linear_search(nacks, dropped_rtp_packet_)) {
|
||||
dropped_rtp_packet_requested_ = true;
|
||||
}
|
||||
return SEND_PACKET;
|
||||
|
||||
@ -10,10 +10,10 @@
|
||||
|
||||
#include "video/rtp_video_stream_receiver.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "media/base/media_constants.h"
|
||||
#include "modules/pacing/packet_router.h"
|
||||
@ -468,15 +468,14 @@ absl::optional<int64_t> RtpVideoStreamReceiver::LastReceivedKeyframePacketMs()
|
||||
|
||||
void RtpVideoStreamReceiver::AddSecondarySink(RtpPacketSinkInterface* sink) {
|
||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_task_checker_);
|
||||
RTC_DCHECK(std::find(secondary_sinks_.cbegin(), secondary_sinks_.cend(),
|
||||
sink) == secondary_sinks_.cend());
|
||||
RTC_DCHECK(!absl::c_linear_search(secondary_sinks_, sink));
|
||||
secondary_sinks_.push_back(sink);
|
||||
}
|
||||
|
||||
void RtpVideoStreamReceiver::RemoveSecondarySink(
|
||||
const RtpPacketSinkInterface* sink) {
|
||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_task_checker_);
|
||||
auto it = std::find(secondary_sinks_.begin(), secondary_sinks_.end(), sink);
|
||||
auto it = absl::c_find(secondary_sinks_, sink);
|
||||
if (it == secondary_sinks_.end()) {
|
||||
// We might be rolling-back a call whose setup failed mid-way. In such a
|
||||
// case, it's simpler to remove "everything" rather than remember what
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "modules/video_coding/include/video_codec_interface.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
@ -749,13 +750,10 @@ VideoSendStream::StreamStats* SendStatisticsProxy::GetStatsEntry(
|
||||
if (it != stats_.substreams.end())
|
||||
return &it->second;
|
||||
|
||||
bool is_media = std::find(rtp_config_.ssrcs.begin(), rtp_config_.ssrcs.end(),
|
||||
ssrc) != rtp_config_.ssrcs.end();
|
||||
bool is_media = absl::c_linear_search(rtp_config_.ssrcs, ssrc);
|
||||
bool is_flexfec = rtp_config_.flexfec.payload_type != -1 &&
|
||||
ssrc == rtp_config_.flexfec.ssrc;
|
||||
bool is_rtx =
|
||||
std::find(rtp_config_.rtx.ssrcs.begin(), rtp_config_.rtx.ssrcs.end(),
|
||||
ssrc) != rtp_config_.rtx.ssrcs.end();
|
||||
bool is_rtx = absl::c_linear_search(rtp_config_.rtx.ssrcs, ssrc);
|
||||
if (!is_media && !is_flexfec && !is_rtx)
|
||||
return nullptr;
|
||||
|
||||
|
||||
@ -10,11 +10,13 @@
|
||||
|
||||
#include "video/send_statistics_proxy.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "system_wrappers/include/metrics.h"
|
||||
#include "test/field_trial.h"
|
||||
#include "test/gtest.h"
|
||||
@ -1685,10 +1687,8 @@ TEST_F(SendStatisticsProxyTest, GetStatsReportsTargetMediaBitrate) {
|
||||
|
||||
TEST_F(SendStatisticsProxyTest, NoSubstreams) {
|
||||
uint32_t excluded_ssrc =
|
||||
std::max(
|
||||
*std::max_element(config_.rtp.ssrcs.begin(), config_.rtp.ssrcs.end()),
|
||||
*std::max_element(config_.rtp.rtx.ssrcs.begin(),
|
||||
config_.rtp.rtx.ssrcs.end())) +
|
||||
std::max(*absl::c_max_element(config_.rtp.ssrcs),
|
||||
*absl::c_max_element(config_.rtp.rtx.ssrcs)) +
|
||||
1;
|
||||
// From RtcpStatisticsCallback.
|
||||
RtcpStatistics rtcp_stats;
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_format.h"
|
||||
#include "modules/rtp_rtcp/source/rtp_utility.h"
|
||||
@ -738,8 +739,7 @@ void VideoAnalyzer::PrintResult(const char* result_type,
|
||||
void VideoAnalyzer::PrintSamplesToFile() {
|
||||
FILE* out = graph_data_output_file_;
|
||||
rtc::CritScope crit(&comparison_lock_);
|
||||
std::sort(samples_.begin(), samples_.end(),
|
||||
[](const Sample& A, const Sample& B) -> bool {
|
||||
absl::c_sort(samples_, [](const Sample& A, const Sample& B) -> bool {
|
||||
return A.input_time_ms < B.input_time_ms;
|
||||
});
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
@ -351,8 +352,7 @@ void VideoReceiveStream::Start() {
|
||||
field_trial::FindFullName("WebRTC-DecoderDataDumpDirectory");
|
||||
// Because '/' can't be used inside a field trial parameter, we use ':'
|
||||
// instead.
|
||||
std::replace(decoded_output_file.begin(), decoded_output_file.end(), ':',
|
||||
'/');
|
||||
absl::c_replace(decoded_output_file, ':', '/');
|
||||
if (!decoded_output_file.empty()) {
|
||||
char filename_buffer[256];
|
||||
rtc::SimpleStringBuilder ssb(filename_buffer);
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "api/crypto/crypto_options.h"
|
||||
#include "api/rtp_parameters.h"
|
||||
#include "api/scoped_refptr.h"
|
||||
@ -48,10 +49,9 @@ constexpr TimeDelta kEncoderTimeOut = TimeDelta::Seconds<2>();
|
||||
|
||||
bool TransportSeqNumExtensionConfigured(const VideoSendStream::Config& config) {
|
||||
const std::vector<RtpExtension>& extensions = config.rtp.extensions;
|
||||
return std::find_if(
|
||||
extensions.begin(), extensions.end(), [](const RtpExtension& ext) {
|
||||
return absl::c_any_of(extensions, [](const RtpExtension& ext) {
|
||||
return ext.uri == RtpExtension::kTransportSequenceNumberUri;
|
||||
}) != extensions.end();
|
||||
});
|
||||
}
|
||||
|
||||
const char kForcedFallbackFieldTrial[] =
|
||||
@ -320,12 +320,10 @@ VideoSendStreamImpl::VideoSendStreamImpl(
|
||||
// side doesn't support the rotation extension. This allows us to prepare the
|
||||
// encoder in the expectation that rotation is supported - which is the common
|
||||
// case.
|
||||
bool rotation_applied =
|
||||
std::find_if(config_->rtp.extensions.begin(),
|
||||
config_->rtp.extensions.end(),
|
||||
[](const RtpExtension& extension) {
|
||||
bool rotation_applied = absl::c_none_of(
|
||||
config_->rtp.extensions, [](const RtpExtension& extension) {
|
||||
return extension.uri == RtpExtension::kVideoRotationUri;
|
||||
}) == config_->rtp.extensions.end();
|
||||
});
|
||||
|
||||
video_stream_encoder_->SetSink(this, rotation_applied);
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/task_queue/default_task_queue_factory.h"
|
||||
#include "api/test/simulated_network.h"
|
||||
@ -935,8 +936,7 @@ void VideoSendStreamTest::TestNackRetransmission(
|
||||
sequence_number = (rtx_header[0] << 8) + rtx_header[1];
|
||||
}
|
||||
|
||||
auto found = std::find(nacked_sequence_numbers_.begin(),
|
||||
nacked_sequence_numbers_.end(), sequence_number);
|
||||
auto found = absl::c_find(nacked_sequence_numbers_, sequence_number);
|
||||
if (found != nacked_sequence_numbers_.end()) {
|
||||
nacked_sequence_numbers_.erase(found);
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <numeric>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/video/encoded_image.h"
|
||||
#include "api/video/i420_buffer.h"
|
||||
@ -642,9 +643,8 @@ void VideoStreamEncoder::ReconfigureEncoder() {
|
||||
|
||||
// Stream dimensions may be not equal to given because of a simulcast
|
||||
// restrictions.
|
||||
auto highest_stream = std::max_element(
|
||||
streams.begin(), streams.end(),
|
||||
[](const webrtc::VideoStream& a, const webrtc::VideoStream& b) {
|
||||
auto highest_stream = absl::c_max_element(
|
||||
streams, [](const webrtc::VideoStream& a, const webrtc::VideoStream& b) {
|
||||
return std::tie(a.width, a.height) < std::tie(b.width, b.height);
|
||||
});
|
||||
int highest_stream_width = static_cast<int>(highest_stream->width);
|
||||
@ -1898,7 +1898,7 @@ void VideoStreamEncoder::AdaptCounter::DecrementFramerate(int reason,
|
||||
DecrementFramerate(reason);
|
||||
// Reset if at max fps (i.e. in case of fewer steps up than down).
|
||||
if (cur_fps == std::numeric_limits<int>::max())
|
||||
std::fill(fps_counters_.begin(), fps_counters_.end(), 0);
|
||||
absl::c_fill(fps_counters_, 0);
|
||||
}
|
||||
|
||||
int VideoStreamEncoder::AdaptCounter::FramerateCount() const {
|
||||
@ -1923,7 +1923,7 @@ int VideoStreamEncoder::AdaptCounter::TotalCount(int reason) const {
|
||||
|
||||
int VideoStreamEncoder::AdaptCounter::Count(
|
||||
const std::vector<int>& counters) const {
|
||||
return std::accumulate(counters.begin(), counters.end(), 0);
|
||||
return absl::c_accumulate(counters, 0);
|
||||
}
|
||||
|
||||
void VideoStreamEncoder::AdaptCounter::MoveCount(std::vector<int>* counters,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user