OLD | NEW |
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 size_t data_size = 0, // size of data | 91 size_t data_size = 0, // size of data |
92 uint8_t* data = nullptr) { // data pointer | 92 uint8_t* data = nullptr) { // data pointer |
93 VCMPacket packet; | 93 VCMPacket packet; |
94 packet.codec = kVideoCodecVP8; | 94 packet.codec = kVideoCodecVP8; |
95 packet.seqNum = seq_num; | 95 packet.seqNum = seq_num; |
96 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; | 96 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; |
97 packet.isFirstPacket = first; | 97 packet.isFirstPacket = first; |
98 packet.markerBit = last; | 98 packet.markerBit = last; |
99 packet.sizeBytes = data_size; | 99 packet.sizeBytes = data_size; |
100 packet.dataPtr = data; | 100 packet.dataPtr = data; |
101 packet.codecSpecificHeader.codecHeader.VP8.pictureId = pid % (1 << 15); | 101 packet.video_header.codecHeader.VP8.pictureId = pid % (1 << 15); |
102 packet.codecSpecificHeader.codecHeader.VP8.temporalIdx = tid; | 102 packet.video_header.codecHeader.VP8.temporalIdx = tid; |
103 packet.codecSpecificHeader.codecHeader.VP8.tl0PicIdx = tl0; | 103 packet.video_header.codecHeader.VP8.tl0PicIdx = tl0; |
104 packet.codecSpecificHeader.codecHeader.VP8.layerSync = sync; | 104 packet.video_header.codecHeader.VP8.layerSync = sync; |
105 | 105 |
106 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); | 106 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); |
107 } | 107 } |
108 | 108 |
109 // Insert a Vp9 packet into the packet buffer. | 109 // Insert a Vp9 packet into the packet buffer. |
110 void InsertVp9Gof(uint16_t seq_num, // packet sequence number | 110 void InsertVp9Gof(uint16_t seq_num, // packet sequence number |
111 bool keyframe, // is keyframe | 111 bool keyframe, // is keyframe |
112 bool first, // is first packet of frame | 112 bool first, // is first packet of frame |
113 bool last, // is last packet of frame | 113 bool last, // is last packet of frame |
114 bool up = false, // frame is up-switch point | 114 bool up = false, // frame is up-switch point |
115 int32_t pid = kNoPictureId, // picture id | 115 int32_t pid = kNoPictureId, // picture id |
116 uint8_t sid = kNoSpatialIdx, // spatial id | 116 uint8_t sid = kNoSpatialIdx, // spatial id |
117 uint8_t tid = kNoTemporalIdx, // temporal id | 117 uint8_t tid = kNoTemporalIdx, // temporal id |
118 int32_t tl0 = kNoTl0PicIdx, // tl0 pic index | 118 int32_t tl0 = kNoTl0PicIdx, // tl0 pic index |
119 GofInfoVP9* ss = nullptr, // scalability structure | 119 GofInfoVP9* ss = nullptr, // scalability structure |
120 size_t data_size = 0, // size of data | 120 size_t data_size = 0, // size of data |
121 uint8_t* data = nullptr) { // data pointer | 121 uint8_t* data = nullptr) { // data pointer |
122 VCMPacket packet; | 122 VCMPacket packet; |
123 packet.codec = kVideoCodecVP9; | 123 packet.codec = kVideoCodecVP9; |
124 packet.seqNum = seq_num; | 124 packet.seqNum = seq_num; |
125 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; | 125 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; |
126 packet.isFirstPacket = first; | 126 packet.isFirstPacket = first; |
127 packet.markerBit = last; | 127 packet.markerBit = last; |
128 packet.sizeBytes = data_size; | 128 packet.sizeBytes = data_size; |
129 packet.dataPtr = data; | 129 packet.dataPtr = data; |
130 packet.codecSpecificHeader.codecHeader.VP9.flexible_mode = false; | 130 packet.video_header.codecHeader.VP9.flexible_mode = false; |
131 packet.codecSpecificHeader.codecHeader.VP9.picture_id = pid % (1 << 15); | 131 packet.video_header.codecHeader.VP9.picture_id = pid % (1 << 15); |
132 packet.codecSpecificHeader.codecHeader.VP9.temporal_idx = tid; | 132 packet.video_header.codecHeader.VP9.temporal_idx = tid; |
133 packet.codecSpecificHeader.codecHeader.VP9.spatial_idx = sid; | 133 packet.video_header.codecHeader.VP9.spatial_idx = sid; |
134 packet.codecSpecificHeader.codecHeader.VP9.tl0_pic_idx = tl0; | 134 packet.video_header.codecHeader.VP9.tl0_pic_idx = tl0; |
135 packet.codecSpecificHeader.codecHeader.VP9.temporal_up_switch = up; | 135 packet.video_header.codecHeader.VP9.temporal_up_switch = up; |
136 if (ss != nullptr) { | 136 if (ss != nullptr) { |
137 packet.codecSpecificHeader.codecHeader.VP9.ss_data_available = true; | 137 packet.video_header.codecHeader.VP9.ss_data_available = true; |
138 packet.codecSpecificHeader.codecHeader.VP9.gof = *ss; | 138 packet.video_header.codecHeader.VP9.gof = *ss; |
139 } | 139 } |
140 | 140 |
141 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); | 141 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); |
142 } | 142 } |
143 | 143 |
144 // Insert a Vp9 packet into the packet buffer. | 144 // Insert a Vp9 packet into the packet buffer. |
145 void InsertVp9Flex(uint16_t seq_num, // packet sequence number | 145 void InsertVp9Flex(uint16_t seq_num, // packet sequence number |
146 bool keyframe, // is keyframe | 146 bool keyframe, // is keyframe |
147 bool first, // is first packet of frame | 147 bool first, // is first packet of frame |
148 bool last, // is last packet of frame | 148 bool last, // is last packet of frame |
149 bool inter, // depends on S-1 layer | 149 bool inter, // depends on S-1 layer |
150 int32_t pid = kNoPictureId, // picture id | 150 int32_t pid = kNoPictureId, // picture id |
151 uint8_t sid = kNoSpatialIdx, // spatial id | 151 uint8_t sid = kNoSpatialIdx, // spatial id |
152 uint8_t tid = kNoTemporalIdx, // temporal id | 152 uint8_t tid = kNoTemporalIdx, // temporal id |
153 int32_t tl0 = kNoTl0PicIdx, // tl0 pic index | 153 int32_t tl0 = kNoTl0PicIdx, // tl0 pic index |
154 std::vector<uint8_t> refs = | 154 std::vector<uint8_t> refs = |
155 std::vector<uint8_t>(), // frame references | 155 std::vector<uint8_t>(), // frame references |
156 size_t data_size = 0, // size of data | 156 size_t data_size = 0, // size of data |
157 uint8_t* data = nullptr) { // data pointer | 157 uint8_t* data = nullptr) { // data pointer |
158 VCMPacket packet; | 158 VCMPacket packet; |
159 packet.codec = kVideoCodecVP9; | 159 packet.codec = kVideoCodecVP9; |
160 packet.seqNum = seq_num; | 160 packet.seqNum = seq_num; |
161 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; | 161 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; |
162 packet.isFirstPacket = first; | 162 packet.isFirstPacket = first; |
163 packet.markerBit = last; | 163 packet.markerBit = last; |
164 packet.sizeBytes = data_size; | 164 packet.sizeBytes = data_size; |
165 packet.dataPtr = data; | 165 packet.dataPtr = data; |
166 packet.codecSpecificHeader.codecHeader.VP9.inter_layer_predicted = inter; | 166 packet.video_header.codecHeader.VP9.inter_layer_predicted = inter; |
167 packet.codecSpecificHeader.codecHeader.VP9.flexible_mode = true; | 167 packet.video_header.codecHeader.VP9.flexible_mode = true; |
168 packet.codecSpecificHeader.codecHeader.VP9.picture_id = pid % (1 << 15); | 168 packet.video_header.codecHeader.VP9.picture_id = pid % (1 << 15); |
169 packet.codecSpecificHeader.codecHeader.VP9.temporal_idx = tid; | 169 packet.video_header.codecHeader.VP9.temporal_idx = tid; |
170 packet.codecSpecificHeader.codecHeader.VP9.spatial_idx = sid; | 170 packet.video_header.codecHeader.VP9.spatial_idx = sid; |
171 packet.codecSpecificHeader.codecHeader.VP9.tl0_pic_idx = tl0; | 171 packet.video_header.codecHeader.VP9.tl0_pic_idx = tl0; |
172 packet.codecSpecificHeader.codecHeader.VP9.num_ref_pics = refs.size(); | 172 packet.video_header.codecHeader.VP9.num_ref_pics = refs.size(); |
173 for (size_t i = 0; i < refs.size(); ++i) | 173 for (size_t i = 0; i < refs.size(); ++i) |
174 packet.codecSpecificHeader.codecHeader.VP9.pid_diff[i] = refs[i]; | 174 packet.video_header.codecHeader.VP9.pid_diff[i] = refs[i]; |
175 | 175 |
176 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); | 176 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); |
177 } | 177 } |
178 | 178 |
179 // Check if a frame with picture id |pid| and spatial index |sidx| has been | 179 // Check if a frame with picture id |pid| and spatial index |sidx| has been |
180 // delivered from the packet buffer, and if so, if it has the references | 180 // delivered from the packet buffer, and if so, if it has the references |
181 // specified by |refs|. | 181 // specified by |refs|. |
182 template <typename... T> | 182 template <typename... T> |
183 void CheckReferences(uint16_t pid, uint16_t sidx, T... refs) const { | 183 void CheckReferences(uint16_t pid, uint16_t sidx, T... refs) const { |
184 auto frame_it = frames_from_callback_.find(std::make_pair(pid, sidx)); | 184 auto frame_it = frames_from_callback_.find(std::make_pair(pid, sidx)); |
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1448 CheckReferencesVp9(pid + 5, 1, pid + 4); | 1448 CheckReferencesVp9(pid + 5, 1, pid + 4); |
1449 CheckReferencesVp9(pid + 6, 0, pid + 4); | 1449 CheckReferencesVp9(pid + 6, 0, pid + 4); |
1450 CheckReferencesVp9(pid + 6, 1, pid + 5); | 1450 CheckReferencesVp9(pid + 6, 1, pid + 5); |
1451 CheckReferencesVp9(pid + 7, 1, pid + 6); | 1451 CheckReferencesVp9(pid + 7, 1, pid + 6); |
1452 CheckReferencesVp9(pid + 8, 0, pid + 6); | 1452 CheckReferencesVp9(pid + 8, 0, pid + 6); |
1453 CheckReferencesVp9(pid + 8, 1, pid + 7); | 1453 CheckReferencesVp9(pid + 8, 1, pid + 7); |
1454 } | 1454 } |
1455 | 1455 |
1456 } // namespace video_coding | 1456 } // namespace video_coding |
1457 } // namespace webrtc | 1457 } // namespace webrtc |
OLD | NEW |