OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // P,F: | P_DIFF |N| up to 3 times has to be specified. | 239 // P,F: | P_DIFF |N| up to 3 times has to be specified. |
240 // +-+-+-+-+-+-+-+-+ N=1: An additional P_DIFF follows | 240 // +-+-+-+-+-+-+-+-+ N=1: An additional P_DIFF follows |
241 // current P_DIFF. | 241 // current P_DIFF. |
242 // | 242 // |
243 bool WriteRefIndices(const RTPVideoHeaderVP9& vp9, | 243 bool WriteRefIndices(const RTPVideoHeaderVP9& vp9, |
244 rtc::BitBufferWriter* writer) { | 244 rtc::BitBufferWriter* writer) { |
245 if (!PictureIdPresent(vp9) || | 245 if (!PictureIdPresent(vp9) || |
246 vp9.num_ref_pics == 0 || vp9.num_ref_pics > kMaxVp9RefPics) { | 246 vp9.num_ref_pics == 0 || vp9.num_ref_pics > kMaxVp9RefPics) { |
247 return false; | 247 return false; |
248 } | 248 } |
249 for (size_t i = 0; i < vp9.num_ref_pics; ++i) { | 249 for (uint8_t i = 0; i < vp9.num_ref_pics; ++i) { |
250 bool n_bit = !(i == vp9.num_ref_pics - 1); | 250 bool n_bit = !(i == vp9.num_ref_pics - 1); |
251 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.pid_diff[i], 7)); | 251 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.pid_diff[i], 7)); |
252 RETURN_FALSE_ON_ERROR(writer->WriteBits(n_bit ? 1 : 0, 1)); | 252 RETURN_FALSE_ON_ERROR(writer->WriteBits(n_bit ? 1 : 0, 1)); |
253 } | 253 } |
254 return true; | 254 return true; |
255 } | 255 } |
256 | 256 |
257 // Scalability structure (SS). | 257 // Scalability structure (SS). |
258 // | 258 // |
259 // +-+-+-+-+-+-+-+-+ | 259 // +-+-+-+-+-+-+-+-+ |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 } | 294 } |
295 if (g_bit) { | 295 if (g_bit) { |
296 RETURN_FALSE_ON_ERROR(writer->WriteUInt8(vp9.gof.num_frames_in_gof)); | 296 RETURN_FALSE_ON_ERROR(writer->WriteUInt8(vp9.gof.num_frames_in_gof)); |
297 } | 297 } |
298 for (size_t i = 0; i < vp9.gof.num_frames_in_gof; ++i) { | 298 for (size_t i = 0; i < vp9.gof.num_frames_in_gof; ++i) { |
299 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.gof.temporal_idx[i], 3)); | 299 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.gof.temporal_idx[i], 3)); |
300 RETURN_FALSE_ON_ERROR( | 300 RETURN_FALSE_ON_ERROR( |
301 writer->WriteBits(vp9.gof.temporal_up_switch[i] ? 1 : 0, 1)); | 301 writer->WriteBits(vp9.gof.temporal_up_switch[i] ? 1 : 0, 1)); |
302 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.gof.num_ref_pics[i], 2)); | 302 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.gof.num_ref_pics[i], 2)); |
303 RETURN_FALSE_ON_ERROR(writer->WriteBits(kReservedBitValue0, 2)); | 303 RETURN_FALSE_ON_ERROR(writer->WriteBits(kReservedBitValue0, 2)); |
304 for (size_t r = 0; r < vp9.gof.num_ref_pics[i]; ++r) { | 304 for (uint8_t r = 0; r < vp9.gof.num_ref_pics[i]; ++r) { |
305 RETURN_FALSE_ON_ERROR(writer->WriteUInt8(vp9.gof.pid_diff[i][r])); | 305 RETURN_FALSE_ON_ERROR(writer->WriteUInt8(vp9.gof.pid_diff[i][r])); |
306 } | 306 } |
307 } | 307 } |
308 return true; | 308 return true; |
309 } | 309 } |
310 | 310 |
311 // Picture ID: | 311 // Picture ID: |
312 // | 312 // |
313 // +-+-+-+-+-+-+-+-+ | 313 // +-+-+-+-+-+-+-+-+ |
314 // I: |M| PICTURE ID | M:0 => picture id is 7 bits. | 314 // I: |M| PICTURE ID | M:0 => picture id is 7 bits. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 for (size_t i = 0; i < vp9->gof.num_frames_in_gof; ++i) { | 459 for (size_t i = 0; i < vp9->gof.num_frames_in_gof; ++i) { |
460 uint32_t t, u_bit, r; | 460 uint32_t t, u_bit, r; |
461 RETURN_FALSE_ON_ERROR(parser->ReadBits(&t, 3)); | 461 RETURN_FALSE_ON_ERROR(parser->ReadBits(&t, 3)); |
462 RETURN_FALSE_ON_ERROR(parser->ReadBits(&u_bit, 1)); | 462 RETURN_FALSE_ON_ERROR(parser->ReadBits(&u_bit, 1)); |
463 RETURN_FALSE_ON_ERROR(parser->ReadBits(&r, 2)); | 463 RETURN_FALSE_ON_ERROR(parser->ReadBits(&r, 2)); |
464 RETURN_FALSE_ON_ERROR(parser->ConsumeBits(2)); | 464 RETURN_FALSE_ON_ERROR(parser->ConsumeBits(2)); |
465 vp9->gof.temporal_idx[i] = t; | 465 vp9->gof.temporal_idx[i] = t; |
466 vp9->gof.temporal_up_switch[i] = u_bit ? true : false; | 466 vp9->gof.temporal_up_switch[i] = u_bit ? true : false; |
467 vp9->gof.num_ref_pics[i] = r; | 467 vp9->gof.num_ref_pics[i] = r; |
468 | 468 |
469 for (size_t p = 0; p < vp9->gof.num_ref_pics[i]; ++p) { | 469 for (uint8_t p = 0; p < vp9->gof.num_ref_pics[i]; ++p) { |
470 uint8_t p_diff; | 470 uint8_t p_diff; |
471 RETURN_FALSE_ON_ERROR(parser->ReadUInt8(&p_diff)); | 471 RETURN_FALSE_ON_ERROR(parser->ReadUInt8(&p_diff)); |
472 vp9->gof.pid_diff[i][p] = p_diff; | 472 vp9->gof.pid_diff[i][p] = p_diff; |
473 } | 473 } |
474 } | 474 } |
475 return true; | 475 return true; |
476 } | 476 } |
477 | 477 |
478 // Gets the size of next payload chunk to send. Returns 0 on error. | 478 // Gets the size of next payload chunk to send. Returns 0 on error. |
479 size_t CalcNextSize(size_t max_length, size_t rem_bytes) { | 479 size_t CalcNextSize(size_t max_length, size_t rem_bytes) { |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 if (parsed_payload->payload_length == 0) { | 746 if (parsed_payload->payload_length == 0) { |
747 LOG(LS_ERROR) << "Failed parsing VP9 payload data."; | 747 LOG(LS_ERROR) << "Failed parsing VP9 payload data."; |
748 return false; | 748 return false; |
749 } | 749 } |
750 parsed_payload->payload = | 750 parsed_payload->payload = |
751 payload + payload_length - parsed_payload->payload_length; | 751 payload + payload_length - parsed_payload->payload_length; |
752 | 752 |
753 return true; | 753 return true; |
754 } | 754 } |
755 } // namespace webrtc | 755 } // namespace webrtc |
OLD | NEW |