Fixing a few tests for the upcoming Opus 1.2-alpha.

BUG=b/35415318

NOTRY=True

Review-Url: https://codereview.webrtc.org/2746763005
Cr-Commit-Position: refs/heads/master@{#17234}
This commit is contained in:
minyue
2017-03-14 14:33:30 -07:00
committed by Commit bot
parent 275e2099ab
commit a613eb6bff
3 changed files with 61 additions and 12 deletions

View File

@ -644,7 +644,7 @@ TEST_P(OpusTest, OpusDurationEstimation) {
}
TEST_P(OpusTest, OpusDecodeRepacketized) {
const int kPackets = 6;
constexpr size_t kPackets = 6;
PrepareSpeechData(channels_, 20, 20 * kPackets);
@ -668,14 +668,26 @@ TEST_P(OpusTest, OpusDecodeRepacketized) {
new int16_t[kPackets * kOpus20msFrameSamples * channels_]);
OpusRepacketizer* rp = opus_repacketizer_create();
for (int idx = 0; idx < kPackets; idx++) {
size_t num_packets = 0;
constexpr size_t kMaxCycles = 100;
for (size_t idx = 0; idx < kMaxCycles; ++idx) {
auto speech_block = speech_data_.GetNextBlock();
encoded_bytes_ =
WebRtcOpus_Encode(opus_encoder_, speech_block.data(),
rtc::CheckedDivExact(speech_block.size(), channels_),
kMaxBytes, bitstream_);
EXPECT_EQ(OPUS_OK, opus_repacketizer_cat(rp, bitstream_, encoded_bytes_));
if (opus_repacketizer_cat(rp, bitstream_, encoded_bytes_) == OPUS_OK) {
++num_packets;
if (num_packets == kPackets) {
break;
}
} else {
// Opus repacketizer cannot guarantee a success. We try again if it fails.
opus_repacketizer_init(rp);
num_packets = 0;
}
}
EXPECT_EQ(kPackets, num_packets);
encoded_bytes_ = opus_repacketizer_out(rp, bitstream_, kMaxBytes);