• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/codecs/av1/create_scalability_structure.h"
11 
12 #include <memory>
13 
14 #include "absl/strings/string_view.h"
15 #include "modules/video_coding/codecs/av1/scalability_structure_l1t2.h"
16 #include "modules/video_coding/codecs/av1/scalability_structure_l1t3.h"
17 #include "modules/video_coding/codecs/av1/scalability_structure_l2t1.h"
18 #include "modules/video_coding/codecs/av1/scalability_structure_l2t1_key.h"
19 #include "modules/video_coding/codecs/av1/scalability_structure_l2t1h.h"
20 #include "modules/video_coding/codecs/av1/scalability_structure_l2t2.h"
21 #include "modules/video_coding/codecs/av1/scalability_structure_l2t2_key.h"
22 #include "modules/video_coding/codecs/av1/scalability_structure_l2t2_key_shift.h"
23 #include "modules/video_coding/codecs/av1/scalability_structure_l3t1.h"
24 #include "modules/video_coding/codecs/av1/scalability_structure_l3t3.h"
25 #include "modules/video_coding/codecs/av1/scalability_structure_s2t1.h"
26 #include "modules/video_coding/codecs/av1/scalable_video_controller.h"
27 #include "modules/video_coding/codecs/av1/scalable_video_controller_no_layering.h"
28 #include "rtc_base/checks.h"
29 
30 namespace webrtc {
31 namespace {
32 
33 struct NamedStructureFactory {
34   absl::string_view name;
35   // Use function pointer to make NamedStructureFactory trivally destructable.
36   std::unique_ptr<ScalableVideoController> (*factory)();
37 };
38 
39 // Wrap std::make_unique function to have correct return type.
40 template <typename T>
Create()41 std::unique_ptr<ScalableVideoController> Create() {
42   return std::make_unique<T>();
43 }
44 
45 constexpr NamedStructureFactory kFactories[] = {
46     {"NONE", Create<ScalableVideoControllerNoLayering>},
47     {"L1T2", Create<ScalabilityStructureL1T2>},
48     {"L1T3", Create<ScalabilityStructureL1T3>},
49     {"L2T1", Create<ScalabilityStructureL2T1>},
50     {"L2T1h", Create<ScalabilityStructureL2T1h>},
51     {"L2T1_KEY", Create<ScalabilityStructureL2T1Key>},
52     {"L2T2", Create<ScalabilityStructureL2T2>},
53     {"L2T2_KEY", Create<ScalabilityStructureL2T2Key>},
54     {"L2T2_KEY_SHIFT", Create<ScalabilityStructureL2T2KeyShift>},
55     {"L3T1", Create<ScalabilityStructureL3T1>},
56     {"L3T3", Create<ScalabilityStructureL3T3>},
57     {"S2T1", Create<ScalabilityStructureS2T1>},
58 };
59 
60 }  // namespace
61 
CreateScalabilityStructure(absl::string_view name)62 std::unique_ptr<ScalableVideoController> CreateScalabilityStructure(
63     absl::string_view name) {
64   RTC_DCHECK(!name.empty());
65   for (const auto& entry : kFactories) {
66     if (entry.name == name) {
67       return entry.factory();
68     }
69   }
70   return nullptr;
71 }
72 
73 }  // namespace webrtc
74