OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include <cstring> | |
12 #include <limits> | |
13 #include <map> | |
14 #include <set> | |
15 #include <utility> | |
16 | |
17 #include "testing/gtest/include/gtest/gtest.h" | |
18 #include "webrtc/base/random.h" | |
19 #include "webrtc/base/refcount.h" | |
20 #include "webrtc/modules/video_coding/frame_object.h" | |
21 #include "webrtc/modules/video_coding/packet_buffer.h" | |
22 #include "webrtc/system_wrappers/include/clock.h" | |
23 | |
24 namespace webrtc { | |
25 namespace video_coding { | |
26 | |
27 class PacketBufferFake : public PacketBuffer { | |
stefan-webrtc
2016/08/04 14:32:30
FakePacketBuffer
philipel
2016/08/04 14:45:02
Done.
| |
28 public: | |
29 PacketBufferFake() : PacketBuffer(nullptr, 0, 0, nullptr) {} | |
30 | |
31 VCMPacket* GetPacket(uint16_t seq_num) override { | |
32 auto packet_it = packets_.find(seq_num); | |
33 return packet_it == packets_.end() ? nullptr : &packet_it->second; | |
34 } | |
35 | |
36 bool InsertPacket(const VCMPacket& packet) override { | |
37 packets_[packet.seqNum] = packet; | |
38 return true; | |
39 } | |
40 | |
41 bool GetBitstream(const RtpFrameObject& frame, | |
42 uint8_t* destination) override { | |
43 return true; | |
44 } | |
45 | |
46 void ReturnFrame(RtpFrameObject* frame) override { | |
47 packets_.erase(frame->first_seq_num()); | |
48 } | |
49 | |
50 private: | |
51 std::map<uint16_t, VCMPacket> packets_; | |
52 }; | |
53 | |
54 class TestRtpFrameReferenceFinder : public ::testing::Test, | |
55 public OnCompleteFrameCallback { | |
56 protected: | |
57 TestRtpFrameReferenceFinder() | |
58 : rand_(0x8739211), | |
59 ref_packet_buffer_(new rtc::RefCountedObject<PacketBufferFake>()), | |
danilchap
2016/08/04 16:03:09
PacketBufferFake inherited from PacketBuffer that
philipel
2016/08/08 13:34:57
Done.
| |
60 reference_finder_(new RtpFrameReferenceFinder(this)), | |
61 frames_from_callback_(FrameComp()) {} | |
62 | |
63 uint16_t Rand() { return rand_.Rand(std::numeric_limits<uint16_t>::max()); } | |
64 | |
65 void OnCompleteFrame(std::unique_ptr<FrameObject> frame) override { | |
66 uint16_t pid = frame->picture_id; | |
67 uint16_t sidx = frame->spatial_layer; | |
68 auto frame_it = frames_from_callback_.find(std::make_pair(pid, sidx)); | |
69 if (frame_it != frames_from_callback_.end()) { | |
70 ADD_FAILURE() << "Already received frame with (pid:sidx): (" << pid << ":" | |
71 << sidx << ")"; | |
72 return; | |
73 } | |
74 | |
75 frames_from_callback_.insert( | |
76 std::make_pair(std::make_pair(pid, sidx), std::move(frame))); | |
77 } | |
78 | |
79 void InsertGeneric(uint16_t seq_num_start, | |
80 uint16_t seq_num_end, | |
81 bool keyframe) { | |
82 VCMPacket packet; | |
83 packet.codec = kVideoCodecGeneric; | |
84 packet.seqNum = seq_num_start; | |
85 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; | |
86 | |
87 ref_packet_buffer_->InsertPacket(packet); | |
88 std::unique_ptr<RtpFrameObject> frame(new RtpFrameObject( | |
89 ref_packet_buffer_, seq_num_start, seq_num_end, 0, 0, 0)); | |
90 reference_finder_->ManageFrame(std::move(frame)); | |
91 } | |
92 | |
93 void InsertVp8(uint16_t seq_num_start, | |
94 uint16_t seq_num_end, | |
95 bool keyframe, | |
96 int32_t pid = kNoPictureId, | |
97 uint8_t tid = kNoTemporalIdx, | |
98 int32_t tl0 = kNoTl0PicIdx, | |
99 bool sync = false) { | |
100 VCMPacket packet; | |
101 packet.codec = kVideoCodecVP8; | |
102 packet.seqNum = seq_num_start; | |
103 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; | |
104 packet.video_header.codecHeader.VP8.pictureId = pid % (1 << 15); | |
105 packet.video_header.codecHeader.VP8.temporalIdx = tid; | |
106 packet.video_header.codecHeader.VP8.tl0PicIdx = tl0; | |
107 packet.video_header.codecHeader.VP8.layerSync = sync; | |
108 | |
109 ref_packet_buffer_->InsertPacket(packet); | |
110 std::unique_ptr<RtpFrameObject> frame(new RtpFrameObject( | |
111 ref_packet_buffer_, seq_num_start, seq_num_end, 0, 0, 0)); | |
112 reference_finder_->ManageFrame(std::move(frame)); | |
113 } | |
114 | |
115 void InsertVp9Gof(uint16_t seq_num_start, | |
116 uint16_t seq_num_end, | |
117 bool keyframe, | |
118 int32_t pid = kNoPictureId, | |
119 uint8_t sid = kNoSpatialIdx, | |
120 uint8_t tid = kNoTemporalIdx, | |
121 int32_t tl0 = kNoTl0PicIdx, | |
122 bool up_switch = false, | |
123 GofInfoVP9* ss = nullptr) { | |
124 VCMPacket packet; | |
125 packet.codec = kVideoCodecVP9; | |
126 packet.seqNum = seq_num_start; | |
127 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; | |
128 packet.video_header.codecHeader.VP9.flexible_mode = false; | |
129 packet.video_header.codecHeader.VP9.picture_id = pid % (1 << 15); | |
130 packet.video_header.codecHeader.VP9.temporal_idx = tid; | |
131 packet.video_header.codecHeader.VP9.spatial_idx = sid; | |
132 packet.video_header.codecHeader.VP9.tl0_pic_idx = tl0; | |
133 packet.video_header.codecHeader.VP9.temporal_up_switch = up_switch; | |
134 if (ss != nullptr) { | |
135 packet.video_header.codecHeader.VP9.ss_data_available = true; | |
136 packet.video_header.codecHeader.VP9.gof = *ss; | |
137 } | |
138 | |
139 ref_packet_buffer_->InsertPacket(packet); | |
140 std::unique_ptr<RtpFrameObject> frame(new RtpFrameObject( | |
141 ref_packet_buffer_, seq_num_start, seq_num_end, 0, 0, 0)); | |
142 reference_finder_->ManageFrame(std::move(frame)); | |
143 } | |
144 | |
145 void InsertVp9Flex(uint16_t seq_num_start, | |
146 uint16_t seq_num_end, | |
147 bool keyframe, | |
148 int32_t pid = kNoPictureId, | |
149 uint8_t sid = kNoSpatialIdx, | |
150 uint8_t tid = kNoTemporalIdx, | |
151 int32_t tl0 = kNoTl0PicIdx, | |
152 bool inter = false, | |
153 std::vector<uint8_t> refs = std::vector<uint8_t>()) { | |
154 VCMPacket packet; | |
155 packet.codec = kVideoCodecVP9; | |
156 packet.seqNum = seq_num_start; | |
157 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; | |
158 packet.video_header.codecHeader.VP9.inter_layer_predicted = inter; | |
159 packet.video_header.codecHeader.VP9.flexible_mode = true; | |
160 packet.video_header.codecHeader.VP9.picture_id = pid % (1 << 15); | |
161 packet.video_header.codecHeader.VP9.temporal_idx = tid; | |
162 packet.video_header.codecHeader.VP9.spatial_idx = sid; | |
163 packet.video_header.codecHeader.VP9.tl0_pic_idx = tl0; | |
164 packet.video_header.codecHeader.VP9.num_ref_pics = refs.size(); | |
165 for (size_t i = 0; i < refs.size(); ++i) | |
166 packet.video_header.codecHeader.VP9.pid_diff[i] = refs[i]; | |
167 | |
168 ref_packet_buffer_->InsertPacket(packet); | |
169 std::unique_ptr<RtpFrameObject> frame(new RtpFrameObject( | |
170 ref_packet_buffer_, seq_num_start, seq_num_end, 0, 0, 0)); | |
171 reference_finder_->ManageFrame(std::move(frame)); | |
172 } | |
173 | |
174 // Check if a frame with picture id |pid| and spatial index |sidx| has been | |
175 // delivered from the packet buffer, and if so, if it has the references | |
176 // specified by |refs|. | |
177 template <typename... T> | |
178 void CheckReferences(uint16_t pid, uint16_t sidx, T... refs) const { | |
179 auto frame_it = frames_from_callback_.find(std::make_pair(pid, sidx)); | |
180 if (frame_it == frames_from_callback_.end()) { | |
181 ADD_FAILURE() << "Could not find frame with (pid:sidx): (" << pid << ":" | |
182 << sidx << ")"; | |
183 return; | |
184 } | |
185 | |
186 std::set<uint16_t> actual_refs; | |
187 for (uint8_t r = 0; r < frame_it->second->num_references; ++r) { | |
188 actual_refs.insert(frame_it->second->references[r]); | |
189 } | |
190 | |
191 std::set<uint16_t> expected_refs; | |
192 RefsToSet(&expected_refs, refs...); | |
193 | |
194 ASSERT_EQ(expected_refs, actual_refs); | |
195 } | |
196 | |
197 template <typename... T> | |
198 void CheckReferencesGeneric(uint16_t pid, T... refs) const { | |
199 CheckReferences(pid, 0, refs...); | |
200 } | |
201 | |
202 template <typename... T> | |
203 void CheckReferencesVp8(uint16_t pid, T... refs) const { | |
204 CheckReferences(pid, 0, refs...); | |
205 } | |
206 | |
207 template <typename... T> | |
208 void CheckReferencesVp9(uint16_t pid, uint8_t sidx, T... refs) const { | |
209 CheckReferences(pid, sidx, refs...); | |
210 } | |
211 | |
212 template <typename... T> | |
213 void RefsToSet(std::set<uint16_t>* m, uint16_t ref, T... refs) const { | |
214 m->insert(ref); | |
215 RefsToSet(m, refs...); | |
216 } | |
217 | |
218 void RefsToSet(std::set<uint16_t>* m) const {} | |
219 | |
220 Random rand_; | |
221 rtc::scoped_refptr<PacketBufferFake> ref_packet_buffer_; | |
222 std::unique_ptr<RtpFrameReferenceFinder> reference_finder_; | |
223 struct FrameComp { | |
224 bool operator()(const std::pair<uint16_t, uint8_t> f1, | |
225 const std::pair<uint16_t, uint8_t> f2) const { | |
226 if (f1.first == f2.first) | |
227 return f1.second < f2.second; | |
228 return f1.first < f2.first; | |
229 } | |
230 }; | |
231 std::map<std::pair<uint16_t, uint8_t>, | |
232 std::unique_ptr<FrameObject>, | |
233 FrameComp> | |
234 frames_from_callback_; | |
235 }; | |
236 | |
237 TEST_F(TestRtpFrameReferenceFinder, PaddingPackets) { | |
238 uint16_t sn = Rand(); | |
239 | |
240 InsertGeneric(sn, sn, true); | |
241 InsertGeneric(sn + 2, sn + 2, false); | |
242 EXPECT_EQ(1UL, frames_from_callback_.size()); | |
243 reference_finder_->PaddingReceived(sn + 1); | |
244 EXPECT_EQ(2UL, frames_from_callback_.size()); | |
245 } | |
246 | |
247 TEST_F(TestRtpFrameReferenceFinder, PaddingPacketsReordered) { | |
248 uint16_t sn = Rand(); | |
249 | |
250 InsertGeneric(sn, sn, true); | |
251 reference_finder_->PaddingReceived(sn + 1); | |
252 reference_finder_->PaddingReceived(sn + 4); | |
253 InsertGeneric(sn + 2, sn + 3, false); | |
254 | |
255 EXPECT_EQ(2UL, frames_from_callback_.size()); | |
256 CheckReferencesGeneric(sn); | |
257 CheckReferencesGeneric(sn + 3, sn); | |
258 } | |
259 | |
260 TEST_F(TestRtpFrameReferenceFinder, PaddingPacketsReorderedMultipleKeyframes) { | |
261 uint16_t sn = Rand(); | |
262 | |
263 InsertGeneric(sn, sn, true); | |
264 reference_finder_->PaddingReceived(sn + 1); | |
265 reference_finder_->PaddingReceived(sn + 4); | |
266 InsertGeneric(sn + 2, sn + 3, false); | |
267 InsertGeneric(sn + 5, sn + 5, true); | |
268 reference_finder_->PaddingReceived(sn + 6); | |
269 reference_finder_->PaddingReceived(sn + 9); | |
270 InsertGeneric(sn + 7, sn + 8, false); | |
271 | |
272 EXPECT_EQ(4UL, frames_from_callback_.size()); | |
273 } | |
274 | |
275 TEST_F(TestRtpFrameReferenceFinder, Vp8NoPictureId) { | |
276 uint16_t sn = Rand(); | |
277 | |
278 InsertVp8(sn, sn + 2, true); | |
279 ASSERT_EQ(1UL, frames_from_callback_.size()); | |
280 | |
281 InsertVp8(sn + 3, sn + 4, false); | |
282 ASSERT_EQ(2UL, frames_from_callback_.size()); | |
283 | |
284 InsertVp8(sn + 5, sn + 8, false); | |
285 ASSERT_EQ(3UL, frames_from_callback_.size()); | |
286 | |
287 InsertVp8(sn + 9, sn + 9, false); | |
288 ASSERT_EQ(4UL, frames_from_callback_.size()); | |
289 | |
290 InsertVp8(sn + 10, sn + 11, false); | |
291 ASSERT_EQ(5UL, frames_from_callback_.size()); | |
292 | |
293 InsertVp8(sn + 12, sn + 12, true); | |
294 ASSERT_EQ(6UL, frames_from_callback_.size()); | |
295 | |
296 InsertVp8(sn + 13, sn + 17, false); | |
297 ASSERT_EQ(7UL, frames_from_callback_.size()); | |
298 | |
299 InsertVp8(sn + 18, sn + 18, false); | |
300 ASSERT_EQ(8UL, frames_from_callback_.size()); | |
301 | |
302 InsertVp8(sn + 19, sn + 20, false); | |
303 ASSERT_EQ(9UL, frames_from_callback_.size()); | |
304 | |
305 InsertVp8(sn + 21, sn + 21, false); | |
306 | |
307 ASSERT_EQ(10UL, frames_from_callback_.size()); | |
308 CheckReferencesVp8(sn + 2); | |
309 CheckReferencesVp8(sn + 4, sn + 2); | |
310 CheckReferencesVp8(sn + 8, sn + 4); | |
311 CheckReferencesVp8(sn + 9, sn + 8); | |
312 CheckReferencesVp8(sn + 11, sn + 9); | |
313 CheckReferencesVp8(sn + 12); | |
314 CheckReferencesVp8(sn + 17, sn + 12); | |
315 CheckReferencesVp8(sn + 18, sn + 17); | |
316 CheckReferencesVp8(sn + 20, sn + 18); | |
317 CheckReferencesVp8(sn + 21, sn + 20); | |
318 } | |
319 | |
320 TEST_F(TestRtpFrameReferenceFinder, Vp8NoPictureIdReordered) { | |
321 uint16_t sn = 0xfffa; | |
322 | |
323 InsertVp8(sn, sn + 2, true); | |
324 InsertVp8(sn + 3, sn + 4, false); | |
325 InsertVp8(sn + 5, sn + 8, false); | |
326 InsertVp8(sn + 9, sn + 9, false); | |
327 InsertVp8(sn + 10, sn + 11, false); | |
328 InsertVp8(sn + 12, sn + 12, true); | |
329 InsertVp8(sn + 13, sn + 17, false); | |
330 InsertVp8(sn + 18, sn + 18, false); | |
331 InsertVp8(sn + 19, sn + 20, false); | |
332 InsertVp8(sn + 21, sn + 21, false); | |
333 | |
334 ASSERT_EQ(10UL, frames_from_callback_.size()); | |
335 CheckReferencesVp8(sn + 2); | |
336 CheckReferencesVp8(sn + 4, sn + 2); | |
337 CheckReferencesVp8(sn + 8, sn + 4); | |
338 CheckReferencesVp8(sn + 9, sn + 8); | |
339 CheckReferencesVp8(sn + 11, sn + 9); | |
340 CheckReferencesVp8(sn + 12); | |
341 CheckReferencesVp8(sn + 17, sn + 12); | |
342 CheckReferencesVp8(sn + 18, sn + 17); | |
343 CheckReferencesVp8(sn + 20, sn + 18); | |
344 CheckReferencesVp8(sn + 21, sn + 20); | |
345 } | |
346 | |
347 TEST_F(TestRtpFrameReferenceFinder, Vp8KeyFrameReferences) { | |
348 uint16_t sn = Rand(); | |
349 InsertVp8(sn, sn, true); | |
350 | |
351 ASSERT_EQ(1UL, frames_from_callback_.size()); | |
352 CheckReferencesVp8(sn); | |
353 } | |
354 | |
355 // Test with 1 temporal layer. | |
356 TEST_F(TestRtpFrameReferenceFinder, Vp8TemporalLayers_0) { | |
357 uint16_t pid = Rand(); | |
358 uint16_t sn = Rand(); | |
359 | |
360 InsertVp8(sn, sn, true, pid, 0, 1); | |
361 InsertVp8(sn + 1, sn + 1, false, pid + 1, 0, 2); | |
362 InsertVp8(sn + 2, sn + 2, false, pid + 2, 0, 3); | |
363 InsertVp8(sn + 3, sn + 3, false, pid + 3, 0, 4); | |
364 | |
365 ASSERT_EQ(4UL, frames_from_callback_.size()); | |
366 CheckReferencesVp8(pid); | |
367 CheckReferencesVp8(pid + 1, pid); | |
368 CheckReferencesVp8(pid + 2, pid + 1); | |
369 CheckReferencesVp8(pid + 3, pid + 2); | |
370 } | |
371 | |
372 // Test with 1 temporal layer. | |
373 TEST_F(TestRtpFrameReferenceFinder, Vp8TemporalLayersReordering_0) { | |
374 uint16_t pid = Rand(); | |
375 uint16_t sn = Rand(); | |
376 | |
377 InsertVp8(sn, sn, true, pid, 0, 1); | |
378 InsertVp8(sn + 1, sn + 1, false, pid + 1, 0, 2); | |
379 InsertVp8(sn + 3, sn + 3, false, pid + 3, 0, 4); | |
380 InsertVp8(sn + 2, sn + 2, false, pid + 2, 0, 3); | |
381 InsertVp8(sn + 5, sn + 5, false, pid + 5, 0, 6); | |
382 InsertVp8(sn + 6, sn + 6, false, pid + 6, 0, 7); | |
383 InsertVp8(sn + 4, sn + 4, false, pid + 4, 0, 5); | |
384 | |
385 ASSERT_EQ(7UL, frames_from_callback_.size()); | |
386 CheckReferencesVp8(pid); | |
387 CheckReferencesVp8(pid + 1, pid); | |
388 CheckReferencesVp8(pid + 2, pid + 1); | |
389 CheckReferencesVp8(pid + 3, pid + 2); | |
390 CheckReferencesVp8(pid + 4, pid + 3); | |
391 CheckReferencesVp8(pid + 5, pid + 4); | |
392 CheckReferencesVp8(pid + 6, pid + 5); | |
393 } | |
394 | |
395 // Test with 2 temporal layers in a 01 pattern. | |
396 TEST_F(TestRtpFrameReferenceFinder, Vp8TemporalLayers_01) { | |
397 uint16_t pid = Rand(); | |
398 uint16_t sn = Rand(); | |
399 | |
400 InsertVp8(sn, sn, true, pid, 0, 255); | |
401 InsertVp8(sn + 1, sn + 1, false, pid + 1, 1, 255, true); | |
402 InsertVp8(sn + 2, sn + 2, false, pid + 2, 0, 0); | |
403 InsertVp8(sn + 3, sn + 3, false, pid + 3, 1, 0); | |
404 | |
405 ASSERT_EQ(4UL, frames_from_callback_.size()); | |
406 CheckReferencesVp8(pid); | |
407 CheckReferencesVp8(pid + 1, pid); | |
408 CheckReferencesVp8(pid + 2, pid); | |
409 CheckReferencesVp8(pid + 3, pid + 1, pid + 2); | |
410 } | |
411 | |
412 // Test with 2 temporal layers in a 01 pattern. | |
413 TEST_F(TestRtpFrameReferenceFinder, Vp8TemporalLayersReordering_01) { | |
414 uint16_t pid = Rand(); | |
415 uint16_t sn = Rand(); | |
416 | |
417 InsertVp8(sn + 1, sn + 1, false, pid + 1, 1, 255, true); | |
418 InsertVp8(sn, sn, true, pid, 0, 255); | |
419 InsertVp8(sn + 3, sn + 3, false, pid + 3, 1, 0); | |
420 InsertVp8(sn + 5, sn + 5, false, pid + 5, 1, 1); | |
421 InsertVp8(sn + 2, sn + 2, false, pid + 2, 0, 0); | |
422 InsertVp8(sn + 4, sn + 4, false, pid + 4, 0, 1); | |
423 InsertVp8(sn + 6, sn + 6, false, pid + 6, 0, 2); | |
424 InsertVp8(sn + 7, sn + 7, false, pid + 7, 1, 2); | |
425 | |
426 ASSERT_EQ(8UL, frames_from_callback_.size()); | |
427 CheckReferencesVp8(pid); | |
428 CheckReferencesVp8(pid + 1, pid); | |
429 CheckReferencesVp8(pid + 2, pid); | |
430 CheckReferencesVp8(pid + 3, pid + 1, pid + 2); | |
431 CheckReferencesVp8(pid + 4, pid + 2); | |
432 CheckReferencesVp8(pid + 5, pid + 3, pid + 4); | |
433 CheckReferencesVp8(pid + 6, pid + 4); | |
434 CheckReferencesVp8(pid + 7, pid + 5, pid + 6); | |
435 } | |
436 | |
437 // Test with 3 temporal layers in a 0212 pattern. | |
438 TEST_F(TestRtpFrameReferenceFinder, Vp8TemporalLayers_0212) { | |
439 uint16_t pid = Rand(); | |
440 uint16_t sn = Rand(); | |
441 | |
442 InsertVp8(sn, sn, true, pid, 0, 55); | |
443 InsertVp8(sn + 1, sn + 1, false, pid + 1, 2, 55, true); | |
444 InsertVp8(sn + 2, sn + 2, false, pid + 2, 1, 55, true); | |
445 InsertVp8(sn + 3, sn + 3, false, pid + 3, 2, 55); | |
446 InsertVp8(sn + 4, sn + 4, false, pid + 4, 0, 56); | |
447 InsertVp8(sn + 5, sn + 5, false, pid + 5, 2, 56); | |
448 InsertVp8(sn + 6, sn + 6, false, pid + 6, 1, 56); | |
449 InsertVp8(sn + 7, sn + 7, false, pid + 7, 2, 56); | |
450 InsertVp8(sn + 8, sn + 8, false, pid + 8, 0, 57); | |
451 InsertVp8(sn + 9, sn + 9, false, pid + 9, 2, 57, true); | |
452 InsertVp8(sn + 10, sn + 10, false, pid + 10, 1, 57, true); | |
453 InsertVp8(sn + 11, sn + 11, false, pid + 11, 2, 57); | |
454 | |
455 ASSERT_EQ(12UL, frames_from_callback_.size()); | |
456 CheckReferencesVp8(pid); | |
457 CheckReferencesVp8(pid + 1, pid); | |
458 CheckReferencesVp8(pid + 2, pid); | |
459 CheckReferencesVp8(pid + 3, pid, pid + 1, pid + 2); | |
460 CheckReferencesVp8(pid + 4, pid); | |
461 CheckReferencesVp8(pid + 5, pid + 2, pid + 3, pid + 4); | |
462 CheckReferencesVp8(pid + 6, pid + 2, pid + 4); | |
463 CheckReferencesVp8(pid + 7, pid + 4, pid + 5, pid + 6); | |
464 CheckReferencesVp8(pid + 8, pid + 4); | |
465 CheckReferencesVp8(pid + 9, pid + 8); | |
466 CheckReferencesVp8(pid + 10, pid + 8); | |
467 CheckReferencesVp8(pid + 11, pid + 8, pid + 9, pid + 10); | |
468 } | |
469 | |
470 // Test with 3 temporal layers in a 0212 pattern. | |
471 TEST_F(TestRtpFrameReferenceFinder, Vp8TemporalLayersMissingFrame_0212) { | |
472 uint16_t pid = Rand(); | |
473 uint16_t sn = Rand(); | |
474 | |
475 InsertVp8(sn, sn, true, pid, 0, 55, false); | |
476 InsertVp8(sn + 2, sn + 2, false, pid + 2, 1, 55, true); | |
477 InsertVp8(sn + 3, sn + 3, false, pid + 3, 2, 55, false); | |
478 | |
479 ASSERT_EQ(2UL, frames_from_callback_.size()); | |
480 CheckReferencesVp8(pid); | |
481 CheckReferencesVp8(pid + 2, pid); | |
482 } | |
483 | |
484 // Test with 3 temporal layers in a 0212 pattern. | |
485 TEST_F(TestRtpFrameReferenceFinder, Vp8TemporalLayersReordering_0212) { | |
486 uint16_t pid = 126; | |
487 uint16_t sn = Rand(); | |
488 | |
489 InsertVp8(sn + 1, sn + 1, false, pid + 1, 2, 55, true); | |
490 InsertVp8(sn, sn, true, pid, 0, 55, false); | |
491 InsertVp8(sn + 2, sn + 2, false, pid + 2, 1, 55, true); | |
492 InsertVp8(sn + 4, sn + 4, false, pid + 4, 0, 56, false); | |
493 InsertVp8(sn + 5, sn + 5, false, pid + 5, 2, 56, false); | |
494 InsertVp8(sn + 3, sn + 3, false, pid + 3, 2, 55, false); | |
495 InsertVp8(sn + 7, sn + 7, false, pid + 7, 2, 56, false); | |
496 InsertVp8(sn + 9, sn + 9, false, pid + 9, 2, 57, true); | |
497 InsertVp8(sn + 6, sn + 6, false, pid + 6, 1, 56, false); | |
498 InsertVp8(sn + 8, sn + 8, false, pid + 8, 0, 57, false); | |
499 InsertVp8(sn + 11, sn + 11, false, pid + 11, 2, 57, false); | |
500 InsertVp8(sn + 10, sn + 10, false, pid + 10, 1, 57, true); | |
501 | |
502 ASSERT_EQ(12UL, frames_from_callback_.size()); | |
503 CheckReferencesVp8(pid); | |
504 CheckReferencesVp8(pid + 1, pid); | |
505 CheckReferencesVp8(pid + 2, pid); | |
506 CheckReferencesVp8(pid + 3, pid, pid + 1, pid + 2); | |
507 CheckReferencesVp8(pid + 4, pid); | |
508 CheckReferencesVp8(pid + 5, pid + 2, pid + 3, pid + 4); | |
509 CheckReferencesVp8(pid + 6, pid + 2, pid + 4); | |
510 CheckReferencesVp8(pid + 7, pid + 4, pid + 5, pid + 6); | |
511 CheckReferencesVp8(pid + 8, pid + 4); | |
512 CheckReferencesVp8(pid + 9, pid + 8); | |
513 CheckReferencesVp8(pid + 10, pid + 8); | |
514 CheckReferencesVp8(pid + 11, pid + 8, pid + 9, pid + 10); | |
515 } | |
516 | |
517 TEST_F(TestRtpFrameReferenceFinder, Vp8InsertManyFrames_0212) { | |
518 uint16_t pid = Rand(); | |
519 uint16_t sn = Rand(); | |
520 | |
521 const int keyframes_to_insert = 50; | |
522 const int frames_per_keyframe = 120; // Should be a multiple of 4. | |
523 uint8_t tl0 = 128; | |
524 | |
525 for (int k = 0; k < keyframes_to_insert; ++k) { | |
526 InsertVp8(sn, sn, true, pid, 0, tl0, false); | |
527 InsertVp8(sn + 1, sn + 1, false, pid + 1, 2, tl0, true); | |
528 InsertVp8(sn + 2, sn + 2, false, pid + 2, 1, tl0, true); | |
529 InsertVp8(sn + 3, sn + 3, false, pid + 3, 2, tl0, false); | |
530 CheckReferencesVp8(pid); | |
531 CheckReferencesVp8(pid + 1, pid); | |
532 CheckReferencesVp8(pid + 2, pid); | |
533 CheckReferencesVp8(pid + 3, pid, pid + 1, pid + 2); | |
534 frames_from_callback_.clear(); | |
535 ++tl0; | |
536 | |
537 for (int f = 4; f < frames_per_keyframe; f += 4) { | |
538 uint16_t sf = sn + f; | |
539 uint16_t pidf = pid + f; | |
540 | |
541 InsertVp8(sf, sf, false, pidf, 0, tl0, false); | |
542 InsertVp8(sf + 1, sf + 1, false, pidf + 1, 2, tl0, false); | |
543 InsertVp8(sf + 2, sf + 2, false, pidf + 2, 1, tl0, false); | |
544 InsertVp8(sf + 3, sf + 3, false, pidf + 3, 2, tl0, false); | |
545 CheckReferencesVp8(pidf, pidf - 4); | |
546 CheckReferencesVp8(pidf + 1, pidf, pidf - 1, pidf - 2); | |
547 CheckReferencesVp8(pidf + 2, pidf, pidf - 2); | |
548 CheckReferencesVp8(pidf + 3, pidf, pidf + 1, pidf + 2); | |
549 frames_from_callback_.clear(); | |
550 ++tl0; | |
551 } | |
552 | |
553 pid += frames_per_keyframe; | |
554 sn += frames_per_keyframe; | |
555 } | |
556 } | |
557 | |
558 TEST_F(TestRtpFrameReferenceFinder, Vp8LayerSync) { | |
559 uint16_t pid = Rand(); | |
560 uint16_t sn = Rand(); | |
561 | |
562 InsertVp8(sn, sn, true, pid, 0, 0, false); | |
563 InsertVp8(sn + 1, sn + 1, false, pid + 1, 1, 0, true); | |
564 InsertVp8(sn + 2, sn + 2, false, pid + 2, 0, 1, false); | |
565 ASSERT_EQ(3UL, frames_from_callback_.size()); | |
566 | |
567 InsertVp8(sn + 4, sn + 4, false, pid + 4, 0, 2, false); | |
568 InsertVp8(sn + 5, sn + 5, false, pid + 5, 1, 2, true); | |
569 InsertVp8(sn + 6, sn + 6, false, pid + 6, 0, 3, false); | |
570 InsertVp8(sn + 7, sn + 7, false, pid + 7, 1, 3, false); | |
571 | |
572 ASSERT_EQ(7UL, frames_from_callback_.size()); | |
573 CheckReferencesVp8(pid); | |
574 CheckReferencesVp8(pid + 1, pid); | |
575 CheckReferencesVp8(pid + 2, pid); | |
576 CheckReferencesVp8(pid + 4, pid + 2); | |
577 CheckReferencesVp8(pid + 5, pid + 4); | |
578 CheckReferencesVp8(pid + 6, pid + 4); | |
579 CheckReferencesVp8(pid + 7, pid + 6, pid + 5); | |
580 } | |
581 | |
582 TEST_F(TestRtpFrameReferenceFinder, Vp9GofInsertOneFrame) { | |
583 uint16_t pid = Rand(); | |
584 uint16_t sn = Rand(); | |
585 GofInfoVP9 ss; | |
586 ss.SetGofInfoVP9(kTemporalStructureMode1); | |
587 | |
588 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
589 | |
590 CheckReferencesVp9(pid, 0); | |
591 } | |
592 | |
593 TEST_F(TestRtpFrameReferenceFinder, Vp9NoPictureIdReordered) { | |
594 uint16_t sn = 0xfffa; | |
595 | |
596 InsertVp9Gof(sn, sn + 2, true); | |
597 InsertVp9Gof(sn + 3, sn + 4, false); | |
598 InsertVp9Gof(sn + 9, sn + 9, false); | |
599 InsertVp9Gof(sn + 5, sn + 8, false); | |
600 InsertVp9Gof(sn + 12, sn + 12, true); | |
601 InsertVp9Gof(sn + 10, sn + 11, false); | |
602 InsertVp9Gof(sn + 13, sn + 17, false); | |
603 InsertVp9Gof(sn + 19, sn + 20, false); | |
604 InsertVp9Gof(sn + 21, sn + 21, false); | |
605 InsertVp9Gof(sn + 18, sn + 18, false); | |
606 | |
607 ASSERT_EQ(10UL, frames_from_callback_.size()); | |
608 CheckReferencesVp9(sn + 2, 0); | |
609 CheckReferencesVp9(sn + 4, 0, sn + 2); | |
610 CheckReferencesVp9(sn + 8, 0, sn + 4); | |
611 CheckReferencesVp9(sn + 9, 0, sn + 8); | |
612 CheckReferencesVp9(sn + 11, 0, sn + 9); | |
613 CheckReferencesVp9(sn + 12, 0); | |
614 CheckReferencesVp9(sn + 17, 0, sn + 12); | |
615 CheckReferencesVp9(sn + 18, 0, sn + 17); | |
616 CheckReferencesVp9(sn + 20, 0, sn + 18); | |
617 CheckReferencesVp9(sn + 21, 0, sn + 20); | |
618 } | |
619 | |
620 TEST_F(TestRtpFrameReferenceFinder, Vp9GofTemporalLayers_0) { | |
621 uint16_t pid = Rand(); | |
622 uint16_t sn = Rand(); | |
623 GofInfoVP9 ss; | |
624 ss.SetGofInfoVP9(kTemporalStructureMode1); // Only 1 spatial layer. | |
625 | |
626 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
627 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 0, 1, false); | |
628 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 0, 2, false); | |
629 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 0, 3, false); | |
630 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 4, false); | |
631 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 0, 5, false); | |
632 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 0, 6, false); | |
633 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 0, 7, false); | |
634 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 8, false); | |
635 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 0, 9, false); | |
636 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 0, 10, false); | |
637 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 0, 11, false); | |
638 InsertVp9Gof(sn + 12, sn + 12, false, pid + 12, 0, 0, 12, false); | |
639 InsertVp9Gof(sn + 13, sn + 13, false, pid + 13, 0, 0, 13, false); | |
640 InsertVp9Gof(sn + 14, sn + 14, false, pid + 14, 0, 0, 14, false); | |
641 InsertVp9Gof(sn + 15, sn + 15, false, pid + 15, 0, 0, 15, false); | |
642 InsertVp9Gof(sn + 16, sn + 16, false, pid + 16, 0, 0, 16, false); | |
643 InsertVp9Gof(sn + 17, sn + 17, false, pid + 17, 0, 0, 17, false); | |
644 InsertVp9Gof(sn + 18, sn + 18, false, pid + 18, 0, 0, 18, false); | |
645 InsertVp9Gof(sn + 19, sn + 19, false, pid + 19, 0, 0, 19, false); | |
646 | |
647 ASSERT_EQ(20UL, frames_from_callback_.size()); | |
648 CheckReferencesVp9(pid, 0); | |
649 CheckReferencesVp9(pid + 1, 0, pid); | |
650 CheckReferencesVp9(pid + 2, 0, pid + 1); | |
651 CheckReferencesVp9(pid + 3, 0, pid + 2); | |
652 CheckReferencesVp9(pid + 4, 0, pid + 3); | |
653 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
654 CheckReferencesVp9(pid + 6, 0, pid + 5); | |
655 CheckReferencesVp9(pid + 7, 0, pid + 6); | |
656 CheckReferencesVp9(pid + 8, 0, pid + 7); | |
657 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
658 CheckReferencesVp9(pid + 10, 0, pid + 9); | |
659 CheckReferencesVp9(pid + 11, 0, pid + 10); | |
660 CheckReferencesVp9(pid + 12, 0, pid + 11); | |
661 CheckReferencesVp9(pid + 13, 0, pid + 12); | |
662 CheckReferencesVp9(pid + 14, 0, pid + 13); | |
663 CheckReferencesVp9(pid + 15, 0, pid + 14); | |
664 CheckReferencesVp9(pid + 16, 0, pid + 15); | |
665 CheckReferencesVp9(pid + 17, 0, pid + 16); | |
666 CheckReferencesVp9(pid + 18, 0, pid + 17); | |
667 CheckReferencesVp9(pid + 19, 0, pid + 18); | |
668 } | |
669 | |
670 TEST_F(TestRtpFrameReferenceFinder, Vp9GofTemporalLayersReordered_0) { | |
671 uint16_t pid = Rand(); | |
672 uint16_t sn = Rand(); | |
673 GofInfoVP9 ss; | |
674 ss.SetGofInfoVP9(kTemporalStructureMode1); // Only 1 spatial layer. | |
675 | |
676 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 0, 2, false); | |
677 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 0, 1, false); | |
678 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
679 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 4, false); | |
680 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 0, 3, false); | |
681 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 0, 5, false); | |
682 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 0, 7, false); | |
683 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 0, 6, false); | |
684 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 8, false); | |
685 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 0, 10, false); | |
686 InsertVp9Gof(sn + 13, sn + 13, false, pid + 13, 0, 0, 13, false); | |
687 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 0, 11, false); | |
688 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 0, 9, false); | |
689 InsertVp9Gof(sn + 16, sn + 16, false, pid + 16, 0, 0, 16, false); | |
690 InsertVp9Gof(sn + 14, sn + 14, false, pid + 14, 0, 0, 14, false); | |
691 InsertVp9Gof(sn + 15, sn + 15, false, pid + 15, 0, 0, 15, false); | |
692 InsertVp9Gof(sn + 12, sn + 12, false, pid + 12, 0, 0, 12, false); | |
693 InsertVp9Gof(sn + 17, sn + 17, false, pid + 17, 0, 0, 17, false); | |
694 InsertVp9Gof(sn + 19, sn + 19, false, pid + 19, 0, 0, 19, false); | |
695 InsertVp9Gof(sn + 18, sn + 18, false, pid + 18, 0, 0, 18, false); | |
696 | |
697 ASSERT_EQ(20UL, frames_from_callback_.size()); | |
698 CheckReferencesVp9(pid, 0); | |
699 CheckReferencesVp9(pid + 1, 0, pid); | |
700 CheckReferencesVp9(pid + 2, 0, pid + 1); | |
701 CheckReferencesVp9(pid + 3, 0, pid + 2); | |
702 CheckReferencesVp9(pid + 4, 0, pid + 3); | |
703 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
704 CheckReferencesVp9(pid + 6, 0, pid + 5); | |
705 CheckReferencesVp9(pid + 7, 0, pid + 6); | |
706 CheckReferencesVp9(pid + 8, 0, pid + 7); | |
707 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
708 CheckReferencesVp9(pid + 10, 0, pid + 9); | |
709 CheckReferencesVp9(pid + 11, 0, pid + 10); | |
710 CheckReferencesVp9(pid + 12, 0, pid + 11); | |
711 CheckReferencesVp9(pid + 13, 0, pid + 12); | |
712 CheckReferencesVp9(pid + 14, 0, pid + 13); | |
713 CheckReferencesVp9(pid + 15, 0, pid + 14); | |
714 CheckReferencesVp9(pid + 16, 0, pid + 15); | |
715 CheckReferencesVp9(pid + 17, 0, pid + 16); | |
716 CheckReferencesVp9(pid + 18, 0, pid + 17); | |
717 CheckReferencesVp9(pid + 19, 0, pid + 18); | |
718 } | |
719 | |
720 TEST_F(TestRtpFrameReferenceFinder, Vp9GofSkipFramesTemporalLayers_01) { | |
721 uint16_t pid = Rand(); | |
722 uint16_t sn = Rand(); | |
723 GofInfoVP9 ss; | |
724 ss.SetGofInfoVP9(kTemporalStructureMode2); // 0101 pattern | |
725 | |
726 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
727 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 1, 0, false); | |
728 // Skip GOF with tl0 1 | |
729 InsertVp9Gof(sn + 4, sn + 4, true, pid + 4, 0, 0, 2, false, &ss); | |
730 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 1, 2, false); | |
731 // Skip GOF with tl0 3 | |
732 // Skip GOF with tl0 4 | |
733 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 0, 5, false, &ss); | |
734 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 1, 5, false); | |
735 | |
736 ASSERT_EQ(6UL, frames_from_callback_.size()); | |
737 CheckReferencesVp9(pid, 0); | |
738 CheckReferencesVp9(pid + 1, 0, pid); | |
739 CheckReferencesVp9(pid + 4, 0); | |
740 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
741 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
742 CheckReferencesVp9(pid + 11, 0, pid + 10); | |
743 } | |
744 | |
745 TEST_F(TestRtpFrameReferenceFinder, Vp9GofSkipFramesTemporalLayers_0212) { | |
746 uint16_t pid = Rand(); | |
747 uint16_t sn = Rand(); | |
748 GofInfoVP9 ss; | |
749 ss.SetGofInfoVP9(kTemporalStructureMode3); // 02120212 pattern | |
750 | |
751 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
752 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 2, 0, false); | |
753 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 1, 0, false); | |
754 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 2, 0, false); | |
755 | |
756 ASSERT_EQ(4UL, frames_from_callback_.size()); | |
757 CheckReferencesVp9(pid, 0); | |
758 CheckReferencesVp9(pid + 1, 0, pid); | |
759 CheckReferencesVp9(pid + 2, 0, pid); | |
760 CheckReferencesVp9(pid + 3, 0, pid + 1, pid + 2); | |
761 | |
762 // Skip frames with tl0 = 1 | |
763 | |
764 InsertVp9Gof(sn + 8, sn + 8, true, pid + 8, 0, 0, 2, false, &ss); | |
765 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 2, 2, false); | |
766 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 1, 2, false); | |
767 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 2, 2, false); | |
768 | |
769 ASSERT_EQ(8UL, frames_from_callback_.size()); | |
770 CheckReferencesVp9(pid + 8, 0); | |
771 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
772 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
773 CheckReferencesVp9(pid + 11, 0, pid + 9, pid + 10); | |
774 | |
775 // Now insert frames with tl0 = 1 | |
776 InsertVp9Gof(sn + 4, sn + 4, true, pid + 4, 0, 0, 1, false, &ss); | |
777 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 2, 1, false); | |
778 | |
779 ASSERT_EQ(9UL, frames_from_callback_.size()); | |
780 CheckReferencesVp9(pid + 4, 0); | |
781 | |
782 // Rest of frames belonging to tl0 = 1 | |
783 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 2, 1, false); | |
784 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 1, 1, true); // up-switch | |
785 | |
786 ASSERT_EQ(12UL, frames_from_callback_.size()); | |
787 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
788 CheckReferencesVp9(pid + 6, 0, pid + 4); | |
789 CheckReferencesVp9(pid + 7, 0, pid + 6); | |
790 } | |
791 | |
792 TEST_F(TestRtpFrameReferenceFinder, Vp9GofTemporalLayers_01) { | |
793 uint16_t pid = Rand(); | |
794 uint16_t sn = Rand(); | |
795 GofInfoVP9 ss; | |
796 ss.SetGofInfoVP9(kTemporalStructureMode2); // 0101 pattern | |
797 | |
798 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
799 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 1, 0, false); | |
800 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 0, 1, false); | |
801 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 1, 1, false); | |
802 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 2, false); | |
803 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 1, 2, false); | |
804 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 0, 3, false); | |
805 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 1, 3, false); | |
806 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 4, false); | |
807 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 1, 4, false); | |
808 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 0, 5, false); | |
809 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 1, 5, false); | |
810 InsertVp9Gof(sn + 12, sn + 12, false, pid + 12, 0, 0, 6, false); | |
811 InsertVp9Gof(sn + 13, sn + 13, false, pid + 13, 0, 1, 6, false); | |
812 InsertVp9Gof(sn + 14, sn + 14, false, pid + 14, 0, 0, 7, false); | |
813 InsertVp9Gof(sn + 15, sn + 15, false, pid + 15, 0, 1, 7, false); | |
814 InsertVp9Gof(sn + 16, sn + 16, false, pid + 16, 0, 0, 8, false); | |
815 InsertVp9Gof(sn + 17, sn + 17, false, pid + 17, 0, 1, 8, false); | |
816 InsertVp9Gof(sn + 18, sn + 18, false, pid + 18, 0, 0, 9, false); | |
817 InsertVp9Gof(sn + 19, sn + 19, false, pid + 19, 0, 1, 9, false); | |
818 | |
819 ASSERT_EQ(20UL, frames_from_callback_.size()); | |
820 CheckReferencesVp9(pid, 0); | |
821 CheckReferencesVp9(pid + 1, 0, pid); | |
822 CheckReferencesVp9(pid + 2, 0, pid); | |
823 CheckReferencesVp9(pid + 3, 0, pid + 2); | |
824 CheckReferencesVp9(pid + 4, 0, pid + 2); | |
825 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
826 CheckReferencesVp9(pid + 6, 0, pid + 4); | |
827 CheckReferencesVp9(pid + 7, 0, pid + 6); | |
828 CheckReferencesVp9(pid + 8, 0, pid + 6); | |
829 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
830 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
831 CheckReferencesVp9(pid + 11, 0, pid + 10); | |
832 CheckReferencesVp9(pid + 12, 0, pid + 10); | |
833 CheckReferencesVp9(pid + 13, 0, pid + 12); | |
834 CheckReferencesVp9(pid + 14, 0, pid + 12); | |
835 CheckReferencesVp9(pid + 15, 0, pid + 14); | |
836 CheckReferencesVp9(pid + 16, 0, pid + 14); | |
837 CheckReferencesVp9(pid + 17, 0, pid + 16); | |
838 CheckReferencesVp9(pid + 18, 0, pid + 16); | |
839 CheckReferencesVp9(pid + 19, 0, pid + 18); | |
840 } | |
841 | |
842 TEST_F(TestRtpFrameReferenceFinder, Vp9GofTemporalLayersReordered_01) { | |
843 uint16_t pid = Rand(); | |
844 uint16_t sn = Rand(); | |
845 GofInfoVP9 ss; | |
846 ss.SetGofInfoVP9(kTemporalStructureMode2); // 01 pattern | |
847 | |
848 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 1, 0, false); | |
849 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
850 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 0, 1, false); | |
851 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 2, false); | |
852 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 1, 1, false); | |
853 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 1, 2, false); | |
854 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 1, 3, false); | |
855 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 0, 3, false); | |
856 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 0, 5, false); | |
857 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 4, false); | |
858 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 1, 4, false); | |
859 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 1, 5, false); | |
860 InsertVp9Gof(sn + 13, sn + 13, false, pid + 13, 0, 1, 6, false); | |
861 InsertVp9Gof(sn + 16, sn + 16, false, pid + 16, 0, 0, 8, false); | |
862 InsertVp9Gof(sn + 12, sn + 12, false, pid + 12, 0, 0, 6, false); | |
863 InsertVp9Gof(sn + 14, sn + 14, false, pid + 14, 0, 0, 7, false); | |
864 InsertVp9Gof(sn + 17, sn + 17, false, pid + 17, 0, 1, 8, false); | |
865 InsertVp9Gof(sn + 19, sn + 19, false, pid + 19, 0, 1, 9, false); | |
866 InsertVp9Gof(sn + 15, sn + 15, false, pid + 15, 0, 1, 7, false); | |
867 InsertVp9Gof(sn + 18, sn + 18, false, pid + 18, 0, 0, 9, false); | |
868 | |
869 ASSERT_EQ(20UL, frames_from_callback_.size()); | |
870 CheckReferencesVp9(pid, 0); | |
871 CheckReferencesVp9(pid + 1, 0, pid); | |
872 CheckReferencesVp9(pid + 2, 0, pid); | |
873 CheckReferencesVp9(pid + 3, 0, pid + 2); | |
874 CheckReferencesVp9(pid + 4, 0, pid + 2); | |
875 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
876 CheckReferencesVp9(pid + 6, 0, pid + 4); | |
877 CheckReferencesVp9(pid + 7, 0, pid + 6); | |
878 CheckReferencesVp9(pid + 8, 0, pid + 6); | |
879 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
880 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
881 CheckReferencesVp9(pid + 11, 0, pid + 10); | |
882 CheckReferencesVp9(pid + 12, 0, pid + 10); | |
883 CheckReferencesVp9(pid + 13, 0, pid + 12); | |
884 CheckReferencesVp9(pid + 14, 0, pid + 12); | |
885 CheckReferencesVp9(pid + 15, 0, pid + 14); | |
886 CheckReferencesVp9(pid + 16, 0, pid + 14); | |
887 CheckReferencesVp9(pid + 17, 0, pid + 16); | |
888 CheckReferencesVp9(pid + 18, 0, pid + 16); | |
889 CheckReferencesVp9(pid + 19, 0, pid + 18); | |
890 } | |
891 | |
892 TEST_F(TestRtpFrameReferenceFinder, Vp9GofTemporalLayers_0212) { | |
893 uint16_t pid = Rand(); | |
894 uint16_t sn = Rand(); | |
895 GofInfoVP9 ss; | |
896 ss.SetGofInfoVP9(kTemporalStructureMode3); // 0212 pattern | |
897 | |
898 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
899 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 2, 0, false); | |
900 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 1, 0, false); | |
901 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 2, 0, false); | |
902 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 1, false); | |
903 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 2, 1, false); | |
904 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 1, 1, false); | |
905 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 2, 1, false); | |
906 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 2, false); | |
907 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 2, 2, false); | |
908 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 1, 2, false); | |
909 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 2, 2, false); | |
910 InsertVp9Gof(sn + 12, sn + 12, false, pid + 12, 0, 0, 3, false); | |
911 InsertVp9Gof(sn + 13, sn + 13, false, pid + 13, 0, 2, 3, false); | |
912 InsertVp9Gof(sn + 14, sn + 14, false, pid + 14, 0, 1, 3, false); | |
913 InsertVp9Gof(sn + 15, sn + 15, false, pid + 15, 0, 2, 3, false); | |
914 InsertVp9Gof(sn + 16, sn + 16, false, pid + 16, 0, 0, 4, false); | |
915 InsertVp9Gof(sn + 17, sn + 17, false, pid + 17, 0, 2, 4, false); | |
916 InsertVp9Gof(sn + 18, sn + 18, false, pid + 18, 0, 1, 4, false); | |
917 InsertVp9Gof(sn + 19, sn + 19, false, pid + 19, 0, 2, 4, false); | |
918 | |
919 ASSERT_EQ(20UL, frames_from_callback_.size()); | |
920 CheckReferencesVp9(pid, 0); | |
921 CheckReferencesVp9(pid + 1, 0, pid); | |
922 CheckReferencesVp9(pid + 2, 0, pid); | |
923 CheckReferencesVp9(pid + 3, 0, pid + 1, pid + 2); | |
924 CheckReferencesVp9(pid + 4, 0, pid); | |
925 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
926 CheckReferencesVp9(pid + 6, 0, pid + 4); | |
927 CheckReferencesVp9(pid + 7, 0, pid + 5, pid + 6); | |
928 CheckReferencesVp9(pid + 8, 0, pid + 4); | |
929 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
930 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
931 CheckReferencesVp9(pid + 11, 0, pid + 9, pid + 10); | |
932 CheckReferencesVp9(pid + 12, 0, pid + 8); | |
933 CheckReferencesVp9(pid + 13, 0, pid + 12); | |
934 CheckReferencesVp9(pid + 14, 0, pid + 12); | |
935 CheckReferencesVp9(pid + 15, 0, pid + 13, pid + 14); | |
936 CheckReferencesVp9(pid + 16, 0, pid + 12); | |
937 CheckReferencesVp9(pid + 17, 0, pid + 16); | |
938 CheckReferencesVp9(pid + 18, 0, pid + 16); | |
939 CheckReferencesVp9(pid + 19, 0, pid + 17, pid + 18); | |
940 } | |
941 | |
942 TEST_F(TestRtpFrameReferenceFinder, Vp9GofTemporalLayersReordered_0212) { | |
943 uint16_t pid = Rand(); | |
944 uint16_t sn = Rand(); | |
945 GofInfoVP9 ss; | |
946 ss.SetGofInfoVP9(kTemporalStructureMode3); // 0212 pattern | |
947 | |
948 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 1, 0, false); | |
949 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 2, 0, false); | |
950 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
951 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 2, 0, false); | |
952 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 1, 1, false); | |
953 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 2, 1, false); | |
954 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 1, false); | |
955 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 2, 2, false); | |
956 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 2, 1, false); | |
957 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 2, false); | |
958 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 2, 2, false); | |
959 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 1, 2, false); | |
960 InsertVp9Gof(sn + 13, sn + 13, false, pid + 13, 0, 2, 3, false); | |
961 InsertVp9Gof(sn + 12, sn + 12, false, pid + 12, 0, 0, 3, false); | |
962 InsertVp9Gof(sn + 14, sn + 14, false, pid + 14, 0, 1, 3, false); | |
963 InsertVp9Gof(sn + 16, sn + 16, false, pid + 16, 0, 0, 4, false); | |
964 InsertVp9Gof(sn + 15, sn + 15, false, pid + 15, 0, 2, 3, false); | |
965 InsertVp9Gof(sn + 17, sn + 17, false, pid + 17, 0, 2, 4, false); | |
966 InsertVp9Gof(sn + 19, sn + 19, false, pid + 19, 0, 2, 4, false); | |
967 InsertVp9Gof(sn + 18, sn + 18, false, pid + 18, 0, 1, 4, false); | |
968 | |
969 ASSERT_EQ(20UL, frames_from_callback_.size()); | |
970 CheckReferencesVp9(pid, 0); | |
971 CheckReferencesVp9(pid + 1, 0, pid); | |
972 CheckReferencesVp9(pid + 2, 0, pid); | |
973 CheckReferencesVp9(pid + 3, 0, pid + 1, pid + 2); | |
974 CheckReferencesVp9(pid + 4, 0, pid); | |
975 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
976 CheckReferencesVp9(pid + 6, 0, pid + 4); | |
977 CheckReferencesVp9(pid + 7, 0, pid + 5, pid + 6); | |
978 CheckReferencesVp9(pid + 8, 0, pid + 4); | |
979 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
980 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
981 CheckReferencesVp9(pid + 11, 0, pid + 9, pid + 10); | |
982 CheckReferencesVp9(pid + 12, 0, pid + 8); | |
983 CheckReferencesVp9(pid + 13, 0, pid + 12); | |
984 CheckReferencesVp9(pid + 14, 0, pid + 12); | |
985 CheckReferencesVp9(pid + 15, 0, pid + 13, pid + 14); | |
986 CheckReferencesVp9(pid + 16, 0, pid + 12); | |
987 CheckReferencesVp9(pid + 17, 0, pid + 16); | |
988 CheckReferencesVp9(pid + 18, 0, pid + 16); | |
989 CheckReferencesVp9(pid + 19, 0, pid + 17, pid + 18); | |
990 } | |
991 | |
992 TEST_F(TestRtpFrameReferenceFinder, Vp9GofTemporalLayersUpSwitch_02120212) { | |
993 uint16_t pid = Rand(); | |
994 uint16_t sn = Rand(); | |
995 GofInfoVP9 ss; | |
996 ss.SetGofInfoVP9(kTemporalStructureMode4); // 02120212 pattern | |
997 | |
998 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
999 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 2, 0, false); | |
1000 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 1, 0, false); | |
1001 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 2, 0, false); | |
1002 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 1, false); | |
1003 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 2, 1, false); | |
1004 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 1, 1, true); | |
1005 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 2, 1, false); | |
1006 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 2, true); | |
1007 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 2, 2, false); | |
1008 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 1, 2, false); | |
1009 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 2, 2, true); | |
1010 InsertVp9Gof(sn + 12, sn + 12, false, pid + 12, 0, 0, 3, false); | |
1011 InsertVp9Gof(sn + 13, sn + 13, false, pid + 13, 0, 2, 3, false); | |
1012 InsertVp9Gof(sn + 14, sn + 14, false, pid + 14, 0, 1, 3, false); | |
1013 InsertVp9Gof(sn + 15, sn + 15, false, pid + 15, 0, 2, 3, false); | |
1014 | |
1015 ASSERT_EQ(16UL, frames_from_callback_.size()); | |
1016 CheckReferencesVp9(pid, 0); | |
1017 CheckReferencesVp9(pid + 1, 0, pid); | |
1018 CheckReferencesVp9(pid + 2, 0, pid); | |
1019 CheckReferencesVp9(pid + 3, 0, pid + 1, pid + 2); | |
1020 CheckReferencesVp9(pid + 4, 0, pid); | |
1021 CheckReferencesVp9(pid + 5, 0, pid + 3, pid + 4); | |
1022 CheckReferencesVp9(pid + 6, 0, pid + 2, pid + 4); | |
1023 CheckReferencesVp9(pid + 7, 0, pid + 6); | |
1024 CheckReferencesVp9(pid + 8, 0, pid + 4); | |
1025 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
1026 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
1027 CheckReferencesVp9(pid + 11, 0, pid + 9, pid + 10); | |
1028 CheckReferencesVp9(pid + 12, 0, pid + 8); | |
1029 CheckReferencesVp9(pid + 13, 0, pid + 11, pid + 12); | |
1030 CheckReferencesVp9(pid + 14, 0, pid + 10, pid + 12); | |
1031 CheckReferencesVp9(pid + 15, 0, pid + 13, pid + 14); | |
1032 } | |
1033 | |
1034 TEST_F(TestRtpFrameReferenceFinder, | |
1035 Vp9GofTemporalLayersUpSwitchReordered_02120212) { | |
1036 uint16_t pid = Rand(); | |
1037 uint16_t sn = Rand(); | |
1038 GofInfoVP9 ss; | |
1039 ss.SetGofInfoVP9(kTemporalStructureMode4); // 02120212 pattern | |
1040 | |
1041 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 2, 0, false); | |
1042 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
1043 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 1, false); | |
1044 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 1, 0, false); | |
1045 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 2, 1, false); | |
1046 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 2, 0, false); | |
1047 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 2, 1, false); | |
1048 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 2, 2, false); | |
1049 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 1, 1, true); | |
1050 InsertVp9Gof(sn + 12, sn + 12, false, pid + 12, 0, 0, 3, false); | |
1051 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 1, 2, false); | |
1052 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 2, true); | |
1053 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 2, 2, true); | |
1054 InsertVp9Gof(sn + 13, sn + 13, false, pid + 13, 0, 2, 3, false); | |
1055 InsertVp9Gof(sn + 15, sn + 15, false, pid + 15, 0, 2, 3, false); | |
1056 InsertVp9Gof(sn + 14, sn + 14, false, pid + 14, 0, 1, 3, false); | |
1057 | |
1058 ASSERT_EQ(16UL, frames_from_callback_.size()); | |
1059 CheckReferencesVp9(pid, 0); | |
1060 CheckReferencesVp9(pid + 1, 0, pid); | |
1061 CheckReferencesVp9(pid + 2, 0, pid); | |
1062 CheckReferencesVp9(pid + 3, 0, pid + 1, pid + 2); | |
1063 CheckReferencesVp9(pid + 4, 0, pid); | |
1064 CheckReferencesVp9(pid + 5, 0, pid + 3, pid + 4); | |
1065 CheckReferencesVp9(pid + 6, 0, pid + 2, pid + 4); | |
1066 CheckReferencesVp9(pid + 7, 0, pid + 6); | |
1067 CheckReferencesVp9(pid + 8, 0, pid + 4); | |
1068 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
1069 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
1070 CheckReferencesVp9(pid + 11, 0, pid + 9, pid + 10); | |
1071 CheckReferencesVp9(pid + 12, 0, pid + 8); | |
1072 CheckReferencesVp9(pid + 13, 0, pid + 11, pid + 12); | |
1073 CheckReferencesVp9(pid + 14, 0, pid + 10, pid + 12); | |
1074 CheckReferencesVp9(pid + 15, 0, pid + 13, pid + 14); | |
1075 } | |
1076 | |
1077 TEST_F(TestRtpFrameReferenceFinder, Vp9GofTemporalLayersReordered_01_0212) { | |
1078 uint16_t pid = Rand(); | |
1079 uint16_t sn = Rand(); | |
1080 GofInfoVP9 ss; | |
1081 ss.SetGofInfoVP9(kTemporalStructureMode2); // 01 pattern | |
1082 | |
1083 InsertVp9Gof(sn + 1, sn + 1, false, pid + 1, 0, 1, 0, false); | |
1084 InsertVp9Gof(sn, sn, true, pid, 0, 0, 0, false, &ss); | |
1085 InsertVp9Gof(sn + 3, sn + 3, false, pid + 3, 0, 1, 1, false); | |
1086 InsertVp9Gof(sn + 6, sn + 6, false, pid + 6, 0, 1, 2, false); | |
1087 ss.SetGofInfoVP9(kTemporalStructureMode3); // 0212 pattern | |
1088 InsertVp9Gof(sn + 4, sn + 4, false, pid + 4, 0, 0, 2, false, &ss); | |
1089 InsertVp9Gof(sn + 2, sn + 2, false, pid + 2, 0, 0, 1, false); | |
1090 InsertVp9Gof(sn + 5, sn + 5, false, pid + 5, 0, 2, 2, false); | |
1091 InsertVp9Gof(sn + 8, sn + 8, false, pid + 8, 0, 0, 3, false); | |
1092 InsertVp9Gof(sn + 10, sn + 10, false, pid + 10, 0, 1, 3, false); | |
1093 InsertVp9Gof(sn + 7, sn + 7, false, pid + 7, 0, 2, 2, false); | |
1094 InsertVp9Gof(sn + 11, sn + 11, false, pid + 11, 0, 2, 3, false); | |
1095 InsertVp9Gof(sn + 9, sn + 9, false, pid + 9, 0, 2, 3, false); | |
1096 | |
1097 ASSERT_EQ(12UL, frames_from_callback_.size()); | |
1098 CheckReferencesVp9(pid, 0); | |
1099 CheckReferencesVp9(pid + 1, 0, pid); | |
1100 CheckReferencesVp9(pid + 2, 0, pid); | |
1101 CheckReferencesVp9(pid + 3, 0, pid + 2); | |
1102 CheckReferencesVp9(pid + 4, 0, pid); | |
1103 CheckReferencesVp9(pid + 5, 0, pid + 4); | |
1104 CheckReferencesVp9(pid + 6, 0, pid + 4); | |
1105 CheckReferencesVp9(pid + 7, 0, pid + 5, pid + 6); | |
1106 CheckReferencesVp9(pid + 8, 0, pid + 4); | |
1107 CheckReferencesVp9(pid + 9, 0, pid + 8); | |
1108 CheckReferencesVp9(pid + 10, 0, pid + 8); | |
1109 CheckReferencesVp9(pid + 11, 0, pid + 9, pid + 10); | |
1110 } | |
1111 | |
1112 TEST_F(TestRtpFrameReferenceFinder, Vp9FlexibleModeOneFrame) { | |
1113 uint16_t pid = Rand(); | |
1114 uint16_t sn = Rand(); | |
1115 | |
1116 // sn, false, frst, lst, intr, pid, sid, tid, tl0 | |
1117 InsertVp9Flex(sn, sn, true, pid, 0, 0, 0, false); | |
1118 | |
1119 ASSERT_EQ(1UL, frames_from_callback_.size()); | |
1120 CheckReferencesVp9(pid, 0); | |
1121 } | |
1122 | |
1123 TEST_F(TestRtpFrameReferenceFinder, Vp9FlexibleModeTwoSpatialLayers) { | |
1124 uint16_t pid = Rand(); | |
1125 uint16_t sn = Rand(); | |
1126 | |
1127 // sn , false, frst, lst, intr, pid , sid, tid, tl0, refs | |
stefan-webrtc
2016/08/04 14:32:30
Something should probably be done with these comme
philipel
2016/08/04 14:45:02
Removed comments.
danilchap
2016/08/05 12:50:50
Now it it hard to understand what frames do you in
philipel
2016/08/08 13:34:57
I can add comments about the order of the paramete
danilchap
2016/08/08 14:49:31
fyi:
// clang-format off
Customly formatted text
| |
1128 InsertVp9Flex(sn, sn, true, pid, 0, 0, 0, false); | |
1129 InsertVp9Flex(sn + 1, sn + 1, true, pid, 1, 0, 0, true); | |
1130 InsertVp9Flex(sn + 2, sn + 2, false, pid + 1, 1, 0, 0, false, {1}); | |
1131 InsertVp9Flex(sn + 3, sn + 3, false, pid + 2, 0, 0, 1, false, {2}); | |
1132 InsertVp9Flex(sn + 4, sn + 4, false, pid + 2, 1, 0, 1, false, {1}); | |
1133 InsertVp9Flex(sn + 5, sn + 5, false, pid + 3, 1, 0, 1, false, {1}); | |
1134 InsertVp9Flex(sn + 6, sn + 6, false, pid + 4, 0, 0, 2, false, {2}); | |
1135 InsertVp9Flex(sn + 7, sn + 7, false, pid + 4, 1, 0, 2, false, {1}); | |
1136 InsertVp9Flex(sn + 8, sn + 8, false, pid + 5, 1, 0, 2, false, {1}); | |
1137 InsertVp9Flex(sn + 9, sn + 9, false, pid + 6, 0, 0, 3, false, {2}); | |
1138 InsertVp9Flex(sn + 10, sn + 10, false, pid + 6, 1, 0, 3, false, {1}); | |
1139 InsertVp9Flex(sn + 11, sn + 11, false, pid + 7, 1, 0, 3, false, {1}); | |
1140 InsertVp9Flex(sn + 12, sn + 12, false, pid + 8, 0, 0, 4, false, {2}); | |
1141 InsertVp9Flex(sn + 13, sn + 13, false, pid + 8, 1, 0, 4, false, {1}); | |
1142 | |
1143 ASSERT_EQ(14UL, frames_from_callback_.size()); | |
1144 CheckReferencesVp9(pid, 0); | |
1145 CheckReferencesVp9(pid, 1); | |
1146 CheckReferencesVp9(pid + 1, 1, pid); | |
1147 CheckReferencesVp9(pid + 2, 0, pid); | |
1148 CheckReferencesVp9(pid + 2, 1, pid + 1); | |
1149 CheckReferencesVp9(pid + 3, 1, pid + 2); | |
1150 CheckReferencesVp9(pid + 4, 0, pid + 2); | |
1151 CheckReferencesVp9(pid + 4, 1, pid + 3); | |
1152 CheckReferencesVp9(pid + 5, 1, pid + 4); | |
1153 CheckReferencesVp9(pid + 6, 0, pid + 4); | |
1154 CheckReferencesVp9(pid + 6, 1, pid + 5); | |
1155 CheckReferencesVp9(pid + 7, 1, pid + 6); | |
1156 CheckReferencesVp9(pid + 8, 0, pid + 6); | |
1157 CheckReferencesVp9(pid + 8, 1, pid + 7); | |
1158 } | |
1159 | |
1160 TEST_F(TestRtpFrameReferenceFinder, Vp9FlexibleModeTwoSpatialLayersReordered) { | |
1161 uint16_t pid = Rand(); | |
1162 uint16_t sn = Rand(); | |
1163 | |
1164 // sn , false, frst, lst, intr, pid , sid, tid, tl0, refs | |
1165 InsertVp9Flex(sn + 1, sn + 1, true, pid, 1, 0, 0, true); | |
1166 InsertVp9Flex(sn + 2, sn + 2, false, pid + 1, 1, 0, 0, false, {1}); | |
1167 InsertVp9Flex(sn, sn, true, pid, 0, 0, 0, false); | |
1168 InsertVp9Flex(sn + 4, sn + 4, false, pid + 2, 1, 0, 1, false, {1}); | |
1169 InsertVp9Flex(sn + 5, sn + 5, false, pid + 3, 1, 0, 1, false, {1}); | |
1170 InsertVp9Flex(sn + 3, sn + 3, false, pid + 2, 0, 0, 1, false, {2}); | |
1171 InsertVp9Flex(sn + 7, sn + 7, false, pid + 4, 1, 0, 2, false, {1}); | |
1172 InsertVp9Flex(sn + 6, sn + 6, false, pid + 4, 0, 0, 2, false, {2}); | |
1173 InsertVp9Flex(sn + 8, sn + 8, false, pid + 5, 1, 0, 2, false, {1}); | |
1174 InsertVp9Flex(sn + 9, sn + 9, false, pid + 6, 0, 0, 3, false, {2}); | |
1175 InsertVp9Flex(sn + 11, sn + 11, false, pid + 7, 1, 0, 3, false, {1}); | |
1176 InsertVp9Flex(sn + 10, sn + 10, false, pid + 6, 1, 0, 3, false, {1}); | |
1177 InsertVp9Flex(sn + 13, sn + 13, false, pid + 8, 1, 0, 4, false, {1}); | |
1178 InsertVp9Flex(sn + 12, sn + 12, false, pid + 8, 0, 0, 4, false, {2}); | |
1179 | |
1180 ASSERT_EQ(14UL, frames_from_callback_.size()); | |
1181 CheckReferencesVp9(pid, 0); | |
1182 CheckReferencesVp9(pid, 1); | |
1183 CheckReferencesVp9(pid + 1, 1, pid); | |
1184 CheckReferencesVp9(pid + 2, 0, pid); | |
1185 CheckReferencesVp9(pid + 2, 1, pid + 1); | |
1186 CheckReferencesVp9(pid + 3, 1, pid + 2); | |
1187 CheckReferencesVp9(pid + 4, 0, pid + 2); | |
1188 CheckReferencesVp9(pid + 4, 1, pid + 3); | |
1189 CheckReferencesVp9(pid + 5, 1, pid + 4); | |
1190 CheckReferencesVp9(pid + 6, 0, pid + 4); | |
1191 CheckReferencesVp9(pid + 6, 1, pid + 5); | |
1192 CheckReferencesVp9(pid + 7, 1, pid + 6); | |
1193 CheckReferencesVp9(pid + 8, 0, pid + 6); | |
1194 CheckReferencesVp9(pid + 8, 1, pid + 7); | |
1195 } | |
1196 | |
1197 } // namespace video_coding | |
1198 } // namespace webrtc | |
OLD | NEW |