2011-10-26 00:27:17 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// Commandline tool to unpack audioproc debug files.
|
|
|
|
|
//
|
|
|
|
|
// The debug files are dumped as protobuf blobs. For analysis, it's necessary
|
|
|
|
|
// to unpack the file into its component parts: audio and other data.
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2016-02-17 06:39:05 -08:00
|
|
|
#include <memory>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/test/protobuf_utils.h"
|
|
|
|
|
#include "modules/audio_processing/test/test_utils.h"
|
|
|
|
|
#include "rtc_base/flags.h"
|
|
|
|
|
#include "rtc_base/format_macros.h"
|
|
|
|
|
#include "rtc_base/ignore_wundef.h"
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "typedefs.h" // NOLINT(build/include)
|
2011-10-26 00:27:17 +00:00
|
|
|
|
2016-09-28 17:42:01 -07:00
|
|
|
RTC_PUSH_IGNORING_WUNDEF()
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/debug.pb.h"
|
2016-09-28 17:42:01 -07:00
|
|
|
RTC_POP_IGNORING_WUNDEF()
|
|
|
|
|
|
2011-10-26 00:27:17 +00:00
|
|
|
// TODO(andrew): unpack more of the data.
|
2014-09-04 18:12:00 +00:00
|
|
|
DEFINE_string(input_file, "input", "The name of the input stream file.");
|
|
|
|
|
DEFINE_string(output_file, "ref_out",
|
2011-11-11 19:13:36 +00:00
|
|
|
"The name of the reference output stream file.");
|
2014-09-04 18:12:00 +00:00
|
|
|
DEFINE_string(reverse_file, "reverse",
|
2011-11-11 19:13:36 +00:00
|
|
|
"The name of the reverse input stream file.");
|
|
|
|
|
DEFINE_string(delay_file, "delay.int32", "The name of the delay file.");
|
|
|
|
|
DEFINE_string(drift_file, "drift.int32", "The name of the drift file.");
|
|
|
|
|
DEFINE_string(level_file, "level.int32", "The name of the level file.");
|
2014-02-12 15:28:30 +00:00
|
|
|
DEFINE_string(keypress_file, "keypress.bool", "The name of the keypress file.");
|
2011-11-11 19:13:36 +00:00
|
|
|
DEFINE_string(settings_file, "settings.txt", "The name of the settings file.");
|
|
|
|
|
DEFINE_bool(full, false,
|
|
|
|
|
"Unpack the full set of files (normally not needed).");
|
2014-09-04 18:12:00 +00:00
|
|
|
DEFINE_bool(raw, false, "Write raw data instead of a WAV file.");
|
2015-05-06 10:51:34 +02:00
|
|
|
DEFINE_bool(text,
|
|
|
|
|
false,
|
|
|
|
|
"Write non-audio files as text files instead of binary files.");
|
2017-08-31 03:21:39 -07:00
|
|
|
DEFINE_bool(help, false, "Print this message.");
|
2011-10-26 00:27:17 +00:00
|
|
|
|
2015-10-03 00:39:14 +02:00
|
|
|
#define PRINT_CONFIG(field_name) \
|
|
|
|
|
if (msg.has_##field_name()) { \
|
|
|
|
|
fprintf(settings_file, " " #field_name ": %d\n", msg.field_name()); \
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-16 13:52:32 +02:00
|
|
|
#define PRINT_CONFIG_FLOAT(field_name) \
|
|
|
|
|
if (msg.has_##field_name()) { \
|
|
|
|
|
fprintf(settings_file, " " #field_name ": %f\n", msg.field_name()); \
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:26:12 +00:00
|
|
|
namespace webrtc {
|
2011-10-26 00:27:17 +00:00
|
|
|
|
2014-03-10 22:26:12 +00:00
|
|
|
using audioproc::Event;
|
|
|
|
|
using audioproc::ReverseStream;
|
|
|
|
|
using audioproc::Stream;
|
|
|
|
|
using audioproc::Init;
|
2011-10-26 00:27:17 +00:00
|
|
|
|
2014-03-10 22:26:12 +00:00
|
|
|
void WriteData(const void* data, size_t size, FILE* file,
|
|
|
|
|
const std::string& filename) {
|
|
|
|
|
if (fwrite(data, size, 1, file) != 1) {
|
|
|
|
|
printf("Error when writing to %s\n", filename.c_str());
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
2011-10-26 00:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:26:12 +00:00
|
|
|
int do_main(int argc, char* argv[]) {
|
2011-10-26 00:27:17 +00:00
|
|
|
std::string program_name = argv[0];
|
|
|
|
|
std::string usage = "Commandline tool to unpack audioproc debug files.\n"
|
|
|
|
|
"Example usage:\n" + program_name + " debug_dump.pb\n";
|
|
|
|
|
|
2017-08-31 03:21:39 -07:00
|
|
|
if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
|
|
|
|
|
FLAG_help || argc < 2) {
|
|
|
|
|
printf("%s", usage.c_str());
|
|
|
|
|
if (FLAG_help) {
|
|
|
|
|
rtc::FlagList::Print(nullptr, false);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2011-10-26 00:27:17 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-10 22:26:12 +00:00
|
|
|
FILE* debug_file = OpenFile(argv[1], "rb");
|
2011-11-11 19:13:36 +00:00
|
|
|
|
2011-10-26 00:27:17 +00:00
|
|
|
Event event_msg;
|
2011-11-11 19:13:36 +00:00
|
|
|
int frame_count = 0;
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
size_t reverse_samples_per_channel = 0;
|
|
|
|
|
size_t input_samples_per_channel = 0;
|
|
|
|
|
size_t output_samples_per_channel = 0;
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
size_t num_reverse_channels = 0;
|
|
|
|
|
size_t num_input_channels = 0;
|
|
|
|
|
size_t num_output_channels = 0;
|
2016-02-17 06:39:05 -08:00
|
|
|
std::unique_ptr<WavWriter> reverse_wav_file;
|
|
|
|
|
std::unique_ptr<WavWriter> input_wav_file;
|
|
|
|
|
std::unique_ptr<WavWriter> output_wav_file;
|
|
|
|
|
std::unique_ptr<RawFile> reverse_raw_file;
|
|
|
|
|
std::unique_ptr<RawFile> input_raw_file;
|
|
|
|
|
std::unique_ptr<RawFile> output_raw_file;
|
2015-10-03 00:39:14 +02:00
|
|
|
|
2017-08-31 03:21:39 -07:00
|
|
|
FILE* settings_file = OpenFile(FLAG_settings_file, "wb");
|
2015-10-03 00:39:14 +02:00
|
|
|
|
2014-09-02 07:51:51 +00:00
|
|
|
while (ReadMessageFromFile(debug_file, &event_msg)) {
|
2011-10-26 00:27:17 +00:00
|
|
|
if (event_msg.type() == Event::REVERSE_STREAM) {
|
|
|
|
|
if (!event_msg.has_reverse_stream()) {
|
2014-03-10 22:26:12 +00:00
|
|
|
printf("Corrupt input file: ReverseStream missing.\n");
|
2011-10-26 00:27:17 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ReverseStream msg = event_msg.reverse_stream();
|
2011-11-11 19:13:36 +00:00
|
|
|
if (msg.has_data()) {
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_raw && !reverse_raw_file) {
|
|
|
|
|
reverse_raw_file.reset(new RawFile(std::string(FLAG_reverse_file) +
|
|
|
|
|
".pcm"));
|
2014-09-04 18:12:00 +00:00
|
|
|
}
|
2014-09-03 13:39:01 +00:00
|
|
|
// TODO(aluebs): Replace "num_reverse_channels *
|
|
|
|
|
// reverse_samples_per_channel" with "msg.data().size() /
|
|
|
|
|
// sizeof(int16_t)" and so on when this fix in audio_processing has made
|
|
|
|
|
// it into stable: https://webrtc-codereview.appspot.com/15299004/
|
2014-09-02 07:51:51 +00:00
|
|
|
WriteIntData(reinterpret_cast<const int16_t*>(msg.data().data()),
|
2014-09-03 13:39:01 +00:00
|
|
|
num_reverse_channels * reverse_samples_per_channel,
|
2014-09-02 07:51:51 +00:00
|
|
|
reverse_wav_file.get(),
|
2014-09-04 18:12:00 +00:00
|
|
|
reverse_raw_file.get());
|
2014-03-10 22:26:12 +00:00
|
|
|
} else if (msg.channel_size() > 0) {
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_raw && !reverse_raw_file) {
|
|
|
|
|
reverse_raw_file.reset(new RawFile(std::string(FLAG_reverse_file) +
|
|
|
|
|
".float"));
|
2014-09-04 18:12:00 +00:00
|
|
|
}
|
2016-02-17 06:39:05 -08:00
|
|
|
std::unique_ptr<const float* []> data(
|
2015-02-26 14:34:55 +00:00
|
|
|
new const float* [num_reverse_channels]);
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < num_reverse_channels; ++i) {
|
2014-09-02 07:51:51 +00:00
|
|
|
data[i] = reinterpret_cast<const float*>(msg.channel(i).data());
|
|
|
|
|
}
|
|
|
|
|
WriteFloatData(data.get(),
|
2014-09-03 13:39:01 +00:00
|
|
|
reverse_samples_per_channel,
|
2014-09-02 07:51:51 +00:00
|
|
|
num_reverse_channels,
|
|
|
|
|
reverse_wav_file.get(),
|
2014-09-04 18:12:00 +00:00
|
|
|
reverse_raw_file.get());
|
2011-10-26 00:27:17 +00:00
|
|
|
}
|
|
|
|
|
} else if (event_msg.type() == Event::STREAM) {
|
2011-11-11 19:13:36 +00:00
|
|
|
frame_count++;
|
2011-10-26 00:27:17 +00:00
|
|
|
if (!event_msg.has_stream()) {
|
2014-03-10 22:26:12 +00:00
|
|
|
printf("Corrupt input file: Stream missing.\n");
|
2011-10-26 00:27:17 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const Stream msg = event_msg.stream();
|
2011-11-11 19:13:36 +00:00
|
|
|
if (msg.has_input_data()) {
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_raw && !input_raw_file) {
|
|
|
|
|
input_raw_file.reset(new RawFile(std::string(FLAG_input_file) +
|
|
|
|
|
".pcm"));
|
2014-09-04 18:12:00 +00:00
|
|
|
}
|
2014-09-02 07:51:51 +00:00
|
|
|
WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()),
|
2014-09-03 13:39:01 +00:00
|
|
|
num_input_channels * input_samples_per_channel,
|
2014-09-02 07:51:51 +00:00
|
|
|
input_wav_file.get(),
|
2014-09-04 18:12:00 +00:00
|
|
|
input_raw_file.get());
|
2014-03-10 22:26:12 +00:00
|
|
|
} else if (msg.input_channel_size() > 0) {
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_raw && !input_raw_file) {
|
|
|
|
|
input_raw_file.reset(new RawFile(std::string(FLAG_input_file) +
|
|
|
|
|
".float"));
|
2014-09-04 18:12:00 +00:00
|
|
|
}
|
2016-02-17 06:39:05 -08:00
|
|
|
std::unique_ptr<const float* []> data(
|
2015-02-26 14:34:55 +00:00
|
|
|
new const float* [num_input_channels]);
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < num_input_channels; ++i) {
|
2014-09-02 07:51:51 +00:00
|
|
|
data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data());
|
|
|
|
|
}
|
|
|
|
|
WriteFloatData(data.get(),
|
2014-09-03 13:39:01 +00:00
|
|
|
input_samples_per_channel,
|
2014-09-02 07:51:51 +00:00
|
|
|
num_input_channels,
|
|
|
|
|
input_wav_file.get(),
|
2014-09-04 18:12:00 +00:00
|
|
|
input_raw_file.get());
|
2011-10-26 00:27:17 +00:00
|
|
|
}
|
2011-11-11 19:13:36 +00:00
|
|
|
|
|
|
|
|
if (msg.has_output_data()) {
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_raw && !output_raw_file) {
|
|
|
|
|
output_raw_file.reset(new RawFile(std::string(FLAG_output_file) +
|
|
|
|
|
".pcm"));
|
2014-09-04 18:12:00 +00:00
|
|
|
}
|
2014-09-02 07:51:51 +00:00
|
|
|
WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()),
|
2014-09-03 13:39:01 +00:00
|
|
|
num_output_channels * output_samples_per_channel,
|
2014-09-02 07:51:51 +00:00
|
|
|
output_wav_file.get(),
|
2014-09-04 18:12:00 +00:00
|
|
|
output_raw_file.get());
|
2014-03-10 22:26:12 +00:00
|
|
|
} else if (msg.output_channel_size() > 0) {
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_raw && !output_raw_file) {
|
|
|
|
|
output_raw_file.reset(new RawFile(std::string(FLAG_output_file) +
|
|
|
|
|
".float"));
|
2014-09-04 18:12:00 +00:00
|
|
|
}
|
2016-02-17 06:39:05 -08:00
|
|
|
std::unique_ptr<const float* []> data(
|
2015-02-26 14:34:55 +00:00
|
|
|
new const float* [num_output_channels]);
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
for (size_t i = 0; i < num_output_channels; ++i) {
|
2014-09-02 07:51:51 +00:00
|
|
|
data[i] =
|
|
|
|
|
reinterpret_cast<const float*>(msg.output_channel(i).data());
|
|
|
|
|
}
|
|
|
|
|
WriteFloatData(data.get(),
|
2014-09-03 13:39:01 +00:00
|
|
|
output_samples_per_channel,
|
2014-09-02 07:51:51 +00:00
|
|
|
num_output_channels,
|
|
|
|
|
output_wav_file.get(),
|
2014-09-04 18:12:00 +00:00
|
|
|
output_raw_file.get());
|
2011-10-26 00:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_full) {
|
2011-11-11 19:13:36 +00:00
|
|
|
if (msg.has_delay()) {
|
2017-08-31 03:21:39 -07:00
|
|
|
static FILE* delay_file = OpenFile(FLAG_delay_file, "wb");
|
2011-11-11 19:13:36 +00:00
|
|
|
int32_t delay = msg.delay();
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_text) {
|
2015-05-06 10:51:34 +02:00
|
|
|
fprintf(delay_file, "%d\n", delay);
|
|
|
|
|
} else {
|
2017-08-31 03:21:39 -07:00
|
|
|
WriteData(&delay, sizeof(delay), delay_file, FLAG_delay_file);
|
2015-05-06 10:51:34 +02:00
|
|
|
}
|
2011-11-11 19:13:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (msg.has_drift()) {
|
2017-08-31 03:21:39 -07:00
|
|
|
static FILE* drift_file = OpenFile(FLAG_drift_file, "wb");
|
2011-11-11 19:13:36 +00:00
|
|
|
int32_t drift = msg.drift();
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_text) {
|
2015-05-06 10:51:34 +02:00
|
|
|
fprintf(drift_file, "%d\n", drift);
|
|
|
|
|
} else {
|
2017-08-31 03:21:39 -07:00
|
|
|
WriteData(&drift, sizeof(drift), drift_file, FLAG_drift_file);
|
2015-05-06 10:51:34 +02:00
|
|
|
}
|
2011-11-11 19:13:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (msg.has_level()) {
|
2017-08-31 03:21:39 -07:00
|
|
|
static FILE* level_file = OpenFile(FLAG_level_file, "wb");
|
2011-11-11 19:13:36 +00:00
|
|
|
int32_t level = msg.level();
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_text) {
|
2015-05-06 10:51:34 +02:00
|
|
|
fprintf(level_file, "%d\n", level);
|
|
|
|
|
} else {
|
2017-08-31 03:21:39 -07:00
|
|
|
WriteData(&level, sizeof(level), level_file, FLAG_level_file);
|
2015-05-06 10:51:34 +02:00
|
|
|
}
|
2011-11-11 19:13:36 +00:00
|
|
|
}
|
2014-02-12 15:28:30 +00:00
|
|
|
|
|
|
|
|
if (msg.has_keypress()) {
|
2017-08-31 03:21:39 -07:00
|
|
|
static FILE* keypress_file = OpenFile(FLAG_keypress_file, "wb");
|
2014-02-12 15:28:30 +00:00
|
|
|
bool keypress = msg.keypress();
|
2017-08-31 03:21:39 -07:00
|
|
|
if (FLAG_text) {
|
2015-05-06 10:51:34 +02:00
|
|
|
fprintf(keypress_file, "%d\n", keypress);
|
|
|
|
|
} else {
|
|
|
|
|
WriteData(&keypress, sizeof(keypress), keypress_file,
|
2017-08-31 03:21:39 -07:00
|
|
|
FLAG_keypress_file);
|
2015-05-06 10:51:34 +02:00
|
|
|
}
|
2014-02-12 15:28:30 +00:00
|
|
|
}
|
2011-10-26 00:27:17 +00:00
|
|
|
}
|
2015-10-03 00:39:14 +02:00
|
|
|
} else if (event_msg.type() == Event::CONFIG) {
|
|
|
|
|
if (!event_msg.has_config()) {
|
|
|
|
|
printf("Corrupt input file: Config missing.\n");
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
const audioproc::Config msg = event_msg.config();
|
|
|
|
|
|
|
|
|
|
fprintf(settings_file, "APM re-config at frame: %d\n", frame_count);
|
|
|
|
|
|
|
|
|
|
PRINT_CONFIG(aec_enabled);
|
|
|
|
|
PRINT_CONFIG(aec_delay_agnostic_enabled);
|
|
|
|
|
PRINT_CONFIG(aec_drift_compensation_enabled);
|
|
|
|
|
PRINT_CONFIG(aec_extended_filter_enabled);
|
|
|
|
|
PRINT_CONFIG(aec_suppression_level);
|
|
|
|
|
PRINT_CONFIG(aecm_enabled);
|
|
|
|
|
PRINT_CONFIG(aecm_comfort_noise_enabled);
|
|
|
|
|
PRINT_CONFIG(aecm_routing_mode);
|
|
|
|
|
PRINT_CONFIG(agc_enabled);
|
|
|
|
|
PRINT_CONFIG(agc_mode);
|
|
|
|
|
PRINT_CONFIG(agc_limiter_enabled);
|
|
|
|
|
PRINT_CONFIG(noise_robust_agc_enabled);
|
|
|
|
|
PRINT_CONFIG(hpf_enabled);
|
|
|
|
|
PRINT_CONFIG(ns_enabled);
|
|
|
|
|
PRINT_CONFIG(ns_level);
|
|
|
|
|
PRINT_CONFIG(transient_suppression_enabled);
|
2016-05-16 15:32:38 -07:00
|
|
|
PRINT_CONFIG(intelligibility_enhancer_enabled);
|
2018-04-16 13:52:32 +02:00
|
|
|
PRINT_CONFIG(pre_amplifier_enabled);
|
|
|
|
|
PRINT_CONFIG_FLOAT(pre_amplifier_fixed_gain_factor);
|
|
|
|
|
|
2016-04-15 01:19:44 -07:00
|
|
|
if (msg.has_experiments_description()) {
|
|
|
|
|
fprintf(settings_file, " experiments_description: %s\n",
|
|
|
|
|
msg.experiments_description().c_str());
|
|
|
|
|
}
|
2011-11-11 19:13:36 +00:00
|
|
|
} else if (event_msg.type() == Event::INIT) {
|
|
|
|
|
if (!event_msg.has_init()) {
|
2014-03-10 22:26:12 +00:00
|
|
|
printf("Corrupt input file: Init missing.\n");
|
2011-10-26 00:27:17 +00:00
|
|
|
return 1;
|
|
|
|
|
}
|
2011-11-11 19:13:36 +00:00
|
|
|
|
|
|
|
|
const Init msg = event_msg.init();
|
|
|
|
|
// These should print out zeros if they're missing.
|
|
|
|
|
fprintf(settings_file, "Init at frame: %d\n", frame_count);
|
2014-09-02 07:51:51 +00:00
|
|
|
int input_sample_rate = msg.sample_rate();
|
|
|
|
|
fprintf(settings_file, " Input sample rate: %d\n", input_sample_rate);
|
|
|
|
|
int output_sample_rate = msg.output_sample_rate();
|
|
|
|
|
fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate);
|
|
|
|
|
int reverse_sample_rate = msg.reverse_sample_rate();
|
|
|
|
|
fprintf(settings_file,
|
|
|
|
|
" Reverse sample rate: %d\n",
|
|
|
|
|
reverse_sample_rate);
|
|
|
|
|
num_input_channels = msg.num_input_channels();
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
fprintf(settings_file, " Input channels: %" PRIuS "\n",
|
|
|
|
|
num_input_channels);
|
2014-09-02 07:51:51 +00:00
|
|
|
num_output_channels = msg.num_output_channels();
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
fprintf(settings_file, " Output channels: %" PRIuS "\n",
|
|
|
|
|
num_output_channels);
|
2014-09-02 07:51:51 +00:00
|
|
|
num_reverse_channels = msg.num_reverse_channels();
|
Convert channel counts to size_t.
IIRC, this was originally requested by ajm during review of the other size_t conversions I did over the past year, and I agreed it made sense, but wanted to do it separately since those changes were already gargantuan.
BUG=chromium:81439
TEST=none
R=henrik.lundin@webrtc.org, henrika@webrtc.org, kjellander@webrtc.org, minyue@webrtc.org, perkj@webrtc.org, solenberg@webrtc.org, stefan@webrtc.org, tina.legrand@webrtc.org
Review URL: https://codereview.webrtc.org/1316523002 .
Cr-Commit-Position: refs/heads/master@{#11229}
2016-01-12 16:26:35 -08:00
|
|
|
fprintf(settings_file, " Reverse channels: %" PRIuS "\n",
|
|
|
|
|
num_reverse_channels);
|
2011-11-11 19:13:36 +00:00
|
|
|
|
|
|
|
|
fprintf(settings_file, "\n");
|
2014-09-02 07:51:51 +00:00
|
|
|
|
|
|
|
|
if (reverse_sample_rate == 0) {
|
|
|
|
|
reverse_sample_rate = input_sample_rate;
|
|
|
|
|
}
|
|
|
|
|
if (output_sample_rate == 0) {
|
|
|
|
|
output_sample_rate = input_sample_rate;
|
|
|
|
|
}
|
|
|
|
|
|
Misc. small cleanups.
* Better param names
* Avoid using negative values for (bogus) placeholder channel counts (mostly in tests). Since channels will be changing to size_t, negative values will be illegal; it's sufficient to use 0 in these cases.
* Use arraysize()
* Use size_t for counting frames, samples, blocks, buffers, and bytes -- most of these are already size_t in most places, this just fixes some stragglers
* reinterpret_cast<int64_t>(void*) is not necessarily safe; use uintptr_t instead
* Remove unnecessary code, e.g. dead code, needlessly long/repetitive code, or function overrides that exactly match the base definition
* Fix indenting
* Use uint32_t for timestamps (matching how it's already a uint32_t in most places)
* Spelling
* RTC_CHECK_EQ(expected, actual)
* Rewrap
* Use .empty()
* Be more pedantic about matching int/int32_t/
* Remove pointless consts on input parameters to functions
* Add missing sanity checks
All this was found in the course of constructing https://codereview.webrtc.org/1316523002/ , and is being landed separately first.
BUG=none
TEST=none
Review URL: https://codereview.webrtc.org/1534193008
Cr-Commit-Position: refs/heads/master@{#11191}
2016-01-08 13:50:27 -08:00
|
|
|
reverse_samples_per_channel =
|
|
|
|
|
static_cast<size_t>(reverse_sample_rate / 100);
|
|
|
|
|
input_samples_per_channel =
|
|
|
|
|
static_cast<size_t>(input_sample_rate / 100);
|
|
|
|
|
output_samples_per_channel =
|
|
|
|
|
static_cast<size_t>(output_sample_rate / 100);
|
2014-09-03 13:39:01 +00:00
|
|
|
|
2017-08-31 03:21:39 -07:00
|
|
|
if (!FLAG_raw) {
|
2014-09-04 18:12:00 +00:00
|
|
|
// The WAV files need to be reset every time, because they cant change
|
|
|
|
|
// their sample rate or number of channels.
|
2016-06-17 09:41:41 -07:00
|
|
|
std::stringstream reverse_name;
|
2017-08-31 03:21:39 -07:00
|
|
|
reverse_name << FLAG_reverse_file << frame_count << ".wav";
|
2016-06-17 09:41:41 -07:00
|
|
|
reverse_wav_file.reset(new WavWriter(reverse_name.str(),
|
2014-10-31 21:51:03 +00:00
|
|
|
reverse_sample_rate,
|
|
|
|
|
num_reverse_channels));
|
2016-06-17 09:41:41 -07:00
|
|
|
std::stringstream input_name;
|
2017-08-31 03:21:39 -07:00
|
|
|
input_name << FLAG_input_file << frame_count << ".wav";
|
2016-06-17 09:41:41 -07:00
|
|
|
input_wav_file.reset(new WavWriter(input_name.str(),
|
2014-10-31 21:51:03 +00:00
|
|
|
input_sample_rate,
|
|
|
|
|
num_input_channels));
|
2016-06-17 09:41:41 -07:00
|
|
|
std::stringstream output_name;
|
2017-08-31 03:21:39 -07:00
|
|
|
output_name << FLAG_output_file << frame_count << ".wav";
|
2016-06-17 09:41:41 -07:00
|
|
|
output_wav_file.reset(new WavWriter(output_name.str(),
|
2014-10-31 21:51:03 +00:00
|
|
|
output_sample_rate,
|
|
|
|
|
num_output_channels));
|
2014-09-02 07:51:51 +00:00
|
|
|
}
|
2011-10-26 00:27:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2014-03-10 22:26:12 +00:00
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
|
return webrtc::do_main(argc, argv);
|
|
|
|
|
}
|