OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include "webrtc/common_video/h264/sps_parser.h" | 11 #include "webrtc/common_video/h264/sps_parser.h" |
12 | 12 |
| 13 #include <memory> |
| 14 |
13 #include "webrtc/common_video/h264/h264_common.h" | 15 #include "webrtc/common_video/h264/h264_common.h" |
14 #include "webrtc/base/bitbuffer.h" | 16 #include "webrtc/base/bitbuffer.h" |
15 #include "webrtc/base/bytebuffer.h" | 17 #include "webrtc/base/bytebuffer.h" |
16 #include "webrtc/base/logging.h" | 18 #include "webrtc/base/logging.h" |
17 | 19 |
18 typedef rtc::Optional<webrtc::SpsParser::SpsState> OptionalSps; | 20 typedef rtc::Optional<webrtc::SpsParser::SpsState> OptionalSps; |
19 | 21 |
20 #define RETURN_EMPTY_ON_FAIL(x) \ | 22 #define RETURN_EMPTY_ON_FAIL(x) \ |
21 if (!(x)) { \ | 23 if (!(x)) { \ |
22 return OptionalSps(); \ | 24 return OptionalSps(); \ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // profile_idc: u(8). We need it to determine if we need to read/skip chroma | 63 // profile_idc: u(8). We need it to determine if we need to read/skip chroma |
62 // formats. | 64 // formats. |
63 uint8_t profile_idc; | 65 uint8_t profile_idc; |
64 RETURN_EMPTY_ON_FAIL(buffer->ReadUInt8(&profile_idc)); | 66 RETURN_EMPTY_ON_FAIL(buffer->ReadUInt8(&profile_idc)); |
65 // constraint_set0_flag through constraint_set5_flag + reserved_zero_2bits | 67 // constraint_set0_flag through constraint_set5_flag + reserved_zero_2bits |
66 // 1 bit each for the flags + 2 bits = 8 bits = 1 byte. | 68 // 1 bit each for the flags + 2 bits = 8 bits = 1 byte. |
67 RETURN_EMPTY_ON_FAIL(buffer->ConsumeBytes(1)); | 69 RETURN_EMPTY_ON_FAIL(buffer->ConsumeBytes(1)); |
68 // level_idc: u(8) | 70 // level_idc: u(8) |
69 RETURN_EMPTY_ON_FAIL(buffer->ConsumeBytes(1)); | 71 RETURN_EMPTY_ON_FAIL(buffer->ConsumeBytes(1)); |
70 // seq_parameter_set_id: ue(v) | 72 // seq_parameter_set_id: ue(v) |
71 RETURN_EMPTY_ON_FAIL(buffer->ReadExponentialGolomb(&golomb_ignored)); | 73 RETURN_EMPTY_ON_FAIL(buffer->ReadExponentialGolomb(&sps.id)); |
72 sps.separate_colour_plane_flag = 0; | 74 sps.separate_colour_plane_flag = 0; |
73 // See if profile_idc has chroma format information. | 75 // See if profile_idc has chroma format information. |
74 if (profile_idc == 100 || profile_idc == 110 || profile_idc == 122 || | 76 if (profile_idc == 100 || profile_idc == 110 || profile_idc == 122 || |
75 profile_idc == 244 || profile_idc == 44 || profile_idc == 83 || | 77 profile_idc == 244 || profile_idc == 44 || profile_idc == 83 || |
76 profile_idc == 86 || profile_idc == 118 || profile_idc == 128 || | 78 profile_idc == 86 || profile_idc == 118 || profile_idc == 128 || |
77 profile_idc == 138 || profile_idc == 139 || profile_idc == 134) { | 79 profile_idc == 138 || profile_idc == 139 || profile_idc == 134) { |
78 // chroma_format_idc: ue(v) | 80 // chroma_format_idc: ue(v) |
79 RETURN_EMPTY_ON_FAIL(buffer->ReadExponentialGolomb(&chroma_format_idc)); | 81 RETURN_EMPTY_ON_FAIL(buffer->ReadExponentialGolomb(&chroma_format_idc)); |
80 if (chroma_format_idc == 3) { | 82 if (chroma_format_idc == 3) { |
81 // separate_colour_plane_flag: u(1) | 83 // separate_colour_plane_flag: u(1) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 } | 212 } |
211 } | 213 } |
212 // Subtract the crop for each dimension. | 214 // Subtract the crop for each dimension. |
213 sps.width -= (frame_crop_left_offset + frame_crop_right_offset); | 215 sps.width -= (frame_crop_left_offset + frame_crop_right_offset); |
214 sps.height -= (frame_crop_top_offset + frame_crop_bottom_offset); | 216 sps.height -= (frame_crop_top_offset + frame_crop_bottom_offset); |
215 | 217 |
216 return OptionalSps(sps); | 218 return OptionalSps(sps); |
217 } | 219 } |
218 | 220 |
219 } // namespace webrtc | 221 } // namespace webrtc |
OLD | NEW |