[go: nahoru, domu]

Skip to content

Commit

Permalink
Fixed dereferencing offset in some places
Browse files Browse the repository at this point in the history
  • Loading branch information
kinarr committed Jul 12, 2022
1 parent 630d2e3 commit 085eb8c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions tensorflow_lite_support/cc/task/audio/utils/audio_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace task {
namespace audio {

tflite::support::StatusOr<AudioBuffer> LoadAudioBufferFromFile(
const std::string& wav_file_path, int buffer_size, uint32_t* offset,
const std::string& wav_file_path, uint32_t* buffer_size, uint32_t* offset,
std::vector<float>* wav_data) {
std::string contents = ReadFile(wav_file_path);

Expand All @@ -32,8 +32,8 @@ tflite::support::StatusOr<AudioBuffer> LoadAudioBufferFromFile(
contents, wav_data, offset, &decoded_sample_count, &decoded_channel_count,
&decoded_sample_rate));

if (decoded_sample_count > buffer_size) {
decoded_sample_count = buffer_size;
if (decoded_sample_count > *buffer_size) {
decoded_sample_count = *buffer_size;
}

return AudioBuffer(
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_lite_support/cc/task/audio/utils/audio_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace audio {
// object, the user of this function has to make sure that wav_data outlives the
// returned AudioBuffer object.
tflite::support::StatusOr<AudioBuffer> LoadAudioBufferFromFile(
const std::string& wav_file_path, int buffer_size, uint32_t* offset,
const std::string& wav_file_path, uint32_t* buffer_size, uint32_t* offset,
std::vector<float>* wav_data);

} // namespace audio
Expand Down
4 changes: 2 additions & 2 deletions tensorflow_lite_support/cc/task/audio/utils/wav_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ absl::Status DecodeLin16WaveAsFloatVector(const std::string& wav_string,
}
if (format_chunk_size == 18) {
// Skip over this unused section.
offset += 2;
*offset += 2;
}

bool was_data_found = false;
Expand Down Expand Up @@ -213,7 +213,7 @@ absl::Status DecodeLin16WaveAsFloatVector(const std::string& wav_string,
(*float_values)[i] = Int16SampleToFloat(single_channel_value);
}
} else {
offset += chunk_size;
*offset += chunk_size;
}
}
if (!was_data_found) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PYBIND11_MODULE(_pywrap_audio_buffer, m) {
});

m.def("LoadAudioBufferFromFile",
[](const std::string& wav_file, int buffer_size, uint32_t* offset,
[](const std::string& wav_file, uint32_t* buffer_size, uint32_t* offset,
py::buffer buffer) -> AudioBuffer {
py::buffer_info info = buffer.request();

Expand Down

0 comments on commit 085eb8c

Please sign in to comment.