/****************************************************************************** * * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ /** ******************************************************************************* * @file * isvcd_process_pslice.h * * @brief * Contains routines that resample for SVC resampling * * @author * Kishore * * @remarks * None * ******************************************************************************* */ #ifndef _ISVCD_RESAMP_SVC_H_ #define _ISVCD_RESAMP_SVC_H_ #include "ih264_typedefs.h" #include "ih264_macros.h" #include "ih264_platform_macros.h" #include "ih264d_structs.h" #define SVCD_FALSE 0 #define SVCD_TRUE 1 #define MAP_BUFF_WIDTH 48 #define MAP_BUFF_HEIGHT 48 #define INTERMEDIATE_BUFF_WIDTH 48 #define INTERMEDIATE_BUFF_HEIGHT (MB_HEIGHT + 4) #define MAX_REF_ARR_WD_HT 48 #define MAX_REF_IDX_ARRAY (MAX_REF_ARR_WD_HT + MB_WIDTH) #define DYADIC_REF_W_Y 20 #define DYADIC_REF_H_Y 20 #define DYADIC_REF_W_C 10 #define DYADIC_REF_H_C 10 #define SUB_BLOCK_WIDTH 4 #define SUB_BLOCK_HEIGHT 4 #define SUB_BLOCK_SIZE (SUB_BLOCK_WIDTH * SUB_BLOCK_HEIGHT) #define BLOCK_WIDTH 8 #define BLOCK_HEIGHT 8 #define BLOCK_SIZE (BLOCK_WIDTH * BLOCK_HEIGHT) #define MB_WIDTH 16 #define MB_HEIGHT 16 #define CLIPUCHAR(x) CLIP3(0, 255, (x)) #define MB_WIDTH_SHIFT 4 #define MB_HEIGHT_SHIFT 4 #define REF_ARRAY_WIDTH 48 #define REF_ARRAY_HEIGHT 48 #define MAX_PIX_FILL_LUMA 4 #define MAX_PIX_FILL_CHROMA 2 typedef void (*pf_vert_interpol_chroma_dyadic)(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf, WORD32 i4_phase_0, WORD32 i4_phase_1); typedef void (*pf_horz_interpol_chroma_dyadic)(WORD16 *pi2_tmp_filt_buf, UWORD8 *pu1_out_buf, WORD32 i4_out_stride, WORD32 i4_phase_0, WORD32 i4_phase_1); typedef struct { void *pv_buffer; /*!< Buffer pointer */ WORD32 i4_element_size; /*!< size of the structure or unit */ WORD32 i4_num_element_stride; /*!< Stride of buffer in terms of number of elements */ } mem_element_t; typedef struct { UWORD8 u1_seg_dim; /*!< describes segment dimension */ UWORD8 u1_seg_off; /*!< describes offset from start */ UWORD8 u1_mb_adjoin; /*!< describes whether mb is adjoining the segment 0 => not adjoining 1 => adjoining */ WORD8 i1_dist_idx; /*!< distance to nearest MB */ WORD8 i1_nearst_mb_bdry; /*!< describes the nearest mb boundary +1 => rightMB/bottomMB -1 => leftMB/topMB */ } seg_description_t; typedef struct { UWORD8 u1_num_segments; /*!< place holder to store the number of segments */ UWORD8 u4_start_pos; /*!< this variable indicates where is start locatiion of the segment with respect to less the block_width or greater than block width */ seg_description_t s_segments[4]; /*!< place holder to store per segment description */ } seg_lookup_desc_t; typedef struct { WORD16 i2_min_pos; /*!< place holder to store the projected MIN referecne position for a MB in current layer. can be used to store either horizontal or vertical positions */ WORD16 i2_max_pos; /*!< place holder to store the projected MAX referecne position for a MB in current layer. can be used to store either horizontal or vertical positions */ } ref_min_max_map_t; typedef struct { WORD16 i2_left; /*!< Horizontal offset of upper left luma sample after resampling process on reference layer with respect to upper left luma sample of current layer. */ WORD16 i2_top; /*!< Vertical offset of upper left luma pixel after resampling process on reference layer */ WORD16 i2_rt; /*!< Horizontal offset of bottom right luma sample after resampling process on reference layer with respect to bottom right luma sample. */ WORD16 i2_bot; /*!< Vertical offset of bottom right luma pixel after resampling process on reference layer */ } ref_lyr_scaled_offset_t; typedef struct { UWORD8 i2_ref_pos; /*!< place holder to store the projected referecne position for a pixel in current layer. can be used to store either horizontal or vertical positions */ UWORD8 i2_phase; /*!< place holder to store the projected phase for a pixel in current layer. can be used to store either horizontal or vertical phase */ } ref_pixel_map_t; typedef struct { WORD16 i2_offset; /*!< place holder to store the projected start point of reference window for each MB in current layer.can be used to store either horizontal or vertical offset */ WORD16 i2_length; /*!< place holder to store reference array length of the reference window for each MB in current layer.can be used to store either horizontal width or vertical height */ } ref_mb_map_t; typedef struct { /* used for mapping purpose */ ref_pixel_map_t *ps_x_pos_phase; /*!< buffers to store the projected referecne X and phase X for each pixel in current layer in horizontal direction */ ref_pixel_map_t *ps_y_pos_phase; /*!< buffers to store the projected referecne Y and phase Y for each pixel in current layer in vertical direction */ ref_mb_map_t *ps_x_offset_length; /*!< buffers to store the projected start point of reference window and reference array width in horizontal direction for each MB in current layer */ ref_mb_map_t *ps_y_offset_length; /*!< buffers to store the projected start point of reference window and reference array height in vertical direction for each MB in current layer */ } residual_samp_map_ctxt_t; typedef struct { residual_samp_map_ctxt_t s_luma_map_ctxt; /*!< map structure for luma projected locations for curr resolution layer */ residual_samp_map_ctxt_t s_chroma_map_ctxt; /*!< map structure for chroma projected locations for curr resolution layer */ WORD32 i4_ref_width; /*!< reference layer width in terms luma samples */ WORD32 i4_ref_height; /*!< reference layer height in terms luma samples */ WORD32 i4_curr_width; /*!< current layer width in terms luma samples */ WORD32 i4_curr_height; /*!< current layer height in terms luma samples */ WORD32 i4_dyadic_flag; /*!< flag to indicate whether the upscaling factor is 2 in both directions /* following variables are for Dyadic cases only */ WORD32 i4_chrm_alt_proc; /*!< Alternate processing for chroma for specific values of phases */ WORD32 i4_chrm_vert_int_mode; /*!< Chroma horizontal interpolation alternate mode */ WORD32 i4_chrm_horz_int_mode; /*!