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_COMMON_H_
18 #define LIBGAV1_SRC_DSP_COMMON_H_
19 
20 #include <cstddef>  // ptrdiff_t
21 #include <cstdint>
22 
23 #include "src/dsp/constants.h"
24 #include "src/utils/constants.h"
25 #include "src/utils/memory.h"
26 
27 namespace libgav1 {
28 
29 // Self guided projection filter.
30 struct SgrProjInfo {
31   int index;
32   int multiplier[2];
33 };
34 
35 struct WienerInfo {
36   static const int kVertical = 0;
37   static const int kHorizontal = 1;
38 
39   alignas(kMaxAlignment) int16_t filter[2][kSubPixelTaps];
40 };
41 
42 struct RestorationUnitInfo : public MaxAlignedAllocable {
43   LoopRestorationType type;
44   SgrProjInfo sgr_proj_info;
45   WienerInfo wiener_info;
46 };
47 
48 struct RestorationBuffer {
49   // For self-guided filter.
50   int* box_filter_process_output[2];
51   ptrdiff_t box_filter_process_output_stride;
52   uint32_t* box_filter_process_intermediate[2];
53   ptrdiff_t box_filter_process_intermediate_stride;
54   // For wiener filter.
55   uint16_t* wiener_buffer;
56   ptrdiff_t wiener_buffer_stride;
57 };
58 
59 }  // namespace libgav1
60 
61 #endif  // LIBGAV1_SRC_DSP_COMMON_H_
62