From 052cc9d92a8d1aa7a3c8bd11d9ee65e2ca7181ad Mon Sep 17 00:00:00 2001 From: Fanny Linderborg Date: Thu, 26 Sep 2024 12:33:18 +0200 Subject: [PATCH] Fix misspelled function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:358039777 Change-Id: I640256a33c6a2f998042555607e053aa0b09e626 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/363803 Commit-Queue: Fanny Linderborg Reviewed-by: Erik Språng Cr-Commit-Position: refs/heads/main@{#43091} --- .../corruption_classifier.cc | 14 +++++++++- .../corruption_classifier.h | 10 ++++++- .../corruption_classifier_unittest.cc | 28 +++++++++---------- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/video/corruption_detection/corruption_classifier.cc b/video/corruption_detection/corruption_classifier.cc index d72626a73d..d9ead1f746 100644 --- a/video/corruption_detection/corruption_classifier.cc +++ b/video/corruption_detection/corruption_classifier.cc @@ -38,7 +38,7 @@ CorruptionClassifier::CorruptionClassifier(float growth_rate, float midpoint) << "Calculating corruption probability using logistic function."; } -double CorruptionClassifier::CalculateCorruptionProbablility( +double CorruptionClassifier::CalculateCorruptionProbability( rtc::ArrayView filtered_original_samples, rtc::ArrayView filtered_compressed_samples, int luma_threshold, @@ -59,6 +59,18 @@ double CorruptionClassifier::CalculateCorruptionProbablility( return 1 / (1 + std::exp(-config->growth_rate * (loss - config->midpoint))); } +// TODO: bugs.webrtc.org/358039777 - Remove this function when Google +// downstream projects start using the correctly spelled function. +double CorruptionClassifier::CalculateCorruptionProbablility( + rtc::ArrayView filtered_original_samples, + rtc::ArrayView filtered_compressed_samples, + int luma_threshold, + int chroma_threshold) const { + return CalculateCorruptionProbability(filtered_original_samples, + filtered_compressed_samples, + luma_threshold, chroma_threshold); +} + // The score is calculated according to the following formula : // // score = (sum_i max{(|original_i - compressed_i| - threshold, 0)^2}) / N diff --git a/video/corruption_detection/corruption_classifier.h b/video/corruption_detection/corruption_classifier.h index 8e0c061fe0..538007b75b 100644 --- a/video/corruption_detection/corruption_classifier.h +++ b/video/corruption_detection/corruption_classifier.h @@ -18,7 +18,7 @@ namespace webrtc { -// Based on the given filtered samples to `CalculateCorruptionProbablility` this +// Based on the given filtered samples to `CalculateCorruptionProbability` this // class calculates a probability to indicate whether the frame is corrupted. // The classification is done either by scaling the loss to the interval of [0, // 1] using a simple `scale_factor` or by applying a logistic function to the @@ -41,6 +41,14 @@ class CorruptionClassifier { // scaling the loss to the interval of [0, 1] using a simple `scale_factor` // or by applying a logistic function to the loss. The method is chosen // depending on the used constructor. + double CalculateCorruptionProbability( + rtc::ArrayView filtered_original_samples, + rtc::ArrayView filtered_compressed_samples, + int luma_threshold, + int chroma_threshold) const; + + // TODO: bugs.webrtc.org/358039777 - Remove this function when Google + // downstream projects start using the correctly spelled function. double CalculateCorruptionProbablility( rtc::ArrayView filtered_original_samples, rtc::ArrayView filtered_compressed_samples, diff --git a/video/corruption_detection/corruption_classifier_unittest.cc b/video/corruption_detection/corruption_classifier_unittest.cc index 8a68d569e4..5f8252400e 100644 --- a/video/corruption_detection/corruption_classifier_unittest.cc +++ b/video/corruption_detection/corruption_classifier_unittest.cc @@ -63,7 +63,7 @@ std::vector GetCompressedSampleValues( #if GTEST_HAS_DEATH_TEST TEST(CorruptionClassifierTest, EmptySamplesShouldResultInDeath) { CorruptionClassifier corruption_classifier(kScaleFactor); - EXPECT_DEATH(corruption_classifier.CalculateCorruptionProbablility( + EXPECT_DEATH(corruption_classifier.CalculateCorruptionProbability( {}, {}, kLumaThreshold, kChromaThreshold), _); } @@ -73,7 +73,7 @@ TEST(CorruptionClassifierTest, DifferentAmountOfSamplesShouldResultInDeath) { const std::vector filtered_compressed_samples = { {.value = 1.0, .plane = ImagePlane::kLuma}}; - EXPECT_DEATH(corruption_classifier.CalculateCorruptionProbablility( + EXPECT_DEATH(corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, filtered_compressed_samples, kLumaThreshold, kChromaThreshold), HasSubstr("The original and compressed frame have different " @@ -95,7 +95,7 @@ TEST(CorruptionClassifierTest, // Logistic function giving the expected result inside DoubleNear. This // applies for all the following tests. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.0, kMaxAbsoluteError)); @@ -111,7 +111,7 @@ TEST(CorruptionClassifierTest, // Expected: score = 0. See above for explanation why we have `0.0009` below. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.0009, kMaxAbsoluteError)); @@ -128,7 +128,7 @@ TEST(CorruptionClassifierTest, // Expected: score = 0. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.0, kMaxAbsoluteError)); @@ -145,7 +145,7 @@ TEST(CorruptionClassifierTest, // Expected: score = 0. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.0009, kMaxAbsoluteError)); @@ -162,7 +162,7 @@ TEST(CorruptionClassifierTest, // Expected: score = (0.5)^2 / 3. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.0060, kMaxAbsoluteError)); @@ -179,7 +179,7 @@ TEST(CorruptionClassifierTest, // Expected: score = (0.5)^2 / 3. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.001, kMaxAbsoluteError)); @@ -196,7 +196,7 @@ TEST(CorruptionClassifierTest, // Expected: score = ((0.5)^2 + 2*(1.2)^2) / 3. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.07452, kMaxAbsoluteError)); @@ -213,7 +213,7 @@ TEST(CorruptionClassifierTest, // Expected: score = ((0.5)^2 + 2*(1.2)^2) / 3. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.0026, kMaxAbsoluteError)); @@ -233,7 +233,7 @@ TEST(CorruptionClassifierTest, // Expected: score = ((3)^2 + 2*(2)^2) / 3. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.4048, kMaxAbsoluteError)); @@ -250,7 +250,7 @@ TEST(CorruptionClassifierTest, // Expected: score = ((3)^2 + 2*(2)^2) / 3. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(0.2086, kMaxAbsoluteError)); @@ -267,7 +267,7 @@ TEST(CorruptionClassifierTest, // Expected: score = ((5)^2 + 2*(4)^2) / 3. Expected 1 because of capping. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(1, kMaxAbsoluteError)); @@ -284,7 +284,7 @@ TEST(CorruptionClassifierTest, // Expected: score = ((5)^2 + 2*(4)^2) / 3. EXPECT_THAT( - corruption_classifier.CalculateCorruptionProbablility( + corruption_classifier.CalculateCorruptionProbability( kFilteredOriginalSampleValues, kFilteredCompressedSampleValues, kLumaThreshold, kChromaThreshold), DoubleNear(1, kMaxAbsoluteError));