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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_format_vp9.cc

Issue 1409753007: Reland of "Change type of pid_diff (int16_t -> uint8_t) according to updates in RTP payload profile… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: also update include/module_common_types.h Created 5 years, 1 month 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) 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // P,F: | P_DIFF |N| up to 3 times has to be specified. 232 // P,F: | P_DIFF |N| up to 3 times has to be specified.
233 // +-+-+-+-+-+-+-+-+ N=1: An additional P_DIFF follows 233 // +-+-+-+-+-+-+-+-+ N=1: An additional P_DIFF follows
234 // current P_DIFF. 234 // current P_DIFF.
235 // 235 //
236 bool WriteRefIndices(const RTPVideoHeaderVP9& vp9, 236 bool WriteRefIndices(const RTPVideoHeaderVP9& vp9,
237 rtc::BitBufferWriter* writer) { 237 rtc::BitBufferWriter* writer) {
238 if (!PictureIdPresent(vp9) || 238 if (!PictureIdPresent(vp9) ||
239 vp9.num_ref_pics == 0 || vp9.num_ref_pics > kMaxVp9RefPics) { 239 vp9.num_ref_pics == 0 || vp9.num_ref_pics > kMaxVp9RefPics) {
240 return false; 240 return false;
241 } 241 }
242 for (size_t i = 0; i < vp9.num_ref_pics; ++i) { 242 for (uint8_t i = 0; i < vp9.num_ref_pics; ++i) {
243 bool n_bit = !(i == vp9.num_ref_pics - 1); 243 bool n_bit = !(i == vp9.num_ref_pics - 1);
244 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.pid_diff[i], 7)); 244 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.pid_diff[i], 7));
245 RETURN_FALSE_ON_ERROR(writer->WriteBits(n_bit ? 1 : 0, 1)); 245 RETURN_FALSE_ON_ERROR(writer->WriteBits(n_bit ? 1 : 0, 1));
246 } 246 }
247 return true; 247 return true;
248 } 248 }
249 249
250 // Scalability structure (SS). 250 // Scalability structure (SS).
251 // 251 //
252 // +-+-+-+-+-+-+-+-+ 252 // +-+-+-+-+-+-+-+-+
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 287 }
288 if (g_bit) { 288 if (g_bit) {
289 RETURN_FALSE_ON_ERROR(writer->WriteUInt8(vp9.gof.num_frames_in_gof)); 289 RETURN_FALSE_ON_ERROR(writer->WriteUInt8(vp9.gof.num_frames_in_gof));
290 } 290 }
291 for (size_t i = 0; i < vp9.gof.num_frames_in_gof; ++i) { 291 for (size_t i = 0; i < vp9.gof.num_frames_in_gof; ++i) {
292 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.gof.temporal_idx[i], 3)); 292 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.gof.temporal_idx[i], 3));
293 RETURN_FALSE_ON_ERROR( 293 RETURN_FALSE_ON_ERROR(
294 writer->WriteBits(vp9.gof.temporal_up_switch[i] ? 1 : 0, 1)); 294 writer->WriteBits(vp9.gof.temporal_up_switch[i] ? 1 : 0, 1));
295 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.gof.num_ref_pics[i], 2)); 295 RETURN_FALSE_ON_ERROR(writer->WriteBits(vp9.gof.num_ref_pics[i], 2));
296 RETURN_FALSE_ON_ERROR(writer->WriteBits(kReservedBitValue0, 2)); 296 RETURN_FALSE_ON_ERROR(writer->WriteBits(kReservedBitValue0, 2));
297 for (size_t r = 0; r < vp9.gof.num_ref_pics[i]; ++r) { 297 for (uint8_t r = 0; r < vp9.gof.num_ref_pics[i]; ++r) {
298 RETURN_FALSE_ON_ERROR(writer->WriteUInt8(vp9.gof.pid_diff[i][r])); 298 RETURN_FALSE_ON_ERROR(writer->WriteUInt8(vp9.gof.pid_diff[i][r]));
299 } 299 }
300 } 300 }
301 return true; 301 return true;
302 } 302 }
303 303
304 // Picture ID: 304 // Picture ID:
305 // 305 //
306 // +-+-+-+-+-+-+-+-+ 306 // +-+-+-+-+-+-+-+-+
307 // I: |M| PICTURE ID | M:0 => picture id is 7 bits. 307 // I: |M| PICTURE ID | M:0 => picture id is 7 bits.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 for (size_t i = 0; i < vp9->gof.num_frames_in_gof; ++i) { 446 for (size_t i = 0; i < vp9->gof.num_frames_in_gof; ++i) {
447 uint32_t t, u_bit, r; 447 uint32_t t, u_bit, r;
448 RETURN_FALSE_ON_ERROR(parser->ReadBits(&t, 3)); 448 RETURN_FALSE_ON_ERROR(parser->ReadBits(&t, 3));
449 RETURN_FALSE_ON_ERROR(parser->ReadBits(&u_bit, 1)); 449 RETURN_FALSE_ON_ERROR(parser->ReadBits(&u_bit, 1));
450 RETURN_FALSE_ON_ERROR(parser->ReadBits(&r, 2)); 450 RETURN_FALSE_ON_ERROR(parser->ReadBits(&r, 2));
451 RETURN_FALSE_ON_ERROR(parser->ConsumeBits(2)); 451 RETURN_FALSE_ON_ERROR(parser->ConsumeBits(2));
452 vp9->gof.temporal_idx[i] = t; 452 vp9->gof.temporal_idx[i] = t;
453 vp9->gof.temporal_up_switch[i] = u_bit ? true : false; 453 vp9->gof.temporal_up_switch[i] = u_bit ? true : false;
454 vp9->gof.num_ref_pics[i] = r; 454 vp9->gof.num_ref_pics[i] = r;
455 455
456 for (size_t p = 0; p < vp9->gof.num_ref_pics[i]; ++p) { 456 for (uint8_t p = 0; p < vp9->gof.num_ref_pics[i]; ++p) {
457 uint8_t p_diff; 457 uint8_t p_diff;
458 RETURN_FALSE_ON_ERROR(parser->ReadUInt8(&p_diff)); 458 RETURN_FALSE_ON_ERROR(parser->ReadUInt8(&p_diff));
459 vp9->gof.pid_diff[i][p] = p_diff; 459 vp9->gof.pid_diff[i][p] = p_diff;
460 } 460 }
461 } 461 }
462 return true; 462 return true;
463 } 463 }
464 464
465 // Gets the size of next payload chunk to send. Returns 0 on error. 465 // Gets the size of next payload chunk to send. Returns 0 on error.
466 size_t CalcNextSize(size_t max_length, size_t rem_bytes) { 466 size_t CalcNextSize(size_t max_length, size_t rem_bytes) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 if (parsed_payload->payload_length == 0) { 733 if (parsed_payload->payload_length == 0) {
734 LOG(LS_ERROR) << "Failed parsing VP9 payload data."; 734 LOG(LS_ERROR) << "Failed parsing VP9 payload data.";
735 return false; 735 return false;
736 } 736 }
737 parsed_payload->payload = 737 parsed_payload->payload =
738 payload + payload_length - parsed_payload->payload_length; 738 payload + payload_length - parsed_payload->payload_length;
739 739
740 return true; 740 return true;
741 } 741 }
742 } // namespace webrtc 742 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/interface/module_common_types.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_format_vp9_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698