• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef _ISVCD_RESIDUAL_RESAMP_H_
21 #define _ISVCD_RESIDUAL_RESAMP_H_
22 
23 /**
24  *******************************************************************************
25  * @file
26  *  isvcd_residual_resamp.h
27  *
28  * @brief
29  *  Contains routines that resample for SVC resampling
30  *
31  * @author
32  *  Kishore
33  *
34  * @remarks
35  *  None
36  *
37  *******************************************************************************
38  */
39 
40 #include "ih264_typedefs.h"
41 #include "ih264_macros.h"
42 #include "ih264_platform_macros.h"
43 #include "isvcd_structs.h"
44 
45 #define REF_ARRAY_WIDTH_RES_SAMP (MB_WIDTH + 6)
46 #define REF_ARRAY_HEIGHT_RES_SAMP (MB_HEIGHT + 6)
47 
48 typedef void i264_residual_reflayer_const_non_boundary_mb(
49     WORD16 *pi2_inp_data, WORD32 i4_inp_data_stride, WORD16 *pi2_ref_array, WORD32 i4_refarray_wd,
50     WORD32 i4_refarray_ht, WORD32 i4_ref_mb_type_q0, WORD32 i4_ref_mb_type_q1,
51     WORD32 i4_ref_mb_type_q2, WORD32 i4_ref_mb_type_q3, WORD32 i4_mb_quard1_part_x,
52     WORD32 i4_mb_quard1_part_y, WORD32 i4_chroma_flag);
53 
54 typedef void i264_residual_reflayer_const_boundary_mb(
55     WORD16 *pi2_inp_data, WORD32 i4_inp_data_stride, WORD16 *pi2_ref_array, WORD32 i4_refarray_wd,
56     WORD32 i4_refarray_ht, WORD32 i4_ref_wd, WORD32 i4_ref_ht, WORD32 i4_x_offset,
57     WORD32 i4_y_offset, WORD32 i4_ref_mb_type_q0, WORD32 i4_ref_mb_type_q1,
58     WORD32 i4_ref_mb_type_q2, WORD32 i4_ref_mb_type_q3, WORD32 i4_mb_quard1_part_x,
59     WORD32 i4_mb_quard1_part_y, WORD32 i4_chroma_flag);
60 
61 typedef void i264_interpolate_residual(void *pv_residual_samp_ctxt, WORD16 *pi2_out,
62                                        WORD32 i4_out_stride, WORD32 i4_refarray_wd, UWORD16 u2_mb_x,
63                                        UWORD16 u2_mb_y, WORD32 i4_chroma_flag);
64 
65 typedef void i264_residual_luma_dyadic(void *pv_residual_samp_ctxt, WORD16 *pi2_inp_data,
66                                        WORD32 i4_inp_data_stride, WORD16 *pi2_out_res,
67                                        WORD32 i4_out_res_stride, mem_element_t *ps_ref_mb_mode,
68                                        UWORD16 u2_mb_x, UWORD16 u2_mb_y, WORD32 i4_ref_nnz,
69                                        WORD32 i4_ref_tx_size);
70 
71 typedef void i264_residual_chroma_dyadic(void *pv_residual_samp_ctxt, WORD16 *pi2_inp_data,
72                                          WORD32 i4_inp_data_stride, WORD16 *pi2_out_res,
73                                          WORD32 i4_out_res_stride);
74 
75 typedef void i264_residual_chroma_dyadic_alt(void *pv_residual_samp_ctxt, UWORD16 u2_mb_x,
76                                              UWORD16 u2_mb_y, mem_element_t *ps_ref_mb_mode,
77                                              WORD16 *pi2_inp_data, WORD32 i4_inp_data_stride,
78                                              WORD16 *pi2_out_res, WORD32 i4_out_res_stride,
79                                              WORD32 i4_cr_flag);
80 
81 /*C Declarations*/
82 i264_residual_luma_dyadic isvcd_residual_luma_dyadic;
83 i264_residual_chroma_dyadic isvcd_residual_chroma_dyadic;
84 i264_residual_chroma_dyadic_alt isvcd_residual_chroma_dyadic_alt;
85 
86 i264_interpolate_residual isvcd_interpolate_residual;
87 i264_residual_reflayer_const_non_boundary_mb isvcd_residual_reflayer_const_non_boundary_mb;
88 i264_residual_reflayer_const_boundary_mb isvcd_residual_reflayer_const_boundary_mb;
89 
90 /*ARM Declarations*/
91 i264_residual_luma_dyadic isvcd_residual_luma_dyadic_neonintr;
92 i264_interpolate_residual isvcd_interpolate_residual_neonintr;
93 i264_residual_reflayer_const_non_boundary_mb isvcd_residual_reflayer_const_non_boundary_mb_neonintr;
94 
95 /*x86 Declarations*/
96 i264_residual_luma_dyadic isvcd_residual_luma_dyadic_sse42;
97 i264_interpolate_residual isvcd_interpolate_residual_sse42;
98 i264_residual_reflayer_const_non_boundary_mb isvcd_residual_reflayer_const_non_boundary_mb_sse42;
99 
100 typedef WORD32 ftype_residual_samp_mb(void *pv_residual_samp_ctxt, mem_element_t *ps_ref_luma,
101                                       mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode,
102                                       mem_element_t *ps_out_luma, mem_element_t *ps_out_chroma,
103                                       UWORD16 u2_mb_x, UWORD16 u2_mb_y);
104 
105 WORD32 isvcd_residual_samp_mb_dyadic(void *pv_residual_samp_ctxt, mem_element_t *ps_ref_luma,
106                                      mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode,
107                                      mem_element_t *ps_out_luma, mem_element_t *ps_out_chroma,
108                                      UWORD16 u2_mb_x, UWORD16 u2_mb_y);
109 
110 WORD32 isvcd_residual_samp_mb(void *pv_residual_samp_ctxt, mem_element_t *ps_ref_luma,
111                               mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode,
112                               mem_element_t *ps_out_luma, mem_element_t *ps_out_chroma,
113                               UWORD16 u2_mb_x, UWORD16 u2_mb_y);
114 
115 typedef struct
116 {
117     /* used for mapping purpose */
118     ref_pixel_map_t *ps_x_pos_phase;  /*!< buffers to store the projected
119                                          referecne X and phase X for each
120                                          pixel in current layer in
121                                          horizontal direction
122                                       */
123     ref_pixel_map_t *ps_y_pos_phase;  /*!< buffers to store the projected
124                                          referecne Y and phase Y for each
125                                          pixel in current layer in
126                                          vertical direction
127                                       */
128     ref_mb_map_t *ps_x_offset_length; /*!< buffers to store the projected
129                                       start point of reference window and
130                                       reference array  width in
131                                       horizontal direction for each MB in
132                                       current layer
133                                   */
134     ref_mb_map_t *ps_y_offset_length; /*!< buffers to store the projected
135                                       start point of reference window and
136                                       reference array  height in
137                                       vertical direction for each MB in
138                                       current layer
139                                   */
140 } residual_samp_map_ctxt_t;
141 
142 typedef struct
143 {
144     residual_samp_map_ctxt_t s_luma_map_ctxt;    /*!< map structure for luma
145                                                      projected locations
146                                                      for curr resolution layer
147                                                    */
148     residual_samp_map_ctxt_t s_chroma_map_ctxt;  /*!< map structure for chroma
149                                                     projected locations
150                                                     for curr resolution layer
151                                                   */
152     WORD32 i4_ref_width;                         /*!< reference layer width in
153                                                    terms luma samples
154                                                  */
155     WORD32 i4_ref_height;                        /*!< reference layer height in
156                                                     terms luma samples
157                                                   */
158     WORD32 i4_curr_width;                        /*!< current layer width in
159                                                    terms luma samples
160                                                  */
161     WORD32 i4_curr_height;                       /*!< current layer height in
162                                                    terms luma samples
163                                                  */
164     WORD32 i4_dyadic_flag;                       /*!< flag to indicate whether
165                                                    the upscaling factor is 2
166                                                    in both directions
167                                                  */
168     ftype_residual_samp_mb *pf_residual_samp_mb; /*!< function pointer
169                                                  for dyadic optimization*/
170 
171     /* following variables are for Dyadic cases only */
172     WORD32 i4_chrm_alt_proc;      /*!< Alternate processing
173                                   for chroma for specific
174                                   values of phases
175                                   */
176 
177     WORD32 i4_chrm_vert_int_mode; /*!< Chroma horizontal
178                                   interpolation alternate
179                                   mode
180                                  */
181 
182     WORD32 i4_chrm_horz_int_mode; /*!<Chroma vertical
183                                   interpolation alternate
184                                   modes
185                                   */
186 } res_lyr_ctxt;
187 
188 typedef struct
189 {
190     res_lyr_ctxt as_res_lyrs[MAX_NUM_RES_LYRS]; /*!< Array of resolutoin layer
191                                                   ctxt.The first strcuture in the
192                                                   array will be used for storing
193                                                   the "second resolution" map in
194                                                   an access unit w.r.t to its
195                                                   base resolution, and for base
196                                                   resolution nothing will be
197                                                   computed or stored
198                                               */
199 
200     WORD16 *pi2_refarray_buffer;                /*!< buffer to store the reference
201                                                       layer data before residual
202                                                       sampling
203                                                  */
204 
205     UWORD8 *pu1_ref_x_ptr_incr;                 /*!< buffer to store the reference
206                                                     array ptr increments for
207                                                     operand 2 of interpolation
208                                               */
209     UWORD8 *pu1_ref_y_ptr_incr;                 /*!< buffer to store the reference
210                                                     array ptr increments for
211                                                     operand 2 of interpolation
212                                               */
213 
214     WORD32 i4_res_lyr_id;                       /*!< resolution id of the layer
215                                                      which is to be processed
216                                                  */
217     WORD32 i4_ref_width;                        /*!< reference layer width in
218                                                   terms luma samples
219                                                  */
220 
221     WORD32 i4_ref_height;                       /*!< reference layer height in
222                                                  terms luma samples
223                                                   */
224 
225     /*Dyadic Residual Resamp*/
226     i264_residual_luma_dyadic *pf_residual_luma_dyadic;
227     i264_residual_chroma_dyadic *pf_residual_chroma_dyadic;
228     i264_residual_chroma_dyadic_alt *pf_residual_chroma_dyadic_alt;
229 
230     /*Non-dyadic Residual Resamp*/
231     i264_interpolate_residual *pf_interpolate_residual;
232     i264_residual_reflayer_const_non_boundary_mb *pf_residual_reflayer_const_non_boundary_mb;
233     i264_residual_reflayer_const_boundary_mb *pf_residual_reflayer_const_boundary_mb;
234 } residual_sampling_ctxt_t;
235 
236 WORD32 isvcd_residual_samp_res_init(void *pv_dec);
237 
238 #endif /* _ISVCD_RESIDUAL_RESAMP_H_ */
239