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 21*495ae853SAndroid Build Coastguard Worker #ifndef _ISVC_INTRA_RESAMPLE_H_ 22*495ae853SAndroid Build Coastguard Worker #define _ISVC_INTRA_RESAMPLE_H_ 23*495ae853SAndroid Build Coastguard Worker 24*495ae853SAndroid Build Coastguard Worker #include "ih264_typedefs.h" 25*495ae853SAndroid Build Coastguard Worker #include "isvc_macros.h" 26*495ae853SAndroid Build Coastguard Worker #include "ih264_platform_macros.h" 27*495ae853SAndroid Build Coastguard Worker #include "isvc_structs.h" 28*495ae853SAndroid Build Coastguard Worker 29*495ae853SAndroid Build Coastguard Worker #define DYADIC_REF_W_Y 20 30*495ae853SAndroid Build Coastguard Worker #define DYADIC_REF_H_Y 20 31*495ae853SAndroid Build Coastguard Worker #define DYADIC_REF_W_C 10 32*495ae853SAndroid Build Coastguard Worker #define DYADIC_REF_H_C 10 33*495ae853SAndroid Build Coastguard Worker 34*495ae853SAndroid Build Coastguard Worker #define MAX_NUM_RES_LYRS 4 35*495ae853SAndroid Build Coastguard Worker 36*495ae853SAndroid Build Coastguard Worker #define MAX_PIX_FILL_LUMA 4 37*495ae853SAndroid Build Coastguard Worker #define MAX_PIX_FILL_CHROMA 2 38*495ae853SAndroid Build Coastguard Worker 39*495ae853SAndroid Build Coastguard Worker #define MAX_REF_ARR_WD_HT 48 40*495ae853SAndroid Build Coastguard Worker #define MAX_REF_IDX_ARRAY (MAX_REF_ARR_WD_HT + MB_SIZE) 41*495ae853SAndroid Build Coastguard Worker 42*495ae853SAndroid Build Coastguard Worker #define CLIPUCHAR(x) CLIP3(0, 255, (x)) 43*495ae853SAndroid Build Coastguard Worker 44*495ae853SAndroid Build Coastguard Worker #define REF_ARRAY_WIDTH 48 45*495ae853SAndroid Build Coastguard Worker #define REF_ARRAY_HEIGHT 48 46*495ae853SAndroid Build Coastguard Worker 47*495ae853SAndroid Build Coastguard Worker typedef void FT_INTERPOLATE_LUMA_2X(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf, 48*495ae853SAndroid Build Coastguard Worker UWORD8 *pu1_out_buf, WORD32 i4_out_stride); 49*495ae853SAndroid Build Coastguard Worker 50*495ae853SAndroid Build Coastguard Worker typedef void FT_VERT_INTERPOLATE_CHROMA_2X(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf, 51*495ae853SAndroid Build Coastguard Worker WORD32 i4_phase_0, WORD32 i4_phase_1); 52*495ae853SAndroid Build Coastguard Worker 53*495ae853SAndroid Build Coastguard Worker typedef void FT_HORZ_INTERPOLATE_CHROMA_2X(WORD16 *pi2_tmp_filt_buf, UWORD8 *pu1_out_buf, 54*495ae853SAndroid Build Coastguard Worker WORD32 i4_out_stride, WORD32 i4_phase_0, 55*495ae853SAndroid Build Coastguard Worker WORD32 i4_phase_1); 56*495ae853SAndroid Build Coastguard Worker 57*495ae853SAndroid Build Coastguard Worker typedef struct mem_element_t 58*495ae853SAndroid Build Coastguard Worker { 59*495ae853SAndroid Build Coastguard Worker /* Buffer pointer */ 60*495ae853SAndroid Build Coastguard Worker void *pv_buffer; 61*495ae853SAndroid Build Coastguard Worker 62*495ae853SAndroid Build Coastguard Worker /* size of the structure or unit */ 63*495ae853SAndroid Build Coastguard Worker WORD32 i4_element_size; 64*495ae853SAndroid Build Coastguard Worker 65*495ae853SAndroid Build Coastguard Worker /* Stride of buffer in terms of number of elements.*/ 66*495ae853SAndroid Build Coastguard Worker WORD32 i4_num_element_stride; 67*495ae853SAndroid Build Coastguard Worker } mem_element_t; 68*495ae853SAndroid Build Coastguard Worker 69*495ae853SAndroid Build Coastguard Worker typedef struct seg_description_t 70*495ae853SAndroid Build Coastguard Worker { 71*495ae853SAndroid Build Coastguard Worker /* describes segment dimension */ 72*495ae853SAndroid Build Coastguard Worker UWORD8 u1_seg_dim; 73*495ae853SAndroid Build Coastguard Worker 74*495ae853SAndroid Build Coastguard Worker /* describes offset from start */ 75*495ae853SAndroid Build Coastguard Worker UWORD8 u1_seg_off; 76*495ae853SAndroid Build Coastguard Worker 77*495ae853SAndroid Build Coastguard Worker /* describes whether mb is adjoining the segment 78*495ae853SAndroid Build Coastguard Worker 0 => not adjoining 1 => adjoining */ 79*495ae853SAndroid Build Coastguard Worker UWORD8 u1_mb_adjoin; 80*495ae853SAndroid Build Coastguard Worker 81*495ae853SAndroid Build Coastguard Worker /* distance to nearest MB */ 82*495ae853SAndroid Build Coastguard Worker WORD8 i1_dist_idx; 83*495ae853SAndroid Build Coastguard Worker 84*495ae853SAndroid Build Coastguard Worker /* describes the nearest mb boundary 85*495ae853SAndroid Build Coastguard Worker +1 => rightMB/bottomMB 86*495ae853SAndroid Build Coastguard Worker -1 => leftMB/topMB */ 87*495ae853SAndroid Build Coastguard Worker WORD8 i1_nearst_mb_bdry; 88*495ae853SAndroid Build Coastguard Worker } seg_description_t; 89*495ae853SAndroid Build Coastguard Worker 90*495ae853SAndroid Build Coastguard Worker typedef struct seg_lookup_desc_t 91*495ae853SAndroid Build Coastguard Worker { 92*495ae853SAndroid Build Coastguard Worker /* place holder to store the number of segments */ 93*495ae853SAndroid Build Coastguard Worker UWORD8 u1_num_segments; 94*495ae853SAndroid Build Coastguard Worker 95*495ae853SAndroid Build Coastguard Worker /* this variable indicates where is start locatiion of the segment with 96*495ae853SAndroid Build Coastguard Worker respect to less the block_width or greater than block width*/ 97*495ae853SAndroid Build Coastguard Worker UWORD8 u4_start_pos; 98*495ae853SAndroid Build Coastguard Worker 99*495ae853SAndroid Build Coastguard Worker /* place holder to store per segment description */ 100*495ae853SAndroid Build Coastguard Worker seg_description_t s_segments[4]; 101*495ae853SAndroid Build Coastguard Worker } seg_lookup_desc_t; 102*495ae853SAndroid Build Coastguard Worker 103*495ae853SAndroid Build Coastguard Worker typedef struct intra_samp_lyr_ctxt 104*495ae853SAndroid Build Coastguard Worker { 105*495ae853SAndroid Build Coastguard Worker /* mb position */ 106*495ae853SAndroid Build Coastguard Worker coordinates_t *ps_mb_pos; 107*495ae853SAndroid Build Coastguard Worker 108*495ae853SAndroid Build Coastguard Worker /* reference layer width in terms luma samples */ 109*495ae853SAndroid Build Coastguard Worker WORD32 i4_ref_width; 110*495ae853SAndroid Build Coastguard Worker 111*495ae853SAndroid Build Coastguard Worker /* reference layer height in terms luma samples */ 112*495ae853SAndroid Build Coastguard Worker WORD32 i4_ref_height; 113*495ae853SAndroid Build Coastguard Worker 114*495ae853SAndroid Build Coastguard Worker /* Constrained intra resampling flag. Range is [0,1]. */ 115*495ae853SAndroid Build Coastguard Worker WORD8 i1_constrained_intra_rsmpl_flag; 116*495ae853SAndroid Build Coastguard Worker 117*495ae853SAndroid Build Coastguard Worker /* Chroma xPhase for even values of x for dyadic cases */ 118*495ae853SAndroid Build Coastguard Worker WORD32 i4_x_phase_0; 119*495ae853SAndroid Build Coastguard Worker 120*495ae853SAndroid Build Coastguard Worker /* Chroma xPhase for odd values of x for dyadic cases */ 121*495ae853SAndroid Build Coastguard Worker WORD32 i4_x_phase_1; 122*495ae853SAndroid Build Coastguard Worker 123*495ae853SAndroid Build Coastguard Worker /* Chroma yPhase for even values of y for dyadic cases */ 124*495ae853SAndroid Build Coastguard Worker WORD32 i4_y_phase_0; 125*495ae853SAndroid Build Coastguard Worker 126*495ae853SAndroid Build Coastguard Worker /* Chroma yPhase for odd values of y for dyadic cases */ 127*495ae853SAndroid Build Coastguard Worker WORD32 i4_y_phase_1; 128*495ae853SAndroid Build Coastguard Worker 129*495ae853SAndroid Build Coastguard Worker FT_INTERPOLATE_LUMA_2X *pf_interpolate_luma; 130*495ae853SAndroid Build Coastguard Worker 131*495ae853SAndroid Build Coastguard Worker FT_VERT_INTERPOLATE_CHROMA_2X *pf_vert_interpol_chroma; 132*495ae853SAndroid Build Coastguard Worker 133*495ae853SAndroid Build Coastguard Worker FT_HORZ_INTERPOLATE_CHROMA_2X *pf_horz_interpol_chroma; 134*495ae853SAndroid Build Coastguard Worker 135*495ae853SAndroid Build Coastguard Worker WORD16 i2_x_min_pos; 136*495ae853SAndroid Build Coastguard Worker 137*495ae853SAndroid Build Coastguard Worker WORD16 i2_x_max_pos; 138*495ae853SAndroid Build Coastguard Worker 139*495ae853SAndroid Build Coastguard Worker WORD16 i2_y_min_pos; 140*495ae853SAndroid Build Coastguard Worker 141*495ae853SAndroid Build Coastguard Worker WORD16 i2_y_max_pos; 142*495ae853SAndroid Build Coastguard Worker 143*495ae853SAndroid Build Coastguard Worker coordinates_t *ps_phase; 144*495ae853SAndroid Build Coastguard Worker 145*495ae853SAndroid Build Coastguard Worker WORD32 *pi4_ref_array_positions_x; 146*495ae853SAndroid Build Coastguard Worker 147*495ae853SAndroid Build Coastguard Worker WORD32 *pi4_ref_array_positions_y; 148*495ae853SAndroid Build Coastguard Worker 149*495ae853SAndroid Build Coastguard Worker coordinates_t *ps_offsets; 150*495ae853SAndroid Build Coastguard Worker 151*495ae853SAndroid Build Coastguard Worker coordinates_t *ps_ref_array_dims; 152*495ae853SAndroid Build Coastguard Worker 153*495ae853SAndroid Build Coastguard Worker /* buffers to store lookup for horizontal segment description */ 154*495ae853SAndroid Build Coastguard Worker seg_lookup_desc_t as_seg_lookup_horz[MB_SIZE]; 155*495ae853SAndroid Build Coastguard Worker 156*495ae853SAndroid Build Coastguard Worker /* buffers to store lookup for vertical segment description */ 157*495ae853SAndroid Build Coastguard Worker seg_lookup_desc_t as_seg_lookup_vert[MB_SIZE]; 158*495ae853SAndroid Build Coastguard Worker 159*495ae853SAndroid Build Coastguard Worker /* buffers to store lookup for x indexes to get 160*495ae853SAndroid Build Coastguard Worker availability from 4x4 availability grid */ 161*495ae853SAndroid Build Coastguard Worker UWORD8 au1_refarray_x_idx[MAX_REF_IDX_ARRAY]; 162*495ae853SAndroid Build Coastguard Worker 163*495ae853SAndroid Build Coastguard Worker /* buffers to store lookup for y indexes to get 164*495ae853SAndroid Build Coastguard Worker availability from 4x4 availability grid */ 165*495ae853SAndroid Build Coastguard Worker UWORD8 au1_refarray_y_idx[MAX_REF_IDX_ARRAY]; 166*495ae853SAndroid Build Coastguard Worker } intra_samp_lyr_ctxt; 167*495ae853SAndroid Build Coastguard Worker 168*495ae853SAndroid Build Coastguard Worker typedef struct intra_sampling_ctxt_t 169*495ae853SAndroid Build Coastguard Worker { 170*495ae853SAndroid Build Coastguard Worker /* Array of resolution layer ctxt. */ 171*495ae853SAndroid Build Coastguard Worker intra_samp_lyr_ctxt as_res_lyrs[MAX_NUM_RES_LYRS]; 172*495ae853SAndroid Build Coastguard Worker 173*495ae853SAndroid Build Coastguard Worker /* pointer to array of SPS */ 174*495ae853SAndroid Build Coastguard Worker void *ps_sps; 175*495ae853SAndroid Build Coastguard Worker 176*495ae853SAndroid Build Coastguard Worker /* buffer to store the reference layer data before intra sampling */ 177*495ae853SAndroid Build Coastguard Worker UWORD8 *pu1_refarray_buffer; 178*495ae853SAndroid Build Coastguard Worker 179*495ae853SAndroid Build Coastguard Worker /* buffer to hold the reference layer Cb data before intra 180*495ae853SAndroid Build Coastguard Worker resampling (used for dyadic cases only) */ 181*495ae853SAndroid Build Coastguard Worker UWORD8 *pu1_refarray_cb; 182*495ae853SAndroid Build Coastguard Worker 183*495ae853SAndroid Build Coastguard Worker /* buffer to hold the reference layer Cr data before intra 184*495ae853SAndroid Build Coastguard Worker resampling (used for dyadic cases only) */ 185*495ae853SAndroid Build Coastguard Worker UWORD8 *pu1_refarray_cr; 186*495ae853SAndroid Build Coastguard Worker 187*495ae853SAndroid Build Coastguard Worker /* intermideate buffer for interpolation */ 188*495ae853SAndroid Build Coastguard Worker WORD32 *pi4_temp_interpolation_buffer; 189*495ae853SAndroid Build Coastguard Worker 190*495ae853SAndroid Build Coastguard Worker /* resolution id of the layer which is to be processed */ 191*495ae853SAndroid Build Coastguard Worker WORD32 i4_res_lyr_id; 192*495ae853SAndroid Build Coastguard Worker 193*495ae853SAndroid Build Coastguard Worker /* reference layer width in terms luma samples */ 194*495ae853SAndroid Build Coastguard Worker WORD32 i4_ref_width; 195*495ae853SAndroid Build Coastguard Worker 196*495ae853SAndroid Build Coastguard Worker /* reference layer width in terms luma samples */ 197*495ae853SAndroid Build Coastguard Worker WORD32 i4_refarray_stride; 198*495ae853SAndroid Build Coastguard Worker 199*495ae853SAndroid Build Coastguard Worker /* reference layer height in terms luma samples */ 200*495ae853SAndroid Build Coastguard Worker WORD32 i4_ref_height; 201*495ae853SAndroid Build Coastguard Worker } intra_sampling_ctxt_t; 202*495ae853SAndroid Build Coastguard Worker 203*495ae853SAndroid Build Coastguard Worker typedef struct inter_lyr_mb_prms_t 204*495ae853SAndroid Build Coastguard Worker { 205*495ae853SAndroid Build Coastguard Worker /* NNZs of Chroma. Here each bit corresonds 206*495ae853SAndroid Build Coastguard Worker to a NNZs of 4x4 sub block. Lower 4 bits are 207*495ae853SAndroid Build Coastguard Worker used for Cb and upper are used for Cr */ 208*495ae853SAndroid Build Coastguard Worker UWORD8 u1_chroma_nnz; 209*495ae853SAndroid Build Coastguard Worker 210*495ae853SAndroid Build Coastguard Worker /* NNZs of Luma. Here each bit corresonds 211*495ae853SAndroid Build Coastguard Worker to a NNZs of 4x4 sub block in raster scan order. */ 212*495ae853SAndroid Build Coastguard Worker UWORD16 u2_luma_nnz; 213*495ae853SAndroid Build Coastguard Worker 214*495ae853SAndroid Build Coastguard Worker /* Packed MB mode transform size of an MB */ 215*495ae853SAndroid Build Coastguard Worker WORD8 i1_mb_mode; 216*495ae853SAndroid Build Coastguard Worker } inter_lyr_mb_prms_t; 217*495ae853SAndroid Build Coastguard Worker 218*495ae853SAndroid Build Coastguard Worker /* Function declarations */ 219*495ae853SAndroid Build Coastguard Worker extern void isvc_intra_samp_mb_dyadic(void *pv_intra_samp_ctxt, mem_element_t *ps_ref_luma, 220*495ae853SAndroid Build Coastguard Worker mem_element_t *ps_ref_chroma, 221*495ae853SAndroid Build Coastguard Worker mem_element_t *ps_ref_mb_mode_map, 222*495ae853SAndroid Build Coastguard Worker mem_element_t *ps_curr_luma, mem_element_t *ps_curr_chroma, 223*495ae853SAndroid Build Coastguard Worker UWORD16 u2_mb_x, UWORD16 u2_mb_y, 224*495ae853SAndroid Build Coastguard Worker WORD32 i4_scaled_ref_layer_left_offset, 225*495ae853SAndroid Build Coastguard Worker WORD32 i4_scaled_ref_layer_top_offset); 226*495ae853SAndroid Build Coastguard Worker 227*495ae853SAndroid Build Coastguard Worker extern void isvc_intra_samp_mb(void *pv_intra_samp_ctxt_luma, void *pv_intra_samp_ctxt_chroma, 228*495ae853SAndroid Build Coastguard Worker mem_element_t *ps_ref_luma, mem_element_t *ps_ref_chroma, 229*495ae853SAndroid Build Coastguard Worker mem_element_t *ps_ref_mb_mode_map, mem_element_t *ps_curr_luma, 230*495ae853SAndroid Build Coastguard Worker mem_element_t *ps_curr_chroma); 231*495ae853SAndroid Build Coastguard Worker 232*495ae853SAndroid Build Coastguard Worker extern void isvc_intra_resamp_generate_segment_lookup(seg_lookup_desc_t *ps_seg_lookup_table, 233*495ae853SAndroid Build Coastguard Worker WORD32 i4_dimension, WORD32 i4_mb_size, 234*495ae853SAndroid Build Coastguard Worker WORD32 i4_shift_val); 235*495ae853SAndroid Build Coastguard Worker 236*495ae853SAndroid Build Coastguard Worker /* C Declarations */ 237*495ae853SAndroid Build Coastguard Worker extern FT_INTERPOLATE_LUMA_2X isvc_interpolate_base_luma_dyadic; 238*495ae853SAndroid Build Coastguard Worker extern FT_VERT_INTERPOLATE_CHROMA_2X isvc_vert_interpol_chroma_dyadic; 239*495ae853SAndroid Build Coastguard Worker extern FT_HORZ_INTERPOLATE_CHROMA_2X isvc_horz_interpol_chroma_dyadic; 240*495ae853SAndroid Build Coastguard Worker 241*495ae853SAndroid Build Coastguard Worker /* SSE42 Declarations */ 242*495ae853SAndroid Build Coastguard Worker extern FT_INTERPOLATE_LUMA_2X isvc_interpolate_base_luma_dyadic_sse42; 243*495ae853SAndroid Build Coastguard Worker extern FT_VERT_INTERPOLATE_CHROMA_2X isvc_vert_interpol_chroma_dyadic_sse42; 244*495ae853SAndroid Build Coastguard Worker extern FT_HORZ_INTERPOLATE_CHROMA_2X isvc_horz_interpol_chroma_dyadic_sse42; 245*495ae853SAndroid Build Coastguard Worker 246*495ae853SAndroid Build Coastguard Worker /* NEON Declarations */ 247*495ae853SAndroid Build Coastguard Worker extern FT_INTERPOLATE_LUMA_2X isvc_interpolate_base_luma_dyadic_neon; 248*495ae853SAndroid Build Coastguard Worker extern FT_VERT_INTERPOLATE_CHROMA_2X isvc_vert_interpol_chroma_dyadic_neon; 249*495ae853SAndroid Build Coastguard Worker extern FT_HORZ_INTERPOLATE_CHROMA_2X isvc_horz_interpol_chroma_dyadic_neon; 250*495ae853SAndroid Build Coastguard Worker 251*495ae853SAndroid Build Coastguard Worker #endif 252