Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug in ViSQOL model file extraction. #46

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmake/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ add_test(NAME zimtohrli_loudness_computation_ipynb_test
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)


add_test(NAME zimtohrli_go_test
COMMAND go test ./...
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
Expand Down
15 changes: 11 additions & 4 deletions cpp/zimt/visqol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@

#include "zimt/visqol.h"

#include <iostream>
#include <cerrno>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <random>
#include <string>
#include <vector>

#include "absl/log/check.h"
#include "absl/types/span.h"
Expand All @@ -27,13 +33,14 @@ constexpr size_t SAMPLE_RATE = 48000;
namespace zimtohrli {

ViSQOL::ViSQOL() {
std::string path_template = (std::filesystem::path(std::string(P_tmpdir)) /
std::string path_template = (std::filesystem::temp_directory_path() /
"zimtohrli_cpp_zimt_visqol_model_XXXXXX")
.string();
std::vector<char> populated_path_template(path_template.begin(),
path_template.end());
int model_path_file = mkstemp(populated_path_template.data());
CHECK_GT(model_path_file, 0);
populated_path_template.push_back('\0');
const int model_path_file = mkstemp(populated_path_template.data());
CHECK_GT(model_path_file, 0) << strerror(errno);
CHECK_EQ(close(model_path_file), 0);
model_path_ = std::filesystem::path(std::string(
populated_path_template.data(), populated_path_template.size()));
Expand Down
2 changes: 1 addition & 1 deletion cpp/zimt/visqol_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace zimtohrli {

absl::Span<char> ViSQOLModel() {
absl::Span<const char> ViSQOLModel() {
return absl::Span<char>(reinterpret_cast<char*>(visqol_model_bytes),
visqol_model_bytes_len);
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/zimt/visqol_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
namespace zimtohrli {

// Returns the bytes of the default ViSQOL model.
absl::Span<char> ViSQOLModel();
absl::Span<const char> ViSQOLModel();

} // namespace zimtohrli

Expand Down
Binary file modified go/goohrli/goohrli.a
Binary file not shown.
Loading