1 /******************************************************************************
2 *
3 * Copyright (C) 2022 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *****************************************************************************
18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20
21 #ifndef _ISVCE_DOWNSCALER_PRIVATE_DEFS_H_
22 #define _ISVCE_DOWNSCALER_PRIVATE_DEFS_H_
23 #include "ih264_typedefs.h"
24 #include "isvc_macros.h"
25 #include "ih264_debug.h"
26 #include "isvc_structs.h"
27 #include "isvce_downscaler.h"
28
29 /* Macros */
30 #define DOWNSCALER_Q 16
31
32 #define FILTER_COEFF_Q 7
33
34 #define NUM_SCALER_FILTER_TAPS 8
35
36 #define NUM_SCALER_FILTER_PHASES 8
37
38 /* Typedefs */
39 typedef WORD8 (*FILTER_COEFF_ARRAY)[NUM_SCALER_FILTER_TAPS * 2];
40
41 typedef void FT_DOWNSCALER(downscaler_ctxt_t *ps_scaler_state, buffer_container_t *ps_src,
42 buffer_container_t *ps_dst, FILTER_COEFF_ARRAY pai1_filters,
43 UWORD32 u4_blk_wd, UWORD32 u4_blk_ht, UWORD8 u1_is_chroma);
44
45 /* Structs */
46 typedef struct
47 {
48 /**
49 * pointer to scratch buf
50 */
51 void *pv_scratch_buf;
52
53 /**
54 * initial offset while calculating input pixel location
55 */
56 WORD32 i4_init_offset;
57
58 /**
59 * increment to the centre pixel in horizontal direction
60 */
61 UWORD32 u4_horz_increment;
62
63 /**
64 * increment to the centre pixel in vertical direction
65 */
66 UWORD32 u4_vert_increment;
67
68 /**
69 * pointer to the filter coefficients
70 */
71 FILTER_COEFF_ARRAY pai1_filters;
72
73 /**
74 * function pointer to the leaf level function for horizontal scaling
75 */
76 FT_DOWNSCALER *pf_downscaler;
77
78 /**
79 * width of the input (highest SVC layer)
80 */
81 UWORD32 u4_in_wd;
82
83 /**
84 * height of the input (highest SVC layer)
85 */
86 UWORD32 u4_in_ht;
87
88 } downscaler_state_t;
89
get_filter_phase(UWORD32 u4_center_pixel_pos)90 static FORCEINLINE UWORD32 get_filter_phase(UWORD32 u4_center_pixel_pos)
91 {
92 UWORD32 au4_phase_binning_pos[NUM_SCALER_FILTER_PHASES + 1];
93 UWORD32 i;
94
95 ASSERT(NUM_SCALER_FILTER_PHASES == 8);
96
97 for(i = 0; i < NUM_SCALER_FILTER_PHASES + 1; i++)
98 {
99 au4_phase_binning_pos[i] = (i << DOWNSCALER_Q) / NUM_SCALER_FILTER_PHASES;
100 }
101
102 u4_center_pixel_pos = u4_center_pixel_pos % (1 << DOWNSCALER_Q);
103
104 for(i = 0; i < NUM_SCALER_FILTER_PHASES; i++)
105 {
106 if((u4_center_pixel_pos < au4_phase_binning_pos[i + 1]) &&
107 (u4_center_pixel_pos >= au4_phase_binning_pos[i]))
108 {
109 return i;
110 }
111 }
112
113 ASSERT(0);
114
115 return 0;
116 }
117
118 /* SSE42 Declarations */
119 extern FT_DOWNSCALER isvce_horizontal_downscale_and_transpose_sse42;
120
121 /* NEON Declarations */
122 extern FT_DOWNSCALER isvce_horizontal_downscale_and_transpose_neon;
123
124 #endif
125