Formatting ACM tests

Pure formatting of all files located in /webrtc/modules/audio_coding/main/test/

Smaller manual modifications done after using Eclipse formatting tool, like wrapping long lines (mostly comments).

BUG=issue1024

Review URL: https://webrtc-codereview.appspot.com/1342004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3946 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org
2013-05-03 07:34:12 +00:00
parent 03efc89151
commit d5726a1286
34 changed files with 4385 additions and 5230 deletions

View File

@ -63,25 +63,24 @@ class DelayTest {
public:
DelayTest()
: acm_a_(NULL),
acm_b_(NULL),
channel_a2b_(NULL),
test_cntr_(0),
encoding_sample_rate_hz_(8000) {
}
: acm_a_(NULL),
acm_b_(NULL),
channel_a2b_(NULL),
test_cntr_(0),
encoding_sample_rate_hz_(8000) {}
~DelayTest() {}
void TearDown() {
if(acm_a_ != NULL) {
if (acm_a_ != NULL) {
AudioCodingModule::Destroy(acm_a_);
acm_a_ = NULL;
}
if(acm_b_ != NULL) {
if (acm_b_ != NULL) {
AudioCodingModule::Destroy(acm_b_);
acm_b_ = NULL;
}
if(channel_a2b_ != NULL) {
if (channel_a2b_ != NULL) {
delete channel_a2b_;
channel_a2b_ = NULL;
}
@ -89,8 +88,8 @@ class DelayTest {
void SetUp() {
test_cntr_ = 0;
std::string file_name =
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
std::string file_name = webrtc::test::ResourcePath(
"audio_coding/testfile32kHz", "pcm");
if (FLAGS_input_file.size() > 0)
file_name = FLAGS_input_file;
in_file_a_.Open(file_name, 32000, "rb");
@ -108,15 +107,15 @@ class DelayTest {
uint8_t num_encoders = acm_a_->NumberOfCodecs();
CodecInst my_codec_param;
for(int n = 0; n < num_encoders; n++) {
for (int n = 0; n < num_encoders; n++) {
acm_b_->Codec(n, &my_codec_param);
if (STR_CASE_CMP(my_codec_param.plname, "opus") == 0)
my_codec_param.channels = 1;
else if (my_codec_param.channels > 1)
else if (my_codec_param.channels > 1)
continue;
if (STR_CASE_CMP(my_codec_param.plname, "CN") == 0 &&
my_codec_param.plfreq == 48000)
continue;
continue;
if (STR_CASE_CMP(my_codec_param.plname, "telephone-event") == 0)
continue;
acm_b_->RegisterReceiveCodec(my_codec_param);
@ -141,14 +140,13 @@ class DelayTest {
void ApplyConfig(const Config& config) {
printf("====================================\n");
printf("Test %d \n"
"Codec: %s, %d kHz, %d channel(s)\n"
"ACM: DTX %s, FEC %s\n"
"Channel: %s\n",
++test_cntr_,
config.codec.name, config.codec.sample_rate_hz,
config.codec.num_channels, config.acm.dtx ? "on" : "off",
config.acm.fec ? "on" : "off",
config.packet_loss ? "with packet-loss" : "no packet-loss");
"Codec: %s, %d kHz, %d channel(s)\n"
"ACM: DTX %s, FEC %s\n"
"Channel: %s\n",
++test_cntr_, config.codec.name, config.codec.sample_rate_hz,
config.codec.num_channels, config.acm.dtx ? "on" : "off",
config.acm.fec ? "on" : "off",
config.packet_loss ? "with packet-loss" : "no packet-loss");
SendCodec(config.codec);
ConfigAcm(config.acm);
ConfigChannel(config.packet_loss);
@ -156,9 +154,10 @@ class DelayTest {
void SendCodec(const CodecConfig& config) {
CodecInst my_codec_param;
ASSERT_EQ(0, AudioCodingModule::Codec(config.name, &my_codec_param,
config.sample_rate_hz,
config.num_channels));
ASSERT_EQ(
0,
AudioCodingModule::Codec(config.name, &my_codec_param,
config.sample_rate_hz, config.num_channels));
encoding_sample_rate_hz_ = my_codec_param.plfreq;
ASSERT_EQ(0, acm_a_->RegisterSendCodec(my_codec_param));
}
@ -174,11 +173,9 @@ class DelayTest {
void OpenOutFile(const char* output_id) {
std::stringstream file_stream;
file_stream << "delay_test_" << FLAGS_codec << "_"
<< FLAGS_sample_rate_hz << "Hz" << "_"
<< FLAGS_init_delay << "ms_"
<< FLAGS_delay << "ms.pcm";
std::cout << "Output file: " << file_stream.str() << std::endl <<std::endl;
file_stream << "delay_test_" << FLAGS_codec << "_" << FLAGS_sample_rate_hz
<< "Hz" << "_" << FLAGS_init_delay << "ms_" << FLAGS_delay << "ms.pcm";
std::cout << "Output file: " << file_stream.str() << std::endl << std::endl;
std::string file_name = webrtc::test::OutputPath() + file_stream.str();
out_file_b_.Open(file_name.c_str(), 32000, "wb");
}
@ -194,7 +191,7 @@ class DelayTest {
uint32_t received_ts;
double average_delay = 0;
double inst_delay_sec = 0;
while(num_frames < (duration_sec * 100)) {
while (num_frames < (duration_sec * 100)) {
if (in_file_a_.EndOfFile()) {
in_file_a_.Rewind();
}
@ -206,27 +203,24 @@ class DelayTest {
fprintf(stdout, "delay: min=%3d max=%3d mean=%3d median=%3d"
" ts-based average = %6.3f, "
"curr buff-lev = %4u opt buff-lev = %4u \n",
statistics.minWaitingTimeMs,
statistics.maxWaitingTimeMs,
statistics.meanWaitingTimeMs,
statistics.medianWaitingTimeMs,
average_delay,
statistics.currentBufferSize,
statistics.minWaitingTimeMs, statistics.maxWaitingTimeMs,
statistics.meanWaitingTimeMs, statistics.medianWaitingTimeMs,
average_delay, statistics.currentBufferSize,
statistics.preferredBufferSize);
fflush(stdout);
fflush (stdout);
}
in_file_a_.Read10MsData(audio_frame);
ASSERT_EQ(0, acm_a_->Add10MsData(audio_frame));
ASSERT_LE(0, acm_a_->Process());
ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
out_file_b_.Write10MsData(audio_frame.data_,
audio_frame.samples_per_channel_ *
audio_frame.num_channels_);
out_file_b_.Write10MsData(
audio_frame.data_,
audio_frame.samples_per_channel_ * audio_frame.num_channels_);
acm_b_->PlayoutTimestamp(&playout_ts);
received_ts = channel_a2b_->LastInTimestamp();
inst_delay_sec = static_cast<uint32_t>(received_ts - playout_ts) /
static_cast<double>(encoding_sample_rate_hz_);
inst_delay_sec = static_cast<uint32_t>(received_ts - playout_ts)
/ static_cast<double>(encoding_sample_rate_hz_);
if (num_frames > 10)
average_delay = 0.95 * average_delay + 0.05 * inst_delay_sec;
@ -248,7 +242,7 @@ class DelayTest {
int encoding_sample_rate_hz_;
};
} // namespace webrtc
} // namespace webrtc
int main(int argc, char* argv[]) {