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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 } | 244 } |
245 if (pps_->entropy_coding_mode_flag && | 245 if (pps_->entropy_coding_mode_flag && |
246 slice_type != H264::SliceType::kI && slice_type != H264::SliceType::kSi) { | 246 slice_type != H264::SliceType::kI && slice_type != H264::SliceType::kSi) { |
247 // cabac_init_idc: ue(v) | 247 // cabac_init_idc: ue(v) |
248 RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp)); | 248 RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp)); |
249 } | 249 } |
250 | 250 |
251 int32_t last_slice_qp_delta; | 251 int32_t last_slice_qp_delta; |
252 RETURN_INV_ON_FAIL( | 252 RETURN_INV_ON_FAIL( |
253 slice_reader.ReadSignedExponentialGolomb(&last_slice_qp_delta)); | 253 slice_reader.ReadSignedExponentialGolomb(&last_slice_qp_delta)); |
254 if (last_slice_qp_delta > 52 || last_slice_qp_delta < -52) { | |
magjed_webrtc
2016/11/28 16:41:32
Is the constant 52 specified by the spec? We shoul
pbos-webrtc
2016/11/28 17:15:45
I think you should also add range checking in GetL
kthelgason
2016/11/29 10:27:12
Yes, and done.
kthelgason
2016/11/29 10:27:12
Yes, and done.
| |
255 // Something has gone wrong, and the parsed value is invalid. | |
256 LOG(LS_WARNING) << "Parsed QP value out of range."; | |
257 return kInvalidStream; | |
258 } | |
259 | |
254 last_slice_qp_delta_ = rtc::Optional<int32_t>(last_slice_qp_delta); | 260 last_slice_qp_delta_ = rtc::Optional<int32_t>(last_slice_qp_delta); |
255 return kOk; | 261 return kOk; |
256 } | 262 } |
257 | 263 |
258 void H264BitstreamParser::ParseSlice(const uint8_t* slice, size_t length) { | 264 void H264BitstreamParser::ParseSlice(const uint8_t* slice, size_t length) { |
259 H264::NaluType nalu_type = H264::ParseNaluType(slice[0]); | 265 H264::NaluType nalu_type = H264::ParseNaluType(slice[0]); |
260 switch (nalu_type) { | 266 switch (nalu_type) { |
261 case H264::NaluType::kSps: { | 267 case H264::NaluType::kSps: { |
262 sps_ = SpsParser::ParseSps(slice + H264::kNaluTypeSize, | 268 sps_ = SpsParser::ParseSps(slice + H264::kNaluTypeSize, |
263 length - H264::kNaluTypeSize); | 269 length - H264::kNaluTypeSize); |
(...skipping 25 matching lines...) Expand all Loading... | |
289 } | 295 } |
290 | 296 |
291 bool H264BitstreamParser::GetLastSliceQp(int* qp) const { | 297 bool H264BitstreamParser::GetLastSliceQp(int* qp) const { |
292 if (!last_slice_qp_delta_ || !pps_) | 298 if (!last_slice_qp_delta_ || !pps_) |
293 return false; | 299 return false; |
294 *qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_; | 300 *qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_; |
295 return true; | 301 return true; |
296 } | 302 } |
297 | 303 |
298 } // namespace webrtc | 304 } // namespace webrtc |
OLD | NEW |