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

Side by Side Diff: webrtc/modules/audio_coding/codecs/ilbc/ilbc_unittest.cc

Issue 2342443005: Moved Opus-specific payload splitting into AudioDecoderOpus. (Closed)
Patch Set: Created 4 years, 3 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 TEST_P(SplitIlbcTest, NumFrames) { 71 TEST_P(SplitIlbcTest, NumFrames) {
72 AudioDecoderIlbc decoder; 72 AudioDecoderIlbc decoder;
73 const size_t frame_length_samples = frame_length_ms_ * 8; 73 const size_t frame_length_samples = frame_length_ms_ * 8;
74 const size_t payload_length_bytes = frame_length_bytes_ * num_frames_; 74 const size_t payload_length_bytes = frame_length_bytes_ * num_frames_;
75 rtc::Buffer payload(payload_length_bytes); 75 rtc::Buffer payload(payload_length_bytes);
76 // Fill payload with increasing integers {0, 1, 2, ...}. 76 // Fill payload with increasing integers {0, 1, 2, ...}.
77 for (size_t i = 0; i < payload.size(); ++i) { 77 for (size_t i = 0; i < payload.size(); ++i) {
78 payload[i] = static_cast<uint8_t>(i); 78 payload[i] = static_cast<uint8_t>(i);
79 } 79 }
80 80
81 auto results = decoder.ParsePayload(&payload, 0, true); 81 auto results = decoder.ParsePayload(&payload, 0);
82 EXPECT_EQ(num_frames_, results.size()); 82 EXPECT_EQ(num_frames_, results.size());
83 83
84 size_t frame_num = 0; 84 size_t frame_num = 0;
85 uint8_t payload_value = 0; 85 uint8_t payload_value = 0;
86 for (const auto& result : results) { 86 for (const auto& result : results) {
87 EXPECT_EQ(frame_length_samples * frame_num, result.timestamp); 87 EXPECT_EQ(frame_length_samples * frame_num, result.timestamp);
88 const LegacyEncodedAudioFrame* frame = 88 const LegacyEncodedAudioFrame* frame =
89 static_cast<const LegacyEncodedAudioFrame*>(result.frame.get()); 89 static_cast<const LegacyEncodedAudioFrame*>(result.frame.get());
90 const rtc::Buffer& payload = frame->payload(); 90 const rtc::Buffer& payload = frame->payload();
91 EXPECT_EQ(frame_length_bytes_, payload.size()); 91 EXPECT_EQ(frame_length_bytes_, payload.size());
(...skipping 21 matching lines...) Expand all
113 std::pair<int, int>(3, 30), 113 std::pair<int, int>(3, 30),
114 std::pair<int, int>(4, 30), 114 std::pair<int, int>(4, 30),
115 std::pair<int, int>(5, 30), 115 std::pair<int, int>(5, 30),
116 std::pair<int, int>(18, 30))); 116 std::pair<int, int>(18, 30)));
117 117
118 // Test too large payload size. 118 // Test too large payload size.
119 TEST(IlbcPayloadSplitter, TooLargePayload) { 119 TEST(IlbcPayloadSplitter, TooLargePayload) {
120 AudioDecoderIlbc decoder; 120 AudioDecoderIlbc decoder;
121 constexpr size_t kPayloadLengthBytes = 950; 121 constexpr size_t kPayloadLengthBytes = 950;
122 rtc::Buffer payload(kPayloadLengthBytes); 122 rtc::Buffer payload(kPayloadLengthBytes);
123 const auto results = decoder.ParsePayload(&payload, 0, true); 123 const auto results = decoder.ParsePayload(&payload, 0);
124 EXPECT_TRUE(results.empty()); 124 EXPECT_TRUE(results.empty());
125 } 125 }
126 126
127 // Payload not an integer number of frames. 127 // Payload not an integer number of frames.
128 TEST(IlbcPayloadSplitter, UnevenPayload) { 128 TEST(IlbcPayloadSplitter, UnevenPayload) {
129 AudioDecoderIlbc decoder; 129 AudioDecoderIlbc decoder;
130 constexpr size_t kPayloadLengthBytes = 39; // Not an even number of frames. 130 constexpr size_t kPayloadLengthBytes = 39; // Not an even number of frames.
131 rtc::Buffer payload(kPayloadLengthBytes); 131 rtc::Buffer payload(kPayloadLengthBytes);
132 const auto results = decoder.ParsePayload(&payload, 0, true); 132 const auto results = decoder.ParsePayload(&payload, 0);
133 EXPECT_TRUE(results.empty()); 133 EXPECT_TRUE(results.empty());
134 } 134 }
135 135
136 } // namespace webrtc 136 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698