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/average_blend.h" 20 #include "src/dsp/cdef.h" 21 #include "src/dsp/convolve.h" 22 #include "src/dsp/distance_weighted_blend.h" 23 #include "src/dsp/film_grain.h" 24 #include "src/dsp/intra_edge.h" 25 #include "src/dsp/intrapred.h" 26 #include "src/dsp/intrapred_cfl.h" 27 #include "src/dsp/intrapred_directional.h" 28 #include "src/dsp/intrapred_filter.h" 29 #include "src/dsp/intrapred_smooth.h" 30 #include "src/dsp/inverse_transform.h" 31 #include "src/dsp/loop_filter.h" 32 #include "src/dsp/loop_restoration.h" 33 #include "src/dsp/mask_blend.h" 34 #include "src/dsp/motion_field_projection.h" 35 #include "src/dsp/motion_vector_search.h" 36 #include "src/dsp/obmc.h" 37 #include "src/dsp/super_res.h" 38 #include "src/dsp/warp.h" 39 #include "src/dsp/weight_mask.h" 40 #include "src/utils/cpu.h" 41 42 namespace libgav1 { 43 namespace dsp_internal { 44 DspInit_C()45void DspInit_C() { 46 dsp::AverageBlendInit_C(); 47 dsp::CdefInit_C(); 48 dsp::ConvolveInit_C(); 49 dsp::DistanceWeightedBlendInit_C(); 50 dsp::FilmGrainInit_C(); 51 dsp::IntraEdgeInit_C(); 52 dsp::IntraPredCflInit_C(); 53 dsp::IntraPredDirectionalInit_C(); 54 dsp::IntraPredFilterInit_C(); 55 dsp::IntraPredInit_C(); 56 dsp::IntraPredSmoothInit_C(); 57 dsp::InverseTransformInit_C(); 58 dsp::LoopFilterInit_C(); 59 dsp::LoopRestorationInit_C(); 60 dsp::MaskBlendInit_C(); 61 dsp::MotionFieldProjectionInit_C(); 62 dsp::MotionVectorSearchInit_C(); 63 dsp::ObmcInit_C(); 64 dsp::SuperResInit_C(); 65 dsp::WarpInit_C(); 66 dsp::WeightMaskInit_C(); 67 } 68 GetWritableDspTable(int bitdepth)69dsp::Dsp* GetWritableDspTable(int bitdepth) { 70 switch (bitdepth) { 71 case 8: { 72 static dsp::Dsp dsp_8bpp; 73 return &dsp_8bpp; 74 } 75 #if LIBGAV1_MAX_BITDEPTH >= 10 76 case 10: { 77 static dsp::Dsp dsp_10bpp; 78 return &dsp_10bpp; 79 } 80 #endif 81 } 82 return nullptr; 83 } 84 85 } // namespace dsp_internal 86 87 namespace dsp { 88 DspInit()89void DspInit() { 90 static std::once_flag once; 91 std::call_once(once, []() { 92 dsp_internal::DspInit_C(); 93 #if LIBGAV1_ENABLE_SSE4_1 || LIBGAV1_ENABLE_AVX2 94 const uint32_t cpu_features = GetCpuInfo(); 95 #if LIBGAV1_ENABLE_SSE4_1 96 if ((cpu_features & kSSE4_1) != 0) { 97 AverageBlendInit_SSE4_1(); 98 CdefInit_SSE4_1(); 99 ConvolveInit_SSE4_1(); 100 DistanceWeightedBlendInit_SSE4_1(); 101 FilmGrainInit_SSE4_1(); 102 IntraEdgeInit_SSE4_1(); 103 IntraPredCflInit_SSE4_1(); 104 IntraPredDirectionalInit_SSE4_1(); 105 IntraPredFilterInit_SSE4_1(); 106 IntraPredInit_SSE4_1(); 107 IntraPredCflInit_SSE4_1(); 108 IntraPredSmoothInit_SSE4_1(); 109 InverseTransformInit_SSE4_1(); 110 LoopFilterInit_SSE4_1(); 111 LoopRestorationInit_SSE4_1(); 112 MaskBlendInit_SSE4_1(); 113 MotionFieldProjectionInit_SSE4_1(); 114 MotionVectorSearchInit_SSE4_1(); 115 ObmcInit_SSE4_1(); 116 SuperResInit_SSE4_1(); 117 WarpInit_SSE4_1(); 118 WeightMaskInit_SSE4_1(); 119 #if LIBGAV1_MAX_BITDEPTH >= 10 120 LoopRestorationInit10bpp_SSE4_1(); 121 #endif // LIBGAV1_MAX_BITDEPTH >= 10 122 } 123 #endif // LIBGAV1_ENABLE_SSE4_1 124 #if LIBGAV1_ENABLE_AVX2 125 if ((cpu_features & kAVX2) != 0) { 126 CdefInit_AVX2(); 127 ConvolveInit_AVX2(); 128 LoopRestorationInit_AVX2(); 129 #if LIBGAV1_MAX_BITDEPTH >= 10 130 LoopRestorationInit10bpp_AVX2(); 131 #endif // LIBGAV1_MAX_BITDEPTH >= 10 132 } 133 #endif // LIBGAV1_ENABLE_AVX2 134 #endif // LIBGAV1_ENABLE_SSE4_1 || LIBGAV1_ENABLE_AVX2 135 #if LIBGAV1_ENABLE_NEON 136 AverageBlendInit_NEON(); 137 CdefInit_NEON(); 138 ConvolveInit_NEON(); 139 DistanceWeightedBlendInit_NEON(); 140 FilmGrainInit_NEON(); 141 IntraEdgeInit_NEON(); 142 IntraPredCflInit_NEON(); 143 IntraPredDirectionalInit_NEON(); 144 IntraPredFilterInit_NEON(); 145 IntraPredInit_NEON(); 146 IntraPredSmoothInit_NEON(); 147 InverseTransformInit_NEON(); 148 LoopFilterInit_NEON(); 149 LoopRestorationInit_NEON(); 150 MaskBlendInit_NEON(); 151 MotionFieldProjectionInit_NEON(); 152 MotionVectorSearchInit_NEON(); 153 ObmcInit_NEON(); 154 SuperResInit_NEON(); 155 WarpInit_NEON(); 156 WeightMaskInit_NEON(); 157 #if LIBGAV1_MAX_BITDEPTH >= 10 158 InverseTransformInit10bpp_NEON(); 159 #endif // LIBGAV1_MAX_BITDEPTH >= 10 160 #endif // LIBGAV1_ENABLE_NEON 161 }); 162 } 163 GetDspTable(int bitdepth)164const Dsp* GetDspTable(int bitdepth) { 165 return dsp_internal::GetWritableDspTable(bitdepth); 166 } 167 168 } // namespace dsp 169 } // namespace libgav1 170