webrtc/modules/video_coding/codecs/test/video_codec_stats_impl.h
Sergey Silkin 26d1b26277 Log metrics even if test failed
Set of codecs for testing is hardcoded to AV1, VP8, VP9, H264, H265. Some codecs may not be available due to lack of support on the platform or due to some issue in our code which would be a regression. Reporting zero metrics for failed tests would allow the perf tool to detect such a regression.

This also enables codec tests by default. The tests should not run on bots since video_codec_perf_tests binary is not included in any test suits yet.

Bug: webrtc:14852
Change-Id: I967160069055036f93e595d328c4d5f1ca483be9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/300868
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39840}
2023-04-13 08:49:37 +00:00

62 lines
1.8 KiB
C++

/*
* Copyright (c) 2023 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_
#define MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_
#include <map>
#include <string>
#include <vector>
#include "absl/types/optional.h"
#include "api/test/video_codec_stats.h"
namespace webrtc {
namespace test {
// Implementation of `VideoCodecStats`. This class is not thread-safe.
class VideoCodecStatsImpl : public VideoCodecStats {
public:
std::vector<Frame> Slice(
absl::optional<Filter> filter = absl::nullopt) const override;
Stream Aggregate(const std::vector<Frame>& frames) const override;
void AddFrame(const Frame& frame);
// Returns raw pointers to previously added frame. If frame does not exist,
// returns `nullptr`.
Frame* GetFrame(uint32_t timestamp_rtp, int spatial_idx);
private:
struct FrameId {
uint32_t timestamp_rtp;
int spatial_idx;
bool operator==(const FrameId& o) const {
return timestamp_rtp == o.timestamp_rtp && spatial_idx == o.spatial_idx;
}
bool operator<(const FrameId& o) const {
if (timestamp_rtp < o.timestamp_rtp)
return true;
if (timestamp_rtp == o.timestamp_rtp && spatial_idx < o.spatial_idx)
return true;
return false;
}
};
std::map<FrameId, Frame> frames_;
};
} // namespace test
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_CODECS_TEST_VIDEO_CODEC_STATS_IMPL_H_