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

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

Issue 2039353002: Fix issue with parsing of incorrect (empty) Stap-A H264 NAL units. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 396 }
397 h264_header->nalu_type = nal_type; 397 h264_header->nalu_type = nal_type;
398 parsed_payload->frame_type = kVideoFrameDelta; 398 parsed_payload->frame_type = kVideoFrameDelta;
399 399
400 nalu_start_offsets.push_back(length_ + kLengthFieldSize); // End offset. 400 nalu_start_offsets.push_back(length_ + kLengthFieldSize); // End offset.
401 for (size_t i = 0; i < nalu_start_offsets.size() - 1; ++i) { 401 for (size_t i = 0; i < nalu_start_offsets.size() - 1; ++i) {
402 size_t start_offset = nalu_start_offsets[i]; 402 size_t start_offset = nalu_start_offsets[i];
403 // End offset is actually start offset for next unit, excluding length field 403 // End offset is actually start offset for next unit, excluding length field
404 // so remove that from this units length. 404 // so remove that from this units length.
405 size_t end_offset = nalu_start_offsets[i + 1] - kLengthFieldSize; 405 size_t end_offset = nalu_start_offsets[i + 1] - kLengthFieldSize;
406 if (end_offset - start_offset < H264::kNaluTypeSize) {
407 LOG(LS_ERROR) << "STAP-A packet too short";
408 return false;
409 }
410
406 nal_type = payload_data[start_offset] & kTypeMask; 411 nal_type = payload_data[start_offset] & kTypeMask;
407 start_offset += H264::kNaluTypeSize; 412 start_offset += H264::kNaluTypeSize;
408 413
409 if (nal_type == H264::NaluType::kSps) { 414 if (nal_type == H264::NaluType::kSps) {
410 // Check if VUI is present in SPS and if it needs to be modified to avoid 415 // Check if VUI is present in SPS and if it needs to be modified to avoid
411 // excessive decoder latency. 416 // excessive decoder latency.
412 417
413 // Copy any previous data first (likely just the first header). 418 // Copy any previous data first (likely just the first header).
414 std::unique_ptr<rtc::Buffer> output_buffer(new rtc::Buffer()); 419 std::unique_ptr<rtc::Buffer> output_buffer(new rtc::Buffer());
415 if (start_offset) 420 if (start_offset)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 parsed_payload->type.Video.codec = kRtpVideoH264; 522 parsed_payload->type.Video.codec = kRtpVideoH264;
518 parsed_payload->type.Video.isFirstPacket = first_fragment; 523 parsed_payload->type.Video.isFirstPacket = first_fragment;
519 RTPVideoHeaderH264* h264_header = 524 RTPVideoHeaderH264* h264_header =
520 &parsed_payload->type.Video.codecHeader.H264; 525 &parsed_payload->type.Video.codecHeader.H264;
521 h264_header->packetization_type = kH264FuA; 526 h264_header->packetization_type = kH264FuA;
522 h264_header->nalu_type = original_nal_type; 527 h264_header->nalu_type = original_nal_type;
523 return true; 528 return true;
524 } 529 }
525 530
526 } // namespace webrtc 531 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_format_h264_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698