• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The libgav1 Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "src/dsp/dsp.h"
16 
17 #include <mutex>  // NOLINT (unapproved c++11 header)
18 
19 #include "src/dsp/arm/weight_mask_neon.h"
20 #include "src/dsp/average_blend.h"
21 #include "src/dsp/cdef.h"
22 #include "src/dsp/convolve.h"
23 #include "src/dsp/distance_weighted_blend.h"
24 #include "src/dsp/film_grain.h"
25 #include "src/dsp/intra_edge.h"
26 #include "src/dsp/intrapred.h"
27 #include "src/dsp/inverse_transform.h"
28 #include "src/dsp/loop_filter.h"
29 #include "src/dsp/loop_restoration.h"
30 #include "src/dsp/mask_blend.h"
31 #include "src/dsp/motion_field_projection.h"
32 #include "src/dsp/motion_vector_search.h"
33 #include "src/dsp/obmc.h"
34 #include "src/dsp/super_res.h"
35 #include "src/dsp/warp.h"
36 #include "src/dsp/weight_mask.h"
37 #include "src/utils/cpu.h"
38 
39 namespace libgav1 {
40 namespace dsp_internal {
41 
GetWritableDspTable(int bitdepth)42 dsp::Dsp* GetWritableDspTable(int bitdepth) {
43   switch (bitdepth) {
44     case 8: {
45       static dsp::Dsp dsp_8bpp;
46       return &dsp_8bpp;
47     }
48 #if LIBGAV1_MAX_BITDEPTH >= 10
49     case 10: {
50       static dsp::Dsp dsp_10bpp;
51       return &dsp_10bpp;
52     }
53 #endif
54   }
55   return nullptr;
56 }
57 
58 }  // namespace dsp_internal
59 
60 namespace dsp {
61 
DspInit()62 void DspInit() {
63   static std::once_flag once;
64   std::call_once(once, []() {
65     AverageBlendInit_C();
66     CdefInit_C();
67     ConvolveInit_C();
68     DistanceWeightedBlendInit_C();
69     FilmGrainInit_C();
70     IntraEdgeInit_C();
71     IntraPredInit_C();
72     InverseTransformInit_C();
73     LoopFilterInit_C();
74     LoopRestorationInit_C();
75     MaskBlendInit_C();
76     MotionFieldProjectionInit_C();
77     MotionVectorSearchInit_C();
78     ObmcInit_C();
79     SuperResInit_C();
80     WarpInit_C();
81     WeightMaskInit_C();
82 #if LIBGAV1_ENABLE_SSE4_1
83     const uint32_t cpu_features = GetCpuInfo();
84     if ((cpu_features & kSSE4_1) != 0) {
85       AverageBlendInit_SSE4_1();
86       CdefInit_SSE4_1();
87       ConvolveInit_SSE4_1();
88       DistanceWeightedBlendInit_SSE4_1();
89       IntraEdgeInit_SSE4_1();
90       IntraPredInit_SSE4_1();
91       IntraPredCflInit_SSE4_1();
92       IntraPredSmoothInit_SSE4_1();
93       InverseTransformInit_SSE4_1();
94       LoopFilterInit_SSE4_1();
95       LoopRestorationInit_SSE4_1();
96       MaskBlendInit_SSE4_1();
97       MotionFieldProjectionInit_SSE4_1();
98       MotionVectorSearchInit_SSE4_1();
99       ObmcInit_SSE4_1();
100       SuperResInit_SSE4_1();
101       WarpInit_SSE4_1();
102       WeightMaskInit_SSE4_1();
103     }
104 #endif  // LIBGAV1_ENABLE_SSE4_1
105 #if LIBGAV1_ENABLE_NEON
106     AverageBlendInit_NEON();
107     CdefInit_NEON();
108     ConvolveInit_NEON();
109     DistanceWeightedBlendInit_NEON();
110     FilmGrainInit_NEON();
111     IntraEdgeInit_NEON();
112     IntraPredCflInit_NEON();
113     IntraPredDirectionalInit_NEON();
114     IntraPredFilterIntraInit_NEON();
115     IntraPredInit_NEON();
116     IntraPredSmoothInit_NEON();
117     InverseTransformInit_NEON();
118     LoopFilterInit_NEON();
119     LoopRestorationInit_NEON();
120     MaskBlendInit_NEON();
121     MotionFieldProjectionInit_NEON();
122     MotionVectorSearchInit_NEON();
123     ObmcInit_NEON();
124     SuperResInit_NEON();
125     WarpInit_NEON();
126     WeightMaskInit_NEON();
127 #endif  // LIBGAV1_ENABLE_NEON
128   });
129 }
130 
GetDspTable(int bitdepth)131 const Dsp* GetDspTable(int bitdepth) {
132   return dsp_internal::GetWritableDspTable(bitdepth);
133 }
134 
135 }  // namespace dsp
136 }  // namespace libgav1
137