-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for producing approximate mean opinion scores.
Also added the possibility to produce unified output for all channels of a sound.
- Loading branch information
Showing
12 changed files
with
379 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2024 The Zimtohrli Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "zimt/mos.h" | ||
|
||
#include <array> | ||
#include <cmath> | ||
|
||
namespace zimtohrli { | ||
|
||
const std::array<float, 4> params = {3.439e+00, -4.138e-02, 3.008e+00, | ||
-1.354e-01}; | ||
|
||
namespace { | ||
|
||
float sigmoid(float x) { return 1 / (1 + std::exp(-x)); } | ||
|
||
} // namespace | ||
|
||
// Optimized using `mos_mapping.ipynb`. | ||
float MOSFromZimtohrli(float zimtohrli_distance) { | ||
return 1 + 2 * (sigmoid(params[0] + params[1] * zimtohrli_distance) + | ||
sigmoid(params[2] + params[3] * zimtohrli_distance)); | ||
} | ||
|
||
} // namespace zimtohrli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2024 The Zimtohrli Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef CPP_ZIMT_MOS_H_ | ||
#define CPP_ZIMT_MOS_H_ | ||
|
||
namespace zimtohrli { | ||
|
||
// Returns a _very_approximate_ mean opinion score based on the | ||
// provided Zimtohrli distance. | ||
// This is calibrated using default settings of v0.1.5, with a | ||
// minimum channel bandwidth (zimtohrli::Cam.minimum_bandwidth_hz) | ||
// of 5Hz and perceptual sample rate | ||
// (zimtohrli::Distance(..., perceptual_sample_rate, ...) of 100Hz. | ||
float MOSFromZimtohrli(float zimtohrli_distance); | ||
|
||
} // namespace zimtohrli | ||
|
||
#endif // CPP_ZIMT_MOS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2024 The Zimtohrli Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "zimt/mos.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace zimtohrli { | ||
|
||
namespace { | ||
|
||
TEST(MOS, MOSFromZimtohrli) { | ||
const std::vector<float> zimt_scores = {5, 20, 40, 80}; | ||
const std::vector<float> mos = {4.746790024702545, 4.01181593706087, | ||
2.8773086764995064, 2.0648331964917945}; | ||
for (size_t index = 0; index < zimt_scores.size(); ++index) { | ||
ASSERT_NEAR(MOSFromZimtohrli(zimt_scores[index]), mos[index], 1e-2); | ||
} | ||
} | ||
|
||
} // namespace | ||
|
||
} // namespace zimtohrli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.