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 1532903002: Reenables several NetEq unittests on android. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Small change to disable bitexactness test on arm64. Created 4 years, 11 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
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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) { 405 void NetEqDecodingTest::OpenInputFile(const std::string &rtp_file) {
406 rtp_source_.reset(test::RtpFileSource::Create(rtp_file)); 406 rtp_source_.reset(test::RtpFileSource::Create(rtp_file));
407 } 407 }
408 408
409 void NetEqDecodingTest::Process(size_t* out_len) { 409 void NetEqDecodingTest::Process(size_t* out_len) {
410 // Check if time to receive. 410 // Check if time to receive.
411 while (packet_ && sim_clock_ >= packet_->time_ms()) { 411 while (packet_ && sim_clock_ >= packet_->time_ms()) {
412 if (packet_->payload_length_bytes() > 0) { 412 if (packet_->payload_length_bytes() > 0) {
413 WebRtcRTPHeader rtp_header; 413 WebRtcRTPHeader rtp_header;
414 packet_->ConvertHeader(&rtp_header); 414 packet_->ConvertHeader(&rtp_header);
415 #ifndef WEBRTC_CODEC_ISAC
416 // Ignore payload type 104 (iSAC-swb) if ISAC is not supported.
417 if (rtp_header.header.payloadType != 104)
418 #endif
415 ASSERT_EQ(0, neteq_->InsertPacket( 419 ASSERT_EQ(0, neteq_->InsertPacket(
416 rtp_header, 420 rtp_header,
417 rtc::ArrayView<const uint8_t>( 421 rtc::ArrayView<const uint8_t>(
418 packet_->payload(), packet_->payload_length_bytes()), 422 packet_->payload(), packet_->payload_length_bytes()),
419 static_cast<uint32_t>(packet_->time_ms() * 423 static_cast<uint32_t>(packet_->time_ms() *
420 (output_sample_rate_ / 1000)))); 424 (output_sample_rate_ / 1000))));
421 } 425 }
422 // Get next packet. 426 // Get next packet.
423 packet_.reset(rtp_source_->NextPacket()); 427 packet_.reset(rtp_source_->NextPacket());
424 } 428 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 size_t* payload_len) { 512 size_t* payload_len) {
509 rtp_info->header.sequenceNumber = frame_index; 513 rtp_info->header.sequenceNumber = frame_index;
510 rtp_info->header.timestamp = timestamp; 514 rtp_info->header.timestamp = timestamp;
511 rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC. 515 rtp_info->header.ssrc = 0x1234; // Just an arbitrary SSRC.
512 rtp_info->header.payloadType = 98; // WB CNG. 516 rtp_info->header.payloadType = 98; // WB CNG.
513 rtp_info->header.markerBit = 0; 517 rtp_info->header.markerBit = 0;
514 payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen. 518 payload[0] = 64; // Noise level -64 dBov, quite arbitrarily chosen.
515 *payload_len = 1; // Only noise level, no spectral parameters. 519 *payload_len = 1; // Only noise level, no spectral parameters.
516 } 520 }
517 521
518 #if !defined(WEBRTC_IOS) && !defined(WEBRTC_ANDROID) && \ 522 #if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
519 defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \ 523 (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \
520 (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) && \ 524 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) && \
521 defined(WEBRTC_CODEC_ILBC) && defined(WEBRTC_CODEC_G722) 525 !defined(WEBRTC_ARCH_ARM64)
522 #define MAYBE_TestBitExactness TestBitExactness 526 #define MAYBE_TestBitExactness TestBitExactness
523 #else 527 #else
524 #define MAYBE_TestBitExactness DISABLED_TestBitExactness 528 #define MAYBE_TestBitExactness DISABLED_TestBitExactness
525 #endif 529 #endif
526 TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) { 530 TEST_F(NetEqDecodingTest, MAYBE_TestBitExactness) {
527 const std::string input_rtp_file = 531 const std::string input_rtp_file =
528 webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); 532 webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp");
529 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm 533 // Note that neteq4_universal_ref.pcm and neteq4_universal_ref_win_32.pcm
530 // are identical. The latter could have been removed, but if clients still 534 // are identical. The latter could have been removed, but if clients still
531 // have a copy of the file, the test will fail. 535 // have a copy of the file, the test will fail.
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 TEST_F(NetEqDecodingTest, UnknownPayloadType) { 926 TEST_F(NetEqDecodingTest, UnknownPayloadType) {
923 const size_t kPayloadBytes = 100; 927 const size_t kPayloadBytes = 100;
924 uint8_t payload[kPayloadBytes] = {0}; 928 uint8_t payload[kPayloadBytes] = {0};
925 WebRtcRTPHeader rtp_info; 929 WebRtcRTPHeader rtp_info;
926 PopulateRtpInfo(0, 0, &rtp_info); 930 PopulateRtpInfo(0, 0, &rtp_info);
927 rtp_info.header.payloadType = 1; // Not registered as a decoder. 931 rtp_info.header.payloadType = 1; // Not registered as a decoder.
928 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); 932 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0));
929 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); 933 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError());
930 } 934 }
931 935
932 #if defined(WEBRTC_ANDROID) 936 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
937 #define MAYBE_DecoderError DecoderError
938 #else
933 #define MAYBE_DecoderError DISABLED_DecoderError 939 #define MAYBE_DecoderError DISABLED_DecoderError
934 #else
935 #define MAYBE_DecoderError DecoderError
936 #endif 940 #endif
937 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) 941
938 TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { 942 TEST_F(NetEqDecodingTest, MAYBE_DecoderError) {
939 const size_t kPayloadBytes = 100; 943 const size_t kPayloadBytes = 100;
940 uint8_t payload[kPayloadBytes] = {0}; 944 uint8_t payload[kPayloadBytes] = {0};
941 WebRtcRTPHeader rtp_info; 945 WebRtcRTPHeader rtp_info;
942 PopulateRtpInfo(0, 0, &rtp_info); 946 PopulateRtpInfo(0, 0, &rtp_info);
943 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. 947 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid.
944 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); 948 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
945 NetEqOutputType type; 949 NetEqOutputType type;
946 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call 950 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call
947 // to GetAudio. 951 // to GetAudio.
948 for (size_t i = 0; i < kMaxBlockSize; ++i) { 952 for (size_t i = 0; i < kMaxBlockSize; ++i) {
949 out_data_[i] = 1; 953 out_data_[i] = 1;
950 } 954 }
951 size_t num_channels; 955 size_t num_channels;
952 size_t samples_per_channel; 956 size_t samples_per_channel;
953 EXPECT_EQ(NetEq::kFail, 957 EXPECT_EQ(NetEq::kFail,
954 neteq_->GetAudio(kMaxBlockSize, out_data_, 958 neteq_->GetAudio(kMaxBlockSize, out_data_,
955 &samples_per_channel, &num_channels, &type)); 959 &samples_per_channel, &num_channels, &type));
956 // Verify that there is a decoder error to check. 960 // Verify that there is a decoder error to check.
957 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); 961 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError());
958 // Code 6730 is an iSAC error code. 962
959 EXPECT_EQ(6730, neteq_->LastDecoderError()); 963 enum NetEqDecoderError {
964 ISAC_LENGTH_MISMATCH = 6730,
965 ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH = 6640
966 };
967 #if defined(WEBRTC_CODEC_ISAC)
968 EXPECT_EQ(ISAC_LENGTH_MISMATCH, neteq_->LastDecoderError());
969 #elif defined(WEBRTC_CODEC_ISACFX)
970 EXPECT_EQ(ISAC_RANGE_ERROR_DECODE_FRAME_LENGTH, neteq_->LastDecoderError());
971 #endif
960 // Verify that the first 160 samples are set to 0, and that the remaining 972 // Verify that the first 160 samples are set to 0, and that the remaining
961 // samples are left unmodified. 973 // samples are left unmodified.
962 static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate. 974 static const int kExpectedOutputLength = 160; // 10 ms at 16 kHz sample rate.
963 for (int i = 0; i < kExpectedOutputLength; ++i) { 975 for (int i = 0; i < kExpectedOutputLength; ++i) {
964 std::ostringstream ss; 976 std::ostringstream ss;
965 ss << "i = " << i; 977 ss << "i = " << i;
966 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. 978 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
967 EXPECT_EQ(0, out_data_[i]); 979 EXPECT_EQ(0, out_data_[i]);
968 } 980 }
969 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) { 981 for (size_t i = kExpectedOutputLength; i < kMaxBlockSize; ++i) {
970 std::ostringstream ss; 982 std::ostringstream ss;
971 ss << "i = " << i; 983 ss << "i = " << i;
972 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. 984 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure.
973 EXPECT_EQ(1, out_data_[i]); 985 EXPECT_EQ(1, out_data_[i]);
974 } 986 }
975 } 987 }
976 #endif
977 988
978 TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) { 989 TEST_F(NetEqDecodingTest, GetAudioBeforeInsertPacket) {
979 NetEqOutputType type; 990 NetEqOutputType type;
980 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call 991 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call
981 // to GetAudio. 992 // to GetAudio.
982 for (size_t i = 0; i < kMaxBlockSize; ++i) { 993 for (size_t i = 0; i < kMaxBlockSize; ++i) {
983 out_data_[i] = 1; 994 out_data_[i] = 1;
984 } 995 }
985 size_t num_channels; 996 size_t num_channels;
986 size_t samples_per_channel; 997 size_t samples_per_channel;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 CheckBgn(32000); 1176 CheckBgn(32000);
1166 } 1177 }
1167 1178
1168 TEST_F(NetEqBgnTestFade, RunTest) { 1179 TEST_F(NetEqBgnTestFade, RunTest) {
1169 CheckBgn(8000); 1180 CheckBgn(8000);
1170 CheckBgn(16000); 1181 CheckBgn(16000);
1171 CheckBgn(32000); 1182 CheckBgn(32000);
1172 } 1183 }
1173 1184
1174 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) 1185 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
1175 TEST_F(NetEqDecodingTest, SyncPacketInsert) { 1186 #define MAYBE_SyncPacketInsert SyncPacketInsert
1187 #else
1188 #define MAYBE_SyncPacketInsert DISABLED_SyncPacketInsert
1189 #endif
1190 TEST_F(NetEqDecodingTest, MAYBE_SyncPacketInsert) {
1176 WebRtcRTPHeader rtp_info; 1191 WebRtcRTPHeader rtp_info;
1177 uint32_t receive_timestamp = 0; 1192 uint32_t receive_timestamp = 0;
1178 // For the readability use the following payloads instead of the defaults of 1193 // For the readability use the following payloads instead of the defaults of
1179 // this test. 1194 // this test.
1180 uint8_t kPcm16WbPayloadType = 1; 1195 uint8_t kPcm16WbPayloadType = 1;
1181 uint8_t kCngNbPayloadType = 2; 1196 uint8_t kCngNbPayloadType = 2;
1182 uint8_t kCngWbPayloadType = 3; 1197 uint8_t kCngWbPayloadType = 3;
1183 uint8_t kCngSwb32PayloadType = 4; 1198 uint8_t kCngSwb32PayloadType = 4;
1184 uint8_t kCngSwb48PayloadType = 5; 1199 uint8_t kCngSwb48PayloadType = 5;
1185 uint8_t kAvtPayloadType = 6; 1200 uint8_t kAvtPayloadType = 6;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); 1259 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
1245 1260
1246 // Change of SSRC is not allowed with a sync packet. 1261 // Change of SSRC is not allowed with a sync packet.
1247 rtp_info.header.payloadType = kPcm16WbPayloadType; 1262 rtp_info.header.payloadType = kPcm16WbPayloadType;
1248 ++rtp_info.header.ssrc; 1263 ++rtp_info.header.ssrc;
1249 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); 1264 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
1250 1265
1251 --rtp_info.header.ssrc; 1266 --rtp_info.header.ssrc;
1252 EXPECT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); 1267 EXPECT_EQ(0, neteq_->InsertSyncPacket(rtp_info, receive_timestamp));
1253 } 1268 }
1254 #endif
1255 1269
1256 // First insert several noise like packets, then sync-packets. Decoding all 1270 // First insert several noise like packets, then sync-packets. Decoding all
1257 // packets should not produce error, statistics should not show any packet loss 1271 // packets should not produce error, statistics should not show any packet loss
1258 // and sync-packets should decode to zero. 1272 // and sync-packets should decode to zero.
1259 // TODO(turajs) we will have a better test if we have a referece NetEq, and 1273 // TODO(turajs) we will have a better test if we have a referece NetEq, and
1260 // when Sync packets are inserted in "test" NetEq we insert all-zero payload 1274 // when Sync packets are inserted in "test" NetEq we insert all-zero payload
1261 // in reference NetEq and compare the output of those two. 1275 // in reference NetEq and compare the output of those two.
1262 TEST_F(NetEqDecodingTest, SyncPacketDecode) { 1276 TEST_F(NetEqDecodingTest, SyncPacketDecode) {
1263 WebRtcRTPHeader rtp_info; 1277 WebRtcRTPHeader rtp_info;
1264 PopulateRtpInfo(0, 0, &rtp_info); 1278 PopulateRtpInfo(0, 0, &rtp_info);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 // Pull audio once. 1653 // Pull audio once.
1640 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, 1654 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
1641 &num_channels, &type)); 1655 &num_channels, &type));
1642 ASSERT_EQ(kBlockSize16kHz, out_len); 1656 ASSERT_EQ(kBlockSize16kHz, out_len);
1643 } 1657 }
1644 // Verify speech output. 1658 // Verify speech output.
1645 EXPECT_EQ(kOutputNormal, type); 1659 EXPECT_EQ(kOutputNormal, type);
1646 } 1660 }
1647 1661
1648 } // namespace webrtc 1662 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_stereo_unittest.cc ('k') | webrtc/modules/modules_unittests.isolate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698