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