Update rtc_tools to not use implicit T* --> scoped_refptr<T> conversion

Bug: webrtc:13464
Change-Id: Ieb7747eaf466254c6feaf5670846b897d700ad07
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246101
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35680}
This commit is contained in:
Niels Möller
2022-01-13 09:56:55 +01:00
committed by WebRTC LUCI CQ
parent 8e64e2ddb4
commit 4024f64cff
4 changed files with 17 additions and 15 deletions

View File

@ -155,7 +155,7 @@ ColorTransformationMatrix CalculateColorTransformationMatrix(
rtc::scoped_refptr<Video> AdjustColors(
const ColorTransformationMatrix& color_transformation,
const rtc::scoped_refptr<Video>& video) {
class ColorAdjustedVideo : public rtc::RefCountedObject<Video> {
class ColorAdjustedVideo : public Video {
public:
ColorAdjustedVideo(const ColorTransformationMatrix& color_transformation,
const rtc::scoped_refptr<Video>& video)
@ -177,7 +177,7 @@ rtc::scoped_refptr<Video> AdjustColors(
const rtc::scoped_refptr<Video> video_;
};
return new ColorAdjustedVideo(color_transformation, video);
return rtc::make_ref_counted<ColorAdjustedVideo>(color_transformation, video);
}
rtc::scoped_refptr<I420BufferInterface> AdjustColors(

View File

@ -132,7 +132,7 @@ rtc::scoped_refptr<I420BufferInterface> AdjustCropping(
rtc::scoped_refptr<Video> AdjustCropping(
const rtc::scoped_refptr<Video>& reference_video,
const rtc::scoped_refptr<Video>& test_video) {
class CroppedVideo : public rtc::RefCountedObject<Video> {
class CroppedVideo : public Video {
public:
CroppedVideo(const rtc::scoped_refptr<Video>& reference_video,
const rtc::scoped_refptr<Video>& test_video)
@ -171,7 +171,7 @@ rtc::scoped_refptr<Video> AdjustCropping(
mutable std::map<size_t, CropRegion> crop_regions_;
};
return new CroppedVideo(reference_video, test_video);
return rtc::make_ref_counted<CroppedVideo>(reference_video, test_video);
}
} // namespace test

View File

@ -37,7 +37,7 @@ namespace {
const int kNumberOfFramesLookAhead = 60;
// Helper class that takes a video and generates an infinite looping video.
class LoopingVideo : public rtc::RefCountedObject<Video> {
class LoopingVideo : public Video {
public:
explicit LoopingVideo(const rtc::scoped_refptr<Video>& video)
: video_(video) {}
@ -59,7 +59,7 @@ class LoopingVideo : public rtc::RefCountedObject<Video> {
// Helper class that take a vector of frame indices and a video and produces a
// new video where the frames have been reshuffled.
class ReorderedVideo : public rtc::RefCountedObject<Video> {
class ReorderedVideo : public Video {
public:
ReorderedVideo(const rtc::scoped_refptr<Video>& video,
const std::vector<size_t>& indices)
@ -80,7 +80,7 @@ class ReorderedVideo : public rtc::RefCountedObject<Video> {
};
// Helper class that takes a video and produces a downscaled video.
class DownscaledVideo : public rtc::RefCountedObject<Video> {
class DownscaledVideo : public Video {
public:
DownscaledVideo(float scale_factor, const rtc::scoped_refptr<Video>& video)
: downscaled_width_(
@ -113,7 +113,7 @@ class DownscaledVideo : public rtc::RefCountedObject<Video> {
// Helper class that takes a video and caches the latest frame access. This
// improves performance a lot since the original source is often from a file.
class CachedVideo : public rtc::RefCountedObject<Video> {
class CachedVideo : public Video {
public:
CachedVideo(int max_cache_size, const rtc::scoped_refptr<Video>& video)
: max_cache_size_(max_cache_size), video_(video) {}
@ -189,14 +189,15 @@ std::vector<size_t> FindMatchingFrameIndices(
// same memory tens of times.
const float kScaleFactor = 0.25f;
const rtc::scoped_refptr<Video> cached_downscaled_reference_video =
new CachedVideo(kNumberOfFramesLookAhead,
new DownscaledVideo(kScaleFactor, reference_video));
rtc::make_ref_counted<CachedVideo>(kNumberOfFramesLookAhead,
rtc::make_ref_counted<DownscaledVideo>(
kScaleFactor, reference_video));
const rtc::scoped_refptr<Video> downscaled_test_video =
new DownscaledVideo(kScaleFactor, test_video);
rtc::make_ref_counted<DownscaledVideo>(kScaleFactor, test_video);
// Assume the video is looping around.
const rtc::scoped_refptr<Video> looping_reference_video =
new LoopingVideo(cached_downscaled_reference_video);
rtc::make_ref_counted<LoopingVideo>(cached_downscaled_reference_video);
std::vector<size_t> match_indices;
for (const rtc::scoped_refptr<I420BufferInterface>& test_frame :
@ -216,7 +217,8 @@ std::vector<size_t> FindMatchingFrameIndices(
rtc::scoped_refptr<Video> ReorderVideo(const rtc::scoped_refptr<Video>& video,
const std::vector<size_t>& indices) {
return new ReorderedVideo(new LoopingVideo(video), indices);
return rtc::make_ref_counted<ReorderedVideo>(
rtc::make_ref_counted<LoopingVideo>(video), indices);
}
rtc::scoped_refptr<Video> GenerateAlignedReferenceVideo(

View File

@ -110,11 +110,11 @@ Video::Iterator& Video::Iterator::operator++() {
}
Video::Iterator Video::begin() const {
return Iterator(this, 0);
return Iterator(rtc::scoped_refptr<const Video>(this), 0);
}
Video::Iterator Video::end() const {
return Iterator(this, number_of_frames());
return Iterator(rtc::scoped_refptr<const Video>(this), number_of_frames());
}
rtc::scoped_refptr<Video> OpenY4mFile(const std::string& file_name) {