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/profile_level_id.h" | 11 #include "webrtc/common_video/h264/profile_level_id.h" |
12 | 12 |
13 #include <cstdio> | |
13 #include <cstdlib> | 14 #include <cstdlib> |
14 #include <cstring> | 15 #include <cstring> |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 // For level_idc=11 and profile_idc=0x42, 0x4D, or 0x58, the constraint set3 | 19 // For level_idc=11 and profile_idc=0x42, 0x4D, or 0x58, the constraint set3 |
19 // flag specifies if level 1b or level 1.1 is used. | 20 // flag specifies if level 1b or level 1.1 is used. |
20 const uint8_t kConstraintSet3Flag = 0x10; | 21 const uint8_t kConstraintSet3Flag = 0x10; |
21 | 22 |
22 // Convert a string of 8 characters into a byte where the positions containing | 23 // Convert a string of 8 characters into a byte where the positions containing |
(...skipping 98 matching lines...) Loading... | |
121 if (profile_idc == pattern.profile_idc && | 122 if (profile_idc == pattern.profile_idc && |
122 pattern.profile_iop.IsMatch(profile_iop)) { | 123 pattern.profile_iop.IsMatch(profile_iop)) { |
123 return rtc::Optional<ProfileLevelId>({pattern.profile, level}); | 124 return rtc::Optional<ProfileLevelId>({pattern.profile, level}); |
124 } | 125 } |
125 } | 126 } |
126 | 127 |
127 // Unrecognized profile_idc/profile_iop combination. | 128 // Unrecognized profile_idc/profile_iop combination. |
128 return rtc::Optional<ProfileLevelId>(); | 129 return rtc::Optional<ProfileLevelId>(); |
129 } | 130 } |
130 | 131 |
132 std::string ProfileLevelIdToString(const ProfileLevelId& profile_level_id) { | |
133 // Handle special case level == 1b. | |
134 if (profile_level_id.level == kLevel1_b) { | |
135 switch (profile_level_id.profile) { | |
136 case kProfileConstrainedBaseline: | |
137 return "42f00b"; | |
138 case kProfileBaseline: | |
139 return "42100b"; | |
140 case kProfileMain: | |
141 return "4D100b"; | |
142 // Level 1b is not allowed for other profiles. | |
143 default: | |
144 return std::string(); | |
kthelgason
2016/11/03 09:39:05
Maybe we should return an rtc::Optional<std::strin
magjed_webrtc
2016/11/03 12:31:16
You are probably right. It's clearer than returnin
| |
145 } | |
146 } | |
147 | |
148 const char* profile_idc_iop_string; | |
149 switch (profile_level_id.profile) { | |
150 case kProfileConstrainedBaseline: | |
151 profile_idc_iop_string = "42e0"; | |
152 break; | |
153 case kProfileBaseline: | |
154 profile_idc_iop_string = "4200"; | |
155 break; | |
156 case kProfileMain: | |
157 profile_idc_iop_string = "4D00"; | |
158 break; | |
159 case kProfileConstrainedHigh: | |
160 profile_idc_iop_string = "640c"; | |
161 break; | |
162 case kProfileHigh: | |
163 profile_idc_iop_string = "6400"; | |
164 break; | |
165 // Unrecognized profile. | |
166 default: | |
167 return std::string(); | |
kthelgason
2016/11/03 09:39:05
perhaps replace this with a RTC_NOTREACHED() if we
magjed_webrtc
2016/11/03 12:31:16
If we handle some case, then we should not CHECK/N
| |
168 } | |
169 | |
170 char str[7]; | |
171 snprintf(str, 7u, "%s%02x", profile_idc_iop_string, profile_level_id.level); | |
172 return str; | |
173 } | |
174 | |
131 } // namespace H264 | 175 } // namespace H264 |
132 } // namespace webrtc | 176 } // namespace webrtc |
OLD | NEW |