| File: | root/firefox-clang/obj-x86_64-pc-linux-gnu/third_party/libwebrtc/modules/video_coding/svc/scalability_structures_gn/./../../../../../../../third_party/libwebrtc/modules/video_coding/svc/create_scalability_structure.cc |
| Warning: | line 26, column 8 Excessive padding in 'struct webrtc::(anonymous namespace)::NamedStructureFactory' (11 padding bytes, where 3 is optimal). Optimal fields order: factory, config, name, consider reordering the fields or adding explicit padding members |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* |
| 2 | * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | #include "modules/video_coding/svc/create_scalability_structure.h" |
| 11 | |
| 12 | #include <memory> |
| 13 | #include <optional> |
| 14 | |
| 15 | #include "api/video_codecs/scalability_mode.h" |
| 16 | #include "modules/video_coding/svc/scalability_structure_full_svc.h" |
| 17 | #include "modules/video_coding/svc/scalability_structure_key_svc.h" |
| 18 | #include "modules/video_coding/svc/scalability_structure_l2t2_key_shift.h" |
| 19 | #include "modules/video_coding/svc/scalability_structure_simulcast.h" |
| 20 | #include "modules/video_coding/svc/scalable_video_controller.h" |
| 21 | #include "modules/video_coding/svc/scalable_video_controller_no_layering.h" |
| 22 | |
| 23 | namespace webrtc { |
| 24 | namespace { |
| 25 | |
| 26 | struct NamedStructureFactory { |
Excessive padding in 'struct webrtc::(anonymous namespace)::NamedStructureFactory' (11 padding bytes, where 3 is optimal). Optimal fields order: factory, config, name, consider reordering the fields or adding explicit padding members | |
| 27 | ScalabilityMode name; |
| 28 | // Use function pointer to make NamedStructureFactory trivally destructable. |
| 29 | std::unique_ptr<ScalableVideoController> (*factory)(); |
| 30 | ScalableVideoController::StreamLayersConfig config; |
| 31 | }; |
| 32 | |
| 33 | // Wrap std::make_unique function to have correct return type. |
| 34 | template <typename T> |
| 35 | std::unique_ptr<ScalableVideoController> Create() { |
| 36 | return std::make_unique<T>(); |
| 37 | } |
| 38 | |
| 39 | template <typename T> |
| 40 | std::unique_ptr<ScalableVideoController> CreateH() { |
| 41 | // 1.5:1 scaling, see https://w3c.github.io/webrtc-svc/#scalabilitymodes* |
| 42 | typename T::ScalingFactor factor; |
| 43 | factor.num = 2; |
| 44 | factor.den = 3; |
| 45 | return std::make_unique<T>(factor); |
| 46 | } |
| 47 | |
| 48 | constexpr ScalableVideoController::StreamLayersConfig kConfigL1T1 = { |
| 49 | .num_spatial_layers = 1, |
| 50 | .num_temporal_layers = 1, |
| 51 | .uses_reference_scaling = false}; |
| 52 | |
| 53 | constexpr ScalableVideoController::StreamLayersConfig kConfigL1T2 = { |
| 54 | .num_spatial_layers = 1, |
| 55 | .num_temporal_layers = 2, |
| 56 | .uses_reference_scaling = false}; |
| 57 | |
| 58 | constexpr ScalableVideoController::StreamLayersConfig kConfigL1T3 = { |
| 59 | .num_spatial_layers = 1, |
| 60 | .num_temporal_layers = 3, |
| 61 | .uses_reference_scaling = false}; |
| 62 | |
| 63 | constexpr ScalableVideoController::StreamLayersConfig kConfigL2T1 = { |
| 64 | .num_spatial_layers = 2, |
| 65 | .num_temporal_layers = 1, |
| 66 | .uses_reference_scaling = true, |
| 67 | .scaling_factor_num = {1, 1}, |
| 68 | .scaling_factor_den = {2, 1}}; |
| 69 | |
| 70 | constexpr ScalableVideoController::StreamLayersConfig kConfigL2T1h = { |
| 71 | .num_spatial_layers = 2, |
| 72 | .num_temporal_layers = 1, |
| 73 | .uses_reference_scaling = true, |
| 74 | .scaling_factor_num = {2, 1}, |
| 75 | .scaling_factor_den = {3, 1}}; |
| 76 | |
| 77 | constexpr ScalableVideoController::StreamLayersConfig kConfigL2T2 = { |
| 78 | .num_spatial_layers = 2, |
| 79 | .num_temporal_layers = 2, |
| 80 | .uses_reference_scaling = true, |
| 81 | .scaling_factor_num = {1, 1}, |
| 82 | .scaling_factor_den = {2, 1}}; |
| 83 | |
| 84 | constexpr ScalableVideoController::StreamLayersConfig kConfigL2T2h = { |
| 85 | .num_spatial_layers = 2, |
| 86 | .num_temporal_layers = 2, |
| 87 | .uses_reference_scaling = true, |
| 88 | .scaling_factor_num = {2, 1}, |
| 89 | .scaling_factor_den = {3, 1}}; |
| 90 | |
| 91 | constexpr ScalableVideoController::StreamLayersConfig kConfigL2T3 = { |
| 92 | .num_spatial_layers = 2, |
| 93 | .num_temporal_layers = 3, |
| 94 | .uses_reference_scaling = true, |
| 95 | .scaling_factor_num = {1, 1}, |
| 96 | .scaling_factor_den = {2, 1}}; |
| 97 | |
| 98 | constexpr ScalableVideoController::StreamLayersConfig kConfigL2T3h = { |
| 99 | .num_spatial_layers = 2, |
| 100 | .num_temporal_layers = 3, |
| 101 | .uses_reference_scaling = true, |
| 102 | .scaling_factor_num = {2, 1}, |
| 103 | .scaling_factor_den = {3, 1}}; |
| 104 | |
| 105 | constexpr ScalableVideoController::StreamLayersConfig kConfigL3T1 = { |
| 106 | .num_spatial_layers = 3, |
| 107 | .num_temporal_layers = 1, |
| 108 | .uses_reference_scaling = true, |
| 109 | .scaling_factor_num = {1, 1, 1}, |
| 110 | .scaling_factor_den = {4, 2, 1}}; |
| 111 | |
| 112 | constexpr ScalableVideoController::StreamLayersConfig kConfigL3T1h = { |
| 113 | .num_spatial_layers = 3, |
| 114 | .num_temporal_layers = 1, |
| 115 | .uses_reference_scaling = true, |
| 116 | .scaling_factor_num = {4, 2, 1}, |
| 117 | .scaling_factor_den = {9, 3, 1}}; |
| 118 | |
| 119 | constexpr ScalableVideoController::StreamLayersConfig kConfigL3T2 = { |
| 120 | .num_spatial_layers = 3, |
| 121 | .num_temporal_layers = 2, |
| 122 | .uses_reference_scaling = true, |
| 123 | .scaling_factor_num = {1, 1, 1}, |
| 124 | .scaling_factor_den = {4, 2, 1}}; |
| 125 | |
| 126 | constexpr ScalableVideoController::StreamLayersConfig kConfigL3T2h = { |
| 127 | .num_spatial_layers = 3, |
| 128 | .num_temporal_layers = 2, |
| 129 | .uses_reference_scaling = true, |
| 130 | .scaling_factor_num = {4, 2, 1}, |
| 131 | .scaling_factor_den = {9, 3, 1}}; |
| 132 | |
| 133 | constexpr ScalableVideoController::StreamLayersConfig kConfigL3T3 = { |
| 134 | .num_spatial_layers = 3, |
| 135 | .num_temporal_layers = 3, |
| 136 | .uses_reference_scaling = true, |
| 137 | .scaling_factor_num = {1, 1, 1}, |
| 138 | .scaling_factor_den = {4, 2, 1}}; |
| 139 | |
| 140 | constexpr ScalableVideoController::StreamLayersConfig kConfigL3T3h = { |
| 141 | .num_spatial_layers = 3, |
| 142 | .num_temporal_layers = 3, |
| 143 | .uses_reference_scaling = true, |
| 144 | .scaling_factor_num = {4, 2, 1}, |
| 145 | .scaling_factor_den = {9, 3, 1}}; |
| 146 | |
| 147 | constexpr ScalableVideoController::StreamLayersConfig kConfigS2T1 = { |
| 148 | .num_spatial_layers = 2, |
| 149 | .num_temporal_layers = 1, |
| 150 | .uses_reference_scaling = false, |
| 151 | .scaling_factor_num = {1, 1}, |
| 152 | .scaling_factor_den = {2, 1}}; |
| 153 | |
| 154 | constexpr ScalableVideoController::StreamLayersConfig kConfigS2T1h = { |
| 155 | .num_spatial_layers = 2, |
| 156 | .num_temporal_layers = 1, |
| 157 | .uses_reference_scaling = false, |
| 158 | .scaling_factor_num = {2, 1}, |
| 159 | .scaling_factor_den = {3, 1}}; |
| 160 | |
| 161 | constexpr ScalableVideoController::StreamLayersConfig kConfigS2T2 = { |
| 162 | .num_spatial_layers = 2, |
| 163 | .num_temporal_layers = 2, |
| 164 | .uses_reference_scaling = false, |
| 165 | .scaling_factor_num = {1, 1}, |
| 166 | .scaling_factor_den = {2, 1}}; |
| 167 | |
| 168 | constexpr ScalableVideoController::StreamLayersConfig kConfigS2T2h = { |
| 169 | .num_spatial_layers = 2, |
| 170 | .num_temporal_layers = 2, |
| 171 | .uses_reference_scaling = false, |
| 172 | .scaling_factor_num = {2, 1}, |
| 173 | .scaling_factor_den = {3, 1}}; |
| 174 | |
| 175 | constexpr ScalableVideoController::StreamLayersConfig kConfigS2T3 = { |
| 176 | .num_spatial_layers = 2, |
| 177 | .num_temporal_layers = 3, |
| 178 | .uses_reference_scaling = false, |
| 179 | .scaling_factor_num = {1, 1}, |
| 180 | .scaling_factor_den = {2, 1}}; |
| 181 | |
| 182 | constexpr ScalableVideoController::StreamLayersConfig kConfigS2T3h = { |
| 183 | .num_spatial_layers = 2, |
| 184 | .num_temporal_layers = 3, |
| 185 | .uses_reference_scaling = false, |
| 186 | .scaling_factor_num = {2, 1}, |
| 187 | .scaling_factor_den = {3, 1}}; |
| 188 | |
| 189 | constexpr ScalableVideoController::StreamLayersConfig kConfigS3T1 = { |
| 190 | .num_spatial_layers = 3, |
| 191 | .num_temporal_layers = 1, |
| 192 | .uses_reference_scaling = false, |
| 193 | .scaling_factor_num = {1, 1, 1}, |
| 194 | .scaling_factor_den = {4, 2, 1}}; |
| 195 | |
| 196 | constexpr ScalableVideoController::StreamLayersConfig kConfigS3T1h = { |
| 197 | .num_spatial_layers = 3, |
| 198 | .num_temporal_layers = 1, |
| 199 | .uses_reference_scaling = false, |
| 200 | .scaling_factor_num = {4, 2, 1}, |
| 201 | .scaling_factor_den = {9, 3, 1}}; |
| 202 | |
| 203 | constexpr ScalableVideoController::StreamLayersConfig kConfigS3T2 = { |
| 204 | .num_spatial_layers = 3, |
| 205 | .num_temporal_layers = 2, |
| 206 | .uses_reference_scaling = false, |
| 207 | .scaling_factor_num = {1, 1, 1}, |
| 208 | .scaling_factor_den = {4, 2, 1}}; |
| 209 | |
| 210 | constexpr ScalableVideoController::StreamLayersConfig kConfigS3T2h = { |
| 211 | .num_spatial_layers = 3, |
| 212 | .num_temporal_layers = 2, |
| 213 | .uses_reference_scaling = false, |
| 214 | .scaling_factor_num = {4, 2, 1}, |
| 215 | .scaling_factor_den = {9, 3, 1}}; |
| 216 | |
| 217 | constexpr ScalableVideoController::StreamLayersConfig kConfigS3T3 = { |
| 218 | .num_spatial_layers = 3, |
| 219 | .num_temporal_layers = 3, |
| 220 | .uses_reference_scaling = false, |
| 221 | .scaling_factor_num = {1, 1, 1}, |
| 222 | .scaling_factor_den = {4, 2, 1}}; |
| 223 | |
| 224 | constexpr ScalableVideoController::StreamLayersConfig kConfigS3T3h = { |
| 225 | .num_spatial_layers = 3, |
| 226 | .num_temporal_layers = 3, |
| 227 | .uses_reference_scaling = false, |
| 228 | .scaling_factor_num = {4, 2, 1}, |
| 229 | .scaling_factor_den = {9, 3, 1}}; |
| 230 | |
| 231 | constexpr NamedStructureFactory kFactories[] = { |
| 232 | {.name = ScalabilityMode::kL1T1, |
| 233 | .factory = Create<ScalableVideoControllerNoLayering>, |
| 234 | .config = kConfigL1T1}, |
| 235 | {.name = ScalabilityMode::kL1T2, |
| 236 | .factory = Create<ScalabilityStructureL1T2>, |
| 237 | .config = kConfigL1T2}, |
| 238 | {.name = ScalabilityMode::kL1T3, |
| 239 | .factory = Create<ScalabilityStructureL1T3>, |
| 240 | .config = kConfigL1T3}, |
| 241 | {.name = ScalabilityMode::kL2T1, |
| 242 | .factory = Create<ScalabilityStructureL2T1>, |
| 243 | .config = kConfigL2T1}, |
| 244 | {.name = ScalabilityMode::kL2T1h, |
| 245 | .factory = CreateH<ScalabilityStructureL2T1>, |
| 246 | .config = kConfigL2T1h}, |
| 247 | {.name = ScalabilityMode::kL2T1_KEY, |
| 248 | .factory = Create<ScalabilityStructureL2T1Key>, |
| 249 | .config = kConfigL2T1}, |
| 250 | {.name = ScalabilityMode::kL2T2, |
| 251 | .factory = Create<ScalabilityStructureL2T2>, |
| 252 | .config = kConfigL2T2}, |
| 253 | {.name = ScalabilityMode::kL2T2h, |
| 254 | .factory = CreateH<ScalabilityStructureL2T2>, |
| 255 | .config = kConfigL2T2h}, |
| 256 | {.name = ScalabilityMode::kL2T2_KEY, |
| 257 | .factory = Create<ScalabilityStructureL2T2Key>, |
| 258 | .config = kConfigL2T2}, |
| 259 | {.name = ScalabilityMode::kL2T2_KEY_SHIFT, |
| 260 | .factory = Create<ScalabilityStructureL2T2KeyShift>, |
| 261 | .config = kConfigL2T2}, |
| 262 | {.name = ScalabilityMode::kL2T3, |
| 263 | .factory = Create<ScalabilityStructureL2T3>, |
| 264 | .config = kConfigL2T3}, |
| 265 | {.name = ScalabilityMode::kL2T3h, |
| 266 | .factory = CreateH<ScalabilityStructureL2T3>, |
| 267 | .config = kConfigL2T3h}, |
| 268 | {.name = ScalabilityMode::kL2T3_KEY, |
| 269 | .factory = Create<ScalabilityStructureL2T3Key>, |
| 270 | .config = kConfigL2T3}, |
| 271 | {.name = ScalabilityMode::kL3T1, |
| 272 | .factory = Create<ScalabilityStructureL3T1>, |
| 273 | .config = kConfigL3T1}, |
| 274 | {.name = ScalabilityMode::kL3T1h, |
| 275 | .factory = CreateH<ScalabilityStructureL3T1>, |
| 276 | .config = kConfigL3T1h}, |
| 277 | {.name = ScalabilityMode::kL3T1_KEY, |
| 278 | .factory = Create<ScalabilityStructureL3T1Key>, |
| 279 | .config = kConfigL3T1}, |
| 280 | {.name = ScalabilityMode::kL3T2, |
| 281 | .factory = Create<ScalabilityStructureL3T2>, |
| 282 | .config = kConfigL3T2}, |
| 283 | {.name = ScalabilityMode::kL3T2h, |
| 284 | .factory = CreateH<ScalabilityStructureL3T2>, |
| 285 | .config = kConfigL3T2h}, |
| 286 | {.name = ScalabilityMode::kL3T2_KEY, |
| 287 | .factory = Create<ScalabilityStructureL3T2Key>, |
| 288 | .config = kConfigL3T2}, |
| 289 | {.name = ScalabilityMode::kL3T3, |
| 290 | .factory = Create<ScalabilityStructureL3T3>, |
| 291 | .config = kConfigL3T3}, |
| 292 | {.name = ScalabilityMode::kL3T3h, |
| 293 | .factory = CreateH<ScalabilityStructureL3T3>, |
| 294 | .config = kConfigL3T3h}, |
| 295 | {.name = ScalabilityMode::kL3T3_KEY, |
| 296 | .factory = Create<ScalabilityStructureL3T3Key>, |
| 297 | .config = kConfigL3T3}, |
| 298 | {.name = ScalabilityMode::kS2T1, |
| 299 | .factory = Create<ScalabilityStructureS2T1>, |
| 300 | .config = kConfigS2T1}, |
| 301 | {.name = ScalabilityMode::kS2T1h, |
| 302 | .factory = CreateH<ScalabilityStructureS2T1>, |
| 303 | .config = kConfigS2T1h}, |
| 304 | {.name = ScalabilityMode::kS2T2, |
| 305 | .factory = Create<ScalabilityStructureS2T2>, |
| 306 | .config = kConfigS2T2}, |
| 307 | {.name = ScalabilityMode::kS2T2h, |
| 308 | .factory = CreateH<ScalabilityStructureS2T2>, |
| 309 | .config = kConfigS2T2h}, |
| 310 | {.name = ScalabilityMode::kS2T3, |
| 311 | .factory = Create<ScalabilityStructureS2T3>, |
| 312 | .config = kConfigS2T3}, |
| 313 | {.name = ScalabilityMode::kS2T3h, |
| 314 | .factory = CreateH<ScalabilityStructureS2T3>, |
| 315 | .config = kConfigS2T3h}, |
| 316 | {.name = ScalabilityMode::kS3T1, |
| 317 | .factory = Create<ScalabilityStructureS3T1>, |
| 318 | .config = kConfigS3T1}, |
| 319 | {.name = ScalabilityMode::kS3T1h, |
| 320 | .factory = CreateH<ScalabilityStructureS3T1>, |
| 321 | .config = kConfigS3T1h}, |
| 322 | {.name = ScalabilityMode::kS3T2, |
| 323 | .factory = Create<ScalabilityStructureS3T2>, |
| 324 | .config = kConfigS3T2}, |
| 325 | {.name = ScalabilityMode::kS3T2h, |
| 326 | .factory = CreateH<ScalabilityStructureS3T2>, |
| 327 | .config = kConfigS3T2h}, |
| 328 | {.name = ScalabilityMode::kS3T3, |
| 329 | .factory = Create<ScalabilityStructureS3T3>, |
| 330 | .config = kConfigS3T3}, |
| 331 | {.name = ScalabilityMode::kS3T3h, |
| 332 | .factory = CreateH<ScalabilityStructureS3T3>, |
| 333 | .config = kConfigS3T3h}, |
| 334 | }; |
| 335 | |
| 336 | } // namespace |
| 337 | |
| 338 | std::unique_ptr<ScalableVideoController> CreateScalabilityStructure( |
| 339 | ScalabilityMode name) { |
| 340 | for (const auto& entry : kFactories) { |
| 341 | if (entry.name == name) { |
| 342 | return entry.factory(); |
| 343 | } |
| 344 | } |
| 345 | return nullptr; |
| 346 | } |
| 347 | |
| 348 | std::optional<ScalableVideoController::StreamLayersConfig> |
| 349 | ScalabilityStructureConfig(ScalabilityMode name) { |
| 350 | for (const auto& entry : kFactories) { |
| 351 | if (entry.name == name) { |
| 352 | return entry.config; |
| 353 | } |
| 354 | } |
| 355 | return std::nullopt; |
| 356 | } |
| 357 | |
| 358 | } // namespace webrtc |