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

Side by Side Diff: webrtc/common_video/h264/h264_bitstream_parser.cc

Issue 2726833005: H264BitstreamParser: Log nalu type when parsing slice type fails. (Closed)
Patch Set: Change log. Created 3 years, 9 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 #include "webrtc/common_video/h264/h264_bitstream_parser.h" 10 #include "webrtc/common_video/h264/h264_bitstream_parser.h"
11 11
12 #include <memory> 12 #include <memory>
13 #include <vector> 13 #include <vector>
14 14
15 #include "webrtc/base/bitbuffer.h" 15 #include "webrtc/base/bitbuffer.h"
16 #include "webrtc/base/bytebuffer.h" 16 #include "webrtc/base/bytebuffer.h"
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 18
19 #include "webrtc/common_video/h264/h264_common.h" 19 #include "webrtc/common_video/h264/h264_common.h"
20 #include "webrtc/base/logging.h" 20 #include "webrtc/base/logging.h"
21 21
22 namespace { 22 namespace {
23 const int kMaxAbsQpDeltaValue = 51; 23 const int kMaxAbsQpDeltaValue = 51;
24 const int kMinQpValue = 0; 24 const int kMinQpValue = 0;
25 const int kMaxQpValue = 51; 25 const int kMaxQpValue = 51;
26 } 26 }
27 27
28 namespace webrtc { 28 namespace webrtc {
29 29
30 #define RETURN_ON_FAIL(x, res) \ 30 #define RETURN_ON_FAIL(x, res) \
31 if (!(x)) { \ 31 if (!(x)) { \
32 LOG_F(LS_ERROR) << "FAILED: " #x; \ 32 LOG_F(LS_WARNING) << "FAILED: " #x; \
33 return res; \ 33 return res; \
34 } 34 }
35 35
36 #define RETURN_INV_ON_FAIL(x) RETURN_ON_FAIL(x, kInvalidStream) 36 #define RETURN_INV_ON_FAIL(x) RETURN_ON_FAIL(x, kInvalidStream)
37 37
38 H264BitstreamParser::H264BitstreamParser() {} 38 H264BitstreamParser::H264BitstreamParser() {}
39 H264BitstreamParser::~H264BitstreamParser() {} 39 H264BitstreamParser::~H264BitstreamParser() {}
40 40
41 H264BitstreamParser::Result H264BitstreamParser::ParseNonParameterSetNalu( 41 H264BitstreamParser::Result H264BitstreamParser::ParseNonParameterSetNalu(
42 const uint8_t* source, 42 const uint8_t* source,
43 size_t source_length, 43 size_t source_length,
(...skipping 13 matching lines...) Expand all
57 // out. 57 // out.
58 bool is_idr = (source[0] & 0x0F) == H264::NaluType::kIdr; 58 bool is_idr = (source[0] & 0x0F) == H264::NaluType::kIdr;
59 uint8_t nal_ref_idc = (source[0] & 0x60) >> 5; 59 uint8_t nal_ref_idc = (source[0] & 0x60) >> 5;
60 uint32_t golomb_tmp; 60 uint32_t golomb_tmp;
61 uint32_t bits_tmp; 61 uint32_t bits_tmp;
62 62
63 // first_mb_in_slice: ue(v) 63 // first_mb_in_slice: ue(v)
64 RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp)); 64 RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp));
65 // slice_type: ue(v) 65 // slice_type: ue(v)
66 uint32_t slice_type; 66 uint32_t slice_type;
67 RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&slice_type)); 67 if (!slice_reader.ReadExponentialGolomb(&slice_type)) {
68 // This is a temporary logging to help diagnose the issue.
69 LOG_F(LS_WARNING) << "Failed to read slice type: " << nalu_type;
70 return kInvalidStream;
71 }
68 // slice_type's 5..9 range is used to indicate that all slices of a picture 72 // slice_type's 5..9 range is used to indicate that all slices of a picture
69 // have the same value of slice_type % 5, we don't care about that, so we map 73 // have the same value of slice_type % 5, we don't care about that, so we map
70 // to the corresponding 0..4 range. 74 // to the corresponding 0..4 range.
71 slice_type %= 5; 75 slice_type %= 5;
72 // pic_parameter_set_id: ue(v) 76 // pic_parameter_set_id: ue(v)
73 RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp)); 77 RETURN_INV_ON_FAIL(slice_reader.ReadExponentialGolomb(&golomb_tmp));
74 if (sps_->separate_colour_plane_flag == 1) { 78 if (sps_->separate_colour_plane_flag == 1) {
75 // colour_plane_id 79 // colour_plane_id
76 RETURN_INV_ON_FAIL(slice_reader.ReadBits(&bits_tmp, 2)); 80 RETURN_INV_ON_FAIL(slice_reader.ReadBits(&bits_tmp, 2));
77 } 81 }
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 const int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_; 310 const int parsed_qp = 26 + pps_->pic_init_qp_minus26 + *last_slice_qp_delta_;
307 if (parsed_qp < kMinQpValue || parsed_qp > kMaxQpValue) { 311 if (parsed_qp < kMinQpValue || parsed_qp > kMaxQpValue) {
308 LOG(LS_ERROR) << "Parsed invalid QP from bitstream."; 312 LOG(LS_ERROR) << "Parsed invalid QP from bitstream.";
309 return false; 313 return false;
310 } 314 }
311 *qp = parsed_qp; 315 *qp = parsed_qp;
312 return true; 316 return true;
313 } 317 }
314 318
315 } // namespace webrtc 319 } // namespace webrtc
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