xref: /aosp_15_r20/external/libgav1/src/dsp/loop_restoration.h (revision 095378508e87ed692bf8dfeb34008b65b3735891)
1 /*
2  * Copyright 2019 The libgav1 Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIBGAV1_SRC_DSP_LOOP_RESTORATION_H_
18 #define LIBGAV1_SRC_DSP_LOOP_RESTORATION_H_
19 
20 // Pull in LIBGAV1_DspXXX defines representing the implementation status
21 // of each function. The resulting value of each can be used by each module to
22 // determine whether an implementation is needed at compile time.
23 // IWYU pragma: begin_exports
24 
25 // ARM:
26 #include "src/dsp/arm/loop_restoration_neon.h"
27 
28 // x86:
29 // Note includes should be sorted in logical order avx2/avx/sse4, etc.
30 // The order of includes is important as each tests for a superior version
31 // before setting the base.
32 // clang-format off
33 #include "src/dsp/x86/loop_restoration_avx2.h"
34 #include "src/dsp/x86/loop_restoration_sse4.h"
35 // clang-format on
36 
37 // IWYU pragma: end_exports
38 
39 namespace libgav1 {
40 namespace dsp {
41 
42 extern const uint8_t kSgrMaLookup[256];
43 
44 // Initializes Dsp::loop_restorations. This function is not thread-safe.
45 void LoopRestorationInit_C();
46 
47 template <typename T>
Circulate3PointersBy1(T * p[3])48 void Circulate3PointersBy1(T* p[3]) {
49   T* const p0 = p[0];
50   p[0] = p[1];
51   p[1] = p[2];
52   p[2] = p0;
53 }
54 
55 template <typename T>
Circulate4PointersBy2(T * p[4])56 void Circulate4PointersBy2(T* p[4]) {
57   std::swap(p[0], p[2]);
58   std::swap(p[1], p[3]);
59 }
60 
61 template <typename T>
Circulate5PointersBy2(T * p[5])62 void Circulate5PointersBy2(T* p[5]) {
63   T* const p0 = p[0];
64   T* const p1 = p[1];
65   p[0] = p[2];
66   p[1] = p[3];
67   p[2] = p[4];
68   p[3] = p0;
69   p[4] = p1;
70 }
71 
72 }  // namespace dsp
73 }  // namespace libgav1
74 
75 #endif  // LIBGAV1_SRC_DSP_LOOP_RESTORATION_H_
76