xref: /aosp_15_r20/external/libavc/decoder/svc/isvcd_intra_resamp.h (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
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  *******************************************************************************
22  * @file
23  *  isvcd_intra_resamp.h
24  *
25  * @brief
26  *  Contains routines that resample for SVC resampling
27  *
28  * @author
29  *  Kishore
30  *
31  * @remarks
32  *  None
33  *
34  *******************************************************************************
35  */
36 
37 #ifndef _ISVCD_INTRA_RESAMPLE_H_
38 #define _ISVCD_INTRA_RESAMPLE_H_
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 SVCD_FALSE 0
46 #define SVCD_TRUE 1
47 
48 #define MAP_BUFF_WIDTH 48
49 #define MAP_BUFF_HEIGHT 48
50 #define INTERMEDIATE_BUFF_WIDTH 48
51 #define INTERMEDIATE_BUFF_HEIGHT (MB_HEIGHT + 4)
52 
53 #define MAX_REF_ARR_WD_HT 48
54 
55 #define MAX_REF_IDX_ARRAY (MAX_REF_ARR_WD_HT + MB_WIDTH)
56 #define DYADIC_REF_W_Y 20
57 #define DYADIC_REF_H_Y 20
58 #define DYADIC_REF_W_C 10
59 #define DYADIC_REF_H_C 10
60 
61 #define SUB_BLOCK_WIDTH 4
62 #define SUB_BLOCK_HEIGHT 4
63 #define SUB_BLOCK_SIZE (SUB_BLOCK_WIDTH * SUB_BLOCK_HEIGHT)
64 #define BLOCK_WIDTH 8
65 #define BLOCK_HEIGHT 8
66 #define BLOCK_SIZE (BLOCK_WIDTH * BLOCK_HEIGHT)
67 #define MB_WIDTH 16
68 #define MB_HEIGHT 16
69 #define CLIPUCHAR(x) CLIP3(0, 255, (x))
70 #define MB_WIDTH_SHIFT 4
71 #define MB_HEIGHT_SHIFT 4
72 
73 #define REF_ARRAY_WIDTH 48
74 #define REF_ARRAY_HEIGHT 48
75 #define MAX_PIX_FILL_LUMA 4
76 #define MAX_PIX_FILL_CHROMA 2
77 
78 extern const WORD8 g_ai1_interp_filter_luma[64];
79 extern const UWORD8 g_au1_interp_filter_chroma[32];
80 extern WORD32 ref_pos_luma[4][16];
81 extern WORD32 ref_pos_chroma[4][8];
82 extern WORD32 phase_luma[3][16];
83 extern UWORD8 phase_luma_u8[3][16];
84 extern WORD8 phase_luma_x86[6][16];
85 extern WORD32 phase_chroma[3][8];
86 extern UWORD8 phase_chroma_u8[3][8];
87 extern UWORD8 ref_pos_luma_mask_m48[8][16];
88 extern UWORD8 ref_pos_luma_mask_m16[8][16];
89 extern UWORD8 ref_pos_luma_mask_m32[8][16];
90 extern UWORD8 ref_pos_chroma_mask_m24[2][16];
91 extern UWORD8 ref_pos_chroma_mask_m8[2][16];
92 extern UWORD8 ref_pos_chroma_mask_m16[2][16];
93 
94 void isvcd_copy_data(UWORD8 *pu1_src, WORD32 i4_src_stride, UWORD8 *pu1_dst, WORD32 i4_dst_stride,
95                      WORD32 i4_num_bytes, WORD32 i4_num_lines);
96 
isvcd_left_most_bit_detect(UWORD32 u4_num)97 static __inline int isvcd_left_most_bit_detect(UWORD32 u4_num)
98 {
99     WORD32 i4_number = 0;
100     if(0xff == u4_num)
101     {
102         return 32;
103     }
104 
105     do
106     {
107         if(0 == (u4_num & 0x80000000))
108         {
109             return i4_number;
110         }
111         u4_num <<= 1;
112         i4_number++;
113     } while(1);
114 }
115 
116 typedef void i264_vert_interpol_chroma_dyadic(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf,
117                                               WORD32 i4_phase_0, WORD32 i4_phase_1);
118 
119 typedef void i264_horz_interpol_chroma_dyadic(WORD16 *pi2_tmp_filt_buf, UWORD8 *pu1_out_buf,
120                                               WORD32 i4_out_stride, WORD32 i4_phase_0,
121                                               WORD32 i4_phase_1);
122 
123 typedef void (*pf_vert_interpol_chroma_dyadic)(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf,
124                                                WORD32 i4_phase_0, WORD32 i4_phase_1);
125 
126 typedef void (*pf_horz_interpol_chroma_dyadic)(WORD16 *pi2_tmp_filt_buf, UWORD8 *pu1_out_buf,
127                                                WORD32 i4_out_stride, WORD32 i4_phase_0,
128                                                WORD32 i4_phase_1);
129 
130 typedef void(ftype_intra_samp_padding)(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index,
131                                        WORD8 i1_yd_index, UWORD8 u1_seg_wd, UWORD8 u1_seg_ht,
132                                        UWORD8 *pu1_refarray_1, UWORD8 *pu1_refarray_2,
133                                        WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x,
134                                        WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available);
135 void isvcd_left_right_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
136                               UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
137                               UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
138                               WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
139                               WORD32 i4_corner_pixel_available);
140 
141 void isvcd_left_right_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
142                                      UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
143                                      UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
144                                      WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
145                                      WORD32 i4_corner_pixel_available);
146 
147 void isvcd_top_bot_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
148                            UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
149                            UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x,
150                            WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available);
151 
152 void isvcd_top_bot_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
153                                   UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
154                                   UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
155                                   WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
156                                   WORD32 i4_corner_pixel_available);
157 
158 void isvcd_diag_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
159                         UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
160                         UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x,
161                         WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available);
162 
163 void isvcd_diag_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
164                                UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
165                                UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
166                                WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
167                                WORD32 i4_corner_pixel_available);
168 
169 void isvcd_diag_reconstruction(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
170                                UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
171                                UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
172                                WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
173                                WORD32 i4_corner_pixel_available);
174 
175 void isvcd_diag_reconstruction_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index,
176                                       WORD8 i1_yd_index, UWORD8 u1_seg_wd, UWORD8 u1_seg_ht,
177                                       UWORD8 *pu1_refarray_1, UWORD8 *pu1_refarray_2,
178                                       WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x,
179                                       WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available);
180 
181 typedef void i264_interpolate_base_luma_dyadic(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf,
182                                                UWORD8 *pu1_out_buf, WORD32 i4_out_stride);
183 
184 typedef void i264_interpolate_intra_base(void *pv_intra_samp_ctxt, UWORD8 *pu1_out,
185                                          WORD32 i4_out_stride, WORD32 i4_refarray_wd,
186                                          WORD32 u2_mb_x, WORD32 u2_mb_y, WORD32 i4_chroma_flag,
187                                          WORD32 i4_refarray_flag);
188 
189 /*C Declarations*/
190 i264_interpolate_base_luma_dyadic isvcd_interpolate_base_luma_dyadic;
191 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_1;
192 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_2;
193 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_3;
194 i264_horz_interpol_chroma_dyadic isvcd_horz_interpol_chroma_dyadic_1;
195 i264_horz_interpol_chroma_dyadic isvcd_horz_interpol_chroma_dyadic_2;
196 
197 /*ARM Declarations*/
198 i264_interpolate_base_luma_dyadic isvcd_interpolate_base_luma_dyadic_neonintr;
199 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_1_neonintr;
200 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_2_neonintr;
201 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_3_neonintr;
202 i264_horz_interpol_chroma_dyadic isvcd_horz_interpol_chroma_dyadic_1_neonintr;
203 i264_horz_interpol_chroma_dyadic isvcd_horz_interpol_chroma_dyadic_2_neonintr;
204 
205 i264_interpolate_intra_base isvcd_interpolate_intra_base;
206 i264_interpolate_intra_base isvcd_interpolate_intra_base_sse42;
207 i264_interpolate_intra_base isvcd_interpolate_intra_base_neonintr;
208 
209 /*x86 Declarations*/
210 i264_interpolate_base_luma_dyadic isvcd_interpolate_base_luma_dyadic_sse42;
211 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_1_sse42;
212 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_2_sse42;
213 i264_vert_interpol_chroma_dyadic isvcd_vert_interpol_chroma_dyadic_3_sse42;
214 i264_horz_interpol_chroma_dyadic isvcd_horz_interpol_chroma_dyadic_1_sse42;
215 i264_horz_interpol_chroma_dyadic isvcd_horz_interpol_chroma_dyadic_2_sse42;
216 
217 typedef struct
218 {
219     UWORD16 u2_mb_x; /*!< MB X of the MB which has to
220                           be processed
221                       */
222     UWORD16 u2_mb_y; /*!< MB Y of the MB which has to
223                           be processed
224                       */
225 } mb_coord_t;
226 
227 typedef struct
228 {
229     void *pv_buffer;              /*!< Buffer pointer */
230     WORD32 i4_element_size;       /*!< size of the structure or unit */
231     WORD32 i4_num_element_stride; /*!< Stride of buffer in terms of number
232                                    of elements.                                 */
233 } mem_element_t;
234 
235 typedef struct
236 {
237     void *pv_buffer1;             /*!< Buffer pointer */
238     void *pv_buffer2;             /*!< Buffer pointer */
239     WORD32 i4_element_size;       /*!< size of the structure or unit */
240     WORD32 i4_num_element_stride; /*!< Stride of buffer in terms of number
241                                    of elements.
242                                */
243 } mem_element_2_t;
244 typedef struct
245 {
246     UWORD8 u1_seg_dim;       /*!< describes segment dimension */
247     UWORD8 u1_seg_off;       /*!< describes offset from start */
248     UWORD8 u1_mb_adjoin;     /*!< describes whether mb is adjoining
249                                  the segment 0 => not adjoining
250                                              1 => adjoining    */
251 
252     WORD8 i1_dist_idx;       /*!< distance to nearest MB */
253 
254     WORD8 i1_nearst_mb_bdry; /*!< describes the nearest mb boundary
255                                  +1 => rightMB/bottomMB
256                                  -1 => leftMB/topMB    */
257 } seg_description_t;
258 
259 typedef struct
260 {
261     UWORD8 u1_num_segments;          /*!< place holder to store the number of
262                                      segments */
263 
264     UWORD8 u4_start_pos;             /*!< this variable indicates where is
265                                       start locatiion of the segment with
266                                       respect to less the block_width or
267                                       greater than block width            */
268 
269     seg_description_t s_segments[4]; /*!< place holder to store per segment
270                                            description    */
271 } seg_lookup_desc_t;
272 typedef struct
273 {
274     WORD16 i2_min_pos; /*!< place holder to store the projected
275                            MIN referecne position for a MB in
276                            current layer. can be used to store
277                            either horizontal or vertical positions
278                        */
279     WORD16 i2_max_pos; /*!< place holder to store the projected
280                            MAX referecne position for a MB in
281                            current layer. can be used to store
282                            either horizontal or vertical positions
283                                   */
284 } ref_min_max_map_t;
285 
286 typedef struct
287 {
288     WORD16 i2_left; /*!< Horizontal offset of upper left luma sample
289                        after resampling process on reference
290                        layer with respect to upper left luma
291                        sample of current layer.
292                    */
293     WORD16 i2_top;  /*!< Vertical offset of upper left luma pixel
294                        after resampling process on reference
295                        layer
296                    */
297     WORD16 i2_rt;   /*!< Horizontal offset of bottom right luma
298                        sample after resampling process on
299                        reference layer with respect to bottom
300                        right luma sample.
301                    */
302     WORD16 i2_bot;  /*!< Vertical offset of bottom right luma
303                        pixel after resampling process on
304                        reference layer
305                    */
306 } ref_lyr_scaled_offset_t;
307 
308 typedef struct
309 {
310     UWORD8 i2_ref_pos; /*!<  place holder to store the projected
311                              referecne position for a pixel in
312                              current layer. can be used to store
313                              either horizontal or vertical positions
314                         */
315     UWORD8 i2_phase;   /*!<  place holder to store the projected
316                              phase for a pixel in current layer.
317                              can be used to store either
318                              horizontal or vertical phase
319                         */
320 } ref_pixel_map_t;
321 
322 typedef struct
323 {
324     WORD16 i2_offset; /*!<  place holder to store the projected
325                             start point of reference window
326                             for each MB in current layer.can be
327                             used to store either horizontal or
328                             vertical offset
329                        */
330     WORD16 i2_length; /*!<  place holder to store reference array
331                             length of the reference window
332                             for each MB in current layer.can be
333                             used to store either horizontal width
334                             or vertical height
335                        */
336 } ref_mb_map_t;
337 
338 typedef struct
339 {
340     WORD32 i4_res_width;                             /*!< Frame width of top most layer in the
341                                                           resolution. It's expressed in terms
342                                                           of luma samples.
343                                                       */
344     WORD32 i4_res_height;                            /*!< Frame height of top most layer in the
345                                                           resolution. It's expressed in terms
346                                                           of luma samples.
347                                                       */
348     ref_lyr_scaled_offset_t s_ref_lyr_scaled_offset; /*!< Scaled offset
349                                       parameters of reference layer considering
350                                       bottom most layer of the resolution as
351                                       current layer. Offsets are with respect
352                                       to upper left luma samples in top most
353                                       layer in the resolution.
354                                   */
355     UWORD16 u2_scaled_ref_width;                     /*!< Considering bottom most layer of the
356                                                        resolution as current layer, scaled
357                                                        width of reference layer in terms of
358                                                        luma pixels. It's inferred parameter
359                                                        based on reference layer offsets.
360                                                    */
361     UWORD16 u2_scaled_ref_height;                    /*!< Considering bottom most layer of the
362                                                       resolution as current layer, scaled
363                                                       height of reference layer in terms of
364                                                       luma pixels. It's inferred parameter
365                                                       based on reference layer offsets.
366                                                    */
367     UWORD8 u1_rstrct_res_change_flag;                /*!< restrictedResolutionChangeFlag for
368                                                   bottom most layer of the resolution. It's
369                                                   a inferred parameter.
370                                                */
371     UWORD8 u1_cropping_change_flag;                  /*!< croppingChangeFlag for bottom most
372                                                     layer of the resolution. It's a inferred
373                                                     parameter.
374                                                  */
375     UWORD8 u1_disable_inter_lyr_dblk_filter_idc;     /*!< Mode of operation for
376                                          inter layer de-blocking. It shall be
377                                          set for bottom most layer of the top
378                                          resolution. By top resolution, it
379                                          referes to the resolution just above
380                                          the current spatial resolution. This
381                                          shall be valid for all resolutions
382                                          except target resolution.
383                                      */
384     WORD8 i1_inter_lyr_alpha_c0_offset;              /*!< specifies the offset used in
385                                                 accessing the alpha and tC0 deblocking
386                                                 filter tables for filtering operations
387                                                 in inter layer de-blocking. Applicable
388                                                 for bottom most layer of the top
389                                                 resolution. By top resolution, it referes
390                                                 to the resolution just above the current
391                                                 spatial resolution. This shall be valid
392                                                 for resolutions except target resolution.
393                                             */
394     WORD8 i1_inter_lyr_beta_offset;                  /*!< specifies the offset used in
395                                                     accessing the beta deblocking filter table
396                                                     for filtering operations in inter layer
397                                                     de-blocking. Applicable for bottom most
398                                                     layer of the top resolution. By top
399                                                     resolution, it referes to the resolution
400                                                     just above the current spatial resolution.
401                                                     This shall be valid for resolutions
402                                                     except target resolution.
403                                                 */
404     WORD8 i1_constrained_intra_rsmpl_flag;           /*!< Constrained intra resampling
405                                              flag. Range is [0,1].
406                                          */
407     WORD8 i1_ref_lyr_chroma_phase_x_plus1_flag;      /*!< specifies the horizontal
408                                          phase shift of the chroma components in
409                                         units of half luma samples of a layer
410                                         frame for the layer pictures that may be
411                                         used for inter-layer prediction
412                                     */
413 
414     WORD8 i1_ref_lyr_chroma_phase_y_plus1;           /*!< specifies the vertical phase
415                                               shift of the chroma components in units of
416                                               half luma samples of a layer frame for the
417                                               layer pictures that may be used for
418                                              inter-layer prediction
419                                          */
420     UWORD8 u1_direct_8x8_inference_flag;             /*!< Direct 8x8 inference flag
421                                                       . Range is [0,1].
422                                             */
423 
424     UWORD8 u1_remap_req_flag;                        /*!< this flag signifies to the
425                                                           upsampling modules whether the Map
426                                                           buffers have to recomputed for current
427                                                           access unit or to retain the previous
428                                                           access units values
429                                                           */
430     UWORD8 u1_dyadic_flag;                           /*!< this flag signifies the scaling
431                                                           ratios are 2 in both directions
432                                                           and the cropping is MB aligned
433                                                         */
434 } res_prms_t;
435 
436 typedef struct
437 {
438     ref_pixel_map_t *ps_x_pos_phase;  /*!< buffers to store the projected
439                                          referecne X and phase X for each
440                                          pixel in current layer in
441                                          horizontal direction
442                                       */
443     ref_pixel_map_t *ps_y_pos_phase;  /*!< buffers to store the projected
444                                          referecne Y and phase Y for each
445                                          pixel in current layer in
446                                          vertical direction
447                                       */
448     ref_mb_map_t *ps_x_offset_length; /*!< buffers to store the projected
449                                       start point of reference window and
450                                       reference array  width in
451                                       horizontal direction for each MB in
452                                       current layer
453                                   */
454     ref_mb_map_t *ps_y_offset_length; /*!< buffers to store the projected
455                                       start point of reference window and
456                                       reference array  height in
457                                       vertical direction for each MB in
458                                       current layer
459                                   */
460     ref_min_max_map_t *ps_x_min_max;
461     /*!< Buffer to store the projected
462                                            MIN and MAX referecne position for a
463                                            MB in current layer in
464                                            horizontal direction
465                                        */
466 
467     ref_min_max_map_t *ps_y_min_max;
468     /*!< Buffer to store the projected
469                                            MIN and MAX referecne position for a
470                                            MB in current layer in
471                                            Vertical direction
472                                        */
473 
474     WORD16 *pi2_xd_index;                  /*!< buffers to store the projected
475                                                  XD for each pixel in an MB
476                                             */
477     WORD16 *pi2_yd_index;                  /*!< buffers to store the projected
478                                                 YD for each pixel in an MB
479                                             */
480     WORD16 *pi2_ya_index;                  /*!< buffers to store the projected
481                                                 YA for each pixel in an MB
482                                           */
483 
484     seg_lookup_desc_t *ps_seg_lookup_horz; /*!< buffers to store lookup for
485                                           horizontal segment description  */
486 
487     seg_lookup_desc_t *ps_seg_lookup_vert; /*!< buffers to store lookup for
488                                           vertical segment description  */
489 
490     UWORD8 *pu1_refarray_x_idx;            /*!< buffers to store lookup for
491                                           x indexes to get availability
492                                            from 4x4 availability grid */
493 
494     UWORD8 *pu1_refarray_y_idx;            /*!< buffers to store lookup for
495                                           y indexes to get availability
496                                            from 4x4 availability grid */
497 } intra_samp_map_ctxt_t;
498 
499 typedef struct
500 {
501     intra_samp_map_ctxt_t s_luma_map_ctxt;   /*!< map structure for luma
502                                                 projected locations
503                                                 for curr resolution layer
504                                               */
505     intra_samp_map_ctxt_t s_chroma_map_ctxt; /*!< map structure for chroma
506                                                 projected locations
507                                                 for curr resolution layer
508                                               */
509     WORD32 i4_ref_width;                     /*!< reference layer width in
510                                                   terms luma samples
511                                               */
512     WORD32 i4_ref_height;                    /*!< reference layer height in
513                                                   terms luma samples
514                                               */
515     WORD32 i4_curr_width;                    /*!< current layer width in
516                                                  terms luma samples
517                                              */
518     WORD32 i4_curr_height;                   /*!< current layer height in
519                                                  terms luma samples
520                                              */
521     WORD8 i1_constrained_intra_rsmpl_flag;   /*!< Constrained intra resampling
522                                                   flag. Range is [0,1].
523                                               */
524     WORD32 i4_x_phase_0;                     /*!< Chroma xPhase for even
525                                           values of x for dyadic cases
526                                           */
527     WORD32 i4_x_phase_1;                     /*!< Chroma xPhase for odd
528                                           values of x for dyadic cases
529                                           */
530     WORD32 i4_y_phase_0;                     /*!< Chroma yPhase for even
531                                           values of y for dyadic cases
532                                           */
533     WORD32 i4_y_phase_1;                     /*!< Chroma yPhase for odd
534                                           values of y for dyadic cases
535                                           */
536 
537     pf_vert_interpol_chroma_dyadic pf_vert_chroma_interpol;
538     /*!< Vertical interpolation
539     function for chroma
540     */
541     pf_horz_interpol_chroma_dyadic pf_horz_chroma_interpol;
542     /*!< Horizontal interpolation
543     function for chroma
544     */
545 } intra_samp_lyr_ctxt;
546 typedef struct
547 {
548     intra_samp_lyr_ctxt as_res_lyrs[MAX_NUM_RES_LYRS]; /*!< Array of resolution
549                                                   layer ctxt.
550                                                   The first strcuture in the
551                                                   array will be used for storing
552                                                   the "second resolution" map in
553                                                   an access unit w.r.t to its
554                                                   base resolution, and for base
555                                                   resolution nothing will be
556                                                   computed or stored
557                                               */
558     void *ps_sps;                                      /*!< pointer to array of SPS
559                                                         */
560 
561     UWORD8 *pu1_refarray_buffer;                       /*!< buffer to store the reference
562                                                            layer data before intra
563                                                            sampling
564                                                       */
565     UWORD8 *pu1_refarray_cb;                           /*!< buffer to hold the reference
566                                                          layer Cb data before intra
567                                                          resampling (used for dyadic
568                                                          cases only)
569                                                     */
570     UWORD8 *pu1_refarray_cr;                           /*!< buffer to hold the reference
571                                                          layer Cr data before intra
572                                                          resampling (used for dyadic
573                                                          cases only)
574                                                     */
575     WORD32 *pi4_temp_interpolation_buffer;             /*!< intermideate buffer
576                                                 for interpolation
577                                            */
578 
579     WORD32 i4_res_lyr_id;                              /*!< resolution id of the layer
580                                                             which is to be processed
581                                                         */
582     WORD32 i4_ref_width;                               /*!< reference layer width in
583                                                         terms luma samples
584                                                        */
585 
586     WORD32 i4_refarray_stride;                         /*!< reference layer width in
587                                                        terms luma samples
588                                                        */
589 
590     WORD32 i4_ref_height;                              /*!< reference layer height in
591                                                        terms luma samples
592                                                         */
593     res_prms_t *ps_res_prms;                           /*!< Current resolution params
594                                                         */
595 
596     i264_interpolate_base_luma_dyadic *pf_interpolate_base_luma_dyadic;
597     i264_interpolate_intra_base *pf_interpolate_intra_base;
598 
599     /*!< Vertical interpolation
600     function for chroma
601     */
602     i264_vert_interpol_chroma_dyadic *pf_vert_chroma_interpol[3];
603 
604     /*!< Horizontal interpolation
605     function for chroma
606     */
607     i264_horz_interpol_chroma_dyadic *pf_horz_chroma_interpol[2];
608 
609 } intra_sampling_ctxt_t;
610 
611 WORD32 isvcd_get_ceil_log2(WORD32 i4_x);
612 
613 void isvcd_2d_memset(void *pv_buf, WORD32 i4_width, WORD32 i4_ht, WORD32 i4_stride, WORD32 i4_val);
614 
615 WORD32 isvcd_intra_resamp_mb(void *pv_intra_samp_ctxt, mem_element_t *ps_ref_luma,
616                              mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode_map,
617                              mem_element_t *ps_curr_luma, mem_element_t *ps_curr_chroma,
618                              mb_coord_t *ps_mb_coord);
619 
620 WORD32 isvcd_intra_resamp_mb_dyadic(void *pv_intra_samp_ctxt, mem_element_t *ps_ref_luma,
621                                     mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode_map,
622                                     mem_element_t *ps_curr_luma, mem_element_t *ps_curr_chroma,
623                                     mb_coord_t *ps_mb_coord, void *ps_svc_dec);
624 
625 WORD32 isvcd_populate_res_prms(void *ps_svc_dec);
626 
627 void isvcd_crop_wnd_flag_res_int(void *ps_svc_dec);
628 
629 WORD32 isvcd_intra_resamp_res_init(void *ps_svc_dec);
630 
631 void isvcd_intra_resamp_res_init_update_flags(void *ps_svc_dec);
632 
633 #endif /* _ISVCD_INTRA_RESAMPLE_H_ */
634