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

Side by Side Diff: webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.cc

Issue 2209143002: Skip AUD while extracting SPS and PPS on iOS. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 4 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 | no next file » | 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) 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 size_t annexb_buffer_size) { 248 size_t annexb_buffer_size) {
249 RTC_DCHECK(annexb_buffer); 249 RTC_DCHECK(annexb_buffer);
250 RTC_DCHECK_GT(annexb_buffer_size, 4u); 250 RTC_DCHECK_GT(annexb_buffer_size, 4u);
251 251
252 // The buffer we receive via RTP has 00 00 00 01 start code artifically 252 // The buffer we receive via RTP has 00 00 00 01 start code artifically
253 // embedded by the RTP depacketizer. Extract NALU information. 253 // embedded by the RTP depacketizer. Extract NALU information.
254 // TODO(tkchin): handle potential case where sps and pps are delivered 254 // TODO(tkchin): handle potential case where sps and pps are delivered
255 // separately. 255 // separately.
256 uint8_t first_nalu_type = annexb_buffer[4] & 0x1f; 256 uint8_t first_nalu_type = annexb_buffer[4] & 0x1f;
257 bool is_first_nalu_type_sps = first_nalu_type == 0x7; 257 bool is_first_nalu_type_sps = first_nalu_type == 0x7;
258 return is_first_nalu_type_sps; 258 if (is_first_nalu_type_sps)
259 return true;
260 bool is_first_nalu_type_delimiter = first_nalu_type == 0x9;
261 // start code + access unit delimiter + start code = 4 + 2 + 4 = 10
tkchin_webrtc 2016/08/04 16:49:05 nit: caps and period // Start code .... = 10. Here
jianjunz 2016/08/05 06:35:32 Done.
262 if (!is_first_nalu_type_delimiter || annexb_buffer_size <= 10u)
263 return false;
264 uint8_t second_nalu_type = annexb_buffer[10] & 0x1f;
265 bool is_second_nalu_type_sps = second_nalu_type == 0x7;
266 return is_second_nalu_type_sps;
259 } 267 }
260 268
261 CMVideoFormatDescriptionRef CreateVideoFormatDescription( 269 CMVideoFormatDescriptionRef CreateVideoFormatDescription(
262 const uint8_t* annexb_buffer, 270 const uint8_t* annexb_buffer,
263 size_t annexb_buffer_size) { 271 size_t annexb_buffer_size) {
264 if (!H264AnnexBBufferHasVideoFormatDescription(annexb_buffer, 272 if (!H264AnnexBBufferHasVideoFormatDescription(annexb_buffer,
265 annexb_buffer_size)) { 273 annexb_buffer_size)) {
266 return nullptr; 274 return nullptr;
267 } 275 }
268 AnnexBBufferReader reader(annexb_buffer, annexb_buffer_size); 276 AnnexBBufferReader reader(annexb_buffer, annexb_buffer_size);
269 CMVideoFormatDescriptionRef description = nullptr; 277 CMVideoFormatDescriptionRef description = nullptr;
270 OSStatus status = noErr; 278 OSStatus status = noErr;
271 // Parse the SPS and PPS into a CMVideoFormatDescription. 279 // Parse the SPS and PPS into a CMVideoFormatDescription.
272 const uint8_t* param_set_ptrs[2] = {}; 280 const uint8_t* param_set_ptrs[2] = {};
273 size_t param_set_sizes[2] = {}; 281 size_t param_set_sizes[2] = {};
282 // Skip AUD
283 if ((annexb_buffer[4] & 0x1f) == 0x9) {
tkchin_webrtc 2016/08/04 16:49:05 suggest having enum for types, and function that r
jianjunz 2016/08/05 06:35:32 Included "webrtc/common_video/h264/h264_common.h"
284 if (!reader.ReadNalu(&param_set_ptrs[0], &param_set_sizes[0])) {
285 LOG(LS_ERROR) << "Failed to read AUD";
286 return nullptr;
287 }
288 }
274 if (!reader.ReadNalu(&param_set_ptrs[0], &param_set_sizes[0])) { 289 if (!reader.ReadNalu(&param_set_ptrs[0], &param_set_sizes[0])) {
275 LOG(LS_ERROR) << "Failed to read SPS"; 290 LOG(LS_ERROR) << "Failed to read SPS";
276 return nullptr; 291 return nullptr;
277 } 292 }
278 if (!reader.ReadNalu(&param_set_ptrs[1], &param_set_sizes[1])) { 293 if (!reader.ReadNalu(&param_set_ptrs[1], &param_set_sizes[1])) {
279 LOG(LS_ERROR) << "Failed to read PPS"; 294 LOG(LS_ERROR) << "Failed to read PPS";
280 return nullptr; 295 return nullptr;
281 } 296 }
282 status = CMVideoFormatDescriptionCreateFromH264ParameterSets( 297 status = CMVideoFormatDescriptionCreateFromH264ParameterSets(
283 kCFAllocatorDefault, 2, param_set_ptrs, param_set_sizes, 4, 298 kCFAllocatorDefault, 2, param_set_ptrs, param_set_sizes, 4,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 return true; 382 return true;
368 } 383 }
369 384
370 size_t AvccBufferWriter::BytesRemaining() const { 385 size_t AvccBufferWriter::BytesRemaining() const {
371 return length_ - offset_; 386 return length_ - offset_;
372 } 387 }
373 388
374 } // namespace webrtc 389 } // namespace webrtc
375 390
376 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) 391 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698