| 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 #include "webrtc/common_video/h264/h264_bitstream_parser.h" | 10 #include "webrtc/common_video/h264/h264_bitstream_parser.h" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 LOG(LS_WARNING) << "Unable to parse SPS from H264 bitstream."; | 277 LOG(LS_WARNING) << "Unable to parse SPS from H264 bitstream."; |
| 278 break; | 278 break; |
| 279 } | 279 } |
| 280 case H264::NaluType::kPps: { | 280 case H264::NaluType::kPps: { |
| 281 pps_ = PpsParser::ParsePps(slice + H264::kNaluTypeSize, | 281 pps_ = PpsParser::ParsePps(slice + H264::kNaluTypeSize, |
| 282 length - H264::kNaluTypeSize); | 282 length - H264::kNaluTypeSize); |
| 283 if (!pps_) | 283 if (!pps_) |
| 284 LOG(LS_WARNING) << "Unable to parse PPS from H264 bitstream."; | 284 LOG(LS_WARNING) << "Unable to parse PPS from H264 bitstream."; |
| 285 break; | 285 break; |
| 286 } | 286 } |
| 287 case H264::NaluType::kAud: |
| 288 case H264::NaluType::kSei: |
| 289 break; // Ignore these nalus, as we don't care about their contents. |
| 287 default: | 290 default: |
| 288 Result res = ParseNonParameterSetNalu(slice, length, nalu_type); | 291 Result res = ParseNonParameterSetNalu(slice, length, nalu_type); |
| 289 if (res != kOk) | 292 if (res != kOk) |
| 290 LOG(LS_INFO) << "Failed to parse bitstream. Error: " << res; | 293 LOG(LS_INFO) << "Failed to parse bitstream. Error: " << res; |
| 291 break; | 294 break; |
| 292 } | 295 } |
| 293 } | 296 } |
| 294 | 297 |
| 295 void H264BitstreamParser::ParseBitstream(const uint8_t* bitstream, | 298 void H264BitstreamParser::ParseBitstream(const uint8_t* bitstream, |
| 296 size_t length) { | 299 size_t length) { |
| 297 std::vector<H264::NaluIndex> nalu_indices = | 300 std::vector<H264::NaluIndex> nalu_indices = |
| 298 H264::FindNaluIndices(bitstream, length); | 301 H264::FindNaluIndices(bitstream, length); |
| 299 for (const H264::NaluIndex& index : nalu_indices) | 302 for (const H264::NaluIndex& index : nalu_indices) |
| 300 ParseSlice(&bitstream[index.payload_start_offset], index.payload_size); | 303 ParseSlice(&bitstream[index.payload_start_offset], index.payload_size); |
| 301 } | 304 } |
| 302 | 305 |
| 303 bool H264BitstreamParser::GetLastSliceQp(int* qp) const { | 306 bool H264BitstreamParser::GetLastSliceQp(int* qp) const { |
| 304 if (!last_slice_qp_delta_ || !pps_) | 307 if (!last_slice_qp_delta_ || !pps_) |
| 305 return false; | 308 return false; |
| 306 const int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_; | 309 const int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_; |
| 307 if (parsed_qp < kMinQpValue || parsed_qp > kMaxQpValue) { | 310 if (parsed_qp < kMinQpValue || parsed_qp > kMaxQpValue) { |
| 308 LOG(LS_ERROR) << "Parsed invalid QP from bitstream."; | 311 LOG(LS_ERROR) << "Parsed invalid QP from bitstream."; |
| 309 return false; | 312 return false; |
| 310 } | 313 } |
| 311 *qp = parsed_qp; | 314 *qp = parsed_qp; |
| 312 return true; | 315 return true; |
| 313 } | 316 } |
| 314 | 317 |
| 315 } // namespace webrtc | 318 } // namespace webrtc |
| OLD | NEW |