Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_unittest.cc

Issue 1515113002: Adding bit exactness test for Opus decoding in NetEq. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: adding ref file for win (since non-bit-exact) Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « resources/audio_coding/neteq_opus.rtp.sha1 ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 ASSERT_EQ(stats.preferred_buffer_size_ms, 222 ASSERT_EQ(stats.preferred_buffer_size_ms,
223 ref_stats.preferred_buffer_size_ms()); 223 ref_stats.preferred_buffer_size_ms());
224 ASSERT_EQ(stats.jitter_peaks_found, ref_stats.jitter_peaks_found()); 224 ASSERT_EQ(stats.jitter_peaks_found, ref_stats.jitter_peaks_found());
225 ASSERT_EQ(stats.packet_loss_rate, ref_stats.packet_loss_rate()); 225 ASSERT_EQ(stats.packet_loss_rate, ref_stats.packet_loss_rate());
226 ASSERT_EQ(stats.packet_discard_rate, ref_stats.packet_discard_rate()); 226 ASSERT_EQ(stats.packet_discard_rate, ref_stats.packet_discard_rate());
227 ASSERT_EQ(stats.expand_rate, ref_stats.expand_rate()); 227 ASSERT_EQ(stats.expand_rate, ref_stats.expand_rate());
228 ASSERT_EQ(stats.preemptive_rate, ref_stats.preemptive_rate()); 228 ASSERT_EQ(stats.preemptive_rate, ref_stats.preemptive_rate());
229 ASSERT_EQ(stats.accelerate_rate, ref_stats.accelerate_rate()); 229 ASSERT_EQ(stats.accelerate_rate, ref_stats.accelerate_rate());
230 ASSERT_EQ(stats.clockdrift_ppm, ref_stats.clockdrift_ppm()); 230 ASSERT_EQ(stats.clockdrift_ppm, ref_stats.clockdrift_ppm());
231 ASSERT_EQ(stats.added_zero_samples, ref_stats.added_zero_samples()); 231 ASSERT_EQ(stats.added_zero_samples, ref_stats.added_zero_samples());
232 ASSERT_EQ(stats.secondary_decoded_rate, 0); 232 ASSERT_EQ(stats.secondary_decoded_rate, ref_stats.secondary_decoded_rate());
233 ASSERT_LE(stats.speech_expand_rate, ref_stats.expand_rate()); 233 ASSERT_LE(stats.speech_expand_rate, ref_stats.expand_rate());
234 #else 234 #else
235 FAIL() << "Reading from reference file requires Proto Buffer."; 235 FAIL() << "Reading from reference file requires Proto Buffer.";
236 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT 236 #endif // WEBRTC_NETEQ_UNITTEST_BITEXACT
237 } 237 }
238 238
239 void RefFiles::WriteToFile(const RtcpStatistics& stats_raw) { 239 void RefFiles::WriteToFile(const RtcpStatistics& stats_raw) {
240 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT 240 #ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT
241 if (!output_fp_) 241 if (!output_fp_)
242 return; 242 return;
(...skipping 29 matching lines...) Expand all
272 } 272 }
273 273
274 class NetEqDecodingTest : public ::testing::Test { 274 class NetEqDecodingTest : public ::testing::Test {
275 protected: 275 protected:
276 // NetEQ must be polled for data once every 10 ms. Thus, neither of the 276 // NetEQ must be polled for data once every 10 ms. Thus, neither of the
277 // constants below can be changed. 277 // constants below can be changed.
278 static const int kTimeStepMs = 10; 278 static const int kTimeStepMs = 10;
279 static const size_t kBlockSize8kHz = kTimeStepMs * 8; 279 static const size_t kBlockSize8kHz = kTimeStepMs * 8;
280 static const size_t kBlockSize16kHz = kTimeStepMs * 16; 280 static const size_t kBlockSize16kHz = kTimeStepMs * 16;
281 static const size_t kBlockSize32kHz = kTimeStepMs * 32; 281 static const size_t kBlockSize32kHz = kTimeStepMs * 32;
282 static const size_t kMaxBlockSize = kBlockSize32kHz; 282 static const size_t kBlockSize48kHz = kTimeStepMs * 48;
283 static const size_t kMaxBlockSize = kBlockSize48kHz;
283 static const int kInitSampleRateHz = 8000; 284 static const int kInitSampleRateHz = 8000;
284 285
285 NetEqDecodingTest(); 286 NetEqDecodingTest();
286 virtual void SetUp(); 287 virtual void SetUp();
287 virtual void TearDown(); 288 virtual void TearDown();
288 void SelectDecoders(NetEqDecoder* used_codec); 289 void SelectDecoders(NetEqDecoder* used_codec);
289 void LoadDecoders(); 290 void LoadDecoders();
290 void OpenInputFile(const std::string &rtp_file); 291 void OpenInputFile(const std::string &rtp_file);
291 void Process(size_t* out_len); 292 void Process(size_t* out_len);
292 293
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) 375 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
375 // Load iSAC. 376 // Load iSAC.
376 ASSERT_EQ( 377 ASSERT_EQ(
377 0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, "isac", 103)); 378 0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISAC, "isac", 103));
378 #endif 379 #endif
379 #ifdef WEBRTC_CODEC_ISAC 380 #ifdef WEBRTC_CODEC_ISAC
380 // Load iSAC SWB. 381 // Load iSAC SWB.
381 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISACswb, 382 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderISACswb,
382 "isac-swb", 104)); 383 "isac-swb", 104));
383 #endif 384 #endif
385 #ifdef WEBRTC_CODEC_OPUS
386 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderOpus,
387 "opus", 111));
388 #endif
384 // Load PCM16B nb. 389 // Load PCM16B nb.
385 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16B, 390 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16B,
386 "pcm16-nb", 93)); 391 "pcm16-nb", 93));
387 // Load PCM16B wb. 392 // Load PCM16B wb.
388 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bwb, 393 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bwb,
389 "pcm16-wb", 94)); 394 "pcm16-wb", 94));
390 // Load PCM16B swb32. 395 // Load PCM16B swb32.
391 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bswb32kHz, 396 ASSERT_EQ(0, neteq_->RegisterPayloadType(NetEqDecoder::kDecoderPCM16Bswb32kHz,
392 "pcm16-swb32", 95)); 397 "pcm16-swb32", 95));
393 // Load CNG 8 kHz. 398 // Load CNG 8 kHz.
(...skipping 25 matching lines...) Expand all
419 packet_.reset(rtp_source_->NextPacket()); 424 packet_.reset(rtp_source_->NextPacket());
420 } 425 }
421 426
422 // Get audio from NetEq. 427 // Get audio from NetEq.
423 NetEqOutputType type; 428 NetEqOutputType type;
424 int num_channels; 429 int num_channels;
425 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, out_len, 430 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, out_len,
426 &num_channels, &type)); 431 &num_channels, &type));
427 ASSERT_TRUE((*out_len == kBlockSize8kHz) || 432 ASSERT_TRUE((*out_len == kBlockSize8kHz) ||
428 (*out_len == kBlockSize16kHz) || 433 (*out_len == kBlockSize16kHz) ||
429 (*out_len == kBlockSize32kHz)); 434 (*out_len == kBlockSize32kHz) ||
435 (*out_len == kBlockSize48kHz));
430 output_sample_rate_ = static_cast<int>(*out_len / 10 * 1000); 436 output_sample_rate_ = static_cast<int>(*out_len / 10 * 1000);
431 EXPECT_EQ(output_sample_rate_, neteq_->last_output_sample_rate_hz()); 437 EXPECT_EQ(output_sample_rate_, neteq_->last_output_sample_rate_hz());
432 438
433 // Increase time. 439 // Increase time.
434 sim_clock_ += kTimeStepMs; 440 sim_clock_ += kTimeStepMs;
435 } 441 }
436 442
437 void NetEqDecodingTest::DecodeAndCompare(const std::string& rtp_file, 443 void NetEqDecodingTest::DecodeAndCompare(const std::string& rtp_file,
438 const std::string& ref_file, 444 const std::string& ref_file,
439 const std::string& stat_ref_file, 445 const std::string& stat_ref_file,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 rtp_info->header.sequenceNumber = frame_index; 510 rtp_info->header.sequenceNumber = frame_index;
505 rtp_info->header.timestamp = timestamp; 511 rtp_info->header.timestamp = timestamp;
506 rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. 512 rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC.
507 rtp_info->header.payloadType = 98; // WB CNG. 513 rtp_info->header.payloadType = 98; // WB CNG.
508 rtp_info->header.markerBit = 0; 514 rtp_info->header.markerBit = 0;
509 payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. 515 payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen.
510 *payload_len = 1; // Only noise level, no spectral parameters. 516 *payload_len = 1; // Only noise level, no spectral parameters.
511 } 517 }
512 518
513 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) && \ 519 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) && \
514 defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ 520 defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
515 (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ 521 (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \
516 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) 522 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722)
517 #define MAYBE_TestBitExactness TestBitExactness 523 #define MAYBE_TestBitExactness TestBitExactness
518 #else 524 #else
519 #define MAYBE_TestBitExactness DISABLED_TestBitExactness 525 #define MAYBE_TestBitExactness DISABLED_TestBitExactness
520 #endif 526 #endif
521 TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { 527 TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) {
522 const std::string input_rtp_file = webrtc::test::ProjectRootPath() + 528 const std::string input_rtp_file = webrtc::test::ProjectRootPath() +
523 "resources/audio_coding/neteq_universal_new.rtp"; 529 "resources/audio_coding/neteq_universal_new.rtp";
524 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm 530 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm
(...skipping 16 matching lines...) Expand all
541 if (FLAGS_gen_ref) { 547 if (FLAGS_gen_ref) {
542 DecodeAndCompare(input_rtp_file, "", "", ""); 548 DecodeAndCompare(input_rtp_file, "", "", "");
543 } else { 549 } else {
544 DecodeAndCompare(input_rtp_file, 550 DecodeAndCompare(input_rtp_file,
545 input_ref_file, 551 input_ref_file,
546 network_stat_ref_file, 552 network_stat_ref_file,
547 rtcp_stat_ref_file); 553 rtcp_stat_ref_file);
548 } 554 }
549 } 555 }
550 556
557 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) && \
558 defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
559 defined(WEBRTC_CODEC_OPUS)
560 #define MAYBE_TestOpusBitExactness TestOpusBitExactness
561 #else
562 #define MAYBE_TestOpusBitExactness DISABLED_TestOpusBitExactness
563 #endif
564 TEST_F(NetEqDecodingTest, MAYBE_TestOpusBitExactness) {
565 const std::string input_rtp_file =
566 webrtc::test::ResourcePath("audio_coding/neteq_opus", "rtp");
567 const std::string input_ref_file =
568 webrtc::test::ResourcePath("audio_coding/neteq4_opus_ref", "pcm");
569 const std::string network_stat_ref_file =
570 webrtc::test::ResourcePath("audio_coding/neteq4_opus_network_stats",
571 "dat");
572 const std::string rtcp_stat_ref_file =
573 webrtc::test::ResourcePath("audio_coding/neteq4_opus_rtcp_stats", "dat");
574
575 if (FLAGS_gen_ref) {
576 DecodeAndCompare(input_rtp_file, "", "", "");
577 } else {
578 DecodeAndCompare(input_rtp_file,
579 input_ref_file,
580 network_stat_ref_file,
581 rtcp_stat_ref_file);
582 }
583 }
584
551 // Use fax mode to avoid time-scaling. This is to simplify the testing of 585 // Use fax mode to avoid time-scaling. This is to simplify the testing of
552 // packet waiting times in the packet buffer. 586 // packet waiting times in the packet buffer.
553 class NetEqDecodingTestFaxMode : public NetEqDecodingTest { 587 class NetEqDecodingTestFaxMode : public NetEqDecodingTest {
554 protected: 588 protected:
555 NetEqDecodingTestFaxMode() : NetEqDecodingTest() { 589 NetEqDecodingTestFaxMode() : NetEqDecodingTest() {
556 config_.playout_mode = kPlayoutFax; 590 config_.playout_mode = kPlayoutFax;
557 } 591 }
558 }; 592 };
559 593
560 TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { 594 TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) {
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1603 // Pull audio once. 1637 // Pull audio once.
1604 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, 1638 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
1605 &num_channels, &type)); 1639 &num_channels, &type));
1606 ASSERT_EQ(kBlockSize16kHz, out_len); 1640 ASSERT_EQ(kBlockSize16kHz, out_len);
1607 } 1641 }
1608 // Verify speech output. 1642 // Verify speech output.
1609 EXPECT_EQ(kOutputNormal, type); 1643 EXPECT_EQ(kOutputNormal, type);
1610 } 1644 }
1611 1645
1612 } // namespace webrtc 1646 } // namespace webrtc
OLDNEW
« no previous file with comments | « resources/audio_coding/neteq_opus.rtp.sha1 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698