Coverage Report

Created: 2026-10-17 07:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavc/decoder/svc/isvcd_intra_resamp.c
Line
Count
Source
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.c
24
 *
25
 * @brief
26
 *  Contains routines that resample for SVC resampling
27
 *
28
 * @author
29
 *  Kishore
30
 *
31
 * @par List of Functions:
32
 *  - isvcd_get_ceil_log2()
33
 *  - isvcd_2d_memset()
34
 *  - isvcd_copy_data()
35
 *  - isvcd_copy_data_semiplanr()
36
 *  - isvcd_get_ref_layer_avlblty_dyadic()
37
 *  - isvcd_diagonal_construct_dyadic()
38
 *  - isvcd_left_right_padding()
39
 *  - isvcd_left_right_padding_chroma()
40
 *  - isvcd_top_bot_padding()
41
 *  - isvcd_top_bot_padding_chroma()
42
 *  - isvcd_diag_reconstruction()
43
 *  - isvcd_diag_reconstruction_chroma()
44
 *  - isvcd_diag_padding()
45
 *  - isvcd_diag_padding_chroma()
46
 *  - isvcd_corner_samp_dyadic()
47
 *  - isvcd_fill_non_avail_pixel()
48
 *  - isvcd_get_ref_layer_mbtype()
49
 *  - isvcd_reflayer_construction()
50
 *  - isvcd_reflayer_construction_dyadic()
51
 *  - isvcd_interpolate_base_luma_dyadic()
52
 *  - isvcd_vert_interpol_chroma_dyadic_1()
53
 *  - isvcd_vert_interpol_chroma_dyadic_2()
54
 *  - isvcd_vert_interpol_chroma_dyadic_3()
55
 *  - isvcd_horz_interpol_chroma_dyadic_1()
56
 *  - isvcd_horz_interpol_chroma_dyadic_2()
57
 *  - isvcd_intra_resamp_mb_dyadic()
58
 *  - isvcd_interpolate_intra_base()
59
 *  - isvcd_intra_resamp_mb()
60
 *  - isvcd_intra_resamp_generate_segment_lookup()
61
 *  - isvcd_intra_resamp_populate_list()
62
 *  - isvcd_populate_res_prms()
63
 *  - isvcd_crop_wnd_flag_res_int()
64
 *  - isvcd_intra_resamp_res_init()
65
 *
66
 * @remarks
67
 *  None
68
 *
69
 *******************************************************************************
70
 */
71
72
#include <assert.h>
73
#include <string.h>
74
75
#include "ih264_typedefs.h"
76
#include "ih264_macros.h"
77
#include "ih264_platform_macros.h"
78
#include "ih264d_bitstrm.h"
79
#include "ih264d_defs.h"
80
#include "ih264d_debug.h"
81
#include "isvcd_structs.h"
82
#include "ih264d_parse_cavlc.h"
83
#include "ih264d_mb_utils.h"
84
#include "ih264d_deblocking.h"
85
#include "ih264d_dpb_manager.h"
86
#include "ih264d_mvpred.h"
87
#include "ih264d_inter_pred.h"
88
#include "ih264d_process_pslice.h"
89
#include "ih264d_error_handler.h"
90
#include "ih264d_cabac.h"
91
#include "ih264d_tables.h"
92
#include "ih264d_parse_slice.h"
93
#include "ih264d_utils.h"
94
#include "ih264d_parse_islice.h"
95
#include "ih264d_process_bslice.h"
96
#include "ih264d_process_intra_mb.h"
97
#include "ih264_debug.h"
98
99
ftype_intra_samp_padding *gpf_lookup_fxns_luma[32] = {
100
    NULL,
101
    NULL,
102
    NULL,
103
    NULL,
104
    NULL,
105
    NULL,
106
    NULL,
107
    NULL,
108
    NULL,
109
    &isvcd_left_right_padding,
110
    NULL,
111
    &isvcd_diag_reconstruction,
112
    NULL,
113
    &isvcd_left_right_padding,
114
    NULL,
115
    &isvcd_diag_reconstruction,
116
    NULL,
117
    NULL,
118
    &isvcd_top_bot_padding,
119
    &isvcd_diag_reconstruction,
120
    NULL,
121
    NULL,
122
    &isvcd_top_bot_padding,
123
    &isvcd_diag_reconstruction,
124
    NULL,
125
    &isvcd_left_right_padding,
126
    &isvcd_top_bot_padding,
127
    &isvcd_diag_reconstruction,
128
    &isvcd_diag_padding,
129
    &isvcd_left_right_padding,
130
    &isvcd_top_bot_padding,
131
    &isvcd_diag_reconstruction,
132
};
133
134
ftype_intra_samp_padding *gpf_lookup_fxns_chroma[32] = {
135
    NULL,
136
    NULL,
137
    NULL,
138
    NULL,
139
    NULL,
140
    NULL,
141
    NULL,
142
    NULL,
143
    NULL,
144
    &isvcd_left_right_padding_chroma,
145
    NULL,
146
    &isvcd_diag_reconstruction_chroma,
147
    NULL,
148
    &isvcd_left_right_padding_chroma,
149
    NULL,
150
    &isvcd_diag_reconstruction_chroma,
151
    NULL,
152
    NULL,
153
    &isvcd_top_bot_padding_chroma,
154
    &isvcd_diag_reconstruction_chroma,
155
    NULL,
156
    NULL,
157
    &isvcd_top_bot_padding_chroma,
158
    &isvcd_diag_reconstruction_chroma,
159
    NULL,
160
    &isvcd_left_right_padding_chroma,
161
    &isvcd_top_bot_padding_chroma,
162
    &isvcd_diag_reconstruction_chroma,
163
    &isvcd_diag_padding_chroma,
164
    &isvcd_left_right_padding_chroma,
165
    &isvcd_top_bot_padding_chroma,
166
    &isvcd_diag_reconstruction_chroma,
167
};
168
169
const UWORD32 gu4_valid_segs_lookup[16] = {
170
    0x0F000000, 0xCF000000, 0x3F000000, 0xFF000000, 0x0F000000, 0xCF000000, 0x3F000000, 0xFF000000,
171
    0x0F000000, 0x8F000000, 0x6F000000, 0xEF000000, 0x1F000000, 0x9F000000, 0x7F000000, 0xFF000000};
172
173
const WORD8 g_ai1_interp_filter_luma[64] = {
174
    0,  -1, -2, -3, -3, -4, -4, -3, -3, -3, -2, -1, -1, -1, -1, -1, 32, 32, 31, 30, 28, 26,
175
    24, 22, 19, 16, 14, 11, 8,  6,  4,  2,  0,  2,  4,  6,  8,  11, 14, 16, 19, 22, 24, 26,
176
    28, 30, 31, 32, 0,  -1, -1, -1, -1, -1, -2, -3, -3, -3, -4, -4, -3, -3, -2, -1};
177
178
const UWORD8 g_au1_interp_filter_chroma[32] = {32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12,
179
                                               10, 8,  6,  4,  2,  0,  2,  4,  6,  8,  10,
180
                                               12, 14, 16, 18, 20, 22, 24, 26, 28, 30};
181
182
WORD32 ref_pos_luma[4][16] = {{10, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20},
183
                              {10, 10, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20},
184
                              {2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12},
185
                              {2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12}};
186
WORD32 ref_pos_chroma[4][8] = {{6, 7, 8, 8, 9, 10, 10, 11},
187
                               {6, 7, 7, 8, 9, 9, 10, 11},
188
                               {6, 6, 7, 8, 8, 9, 10, 10},
189
                               {2, 3, 4, 4, 5, 6, 6, 7}};
190
191
WORD32 phase_luma[3][16] = {{13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13},
192
                            {8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8},
193
                            {3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3}};
194
195
UWORD8 phase_luma_u8[3][16] = {{13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13},
196
                               {8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8},
197
                               {3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3, 13, 8, 3}};
198
199
WORD8 phase_luma_x86[6][16] = {{13, 8, 3, 13, 8, 3, 13, 8, 0, 0, 0, 0, 0, 0, 0, 0},
200
                               {3, 13, 8, 3, 13, 8, 3, 13, 0, 0, 0, 0, 0, 0, 0, 0},
201
                               {8, 3, 13, 8, 3, 13, 8, 3, 0, 0, 0, 0, 0, 0, 0, 0},
202
                               {13, 8, 3, 13, 8, 3, 13, 8, 0, 0, 0, 0, 0, 0, 0, 0},
203
                               {3, 13, 8, 3, 13, 8, 3, 13, 0, 0, 0, 0, 0, 0, 0, 0},
204
                               {8, 3, 13, 8, 3, 13, 8, 3, 0, 0, 0, 0, 0, 0, 0, 0}};
205
206
WORD32 phase_chroma[3][8] = {
207
    {13, 8, 3, 13, 8, 3, 13, 8}, {3, 13, 8, 3, 13, 8, 3, 13}, {8, 3, 13, 8, 3, 13, 8, 3}};
208
209
UWORD8 phase_chroma_u8[3][8] = {
210
    {13, 8, 3, 13, 8, 3, 13, 8}, {3, 13, 8, 3, 13, 8, 3, 13}, {8, 3, 13, 8, 3, 13, 8, 3}};
211
212
UWORD8 ref_pos_luma_mask_m48[8][16] = {{0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11},
213
                                       {2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11},
214
                                       {2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13},
215
                                       {4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13},
216
                                       {4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15},
217
                                       {6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15, 14, 15},
218
                                       {0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11},
219
                                       {4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13}};
220
221
UWORD8 ref_pos_luma_mask_m16[8][16] = {{0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11},
222
                                       {0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11},
223
                                       {2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13},
224
                                       {2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13},
225
                                       {4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15},
226
                                       {4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15},
227
                                       {0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11},
228
                                       {2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13}};
229
230
UWORD8 ref_pos_luma_mask_m32[8][16] = {{0, 1, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9},
231
                                       {0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11},
232
                                       {2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11},
233
                                       {2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13},
234
                                       {4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13},
235
                                       {4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15},
236
                                       {0, 1, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9},
237
                                       {2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13}};
238
239
UWORD8 ref_pos_chroma_mask_m24[2][16] = {{0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11},
240
                                         {2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11, 12, 13}};
241
UWORD8 ref_pos_chroma_mask_m8[2][16] = {{0, 1, 0, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9},
242
                                        {2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11, 10, 11}};
243
UWORD8 ref_pos_chroma_mask_m16[2][16] = {{0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 11},
244
                                         {2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13}};
245
246
/*****************************************************************************/
247
/*                                                                           */
248
/*  Function Name :  isvcd_get_ceil_log2                                      */
249
/*                                                                           */
250
/*  Description   : this function returns the CeilLog2 of the given number   */
251
/*                                                                           */
252
/*                                                                           */
253
/*  Inputs        : i4_input : input number                                  */
254
/*  Globals       : none                                                     */
255
/*  Processing    : it calculate the bits and returns it                     */
256
/*                                                                           */
257
/*  Outputs       : none                                                     */
258
/*  Returns       : ceil of log to base 2                                    */
259
/*                                                                           */
260
/*  Issues        : none                                                     */
261
/*                                                                           */
262
/*  Revision History:                                                        */
263
/*                                                                           */
264
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
265
/*         06 09 2021   vijayakumar          creation                        */
266
/*                                                                           */
267
/*****************************************************************************/
268
WORD32 isvcd_get_ceil_log2(WORD32 i4_input)
269
0
{
270
0
    WORD32 i4_bits = 0;
271
272
0
    i4_input--;
273
0
    while(i4_input > 0)
274
0
    {
275
0
        i4_bits++;
276
0
        i4_input >>= 1;
277
0
    }
278
0
    return (i4_bits);
279
0
}
280
281
/*****************************************************************************/
282
/*                                                                           */
283
/*  Function Name : isvcd_2d_memset                                           */
284
/*                                                                           */
285
/*  Description   : Function performs 2D memset operation                    */
286
/*                                                                           */
287
/*                                                                           */
288
/*  Inputs        : 1. Buffer pointer                                        */
289
/*                  2. width                                                 */
290
/*                  3. Height                                                */
291
/*                  4. Stride                                                */
292
/*                  5. value                                                 */
293
/*  Globals       : None                                                     */
294
/*  Processing    : calls memset fucntion                                    */
295
/*                                                                           */
296
/*  Outputs       : Updates the buffer                                       */
297
/*  Returns       : status                                                   */
298
/*                                                                           */
299
/*  Issues        : None                                                     */
300
/*                                                                           */
301
/*  Revision History:                                                        */
302
/*                                                                           */
303
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
304
/*         24 09 2021   Vijay           Draft                                */
305
/*                                                                           */
306
/*****************************************************************************/
307
void isvcd_2d_memset(void *pv_buf, WORD32 i4_width, WORD32 i4_ht, WORD32 i4_stride, WORD32 i4_val)
308
0
{
309
0
    WORD32 i4_y;
310
0
    UWORD8 *pu1_buf;
311
312
0
    pu1_buf = (UWORD8 *) pv_buf;
313
314
0
    for(i4_y = 0; i4_y < i4_ht; i4_y++)
315
0
    {
316
0
        memset(pu1_buf, i4_val, i4_width);
317
        /* Increment the pointer */
318
0
        pu1_buf += i4_stride;
319
0
    }
320
0
}
321
322
/*****************************************************************************/
323
/*                                                                           */
324
/*  Function Name : isvcd_copy_data                                           */
325
/*                                                                           */
326
/*  Description   : this module copies the data from source to destination   */
327
/*                  the amount of data to be copied is passed as input       */
328
/*                                                                           */
329
/*  Inputs        : pu1_src : pointer to the source buffer                   */
330
/*                  u2_src_stride : source buffer stride                     */
331
/*                  pu1_dst : pointer to the destination buffer              */
332
/*                  u2_dst_stride : destination buffer stride                */
333
/*                  u4_num_bytes : number of bytes to be copied              */
334
/*                  u4_num_lines : number of lines to be copied              */
335
/*  Globals       : none                                                     */
336
/*  Processing    : it does a memcpy from source to destination              */
337
/*                                                                           */
338
/*  Outputs       : none                                                     */
339
/*  Returns       : none                                                     */
340
/*  Issues        : both buffers are assumed to be 2-D buffers               */
341
/*                                                                           */
342
/*  Revision History:                                                        */
343
/*                                                                           */
344
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
345
/*         29 09 2021   vijayakumar          creation                        */
346
/*                                                                           */
347
/*****************************************************************************/
348
void isvcd_copy_data(UWORD8 *pu1_src, WORD32 i4_src_stride, UWORD8 *pu1_dst, WORD32 i4_dst_stride,
349
                     WORD32 i4_num_bytes, WORD32 i4_num_lines)
350
1.61k
{
351
1.61k
    WORD32 i4_vert_lines;
352
353
    /* loop for copy all the lines requried */
354
17.2k
    for(i4_vert_lines = 0; i4_vert_lines < i4_num_lines; i4_vert_lines++)
355
15.6k
    {
356
15.6k
        memcpy(pu1_dst, pu1_src, i4_num_bytes);
357
15.6k
        pu1_src += i4_src_stride;
358
15.6k
        pu1_dst += i4_dst_stride;
359
15.6k
    }
360
1.61k
    return;
361
1.61k
}
362
363
/*****************************************************************************/
364
/*                                                                           */
365
/*  Function Name : isvcd_copy_data_semiplanr                                 */
366
/*                                                                           */
367
/*  Description   : this module copies the data from source to destination   */
368
/*                  the amount of data to be copied is passed as input       */
369
/*                                                                           */
370
/*  Inputs        : pu1_src : pointer to the source buffer                   */
371
/*                  i4_src_stride : source buffer stride                     */
372
/*                  pu1_dst1 : pointer to the destination buffer 1           */
373
/*                  pu1_dst2 : pointer to the destination buffer 2           */
374
/*                  i4_dst_stride : destination buffer stride                */
375
/*                  i4_num_bytes : number of bytes to be copied              */
376
/*                  i4_num_lines : number of lines to be copied              */
377
/*  Globals       : none                                                     */
378
/*  Processing    : it does a memcpy from source to destination              */
379
/*                                                                           */
380
/*  Outputs       : none                                                     */
381
/*  Returns       : none                                                     */
382
/*  Issues        : both buffers are assumed to be 2-D buffers               */
383
/*                                                                           */
384
/*  Revision History:                                                        */
385
/*                                                                           */
386
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
387
/*         29 09 2021   vijayakumar          creation                        */
388
/*                                                                           */
389
/*****************************************************************************/
390
void isvcd_copy_data_semiplanr(UWORD8 *pu1_src, WORD32 i4_src_stride, UWORD8 *pu1_dst1,
391
                               UWORD8 *pu1_dst2, WORD32 i4_dst_stride, WORD32 i4_num_bytes,
392
                               WORD32 i4_num_lines)
393
421
{
394
421
    WORD32 i4_vert_lines, u4_i;
395
396
    /* loop for copy all the lines requried */
397
6.87k
    for(i4_vert_lines = 0; i4_vert_lines < i4_num_lines; i4_vert_lines++)
398
6.45k
    {
399
96.0k
        for(u4_i = 0; u4_i < i4_num_bytes; u4_i++)
400
89.6k
        {
401
89.6k
            *(pu1_dst1 + u4_i) = *(pu1_src + (2 * u4_i));
402
89.6k
            *(pu1_dst2 + u4_i) = *(pu1_src + (2 * u4_i) + 1);
403
89.6k
        }
404
405
6.45k
        pu1_src += i4_src_stride;
406
6.45k
        pu1_dst1 += i4_dst_stride;
407
6.45k
        pu1_dst2 += i4_dst_stride;
408
6.45k
    }
409
421
    return;
410
421
}
411
412
/*****************************************************************************/
413
/*                                                                           */
414
/*  Function Name : isvcd_get_ref_layer_avlblty_dyadic                        */
415
/*                                                                           */
416
/*  Description   : This function is used to find the mb type of the         */
417
/*                  corresponding MB in the reference layer for dyadic cases */
418
/*                                                                           */
419
/*  Inputs        : pv_intra_samp_ctxt : intra samp context                  */
420
/*                  pi1_ref_mb_modes : ref mb modes buffer pointer           */
421
/*                  i4_ref_mode_stride : mb mode buffer stride               */
422
/*                  i4_ref_mb_x : reference MB location X                    */
423
/*                  i4_ref_mb_y : reference MB location Y                    */
424
/*                  pi4_mb_type : pointer to store the mb type               */
425
/*                  i1_curr_slice_id : slice id of current MB                */
426
/*                  i1_cons_intr_samp_flag :constrained intra resampling flag*/
427
/*  Globals       : none                                                     */
428
/*  Processing    : it derives the bit corresponding to reference MB and     */
429
/*                  stores the mbtype as INTRA if the bit is set             */
430
/*  Outputs       : none                                                     */
431
/*  Returns       : none                                                     */
432
/*                                                                           */
433
/*  Issues        : none                                                     */
434
/*                                                                           */
435
/*  Revision History:                                                        */
436
/*                                                                           */
437
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
438
/*         26 09 2021   vijayakumar          creation                        */
439
/*                                                                           */
440
/*****************************************************************************/
441
void isvcd_get_ref_layer_avlblty_dyadic(WORD8 *pi1_ref_mb_modes, WORD32 i4_ref_mode_stride,
442
                                        WORD32 i4_element_size, WORD32 i4_ref_mb_x,
443
                                        WORD32 i4_ref_mb_y, WORD32 *pi4_avlblty,
444
                                        WORD8 i1_curr_slice_id, WORD8 i1_cons_intr_samp_flag)
445
0
{
446
0
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
447
0
    WORD8 i1_mb_mode;
448
449
    /* get the location of the byte which has the current mb mode */
450
0
    pi1_ref_mb_modes += (i4_ref_mb_y * i4_ref_mode_stride * i4_element_size);
451
0
    pi1_ref_mb_modes += (i4_ref_mb_x * i4_element_size);
452
0
    ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes;
453
0
    i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode;
454
455
0
    if(i1_mb_mode <= SVC_INTER_MB)
456
0
    {
457
        /* INTER */
458
0
        *pi4_avlblty = 0;
459
0
    }
460
0
    else
461
0
    {
462
        /* INTRA */
463
0
        *pi4_avlblty = 1;
464
0
    }
465
466
    /* if constrained intra flag is 1 then check for same slice id */
467
0
    if(1 == i1_cons_intr_samp_flag)
468
0
    {
469
0
        if(1 == *pi4_avlblty)
470
0
        {
471
            /* check for different slice idc */
472
0
            if(ps_inter_lyr_mb_prms->i1_slice_id != i1_curr_slice_id)
473
0
            {
474
                /* store the mode as not available for upsampling */
475
0
                *pi4_avlblty = 0;
476
0
            }
477
0
        }
478
0
    }
479
0
}
480
/*****************************************************************************/
481
/*                                                                           */
482
/*  Function Name : isvcd_diagonal_construct_dyadic                           */
483
/*                                                                           */
484
/*  Description   : This function fills the unavaible pixels in the reference*/
485
/*                    array with diagonally constructed samples              */
486
/*  Inputs        : i4_x :current position in reference array X to be filled */
487
/*                  i4_y :current position in reference array Y to be filled */
488
/*                  i4_xd_index : diagonal index in horizontal direction     */
489
/*                  i4_yd_index : diagonal index in vertical direction       */
490
/*                  pu1_refarray : popinter to reference array               */
491
/*                  i4_refarray_wd: width of the reference array             */
492
/*  Globals       : none                                                     */
493
/*  Processing    : Fills the sample which is unavailable with filtered      */
494
/*                    diagonal samples                                       */
495
/*  Outputs       : pixel filled                                             */
496
/*  Returns       : constructed pixel                                        */
497
/*                                                                           */
498
/*  Issues        : none                                                     */
499
/*                                                                           */
500
/*  Revision History:                                                        */
501
/*                                                                           */
502
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
503
/*         06 09 2021   Kishore         creation                             */
504
/*                                                                           */
505
/*****************************************************************************/
506
UWORD8 isvcd_diagonal_construct_dyadic(WORD32 i4_x, WORD32 i4_y, WORD32 i4_xd_index,
507
                                       WORD32 i4_yd_index, UWORD8 *pu1_refarray,
508
                                       WORD32 i4_refarray_wd)
509
0
{
510
0
    WORD32 i4_diff_hor_ver, i4_sgn_xy;
511
0
    WORD32 i4_xc, i4_yc;
512
0
    WORD32 i4_samp1, i4_samp2, i4_samp3;
513
0
    WORD32 i4_result;
514
0
    UWORD8 *pu1_tmp;
515
516
0
    i4_diff_hor_ver = ABS(i4_xd_index) - ABS(i4_yd_index);
517
0
    i4_sgn_xy = SIGN(i4_xd_index * i4_yd_index);
518
519
0
    if(i4_diff_hor_ver > 0)
520
0
    {
521
0
        i4_xc = i4_x - (i4_sgn_xy * i4_yd_index);
522
0
        i4_yc = i4_y - i4_yd_index;
523
0
        pu1_tmp = pu1_refarray + (i4_yc * i4_refarray_wd);
524
0
        i4_samp1 = pu1_tmp[i4_xc - 1];
525
0
        i4_samp2 = pu1_tmp[i4_xc];
526
0
        i4_samp3 = pu1_tmp[i4_xc + 1];
527
0
    }
528
0
    else if(i4_diff_hor_ver < 0)
529
0
    {
530
0
        i4_xc = i4_x - i4_xd_index;
531
0
        i4_yc = i4_y - (i4_sgn_xy * i4_xd_index);
532
0
        pu1_tmp = pu1_refarray + ((i4_yc - 1) * i4_refarray_wd);
533
0
        i4_samp1 = pu1_tmp[i4_xc];
534
0
        pu1_tmp += i4_refarray_wd;
535
0
        i4_samp2 = pu1_tmp[i4_xc];
536
0
        pu1_tmp += i4_refarray_wd;
537
0
        i4_samp3 = pu1_tmp[i4_xc];
538
0
    }
539
0
    else
540
0
    {
541
0
        WORD32 i4_ref_xd, i4_ref_yd;
542
543
0
        i4_ref_xd = i4_x - i4_xd_index;
544
0
        i4_ref_yd = i4_y - i4_yd_index;
545
0
        i4_xc = i4_ref_xd + SIGN(i4_xd_index);
546
0
        i4_yc = i4_ref_yd + SIGN(i4_yd_index);
547
0
        pu1_tmp = pu1_refarray + (i4_ref_yd * i4_refarray_wd);
548
0
        i4_samp1 = pu1_tmp[i4_xc];
549
0
        i4_samp2 = pu1_tmp[i4_ref_xd];
550
0
        pu1_tmp = pu1_refarray + (i4_yc * i4_refarray_wd);
551
0
        i4_samp3 = pu1_tmp[i4_ref_xd];
552
0
    }
553
554
0
    i4_result = (i4_samp1 + (i4_samp2 << 1) + i4_samp3 + 2) >> 2;
555
0
    pu1_tmp = pu1_refarray + (i4_y * i4_refarray_wd);
556
    /* Store the filled sample */
557
0
    pu1_tmp[i4_x] = i4_result;
558
559
0
    return (i4_result);
560
0
}
561
562
/*****************************************************************************/
563
/*                                                                           */
564
/*  Function Name : isvcd_left_right_padding                                  */
565
/*  Description   :  This function does the left/right padding for intra     */
566
/*                      upsampling                                           */
567
/*                                                                           */
568
/*  Inputs        :                                                          */
569
/*  Globals       : none                                                     */
570
/*  Processing    : This function does the left/right padding for intra      */
571
/*                      upsampling                                           */
572
/*  Outputs       : none                                                     */
573
/*  Returns       : number of leading zeroes                                 */
574
/*  Issues        : none                                                     */
575
/*  Revision History:                                                        */
576
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
577
/*         06 09 2021   Vijay                creation                        */
578
/*****************************************************************************/
579
void isvcd_left_right_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
580
                              UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
581
                              UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
582
                              WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
583
                              WORD32 i4_corner_pixel_available)
584
395
{
585
395
    WORD32 i4_idx_i;
586
395
    UWORD8 *pu1_src, *pu1_dst;
587
588
395
    UNUSED(i1_yd_index);
589
395
    UNUSED(pu1_refarray_2);
590
395
    UNUSED(i4_mb_adjoin_x);
591
395
    UNUSED(i4_mb_adjoin_y);
592
395
    UNUSED(i4_corner_pixel_available);
593
594
395
    pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride);
595
395
    pu1_src = pu1_dst + i1_xd_index;
596
395
    i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA);
597
395
    u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA);
598
395
    pu1_dst = pu1_src - i1_xd_index;
599
600
3.06k
    for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
601
2.66k
    {
602
2.66k
        memset(pu1_dst, *pu1_src, u1_seg_wd);
603
2.66k
        pu1_dst += i4_refarray_stride;
604
2.66k
        pu1_src += i4_refarray_stride;
605
2.66k
    }
606
395
}
607
/*****************************************************************************/
608
/*                                                                           */
609
/*  Function Name : isvcd_left_right_padding_chroma                           */
610
/*  Description   :  This function does the left/right padding for intra     */
611
/*                      upsampling for chroma                                */
612
/*                                                                           */
613
/*  Inputs        :                                                          */
614
/*  Globals       : none                                                     */
615
/*  Processing    : This function does the left/right padding for intra      */
616
/*                      upsampling for chroma                                */
617
/*  Outputs       : none                                                     */
618
/*  Returns       : none                                                     */
619
/*  Issues        : none                                                     */
620
/*  Revision History:                                                        */
621
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
622
/*         06 09 2011   Vijay                creation                        */
623
/*****************************************************************************/
624
void isvcd_left_right_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
625
                                     UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
626
                                     UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
627
                                     WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
628
                                     WORD32 i4_corner_pixel_available)
629
395
{
630
395
    WORD32 i4_idx_i;
631
395
    UWORD8 *pu1_src_cb, *pu1_dst_cb;
632
395
    UWORD8 *pu1_src_cr, *pu1_dst_cr;
633
395
    WORD32 i4_tmp;
634
635
395
    UNUSED(i1_yd_index);
636
395
    UNUSED(i4_mb_adjoin_x);
637
395
    UNUSED(i4_mb_adjoin_y);
638
395
    UNUSED(i4_corner_pixel_available);
639
640
395
    i4_tmp = i4_x + (i4_y * i4_refarray_stride);
641
395
    pu1_dst_cb = pu1_refarray_1 + i4_tmp;
642
395
    pu1_src_cb = pu1_dst_cb + i1_xd_index;
643
395
    pu1_dst_cr = pu1_refarray_2 + i4_tmp;
644
395
    pu1_src_cr = pu1_dst_cr + i1_xd_index;
645
646
395
    i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_CHROMA);
647
395
    u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_CHROMA);
648
395
    pu1_dst_cb = pu1_src_cb - i1_xd_index;
649
395
    pu1_dst_cr = pu1_src_cr - i1_xd_index;
650
651
1.77k
    for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
652
1.37k
    {
653
1.37k
        memset(pu1_dst_cb, *pu1_src_cb, u1_seg_wd);
654
1.37k
        pu1_dst_cb += i4_refarray_stride;
655
1.37k
        pu1_src_cb += i4_refarray_stride;
656
1.37k
        memset(pu1_dst_cr, *pu1_src_cr, u1_seg_wd);
657
1.37k
        pu1_dst_cr += i4_refarray_stride;
658
1.37k
        pu1_src_cr += i4_refarray_stride;
659
1.37k
    }
660
395
}
661
662
/*****************************************************************************/
663
/*                                                                           */
664
/*  Function Name : isvcd_top_bot_padding                                     */
665
/*  Description   :  This function does the top/bottom padding for intra     */
666
/*                      upsampling for chroma                                */
667
/*                                                                           */
668
/*  Inputs        :                                                          */
669
/*  Globals       : none                                                     */
670
/*  Processing    : This function does the top/bottom padding for intra      */
671
/*                      upsampling for chroma                                */
672
/*  Outputs       : none                                                     */
673
/*  Returns       : none                                                     */
674
/*  Issues        : none                                                     */
675
/*  Revision History:                                                        */
676
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
677
/*         06 09 2021   Vijay                creation                        */
678
/*****************************************************************************/
679
void isvcd_top_bot_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
680
                           UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
681
                           UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x,
682
                           WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available)
683
310
{
684
310
    WORD32 i4_idx_i;
685
310
    UWORD8 *pu1_src, *pu1_dst;
686
687
310
    UNUSED(i1_xd_index);
688
310
    UNUSED(pu1_refarray_2);
689
310
    UNUSED(i4_mb_adjoin_x);
690
310
    UNUSED(i4_mb_adjoin_y);
691
310
    UNUSED(i4_corner_pixel_available);
692
693
310
    pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride);
694
310
    pu1_src = pu1_dst + (i1_yd_index * i4_refarray_stride);
695
310
    i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA);
696
310
    u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA);
697
310
    pu1_dst = pu1_src - (i1_yd_index * i4_refarray_stride);
698
699
1.25k
    for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
700
946
    {
701
946
        memcpy(pu1_dst, pu1_src, u1_seg_wd);
702
946
        pu1_dst += i4_refarray_stride;
703
946
    }
704
310
}
705
706
/*****************************************************************************/
707
/*                                                                           */
708
/*  Function Name : isvcd_top_bot_padding                                     */
709
/*  Description   :  This function does the top/bottom padding for intra     */
710
/*                      upsampling for chroma                                */
711
/*                                                                           */
712
/*  Inputs        :                                                          */
713
/*  Globals       : none                                                     */
714
/*  Processing    : This function does the top/bottom padding for intra      */
715
/*                      upsampling for chroma                                */
716
/*  Outputs       : none                                                     */
717
/*  Returns       : none                                                     */
718
/*  Issues        : none                                                     */
719
/*  Revision History:                                                        */
720
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
721
/*         06 09 2021   Vijay                creation                        */
722
/*****************************************************************************/
723
void isvcd_top_bot_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
724
                                  UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
725
                                  UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
726
                                  WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
727
                                  WORD32 i4_corner_pixel_available)
728
310
{
729
310
    WORD32 i4_idx_i;
730
310
    UWORD8 *pu1_src_cb, *pu1_dst_cb;
731
310
    UWORD8 *pu1_src_cr, *pu1_dst_cr;
732
310
    WORD32 i4_tmp;
733
734
310
    UNUSED(i1_xd_index);
735
310
    UNUSED(pu1_refarray_2);
736
310
    UNUSED(i4_mb_adjoin_x);
737
310
    UNUSED(i4_mb_adjoin_y);
738
310
    UNUSED(i4_corner_pixel_available);
739
740
310
    i4_tmp = i4_x + (i4_y * i4_refarray_stride);
741
310
    pu1_dst_cb = pu1_refarray_1 + i4_tmp;
742
310
    pu1_dst_cr = pu1_refarray_2 + i4_tmp;
743
744
310
    i4_tmp = (i1_yd_index * i4_refarray_stride);
745
310
    pu1_src_cb = pu1_dst_cb + i4_tmp;
746
310
    pu1_src_cr = pu1_dst_cr + i4_tmp;
747
310
    i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_CHROMA);
748
310
    u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_CHROMA);
749
750
310
    i4_tmp = (i1_yd_index * i4_refarray_stride);
751
310
    pu1_dst_cb = pu1_src_cb - i4_tmp;
752
310
    pu1_dst_cr = pu1_src_cr - i4_tmp;
753
754
844
    for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
755
534
    {
756
534
        memcpy(pu1_dst_cb, pu1_src_cb, u1_seg_wd);
757
534
        pu1_dst_cb += i4_refarray_stride;
758
534
        memcpy(pu1_dst_cr, pu1_src_cr, u1_seg_wd);
759
534
        pu1_dst_cr += i4_refarray_stride;
760
534
    }
761
310
}
762
763
/*****************************************************************************/
764
/*                                                                           */
765
/*  Function Name : isvcd_diag_reconstruction                                 */
766
/*  Description   :  This function does the diagonal reconstuction for intra */
767
/*                      upsampling for luma                                  */
768
/*                                                                           */
769
/*  Inputs        :                                                          */
770
/*  Globals       : none                                                     */
771
/*  Processing    : This function does the diagonal reconstruction for intra */
772
/*                      upsampling for luma                                  */
773
/*  Outputs       : none                                                     */
774
/*  Returns       : none                                                     */
775
/*  Issues        : none                                                     */
776
/*  Revision History:                                                        */
777
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
778
/*         06 09 2021   Vijay                creation                        */
779
/*****************************************************************************/
780
void isvcd_diag_reconstruction(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
781
                               UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
782
                               UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
783
                               WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
784
                               WORD32 i4_corner_pixel_available)
785
603
{
786
603
    WORD32 i4_i;
787
603
    UWORD8 *pu1_src_1, *pu1_src_2, *pu1_dst;
788
603
    UWORD8 u1_filter_delay_buf[18] = {0};
789
603
    UWORD8 u1_out_buf[16] = {0};
790
603
    WORD32 i4_width, i4_height;
791
603
    WORD32 i4_x_off, i4_y_off;
792
603
    WORD32 i4_block_size = BLOCK_WIDTH;
793
794
603
    UNUSED(pu1_refarray_2);
795
796
603
    pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride);
797
603
    pu1_src_1 = pu1_dst + i1_xd_index;
798
603
    pu1_src_2 = pu1_dst + (i1_yd_index * i4_refarray_stride);
799
800
603
    i4_width = MAX(u1_seg_wd, (((i4_mb_adjoin_x >> 3) ^ 1) * i4_block_size));
801
603
    i4_height = MAX(u1_seg_ht, (((i4_mb_adjoin_y >> 4) ^ 1) * i4_block_size));
802
603
    i4_x_off = (i4_width - u1_seg_wd);
803
603
    i4_y_off = (i4_height - u1_seg_ht);
804
805
603
    if(i1_xd_index < 0 && i1_yd_index > 0)
806
176
    {
807
        /* Quadrant 1 Processing load the pixel in the filter delay buffer */
808
1.76k
        for(i4_i = 0; i4_i < (i4_height + 1); i4_i++)
809
1.58k
        {
810
1.58k
            u1_filter_delay_buf[i4_i] = *pu1_src_1;
811
1.58k
            pu1_src_1 += i4_refarray_stride;
812
1.58k
        }
813
814
176
        pu1_src_2 -= i4_x_off;
815
176
        memcpy(&u1_filter_delay_buf[i4_i], pu1_src_2, i4_width);
816
817
176
        if(0 == i4_corner_pixel_available)
818
176
        {
819
            /* interpolate the unavailable corner pixel */
820
176
            u1_filter_delay_buf[i4_i - 1] =
821
176
                (u1_filter_delay_buf[i4_i] + u1_filter_delay_buf[i4_i - 2] + 1) >> 1;
822
176
        }
823
824
2.67k
        for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
825
2.49k
        {
826
            /* get the filtered output */
827
2.49k
            u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) +
828
2.49k
                                (u1_filter_delay_buf[i4_i + 2]) + 2) >>
829
2.49k
                               2;
830
2.49k
        }
831
832
        /* fill the segment with diagonal reconstructed output */
833
1.30k
        for(i4_i = 0; i4_i < u1_seg_ht; i4_i++)
834
1.12k
        {
835
1.12k
            memcpy(pu1_dst, &u1_out_buf[i4_x_off + i4_i], u1_seg_wd);
836
1.12k
            pu1_dst += i4_refarray_stride;
837
1.12k
        }
838
176
    }
839
427
    else if(i1_xd_index > 0 && i1_yd_index > 0)
840
125
    {
841
        /* Quadrant 2 Processing */
842
        /* load the pixel in the filter delay buffer  */
843
125
        memcpy(&u1_filter_delay_buf[0], pu1_src_2, (i4_width + 1));
844
665
        for(i4_i = i4_height; i4_i > 0; i4_i--)
845
540
        {
846
540
            u1_filter_delay_buf[i4_width + i4_i] = *pu1_src_1;
847
540
            pu1_src_1 += i4_refarray_stride;
848
540
        }
849
850
125
        if(0 == i4_corner_pixel_available)
851
125
        {
852
            /* interpolate the unavailable corner pixel */
853
125
            u1_filter_delay_buf[i4_width] =
854
125
                (u1_filter_delay_buf[i4_width - 1] + u1_filter_delay_buf[i4_width + 1] + 1) >> 1;
855
125
        }
856
857
1.54k
        for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
858
1.41k
        {
859
            /* get the filtered output */
860
1.41k
            u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) +
861
1.41k
                                (u1_filter_delay_buf[i4_i + 2]) + 2) >>
862
1.41k
                               2;
863
1.41k
        }
864
865
        /* fill the segment with diagonal reconstructed output */
866
665
        for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++)
867
540
        {
868
540
            memcpy(pu1_dst, &u1_out_buf[i4_height - i4_i], u1_seg_wd);
869
540
            pu1_dst += i4_refarray_stride;
870
540
        }
871
125
    }
872
302
    else if(i1_xd_index > 0 && i1_yd_index < 0)
873
187
    {
874
        /* Quadrant 3 Processing */
875
        /* load the pixel in the filter delay buffer  */
876
187
        memcpy(&u1_filter_delay_buf[0], pu1_src_2, (i4_width + 1));
877
878
187
        pu1_src_1 -= (i4_y_off * i4_refarray_stride);
879
1.55k
        for(i4_i = 1; i4_i <= i4_height; i4_i++)
880
1.36k
        {
881
1.36k
            u1_filter_delay_buf[i4_width + i4_i] = *pu1_src_1;
882
1.36k
            pu1_src_1 += i4_refarray_stride;
883
1.36k
        }
884
885
187
        if(0 == i4_corner_pixel_available)
886
187
        {
887
            /* interpolate the unavailable corner pixel */
888
187
            u1_filter_delay_buf[i4_width] =
889
187
                (u1_filter_delay_buf[i4_width - 1] + u1_filter_delay_buf[i4_width + 1] + 1) >> 1;
890
187
        }
891
892
2.86k
        for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
893
2.67k
        {
894
            /* get the filtered output */
895
2.67k
            u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) +
896
2.67k
                                (u1_filter_delay_buf[i4_i + 2]) + 2) >>
897
2.67k
                               2;
898
2.67k
        }
899
900
        /* fill the segment with diagonal reconstructed output */
901
1.38k
        for(i4_i = 0; i4_i < u1_seg_ht; i4_i++)
902
1.19k
        {
903
1.19k
            memcpy(pu1_dst, &u1_out_buf[i4_y_off + i4_i], u1_seg_wd);
904
1.19k
            pu1_dst += i4_refarray_stride;
905
1.19k
        }
906
187
    }
907
115
    else
908
115
    {
909
        /* Quadrant 4 Processing */
910
        /* load the pixel in the filter delay buffer  */
911
115
        pu1_src_1 += ((u1_seg_ht - 1) * i4_refarray_stride);
912
736
        for(i4_i = 0; i4_i <= i4_height; i4_i++)
913
621
        {
914
621
            u1_filter_delay_buf[i4_i] = *pu1_src_1;
915
621
            pu1_src_1 -= i4_refarray_stride;
916
621
        }
917
918
115
        pu1_src_2 -= i4_x_off;
919
115
        memcpy(&u1_filter_delay_buf[i4_i], pu1_src_2, i4_width);
920
921
115
        if(0 == i4_corner_pixel_available)
922
112
        {
923
            /* interpolate the unavailable corner pixel */
924
112
            u1_filter_delay_buf[i4_i - 1] =
925
112
                (u1_filter_delay_buf[i4_i] + u1_filter_delay_buf[i4_i - 2] + 1) >> 1;
926
112
        }
927
928
1.34k
        for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
929
1.23k
        {
930
            /* get the filtered output */
931
1.23k
            u1_out_buf[i4_i] = ((u1_filter_delay_buf[i4_i]) + (u1_filter_delay_buf[i4_i + 1] * 2) +
932
1.23k
                                (u1_filter_delay_buf[i4_i + 2]) + 2) >>
933
1.23k
                               2;
934
1.23k
        }
935
936
        /* fill the segment with diagonal reconstructed output */
937
621
        for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++)
938
506
        {
939
506
            memcpy(pu1_dst, &u1_out_buf[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd);
940
506
            pu1_dst += i4_refarray_stride;
941
506
        }
942
115
    }
943
603
}
944
/*****************************************************************************/
945
/*                                                                           */
946
/*  Function Name : isvcd_diag_reconstruction_chroma                          */
947
/*  Description   :  This function does the diagonal reconstuction for intra */
948
/*                      upsampling for chroma                                */
949
/*                                                                           */
950
/*  Inputs        :                                                          */
951
/*  Globals       : none                                                     */
952
/*  Processing    : This function does the diagonal reconstruction for intra */
953
/*                      upsampling for chroma                                */
954
/*  Outputs       : none                                                     */
955
/*  Returns       : none                                                     */
956
/*  Issues        : none                                                     */
957
/*  Revision History:                                                        */
958
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
959
/*         06 09 2021   Vijay                creation                        */
960
/*****************************************************************************/
961
void isvcd_diag_reconstruction_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index,
962
                                      WORD8 i1_yd_index, UWORD8 u1_seg_wd, UWORD8 u1_seg_ht,
963
                                      UWORD8 *pu1_refarray_1, UWORD8 *pu1_refarray_2,
964
                                      WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x,
965
                                      WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available)
966
603
{
967
603
    WORD32 i4_i;
968
603
    UWORD8 u1_filter_delay_buf_cb[18] = {0};
969
603
    UWORD8 u1_filter_delay_buf_cr[18] = {0};
970
603
    UWORD8 u1_out_buf_cb[16] = {0};
971
603
    UWORD8 u1_out_buf_cr[16] = {0};
972
603
    WORD32 i4_width, i4_height;
973
603
    WORD32 i4_x_off, i4_y_off;
974
603
    WORD32 i4_block_size = BLOCK_WIDTH >> 1;
975
603
    UWORD8 *pu1_src_1_cb, *pu1_src_2_cb, *pu1_dst_cb;
976
603
    UWORD8 *pu1_src_1_cr, *pu1_src_2_cr, *pu1_dst_cr;
977
603
    WORD32 i4_tmp;
978
979
603
    i4_tmp = i4_x + (i4_y * i4_refarray_stride);
980
603
    pu1_dst_cb = pu1_refarray_1 + i4_tmp;
981
603
    pu1_dst_cr = pu1_refarray_2 + i4_tmp;
982
983
603
    pu1_src_1_cb = pu1_dst_cb + i1_xd_index;
984
603
    pu1_src_1_cr = pu1_dst_cr + i1_xd_index;
985
603
    i4_tmp = (i1_yd_index * i4_refarray_stride);
986
603
    pu1_src_2_cb = pu1_dst_cb + i4_tmp;
987
603
    pu1_src_2_cr = pu1_dst_cr + i4_tmp;
988
989
603
    i4_width = MAX(u1_seg_wd, (((i4_mb_adjoin_x >> 3) ^ 1) * i4_block_size));
990
603
    i4_height = MAX(u1_seg_ht, (((i4_mb_adjoin_y >> 4) ^ 1) * i4_block_size));
991
603
    i4_x_off = (i4_width - u1_seg_wd);
992
603
    i4_y_off = (i4_height - u1_seg_ht);
993
994
603
    if(i1_xd_index < 0 && i1_yd_index > 0)
995
176
    {
996
        /* Quadrant 1 Processing load the pixel in the filter delay buffer */
997
1.05k
        for(i4_i = 0; i4_i < (i4_height + 1); i4_i++)
998
880
        {
999
880
            u1_filter_delay_buf_cb[i4_i] = *pu1_src_1_cb;
1000
880
            pu1_src_1_cb += i4_refarray_stride;
1001
880
            u1_filter_delay_buf_cr[i4_i] = *pu1_src_1_cr;
1002
880
            pu1_src_1_cr += i4_refarray_stride;
1003
880
        }
1004
1005
176
        pu1_src_2_cb -= i4_x_off;
1006
176
        pu1_src_2_cr -= i4_x_off;
1007
176
        memcpy(&u1_filter_delay_buf_cb[i4_i], pu1_src_2_cb, i4_width);
1008
176
        memcpy(&u1_filter_delay_buf_cr[i4_i], pu1_src_2_cr, i4_width);
1009
1010
176
        if(0 == i4_corner_pixel_available)
1011
176
        {
1012
            /* interpolate the unavailable corner pixel */
1013
176
            u1_filter_delay_buf_cb[i4_i - 1] =
1014
176
                (u1_filter_delay_buf_cb[i4_i] + u1_filter_delay_buf_cb[i4_i - 2] + 1) >> 1;
1015
1016
176
            u1_filter_delay_buf_cr[i4_i - 1] =
1017
176
                (u1_filter_delay_buf_cr[i4_i] + u1_filter_delay_buf_cr[i4_i - 2] + 1) >> 1;
1018
176
        }
1019
1020
1.40k
        for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
1021
1.23k
        {
1022
            /* get the filtered output */
1023
1.23k
            u1_out_buf_cb[i4_i] =
1024
1.23k
                ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) +
1025
1.23k
                 (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >>
1026
1.23k
                2;
1027
1028
1.23k
            u1_out_buf_cr[i4_i] =
1029
1.23k
                ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) +
1030
1.23k
                 (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >>
1031
1.23k
                2;
1032
1.23k
        }
1033
1034
        /* fill the segment with diagonal reconstructed output */
1035
738
        for(i4_i = 0; i4_i < u1_seg_ht; i4_i++)
1036
562
        {
1037
562
            memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_x_off + i4_i], u1_seg_wd);
1038
562
            pu1_dst_cb += i4_refarray_stride;
1039
562
            memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_x_off + i4_i], u1_seg_wd);
1040
562
            pu1_dst_cr += i4_refarray_stride;
1041
562
        }
1042
176
    }
1043
427
    else if(i1_xd_index > 0 && i1_yd_index > 0)
1044
125
    {
1045
        /* Quadrant 2 Processing load the pixel in the filter delay buffer  */
1046
125
        memcpy(&u1_filter_delay_buf_cb[0], pu1_src_2_cb, (i4_width + 1));
1047
125
        memcpy(&u1_filter_delay_buf_cr[0], pu1_src_2_cr, (i4_width + 1));
1048
1049
441
        for(i4_i = i4_height; i4_i > 0; i4_i--)
1050
316
        {
1051
316
            u1_filter_delay_buf_cb[i4_width + i4_i] = *pu1_src_1_cb;
1052
316
            pu1_src_1_cb += i4_refarray_stride;
1053
1054
316
            u1_filter_delay_buf_cr[i4_width + i4_i] = *pu1_src_1_cr;
1055
316
            pu1_src_1_cr += i4_refarray_stride;
1056
316
        }
1057
1058
125
        if(0 == i4_corner_pixel_available)
1059
125
        {
1060
            /* interpolate the unavailable corner pixel */
1061
125
            u1_filter_delay_buf_cb[i4_width] =
1062
125
                (u1_filter_delay_buf_cb[i4_width - 1] + u1_filter_delay_buf_cb[i4_width + 1] + 1) >>
1063
125
                1;
1064
1065
125
            u1_filter_delay_buf_cr[i4_width] =
1066
125
                (u1_filter_delay_buf_cr[i4_width - 1] + u1_filter_delay_buf_cr[i4_width + 1] + 1) >>
1067
125
                1;
1068
125
        }
1069
1070
816
        for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
1071
691
        {
1072
            /* get the filtered output */
1073
691
            u1_out_buf_cb[i4_i] =
1074
691
                ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) +
1075
691
                 (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >>
1076
691
                2;
1077
1078
691
            u1_out_buf_cr[i4_i] =
1079
691
                ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) +
1080
691
                 (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >>
1081
691
                2;
1082
691
        }
1083
1084
        /* fill the segment with diagonal reconstructed output */
1085
441
        for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++)
1086
316
        {
1087
316
            memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_height - i4_i], u1_seg_wd);
1088
316
            pu1_dst_cb += i4_refarray_stride;
1089
1090
316
            memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_height - i4_i], u1_seg_wd);
1091
316
            pu1_dst_cr += i4_refarray_stride;
1092
316
        }
1093
125
    }
1094
302
    else if(i1_xd_index > 0 && i1_yd_index < 0)
1095
187
    {
1096
        /* Quadrant 3 Processing load the pixel in the filter delay buffer  */
1097
187
        memcpy(&u1_filter_delay_buf_cb[0], pu1_src_2_cb, (i4_width + 1));
1098
187
        memcpy(&u1_filter_delay_buf_cr[0], pu1_src_2_cr, (i4_width + 1));
1099
1100
187
        i4_tmp = (i4_y_off * i4_refarray_stride);
1101
187
        pu1_src_1_cb -= i4_tmp;
1102
187
        pu1_src_1_cr -= i4_tmp;
1103
935
        for(i4_i = 1; i4_i <= i4_height; i4_i++)
1104
748
        {
1105
748
            u1_filter_delay_buf_cb[i4_width + i4_i] = *pu1_src_1_cb;
1106
748
            pu1_src_1_cb += i4_refarray_stride;
1107
1108
748
            u1_filter_delay_buf_cr[i4_width + i4_i] = *pu1_src_1_cr;
1109
748
            pu1_src_1_cr += i4_refarray_stride;
1110
748
        }
1111
1112
187
        if(0 == i4_corner_pixel_available)
1113
187
        {
1114
            /* interpolate the unavailable corner pixel */
1115
187
            u1_filter_delay_buf_cb[i4_width] =
1116
187
                (u1_filter_delay_buf_cb[i4_width - 1] + u1_filter_delay_buf_cb[i4_width + 1] + 1) >>
1117
187
                1;
1118
1119
187
            u1_filter_delay_buf_cr[i4_width] =
1120
187
                (u1_filter_delay_buf_cr[i4_width - 1] + u1_filter_delay_buf_cr[i4_width + 1] + 1) >>
1121
187
                1;
1122
187
        }
1123
1124
1.49k
        for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
1125
1.30k
        {
1126
            /* get the filtered output */
1127
1.30k
            u1_out_buf_cb[i4_i] =
1128
1.30k
                ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) +
1129
1.30k
                 (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >>
1130
1.30k
                2;
1131
1132
1.30k
            u1_out_buf_cr[i4_i] =
1133
1.30k
                ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) +
1134
1.30k
                 (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >>
1135
1.30k
                2;
1136
1.30k
        }
1137
1138
        /* fill the segment with diagonal reconstructed output */
1139
878
        for(i4_i = 0; i4_i < u1_seg_ht; i4_i++)
1140
691
        {
1141
691
            memcpy(pu1_dst_cb, &u1_out_buf_cb[i4_y_off + i4_i], u1_seg_wd);
1142
691
            pu1_dst_cb += i4_refarray_stride;
1143
691
            memcpy(pu1_dst_cr, &u1_out_buf_cr[i4_y_off + i4_i], u1_seg_wd);
1144
691
            pu1_dst_cr += i4_refarray_stride;
1145
691
        }
1146
187
    }
1147
115
    else
1148
115
    {
1149
        /* Quadrant 4 Processing load the pixel in the filter delay buffer  */
1150
115
        i4_tmp = ((u1_seg_ht - 1) * i4_refarray_stride);
1151
115
        pu1_src_1_cb += i4_tmp;
1152
115
        pu1_src_1_cr += i4_tmp;
1153
1154
483
        for(i4_i = 0; i4_i <= i4_height; i4_i++)
1155
368
        {
1156
368
            u1_filter_delay_buf_cb[i4_i] = *pu1_src_1_cb;
1157
368
            pu1_src_1_cb -= i4_refarray_stride;
1158
1159
368
            u1_filter_delay_buf_cr[i4_i] = *pu1_src_1_cr;
1160
368
            pu1_src_1_cr -= i4_refarray_stride;
1161
368
        }
1162
1163
115
        pu1_src_2_cb -= i4_x_off;
1164
115
        pu1_src_2_cr -= i4_x_off;
1165
115
        memcpy(&u1_filter_delay_buf_cb[i4_i], pu1_src_2_cb, i4_width);
1166
115
        memcpy(&u1_filter_delay_buf_cr[i4_i], pu1_src_2_cr, i4_width);
1167
1168
115
        if(0 == i4_corner_pixel_available)
1169
112
        {
1170
            /* interpolate the unavailable corner pixel */
1171
112
            u1_filter_delay_buf_cb[i4_i - 1] =
1172
112
                (u1_filter_delay_buf_cb[i4_i] + u1_filter_delay_buf_cb[i4_i - 2] + 1) >> 1;
1173
1174
112
            u1_filter_delay_buf_cr[i4_i - 1] =
1175
112
                (u1_filter_delay_buf_cr[i4_i] + u1_filter_delay_buf_cr[i4_i - 2] + 1) >> 1;
1176
112
        }
1177
1178
713
        for(i4_i = 0; i4_i < (i4_width + i4_height - 1); i4_i++)
1179
598
        {
1180
            /* get the filtered output */
1181
598
            u1_out_buf_cb[i4_i] =
1182
598
                ((u1_filter_delay_buf_cb[i4_i]) + (u1_filter_delay_buf_cb[i4_i + 1] * 2) +
1183
598
                 (u1_filter_delay_buf_cb[i4_i + 2]) + 2) >>
1184
598
                2;
1185
1186
598
            u1_out_buf_cr[i4_i] =
1187
598
                ((u1_filter_delay_buf_cr[i4_i]) + (u1_filter_delay_buf_cr[i4_i + 1] * 2) +
1188
598
                 (u1_filter_delay_buf_cr[i4_i + 2]) + 2) >>
1189
598
                2;
1190
598
        }
1191
1192
        /* fill the segment with diagonal reconstructed output */
1193
368
        for(i4_i = 1; i4_i <= u1_seg_ht; i4_i++)
1194
253
        {
1195
253
            memcpy(pu1_dst_cb, &u1_out_buf_cb[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd);
1196
253
            pu1_dst_cb += i4_refarray_stride;
1197
253
            memcpy(pu1_dst_cr, &u1_out_buf_cr[(u1_seg_ht + i4_x_off) - i4_i], u1_seg_wd);
1198
253
            pu1_dst_cr += i4_refarray_stride;
1199
253
        }
1200
115
    }
1201
603
}
1202
/*****************************************************************************/
1203
/*                                                                           */
1204
/*  Function Name : isvcd_diag_padding                                        */
1205
/*  Description   :  This function does the diagonal padding for intra       */
1206
/*                      upsampling for luma                                  */
1207
/*                                                                           */
1208
/*  Inputs        :                                                          */
1209
/*  Globals       : none                                                     */
1210
/*  Processing    : This function does the diagonal padding for intra        */
1211
/*                      upsampling for luma                                  */
1212
/*  Outputs       : none                                                     */
1213
/*  Returns       : none                                                     */
1214
/*  Issues        : none                                                     */
1215
/*  Revision History:                                                        */
1216
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1217
/*         06 09 2021   Vijay                creation                        */
1218
/*****************************************************************************/
1219
void isvcd_diag_padding(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
1220
                        UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
1221
                        UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride, WORD32 i4_mb_adjoin_x,
1222
                        WORD32 i4_mb_adjoin_y, WORD32 i4_corner_pixel_available)
1223
1224
268
{
1225
268
    WORD32 i4_idx_i;
1226
268
    UWORD8 *pu1_src, *pu1_dst;
1227
1228
268
    UNUSED(pu1_refarray_2);
1229
268
    UNUSED(i4_mb_adjoin_x);
1230
268
    UNUSED(i4_mb_adjoin_y);
1231
268
    UNUSED(i4_corner_pixel_available);
1232
1233
268
    pu1_dst = pu1_refarray_1 + i4_x + (i4_y * i4_refarray_stride);
1234
268
    pu1_src = pu1_dst + i1_xd_index + (i1_yd_index * i4_refarray_stride);
1235
268
    i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA);
1236
268
    u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA);
1237
268
    i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA);
1238
268
    u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA);
1239
268
    pu1_dst = pu1_src - i1_xd_index - (i1_yd_index * i4_refarray_stride);
1240
1241
1.09k
    for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
1242
829
    {
1243
829
        memset(pu1_dst, *pu1_src, u1_seg_wd);
1244
829
        pu1_dst += i4_refarray_stride;
1245
829
    }
1246
268
}
1247
1248
/*****************************************************************************/
1249
/*                                                                           */
1250
/*  Function Name : isvcd_diag_padding_chroma                                 */
1251
/*  Description   :  This function does the diagonal padding for intra       */
1252
/*                      upsampling for chroma                                */
1253
/*                                                                           */
1254
/*  Inputs        :                                                          */
1255
/*  Globals       : none                                                     */
1256
/*  Processing    : This function does the diagonal padding for intra        */
1257
/*                      upsampling for chroma                                */
1258
/*  Outputs       : none                                                     */
1259
/*  Returns       : none                                                     */
1260
/*  Issues        : none                                                     */
1261
/*  Revision History:                                                        */
1262
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1263
/*         06 09 2021   Vijay                creation                        */
1264
/*****************************************************************************/
1265
void isvcd_diag_padding_chroma(WORD32 i4_x, WORD32 i4_y, WORD8 i1_xd_index, WORD8 i1_yd_index,
1266
                               UWORD8 u1_seg_wd, UWORD8 u1_seg_ht, UWORD8 *pu1_refarray_1,
1267
                               UWORD8 *pu1_refarray_2, WORD32 i4_refarray_stride,
1268
                               WORD32 i4_mb_adjoin_x, WORD32 i4_mb_adjoin_y,
1269
                               WORD32 i4_corner_pixel_available)
1270
1271
268
{
1272
268
    WORD32 i4_idx_i;
1273
268
    UWORD8 *pu1_src_cb, *pu1_dst_cb;
1274
268
    UWORD8 *pu1_src_cr, *pu1_dst_cr;
1275
268
    WORD32 i4_tmp;
1276
1277
268
    UNUSED(i4_mb_adjoin_x);
1278
268
    UNUSED(i4_mb_adjoin_y);
1279
268
    UNUSED(i4_corner_pixel_available);
1280
1281
268
    i4_tmp = i4_x + (i4_y * i4_refarray_stride);
1282
268
    pu1_dst_cb = pu1_refarray_1 + i4_tmp;
1283
268
    pu1_dst_cr = pu1_refarray_2 + i4_tmp;
1284
268
    i4_tmp = i1_xd_index + (i1_yd_index * i4_refarray_stride);
1285
268
    pu1_src_cb = pu1_dst_cb + i4_tmp;
1286
268
    pu1_src_cr = pu1_dst_cr + i4_tmp;
1287
1288
268
    i1_xd_index = MIN(i1_xd_index, MAX_PIX_FILL_LUMA);
1289
268
    u1_seg_wd = MIN(u1_seg_wd, MAX_PIX_FILL_LUMA);
1290
268
    i1_yd_index = MIN(i1_yd_index, MAX_PIX_FILL_LUMA);
1291
268
    u1_seg_ht = MIN(u1_seg_ht, MAX_PIX_FILL_LUMA);
1292
1293
268
    i4_tmp = (i1_xd_index + (i1_yd_index * i4_refarray_stride));
1294
268
    pu1_dst_cb = pu1_src_cb - i4_tmp;
1295
268
    pu1_dst_cr = pu1_src_cr - i4_tmp;
1296
1297
927
    for(i4_idx_i = 0; i4_idx_i < u1_seg_ht; i4_idx_i++)
1298
659
    {
1299
659
        memset(pu1_dst_cb, *pu1_src_cb, u1_seg_wd);
1300
659
        pu1_dst_cb += i4_refarray_stride;
1301
659
        memset(pu1_dst_cr, *pu1_src_cr, u1_seg_wd);
1302
659
        pu1_dst_cr += i4_refarray_stride;
1303
659
    }
1304
268
}
1305
/*****************************************************************************/
1306
/*                                                                           */
1307
/*  Function Name : isvcd_corner_samp_dyadic                                  */
1308
/*                                                                           */
1309
/*  Description   : This function fills the corner sample in the reference   */
1310
/*                    array with diagonally constructed samples              */
1311
/*  Inputs        : i4_x :current position in reference array X to be filled */
1312
/*                  i4_y :current position in reference array Y to be filled */
1313
/*                  i4_xd_index : diagonal index in horizontal direction     */
1314
/*                  i4_yd_index : diagonal index in vertical direction       */
1315
/*                  pu1_refarray_y : pointer to luma reference array         */
1316
/*                    pu1_refarray_cb : pointer to Cb reference array        */
1317
/*                    pu1_refarray_cr : pointer to Cr reference array        */
1318
/*  Globals       : none                                                     */
1319
/*  Processing    : Fills the sample which is unavailable with filtered      */
1320
/*                    diagonal samples                                       */
1321
/*  Outputs       : pixel filled                                             */
1322
/*  Returns       : none                                                     */
1323
/*                                                                           */
1324
/*  Issues        : none                                                     */
1325
/*                                                                           */
1326
/*  Revision History:                                                        */
1327
/*                                                                           */
1328
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1329
/*         06 09 2021   Vijay           creation                             */
1330
/*                                                                           */
1331
/*****************************************************************************/
1332
void isvcd_corner_samp_dyadic(WORD32 i4_x, WORD32 i4_y, WORD32 i4_xD, WORD32 i4_yD,
1333
                              UWORD8 *pu1_refarray_y, UWORD8 *pu1_refarray_cb,
1334
                              UWORD8 *pu1_refarray_cr)
1335
0
{
1336
0
    WORD32 i4_ref_xD, i4_ref_yD;
1337
0
    WORD32 i4_c_ref_xD, i4_c_ref_yD;
1338
0
    WORD32 i4_xc, i4_yc;
1339
0
    WORD32 i4_c_xc, i4_c_yc;
1340
0
    WORD32 i4_samp1, i4_samp2;
1341
0
    UWORD8 *pu1_tmp_src, *pu1_tmp_dst;
1342
1343
0
    i4_ref_xD = i4_x - i4_xD;
1344
0
    i4_ref_yD = i4_y - i4_yD;
1345
0
    i4_xc = i4_ref_xD + SIGN(i4_xD);
1346
0
    i4_yc = i4_ref_yD + SIGN(i4_yD);
1347
1348
    /* Luma */
1349
0
    pu1_tmp_src = pu1_refarray_y + (i4_yc * DYADIC_REF_W_Y);
1350
0
    i4_samp1 = pu1_tmp_src[i4_ref_xD];
1351
0
    pu1_tmp_src = pu1_refarray_y + (i4_ref_yD * DYADIC_REF_W_Y);
1352
0
    i4_samp2 = pu1_tmp_src[i4_xc];
1353
0
    pu1_tmp_dst = pu1_tmp_src;
1354
0
    pu1_tmp_dst[i4_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1;
1355
1356
    /* Chroma */
1357
0
    i4_c_ref_xD = i4_ref_xD >> 1;
1358
0
    i4_c_ref_yD = i4_ref_yD >> 1;
1359
0
    i4_c_xc = i4_c_ref_xD + SIGN(i4_xD);
1360
0
    i4_c_yc = i4_c_ref_yD + SIGN(i4_yD);
1361
1362
    /* Cb */
1363
0
    pu1_tmp_src = pu1_refarray_cb + (i4_c_yc * DYADIC_REF_W_C);
1364
0
    i4_samp1 = pu1_tmp_src[i4_c_ref_xD];
1365
0
    pu1_tmp_src = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
1366
0
    i4_samp2 = pu1_tmp_src[i4_c_xc];
1367
0
    pu1_tmp_dst = pu1_tmp_src;
1368
0
    pu1_tmp_dst[i4_c_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1;
1369
1370
    /* Cr */
1371
0
    pu1_tmp_src = pu1_refarray_cr + (i4_c_yc * DYADIC_REF_W_C);
1372
0
    i4_samp1 = pu1_tmp_src[i4_c_ref_xD];
1373
0
    pu1_tmp_src = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
1374
0
    i4_samp2 = pu1_tmp_src[i4_c_xc];
1375
0
    pu1_tmp_dst = pu1_tmp_src;
1376
0
    pu1_tmp_dst[i4_c_ref_xD] = (i4_samp1 + i4_samp2 + 1) >> 1;
1377
0
}
1378
1379
/*****************************************************************************/
1380
/*                                                                           */
1381
/*  Function Name : isvcd_fill_non_ava_pixel                                  */
1382
/*                                                                           */
1383
/*  Description   :  This function does the core pixel level processing      */
1384
/*                    while filling the non available pixel                  */
1385
/*                                                                           */
1386
/*  Inputs        : pv_intra_samp_ctxt : intra sampling context              */
1387
/*                  i4_refarray_wd : width of the reference array            */
1388
/*                  i4_refarray_ht : height of the reference array           */
1389
/*                  ps_mb_coord  : current mb coord structure                */
1390
/*                  i4_chroma_flag : chroam processing flag                  */
1391
/*  Globals       : none                                                     */
1392
/*  Processing    : based on the map buffer values the non available pixels  */
1393
/*                   are filled using border extension algorithm             */
1394
/*  Outputs       : none                                                     */
1395
/*  Returns       : none                                                     */
1396
/*                                                                           */
1397
/*  Issues        : none                                                     */
1398
/*                                                                           */
1399
/*  Revision History:                                                        */
1400
/*                                                                           */
1401
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1402
/*         06 09 2021   vijayakumar          creation                        */
1403
/*                                                                           */
1404
/*****************************************************************************/
1405
void isvcd_fill_non_avail_pixel(void *pv_map_ctxt, UWORD8 *pu1_refarray_1, UWORD8 *pu1_refarray_2,
1406
                                WORD32 i4_refarray_stride, mb_coord_t *ps_mb_coord,
1407
                                WORD32 i4_chroma_flag, UWORD8 u1_avail_map[4][4])
1408
842
{
1409
    /* --------------------------------------------------------------------- */
1410
    /* Index Variables                                                         */
1411
    /* --------------------------------------------------------------------- */
1412
842
    intra_samp_map_ctxt_t *ps_map_ctxt;
1413
842
    ref_mb_map_t *ps_x_off_len;
1414
842
    ref_mb_map_t *ps_y_off_len;
1415
842
    WORD32 i4_x, i4_y;
1416
842
    WORD32 i4_corner_pixel_available;
1417
1418
    /* --------------------------------------------------------------------- */
1419
    /* Local Pointer Declaration for Segment lookup                             */
1420
    /* --------------------------------------------------------------------- */
1421
842
    seg_lookup_desc_t *ps_segments_x;
1422
842
    seg_lookup_desc_t *ps_segments_y;
1423
842
    seg_description_t *ps_seg_desc_x, *ps_seg_desc_y;
1424
842
    seg_description_t *ps_seg_x_tmp, *ps_seg_y_tmp;
1425
842
    UWORD8 u1_num_sgmts_x, u1_num_sgmts_y;
1426
1427
    /* --------------------------------------------------------------------- */
1428
    /* Temp Variables for Mapping context                                     */
1429
    /* --------------------------------------------------------------------- */
1430
842
    WORD32 i4_x_offset;
1431
842
    WORD32 i4_y_offset;
1432
842
    WORD32 i4_refmb_wd;
1433
842
    WORD32 i4_refmb_ht;
1434
842
    WORD32 i4_mbaddr_x;
1435
842
    WORD32 i4_mbaddr_y;
1436
842
    WORD32 i4_xr_index, i4_yr_index;
1437
842
    WORD32 i4_j, i4_i;
1438
842
    WORD32 i4_cur_x;
1439
842
    UWORD32 u4_lookup_4bit, u4_lookup_5bit, u4_4thbit;
1440
842
    WORD32 i4_pad_size;
1441
842
    WORD32 i4_x_min;
1442
842
    WORD32 i4_y_min;
1443
842
    WORD32 i4_x_start_pos, i4_y_start_pos;
1444
842
    ref_min_max_map_t *ps_x_min_max;
1445
842
    ref_min_max_map_t *ps_y_min_max;
1446
842
    UWORD8 *pu1_ref_idx_x, *pu1_ref_idx_y;
1447
842
    ftype_intra_samp_padding *pf_intra_samp_padding;
1448
842
    ftype_intra_samp_padding **pf_intra_samp_lookup;
1449
1450
842
    ps_map_ctxt = (intra_samp_map_ctxt_t *) pv_map_ctxt;
1451
842
    ps_x_min_max = ps_map_ctxt->ps_x_min_max;
1452
842
    ps_y_min_max = ps_map_ctxt->ps_y_min_max;
1453
842
    ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
1454
842
    ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
1455
842
    i4_mbaddr_y = ps_mb_coord->u2_mb_y;
1456
842
    i4_mbaddr_x = ps_mb_coord->u2_mb_x;
1457
842
    i4_x_offset = ps_x_off_len[i4_mbaddr_x].i2_offset;
1458
842
    i4_y_offset = ps_y_off_len[i4_mbaddr_y].i2_offset;
1459
842
    i4_refmb_wd = (MB_WIDTH >> i4_chroma_flag) - 1;
1460
842
    i4_refmb_ht = (MB_HEIGHT >> i4_chroma_flag) - 1;
1461
1462
842
    if(0 == i4_chroma_flag)
1463
421
    {
1464
421
        pf_intra_samp_lookup = gpf_lookup_fxns_luma;
1465
421
    }
1466
421
    else
1467
421
    {
1468
421
        pf_intra_samp_lookup = gpf_lookup_fxns_chroma;
1469
421
    }
1470
1471
    /* get the min and max positions */
1472
842
    i4_x_min = ps_x_min_max[i4_mbaddr_x].i2_min_pos;
1473
842
    i4_y_min = ps_y_min_max[i4_mbaddr_y].i2_min_pos;
1474
1475
    /* get the start position of the MB in reference layer */
1476
842
    i4_pad_size = 2 >> i4_chroma_flag;
1477
842
    i4_x_start_pos = (i4_x_min - i4_pad_size);
1478
842
    i4_y_start_pos = (i4_y_min - i4_pad_size);
1479
842
    i4_xr_index = (i4_x_start_pos + i4_x_offset) & i4_refmb_wd;
1480
842
    i4_yr_index = (i4_y_start_pos + i4_y_offset) & i4_refmb_ht;
1481
1482
    /* Find the number of segments in x and y direction */
1483
842
    ps_segments_x = (ps_map_ctxt->ps_seg_lookup_horz + i4_xr_index);
1484
842
    ps_segments_y = (ps_map_ctxt->ps_seg_lookup_vert + i4_yr_index);
1485
842
    u1_num_sgmts_x = ps_segments_x->u1_num_segments;
1486
842
    u1_num_sgmts_y = ps_segments_y->u1_num_segments;
1487
842
    ps_seg_desc_x = ps_segments_x->s_segments;
1488
842
    ps_seg_desc_y = ps_segments_y->s_segments;
1489
842
    pu1_ref_idx_x = ps_map_ctxt->pu1_refarray_x_idx;
1490
842
    pu1_ref_idx_y = ps_map_ctxt->pu1_refarray_y_idx;
1491
842
    i4_cur_x = pu1_ref_idx_x[i4_x_start_pos];
1492
842
    u4_4thbit = ps_segments_x->u4_start_pos;
1493
1494
3.03k
    for(i4_j = 0; i4_j < u1_num_sgmts_y; i4_j++)
1495
2.18k
    {
1496
2.18k
        UWORD8 i4_idx_a, i4_idx_b;
1497
2.18k
        UWORD8 u1_seg_ht, u1_seg_wd;
1498
2.18k
        UWORD8 u1_mb_adjoin_x, u1_mb_adjoin_y;
1499
2.18k
        WORD8 i1_nearst_mb_bdry_x, i1_nearst_mb_bdry_y;
1500
2.18k
        UWORD32 u4_num_valid_segs;
1501
2.18k
        WORD32 i4_idx_a_plus_ny, i4_idx_b_plus_nx, i4_index;
1502
2.18k
        WORD8 i1_yd_index, i1_xd_index;
1503
1504
2.18k
        ps_seg_y_tmp = &ps_seg_desc_y[i4_j];
1505
2.18k
        i4_y = i4_y_start_pos + ps_seg_y_tmp->u1_seg_off;
1506
2.18k
        u1_seg_ht = ps_seg_y_tmp->u1_seg_dim;
1507
2.18k
        i1_yd_index = ps_seg_y_tmp->i1_dist_idx;
1508
2.18k
        i1_nearst_mb_bdry_y = ps_seg_y_tmp->i1_nearst_mb_bdry;
1509
2.18k
        u1_mb_adjoin_y = ps_seg_y_tmp->u1_mb_adjoin;
1510
2.18k
        i4_idx_a = pu1_ref_idx_y[i4_y];
1511
2.18k
        i4_idx_a_plus_ny = (i4_idx_a + i1_nearst_mb_bdry_y);
1512
1513
        /* Pack the availabilities of the next three horizontal MBs in 3bit
1514
           format and 4th bit indicating if the start position is greater than the mb_width/2 */
1515
2.18k
        u4_lookup_4bit = u4_4thbit | u1_avail_map[i4_idx_a][i4_cur_x + 2] << 2 |
1516
2.18k
                         u1_avail_map[i4_idx_a][i4_cur_x + 1] << 1 |
1517
2.18k
                         u1_avail_map[i4_idx_a][i4_cur_x];
1518
1519
2.18k
        u4_num_valid_segs = gu4_valid_segs_lookup[u4_lookup_4bit];
1520
2.18k
        i4_i = isvcd_left_most_bit_detect(u4_num_valid_segs);
1521
2.18k
        u4_num_valid_segs <<= (i4_i + 1);
1522
1523
5.34k
        for(; i4_i < u1_num_sgmts_x; i4_i++)
1524
3.15k
        {
1525
3.15k
            ps_seg_x_tmp = &ps_seg_desc_x[i4_i];
1526
3.15k
            i4_x = i4_x_start_pos + ps_seg_x_tmp->u1_seg_off;
1527
3.15k
            i4_idx_b = pu1_ref_idx_x[i4_x];
1528
3.15k
            u1_seg_wd = ps_seg_x_tmp->u1_seg_dim;
1529
3.15k
            i1_xd_index = ps_seg_x_tmp->i1_dist_idx;
1530
3.15k
            i1_nearst_mb_bdry_x = ps_seg_x_tmp->i1_nearst_mb_bdry;
1531
3.15k
            u1_mb_adjoin_x = ps_seg_x_tmp->u1_mb_adjoin;
1532
3.15k
            i4_idx_b_plus_nx = (i4_idx_b + i1_nearst_mb_bdry_x);
1533
1534
            /* Find the avalability of (x,y-Yd),(x-Xd,y),(x-Xd,y-Yd) and pack it to 3 bits */
1535
3.15k
            u4_lookup_5bit = u1_avail_map[i4_idx_a_plus_ny][i4_idx_b_plus_nx] << 2 |
1536
3.15k
                             u1_avail_map[i4_idx_a_plus_ny][i4_idx_b] << 1 |
1537
3.15k
                             u1_avail_map[i4_idx_a][i4_idx_b_plus_nx] | u1_mb_adjoin_x |
1538
3.15k
                             u1_mb_adjoin_y;
1539
1540
3.15k
            i4_corner_pixel_available = u1_avail_map[i4_idx_a_plus_ny][i4_idx_b_plus_nx];
1541
1542
            /* Function pointer table from lookup to get Left,Top,Bottom,Right,Diagonal padding */
1543
3.15k
            if(u4_lookup_5bit > 31)
1544
0
            {
1545
0
                u4_lookup_5bit = 0;
1546
0
            }
1547
3.15k
            pf_intra_samp_padding = pf_intra_samp_lookup[u4_lookup_5bit];
1548
1549
3.15k
            if(pf_intra_samp_padding != NULL)
1550
3.15k
            {
1551
3.15k
                pf_intra_samp_padding(i4_x, i4_y, i1_xd_index, i1_yd_index, u1_seg_wd, u1_seg_ht,
1552
3.15k
                                      pu1_refarray_1, pu1_refarray_2, i4_refarray_stride,
1553
3.15k
                                      u1_mb_adjoin_x, u1_mb_adjoin_y, i4_corner_pixel_available);
1554
3.15k
            }
1555
1556
            /* increment to the next unavailable segment */
1557
3.15k
            i4_index = isvcd_left_most_bit_detect(u4_num_valid_segs);
1558
3.15k
            u4_num_valid_segs <<= (i4_index + 1);
1559
3.15k
            i4_i += i4_index;
1560
1561
3.15k
        } /* end of loop over ref array width */
1562
1563
2.18k
    }     /* end of loop over ref array height */
1564
842
    return;
1565
842
}
1566
1567
/*****************************************************************************/
1568
/*                                                                           */
1569
/*  Function Name : isvcd_get_ref_layer_mbtype                                */
1570
/*                                                                           */
1571
/*  Description   : This function is used to find the mb type of the         */
1572
/*                    corresponding MB in the reference layer                */
1573
/*                                                                           */
1574
/*  Inputs        : pv_intra_samp_ctxt : intra samp context                  */
1575
/*                  pi1_ref_mb_modes : ref mb modes buffer pointer           */
1576
/*                  i4_ref_mode_stride : mb mode buffer stride               */
1577
/*                  i4_x_ref : reference location X                          */
1578
/*                  i4_y_ref : reference location Y                          */
1579
/*                  pi4_mb_type : pointer to store the mb type               */
1580
/*                  i4_chroma_flag : chroma flag                             */
1581
/*  Globals       : none                                                     */
1582
/*  Processing    : it derives the bit corresponding to reference MB and     */
1583
/*                  stores the mbtype as INTRA if the bit is set             */
1584
/*  Outputs       : none                                                     */
1585
/*  Returns       : none                                                     */
1586
/*                                                                           */
1587
/*  Issues        : none                                                     */
1588
/*                                                                           */
1589
/*  Revision History:                                                        */
1590
/*                                                                           */
1591
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1592
/*         06 09 2021   vijayakumar          creation                        */
1593
/*                                                                           */
1594
/*****************************************************************************/
1595
WORD8 isvcd_get_ref_layer_mbtype(WORD8 *pi1_ref_mb_modes, WORD32 *pi4_mb_type,
1596
                                 WORD8 i1_curr_slice_id, WORD8 i1_cons_intr_samp_flag)
1597
7.72k
{
1598
7.72k
    WORD8 i1_intra_slice_id;
1599
7.72k
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
1600
7.72k
    WORD8 i1_mb_mode;
1601
1602
7.72k
    ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes;
1603
7.72k
    i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode;
1604
1605
7.72k
    if(i1_mb_mode <= SVC_INTER_MB)
1606
5.49k
    {
1607
        /* INTER */
1608
5.49k
        *pi4_mb_type = SVC_INTER_MB;
1609
5.49k
        i1_intra_slice_id = -1;
1610
5.49k
    }
1611
2.22k
    else
1612
2.22k
    {
1613
        /* INTRA */
1614
2.22k
        *pi4_mb_type = SVC_INTRA_MB;
1615
2.22k
        i1_intra_slice_id = ps_inter_lyr_mb_prms->i1_slice_id;
1616
1617
2.22k
        if(1 == i1_cons_intr_samp_flag)
1618
0
        {
1619
            /* check for different slice idc */
1620
0
            if(ps_inter_lyr_mb_prms->i1_slice_id != i1_curr_slice_id)
1621
0
            {
1622
                /* store the mode as INTER (not available for upsampling) */
1623
0
                *pi4_mb_type = SVC_INTER_MB;
1624
0
            }
1625
0
        }
1626
2.22k
    }
1627
1628
    /* if contarained intra flag is 1 then check for same mb mode */
1629
7.72k
    return (i1_intra_slice_id);
1630
7.72k
}
1631
/*****************************************************************************/
1632
/*                                                                           */
1633
/*  Function Name : isvcd_reflayer_construction                               */
1634
/*                                                                           */
1635
/*  Description   :  This function constructs the reference array buffer     */
1636
/*                    used for intra resampling of a component in an MB      */
1637
/*                                                                           */
1638
/*  Inputs        : pv_intra_samp_ctxt: intra sampling context               */
1639
/*                  pu1_inp : input (reference layer data)                   */
1640
/*                  i4_inp_stride : input buffer stride                      */
1641
/*                  ps_ref_mb_mode_map : ref layer mb mode buffer desc       */
1642
/*                  pi4_refarr_wd : pointer to store the reference array WD  */
1643
/*                  pi4_refarr_ht : pointer to store the reference array HT  */
1644
/*                  pi4_x_offset : pointer to store the reference X offset   */
1645
/*                  pi4_y_offset : pointer to store the reference Y offset   */
1646
/*                  ps_coord     : mb co-ordinate structure                  */
1647
/*                  i4_chroma_flag : chroma processing flag                  */
1648
/*  Globals       : none                                                     */
1649
/*  Processing    : it fills the reference layer data if they are falling in */
1650
/*                  INTRA MB region. If all the pixels are not filled  it    */
1651
/*                  calls the border extension algorithm to fill them        */
1652
/*  Outputs       : none                                                     */
1653
/*  Returns       : none                                                     */
1654
/*                                                                           */
1655
/*  Issues        : none                                                     */
1656
/*                                                                           */
1657
/*  Revision History:                                                        */
1658
/*                                                                           */
1659
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1660
/*         06 09 2021   vijayakumar          creation                        */
1661
/*****************************************************************************/
1662
WORD32 isvcd_reflayer_construction(void *pv_intra_samp_ctxt, UWORD8 *pu1_inp_1, UWORD8 *pu1_inp_2,
1663
                                   WORD32 i4_inp_stride, WORD32 i4_refarray_stride,
1664
                                   mem_element_t *ps_ref_mb_mode_map, mb_coord_t *ps_coord,
1665
                                   WORD32 i4_chroma_flag)
1666
842
{
1667
842
    WORD32 i4_x, i4_y;
1668
1669
    /* --------------------------------------------------------------------- */
1670
    /* Context and reference layer realted varaibles                         */
1671
    /* --------------------------------------------------------------------- */
1672
842
    intra_sampling_ctxt_t *ps_ctxt;
1673
842
    intra_samp_map_ctxt_t *ps_map_ctxt;
1674
842
    intra_samp_lyr_ctxt *ps_lyr_ctxt;
1675
842
    WORD8 *pi1_ref_mb_modes, *pi1_ref_mb_modes_bkp_1;
1676
842
    WORD32 i4_ref_mode_stride;
1677
842
    WORD32 i4_element_size;
1678
842
    ref_mb_map_t *ps_x_off_len;
1679
842
    ref_mb_map_t *ps_y_off_len;
1680
842
    WORD32 i4_mbaddr_y;
1681
842
    WORD32 i4_mbaddr_x;
1682
842
    WORD32 i4_mb_ht, i4_mb_wd;
1683
842
    UWORD8 u1_map_buf[4][4] = {0}; /*!< 4x4 mb grid buffer to store the mb availablity */
1684
    /* --------------------------------------------------------------------- */
1685
    /* Temp Variables for Mapping context                                     */
1686
    /* --------------------------------------------------------------------- */
1687
842
    WORD32 i4_ref_wd;
1688
842
    WORD32 i4_ref_ht;
1689
842
    WORD32 i4_x_offset;
1690
842
    WORD32 i4_y_offset;
1691
842
    WORD32 i4_refarray_wd;
1692
842
    WORD32 i4_refarray_ht;
1693
842
    WORD32 i4_mb_type;
1694
842
    WORD8 i1_cons_intr_samp_flag;
1695
842
    WORD8 i1_slice_id = 0;
1696
842
    WORD32 i4_mb_wd_sft, i4_mb_ht_sft;
1697
1698
    /* --------------------------------------------------------------------- */
1699
    /* Local Pointer Declaration for arrays in Mapping context                 */
1700
    /* --------------------------------------------------------------------- */
1701
1702
842
    WORD32 i4_unfill_check;
1703
842
    UWORD8 *pu1_refarray_1, *pu1_refarray_2;
1704
1705
842
    UNUSED(pu1_inp_2);
1706
1707
842
    ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
1708
842
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1709
842
    pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer;
1710
842
    i4_ref_mode_stride = ps_ref_mb_mode_map->i4_num_element_stride;
1711
842
    i4_element_size = ps_ref_mb_mode_map->i4_element_size;
1712
1713
    /* get the condtrained intra sampling flag */
1714
842
    i1_cons_intr_samp_flag = ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag;
1715
1716
842
    if(NULL == pi1_ref_mb_modes)
1717
0
    {
1718
0
        return NOT_OK;
1719
0
    }
1720
1721
    /* --------------------------------------------------------------------- */
1722
    /* Based on Chroma and Luma, extracting the context information struct     */
1723
    /* --------------------------------------------------------------------- */
1724
842
    if(1 == i4_chroma_flag)
1725
421
        ps_map_ctxt = &ps_lyr_ctxt->s_chroma_map_ctxt;
1726
421
    else
1727
421
        ps_map_ctxt = &ps_lyr_ctxt->s_luma_map_ctxt;
1728
1729
842
    ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
1730
842
    ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
1731
1732
    /* --------------------------------------------------------------------- */
1733
    /* Deriving the parameters required for further processing                 */
1734
    /* --------------------------------------------------------------------- */
1735
842
    {
1736
842
        WORD32 i4_base_width = ps_lyr_ctxt->i4_ref_width;
1737
842
        WORD32 i4_base_height = ps_lyr_ctxt->i4_ref_height;
1738
1739
842
        i4_ref_wd = i4_base_width >> i4_chroma_flag;
1740
842
        i4_ref_ht = i4_base_height >> i4_chroma_flag;
1741
842
        i4_mb_wd_sft = (MB_WIDTH_SHIFT - i4_chroma_flag);
1742
842
        i4_mb_ht_sft = (MB_HEIGHT_SHIFT - i4_chroma_flag);
1743
842
    }
1744
1745
    /* --------------------------------------------------------------------- */
1746
    /* Local variables based on the MB address                                 */
1747
    /* --------------------------------------------------------------------- */
1748
842
    i4_mbaddr_y = ps_coord->u2_mb_y;
1749
842
    i4_mbaddr_x = ps_coord->u2_mb_x;
1750
842
    i4_x_offset = ps_x_off_len[i4_mbaddr_x].i2_offset;
1751
842
    i4_y_offset = ps_y_off_len[i4_mbaddr_y].i2_offset;
1752
842
    i4_refarray_wd = ps_x_off_len[i4_mbaddr_x].i2_length;
1753
842
    i4_refarray_ht = ps_y_off_len[i4_mbaddr_y].i2_length;
1754
842
    i4_mb_wd = (MB_WIDTH >> i4_chroma_flag);
1755
842
    i4_mb_ht = (MB_HEIGHT >> i4_chroma_flag);
1756
1757
    /* --------------------------------------------------------------------- */
1758
    /* Derivation of ref slice MB idc                                         */
1759
    /* --------------------------------------------------------------------- */
1760
842
    if(1 == i1_cons_intr_samp_flag)
1761
0
    {
1762
0
        WORD32 i4_x_min, i4_x_max;
1763
0
        WORD32 i4_y_min, i4_y_max;
1764
0
        ref_min_max_map_t *ps_x_min_max;
1765
0
        ref_min_max_map_t *ps_y_min_max;
1766
1767
0
        ps_x_min_max = ps_map_ctxt->ps_x_min_max;
1768
0
        ps_y_min_max = ps_map_ctxt->ps_y_min_max;
1769
1770
        /* get the min and max positions */
1771
0
        i4_x_min = ps_x_min_max[i4_mbaddr_x].i2_min_pos;
1772
0
        i4_x_max = ps_x_min_max[i4_mbaddr_x].i2_max_pos;
1773
0
        i4_y_min = ps_y_min_max[i4_mbaddr_y].i2_min_pos;
1774
0
        i4_y_max = ps_y_min_max[i4_mbaddr_y].i2_max_pos;
1775
1776
        /* default initialization */
1777
0
        i4_mb_type = SVC_INTER_MB;
1778
1779
0
        {
1780
0
            WORD32 i4_x_ref;
1781
0
            WORD32 i4_y_ref;
1782
0
            WORD32 i4_mb_x, i4_mb_y;
1783
1784
0
            i4_y_ref = (i4_y_min + 1) + i4_y_offset;
1785
0
            i4_x_ref = (i4_x_min + 1) + i4_x_offset;
1786
0
            i4_mb_x = (i4_x_ref >> i4_mb_wd_sft);
1787
0
            i4_mb_y = (i4_y_ref >> i4_mb_ht_sft);
1788
0
            pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer;
1789
1790
            /* get the location of the byte which has the current mb mode */
1791
0
            pi1_ref_mb_modes += (i4_mb_y * i4_ref_mode_stride * i4_element_size);
1792
0
            pi1_ref_mb_modes += (i4_mb_x * i4_element_size);
1793
0
        }
1794
1795
0
        for(i4_y = (i4_y_min + 1); i4_y <= (i4_y_max - 1);)
1796
0
        {
1797
0
            WORD32 i4_x_ref;
1798
0
            WORD32 i4_y_ref;
1799
0
            WORD32 i4_distleftX, i4_rangeX;
1800
0
            WORD32 i4_disttopY, i4_rangeY;
1801
1802
0
            i4_y_ref = (i4_y + i4_y_offset);
1803
0
            i4_disttopY = (i4_y_ref) & (i4_mb_ht - 1);
1804
0
            i4_rangeY = (i4_mb_ht - i4_disttopY);
1805
1806
0
            pi1_ref_mb_modes_bkp_1 = pi1_ref_mb_modes;
1807
1808
0
            for(i4_x = (i4_x_min + 1); i4_x <= (i4_x_max - 1);)
1809
0
            {
1810
0
                i4_x_ref = (i4_x + i4_x_offset);
1811
0
                i4_distleftX = (i4_x_ref) & (i4_mb_wd - 1);
1812
0
                i4_rangeX = (i4_mb_wd - i4_distleftX);
1813
1814
                /* get the referecne layer mb type */
1815
0
                i1_slice_id =
1816
0
                    isvcd_get_ref_layer_mbtype(pi1_ref_mb_modes_bkp_1, &i4_mb_type, i1_slice_id, 0);
1817
0
                if(SVC_INTRA_MB == i4_mb_type)
1818
0
                {
1819
                    /* if an Intra MB is returned then break the loop */
1820
0
                    break;
1821
0
                }
1822
1823
0
                i4_x += i4_rangeX;
1824
0
                pi1_ref_mb_modes_bkp_1 += i4_element_size;
1825
0
            } /* end of loop in horizontal direction */
1826
1827
0
            if(SVC_INTRA_MB == i4_mb_type)
1828
0
            {
1829
                /* if an Intra MB is returned then break the loop */
1830
0
                break;
1831
0
            }
1832
1833
0
            i4_y += i4_rangeY;
1834
0
            pi1_ref_mb_modes += (i4_ref_mode_stride * i4_element_size);
1835
1836
0
        } /* end of loop in vertical direction */
1837
0
    }
1838
842
    else
1839
842
    {
1840
        /* set to non valid value */
1841
842
        i1_slice_id = -1;
1842
842
    }
1843
1844
842
    i4_unfill_check = 0;
1845
1846
    /* --------------------------------------------------------------------- */
1847
    /* Copying the data from recon buffer to refSample Array.                */
1848
    /* NOTE: The copying of the data from recon buffer to refSample Array    */
1849
    /*       can be optimized by bring in data at N-MB level,thus taking     */
1850
    /*       advantage of the overlapping data which now gets copied every MB*/
1851
    /* --------------------------------------------------------------------- */
1852
842
    {
1853
842
        WORD32 i4_x_ref_start, i4_x_ref_end;
1854
842
        WORD32 i4_y_ref_start, i4_y_ref_end;
1855
842
        WORD32 i4_rangeW, i4_rangeH;
1856
842
        WORD32 i4_offset;
1857
842
        UWORD8 *pu1_src, *pu1_dst;
1858
842
        UWORD8 *pu1_dst1, *pu1_dst2;
1859
1860
        /* Copy (refW x refH) dimension into reference sample array */
1861
842
        i4_x_ref_start = MAX(0, MIN((i4_ref_wd - 1), i4_x_offset));
1862
842
        i4_x_ref_end = MAX(0, MIN((i4_ref_wd - 1), (i4_refarray_wd - 1) + i4_x_offset));
1863
842
        i4_y_ref_start = MAX(0, MIN((i4_ref_ht - 1), i4_y_offset));
1864
842
        i4_y_ref_end = MAX(0, MIN((i4_ref_ht - 1), (i4_refarray_ht - 1) + i4_y_offset));
1865
1866
        /* find the actual data to be copied */
1867
842
        i4_rangeW = (i4_x_ref_end - i4_x_ref_start + 1);
1868
842
        i4_rangeH = (i4_y_ref_end - i4_y_ref_start + 1);
1869
1870
        /* get the reconbuffer pointer and ref sample array pointer */
1871
842
        i4_offset =
1872
842
            (i4_x_ref_start - i4_x_offset) + ((i4_y_ref_start - i4_y_offset) * i4_refarray_stride);
1873
1874
842
        if(0 == i4_chroma_flag)
1875
421
        {
1876
421
            pu1_refarray_1 = ps_ctxt->pu1_refarray_buffer;
1877
421
            pu1_refarray_2 = NULL;
1878
421
            pu1_src = pu1_inp_1;
1879
421
            pu1_dst = pu1_refarray_1 + i4_offset;
1880
1881
            /* Copy luma data into refsample array */
1882
421
            isvcd_copy_data(pu1_src, i4_inp_stride, pu1_dst, i4_refarray_stride, i4_rangeW,
1883
421
                            i4_rangeH);
1884
421
        }
1885
421
        else
1886
421
        {
1887
421
            pu1_refarray_1 = ps_ctxt->pu1_refarray_buffer;
1888
421
            pu1_refarray_2 = ps_ctxt->pu1_refarray_cb;
1889
421
            pu1_src = pu1_inp_1;
1890
421
            pu1_dst1 = pu1_refarray_1 + i4_offset;
1891
421
            pu1_dst2 = pu1_refarray_2 + i4_offset;
1892
421
            isvcd_copy_data_semiplanr(pu1_src, i4_inp_stride, pu1_dst1, pu1_dst2,
1893
421
                                      i4_refarray_stride, i4_rangeW, i4_rangeH);
1894
421
        }
1895
842
    }
1896
1897
    /* --------------------------------------------------------------------- */
1898
    /* Loop to fill ref sample array and corresponding map for interpolation */
1899
    /* --------------------------------------------------------------------- */
1900
842
    {
1901
842
        WORD32 i4_i, i4_j;
1902
842
        UWORD8 *pu1_ref_idx_x, *pu1_ref_idx_y;
1903
842
        WORD32 i4_x_ref;
1904
842
        WORD32 i4_y_ref;
1905
842
        WORD32 i4_mb_x, i4_mb_y;
1906
1907
842
        i4_y_ref = i4_y_offset;
1908
842
        i4_x_ref = i4_x_offset;
1909
842
        i4_mb_x = (i4_x_ref >> i4_mb_wd_sft);
1910
842
        i4_mb_y = (i4_y_ref >> i4_mb_ht_sft);
1911
842
        pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer;
1912
1913
        /* get the location of the byte which has the current mb mode */
1914
842
        pi1_ref_mb_modes += (i4_mb_y * i4_ref_mode_stride * i4_element_size);
1915
842
        pi1_ref_mb_modes += (i4_mb_x * i4_element_size);
1916
842
        pu1_ref_idx_x = ps_map_ctxt->pu1_refarray_x_idx;
1917
842
        pu1_ref_idx_y = ps_map_ctxt->pu1_refarray_y_idx;
1918
1919
842
        i4_j = 0;
1920
3.36k
        for(i4_y = 0; i4_y < i4_refarray_ht;)
1921
2.52k
        {
1922
2.52k
            WORD32 i4_x_ref;
1923
2.52k
            WORD32 i4_y_ref;
1924
2.52k
            WORD32 i4_distleftX, i4_rangeX;
1925
2.52k
            WORD32 i4_disttopY, i4_rangeY;
1926
1927
2.52k
            i4_y_ref = i4_y + i4_y_offset;
1928
2.52k
            i4_disttopY = (i4_y_ref) & (i4_mb_ht - 1);
1929
2.52k
            i4_rangeY = (i4_mb_ht - i4_disttopY);
1930
1931
            /* find the y-index lookup */
1932
2.52k
            memset(pu1_ref_idx_y, i4_j, i4_rangeY);
1933
2.52k
            pu1_ref_idx_y += i4_rangeY;
1934
1935
2.52k
            i4_i = 0;
1936
2.52k
            pi1_ref_mb_modes_bkp_1 = pi1_ref_mb_modes;
1937
10.2k
            for(i4_x = 0; i4_x < i4_refarray_wd;)
1938
7.72k
            {
1939
7.72k
                i4_x_ref = i4_x + i4_x_offset;
1940
7.72k
                i4_distleftX = (i4_x_ref) & (i4_mb_wd - 1);
1941
7.72k
                i4_rangeX = (i4_mb_wd - i4_distleftX);
1942
1943
7.72k
                if(0 == i4_j)
1944
2.52k
                {
1945
                    /* find the x-index lookup */
1946
2.52k
                    memset(pu1_ref_idx_x, i4_i, i4_rangeX);
1947
2.52k
                    pu1_ref_idx_x += i4_rangeX;
1948
2.52k
                }
1949
1950
                /* get the referecne layer mb type */
1951
7.72k
                isvcd_get_ref_layer_mbtype(pi1_ref_mb_modes_bkp_1, &i4_mb_type, i1_slice_id,
1952
7.72k
                                           i1_cons_intr_samp_flag);
1953
1954
7.72k
                if(SVC_INTRA_MB == i4_mb_type)
1955
2.22k
                {
1956
2.22k
                    u1_map_buf[i4_j][i4_i] = 1;
1957
2.22k
                }
1958
5.49k
                else
1959
5.49k
                {
1960
5.49k
                    i4_unfill_check = 1;
1961
5.49k
                }
1962
1963
7.72k
                i4_x = i4_x + i4_rangeX;
1964
7.72k
                i4_i++;
1965
7.72k
                pi1_ref_mb_modes_bkp_1 += i4_element_size;
1966
1967
7.72k
            } /* end of loop over ref array width */
1968
1969
2.52k
            i4_j++;
1970
2.52k
            i4_y = i4_y + i4_rangeY;
1971
2.52k
            pi1_ref_mb_modes += (i4_ref_mode_stride * i4_element_size);
1972
2.52k
        } /* end of loop over ref array height */
1973
842
    }
1974
1975
    /* --------------------------------------------------------------------- */
1976
    /* Calling boundary extension algorithm to fill unfilled pixels             */
1977
    /* --------------------------------------------------------------------- */
1978
842
    if(i4_unfill_check == 1)
1979
842
    {
1980
842
        isvcd_fill_non_avail_pixel(ps_map_ctxt, pu1_refarray_1, pu1_refarray_2, i4_refarray_stride,
1981
842
                                   ps_coord, i4_chroma_flag, u1_map_buf);
1982
842
    }
1983
842
    return OK;
1984
842
}
1985
1986
/*****************************************************************************/
1987
/*                                                                           */
1988
/*  Function Name : isvcd_reflayer_construction_dyadic                        */
1989
/*                                                                           */
1990
/*  Description   :  This function constructs the reference array buffer     */
1991
/*                   for dyadic cases used for intra resampling of a         */
1992
/*                     component in an MB                                    */
1993
/*                                                                           */
1994
/*  Inputs        : pv_intra_samp_ctxt : intra sampling context              */
1995
/*                  ps_ref_mb_mode_map : ref layer mb mode buffer desc       */
1996
/*                  pu1_inp_luma : luma input (reference layer data)         */
1997
/*                    pu1_inp_chroma : chroma input (reference layer data)   */
1998
/*                  i4_inp_luma_stride : luma input buffer stride            */
1999
/*                    i4_inp_chroma_stride : chroma input buffer stride      */
2000
/*                  i4_top : indicates whether the core 8x8 reference block  */
2001
/*                             is one of 0 and 1 or one of 2 and 3           */
2002
/*                    i4_left : indicates whether the core 8x8 ref block     */
2003
/*                             is one of 0 and 2 or one of 1 and 3           */
2004
/*                    ps_ref_mb_coord : coordinates of the reference MB      */
2005
/*  Globals       : none                                                     */
2006
/*  Processing    : it fills the reference layer data if they are falling in */
2007
/*                  INTRA MB region. If all the pixels are not filled  it    */
2008
/*                  calls the border extension algorithm to fill them        */
2009
/*  Outputs       : none                                                     */
2010
/*  Returns       : none                                                     */
2011
/*                                                                           */
2012
/*  Issues        : none                                                     */
2013
/*                                                                           */
2014
/*  Revision History:                                                        */
2015
/*                                                                           */
2016
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
2017
/*         06 09 2021   Vijay           creation                             */
2018
/*                                                                           */
2019
/*****************************************************************************/
2020
WORD32 isvcd_reflayer_construction_dyadic(void *pv_intra_samp_ctxt,
2021
                                          mem_element_t *ps_ref_mb_mode_map, UWORD8 *pu1_inp_luma,
2022
                                          UWORD8 *pu1_inp_chroma, WORD32 i4_inp_luma_stride,
2023
                                          WORD32 i4_inp_chroma_stride, WORD32 i4_top,
2024
                                          WORD32 i4_left, UWORD16 u2_mb_x, UWORD16 u2_mb_y)
2025
0
{
2026
    /* Index variables */
2027
0
    WORD32 i4_x, i4_y;
2028
0
    WORD32 i4_x0, i4_y0;
2029
0
    WORD32 i4_xc0, i4_yc0;
2030
0
    WORD32 i4_ref_xD, i4_ref_yD;
2031
0
    WORD32 i4_c_ref_xD, i4_c_ref_yD;
2032
2033
    /* --------------------------------------------------------------------- */
2034
    /* Context and reference layer related variables                         */
2035
    /* --------------------------------------------------------------------- */
2036
0
    intra_sampling_ctxt_t *ps_ctxt;
2037
0
    intra_samp_lyr_ctxt *ps_lyr_ctxt;
2038
0
    WORD8 *pi1_ref_mb_modes;
2039
0
    WORD32 i4_ref_mode_stride;
2040
0
    WORD32 i4_element_size;
2041
0
    WORD32 i4_mbaddr_y;
2042
0
    WORD32 i4_mbaddr_x;
2043
2044
    /* --------------------------------------------------------------------- */
2045
    /* Temp Variables for Mapping context                                     */
2046
    /* --------------------------------------------------------------------- */
2047
0
    WORD32 i4_refarray_wd_luma, i4_refarray_wd_chroma;
2048
0
    WORD32 i4_refarray_ht_luma, i4_refarray_ht_chroma;
2049
0
    WORD32 i4_avlblty;
2050
0
    WORD8 i1_cons_intr_samp_flag;
2051
0
    WORD8 i1_slice_id;
2052
0
    WORD8 i1_corner_samp_avlbl_flag;
2053
0
    UWORD8 u1_ny_avlblty;
2054
2055
    /* --------------------------------------------------------------------- */
2056
    /* Local Pointer Declaration for arrays in Mapping context                 */
2057
    /* --------------------------------------------------------------------- */
2058
0
    UWORD8 *pu1_refarray_luma;
2059
0
    UWORD8 *pu1_refarray_cb, *pu1_refarray_cr;
2060
2061
    /* --------------------------------------------------------------------- */
2062
    /* Derivation of local variables                                         */
2063
    /* --------------------------------------------------------------------- */
2064
0
    ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
2065
0
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
2066
0
    pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode_map->pv_buffer;
2067
0
    i4_ref_mode_stride = ps_ref_mb_mode_map->i4_num_element_stride;
2068
0
    i4_element_size = ps_ref_mb_mode_map->i4_element_size;
2069
2070
    /* --------------------------------------------------------------------- */
2071
    /* get the constrained intra resampling flag                             */
2072
    /* --------------------------------------------------------------------- */
2073
0
    i1_cons_intr_samp_flag = ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag;
2074
0
    if(NULL == pi1_ref_mb_modes)
2075
0
    {
2076
0
        return NOT_OK;
2077
0
    }
2078
2079
0
    pu1_refarray_luma = ps_ctxt->pu1_refarray_buffer;
2080
0
    pu1_refarray_cb = ps_ctxt->pu1_refarray_cb;
2081
0
    pu1_refarray_cr = ps_ctxt->pu1_refarray_cr;
2082
2083
    /* --------------------------------------------------------------------- */
2084
    /* Get the coordinates of the reference layer MB                         */
2085
    /* --------------------------------------------------------------------- */
2086
0
    i4_mbaddr_x = u2_mb_x;
2087
0
    i4_mbaddr_y = u2_mb_y;
2088
2089
    /* --------------------------------------------------------------------- */
2090
    /* Getting the size of the valid area of ref array to be brought in         */
2091
    /* --------------------------------------------------------------------- */
2092
0
    i4_refarray_wd_luma = 20;
2093
0
    i4_refarray_ht_luma = 20;
2094
0
    i4_refarray_wd_chroma = i4_refarray_wd_luma >> 1;
2095
0
    i4_refarray_ht_chroma = i4_refarray_ht_luma >> 1;
2096
2097
    /* --------------------------------------------------------------------- */
2098
    /* Derivation of ref slice MB idc                                         */
2099
    /* --------------------------------------------------------------------- */
2100
0
    if(1 == i1_cons_intr_samp_flag)
2101
0
    {
2102
0
        inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
2103
0
        WORD8 *pi1_ref_mb_mode_tmp;
2104
0
        WORD8 i1_mb_mode;
2105
2106
        /* get the location of the byte which has the current mb mode */
2107
0
        pi1_ref_mb_mode_tmp = pi1_ref_mb_modes;
2108
0
        pi1_ref_mb_mode_tmp += (i4_mbaddr_y * i4_ref_mode_stride * i4_element_size);
2109
0
        pi1_ref_mb_mode_tmp += (i4_mbaddr_x * i4_element_size);
2110
0
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_mode_tmp;
2111
0
        i1_mb_mode = ps_inter_lyr_mb_prms->i1_mb_mode;
2112
2113
        /* The reference layer MB should be intra */
2114
0
        UNUSED(i1_mb_mode);
2115
2116
0
        i1_slice_id = ps_inter_lyr_mb_prms->i1_slice_id;
2117
0
    }
2118
0
    else
2119
0
    {
2120
        /* set to non valid value */
2121
0
        i1_slice_id = -1;
2122
0
    }
2123
2124
    /* --------------------------------------------------------------------- */
2125
    /* Bring in the reference array                                          */
2126
    /* --------------------------------------------------------------------- */
2127
0
    {
2128
0
        UWORD8 *pu1_src, *pu1_dst;
2129
0
        WORD32 i4_src_stride, i4_dst_stride;
2130
2131
        /* Copy luma */
2132
0
        i4_src_stride = i4_inp_luma_stride;
2133
0
        i4_dst_stride = DYADIC_REF_W_Y;
2134
0
        pu1_src = pu1_inp_luma;
2135
0
        pu1_dst = pu1_refarray_luma;
2136
0
        isvcd_copy_data(pu1_src, i4_src_stride, pu1_dst, i4_dst_stride, i4_refarray_wd_luma,
2137
0
                        i4_refarray_ht_luma);
2138
        // Semi planar
2139
0
        i4_src_stride = i4_inp_chroma_stride;
2140
0
        i4_dst_stride = DYADIC_REF_W_C;
2141
0
        pu1_src = pu1_inp_chroma;
2142
0
        isvcd_copy_data_semiplanr(pu1_src, i4_src_stride, pu1_refarray_cb, pu1_refarray_cr,
2143
0
                                  i4_dst_stride, i4_refarray_wd_chroma, i4_refarray_ht_chroma);
2144
0
    }
2145
2146
    /* --------------------------------------------------------------------- */
2147
    /* Get the availability of 5 neighboring MBs                             */
2148
    /* --------------------------------------------------------------------- */
2149
0
    {
2150
        /* mb_x + left, mb_y + top */
2151
0
        isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2152
0
                                           i4_mbaddr_x + i4_left, i4_mbaddr_y + i4_top, &i4_avlblty,
2153
0
                                           i1_slice_id, i1_cons_intr_samp_flag);
2154
0
        u1_ny_avlblty = i4_avlblty;
2155
2156
        /* mb_x + left, mb_y */
2157
0
        isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2158
0
                                           i4_mbaddr_x + i4_left, i4_mbaddr_y, &i4_avlblty,
2159
0
                                           i1_slice_id, i1_cons_intr_samp_flag);
2160
0
        u1_ny_avlblty += (i4_avlblty << 1);
2161
2162
        /* mb_x, mb_y + top */
2163
0
        isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2164
0
                                           i4_mbaddr_x, i4_mbaddr_y + i4_top, &i4_avlblty,
2165
0
                                           i1_slice_id, i1_cons_intr_samp_flag);
2166
0
        u1_ny_avlblty += (i4_avlblty << 2);
2167
2168
        /* mb_x - left, mb_y + top */
2169
0
        isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2170
0
                                           i4_mbaddr_x - i4_left, i4_mbaddr_y + i4_top, &i4_avlblty,
2171
0
                                           i1_slice_id, i1_cons_intr_samp_flag);
2172
0
        u1_ny_avlblty += (i4_avlblty << 3);
2173
2174
        /* mb_x + left, mb_y - top */
2175
0
        isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
2176
0
                                           i4_mbaddr_x + i4_left, i4_mbaddr_y - i4_top, &i4_avlblty,
2177
0
                                           i1_slice_id, i1_cons_intr_samp_flag);
2178
0
        u1_ny_avlblty += (i4_avlblty << 4);
2179
0
    }
2180
2181
    /* --------------------------------------------------------------------- */
2182
    /* Filling the unavailable samples, if any                                 */
2183
    /* --------------------------------------------------------------------- */
2184
0
    if(0x7 == u1_ny_avlblty)
2185
0
    {
2186
        /* All are available, exit */
2187
0
        return OK;
2188
0
    }
2189
2190
0
    if(!(u1_ny_avlblty & 0x7))
2191
0
    {
2192
0
        UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2;
2193
0
        UWORD8 *pu1_tmp_src1, *pu1_tmp_src2;
2194
2195
        /* Set the 4 corner samples to (x-xD,y-yD) */
2196
0
        i4_x0 = 9 + (i4_left << 3) + i4_left;
2197
0
        i4_y0 = 9 + (i4_top << 3) + i4_top;
2198
2199
0
        i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2200
0
        i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2201
2202
0
        pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y);
2203
0
        pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2204
0
        pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y;
2205
0
        pu1_tmp_dst1[i4_x0] = pu1_tmp_src[i4_ref_xD];
2206
0
        pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2207
0
        pu1_tmp_dst2[i4_x0] = pu1_tmp_src[i4_ref_xD];
2208
0
        pu1_tmp_dst2[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2209
2210
        /* Set the corner sample of Cb and Cr to (x-xD,y-yD) */
2211
0
        i4_xc0 = i4_x0 >> 1;
2212
0
        i4_yc0 = i4_y0 >> 1;
2213
0
        i4_c_ref_yD = i4_ref_yD >> 1;
2214
0
        i4_c_ref_xD = i4_ref_xD >> 1;
2215
0
        pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
2216
0
        pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2217
0
        pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD];
2218
0
        pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
2219
0
        pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2220
0
        pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD];
2221
0
    }
2222
2223
0
    if(!(u1_ny_avlblty & 0x5))
2224
0
    {
2225
0
        UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2;
2226
0
        UWORD8 *pu1_tmp_src1, *pu1_tmp_src2;
2227
2228
        /* Copy (x0,ref_yD), (x0+1,ref_yD), ..., (x0+7,ref_yD) to */
2229
        /* (x0,y0), (x0+1,y0), ..., (x0+7,y0) and   */
2230
        /* (x0,y0+1), (x0+1,y0+1), ..., (x0+7,y0+1) */
2231
0
        i4_x0 = 2;
2232
0
        i4_y0 = 9 + (i4_top << 3) + i4_top;
2233
0
        if(i4_left > 0)
2234
0
        {
2235
0
            i4_x0 += 8;
2236
0
        }
2237
0
        i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2238
2239
0
        pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y);
2240
0
        pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2241
0
        pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y;
2242
2243
0
        for(i4_x = i4_x0; i4_x < i4_x0 + 8; i4_x++)
2244
0
        {
2245
0
            pu1_tmp_dst1[i4_x] = pu1_tmp_src[i4_x];
2246
0
            pu1_tmp_dst2[i4_x] = pu1_tmp_src[i4_x];
2247
0
        }
2248
2249
        /* Cb and Cr copy */
2250
0
        i4_xc0 = i4_x0 >> 1;
2251
0
        i4_yc0 = i4_y0 >> 1;
2252
0
        i4_c_ref_yD = i4_ref_yD >> 1;
2253
0
        pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
2254
0
        pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2255
0
        pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
2256
0
        pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2257
2258
0
        for(i4_x = i4_xc0; i4_x < i4_xc0 + 4; i4_x++)
2259
0
        {
2260
0
            pu1_tmp_dst1[i4_x] = pu1_tmp_src1[i4_x];
2261
0
            pu1_tmp_dst2[i4_x] = pu1_tmp_src2[i4_x];
2262
0
        }
2263
0
    }
2264
2265
0
    if(!(u1_ny_avlblty & 0x3))
2266
0
    {
2267
0
        UWORD8 *pu1_tmp_src, *pu1_tmp_dst1, *pu1_tmp_dst2;
2268
0
        UWORD8 *pu1_tmp_src1, *pu1_tmp_src2;
2269
2270
        /* Copy (ref_xD,y0) to (x0,y0) and (x0+1,y0); */
2271
        /* copy (ref_xD,y0+1) to (x0,y0+1) and (x0+1,y0+1); ... ;*/
2272
        /* copy (ref_xD,y0+7) to (x0,y0+7) and (x0+1,y0+7) */
2273
0
        i4_x0 = 9 + (i4_left << 3) + i4_left;
2274
0
        i4_y0 = 2;
2275
0
        if(i4_top > 0)
2276
0
        {
2277
0
            i4_y0 += 8;
2278
0
        }
2279
0
        i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2280
2281
0
        pu1_tmp_src = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2282
0
        pu1_tmp_dst1 = pu1_tmp_src;
2283
2284
0
        for(i4_y = i4_y0; i4_y < i4_y0 + 8; i4_y++)
2285
0
        {
2286
0
            pu1_tmp_dst1[i4_x0] = pu1_tmp_src[i4_ref_xD];
2287
0
            pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2288
0
            pu1_tmp_src += DYADIC_REF_W_Y;
2289
0
            pu1_tmp_dst1 += DYADIC_REF_W_Y;
2290
0
        }
2291
2292
        /* Cb and Cr copy */
2293
0
        i4_xc0 = i4_x0 >> 1;
2294
0
        i4_yc0 = i4_y0 >> 1;
2295
0
        i4_c_ref_xD = i4_ref_xD >> 1;
2296
0
        pu1_tmp_src1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2297
0
        pu1_tmp_dst1 = pu1_tmp_src1;
2298
0
        pu1_tmp_src2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2299
0
        pu1_tmp_dst2 = pu1_tmp_src2;
2300
2301
0
        for(i4_y = i4_yc0; i4_y < i4_yc0 + 4; i4_y++)
2302
0
        {
2303
0
            pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD];
2304
0
            pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD];
2305
0
            pu1_tmp_src1 += DYADIC_REF_W_C;
2306
0
            pu1_tmp_src2 += DYADIC_REF_W_C;
2307
0
            pu1_tmp_dst1 += DYADIC_REF_W_C;
2308
0
            pu1_tmp_dst2 += DYADIC_REF_W_C;
2309
0
        }
2310
0
    }
2311
2312
0
    if(!(u1_ny_avlblty & 0x4))
2313
0
    {
2314
0
        if(!(u1_ny_avlblty & 0x8))
2315
0
        {
2316
            /* (mb_x-left,mb_y+top) not available */
2317
0
            UWORD8 *pu1_tmp_src, *pu1_tmp_dst;
2318
2319
0
            i4_x0 = 9 - i4_left;
2320
0
            i4_y0 = 9 + (i4_top << 3) + i4_top;
2321
2322
0
            i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2323
2324
            /* Copy (x0,ref_yD) and (x0+1,ref_yD) to (x0,y0) and (x0+1,y0), and */
2325
            /* to (x0,y0+1) and (x0+1,y0+1) */
2326
0
            pu1_tmp_src = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y);
2327
0
            pu1_tmp_dst = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2328
0
            pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_x0];
2329
0
            pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_x0 + 1];
2330
0
            pu1_tmp_dst += DYADIC_REF_W_Y;
2331
0
            pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_x0];
2332
0
            pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_x0 + 1];
2333
2334
            /* Cb copy */
2335
0
            i4_xc0 = i4_x0 >> 1;
2336
0
            i4_yc0 = i4_y0 >> 1;
2337
0
            i4_c_ref_yD = i4_ref_yD >> 1;
2338
0
            pu1_tmp_src = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
2339
0
            pu1_tmp_dst = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2340
0
            pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_xc0];
2341
2342
            /* Cr copy */
2343
0
            pu1_tmp_src = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
2344
0
            pu1_tmp_dst = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2345
0
            pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_xc0];
2346
2347
0
        } /* if (mb_x-left,mb_y+top) not available */
2348
0
        else
2349
0
        {
2350
0
            WORD32 i4_xD, i4_yD;
2351
0
            WORD32 i4_c_xD, i4_c_yD;
2352
2353
0
            isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride,
2354
0
                                               i4_element_size, i4_mbaddr_x - i4_left, i4_mbaddr_y,
2355
0
                                               &i4_avlblty, i1_slice_id, i1_cons_intr_samp_flag);
2356
0
            i1_corner_samp_avlbl_flag = i4_avlblty;
2357
2358
0
            i4_x0 = 9 - i4_left;
2359
0
            i4_y0 = 9 + (i4_top << 3) + i4_top;
2360
0
            i4_xc0 = i4_x0 >> 1;
2361
0
            i4_yc0 = i4_y0 >> 1;
2362
0
            i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2363
0
            i4_ref_xD = i4_x0 - (i4_left * 7) - (i4_left >> 1);
2364
0
            i4_c_ref_xD = i4_ref_xD >> 1;
2365
0
            i4_c_ref_yD = i4_ref_yD >> 1;
2366
0
            i4_xD = i4_x0 - i4_ref_xD;
2367
0
            i4_yD = i4_y0 - i4_ref_yD;
2368
0
            i4_c_xD = i4_xc0 - i4_c_ref_xD;
2369
0
            i4_c_yD = i4_yc0 - i4_c_ref_yD;
2370
2371
            /* Fill corner sample if not available */
2372
0
            if(!i1_corner_samp_avlbl_flag)
2373
0
            {
2374
0
                isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma,
2375
0
                                         pu1_refarray_cb, pu1_refarray_cr);
2376
0
            }
2377
2378
            /* Call diagonal construction for luma */
2379
0
            for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++)
2380
0
            {
2381
0
                for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++)
2382
0
                {
2383
0
                    isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma,
2384
0
                                                    DYADIC_REF_W_Y);
2385
0
                    i4_xD++;
2386
0
                }
2387
0
                i4_yD++;
2388
0
                i4_xD -= 2;
2389
0
            }
2390
2391
            /* Call diagonal construction for chroma */
2392
0
            isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb,
2393
0
                                            DYADIC_REF_W_C);
2394
2395
0
            isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr,
2396
0
                                            DYADIC_REF_W_C);
2397
0
        }
2398
0
    }
2399
2400
0
    if(!(u1_ny_avlblty & 0x2))
2401
0
    {
2402
0
        if(!(u1_ny_avlblty & 0x10))
2403
0
        {
2404
0
            UWORD8 *pu1_tmp_src, *pu1_tmp_dst;
2405
2406
0
            i4_x0 = 9 + (i4_left << 3) + i4_left;
2407
0
            i4_y0 = 9 - i4_top;
2408
0
            i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2409
2410
            /* Copy (ref_xD,y0) to (x0,y0), (x0+1,y0), and  */
2411
            /* copy (ref_xD,y0+1) to (x0,y0+1), (x0+1,y0+1) */
2412
0
            pu1_tmp_src = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2413
0
            pu1_tmp_dst = pu1_tmp_src;
2414
0
            pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_ref_xD];
2415
0
            pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2416
0
            pu1_tmp_src += DYADIC_REF_W_Y;
2417
0
            pu1_tmp_dst += DYADIC_REF_W_Y;
2418
0
            pu1_tmp_dst[i4_x0] = pu1_tmp_src[i4_ref_xD];
2419
0
            pu1_tmp_dst[i4_x0 + 1] = pu1_tmp_src[i4_ref_xD];
2420
2421
            /* Cb copy */
2422
0
            i4_xc0 = i4_x0 >> 1;
2423
0
            i4_yc0 = i4_y0 >> 1;
2424
0
            i4_c_ref_xD = i4_ref_xD >> 1;
2425
0
            pu1_tmp_src = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2426
0
            pu1_tmp_dst = pu1_tmp_src;
2427
0
            pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_c_ref_xD];
2428
2429
            /* Cr copy */
2430
0
            pu1_tmp_src = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2431
0
            pu1_tmp_dst = pu1_tmp_src;
2432
0
            pu1_tmp_dst[i4_xc0] = pu1_tmp_src[i4_c_ref_xD];
2433
2434
0
        } /* if (mb_x+left,mb_y-top) not available */
2435
0
        else
2436
0
        {
2437
0
            WORD32 i4_xD, i4_yD;
2438
0
            WORD32 i4_c_xD, i4_c_yD;
2439
2440
0
            isvcd_get_ref_layer_avlblty_dyadic(pi1_ref_mb_modes, i4_ref_mode_stride,
2441
0
                                               i4_element_size, i4_mbaddr_x, i4_mbaddr_y - i4_top,
2442
0
                                               &i4_avlblty, i1_slice_id, i1_cons_intr_samp_flag);
2443
0
            i1_corner_samp_avlbl_flag = i4_avlblty;
2444
2445
0
            i4_x0 = 9 + (i4_left << 3) + i4_left;
2446
0
            i4_y0 = 9 - i4_top;
2447
0
            i4_xc0 = i4_x0 >> 1;
2448
0
            i4_yc0 = i4_y0 >> 1;
2449
0
            i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2450
0
            i4_ref_yD = i4_y0 - (i4_top * 7) - (i4_top >> 1);
2451
0
            i4_c_ref_xD = i4_ref_xD >> 1;
2452
0
            i4_c_ref_yD = i4_ref_yD >> 1;
2453
0
            i4_xD = i4_x0 - i4_ref_xD;
2454
0
            i4_yD = i4_y0 - i4_ref_yD;
2455
0
            i4_c_xD = i4_xc0 - i4_c_ref_xD;
2456
0
            i4_c_yD = i4_yc0 - i4_c_ref_yD;
2457
2458
0
            if(!i1_corner_samp_avlbl_flag)
2459
0
            {
2460
0
                isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma,
2461
0
                                         pu1_refarray_cb, pu1_refarray_cr);
2462
0
            }
2463
2464
            /* Call diagonal consrtuction for luma */
2465
0
            for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++)
2466
0
            {
2467
0
                for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++)
2468
0
                {
2469
0
                    isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma,
2470
0
                                                    DYADIC_REF_W_Y);
2471
0
                    i4_xD++;
2472
0
                }
2473
0
                i4_yD++;
2474
0
                i4_xD -= 2;
2475
0
            }
2476
2477
            /* Call diagonal construction for chroma */
2478
0
            isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb,
2479
0
                                            DYADIC_REF_W_C);
2480
2481
0
            isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr,
2482
0
                                            DYADIC_REF_W_C);
2483
0
        }
2484
0
    }
2485
2486
0
    if(u1_ny_avlblty & 1)
2487
0
    {
2488
0
        if(!(u1_ny_avlblty & 2))
2489
0
        {
2490
            /* (mb_x+left,mb_y) is unavailable */
2491
0
            WORD32 i4_xD, i4_yD;
2492
0
            WORD32 i4_c_xD, i4_c_yD;
2493
0
            UWORD8 *pu1_tmp_dst;
2494
0
            UWORD8 u1_filled_samp;
2495
2496
0
            i1_corner_samp_avlbl_flag = (u1_ny_avlblty & 4) >> 2;
2497
2498
0
            i4_x0 = 9 + (i4_left << 3) + i4_left;
2499
0
            i4_y0 = 2;
2500
0
            i4_ref_yD = 1;
2501
0
            if(i4_top > 0)
2502
0
            {
2503
0
                i4_y0 += 8;
2504
0
                i4_ref_yD = 18;
2505
0
            }
2506
2507
0
            i4_ref_xD = i4_x0 - (i4_left) - (i4_left >> 1);
2508
0
            i4_xD = i4_x0 - i4_ref_xD;
2509
0
            i4_yD = i4_y0 - i4_ref_yD;
2510
0
            i4_xc0 = i4_x0 >> 1;
2511
0
            i4_yc0 = i4_y0 >> 1;
2512
0
            i4_c_ref_xD = i4_ref_xD >> 1;
2513
0
            i4_c_ref_yD = i4_ref_yD >> 1;
2514
0
            i4_c_xD = i4_xc0 - i4_c_ref_xD;
2515
0
            i4_c_yD = i4_yc0 - i4_c_ref_yD;
2516
2517
            /* Fill corner sample if unavailable */
2518
0
            if(!i1_corner_samp_avlbl_flag)
2519
0
            {
2520
0
                isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma,
2521
0
                                         pu1_refarray_cb, pu1_refarray_cr);
2522
0
            }
2523
2524
            /* Call the diagonal construction for the 8 rows */
2525
0
            if(i4_top == i4_left)
2526
0
            {
2527
                /* if top * left = 1 (x0,y0) */
2528
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0, i4_xD, i4_yD,
2529
0
                                                                 pu1_refarray_luma, DYADIC_REF_W_Y);
2530
2531
0
                pu1_tmp_dst = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2532
2533
                /* (x0,y0+1), ..., (x0,y0+7) and */
2534
                /* (x0+1,y0), ..., (x0+1,y0+6)   */
2535
0
                for(i4_y = i4_y0 + 1; i4_y < i4_y0 + 8; i4_y++)
2536
0
                {
2537
0
                    i4_yD++;
2538
0
                    u1_filled_samp = isvcd_diagonal_construct_dyadic(
2539
0
                        i4_x0, i4_y, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2540
0
                    pu1_tmp_dst[i4_x0 + 1] = u1_filled_samp;
2541
0
                    pu1_tmp_dst += DYADIC_REF_W_Y;
2542
0
                }
2543
2544
                /* (x0+1,y0+7) */
2545
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(
2546
0
                    i4_x0 + 1, i4_y0 + 7, i4_xD + 1, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2547
0
            }
2548
0
            else
2549
0
            {
2550
                /* top * left = -1 (x0+1,y0) */
2551
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0 + 1, i4_y0, i4_xD + 1, i4_yD,
2552
0
                                                                 pu1_refarray_luma, DYADIC_REF_W_Y);
2553
2554
0
                pu1_tmp_dst = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2555
2556
                /* (x0,y0), ..., (x0,y0+6) and   */
2557
                /* (x0+1,y0+1), ..., (x0+1,y0+7) */
2558
0
                for(i4_y = i4_y0; i4_y < i4_y0 + 7; i4_y++)
2559
0
                {
2560
0
                    u1_filled_samp = isvcd_diagonal_construct_dyadic(
2561
0
                        i4_x0, i4_y, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2562
2563
0
                    pu1_tmp_dst += DYADIC_REF_W_Y;
2564
0
                    pu1_tmp_dst[i4_x0 + 1] = u1_filled_samp;
2565
0
                    i4_yD++;
2566
0
                }
2567
2568
                /* (x0,y0+7) */
2569
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0 + 7, i4_xD, i4_yD,
2570
0
                                                                 pu1_refarray_luma, DYADIC_REF_W_Y);
2571
0
            }
2572
2573
            /* For Cb and Cr */
2574
0
            for(i4_y = i4_yc0; i4_y < i4_yc0 + 4; i4_y++)
2575
0
            {
2576
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_xc0, i4_y, i4_c_xD, i4_c_yD,
2577
0
                                                                 pu1_refarray_cb, DYADIC_REF_W_C);
2578
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_xc0, i4_y, i4_c_xD, i4_c_yD,
2579
0
                                                                 pu1_refarray_cr, DYADIC_REF_W_C);
2580
0
                i4_c_yD++;
2581
0
            }
2582
2583
0
        } /* (mb_x+left,mb_y) is unavailable */
2584
2585
0
        if(!(u1_ny_avlblty & 4))
2586
0
        {
2587
            /* (mb_x,mb_y+top) is unavailable */
2588
0
            WORD32 i4_xD, i4_yD;
2589
0
            WORD32 i4_c_xD, i4_c_yD;
2590
0
            UWORD8 *pu1_tmp_dst;
2591
0
            UWORD8 u1_filled_samp;
2592
2593
0
            i1_corner_samp_avlbl_flag = (u1_ny_avlblty & 2) >> 1;
2594
0
            i4_y0 = 9 + (i4_top << 3) + (i4_top);
2595
0
            i4_x0 = 2;
2596
0
            i4_ref_xD = 1;
2597
0
            if(i4_left > 0)
2598
0
            {
2599
0
                i4_x0 += 8;
2600
0
                i4_ref_xD = 18;
2601
0
            }
2602
2603
0
            i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2604
0
            i4_xD = i4_x0 - i4_ref_xD;
2605
0
            i4_yD = i4_y0 - i4_ref_yD;
2606
0
            i4_xc0 = i4_x0 >> 1;
2607
0
            i4_yc0 = i4_y0 >> 1;
2608
0
            i4_c_ref_xD = i4_ref_xD >> 1;
2609
0
            i4_c_ref_yD = i4_ref_yD >> 1;
2610
0
            i4_c_xD = i4_xc0 - i4_c_ref_xD;
2611
0
            i4_c_yD = i4_yc0 - i4_c_ref_yD;
2612
2613
0
            if(!i1_corner_samp_avlbl_flag)
2614
0
            {
2615
0
                isvcd_corner_samp_dyadic(i4_x0, i4_y0, i4_xD, i4_yD, pu1_refarray_luma,
2616
0
                                         pu1_refarray_cb, pu1_refarray_cr);
2617
0
            }
2618
2619
            /* Call the diagonal construction for the 2 rows */
2620
0
            if(i4_top == i4_left)
2621
0
            {
2622
                /* if top * left = 1 (x0,y0) */
2623
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0, i4_xD, i4_yD,
2624
0
                                                                 pu1_refarray_luma, DYADIC_REF_W_Y);
2625
2626
0
                pu1_tmp_dst = pu1_refarray_luma + ((i4_y0 + 1) * DYADIC_REF_W_Y);
2627
2628
                /* (x0+1,y0), ..., (x0+7,y0) and */
2629
                /* (x0,y0+1), ..., (x0+6,y0+1)   */
2630
0
                for(i4_x = i4_x0 + 1; i4_x < i4_x0 + 8; i4_x++)
2631
0
                {
2632
0
                    i4_xD++;
2633
0
                    u1_filled_samp = isvcd_diagonal_construct_dyadic(
2634
0
                        i4_x, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2635
0
                    pu1_tmp_dst[i4_x - 1] = u1_filled_samp;
2636
0
                }
2637
2638
                /* (x0+7,y0+1) */
2639
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(
2640
0
                    i4_x0 + 7, i4_y0 + 1, i4_xD, i4_yD + 1, pu1_refarray_luma, DYADIC_REF_W_Y);
2641
0
            }
2642
0
            else
2643
0
            {
2644
                /* top * left = -1 */
2645
                /* (x0,y0+1) */
2646
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0, i4_y0 + 1, i4_xD, i4_yD + 1,
2647
0
                                                                 pu1_refarray_luma, DYADIC_REF_W_Y);
2648
2649
0
                pu1_tmp_dst = pu1_refarray_luma + ((i4_y0 + 1) * DYADIC_REF_W_Y);
2650
2651
                /* (x0,y0), ..., (x0,y0+6) and   */
2652
                /* (x0+1,y0+1), ..., (x0+1,y0+7) */
2653
0
                for(i4_x = i4_x0; i4_x < i4_x0 + 7; i4_x++)
2654
0
                {
2655
0
                    u1_filled_samp = isvcd_diagonal_construct_dyadic(
2656
0
                        i4_x, i4_y0, i4_xD, i4_yD, pu1_refarray_luma, DYADIC_REF_W_Y);
2657
2658
0
                    pu1_tmp_dst[i4_x + 1] = u1_filled_samp;
2659
0
                    i4_xD++;
2660
0
                }
2661
2662
                /* (x0+7,y0) */
2663
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x0 + 7, i4_y0, i4_xD, i4_yD,
2664
0
                                                                 pu1_refarray_luma, DYADIC_REF_W_Y);
2665
0
            }
2666
2667
            /* For Cb and Cr */
2668
0
            for(i4_x = i4_xc0; i4_x < i4_xc0 + 4; i4_x++)
2669
0
            {
2670
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x, i4_yc0, i4_c_xD, i4_c_yD,
2671
0
                                                                 pu1_refarray_cb, DYADIC_REF_W_C);
2672
0
                u1_filled_samp = isvcd_diagonal_construct_dyadic(i4_x, i4_yc0, i4_c_xD, i4_c_yD,
2673
0
                                                                 pu1_refarray_cr, DYADIC_REF_W_C);
2674
0
                i4_c_xD++;
2675
0
            }
2676
2677
0
        } /* (mb_x,mb_y+top) is unavailable */
2678
0
    }     /* if (mb_x+left,mb_y+top) not available */
2679
0
    else
2680
0
    {
2681
0
        UWORD8 *pu1_tmp_dst1, *pu1_tmp_dst2;
2682
0
        UWORD8 *pu1_tmp_src1, *pu1_tmp_src2;
2683
2684
0
        if(0x02 == (u1_ny_avlblty & 0x6))
2685
0
        {
2686
            /* (mb_x+left,mb_y) available, (mb_x,mb_y+top) unavailable */
2687
0
            i4_x0 = 9 + (i4_left << 3) + i4_left;
2688
0
            i4_y0 = 9 + (i4_top << 3) + i4_top;
2689
0
            i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2690
2691
            /* Copy (x0,ref_yD), (x0+1,ref_yD) to  */
2692
            /* (x0,y0), (x0+1,y0), and (x0,y0+1), (x0+1,y0+1) */
2693
0
            pu1_tmp_src1 = pu1_refarray_luma + (i4_ref_yD * DYADIC_REF_W_Y);
2694
0
            pu1_tmp_dst1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2695
0
            pu1_tmp_dst2 = pu1_tmp_dst1 + DYADIC_REF_W_Y;
2696
0
            pu1_tmp_dst1[i4_x0] = pu1_tmp_src1[i4_x0];
2697
0
            pu1_tmp_dst2[i4_x0] = pu1_tmp_src1[i4_x0];
2698
0
            pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src1[i4_x0 + 1];
2699
0
            pu1_tmp_dst2[i4_x0 + 1] = pu1_tmp_src1[i4_x0 + 1];
2700
2701
            /* Cb and Cr copy */
2702
0
            i4_xc0 = i4_x0 >> 1;
2703
0
            i4_yc0 = i4_y0 >> 1;
2704
0
            i4_c_ref_yD = i4_ref_yD >> 1;
2705
0
            pu1_tmp_src1 = pu1_refarray_cb + (i4_c_ref_yD * DYADIC_REF_W_C);
2706
0
            pu1_tmp_dst1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2707
0
            pu1_tmp_src2 = pu1_refarray_cr + (i4_c_ref_yD * DYADIC_REF_W_C);
2708
0
            pu1_tmp_dst2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2709
0
            pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_xc0];
2710
0
            pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_xc0];
2711
2712
0
        } /* if (mb_x+left,mb_y) available, (mb_x,mb_y+top) unavailable */
2713
0
        else if(0x04 == (u1_ny_avlblty & 0x6))
2714
0
        {
2715
            /* (mb_x+left,mb_y) unavailable, (mb_x,mb_y+top) available */
2716
0
            i4_x0 = 9 + (i4_left << 3) + i4_left;
2717
0
            i4_y0 = 9 + (i4_top << 3) + i4_top;
2718
0
            i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2719
2720
            /* Copy (ref_xD,y0) to (x0,y0) and (x0+1,y0) */
2721
            /* copy (ref_xD,y0+1) to (x0,y0+1) and (x0+1,y0+1) */
2722
0
            pu1_tmp_src1 = pu1_refarray_luma + (i4_y0 * DYADIC_REF_W_Y);
2723
0
            pu1_tmp_dst1 = pu1_tmp_src1;
2724
0
            pu1_tmp_src2 = pu1_tmp_src1 + DYADIC_REF_W_Y;
2725
0
            pu1_tmp_dst2 = pu1_tmp_src2;
2726
2727
0
            pu1_tmp_dst1[i4_x0] = pu1_tmp_src1[i4_ref_xD];
2728
0
            pu1_tmp_dst1[i4_x0 + 1] = pu1_tmp_src1[i4_ref_xD];
2729
0
            pu1_tmp_dst2[i4_x0] = pu1_tmp_src2[i4_ref_xD];
2730
0
            pu1_tmp_dst2[i4_x0 + 1] = pu1_tmp_src2[i4_ref_xD];
2731
2732
            /* Copy Cb and Cr */
2733
0
            i4_xc0 = i4_x0 >> 1;
2734
0
            i4_yc0 = i4_y0 >> 1;
2735
0
            i4_c_ref_xD = i4_ref_xD >> 1;
2736
2737
0
            pu1_tmp_src1 = pu1_refarray_cb + (i4_yc0 * DYADIC_REF_W_C);
2738
0
            pu1_tmp_dst1 = pu1_tmp_src1;
2739
0
            pu1_tmp_src2 = pu1_refarray_cr + (i4_yc0 * DYADIC_REF_W_C);
2740
0
            pu1_tmp_dst2 = pu1_tmp_src2;
2741
2742
0
            pu1_tmp_dst1[i4_xc0] = pu1_tmp_src1[i4_c_ref_xD];
2743
0
            pu1_tmp_dst2[i4_xc0] = pu1_tmp_src2[i4_c_ref_xD];
2744
2745
0
        } /* if (mb_x+left,mb_y) unavailable, (mb_x,mb_y+top) available */
2746
0
        else if(0x6 == (u1_ny_avlblty & 0x6))
2747
0
        {
2748
            /* (mb_x+left,mb_y) available, (mb_x,mb_y+top) available */
2749
0
            WORD32 i4_xD, i4_yD;
2750
0
            WORD32 i4_c_xD, i4_c_yD;
2751
2752
0
            i4_y0 = 9 + (i4_top << 3) + i4_top;
2753
0
            i4_x0 = 9 + (i4_left << 3) + i4_left;
2754
0
            i4_ref_xD = i4_x0 - i4_left - (i4_left >> 1);
2755
0
            i4_ref_yD = i4_y0 - i4_top - (i4_top >> 1);
2756
0
            i4_xD = i4_x0 - i4_ref_xD;
2757
0
            i4_yD = i4_y0 - i4_ref_yD;
2758
0
            i4_xc0 = i4_x0 >> 1;
2759
0
            i4_yc0 = i4_y0 >> 1;
2760
0
            i4_c_ref_xD = i4_ref_xD >> 1;
2761
0
            i4_c_ref_yD = i4_ref_yD >> 1;
2762
0
            i4_c_xD = i4_xc0 - i4_c_ref_xD;
2763
0
            i4_c_yD = i4_yc0 - i4_c_ref_yD;
2764
2765
            /* Call diagonal construction for luma */
2766
0
            for(i4_y = i4_y0; i4_y < i4_y0 + 2; i4_y++)
2767
0
            {
2768
0
                for(i4_x = i4_x0; i4_x < i4_x0 + 2; i4_x++)
2769
0
                {
2770
0
                    isvcd_diagonal_construct_dyadic(i4_x, i4_y, i4_xD, i4_yD, pu1_refarray_luma,
2771
0
                                                    DYADIC_REF_W_Y);
2772
0
                    i4_xD++;
2773
0
                }
2774
0
                i4_yD++;
2775
0
                i4_xD -= 2;
2776
0
            }
2777
2778
            /* Call diagonal construction for chroma */
2779
0
            isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cb,
2780
0
                                            DYADIC_REF_W_C);
2781
2782
0
            isvcd_diagonal_construct_dyadic(i4_xc0, i4_yc0, i4_c_xD, i4_c_yD, pu1_refarray_cr,
2783
0
                                            DYADIC_REF_W_C);
2784
2785
0
        } /* if (mb_x+left,mb_y) available, (mb_x,mb_y+top) available */
2786
0
    }     /* (mb_x+left,mb_y+top) available */
2787
2788
0
    return OK;
2789
0
}
2790
/*****************************************************************************/
2791
/*                                                                           */
2792
/*  Function Name : isvcd_interpolate_base_luma_dyadic                        */
2793
/*                                                                           */
2794
/*  Description   : This function takes the reference array buffer & performs*/
2795
/*                  intra resampling for dyadic scaling ratios               */
2796
/*  Inputs        : pu1_inp_buf : ptr to the 12x12 reference sample buffer   */
2797
/*                    pi2_tmp_filt_buf : ptr to the 12x16 buffer to hold the */
2798
/*                        vertically interpolated data                       */
2799
/*                  pu1_out_buf : output buffer pointer                      */
2800
/*                  i4_out_stride : output buffer stride                     */
2801
/*  Globals       : none                                                     */
2802
/*  Processing    : it does the interpolation in vertical direction followed */
2803
/*                  by horizontal direction                                  */
2804
/*  Outputs       : resampled pixels                                         */
2805
/*  Returns       : none                                                     */
2806
/*                                                                           */
2807
/*  Issues        : none                                                     */
2808
/*                                                                           */
2809
/*  Revision History:                                                        */
2810
/*                                                                           */
2811
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
2812
/*         06 09 2021   Vijay           creation                             */
2813
/*                                                                           */
2814
/*****************************************************************************/
2815
void isvcd_interpolate_base_luma_dyadic(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf,
2816
                                        UWORD8 *pu1_out_buf, WORD32 i4_out_stride)
2817
0
{
2818
0
    WORD32 i4_x, i4_y;
2819
0
    WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
2820
0
    WORD32 i4_samp_0, i4_samp_1, i4_samp_2, i4_samp_3;
2821
0
    WORD32 i4_rslt_1, i4_rslt_2;
2822
0
    WORD32 i4_filt_stride, i4_src_stride;
2823
0
    UWORD8 *pu1_inp, *pu1_out;
2824
0
    WORD16 *pi2_tmp;
2825
2826
    /* Filter coefficient values for phase 4 */
2827
0
    i4_coeff_0 = -3;
2828
0
    i4_coeff_1 = 28;
2829
0
    i4_coeff_2 = 8;
2830
0
    i4_coeff_3 = -1;
2831
0
    i4_filt_stride = 12;
2832
0
    i4_src_stride = DYADIC_REF_W_Y;
2833
0
    pu1_inp = pu1_inp_buf;
2834
0
    pi2_tmp = pi2_tmp_filt_buf;
2835
0
    pu1_out = pu1_out_buf;
2836
2837
    /* Vertical interpolation */
2838
0
    for(i4_x = 0; i4_x < 12; i4_x++)
2839
0
    {
2840
        /* y = 0, y_phase = 12 */
2841
0
        i4_samp_0 = pu1_inp[i4_x];
2842
0
        pu1_inp += i4_src_stride;
2843
0
        i4_samp_1 = pu1_inp[i4_x];
2844
0
        pu1_inp += i4_src_stride;
2845
0
        i4_samp_2 = pu1_inp[i4_x];
2846
0
        pu1_inp += i4_src_stride;
2847
0
        i4_samp_3 = pu1_inp[i4_x];
2848
0
        pu1_inp += i4_src_stride;
2849
2850
        /* since y_phase 12 for y = 0 */
2851
0
        i4_rslt_1 = i4_samp_0 * i4_coeff_3;
2852
0
        i4_rslt_1 += i4_samp_1 * i4_coeff_2;
2853
0
        i4_rslt_1 += i4_samp_2 * i4_coeff_1;
2854
0
        i4_rslt_1 += i4_samp_3 * i4_coeff_0;
2855
2856
        /* Store the output */
2857
0
        pi2_tmp[i4_x] = i4_rslt_1;
2858
        /* Increment the output ptr */
2859
0
        pi2_tmp += i4_filt_stride;
2860
2861
0
        for(i4_y = 1; i4_y < 15; i4_y += 2)
2862
0
        {
2863
0
            i4_samp_0 = i4_samp_1;
2864
0
            i4_samp_1 = i4_samp_2;
2865
0
            i4_samp_2 = i4_samp_3;
2866
0
            i4_samp_3 = pu1_inp[i4_x];
2867
2868
            /* y_phase is 4 for odd values of y */
2869
            /* and 12 for even values of y    */
2870
0
            i4_rslt_1 = i4_samp_0 * i4_coeff_0;
2871
0
            i4_rslt_1 += i4_samp_1 * i4_coeff_1;
2872
0
            i4_rslt_1 += i4_samp_2 * i4_coeff_2;
2873
0
            i4_rslt_1 += i4_samp_3 * i4_coeff_3;
2874
0
            i4_rslt_2 = i4_samp_0 * i4_coeff_3;
2875
0
            i4_rslt_2 += i4_samp_1 * i4_coeff_2;
2876
0
            i4_rslt_2 += i4_samp_2 * i4_coeff_1;
2877
0
            i4_rslt_2 += i4_samp_3 * i4_coeff_0;
2878
2879
            /* Storing the results */
2880
0
            pi2_tmp[i4_x] = i4_rslt_1;
2881
0
            pi2_tmp += i4_filt_stride;
2882
0
            pi2_tmp[i4_x] = i4_rslt_2;
2883
2884
            /* Incrementing the pointers */
2885
0
            pi2_tmp += i4_filt_stride;
2886
0
            pu1_inp += i4_src_stride;
2887
2888
0
        } /* End of loop over y */
2889
2890
        /* y = 15, y_phase = 4 */
2891
0
        i4_samp_0 = i4_samp_1;
2892
0
        i4_samp_1 = i4_samp_2;
2893
0
        i4_samp_2 = i4_samp_3;
2894
0
        i4_samp_3 = pu1_inp[i4_x];
2895
2896
0
        i4_rslt_1 = i4_samp_0 * i4_coeff_0;
2897
0
        i4_rslt_1 += i4_samp_1 * i4_coeff_1;
2898
0
        i4_rslt_1 += i4_samp_2 * i4_coeff_2;
2899
0
        i4_rslt_1 += i4_samp_3 * i4_coeff_3;
2900
2901
        /* Store the output */
2902
0
        pi2_tmp[i4_x] = i4_rslt_1;
2903
2904
        /* Reinitializing the ptrs */
2905
0
        pu1_inp = pu1_inp_buf;
2906
0
        pi2_tmp = pi2_tmp_filt_buf;
2907
0
    }
2908
2909
    /* Horizontal interpolation */
2910
0
    for(i4_y = 0; i4_y < 16; i4_y++)
2911
0
    {
2912
        /* x = 0, x_phase = 12 */
2913
0
        i4_samp_0 = *pi2_tmp++;
2914
0
        i4_samp_1 = *pi2_tmp++;
2915
0
        i4_samp_2 = *pi2_tmp++;
2916
0
        i4_samp_3 = *pi2_tmp++;
2917
2918
        /* since x_phase 12 for x = 0 */
2919
0
        i4_rslt_1 = i4_samp_0 * i4_coeff_3;
2920
0
        i4_rslt_1 += i4_samp_1 * i4_coeff_2;
2921
0
        i4_rslt_1 += i4_samp_2 * i4_coeff_1;
2922
0
        i4_rslt_1 += i4_samp_3 * i4_coeff_0;
2923
0
        i4_rslt_1 += 512;
2924
2925
0
        i4_rslt_1 >>= 10;
2926
2927
        /* Store the output */
2928
0
        pu1_out[0] = CLIPUCHAR(i4_rslt_1);
2929
2930
0
        for(i4_x = 1; i4_x < 15; i4_x += 2)
2931
0
        {
2932
0
            i4_samp_0 = i4_samp_1;
2933
0
            i4_samp_1 = i4_samp_2;
2934
0
            i4_samp_2 = i4_samp_3;
2935
0
            i4_samp_3 = *pi2_tmp++;
2936
2937
            /* x_phase is 4 for odd values of x */
2938
            /* and 12 for even values of x    */
2939
0
            i4_rslt_1 = i4_samp_0 * i4_coeff_0;
2940
0
            i4_rslt_1 += i4_samp_1 * i4_coeff_1;
2941
0
            i4_rslt_1 += i4_samp_2 * i4_coeff_2;
2942
0
            i4_rslt_1 += i4_samp_3 * i4_coeff_3;
2943
0
            i4_rslt_1 += 512;
2944
2945
0
            i4_rslt_2 = i4_samp_0 * i4_coeff_3;
2946
0
            i4_rslt_2 += i4_samp_1 * i4_coeff_2;
2947
0
            i4_rslt_2 += i4_samp_2 * i4_coeff_1;
2948
0
            i4_rslt_2 += i4_samp_3 * i4_coeff_0;
2949
0
            i4_rslt_2 += 512;
2950
2951
0
            i4_rslt_1 >>= 10;
2952
0
            i4_rslt_2 >>= 10;
2953
2954
            /* Store the output */
2955
0
            pu1_out[i4_x] = CLIPUCHAR(i4_rslt_1);
2956
0
            pu1_out[i4_x + 1] = CLIPUCHAR(i4_rslt_2);
2957
0
        }
2958
2959
        /* x = 15 */
2960
0
        i4_samp_0 = i4_samp_1;
2961
0
        i4_samp_1 = i4_samp_2;
2962
0
        i4_samp_2 = i4_samp_3;
2963
0
        i4_samp_3 = *pi2_tmp++;
2964
2965
0
        i4_rslt_1 = i4_samp_0 * i4_coeff_0;
2966
0
        i4_rslt_1 += i4_samp_1 * i4_coeff_1;
2967
0
        i4_rslt_1 += i4_samp_2 * i4_coeff_2;
2968
0
        i4_rslt_1 += i4_samp_3 * i4_coeff_3;
2969
0
        i4_rslt_1 += 512;
2970
2971
0
        i4_rslt_1 >>= 10;
2972
2973
        /* Store the output */
2974
0
        pu1_out[i4_x] = CLIPUCHAR(i4_rslt_1);
2975
2976
        /* Increment the output ptr */
2977
0
        pu1_out += i4_out_stride;
2978
2979
0
    } /* End of loop over y */
2980
0
} /* isvcd_interpolate_base_luma_dyadic */
2981
2982
/*****************************************************************************/
2983
/*                                                                           */
2984
/*  Function Name : isvcd_vert_interpol_chroma_dyadic_1                       */
2985
/*                                                                           */
2986
/*  Description   : This function takes the reference array buffer & performs*/
2987
/*                  vertical intra resampling for dyadic scaling ratios for  */
2988
/*                    chroma for the following ref_lyr_chroma_phase_y_plus1  */
2989
/*                    chroma_phase_y_plus1:                                  */
2990
/*                        ref_lyr        cur_lyr                             */
2991
/*                            0            0                                 */
2992
/*                            1            0                                 */
2993
/*                            1            1                                 */
2994
/*                            1            2                                 */
2995
/*                            2            1                                 */
2996
/*                            2            2                                 */
2997
/*  Inputs        : pu1_inp_buf : ptr to the 6x6 reference sample buffer     */
2998
/*                    pi2_tmp_filt_buf : ptr to the 6x8 buffer to hold the   */
2999
/*                        vertically interpolated data                       */
3000
/*                    i4_phase_0 : y phase for even values of y              */
3001
/*                    i4_phase_1 : y phase for odd values of y               */
3002
/*  Globals       : none                                                     */
3003
/*  Processing    : it does the interpolation in vertical direction          */
3004
/*  Outputs       : vertically resampled samples                             */
3005
/*  Returns       : none                                                     */
3006
/*                                                                           */
3007
/*  Issues        : none                                                     */
3008
/*                                                                           */
3009
/*  Revision History:                                                        */
3010
/*                                                                           */
3011
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3012
/*         06 09 2021   Vijay           creation                             */
3013
/*                                                                           */
3014
/*****************************************************************************/
3015
void isvcd_vert_interpol_chroma_dyadic_1(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf,
3016
                                         WORD32 i4_phase_0, WORD32 i4_phase_1)
3017
0
{
3018
0
    WORD32 i4_x, i4_y;
3019
0
    WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3020
0
    WORD32 i4_samp_0, i4_samp_1;
3021
0
    WORD32 i4_rslt_1, i4_rslt_2;
3022
0
    WORD32 i4_filt_stride, i4_src_stride;
3023
0
    UWORD8 *pu1_inp;
3024
0
    WORD16 *pi2_tmp;
3025
3026
0
    i4_coeff_0 = 8 - i4_phase_0;
3027
0
    i4_coeff_1 = i4_phase_0;
3028
0
    i4_coeff_2 = 8 - i4_phase_1;
3029
0
    i4_coeff_3 = i4_phase_1;
3030
3031
0
    pu1_inp = pu1_inp_buf;
3032
0
    pi2_tmp = pi2_tmp_filt_buf;
3033
0
    i4_filt_stride = 6;
3034
0
    i4_src_stride = DYADIC_REF_W_C;
3035
3036
    /* Vertical interpolation */
3037
0
    for(i4_x = 0; i4_x < 6; i4_x++)
3038
0
    {
3039
        /* y = 0, y_phase = phase_0 */
3040
0
        i4_samp_0 = pu1_inp[i4_x];
3041
0
        pu1_inp += i4_src_stride;
3042
0
        i4_samp_1 = pu1_inp[i4_x];
3043
0
        pu1_inp += i4_src_stride;
3044
3045
        /* since y_phase = phase_0 for y = 0 */
3046
0
        i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3047
0
        i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3048
3049
        /* Store the output */
3050
0
        pi2_tmp[i4_x] = i4_rslt_1;
3051
3052
        /* Increment the output ptr */
3053
0
        pi2_tmp += i4_filt_stride;
3054
3055
0
        for(i4_y = 1; i4_y < 7; i4_y += 2)
3056
0
        {
3057
0
            i4_samp_0 = i4_samp_1;
3058
0
            i4_samp_1 = pu1_inp[i4_x];
3059
3060
            /* y_phase is phase_1 for odd values of y */
3061
            /* and phase_0 for even values of y          */
3062
0
            i4_rslt_1 = i4_samp_0 * i4_coeff_2;
3063
0
            i4_rslt_1 += i4_samp_1 * i4_coeff_3;
3064
0
            i4_rslt_2 = i4_samp_0 * i4_coeff_0;
3065
0
            i4_rslt_2 += i4_samp_1 * i4_coeff_1;
3066
3067
            /* Storing the results */
3068
0
            pi2_tmp[i4_x] = i4_rslt_1;
3069
0
            pi2_tmp += i4_filt_stride;
3070
0
            pi2_tmp[i4_x] = i4_rslt_2;
3071
3072
            /* Incrementing the pointers */
3073
0
            pi2_tmp += i4_filt_stride;
3074
0
            pu1_inp += i4_src_stride;
3075
3076
0
        } /* End of loop over y */
3077
3078
        /* y = 7, y_phase = phase_1 */
3079
0
        i4_samp_0 = i4_samp_1;
3080
0
        i4_samp_1 = pu1_inp[i4_x];
3081
3082
0
        i4_rslt_1 = i4_samp_0 * i4_coeff_2;
3083
0
        i4_rslt_1 += i4_samp_1 * i4_coeff_3;
3084
3085
        /* Store the output */
3086
0
        pi2_tmp[i4_x] = i4_rslt_1;
3087
3088
        /* Reinitializing the ptrs */
3089
0
        pu1_inp = pu1_inp_buf;
3090
0
        pi2_tmp = pi2_tmp_filt_buf;
3091
3092
0
    } /* End of loop over x */
3093
0
} /* isvcd_vert_interpol_chroma_dyadic_1 */
3094
3095
/*****************************************************************************/
3096
/*                                                                           */
3097
/*  Function Name : isvcd_vert_interpol_chroma_dyadic_2                       */
3098
/*                                                                           */
3099
/*  Description   : This function takes the reference array buffer & performs*/
3100
/*                  vertical intra resampling for dyadic scaling ratios for  */
3101
/*                    chroma for the following ref_lyr_chroma_phase_y_plus1  */
3102
/*                    chroma_phase_y_plus1:                                  */
3103
/*                        ref_lyr        cur_lyr                             */
3104
/*                            0            1                                 */
3105
/*                            0            2                                 */
3106
/*  Inputs        : pu1_inp_buf : ptr to the 6x6 reference sample buffer     */
3107
/*                    pi2_tmp_filt_buf : ptr to the 6x8 buffer to hold the   */
3108
/*                        vertically interpolated data                       */
3109
/*                    i4_phase_0 : y phase for even values of y              */
3110
/*                    i4_phase_1 : y phase for odd values of y               */
3111
/*  Globals       : none                                                     */
3112
/*  Processing    : it does the interpolation in vertical direction          */
3113
/*  Outputs       : vertically resampled samples                             */
3114
/*  Returns       : none                                                     */
3115
/*                                                                           */
3116
/*  Issues        : none                                                     */
3117
/*                                                                           */
3118
/*  Revision History:                                                        */
3119
/*                                                                           */
3120
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3121
/*         06 09 2021   Vijay           creation                             */
3122
/*                                                                           */
3123
/*****************************************************************************/
3124
void isvcd_vert_interpol_chroma_dyadic_2(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf,
3125
                                         WORD32 i4_phase_0, WORD32 i4_phase_1)
3126
0
{
3127
0
    WORD32 i4_x, i4_y;
3128
0
    WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3129
0
    WORD32 i4_samp_0, i4_samp_1;
3130
0
    WORD32 i4_rslt_1, i4_rslt_2;
3131
0
    WORD32 i4_filt_stride, i4_src_stride;
3132
0
    UWORD8 *pu1_inp;
3133
0
    WORD16 *pi2_tmp;
3134
3135
0
    i4_coeff_0 = 8 - i4_phase_0;
3136
0
    i4_coeff_1 = i4_phase_0;
3137
0
    i4_coeff_2 = 8 - i4_phase_1;
3138
0
    i4_coeff_3 = i4_phase_1;
3139
3140
0
    pi2_tmp = pi2_tmp_filt_buf;
3141
0
    i4_filt_stride = 6;
3142
0
    i4_src_stride = DYADIC_REF_W_C;
3143
0
    pu1_inp = pu1_inp_buf + i4_src_stride;
3144
3145
    /* Vertical interpolation */
3146
0
    for(i4_x = 0; i4_x < 6; i4_x++)
3147
0
    {
3148
0
        i4_samp_1 = pu1_inp[i4_x];
3149
0
        pu1_inp += i4_src_stride;
3150
3151
0
        for(i4_y = 0; i4_y < 8; i4_y += 2)
3152
0
        {
3153
0
            i4_samp_0 = i4_samp_1;
3154
0
            i4_samp_1 = pu1_inp[i4_x];
3155
3156
            /* y_phase is phase_1 for odd values of y and phase_0 for even values of y */
3157
0
            i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3158
0
            i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3159
3160
0
            i4_rslt_2 = i4_samp_0 * i4_coeff_2;
3161
0
            i4_rslt_2 += i4_samp_1 * i4_coeff_3;
3162
3163
            /* Storing the results */
3164
0
            pi2_tmp[i4_x] = i4_rslt_1;
3165
0
            pi2_tmp += i4_filt_stride;
3166
0
            pi2_tmp[i4_x] = i4_rslt_2;
3167
3168
            /* Incrementing the pointers */
3169
0
            pi2_tmp += i4_filt_stride;
3170
0
            pu1_inp += i4_src_stride;
3171
3172
0
        } /* End of loop over y */
3173
3174
        /* Reinitializing the ptrs */
3175
0
        pu1_inp = pu1_inp_buf + i4_src_stride;
3176
0
        pi2_tmp = pi2_tmp_filt_buf;
3177
3178
0
    } /* End of loop over x */
3179
0
} /* isvcd_vert_interpol_chroma_dyadic_2 */
3180
3181
/*****************************************************************************/
3182
/*                                                                           */
3183
/*  Function Name : isvcd_vert_interpol_chroma_dyadic_3                       */
3184
/*                                                                           */
3185
/*  Description   : This function takes the reference array buffer & performs*/
3186
/*                  vertical intra resampling for dyadic scaling ratios for  */
3187
/*                    chroma for the following ref_lyr_chroma_phase_y_plus1  */
3188
/*                    chroma_phase_y_plus1:                                  */
3189
/*                        ref_lyr        cur_lyr                             */
3190
/*                            2            0                                 */
3191
/*  Inputs        : pu1_inp_buf : ptr to the 6x6 reference sample buffer     */
3192
/*                    pi2_tmp_filt_buf : ptr to the 6x8 buffer to hold the   */
3193
/*                        vertically interpolated data                       */
3194
/*                    i4_phase_0 : y phase for even values of y              */
3195
/*                    i4_phase_1 : y phase for odd values of y               */
3196
/*  Globals       : none                                                     */
3197
/*  Processing    : it does the interpolation in vertical direction          */
3198
/*  Outputs       : vertically resampled samples                             */
3199
/*  Returns       : none                                                     */
3200
/*                                                                           */
3201
/*  Issues        : none                                                     */
3202
/*                                                                           */
3203
/*  Revision History:                                                        */
3204
/*                                                                           */
3205
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3206
/*         06 09 2021   Vijay           creation                             */
3207
/*                                                                           */
3208
/*****************************************************************************/
3209
void isvcd_vert_interpol_chroma_dyadic_3(UWORD8 *pu1_inp_buf, WORD16 *pi2_tmp_filt_buf,
3210
                                         WORD32 i4_phase_0, WORD32 i4_phase_1)
3211
0
{
3212
0
    WORD32 i4_x, i4_y;
3213
0
    WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3214
0
    WORD32 i4_samp_0, i4_samp_1;
3215
0
    WORD32 i4_rslt_1, i4_rslt_2;
3216
0
    WORD32 i4_filt_stride, i4_src_stride;
3217
0
    UWORD8 *pu1_inp;
3218
0
    WORD16 *pi2_tmp;
3219
3220
0
    i4_coeff_0 = 8 - i4_phase_0;
3221
0
    i4_coeff_1 = i4_phase_0;
3222
0
    i4_coeff_2 = 8 - i4_phase_1;
3223
0
    i4_coeff_3 = i4_phase_1;
3224
3225
0
    pi2_tmp = pi2_tmp_filt_buf;
3226
0
    i4_filt_stride = 6;
3227
0
    i4_src_stride = DYADIC_REF_W_C;
3228
0
    pu1_inp = pu1_inp_buf;
3229
3230
    /* Vertical interpolation */
3231
0
    for(i4_x = 0; i4_x < 6; i4_x++)
3232
0
    {
3233
0
        i4_samp_1 = pu1_inp[i4_x];
3234
0
        pu1_inp += i4_src_stride;
3235
3236
0
        for(i4_y = 0; i4_y < 8; i4_y += 2)
3237
0
        {
3238
0
            i4_samp_0 = i4_samp_1;
3239
0
            i4_samp_1 = pu1_inp[i4_x];
3240
3241
            /* y_phase is phase_1 for odd values of y */
3242
            /* and phase_0 for even values of y          */
3243
0
            i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3244
0
            i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3245
3246
0
            i4_rslt_2 = i4_samp_0 * i4_coeff_2;
3247
0
            i4_rslt_2 += i4_samp_1 * i4_coeff_3;
3248
3249
            /* Storing the results */
3250
0
            pi2_tmp[i4_x] = i4_rslt_1;
3251
0
            pi2_tmp += i4_filt_stride;
3252
0
            pi2_tmp[i4_x] = i4_rslt_2;
3253
3254
            /* Incrementing the pointers */
3255
0
            pi2_tmp += i4_filt_stride;
3256
0
            pu1_inp += i4_src_stride;
3257
3258
0
        } /* End of loop over y */
3259
3260
        /* Reinitializing the ptrs */
3261
0
        pu1_inp = pu1_inp_buf;
3262
0
        pi2_tmp = pi2_tmp_filt_buf;
3263
3264
0
    } /* End of loop over x */
3265
0
} /* isvcd_vert_interpol_chroma_dyadic_3 */
3266
3267
/*****************************************************************************/
3268
/*                                                                           */
3269
/*  Function Name : isvcd_horz_interpol_chroma_dyadic_1                       */
3270
/*                                                                           */
3271
/*  Description   : This function takes the reference array buffer & performs*/
3272
/*                  horizontal intra resampling for dyadic scaling ratios for*/
3273
/*                    chroma with following ref_lyr_chroma_phase_x_plus1_flag*/
3274
/*                    and chroma_phase_x_plus1_flag:                         */
3275
/*                        ref_lyr        cur_lyr                             */
3276
/*                            0            0                                 */
3277
/*                            1            0                                 */
3278
/*                            1            1                                 */
3279
/*  Inputs        : pi2_tmp_filt_buf : ptr to the 6x8 buffer containing the  */
3280
/*                        vertically interpolated data                       */
3281
/*                    pu1_out_buf : pointer to the output buffer             */
3282
/*                    i4_out_stride : output buffer stride                   */
3283
/*                    i4_phase_0 : x phase for even values of x              */
3284
/*                    i4_phase_1 : x phase for odd values of x               */
3285
/*  Globals       : none                                                     */
3286
/*  Processing    : it does the interpolation in vertical direction          */
3287
/*  Outputs       : resampled samples                                        */
3288
/*  Returns       : none                                                     */
3289
/*                                                                           */
3290
/*  Issues        : none                                                     */
3291
/*                                                                           */
3292
/*  Revision History:                                                        */
3293
/*                                                                           */
3294
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3295
/*         06 09 2021   Vijay           creation                             */
3296
/*                                                                           */
3297
/*****************************************************************************/
3298
void isvcd_horz_interpol_chroma_dyadic_1(WORD16 *pi2_tmp_filt_buf, UWORD8 *pu1_out_buf,
3299
                                         WORD32 i4_out_stride, WORD32 i4_phase_0, WORD32 i4_phase_1)
3300
0
{
3301
0
    WORD32 i4_x, i4_y;
3302
0
    WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3303
0
    WORD32 i4_samp_0, i4_samp_1;
3304
0
    WORD32 i4_rslt_1, i4_rslt_2;
3305
0
    WORD32 i4_dst_stride;
3306
0
    UWORD8 *pu1_out;
3307
0
    WORD16 *pi2_tmp;
3308
3309
0
    i4_coeff_0 = 8 - i4_phase_0;
3310
0
    i4_coeff_1 = i4_phase_0;
3311
0
    i4_coeff_2 = 8 - i4_phase_1;
3312
0
    i4_coeff_3 = i4_phase_1;
3313
3314
0
    pu1_out = pu1_out_buf;
3315
0
    pi2_tmp = pi2_tmp_filt_buf;
3316
0
    i4_dst_stride = i4_out_stride;
3317
3318
    /* Horizontal interpolation */
3319
0
    for(i4_y = 0; i4_y < 8; i4_y++)
3320
0
    {
3321
        /* x = 0, x_phase = phase_0 */
3322
0
        i4_samp_0 = *pi2_tmp++;
3323
0
        i4_samp_1 = *pi2_tmp++;
3324
3325
        /* since x_phase = phase_0 for x = 0 */
3326
0
        i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3327
0
        i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3328
3329
        /* Round to 8-bit value */
3330
0
        i4_rslt_1 += 32;
3331
0
        i4_rslt_1 >>= 6;
3332
3333
        /* Store the output */
3334
0
        pu1_out[0] = i4_rslt_1;
3335
3336
0
        for(i4_x = 1; i4_x < 7; i4_x += 2)
3337
0
        {
3338
0
            i4_samp_0 = i4_samp_1;
3339
0
            i4_samp_1 = *pi2_tmp++;
3340
3341
            /* x_phase is phase_1 for odd values of x and phase_0 for even values of x */
3342
0
            i4_rslt_1 = i4_samp_0 * i4_coeff_2;
3343
0
            i4_rslt_1 += i4_samp_1 * i4_coeff_3;
3344
0
            i4_rslt_2 = i4_samp_0 * i4_coeff_0;
3345
0
            i4_rslt_2 += i4_samp_1 * i4_coeff_1;
3346
3347
            /* Rounding to 8-bit values */
3348
0
            i4_rslt_1 += 32;
3349
0
            i4_rslt_1 >>= 6;
3350
0
            i4_rslt_2 += 32;
3351
0
            i4_rslt_2 >>= 6;
3352
3353
            /* Storing the results */
3354
0
            pu1_out[2 * i4_x] = i4_rslt_1;
3355
0
            pu1_out[2 * (i4_x + 1)] = i4_rslt_2;
3356
3357
0
        } /* End of loop over y */
3358
3359
        /* y = 7, y_phase = phase_1 */
3360
0
        i4_samp_0 = i4_samp_1;
3361
0
        i4_samp_1 = *pi2_tmp++;
3362
3363
        /* since x_phase = phase_1 for x = 7 */
3364
0
        i4_rslt_1 = i4_samp_0 * i4_coeff_2;
3365
0
        i4_rslt_1 += i4_samp_1 * i4_coeff_3;
3366
3367
        /* Round to 8-bit value */
3368
0
        i4_rslt_1 += 32;
3369
0
        i4_rslt_1 >>= 6;
3370
3371
        /* Store the output */
3372
0
        pu1_out[2 * 7] = i4_rslt_1;
3373
3374
        /* Incrementing the output ptr */
3375
0
        pu1_out += i4_dst_stride;
3376
3377
0
    } /* End of loop over x */
3378
0
} /* isvcd_horz_interpol_chroma_dyadic_1 */
3379
3380
/*****************************************************************************/
3381
/*                                                                           */
3382
/*  Function Name : isvcd_horz_interpol_chroma_dyadic_2                       */
3383
/*                                                                           */
3384
/*  Description   : This function takes the reference array buffer & performs*/
3385
/*                  horizontal intra resampling for dyadic scaling ratios for*/
3386
/*                    chroma with following ref_lyr_chroma_phase_x_plus1_flag*/
3387
/*                    and chroma_phase_x_plus1_flag:                         */
3388
/*                        ref_lyr        cur_lyr                             */
3389
/*                            0            1                                 */
3390
/*  Inputs        : pi2_tmp_filt_buf : ptr to the 6x8 buffer containing the  */
3391
/*                        vertically interpolated data                       */
3392
/*                    pu1_out_buf : pointer to the output buffer             */
3393
/*                    i4_out_stride : output buffer stride                   */
3394
/*                    i4_phase_0 : x phase for even values of x              */
3395
/*                    i4_phase_1 : x phase for odd values of x               */
3396
/*  Globals       : none                                                     */
3397
/*  Processing    : it does the interpolation in vertical direction          */
3398
/*  Outputs       : resampled samples                                        */
3399
/*  Returns       : none                                                     */
3400
/*                                                                           */
3401
/*  Issues        : none                                                     */
3402
/*                                                                           */
3403
/*  Revision History:                                                        */
3404
/*                                                                           */
3405
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3406
/*         06 09 2021   Vijay           creation                             */
3407
/*                                                                           */
3408
/*****************************************************************************/
3409
void isvcd_horz_interpol_chroma_dyadic_2(WORD16 *pi2_tmp_filt_buf, UWORD8 *pu1_out_buf,
3410
                                         WORD32 i4_out_stride, WORD32 i4_phase_0, WORD32 i4_phase_1)
3411
0
{
3412
0
    WORD32 i4_x, i4_y;
3413
0
    WORD32 i4_coeff_0, i4_coeff_1, i4_coeff_2, i4_coeff_3;
3414
0
    WORD32 i4_samp_0, i4_samp_1;
3415
0
    WORD32 i4_rslt_1, i4_rslt_2;
3416
0
    WORD32 i4_dst_stride;
3417
0
    UWORD8 *pu1_out;
3418
0
    WORD16 *pi2_tmp;
3419
3420
0
    i4_coeff_0 = 8 - i4_phase_0;
3421
0
    i4_coeff_1 = i4_phase_0;
3422
0
    i4_coeff_2 = 8 - i4_phase_1;
3423
0
    i4_coeff_3 = i4_phase_1;
3424
3425
0
    pu1_out = pu1_out_buf;
3426
0
    pi2_tmp = pi2_tmp_filt_buf + 1;
3427
0
    i4_dst_stride = i4_out_stride;
3428
3429
    /* Horizontal interpolation */
3430
0
    for(i4_y = 0; i4_y < 8; i4_y++)
3431
0
    {
3432
        /* x = 0, x_phase = phase_0 */
3433
0
        i4_samp_1 = *pi2_tmp++;
3434
3435
0
        for(i4_x = 0; i4_x < 8; i4_x += 2)
3436
0
        {
3437
0
            i4_samp_0 = i4_samp_1;
3438
0
            i4_samp_1 = *pi2_tmp++;
3439
3440
            /* x_phase is phase_1 for odd values of x */
3441
            /* and phase_0 for even values of x          */
3442
0
            i4_rslt_1 = i4_samp_0 * i4_coeff_0;
3443
0
            i4_rslt_1 += i4_samp_1 * i4_coeff_1;
3444
3445
0
            i4_rslt_2 = i4_samp_0 * i4_coeff_2;
3446
0
            i4_rslt_2 += i4_samp_1 * i4_coeff_3;
3447
3448
            /* Rounding to 8-bit values */
3449
0
            i4_rslt_1 += 32;
3450
0
            i4_rslt_1 >>= 6;
3451
0
            i4_rslt_2 += 32;
3452
0
            i4_rslt_2 >>= 6;
3453
3454
            /* Storing the results */
3455
0
            pu1_out[2 * i4_x] = i4_rslt_1;
3456
0
            pu1_out[2 * (i4_x + 1)] = i4_rslt_2;
3457
3458
0
        } /* End of loop over x */
3459
3460
        /* Incrementing the ptrs */
3461
0
        pi2_tmp += 1;
3462
0
        pu1_out += i4_dst_stride;
3463
3464
0
    } /* End of loop over y */
3465
0
} /* isvcd_horz_interpol_chroma_dyadic_2 */
3466
3467
/*****************************************************************************/
3468
/*                                                                           */
3469
/*  Function Name :  isvcd_intra_resamp_mb_dyadic                               */
3470
/*                                                                           */
3471
/*  Description   : MB level function which performs the intra resampling    */
3472
/*                  of data of an MB (luma and chroma inclusive) for dyadic  */
3473
/*                    scaling ratios                                         */
3474
/*                                                                           */
3475
/*  Inputs        : pv_intra_samp_ctxt : intra sampling context              */
3476
/*                  ps_ref_luma : reference layer luma data buffer desc      */
3477
/*                  ps_ref_chroma : reference layer chroma data buffer desc  */
3478
/*                  ps_ref_mb_mode_map : ref layer mb mode map buff desc     */
3479
/*                  ps_curr_luma : current layer out luma buffer desc        */
3480
/*                  ps_curr_chroma : current layer out chroma buffer desc    */
3481
/*                  x,y : current mb coorinate                               */
3482
/*  Globals       : none                                                     */
3483
/*  Processing    : it calls the reference layer construction followed by    */
3484
/*                   interpolation function for luma and cb and cr           */
3485
/*  Outputs       : inter resampled data of current MB                       */
3486
/*  Returns       : none                                                     */
3487
/*                                                                           */
3488
/*  Issues        : none                                                     */
3489
/*                                                                           */
3490
/*  Revision History:                                                        */
3491
/*                                                                           */
3492
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3493
/*         06 09 2021   Vijay           creation                             */
3494
/*                                                                           */
3495
/*****************************************************************************/
3496
WORD32 isvcd_intra_resamp_mb_dyadic(void *pv_intra_samp_ctxt, mem_element_t *ps_ref_luma,
3497
                                    mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode_map,
3498
                                    mem_element_t *ps_curr_luma, mem_element_t *ps_curr_chroma,
3499
                                    mb_coord_t *ps_mb_coord, void *pv_svc_dec)
3500
0
{
3501
    /* --------------------------------------------------------------------- */
3502
    /* I/O buffer params                                                     */
3503
    /* --------------------------------------------------------------------- */
3504
0
    UWORD8 *pu1_inp_luma, *pu1_inp_chroma;
3505
0
    UWORD8 *pu1_out_luma, *pu1_out_chroma;
3506
0
    UWORD8 *pu1_out_cb, *pu1_out_cr;
3507
0
    UWORD8 *pu1_refarray_luma, *pu1_refarray_cb, *pu1_refarray_cr;
3508
0
    WORD16 *pi2_tmp_filt_buf;
3509
0
    WORD32 i4_inp_luma_stride, i4_inp_chroma_stride;
3510
0
    WORD32 i4_out_luma_stride, i4_out_chroma_stride;
3511
0
    UWORD16 u2_mb_x_ref, u2_mb_y_ref;
3512
0
    svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
3513
0
    dec_slice_svc_ext_params_t *ps_svc_slice_params = NULL;
3514
3515
    /* --------------------------------------------------------------------- */
3516
    /* Intra resampling ctxt pointers                                         */
3517
    /* --------------------------------------------------------------------- */
3518
0
    intra_sampling_ctxt_t *ps_ctxt;
3519
0
    intra_samp_lyr_ctxt *ps_lyr_ctxt;
3520
3521
    /* --------------------------------------------------------------------- */
3522
    /* reference and current layer MB coordinates                             */
3523
    /* --------------------------------------------------------------------- */
3524
0
    WORD32 i4_scaled_mb_x, i4_scaled_mb_y;
3525
0
    WORD32 i4_top, i4_left;
3526
0
    WORD32 ret;
3527
3528
0
    ps_svc_slice_params = &ps_svc_lyr_dec->s_svc_slice_params;
3529
    /* --------------------------------------------------------------------- */
3530
    /* Pointer derivation                                                     */
3531
    /* --------------------------------------------------------------------- */
3532
0
    ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
3533
0
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
3534
3535
    /* --------------------------------------------------------------------- */
3536
    /* MB coordinate derivation                                                 */
3537
    /* --------------------------------------------------------------------- */
3538
0
    i4_scaled_mb_x =
3539
0
        ps_mb_coord->u2_mb_x - (ps_svc_slice_params->i4_scaled_ref_layer_left_offset >> 4);
3540
0
    i4_scaled_mb_y =
3541
0
        ps_mb_coord->u2_mb_y - (ps_svc_slice_params->i4_scaled_ref_layer_top_offset >> 4);
3542
3543
0
    if(i4_scaled_mb_x & 0x1)
3544
0
    {
3545
0
        i4_left = 1;
3546
0
    }
3547
0
    else
3548
0
    {
3549
0
        i4_left = -1;
3550
0
    }
3551
0
    if(i4_scaled_mb_y & 0x1)
3552
0
    {
3553
0
        i4_top = 1;
3554
0
    }
3555
0
    else
3556
0
    {
3557
0
        i4_top = -1;
3558
0
    }
3559
3560
0
    u2_mb_x_ref = (i4_scaled_mb_x >> 1);
3561
0
    u2_mb_y_ref = (i4_scaled_mb_y >> 1);
3562
3563
    /* --------------------------------------------------------------------- */
3564
    /* Reference Array Consrtuction - luma and chroma                         */
3565
    /* --------------------------------------------------------------------- */
3566
0
    pu1_inp_luma = (UWORD8 *) ps_ref_luma->pv_buffer;
3567
0
    pu1_inp_chroma = (UWORD8 *) ps_ref_chroma->pv_buffer;
3568
0
    i4_inp_luma_stride = ps_ref_luma->i4_num_element_stride;
3569
0
    i4_inp_chroma_stride = ps_ref_chroma->i4_num_element_stride;
3570
3571
    /* ------- Constructing refSampleArray ----------------------- */
3572
0
    ret = isvcd_reflayer_construction_dyadic(
3573
0
        pv_intra_samp_ctxt, ps_ref_mb_mode_map, pu1_inp_luma, pu1_inp_chroma, i4_inp_luma_stride,
3574
0
        i4_inp_chroma_stride, i4_top, i4_left, u2_mb_x_ref, u2_mb_y_ref);
3575
3576
0
    if(ret != OK)
3577
0
    {
3578
0
        return NOT_OK;
3579
0
    }
3580
    /* --------------------------------------------------------------------- */
3581
    /* LUMA INTERPOLATION                                                       */
3582
    /* --------------------------------------------------------------------- */
3583
0
    pu1_refarray_luma = ps_ctxt->pu1_refarray_buffer;
3584
0
    if(1 == i4_top)
3585
0
    {
3586
0
        pu1_refarray_luma += (DYADIC_REF_W_Y << 3);
3587
0
    }
3588
0
    if(1 == i4_left)
3589
0
    {
3590
0
        pu1_refarray_luma += 8;
3591
0
    }
3592
0
    pu1_out_luma = (UWORD8 *) ps_curr_luma->pv_buffer;
3593
0
    i4_out_luma_stride = ps_curr_luma->i4_num_element_stride;
3594
0
    pi2_tmp_filt_buf = (WORD16 *) ps_ctxt->pi4_temp_interpolation_buffer;
3595
3596
0
    ps_ctxt->pf_interpolate_base_luma_dyadic(pu1_refarray_luma, pi2_tmp_filt_buf, pu1_out_luma,
3597
0
                                             i4_out_luma_stride);
3598
3599
    /* --------------------------------------------------------------------- */
3600
    /* CHROMA INTERPOLATION                                                     */
3601
    /* --------------------------------------------------------------------- */
3602
0
    pu1_out_chroma = (UWORD8 *) ps_curr_chroma->pv_buffer;
3603
0
    i4_out_chroma_stride = ps_curr_chroma->i4_num_element_stride;
3604
3605
    /* CB */
3606
0
    pu1_out_cb = pu1_out_chroma;
3607
0
    pu1_refarray_cb = ps_ctxt->pu1_refarray_cb;
3608
3609
0
    if(1 == i4_top)
3610
0
    {
3611
0
        pu1_refarray_cb += (DYADIC_REF_W_C << 2);
3612
0
    }
3613
0
    if(1 == i4_left)
3614
0
    {
3615
0
        pu1_refarray_cb += 4;
3616
0
    }
3617
3618
    /* Vertical interpolation */
3619
0
    ps_lyr_ctxt->pf_vert_chroma_interpol(pu1_refarray_cb, pi2_tmp_filt_buf,
3620
0
                                         ps_lyr_ctxt->i4_y_phase_0, ps_lyr_ctxt->i4_y_phase_1);
3621
3622
    /* Horizontal interpolation */
3623
0
    ps_lyr_ctxt->pf_horz_chroma_interpol(pi2_tmp_filt_buf, pu1_out_cb, i4_out_chroma_stride,
3624
0
                                         ps_lyr_ctxt->i4_x_phase_0, ps_lyr_ctxt->i4_x_phase_1);
3625
3626
    /* CR */
3627
0
    pu1_out_cr = pu1_out_chroma + 1;
3628
0
    pu1_refarray_cr = ps_ctxt->pu1_refarray_cr;
3629
3630
0
    if(1 == i4_top)
3631
0
    {
3632
0
        pu1_refarray_cr += (DYADIC_REF_W_C << 2);
3633
0
    }
3634
0
    if(1 == i4_left)
3635
0
    {
3636
0
        pu1_refarray_cr += 4;
3637
0
    }
3638
3639
    /* Vertical interpolation */
3640
0
    ps_lyr_ctxt->pf_vert_chroma_interpol(pu1_refarray_cr, pi2_tmp_filt_buf,
3641
0
                                         ps_lyr_ctxt->i4_y_phase_0, ps_lyr_ctxt->i4_y_phase_1);
3642
3643
    /* Horizontal interpolation */
3644
0
    ps_lyr_ctxt->pf_horz_chroma_interpol(pi2_tmp_filt_buf, pu1_out_cr, i4_out_chroma_stride,
3645
0
                                         ps_lyr_ctxt->i4_x_phase_0, ps_lyr_ctxt->i4_x_phase_1);
3646
0
    return OK;
3647
0
}
3648
3649
/*****************************************************************************/
3650
/*                                                                           */
3651
/*  Function Name : isvcd_interpolate_intra_base                              */
3652
/*                                                                           */
3653
/*  Description   : This function takes the reference array buffer & performs*/
3654
/*                    interpolation of a component to find the intra         */
3655
/*                     resampled value                                       */
3656
/*  Inputs        : pv_intra_samp_ctxt : intra sampling context              */
3657
/*                  pu1_out : output buffer pointer                          */
3658
/*                  i4_out_stride : output buffer stride                     */
3659
/*                  i4_refarray_wd : reference array width                   */
3660
/*                  i4_x_offset : offset in reference layer in horz direction*/
3661
/*                  ps_coord : current mb co-ordinate                        */
3662
/*                  i4_chroma_flag : chroma processing flag                  */
3663
/*  Globals       : none                                                     */
3664
/*  Processing    : it does the interpolation in vertical direction followed */
3665
/*                  by horizontal direction                                  */
3666
/*  Outputs       : resampled pixels                                         */
3667
/*  Returns       : none                                                     */
3668
/*                                                                           */
3669
/*  Issues        : none                                                     */
3670
/*                                                                           */
3671
/*  Revision History:                                                        */
3672
/*                                                                           */
3673
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3674
/*         26 09 2021   vijayakumar          creation                        */
3675
/*                                                                           */
3676
/*****************************************************************************/
3677
void isvcd_interpolate_intra_base(void *pv_intra_samp_ctxt, UWORD8 *pu1_out, WORD32 i4_out_stride,
3678
                                  WORD32 i4_refarray_wd, WORD32 i4_mb_x, WORD32 i4_mb_y,
3679
                                  WORD32 i4_chroma_flag, WORD32 i4_refarray_flag)
3680
1.26k
{
3681
    /* --------------------------------------------------------------------- */
3682
    /* Index Parameters                                                         */
3683
    /* --------------------------------------------------------------------- */
3684
1.26k
    intra_sampling_ctxt_t *ps_ctxt;
3685
1.26k
    intra_samp_map_ctxt_t *ps_map_ctxt;
3686
1.26k
    intra_samp_lyr_ctxt *ps_lyr_ctxt;
3687
1.26k
    WORD32 i4_x, i4_y;
3688
1.26k
    WORD32 i4_frm_mb_x, i4_frm_mb_y;
3689
1.26k
    ref_pixel_map_t *ps_x_pos_phase;
3690
1.26k
    ref_pixel_map_t *ps_y_pos_phase;
3691
3692
1.26k
    WORD32 i4_temp_array_ht;
3693
1.26k
    WORD32 *pi4_interp_buff;
3694
1.26k
    WORD32 *pi4_interp_buff_temp;
3695
1.26k
    WORD32 i4_mb_wd;
3696
1.26k
    WORD32 i4_mb_ht;
3697
1.26k
    WORD32 i4_x_min, i4_x_max;
3698
1.26k
    ref_min_max_map_t *ps_x_min_max;
3699
1.26k
    UWORD8 *pu1_refarray = NULL;
3700
3701
    /* --------------------------------------------------------------------- */
3702
    /* Extracting pointers from the  context                                  */
3703
    /* --------------------------------------------------------------------- */
3704
1.26k
    ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
3705
1.26k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
3706
3707
1.26k
    if(0 == i4_refarray_flag)
3708
842
    {
3709
842
        pu1_refarray = ps_ctxt->pu1_refarray_buffer;
3710
842
    }
3711
421
    else if(1 == i4_refarray_flag)
3712
421
    {
3713
421
        pu1_refarray = ps_ctxt->pu1_refarray_cb;
3714
421
    }
3715
3716
    /* --------------------------------------------------------------------- */
3717
    /* LUMA    or CHROMA */
3718
    /* --------------------------------------------------------------------- */
3719
1.26k
    if(1 == i4_chroma_flag)
3720
842
        ps_map_ctxt = &(ps_lyr_ctxt->s_chroma_map_ctxt);
3721
421
    else
3722
421
        ps_map_ctxt = &(ps_lyr_ctxt->s_luma_map_ctxt);
3723
3724
1.26k
    i4_mb_wd = MB_WIDTH >> i4_chroma_flag;
3725
1.26k
    i4_mb_ht = MB_HEIGHT >> i4_chroma_flag;
3726
1.26k
    ps_x_min_max = ps_map_ctxt->ps_x_min_max;
3727
1.26k
    i4_frm_mb_y = i4_mb_y * i4_mb_ht;
3728
1.26k
    i4_frm_mb_x = i4_mb_x * i4_mb_wd;
3729
3730
    /* get the min and max positions */
3731
1.26k
    i4_x_min = ps_x_min_max[i4_mb_x].i2_min_pos;
3732
1.26k
    i4_x_max = ps_x_min_max[i4_mb_x].i2_max_pos;
3733
3734
    /* --------------------------------------------------------------------- */
3735
    /* Projected frame level pointers                                        */
3736
    /* --------------------------------------------------------------------- */
3737
1.26k
    ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase;
3738
1.26k
    ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase;
3739
3740
    /* --------------------------------------------------------------------- */
3741
    /* Pointers and Dimenstion of the temporary buffer                         */
3742
    /* --------------------------------------------------------------------- */
3743
1.26k
    i4_temp_array_ht = i4_mb_ht;
3744
1.26k
    pi4_interp_buff = ps_ctxt->pi4_temp_interpolation_buffer;
3745
1.26k
    pi4_interp_buff_temp = pi4_interp_buff;
3746
3747
    /* --------------------------------------------------------------------- */
3748
    /* Loop for interpolation in vertical direction                             */
3749
    /* --------------------------------------------------------------------- */
3750
14.7k
    for(i4_y = 0; i4_y < (i4_temp_array_ht); i4_y++)
3751
13.4k
    {
3752
178k
        for(i4_x = (i4_x_min - 1); i4_x <= (i4_x_max + 2); i4_x++)
3753
165k
        {
3754
165k
            UWORD8 *pu1_refarray_temp;
3755
165k
            WORD32 i4_y_ref;
3756
165k
            WORD32 i4_y_phase;
3757
            /* ------------------------------------------------------------ */
3758
            /* Finding the offset                                            */
3759
            /* ------------------------------------------------------------ */
3760
165k
            i4_y_ref = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_ref_pos;
3761
165k
            i4_y_phase = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_phase;
3762
165k
            pu1_refarray_temp = pu1_refarray + i4_x + (i4_y_ref * i4_refarray_wd);
3763
3764
            /* ------------------------------------------------------------ */
3765
            /* Check for Luma/Chroma Processing                                */
3766
            /* ------------------------------------------------------------ */
3767
165k
            if(0 == i4_chroma_flag)
3768
101k
            {
3769
101k
                *(pi4_interp_buff + i4_x) =
3770
101k
                    (g_ai1_interp_filter_luma[i4_y_phase]) *
3771
101k
                        (*(pu1_refarray_temp - i4_refarray_wd)) +
3772
3773
101k
                    (g_ai1_interp_filter_luma[16 + i4_y_phase]) * (*(pu1_refarray_temp)) +
3774
3775
101k
                    (g_ai1_interp_filter_luma[32 + i4_y_phase]) *
3776
101k
                        (*(pu1_refarray_temp + i4_refarray_wd)) +
3777
3778
101k
                    (g_ai1_interp_filter_luma[48 + i4_y_phase]) *
3779
101k
                        (*(pu1_refarray_temp + (2 * i4_refarray_wd)));
3780
101k
            }
3781
64.1k
            else
3782
64.1k
            {
3783
64.1k
                *(pi4_interp_buff + i4_x) =
3784
64.1k
                    (g_au1_interp_filter_chroma[i4_y_phase]) * (*(pu1_refarray_temp)) +
3785
3786
64.1k
                    (g_au1_interp_filter_chroma[16 + i4_y_phase]) *
3787
64.1k
                        (*(pu1_refarray_temp + i4_refarray_wd));
3788
64.1k
            }
3789
3790
165k
        } /* end of loop over array  width */
3791
13.4k
        pi4_interp_buff = pi4_interp_buff + i4_refarray_wd;
3792
13.4k
    }     /* end of loop over temp array height*/
3793
3794
1.26k
    pi4_interp_buff = pi4_interp_buff_temp;
3795
3796
    /* --------------------------------------------------------------------- */
3797
    /* Loop for interpolation in horizontal direction                         */
3798
    /* --------------------------------------------------------------------- */
3799
14.7k
    for(i4_y = 0; i4_y < i4_temp_array_ht; i4_y++)
3800
13.4k
    {
3801
175k
        for(i4_x = 0; i4_x < i4_mb_wd; i4_x++)
3802
161k
        {
3803
161k
            WORD32 i4_x_ref;
3804
161k
            WORD32 i4_x_phase;
3805
            /* ------------------------------------------------------------- */
3806
            /* Finding the offset                                             */
3807
            /* ------------------------------------------------------------- */
3808
161k
            i4_x_ref = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_ref_pos;
3809
161k
            i4_x_phase = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_phase;
3810
161k
            pi4_interp_buff_temp = pi4_interp_buff + i4_x_ref;
3811
3812
            /* ------------------------------------------------------------- */
3813
            /* Check for Luma/Chroma Processing                                 */
3814
            /* ------------------------------------------------------------- */
3815
161k
            if(0 == i4_chroma_flag)
3816
107k
            {
3817
107k
                *(pu1_out + i4_x + (i4_y * i4_out_stride)) =
3818
3819
107k
                    CLIPUCHAR(
3820
107k
                        ((g_ai1_interp_filter_luma[i4_x_phase]) * (*(pi4_interp_buff_temp - 1)) +
3821
107k
                         (g_ai1_interp_filter_luma[16 + i4_x_phase]) * (*(pi4_interp_buff_temp)) +
3822
107k
                         (g_ai1_interp_filter_luma[32 + i4_x_phase]) *
3823
107k
                             (*(pi4_interp_buff_temp + 1)) +
3824
107k
                         (g_ai1_interp_filter_luma[48 + i4_x_phase]) *
3825
107k
                             (*(pi4_interp_buff_temp + 2)) +
3826
107k
                         512) >>
3827
107k
                        10);
3828
107k
            }
3829
53.8k
            else
3830
53.8k
            {
3831
53.8k
                *(pu1_out + (2 * i4_x) + (i4_y * i4_out_stride)) = CLIPUCHAR(
3832
53.8k
                    ((g_au1_interp_filter_chroma[i4_x_phase]) * (*(pi4_interp_buff_temp)) +
3833
53.8k
                     (g_au1_interp_filter_chroma[16 + i4_x_phase]) * (*(pi4_interp_buff_temp + 1)) +
3834
53.8k
                     512) >>
3835
53.8k
                    10);
3836
53.8k
            }
3837
3838
161k
        } /* end of loop over array width */
3839
13.4k
        pi4_interp_buff = pi4_interp_buff + i4_refarray_wd;
3840
13.4k
    }     /* end of loop over MB height */
3841
3842
1.26k
    return;
3843
1.26k
} /* End of Interpolation Function */
3844
/*****************************************************************************/
3845
/*                                                                           */
3846
/*  Function Name :  isvcd_intra_resamp_mb                                      */
3847
/*                                                                           */
3848
/*  Description   : MB level function whcih perform the intra resampling     */
3849
/*                  of data of an MB (luma and chroma insclusive)            */
3850
/*                                                                           */
3851
/*  Inputs        : pv_intra_samp_ctxt : intra sampling context              */
3852
/*                  ps_ref_luma : reference layer luma data buffer desc      */
3853
/*                  ps_ref_chroma : reference layer chroma data buffer desc  */
3854
/*                  ps_ref_mb_mode_map : ref layer mb mode map buff desc     */
3855
/*                  ps_curr_luma : current layer out luma buffer desc        */
3856
/*                  ps_curr_chroma : current layer out chroma buffer desc    */
3857
/*                  ps_mb_coord : current mb coorinate                       */
3858
/*  Globals       : none                                                     */
3859
/*  Processing    : it calls the reference layer construction followed by    */
3860
/*                   interpolation function for luma and cb and cr           */
3861
/*  Outputs       : inter resampled data of current MB                       */
3862
/*  Returns       : none                                                     */
3863
/*                                                                           */
3864
/*  Issues        : none                                                     */
3865
/*                                                                           */
3866
/*  Revision History:                                                        */
3867
/*                                                                           */
3868
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3869
/*         06 09 2021   Vijay                creation                        */
3870
/*                                                                           */
3871
/*****************************************************************************/
3872
WORD32 isvcd_intra_resamp_mb(void *pv_intra_samp_ctxt, mem_element_t *ps_ref_luma,
3873
                             mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode_map,
3874
                             mem_element_t *ps_curr_luma, mem_element_t *ps_curr_chroma,
3875
                             mb_coord_t *ps_mb_coord)
3876
421
{
3877
    /* --------------------------------------------------------------------- */
3878
    /* I/O buffer params                                                     */
3879
    /* --------------------------------------------------------------------- */
3880
421
    intra_sampling_ctxt_t *ps_ctxt;
3881
421
    UWORD8 *pu1_inp_luma, *pu1_inp_cb, *pu1_inp_cr;
3882
421
    UWORD8 *pu1_out_luma, *pu1_out_cb, *pu1_out_cr;
3883
421
    WORD32 i4_inp_stride;
3884
421
    WORD32 i4_out_stride;
3885
421
    WORD32 i4_refarray_stride;
3886
3887
    /* --------------------------------------------------------------------- */
3888
    /* ref sample array and corresponding parametrs                             */
3889
    /* --------------------------------------------------------------------- */
3890
421
    WORD32 i4_chroma_flag, ret;
3891
3892
421
    ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
3893
    /* needs to be populated at proper place */
3894
421
    i4_refarray_stride = ps_ctxt->i4_refarray_stride;
3895
3896
    /* --------------------------------------------------------------------- */
3897
    /* LUMA PROCESSING                                                        */
3898
    /* --------------------------------------------------------------------- */
3899
421
    pu1_inp_luma = (UWORD8 *) ps_ref_luma->pv_buffer;
3900
421
    pu1_out_luma = (UWORD8 *) ps_curr_luma->pv_buffer;
3901
421
    i4_inp_stride = ps_ref_luma->i4_num_element_stride;
3902
421
    i4_out_stride = ps_curr_luma->i4_num_element_stride;
3903
421
    i4_chroma_flag = 0;
3904
3905
    /* ------- Constructing refSampleArray ----------------------- */
3906
421
    ret = isvcd_reflayer_construction(pv_intra_samp_ctxt, pu1_inp_luma, NULL, i4_inp_stride,
3907
421
                                      i4_refarray_stride, ps_ref_mb_mode_map, ps_mb_coord,
3908
421
                                      i4_chroma_flag);
3909
3910
421
    if(ret != OK)
3911
0
    {
3912
0
        return NOT_OK;
3913
0
    }
3914
    /* ---- Interpolation process for Intra_Base prediction     ------ */
3915
421
    ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_luma, i4_out_stride,
3916
421
                                       i4_refarray_stride, ps_mb_coord->u2_mb_x,
3917
421
                                       ps_mb_coord->u2_mb_y, i4_chroma_flag, 0);
3918
3919
    /* --------------------------------------------------------------------- */
3920
    /* CHROMA PROCESSING                                                       */
3921
    /* --------------------------------------------------------------------- */
3922
    /* CB */
3923
421
    i4_inp_stride = ps_ref_chroma->i4_num_element_stride;
3924
421
    pu1_inp_cb = (UWORD8 *) ps_ref_chroma->pv_buffer;
3925
421
    pu1_inp_cr = pu1_inp_cb + 1;
3926
421
    i4_chroma_flag = 1;
3927
3928
    /* ------- Constructing refSampleArray ----------------------- */
3929
421
    ret = isvcd_reflayer_construction(pv_intra_samp_ctxt, pu1_inp_cb, pu1_inp_cr, i4_inp_stride,
3930
421
                                      i4_refarray_stride, ps_ref_mb_mode_map, ps_mb_coord,
3931
421
                                      i4_chroma_flag);
3932
3933
421
    if(ret != OK)
3934
0
    {
3935
0
        return NOT_OK;
3936
0
    }
3937
421
    i4_out_stride = ps_curr_chroma->i4_num_element_stride;
3938
421
    pu1_out_cb = (UWORD8 *) ps_curr_chroma->pv_buffer;
3939
421
    pu1_out_cr = pu1_out_cb + 1;
3940
3941
    /* ---- Cb Interpolation process for Intra_Base prediction     ------ */
3942
421
    ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_cb, i4_out_stride,
3943
421
                                       i4_refarray_stride, ps_mb_coord->u2_mb_x,
3944
421
                                       ps_mb_coord->u2_mb_y, i4_chroma_flag, 0);
3945
3946
    /* ---- Cr Interpolation process for Intra_Base prediction     ------ */
3947
421
    ps_ctxt->pf_interpolate_intra_base(pv_intra_samp_ctxt, pu1_out_cr, i4_out_stride,
3948
421
                                       i4_refarray_stride, ps_mb_coord->u2_mb_x,
3949
421
                                       ps_mb_coord->u2_mb_y, i4_chroma_flag, 1);
3950
421
    return OK;
3951
421
}
3952
3953
/*****************************************************************************/
3954
/*                                                                           */
3955
/*  Function Name : isvcd_intra_resamp_generate_segment_lookup                */
3956
/*                                                                           */
3957
/*  Description   : This function generates segment lookup used to derive    */
3958
/*                    segments which have to be be intra resampled           */
3959
/*                                                                           */
3960
/*  Inputs        : pv_lookup_table : look up table                          */
3961
/*                  i4_dimension    : dimension of the block which is used in*/
3962
/*                                      resampling process.                  */
3963
/*                  i4_mb_size        : size of the mb                       */
3964
/*  Globals       : None                                                     */
3965
/*  Processing    : This function generates segment lookup used to derive    */
3966
/*                    segments which have to be be intra resampled           */
3967
/*  Outputs          : none                                                  */
3968
/*  Returns          : none                                                  */
3969
/*                                                                           */
3970
/*  Issues       : None                                                      */
3971
/*                                                                           */
3972
/*  Revision History:                                                        */
3973
/*                                                                           */
3974
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
3975
/*         06 09 2021   Vijay           Creation                             */
3976
/*                                                                           */
3977
/*****************************************************************************/
3978
void isvcd_intra_resamp_generate_segment_lookup(seg_lookup_desc_t *ps_seg_lookup_table,
3979
                                                WORD32 i4_dimension, WORD32 i4_mb_size,
3980
                                                WORD32 i4_shift_val)
3981
320
{
3982
320
    WORD32 i4_x;
3983
320
    WORD32 i4_position, i4_dist_prev_mb, i4_dist_next_mb;
3984
320
    UWORD8 u1_seg_dim;
3985
320
    UWORD8 u1_num_sgmts;
3986
320
    WORD32 i4_block_size = i4_mb_size >> 1;
3987
320
    UWORD8 u1_offset = 0;
3988
320
    seg_lookup_desc_t *ps_segments;
3989
320
    seg_description_t *ps_seg_desc;
3990
3991
320
    memset(ps_seg_lookup_table, 0, i4_mb_size * sizeof(seg_lookup_desc_t));
3992
3993
4.16k
    for(i4_x = 0; i4_x < i4_mb_size; i4_x++)
3994
3.84k
    {
3995
3.84k
        ps_segments = &ps_seg_lookup_table[i4_x];
3996
3.84k
        ps_seg_desc = ps_segments->s_segments;
3997
3.84k
        i4_position = i4_x;
3998
3999
3.84k
        if(i4_x >= i4_block_size)
4000
1.92k
        {
4001
            /* set the fourth bit so that later it can be directly OR ed */
4002
1.92k
            ps_segments->u4_start_pos = 8;
4003
1.92k
        }
4004
1.92k
        else
4005
1.92k
        {
4006
1.92k
            ps_segments->u4_start_pos = 0;
4007
1.92k
        }
4008
4009
3.84k
        u1_num_sgmts = 0;
4010
3.84k
        u1_offset = 0;
4011
4012
14.4k
        while(i4_position < (i4_x + i4_dimension))
4013
10.5k
        {
4014
            /* check and fill the nearest mb boundry flag */
4015
10.5k
            if((i4_position & (i4_mb_size - 1)) < i4_block_size)
4016
5.28k
            {
4017
5.28k
                ps_seg_desc->i1_nearst_mb_bdry = -1;
4018
5.28k
            }
4019
5.28k
            else
4020
5.28k
            {
4021
5.28k
                ps_seg_desc->i1_nearst_mb_bdry = 1;
4022
5.28k
            }
4023
4024
            /* find the distance from the previous MB for start of segment*/
4025
10.5k
            i4_dist_prev_mb = (i4_position & (i4_mb_size - 1));
4026
4027
10.5k
            ps_seg_desc->i1_dist_idx =
4028
10.5k
                ((i4_dist_prev_mb >= i4_mb_size >> 1) ? (i4_mb_size - i4_dist_prev_mb)
4029
10.5k
                                                      : -(i4_dist_prev_mb + 1));
4030
4031
            /* find the size of the segment */
4032
10.5k
            u1_seg_dim = (i4_block_size - (i4_position & (i4_block_size - 1)));
4033
10.5k
            i4_position += u1_seg_dim;
4034
10.5k
            if(i4_position > (i4_x + i4_dimension))
4035
3.20k
            {
4036
3.20k
                i4_position = (i4_x + i4_dimension);
4037
3.20k
                u1_seg_dim = (i4_position & (i4_block_size - 1));
4038
3.20k
            }
4039
4040
            /* find the distance from the next MB for end of segment */
4041
10.5k
            i4_dist_next_mb = (i4_position & (i4_mb_size - 1));
4042
10.5k
            ps_seg_desc->u1_seg_dim = u1_seg_dim;
4043
10.5k
            ps_seg_desc->u1_seg_off = u1_offset;
4044
4045
            /* check if the segment has a adjoining MB edge */
4046
10.5k
            if(i4_dist_prev_mb == 0)
4047
3.68k
            {
4048
3.68k
                if(0 == u1_num_sgmts)
4049
320
                {
4050
320
                    ps_seg_desc->u1_mb_adjoin = 0;
4051
320
                }
4052
3.36k
                else
4053
3.36k
                {
4054
3.36k
                    ps_seg_desc->u1_mb_adjoin = 1 << i4_shift_val;
4055
3.36k
                }
4056
3.68k
            }
4057
6.88k
            else if(i4_dist_next_mb == 0)
4058
3.68k
            {
4059
3.68k
                if(i4_position == (i4_x + i4_dimension))
4060
320
                {
4061
320
                    ps_seg_desc->u1_mb_adjoin = 0;
4062
320
                }
4063
3.36k
                else
4064
3.36k
                {
4065
3.36k
                    ps_seg_desc->u1_mb_adjoin = 1 << i4_shift_val;
4066
3.36k
                }
4067
3.68k
            }
4068
3.20k
            else
4069
3.20k
            {
4070
3.20k
                ps_seg_desc->u1_mb_adjoin = 0;
4071
3.20k
            }
4072
4073
            /* Updations */
4074
10.5k
            u1_offset += u1_seg_dim;
4075
10.5k
            u1_num_sgmts++;
4076
10.5k
            ps_seg_desc++;
4077
10.5k
        }
4078
4079
        /* fill the number of segments for this position */
4080
3.84k
        ps_segments->u1_num_segments = u1_num_sgmts;
4081
3.84k
    }
4082
320
}
4083
4084
/*****************************************************************************/
4085
/*                                                                           */
4086
/*  Function Name : isvcd_intra_resamp_populate_list                            */
4087
/*                                                                           */
4088
/*  Description   : This is a seq or frame level init function which fills   */
4089
/*                  all offsets, projected locations arrays based on         */
4090
/*                  the two resolutions  and cropping parameters             */
4091
/*  Inputs        : refer ot doxygen comments below                          */
4092
/*  Globals       : none                                                     */
4093
/*  Processing    : it projects the locations and computes the values        */
4094
/*                                                                           */
4095
/*  Outputs       : none                                                     */
4096
/*  Returns       : none                                                     */
4097
/*                                                                           */
4098
/*  Issues        : none                                                     */
4099
/*                                                                           */
4100
/*  Revision History:                                                        */
4101
/*                                                                           */
4102
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
4103
/*         26 06 2009   vijayakumar          creation                        */
4104
/*                                                                           */
4105
/*****************************************************************************/
4106
void isvcd_intra_resamp_populate_list(intra_samp_map_ctxt_t *ps_map_ctxt,
4107
                                      res_prms_t *ps_curr_res_prms, res_prms_t *ps_ref_res_prms,
4108
                                      WORD32 i4_chroma_flag, svc_dec_lyr_struct_t *ps_svc_lyr_dec)
4109
1.44k
{
4110
    /* --------------------------------------------------------------------- */
4111
    /* Local variables required for finding the mapping between the layers     */
4112
    /* --------------------------------------------------------------------- */
4113
1.44k
    UWORD32 i4_shift_x, i4_shift_y, i4_scale_x, i4_scale_y;
4114
1.44k
    WORD32 i4_offset_x, i4_offset_y;
4115
1.44k
    WORD32 i4_add_x, i4_add_y, i4_delta_x, i4_delta_y, i4_refphase_x, i4_refphase_y;
4116
1.44k
    WORD32 i4_phase_x, i4_phase_y, i4_sub_wd, i4_sub_ht, i4_mb_wd, i4_mb_ht;
4117
1.44k
    WORD32 i4_horz_dim, i4_vert_dim, i4_tmp;
4118
1.44k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
4119
    /* --------------------------------------------------------------------- */
4120
    /* Local Pointer Declaration for arrays in Mapping context                 */
4121
    /* --------------------------------------------------------------------- */
4122
1.44k
    ref_mb_map_t *ps_x_off_len, *ps_y_off_len;
4123
1.44k
    UWORD32 i4_ref_wd, i4_ref_ht, i4_scaled_wd, i4_scaled_ht, i4_curr_lyr_width, i4_curr_lyr_height;
4124
4125
    /* --------------------------------------------------------------------- */
4126
    /* Local Flag Declaration                                                 */
4127
    /* --------------------------------------------------------------------- */
4128
1.44k
    WORD32 i4_ref_layer_field_pic_flag, i4_field_pic_flag, i4_frame_mbs_only_flag;
4129
1.44k
    WORD32 i4_ref_layer_frame_Mbs_only_flag, i4_field_Mb_flag, i4_bot_field_flag;
4130
4131
    /* --------------------------------------------------------------------- */
4132
    /* Cropping Parameters Declaration                                         */
4133
    /* --------------------------------------------------------------------- */
4134
1.44k
    WORD32 i4_scaled_ref_layer_left_offset, i4_scaled_ref_layer_top_offset;
4135
1.44k
    WORD32 i4_scaled_ref_layer_right_offset, i4_scaled_ref_layer_bottom_offset;
4136
1.44k
    dec_seq_params_t *ps_sps;
4137
1.44k
    dec_svc_seq_params_t *ps_subset_sps;
4138
1.44k
    ps_sps = ps_dec->ps_cur_sps;
4139
1.44k
    ps_subset_sps = ps_svc_lyr_dec->ps_cur_subset_sps;
4140
4141
    /* --------------------------------------------------------------------- */
4142
    /* Hardcoding flag information    (assuming no field support) */
4143
    /* --------------------------------------------------------------------- */
4144
1.44k
    i4_ref_layer_field_pic_flag = SVCD_FALSE;
4145
1.44k
    i4_field_pic_flag = SVCD_FALSE;
4146
1.44k
    i4_frame_mbs_only_flag = SVCD_TRUE;
4147
1.44k
    i4_field_Mb_flag = SVCD_FALSE;
4148
1.44k
    i4_bot_field_flag = SVCD_FALSE;
4149
1.44k
    i4_ref_layer_frame_Mbs_only_flag = SVCD_TRUE;
4150
1.44k
    i4_horz_dim = 0;
4151
1.44k
    i4_vert_dim = 0;
4152
4153
    /* --------------------------------------------------------------------- */
4154
    /* Pointer and Paramater are intialized    - Chroma and Luma */
4155
    /* --------------------------------------------------------------------- */
4156
1.44k
    {
4157
1.44k
        WORD32 i4_base_width;
4158
1.44k
        WORD32 i4_base_height;
4159
1.44k
        WORD32 i4_ref_layer_chroma_phase_x_plus1_flag;
4160
1.44k
        WORD32 i4_ref_layer_chroma_phase_y_plus1;
4161
1.44k
        WORD32 i4_chroma_phase_x_plus1_flag;
4162
1.44k
        WORD32 i4_chroma_phase_y_plus1;
4163
4164
        /* ------------------------------------------------------------- */
4165
        /* HARD CODED FOR 420                                             */
4166
        /* ------------------------------------------------------------- */
4167
1.44k
        WORD32 i4_sub_wd_chroma = 2;
4168
1.44k
        WORD32 i4_sub_ht_chroma = 2;
4169
4170
1.44k
        i4_base_width = ps_ref_res_prms->i4_res_width;
4171
1.44k
        i4_base_height = ps_ref_res_prms->i4_res_height;
4172
4173
1.44k
        i4_ref_layer_chroma_phase_x_plus1_flag =
4174
1.44k
            ps_curr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag;
4175
4176
1.44k
        i4_ref_layer_chroma_phase_y_plus1 = ps_curr_res_prms->i1_ref_lyr_chroma_phase_y_plus1;
4177
1.44k
        i4_chroma_phase_x_plus1_flag = ps_subset_sps->s_sps_svc_ext.u1_chroma_phase_x_plus1_flag;
4178
1.44k
        i4_chroma_phase_y_plus1 = ps_subset_sps->s_sps_svc_ext.u1_chroma_phase_y_plus1;
4179
1.44k
        i4_scaled_ref_layer_bottom_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_bot;
4180
1.44k
        i4_scaled_ref_layer_left_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_left;
4181
1.44k
        i4_scaled_ref_layer_top_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_top;
4182
1.44k
        i4_scaled_ref_layer_right_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_rt;
4183
4184
        /* ----------------------------------------------------------------- */
4185
        /* Computing Effective Frame Dimensions                                 */
4186
        /* ------------------------------------------------------------------*/
4187
1.44k
        i4_ref_wd = (i4_base_width >> i4_chroma_flag);
4188
1.44k
        i4_ref_ht = (i4_base_height >> i4_chroma_flag) * (1 + i4_ref_layer_field_pic_flag);
4189
4190
1.44k
        i4_scaled_wd = ps_curr_res_prms->u2_scaled_ref_width;
4191
1.44k
        i4_scaled_ht = ps_curr_res_prms->u2_scaled_ref_height;
4192
1.44k
        i4_scaled_wd = (i4_scaled_wd >> i4_chroma_flag);
4193
1.44k
        i4_scaled_ht = (i4_scaled_ht >> i4_chroma_flag) * (1 + i4_field_pic_flag);
4194
4195
1.44k
        if(1 == i4_chroma_flag)
4196
720
        {
4197
720
            i4_refphase_x = i4_ref_layer_chroma_phase_x_plus1_flag - 1;
4198
720
            i4_refphase_y = i4_ref_layer_chroma_phase_y_plus1 - 1;
4199
720
            i4_phase_x = i4_chroma_phase_x_plus1_flag - 1;
4200
720
            i4_phase_y = i4_chroma_phase_y_plus1 - 1;
4201
720
            i4_sub_wd = i4_sub_wd_chroma;
4202
720
            i4_sub_ht = i4_sub_ht_chroma;
4203
720
            i4_mb_wd = MB_WIDTH >> 1;
4204
720
            i4_mb_ht = MB_HEIGHT >> 1;
4205
720
        }
4206
720
        else
4207
720
        {
4208
720
            i4_refphase_x = 0;
4209
720
            i4_refphase_y = 0;
4210
720
            i4_phase_x = 0;
4211
720
            i4_phase_y = 0;
4212
720
            i4_sub_wd = 1;
4213
720
            i4_sub_ht = 1;
4214
720
            i4_mb_wd = MB_WIDTH;
4215
720
            i4_mb_ht = MB_HEIGHT;
4216
720
        }
4217
1.44k
    }
4218
4219
    /* --------------------------------------------------------------------- */
4220
    /* Derive shift x and y based on level idd                               */
4221
    /* --------------------------------------------------------------------- */
4222
1.44k
    if(ps_sps->u1_level_idc <= 30)
4223
1.44k
    {
4224
1.44k
        i4_shift_x = 16;
4225
1.44k
        i4_shift_y = 16;
4226
1.44k
    }
4227
0
    else
4228
0
    {
4229
0
        i4_shift_x = 31 - isvcd_get_ceil_log2(i4_ref_wd);
4230
0
        i4_shift_y = 31 - isvcd_get_ceil_log2(i4_ref_ht);
4231
0
    }
4232
4233
    /* --------------------------------------------------------------------- */
4234
    /* The following condition is not true in our case for time being         */
4235
    /* --------------------------------------------------------------------- */
4236
1.44k
    if((SVCD_FALSE == i4_frame_mbs_only_flag) || (SVCD_FALSE == i4_ref_layer_frame_Mbs_only_flag))
4237
0
    {
4238
0
        i4_phase_y = i4_phase_y + 4 * i4_bot_field_flag;
4239
4240
0
        if(1 == i4_ref_layer_frame_Mbs_only_flag)
4241
0
            i4_refphase_y = (2 * i4_refphase_y) + 2;
4242
0
        else
4243
0
            i4_refphase_y = i4_refphase_y + (4 * i4_bot_field_flag);
4244
0
    }
4245
4246
    /* --------------------------------------------------------------------- */
4247
    /* Dx and Dy Computation - Ratio of the base and enhance layer width     */
4248
    /* --------------------------------------------------------------------- */
4249
1.44k
    i4_scale_x = ((i4_ref_wd << i4_shift_x) + (i4_scaled_wd >> 1)) / (i4_scaled_wd);
4250
1.44k
    i4_scale_y = ((i4_ref_ht << i4_shift_y) + (i4_scaled_ht >> 1)) / (i4_scaled_ht);
4251
4252
1.44k
    i4_offset_x = i4_scaled_ref_layer_left_offset / i4_sub_wd;
4253
1.44k
    i4_add_x = (((i4_ref_wd * (2 + i4_phase_x)) << (i4_shift_x - 2)) + (i4_scaled_wd >> 1)) /
4254
1.44k
                   i4_scaled_wd +
4255
1.44k
               (1 << (i4_shift_x - 5));
4256
1.44k
    i4_delta_x = 4 * (2 + i4_refphase_x);
4257
4258
1.44k
    if((SVCD_TRUE == i4_frame_mbs_only_flag) && (SVCD_TRUE == i4_ref_layer_frame_Mbs_only_flag))
4259
1.44k
    {
4260
1.44k
        i4_offset_y = i4_scaled_ref_layer_top_offset / i4_sub_ht;
4261
1.44k
        i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (i4_shift_y - 2)) + (i4_scaled_ht >> 1)) /
4262
1.44k
                       i4_scaled_ht +
4263
1.44k
                   (1 << (i4_shift_y - 5));
4264
1.44k
        i4_delta_y = 4 * (2 + i4_refphase_y);
4265
1.44k
    }
4266
0
    else
4267
0
    {
4268
0
        i4_offset_y = i4_scaled_ref_layer_top_offset / (2 * i4_sub_ht);
4269
0
        i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (i4_shift_y - 3)) + (i4_scaled_ht >> 1)) /
4270
0
                       i4_scaled_ht +
4271
0
                   (1 << (i4_shift_y - 5));
4272
0
        i4_delta_y = 2 * (2 + i4_refphase_y);
4273
0
    }
4274
4275
    /* --------------------------------------------------------------------- */
4276
    /* Intializing Local Pointers    - Chroma and Luma                         */
4277
    /* --------------------------------------------------------------------- */
4278
1.44k
    ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
4279
1.44k
    ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
4280
1.44k
    i4_curr_lyr_width = ps_curr_res_prms->i4_res_width >> i4_chroma_flag;
4281
1.44k
    i4_curr_lyr_height = ps_curr_res_prms->i4_res_height >> i4_chroma_flag;
4282
4283
    /* --------------------------------------------------------------------- */
4284
    /* Dyadic Scaling Ratios Handling                                         */
4285
    /* --------------------------------------------------------------------- */
4286
1.44k
    if(1 == ps_curr_res_prms->u1_dyadic_flag)
4287
1.28k
    {
4288
1.28k
        WORD32 i4_refarray_wd, i4_x_offset;
4289
1.28k
        WORD32 i4_refarray_ht, i4_y_offset;
4290
1.28k
        WORD32 i4_crp_wd_lt, i4_crp_ht_top;
4291
1.28k
        WORD32 i4_crp_wd_rt, i4_crp_ht_bot;
4292
1.28k
        WORD32 i4_ref_lyr_wd, i4_ref_lyr_ht;
4293
1.28k
        WORD32 i4_ref_x, i4_ref_y;
4294
1.28k
        WORD32 i4_ofst;
4295
1.28k
        WORD32 i4_i, i4_j;
4296
4297
        /* Hard coded for dyadic case */
4298
1.28k
        i4_refarray_wd = 20 >> i4_chroma_flag;
4299
1.28k
        i4_ofst = -2 >> i4_chroma_flag;
4300
1.28k
        i4_crp_wd_lt = i4_scaled_ref_layer_left_offset >> i4_chroma_flag;
4301
1.28k
        i4_crp_wd_rt = i4_scaled_ref_layer_right_offset >> i4_chroma_flag;
4302
1.28k
        i4_ref_lyr_wd = (i4_curr_lyr_width >> 1);
4303
4304
1.28k
        i4_ref_x = 0;
4305
3.84k
        for(i4_i = 0; i4_i < (WORD32) i4_curr_lyr_width; i4_i += (i4_mb_wd << 1))
4306
2.56k
        {
4307
2.56k
            i4_x_offset = MAX(i4_ofst, (i4_ref_x + i4_ofst));
4308
2.56k
            i4_x_offset = MIN(i4_x_offset, (i4_ref_lyr_wd - i4_ofst));
4309
2.56k
            ps_x_off_len->i2_offset = i4_x_offset;
4310
2.56k
            ps_x_off_len->i2_length = i4_refarray_wd;
4311
2.56k
            ps_x_off_len++;
4312
2.56k
            ps_x_off_len->i2_offset = i4_x_offset;
4313
2.56k
            ps_x_off_len->i2_length = i4_refarray_wd;
4314
2.56k
            ps_x_off_len++;
4315
2.56k
            if(i4_i >= i4_crp_wd_lt)
4316
2.56k
            {
4317
2.56k
                if(i4_i <= (WORD32) (i4_curr_lyr_width - i4_crp_wd_rt))
4318
2.56k
                {
4319
2.56k
                    i4_ref_x += i4_mb_wd;
4320
2.56k
                }
4321
2.56k
            }
4322
2.56k
        }
4323
4324
1.28k
        i4_refarray_ht = 20 >> i4_chroma_flag;
4325
1.28k
        i4_crp_ht_top = i4_scaled_ref_layer_top_offset >> i4_chroma_flag;
4326
1.28k
        i4_crp_ht_bot = i4_scaled_ref_layer_bottom_offset >> i4_chroma_flag;
4327
1.28k
        i4_ref_lyr_ht = (i4_curr_lyr_height >> 1);
4328
4329
1.28k
        i4_ref_y = 0;
4330
8.78k
        for(i4_j = 0; i4_j < (WORD32) i4_curr_lyr_height; i4_j += (i4_mb_ht << 1))
4331
7.50k
        {
4332
7.50k
            i4_y_offset = MAX(i4_ofst, (i4_ref_y + i4_ofst));
4333
7.50k
            i4_y_offset = MIN(i4_y_offset, (i4_ref_lyr_ht - i4_ofst));
4334
7.50k
            ps_y_off_len->i2_offset = i4_y_offset;
4335
7.50k
            ps_y_off_len->i2_length = i4_refarray_ht;
4336
7.50k
            ps_y_off_len++;
4337
7.50k
            ps_y_off_len->i2_offset = i4_y_offset;
4338
7.50k
            ps_y_off_len->i2_length = i4_refarray_ht;
4339
7.50k
            ps_y_off_len++;
4340
7.50k
            if(i4_j >= i4_crp_ht_top)
4341
7.50k
            {
4342
7.50k
                if(i4_j <= (WORD32) (i4_curr_lyr_height - i4_crp_ht_bot))
4343
7.50k
                {
4344
7.50k
                    i4_ref_y += i4_mb_ht;
4345
7.50k
                }
4346
7.50k
            }
4347
7.50k
        }
4348
        /* No need to process further, return */
4349
1.28k
        return;
4350
1.28k
    } /* If dyadic path */
4351
4352
    /* Proposed Algo for Optimization */
4353
160
    {
4354
160
        WORD32 i4_max, i4_min;
4355
160
        ref_min_max_map_t *ps_x_min_max;
4356
160
        ref_min_max_map_t *ps_y_min_max;
4357
160
        WORD32 i4_i, i4_j;
4358
4359
160
        ps_x_min_max = ps_map_ctxt->ps_x_min_max;
4360
160
        ps_y_min_max = ps_map_ctxt->ps_y_min_max;
4361
        /* ----------------------------------------------------------------- */
4362
        /* Computation of offsetX refArrayW Xmin and Xmax Lists                 */
4363
        /* ----------------------------------------------------------------- */
4364
640
        for(i4_i = 0; i4_i < (WORD32) i4_curr_lyr_width; i4_i = i4_i + i4_mb_wd)
4365
480
        {
4366
480
            WORD32 i4_refarray_wd, i4_xr_index;
4367
480
            WORD32 i4_x_refmin16;
4368
480
            WORD32 i4_x_refmax16;
4369
480
            WORD32 i4_x_offset;
4370
4371
480
            i4_x_refmin16 = (WORD64) (((WORD64) (i4_i - i4_offset_x) * i4_scale_x + i4_add_x) >>
4372
480
                                      ((WORD32) (i4_shift_x - 4))) -
4373
480
                            i4_delta_x;
4374
4375
480
            i4_x_refmax16 =
4376
480
                (WORD64) (((WORD64) (i4_i + i4_mb_wd - 1 - i4_offset_x) * i4_scale_x + i4_add_x) >>
4377
480
                          ((WORD32) (i4_shift_x - 4))) -
4378
480
                i4_delta_x;
4379
4380
            /* ------------------------------------------------------------- */
4381
            /* Modified AC205                                                 */
4382
            /* Minimum width required - So adding 2 pixels on each side         */
4383
            /* ------------------------------------------------------------- */
4384
480
            i4_refarray_wd = ((i4_x_refmax16 + 15) >> 4) - (i4_x_refmin16 >> 4) + 1 + 4;
4385
4386
            /* ------------------------------------------------------------- */
4387
            /* Setting the offset 2 pixels before                             */
4388
            /* ------------------------------------------------------------- */
4389
480
            i4_x_offset = (i4_x_refmin16 >> 4) - 2;
4390
4391
            /* ------------------------------------------------------------- */
4392
            /* Modifying the values based on the location                     */
4393
            /* ------------------------------------------------------------- */
4394
480
            i4_min = i4_x_offset;
4395
480
            i4_xr_index = i4_min - ((i4_min / i4_mb_wd) * i4_mb_wd);
4396
4397
480
            if(i4_xr_index < (i4_mb_wd >> 1))
4398
400
            {
4399
400
                i4_refarray_wd = i4_refarray_wd + (i4_mb_wd >> 1);
4400
400
                i4_x_offset = i4_x_offset - (i4_mb_wd >> 1);
4401
400
            }
4402
4403
480
            i4_max = ((i4_x_refmax16 + 15) >> 4) + 2;
4404
480
            i4_xr_index = i4_max - ((i4_max / i4_mb_wd) * i4_mb_wd);
4405
4406
480
            if(i4_xr_index >= (i4_mb_wd >> 1)) i4_refarray_wd = i4_refarray_wd + (i4_mb_wd >> 1);
4407
4408
            /* ------------------------------------------------------------- */
4409
            /* Filling the arrays with offset, min, max and refArray dim     */
4410
            /* ------------------------------------------------------------- */
4411
480
            ps_x_off_len->i2_offset = i4_x_offset;
4412
480
            ps_x_off_len->i2_length = i4_refarray_wd;
4413
4414
480
            ps_x_min_max->i2_min_pos = (i4_x_refmin16 >> 4) - i4_x_offset;
4415
480
            ps_x_min_max->i2_max_pos = ((i4_x_refmax16 + 15) >> 4) - i4_x_offset;
4416
4417
480
            i4_tmp = (WORD32) (ps_x_min_max->i2_max_pos - ps_x_min_max->i2_min_pos) +
4418
480
                     (4 >> i4_chroma_flag);
4419
480
            if(i4_tmp > i4_horz_dim)
4420
160
            {
4421
160
                i4_horz_dim = i4_tmp;
4422
160
            }
4423
4424
            /* increment the pointer */
4425
480
            ps_x_off_len++;
4426
480
            ps_x_min_max++;
4427
480
        } /* end of loop over scaled width */
4428
4429
        /* ----------------------------------------------------------------- */
4430
        /* Computation of offsetY refArrayH Ymin and Ymax Lists                 */
4431
        /* ----------------------------------------------------------------- */
4432
1.60k
        for(i4_j = 0; i4_j < (WORD32) i4_curr_lyr_height; i4_j = i4_j + i4_mb_ht)
4433
1.44k
        {
4434
1.44k
            WORD32 i4_refarray_ht, i4_yr_index;
4435
1.44k
            WORD32 i4_y_refmin16;
4436
1.44k
            WORD32 i4_y_refmax16;
4437
1.44k
            WORD32 i4_y_offset;
4438
4439
1.44k
            i4_y_refmin16 = (WORD64) (((WORD64) (i4_j - i4_offset_y) * i4_scale_y + i4_add_y) >>
4440
1.44k
                                      ((WORD32) (i4_shift_y - 4))) -
4441
1.44k
                            i4_delta_y;
4442
4443
1.44k
            i4_y_refmax16 =
4444
1.44k
                (WORD64) (((WORD64) (i4_j + i4_mb_ht - 1 - i4_offset_y) * i4_scale_y + i4_add_y) >>
4445
1.44k
                          ((WORD32) (i4_shift_y - 4))) -
4446
1.44k
                i4_delta_y;
4447
4448
            /* ------------------------------------------------------------- */
4449
            /* Modified AC205                                                 */
4450
            /* Minimum width required - So adding 2 pixels on each side            */
4451
            /* ------------------------------------------------------------- */
4452
1.44k
            i4_refarray_ht = ((i4_y_refmax16 + 15) >> 4) - (i4_y_refmin16 >> 4) + 1 + 4;
4453
4454
            /* ------------------------------------------------------------- */
4455
            /* Setting the offset 2 pixels before                             */
4456
            /* ------------------------------------------------------------- */
4457
1.44k
            i4_y_offset = (i4_y_refmin16 >> 4) - 2;
4458
4459
            /* ------------------------------------------------------------- */
4460
            /* Modifying the values based on the location                     */
4461
            /* ------------------------------------------------------------- */
4462
1.44k
            i4_min = i4_y_offset;
4463
1.44k
            i4_yr_index = i4_min - ((i4_min / i4_mb_ht) * i4_mb_ht);
4464
1.44k
            if(i4_yr_index < (i4_mb_ht >> 1))
4465
880
            {
4466
880
                i4_refarray_ht = i4_refarray_ht + (i4_mb_ht >> 1);
4467
880
                i4_y_offset = i4_y_offset - (i4_mb_ht >> 1);
4468
880
            }
4469
4470
1.44k
            i4_max = ((i4_y_refmax16 + 15) >> 4) + 2;
4471
1.44k
            i4_yr_index = i4_max - ((i4_max / i4_mb_ht) * i4_mb_ht);
4472
1.44k
            if(i4_yr_index >= (i4_mb_ht >> 1)) i4_refarray_ht = i4_refarray_ht + (i4_mb_ht >> 1);
4473
4474
            /* ------------------------------------------------------------- */
4475
            /* Filling the arrays with offset, min, max and refArray dim     */
4476
            /* ------------------------------------------------------------- */
4477
1.44k
            ps_y_off_len->i2_offset = i4_y_offset;
4478
1.44k
            ps_y_off_len->i2_length = i4_refarray_ht;
4479
1.44k
            ps_y_min_max->i2_min_pos = (i4_y_refmin16 >> 4) - i4_y_offset;
4480
1.44k
            ps_y_min_max->i2_max_pos = ((i4_y_refmax16 + 15) >> 4) - i4_y_offset;
4481
4482
1.44k
            i4_tmp = (WORD32) (ps_y_min_max->i2_max_pos - ps_y_min_max->i2_min_pos) +
4483
1.44k
                     (4 >> i4_chroma_flag);
4484
1.44k
            if(i4_tmp > i4_vert_dim)
4485
160
            {
4486
160
                i4_vert_dim = i4_tmp;
4487
160
            }
4488
4489
            /* increment the pointer */
4490
1.44k
            ps_y_off_len++;
4491
1.44k
            ps_y_min_max++;
4492
1.44k
        } /* end of loop over scaled height */
4493
160
    }
4494
4495
    /* --------------------------------------------------------------------- */
4496
    /* Computation of Xref and Xphase List as per standard                     */
4497
    /* --------------------------------------------------------------------- */
4498
160
    ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
4499
160
    ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
4500
4501
160
    {
4502
160
        ref_pixel_map_t *ps_x_pos_phase;
4503
160
        WORD32 i4_xc;
4504
160
        WORD32 i4_offset_x_index;
4505
4506
160
        ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase;
4507
4508
5.92k
        for(i4_xc = 0; i4_xc < (WORD32) i4_curr_lyr_width; i4_xc++)
4509
5.76k
        {
4510
5.76k
            WORD32 i4_x_offset;
4511
5.76k
            WORD32 i4_x_ref16;
4512
4513
5.76k
            i4_offset_x_index = i4_xc / i4_mb_wd;
4514
4515
5.76k
            i4_x_offset = ps_x_off_len[i4_offset_x_index].i2_offset;
4516
4517
5.76k
            i4_x_ref16 = (WORD64) (((WORD64) (i4_xc - i4_offset_x) * i4_scale_x + i4_add_x) >>
4518
5.76k
                                   ((WORD32) (i4_shift_x - 4))) -
4519
5.76k
                         i4_delta_x;
4520
4521
            /* store the values */
4522
5.76k
            ps_x_pos_phase->i2_ref_pos = (i4_x_ref16 >> 4) - i4_x_offset;
4523
5.76k
            ps_x_pos_phase->i2_phase = i4_x_ref16 & 15;
4524
4525
            /* increment the pointer */
4526
5.76k
            ps_x_pos_phase++;
4527
4528
5.76k
        } /* end of loop over scaled width */
4529
160
    }
4530
4531
    /* --------------------------------------------------------------------- */
4532
    /* Computation of Yref and Yphase List as per standard                     */
4533
    /* --------------------------------------------------------------------- */
4534
160
    {
4535
160
        WORD32 i4_yc;
4536
160
        ref_pixel_map_t *ps_y_pos_phase;
4537
4538
160
        ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase;
4539
4540
17.4k
        for(i4_yc = 0; i4_yc < (WORD32) i4_curr_lyr_height; i4_yc++)
4541
17.2k
        {
4542
17.2k
            WORD32 i4_y_offset;
4543
17.2k
            WORD32 i4_y_ref16;
4544
17.2k
            WORD32 i4_offset_y_index;
4545
4546
17.2k
            i4_offset_y_index = i4_yc / i4_mb_ht;
4547
4548
17.2k
            i4_y_offset = ps_y_off_len[i4_offset_y_index].i2_offset;
4549
4550
17.2k
            if((SVCD_FALSE == i4_frame_mbs_only_flag) ||
4551
17.2k
               (SVCD_FALSE == i4_ref_layer_frame_Mbs_only_flag))
4552
0
            {
4553
0
                i4_yc = i4_yc >> (1 - i4_field_Mb_flag);
4554
0
            }
4555
4556
17.2k
            i4_y_ref16 = (WORD64) (((WORD64) (i4_yc - i4_offset_y) * i4_scale_y + i4_add_y) >>
4557
17.2k
                                   ((WORD32) (i4_shift_y - 4))) -
4558
17.2k
                         i4_delta_y;
4559
17.2k
            ps_y_pos_phase->i2_ref_pos = (i4_y_ref16 >> 4) - i4_y_offset;
4560
17.2k
            ps_y_pos_phase->i2_phase = i4_y_ref16 & 15;
4561
4562
            /* increment the pointer */
4563
17.2k
            ps_y_pos_phase++;
4564
4565
17.2k
        } /* end of loop over scaled height */
4566
160
    }
4567
4568
    /* --------------------------------------------------------------------- */
4569
    /* Computation of Corresponding Diagonal Location                         */
4570
    /* --------------------------------------------------------------------- */
4571
160
    {
4572
160
        WORD16 *pi2_xd_index;
4573
160
        WORD16 *pi2_yd_index;
4574
160
        WORD16 *pi2_ya_index;
4575
160
        WORD32 i4_i, i4_j;
4576
4577
160
        pi2_xd_index = ps_map_ctxt->pi2_xd_index;
4578
160
        pi2_yd_index = ps_map_ctxt->pi2_yd_index;
4579
160
        pi2_ya_index = ps_map_ctxt->pi2_ya_index;
4580
4581
2.08k
        for(i4_i = 0; i4_i < i4_mb_wd; i4_i++)
4582
1.92k
        {
4583
1.92k
            *(pi2_xd_index + i4_i) = ((i4_i >= i4_mb_wd >> 1) ? (i4_i - i4_mb_wd) : (i4_i + 1));
4584
4585
1.92k
        } /* end of loop over MB width */
4586
4587
2.08k
        for(i4_j = 0; i4_j < i4_mb_ht; i4_j++)
4588
1.92k
        {
4589
1.92k
            *(pi2_yd_index + i4_j) = ((i4_j >= i4_mb_ht >> 1) ? (i4_j - i4_mb_ht) : (i4_j + 1));
4590
4591
1.92k
            *(pi2_ya_index + i4_j) =
4592
1.92k
                *(pi2_yd_index + i4_j) - (((i4_mb_ht >> 1) + 1) * (SIGN(*(pi2_yd_index + i4_j))));
4593
4594
1.92k
        } /* end of loop over MB height */
4595
160
    }
4596
4597
    /* generate the lookup to generate horizontal segments */
4598
160
    isvcd_intra_resamp_generate_segment_lookup(ps_map_ctxt->ps_seg_lookup_horz, i4_horz_dim,
4599
160
                                               i4_mb_wd, 3);
4600
4601
    /* generate the lookup to generate vertical segments */
4602
160
    isvcd_intra_resamp_generate_segment_lookup(ps_map_ctxt->ps_seg_lookup_vert, i4_vert_dim,
4603
160
                                               i4_mb_ht, 4);
4604
4605
160
    return;
4606
1.44k
} /* end of function "isvcd_intra_resamp_populate_list"*/
4607
4608
/*****************************************************************************/
4609
/*                                                                           */
4610
/*  Function Name : isvcd_populate_res_prms                                   */
4611
/*                                                                           */
4612
/*  Description   :this function populates the current layer params          */
4613
/*                 from the base layer and decoder context                   */
4614
/*  Inputs        :                                                          */
4615
/*  Globals       : none                                                     */
4616
/*  Processing    :                                                          */
4617
/*                                                                           */
4618
/*  Outputs       : none                                                     */
4619
/*  Returns       : none                                                     */
4620
/*                                                                           */
4621
/*  Issues        : none                                                     */
4622
/*                                                                           */
4623
/*  Revision History:                                                        */
4624
/*                                                                           */
4625
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
4626
/*         25 11 2021   Kishore               creation                       */
4627
/*                                                                           */
4628
/*****************************************************************************/
4629
4630
WORD32 isvcd_populate_res_prms(void *pv_svc_dec)
4631
4.09k
{
4632
4.09k
    svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
4633
4.09k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
4634
4.09k
    res_prms_t *ps_curr_lyr_res_prms;
4635
4.09k
    svc_dec_lyr_struct_t *ps_svc_ref_lyr_dec;
4636
4.09k
    ps_svc_ref_lyr_dec = ps_svc_lyr_dec->ps_dec_svc_ref_layer;
4637
4.09k
    ps_curr_lyr_res_prms = &ps_svc_lyr_dec->s_res_prms;
4638
4639
4.09k
    ps_curr_lyr_res_prms->i4_res_width = ps_dec->u2_pic_wd;
4640
4.09k
    ps_curr_lyr_res_prms->i4_res_height = ps_dec->u2_pic_ht;
4641
4.09k
    ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left =
4642
4.09k
        ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_left_offset << 1;
4643
4.09k
    ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top =
4644
4.09k
        ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_top_offset << 1;
4645
4.09k
    ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt =
4646
4.09k
        ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_right_offset << 1;
4647
4.09k
    ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot =
4648
4.09k
        ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.i4_seq_scaled_ref_layer_bottom_offset << 1;
4649
4.09k
    ps_curr_lyr_res_prms->u2_scaled_ref_width =
4650
4.09k
        (ps_dec->u2_frm_wd_in_mbs << 4) - (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left +
4651
4.09k
                                           ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt);
4652
4653
4.09k
    ps_curr_lyr_res_prms->u2_scaled_ref_height =
4654
4.09k
        (ps_dec->u2_frm_ht_in_mbs << 4) - (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top +
4655
4.09k
                                           ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot);
4656
4657
4.09k
    ps_curr_lyr_res_prms->u1_cropping_change_flag = 0;
4658
4.09k
    if(2 == ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_extended_spatial_scalability_idc)
4659
0
    {
4660
0
        ps_curr_lyr_res_prms->u1_cropping_change_flag = 1;
4661
4662
0
        ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left =
4663
0
            ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_left_offset << 1;
4664
4665
0
        ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top =
4666
0
            ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_top_offset << 1;
4667
0
        ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt =
4668
0
            ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_right_offset << 1;
4669
0
        ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot =
4670
0
            ps_svc_lyr_dec->s_svc_slice_params.i4_scaled_ref_layer_bottom_offset << 1;
4671
0
        ps_curr_lyr_res_prms->u2_scaled_ref_width =
4672
0
            (ps_dec->u2_frm_wd_in_mbs << 4) -
4673
0
            (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left +
4674
0
             ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_rt);
4675
4676
0
        ps_curr_lyr_res_prms->u2_scaled_ref_height =
4677
0
            (ps_dec->u2_frm_ht_in_mbs << 4) -
4678
0
            (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top +
4679
0
             ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_bot);
4680
4681
0
        return NOT_OK;
4682
0
    }
4683
4684
4.09k
    ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_TRUE;
4685
4686
4.09k
    ps_curr_lyr_res_prms->u1_disable_inter_lyr_dblk_filter_idc =
4687
4.09k
        ps_svc_lyr_dec->s_svc_slice_params.u4_disable_inter_layer_deblk_filter_idc;
4688
4.09k
    ps_curr_lyr_res_prms->i1_inter_lyr_alpha_c0_offset =
4689
4.09k
        ps_svc_lyr_dec->s_svc_slice_params.i4_inter_layer_slice_alpha_c0_offset_div2;
4690
4.09k
    ps_curr_lyr_res_prms->i1_inter_lyr_beta_offset =
4691
4.09k
        ps_svc_lyr_dec->s_svc_slice_params.i4_inter_layer_slice_beta_offset_div2;
4692
4.09k
    ps_curr_lyr_res_prms->i1_constrained_intra_rsmpl_flag =
4693
4.09k
        ps_svc_lyr_dec->s_svc_slice_params.u1_constrained_intra_resampling_flag;
4694
4.09k
    ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag =
4695
4.09k
        ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_x_plus1_flag;
4696
4.09k
    ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_y_plus1 =
4697
4.09k
        ps_svc_lyr_dec->ps_cur_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_y_plus1;
4698
4.09k
    ps_curr_lyr_res_prms->u1_direct_8x8_inference_flag =
4699
4.09k
        ps_dec->ps_cur_sps->u1_direct_8x8_inference_flag;
4700
4701
4.09k
    ps_curr_lyr_res_prms->u1_remap_req_flag = 1;
4702
4.09k
    ps_curr_lyr_res_prms->u1_dyadic_flag = ps_svc_lyr_dec->u1_dyadic_flag;
4703
4704
    /* Derive the reference layer width and height */
4705
4706
4.09k
    if(SVCD_TRUE != ps_svc_lyr_dec->u1_base_res_flag)
4707
720
    {
4708
720
        WORD32 i4_ref_lyr_width;
4709
720
        WORD32 i4_ref_lyr_ht;
4710
720
        WORD32 i4_dyadic_flag = SVCD_FALSE;
4711
720
        i4_ref_lyr_width = ps_svc_ref_lyr_dec->s_res_prms.i4_res_width;
4712
720
        i4_ref_lyr_ht = ps_svc_ref_lyr_dec->s_res_prms.i4_res_height;
4713
4714
        /* set the Restricted Spatial Resolution change flag */
4715
720
        ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_TRUE;
4716
4717
720
        if(0 == ((ps_curr_lyr_res_prms->u2_scaled_ref_width == i4_ref_lyr_width) ||
4718
720
                 (ps_curr_lyr_res_prms->u2_scaled_ref_width == (i4_ref_lyr_width << 1))))
4719
80
        {
4720
80
            ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE;
4721
80
        }
4722
4723
720
        if(0 == ((ps_curr_lyr_res_prms->u2_scaled_ref_height == i4_ref_lyr_ht) ||
4724
720
                 (ps_curr_lyr_res_prms->u2_scaled_ref_height == (i4_ref_lyr_ht << 1))))
4725
80
        {
4726
80
            ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE;
4727
80
        }
4728
4729
720
        if(0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left & 15))
4730
0
        {
4731
0
            ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE;
4732
0
        }
4733
4734
720
        if(0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top & 15))
4735
0
        {
4736
0
            ps_curr_lyr_res_prms->u1_rstrct_res_change_flag = SVCD_FALSE;
4737
0
        }
4738
4739
        /* populate the dyadic status */
4740
4741
720
        if((ps_curr_lyr_res_prms->u2_scaled_ref_width == (i4_ref_lyr_width << 1)) &&
4742
640
           (ps_curr_lyr_res_prms->u2_scaled_ref_height == (i4_ref_lyr_ht << 1)))
4743
640
        {
4744
640
            i4_dyadic_flag = SVCD_TRUE;
4745
640
        }
4746
80
        else if((ps_curr_lyr_res_prms->u2_scaled_ref_width != ((i4_ref_lyr_width * 3) >> 1)) ||
4747
80
                (ps_curr_lyr_res_prms->u2_scaled_ref_height != ((i4_ref_lyr_ht * 3) >> 1)))
4748
0
        {
4749
0
            ps_curr_lyr_res_prms->u1_dyadic_flag = i4_dyadic_flag;
4750
0
            ps_svc_lyr_dec->u1_dyadic_flag = ps_curr_lyr_res_prms->u1_dyadic_flag;
4751
0
            return NOT_OK;
4752
0
        }
4753
4754
        /* check if cropping is MB aligned */
4755
720
        if(SVCD_TRUE == i4_dyadic_flag)
4756
640
        {
4757
640
            if((0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_left & 15)) ||
4758
640
               (0 != (ps_curr_lyr_res_prms->s_ref_lyr_scaled_offset.i2_top & 15)))
4759
0
            {
4760
0
                i4_dyadic_flag = SVCD_FALSE;
4761
0
            }
4762
640
        }
4763
4764
720
        ps_curr_lyr_res_prms->u1_dyadic_flag = i4_dyadic_flag;
4765
720
        ps_svc_lyr_dec->u1_dyadic_flag = ps_curr_lyr_res_prms->u1_dyadic_flag;
4766
720
    }
4767
4768
4.09k
    {
4769
4.09k
        inter_lyr_mb_prms_t *ps_tmp_prms, *ps_tmp_prms_2;
4770
4.09k
        inter_lyr_mb_prms_t *ps_ref_mb_prms;
4771
4.09k
        WORD32 i4_stride;
4772
4.09k
        WORD32 i4_ht_in_mbs, i4_wd_in_mbs;
4773
4.09k
        WORD32 i4_i;
4774
4775
        /* Derive the reference mb mode map */
4776
4777
4.09k
        ps_ref_mb_prms = ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start;
4778
4.09k
        i4_stride = ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride;
4779
4780
4.09k
        i4_ht_in_mbs = ps_dec->u2_frm_ht_in_mbs;
4781
4.09k
        i4_wd_in_mbs = ps_dec->u2_frm_wd_in_mbs;
4782
4783
        /* Set the first border row to 0xFF */
4784
4.09k
        ps_tmp_prms = (ps_ref_mb_prms - 1 - i4_stride);
4785
4786
4.09k
        memset(ps_svc_lyr_dec->ps_inter_lyr_mb_prms_base, -1,
4787
4.09k
               ps_svc_lyr_dec->u4_inter_lyr_mb_prms_size);
4788
4.09k
        memset(ps_svc_lyr_dec->pu1_svc_base_mode_flag, 0,
4789
4.09k
               ps_svc_lyr_dec->i4_frm_svc_base_mode_cabac_size);
4790
4791
39.0k
        for(i4_i = 0; i4_i < (i4_wd_in_mbs + 2); i4_i++)
4792
35.0k
        {
4793
35.0k
            ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF;
4794
35.0k
            ps_tmp_prms += 1;
4795
35.0k
        }
4796
4797
        /* Set the left and right border pixels of each row to 0 */
4798
4.09k
        ps_tmp_prms = ps_ref_mb_prms - 1;
4799
4800
147k
        for(i4_i = 0; i4_i < i4_ht_in_mbs; i4_i++)
4801
143k
        {
4802
143k
            ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF;
4803
143k
            ps_tmp_prms_2 = ps_tmp_prms + (i4_wd_in_mbs + 1);
4804
143k
            ps_tmp_prms_2->i1_mb_mode = (WORD8) 0xFF;
4805
143k
            ps_tmp_prms += i4_stride;
4806
143k
        }
4807
4808
        /* Set the last border row to 0xFF */
4809
39.0k
        for(i4_i = 0; i4_i < (i4_wd_in_mbs + 2); i4_i++)
4810
35.0k
        {
4811
35.0k
            ps_tmp_prms->i1_mb_mode = (WORD8) 0xFF;
4812
35.0k
            ps_tmp_prms += 1;
4813
35.0k
        }
4814
4.09k
    }
4815
4816
    /* reset residual luma, chroma buffer*/
4817
4.09k
    memset(ps_svc_lyr_dec->pi2_il_residual_resample_luma_base, 0,
4818
4.09k
           ps_svc_lyr_dec->u4_residual_resample_luma_size);
4819
4.09k
    memset(ps_svc_lyr_dec->pi2_il_residual_resample_chroma_base, 0,
4820
4.09k
           ps_svc_lyr_dec->u4_residual_resample_chroma_size);
4821
4822
4.09k
    return OK;
4823
4.09k
}
4824
4825
/*****************************************************************************/
4826
/*                                                                           */
4827
/*  Function Name : isvcd_crop_wnd_flag_res_int                               */
4828
/*                                                                           */
4829
/*  Description   : This routine computes the crop window flag for entire    */
4830
/*                  dependency layer and places it in the crop window flag   */
4831
/*                  buffer                                                   */
4832
/*  Inputs        : 1. ECD context structure                                 */
4833
/*                  2. Crop offset structure                                 */
4834
/*  Globals       : None                                                     */
4835
/*  Processing    : For Mbs within the crop window, flag set to 1 and for    */
4836
/*                  others it is set to 0                                    */
4837
/*                                                                           */
4838
/*  Outputs       : Updates crop window flag buffer                          */
4839
/*  Returns       : status                                                   */
4840
/*                                                                           */
4841
/*  Issues        : None                                                     */
4842
/*                                                                           */
4843
/*  Revision History:                                                        */
4844
/*                                                                           */
4845
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
4846
/*         06 09 2021   Vijay      Draft                                     */
4847
/*                                                                           */
4848
/*****************************************************************************/
4849
void isvcd_crop_wnd_flag_res_int(void *pv_svc_dec)
4850
4.09k
{
4851
4.09k
    UWORD8 *pu1_crop_wnd_flag;
4852
4.09k
    WORD32 i4_num_mbs;
4853
4.09k
    WORD32 i4_crop_mbs_x;
4854
4.09k
    WORD32 i4_crop_mbs_y;
4855
4.09k
    WORD32 i4_cnt;
4856
4.09k
    WORD32 i4_left_offset, i4_rt_offset;
4857
4.09k
    WORD32 i4_top_offset, i4_bot_offset;
4858
4.09k
    WORD32 i4_frm_wd_in_mbs;
4859
4.09k
    WORD32 i4_frm_ht_in_mbs;
4860
4.09k
    dec_struct_t *ps_dec;
4861
4.09k
    svc_dec_lyr_struct_t *ps_svc_lyr_dec;
4862
4.09k
    res_prms_t *ps_res_prms;
4863
4864
4.09k
    ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
4865
4.09k
    ps_dec = &ps_svc_lyr_dec->s_dec;
4866
4.09k
    ps_res_prms = &ps_svc_lyr_dec->s_res_prms;
4867
4.09k
    i4_frm_wd_in_mbs = ps_dec->u2_frm_wd_in_mbs;
4868
4.09k
    i4_frm_ht_in_mbs = ps_dec->u2_frm_ht_in_mbs;
4869
4870
    /* Initializations */
4871
4.09k
    pu1_crop_wnd_flag = ps_svc_lyr_dec->pu1_crop_wnd_flag;
4872
4.09k
    i4_num_mbs = i4_frm_wd_in_mbs * i4_frm_ht_in_mbs;
4873
4874
    /* bottom most layer in a resolution */
4875
4.09k
    if(ps_res_prms->s_ref_lyr_scaled_offset.i2_left >= 0)
4876
4.09k
    {
4877
        /* check for offset greater than 0 */
4878
4.09k
        i4_left_offset = (ps_res_prms->s_ref_lyr_scaled_offset.i2_left + 15) >> 4;
4879
4.09k
    }
4880
0
    else
4881
0
    {
4882
        /* if negative set it to 0*/
4883
0
        i4_left_offset = 0;
4884
0
    }
4885
4886
4.09k
    if(ps_res_prms->s_ref_lyr_scaled_offset.i2_rt >= 0)
4887
4.09k
    {
4888
        /* check for offset greater than 0 */
4889
4.09k
        i4_rt_offset =
4890
4.09k
            (ps_res_prms->i4_res_width - ps_res_prms->s_ref_lyr_scaled_offset.i2_rt) >> 4;
4891
4.09k
    }
4892
0
    else
4893
0
    {
4894
        /* if negative set it to framewidth in MBs */
4895
0
        i4_rt_offset = (ps_res_prms->i4_res_width >> 4);
4896
0
    }
4897
4898
4.09k
    if(ps_res_prms->s_ref_lyr_scaled_offset.i2_top >= 0)
4899
4.09k
    {
4900
        /* check for offset greater than 0 */
4901
4.09k
        i4_top_offset = (ps_res_prms->s_ref_lyr_scaled_offset.i2_top + 15) >> 4;
4902
4.09k
    }
4903
0
    else
4904
0
    {
4905
        /* if negative set it to 0 */
4906
0
        i4_top_offset = 0;
4907
0
    }
4908
4909
4.09k
    if(ps_res_prms->s_ref_lyr_scaled_offset.i2_bot >= 0)
4910
4.09k
    {
4911
        /* check for offset greater than 0 */
4912
4.09k
        i4_bot_offset =
4913
4.09k
            (ps_res_prms->i4_res_height - ps_res_prms->s_ref_lyr_scaled_offset.i2_bot) >> 4;
4914
4.09k
    }
4915
0
    else
4916
0
    {
4917
        /* if negative set it to frameheight in MBs */
4918
0
        i4_bot_offset = (ps_res_prms->i4_res_height >> 4);
4919
0
    }
4920
4921
4.09k
    i4_crop_mbs_x = i4_rt_offset - i4_left_offset;
4922
4.09k
    i4_crop_mbs_y = i4_bot_offset - i4_top_offset;
4923
4924
    /* Set crop window flag to 0 for all mbs */
4925
4.09k
    memset(pu1_crop_wnd_flag, 0, i4_num_mbs);
4926
4927
4.09k
    pu1_crop_wnd_flag += (i4_frm_wd_in_mbs * i4_top_offset);
4928
4.09k
    pu1_crop_wnd_flag += i4_left_offset;
4929
    /* Loop over MBs in crop window */
4930
147k
    for(i4_cnt = 0; i4_cnt < i4_crop_mbs_y; i4_cnt++)
4931
143k
    {
4932
143k
        memset(pu1_crop_wnd_flag, 1, i4_crop_mbs_x);
4933
143k
        pu1_crop_wnd_flag += i4_frm_wd_in_mbs;
4934
143k
    }
4935
4.09k
}
4936
4937
/*****************************************************************************/
4938
/*                                                                           */
4939
/*  Function Name : isvcd_intra_resamp_res_init                                 */
4940
/*                                                                           */
4941
/*  Description   : this function calculates the scale factors and initialise*/
4942
/*                  the context structure                                    */
4943
/*                                                                           */
4944
/*  Inputs        : pv_intra_samp_ctxt: handle to private structure          */
4945
/*                  ps_curr_lyr_res_prms: pointer to current resolution      */
4946
/*                                               params                      */
4947
/*                  ps_ref_lyr_res_prms : pointer to ref resolution params   */
4948
/*  Globals       : none                                                     */
4949
/*  Processing    : it stores the layer dimensions                           */
4950
/*                                                                           */
4951
/*  Outputs       : none                                                     */
4952
/*  Returns       : none                                                     */
4953
/*                                                                           */
4954
/*  Issues        : none                                                     */
4955
/*                                                                           */
4956
/*  Revision History:                                                        */
4957
/*                                                                           */
4958
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
4959
/*         26 08 2021   vijayakumar          creation                        */
4960
/*                                                                           */
4961
/*****************************************************************************/
4962
void isvcd_intra_resamp_res_init_update_flags(void *pv_svc_dec)
4963
674
{
4964
674
    intra_sampling_ctxt_t *ps_ctxt;
4965
674
    intra_samp_lyr_ctxt *ps_lyr_ctxt;
4966
674
    svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
4967
4968
674
    ps_ctxt = (intra_sampling_ctxt_t *) ps_svc_lyr_dec->pv_intra_sample_ctxt;;
4969
    /* get the current layer ctxt */
4970
674
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_svc_lyr_dec->u1_layer_id - 1];
4971
4972
674
    ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag =
4973
674
        ps_svc_lyr_dec->s_svc_slice_params.u1_constrained_intra_resampling_flag;
4974
674
}
4975
4976
/*****************************************************************************/
4977
/*                                                                           */
4978
/*  Function Name : isvcd_intra_resamp_res_init                                 */
4979
/*                                                                           */
4980
/*  Description   : this function calculates the scale factors and initialise*/
4981
/*                  the context structure                                    */
4982
/*                                                                           */
4983
/*  Inputs        : pv_intra_samp_ctxt: handle to private structure          */
4984
/*                  ps_curr_lyr_res_prms: pointer to current resolution      */
4985
/*                                               params                      */
4986
/*                  ps_ref_lyr_res_prms : pointer to ref resolution params   */
4987
/*  Globals       : none                                                     */
4988
/*  Processing    : it stores the layer dimensions                           */
4989
/*                                                                           */
4990
/*  Outputs       : none                                                     */
4991
/*  Returns       : none                                                     */
4992
/*                                                                           */
4993
/*  Issues        : none                                                     */
4994
/*                                                                           */
4995
/*  Revision History:                                                        */
4996
/*                                                                           */
4997
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
4998
/*         26 08 2021   vijayakumar          creation                        */
4999
/*                                                                           */
5000
/*****************************************************************************/
5001
WORD32 isvcd_intra_resamp_res_init(void *pv_svc_dec)
5002
4.09k
{
5003
4.09k
    intra_sampling_ctxt_t *ps_ctxt;
5004
4.09k
    intra_samp_lyr_ctxt *ps_lyr_ctxt;
5005
4.09k
    dec_svc_seq_params_t *ps_cur_subset_sps;
5006
4.09k
    svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
5007
4.09k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
5008
4.09k
    dec_slice_svc_ext_params_t *ps_svc_slice_params = NULL;
5009
5010
4.09k
    void *pv_intra_samp_ctxt = ps_svc_lyr_dec->pv_intra_sample_ctxt;
5011
4.09k
    res_prms_t *ps_curr_lyr_res_prms = &ps_svc_lyr_dec->s_res_prms;
5012
4.09k
    ref_mb_map_t **pps_luma_map_horz = &ps_svc_lyr_dec->ps_intsam_luma_map_horz;
5013
4.09k
    ref_mb_map_t **pps_chroma_map_horz = &ps_svc_lyr_dec->ps_intsam_chroma_map_horz;
5014
4.09k
    ref_mb_map_t **pps_luma_map_vert = &ps_svc_lyr_dec->ps_intsam_luma_map_vert;
5015
4.09k
    ref_mb_map_t **pps_chroma_map_vert = &ps_svc_lyr_dec->ps_intsam_chroma_map_vert;
5016
5017
4.09k
    ps_svc_slice_params = &ps_svc_lyr_dec->s_svc_slice_params;
5018
4.09k
    ps_cur_subset_sps = ps_svc_lyr_dec->ps_cur_subset_sps;
5019
5020
4.09k
    ps_ctxt = (intra_sampling_ctxt_t *) pv_intra_samp_ctxt;
5021
5022
    /* if called for base resolution store default values */
5023
4.09k
    if(SVCD_TRUE == ps_svc_lyr_dec->u1_base_res_flag)
5024
3.37k
    {
5025
3.37k
        *pps_luma_map_horz = NULL;
5026
3.37k
        *pps_chroma_map_horz = NULL;
5027
3.37k
        *pps_luma_map_vert = NULL;
5028
3.37k
        *pps_chroma_map_vert = NULL;
5029
3.37k
        ps_ctxt->i4_res_lyr_id = -1;
5030
3.37k
        ps_ctxt->i4_ref_width = ps_dec->u2_pic_wd;
5031
3.37k
        ps_ctxt->i4_ref_height = ps_dec->u2_pic_ht;
5032
5033
        /* Note: The stride option is provided for bringing in data at NMB */
5034
        /* level. Hence to set a NMB level stride refSample array buffer   */
5035
        /* have to be increased                                            */
5036
3.37k
        ps_ctxt->i4_refarray_stride = REF_ARRAY_WIDTH;
5037
3.37k
        return OK;
5038
3.37k
    }
5039
5040
    /* derive the current sps */
5041
    /* store the res id appropriately */
5042
720
    ps_ctxt->i4_res_lyr_id = ps_svc_lyr_dec->u1_layer_id - 1;
5043
5044
    /* store the resolution params */
5045
720
    ps_ctxt->ps_res_prms = ps_curr_lyr_res_prms;
5046
5047
    /* get the current layer ctxt */
5048
720
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_svc_lyr_dec->u1_layer_id - 1];
5049
5050
720
    ps_ctxt->i4_res_lyr_id = ps_svc_lyr_dec->u1_layer_id - 1;
5051
    /* get the width and heights */
5052
720
    ps_lyr_ctxt->i4_curr_width = ps_dec->u2_pic_wd;
5053
720
    ps_lyr_ctxt->i4_curr_height = ps_dec->u2_pic_ht;
5054
720
    ps_lyr_ctxt->i4_ref_width = ps_ctxt->i4_ref_width;
5055
720
    ps_lyr_ctxt->i4_ref_height = ps_ctxt->i4_ref_height;
5056
720
    ps_lyr_ctxt->i1_constrained_intra_rsmpl_flag =
5057
720
        ps_svc_slice_params->u1_constrained_intra_resampling_flag;
5058
5059
    /* store the structure pointer containing projected locations */
5060
720
    *pps_luma_map_horz = ps_lyr_ctxt->s_luma_map_ctxt.ps_x_offset_length;
5061
720
    *pps_chroma_map_horz = ps_lyr_ctxt->s_chroma_map_ctxt.ps_x_offset_length;
5062
720
    *pps_luma_map_vert = ps_lyr_ctxt->s_luma_map_ctxt.ps_y_offset_length;
5063
720
    *pps_chroma_map_vert = ps_lyr_ctxt->s_chroma_map_ctxt.ps_y_offset_length;
5064
5065
    /* check for recomputation of mapping required */
5066
720
    if(SVCD_TRUE == ps_curr_lyr_res_prms->u1_remap_req_flag)
5067
720
    {
5068
720
        res_prms_t s_ref_res_prms = {0};
5069
720
        WORD32 i4_chroma_x_phase, i4_chroma_y_phase;
5070
720
        WORD32 i4_ref_chroma_x_phase, i4_ref_chroma_y_phase;
5071
720
        WORD32 i4_x_phase_0, i4_x_phase_1;
5072
720
        WORD32 i4_y_phase_0, i4_y_phase_1;
5073
720
        WORD32 i4_vert_flag;
5074
5075
        /* store the reference layer resolution width and height */
5076
720
        s_ref_res_prms.i4_res_width = ps_ctxt->i4_ref_width;
5077
720
        s_ref_res_prms.i4_res_height = ps_ctxt->i4_ref_height;
5078
5079
        /* call the frame level projections calculation function */
5080
720
        isvcd_intra_resamp_populate_list(&ps_lyr_ctxt->s_luma_map_ctxt, ps_curr_lyr_res_prms,
5081
720
                                         &s_ref_res_prms, 0, ps_svc_lyr_dec);
5082
5083
720
        isvcd_intra_resamp_populate_list(&ps_lyr_ctxt->s_chroma_map_ctxt, ps_curr_lyr_res_prms,
5084
720
                                         &s_ref_res_prms, 1, ps_svc_lyr_dec);
5085
5086
        /* Compute the chroma xPhase and yPhase values */
5087
720
        if(1 == ps_curr_lyr_res_prms->u1_dyadic_flag)
5088
640
        {
5089
640
            i4_ref_chroma_x_phase = ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag;
5090
640
            i4_ref_chroma_y_phase = ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_y_plus1;
5091
640
            i4_chroma_x_phase = ps_cur_subset_sps->s_sps_svc_ext.u1_chroma_phase_x_plus1_flag;
5092
640
            i4_chroma_y_phase = ps_cur_subset_sps->s_sps_svc_ext.u1_chroma_phase_y_plus1;
5093
5094
640
            i4_x_phase_0 = i4_chroma_x_phase - (i4_ref_chroma_x_phase << 1);
5095
640
            i4_x_phase_1 = (3 + i4_x_phase_0) & 0x7;
5096
640
            i4_x_phase_0 += 7;
5097
640
            i4_x_phase_0 &= 0x7;
5098
640
            i4_y_phase_0 = i4_chroma_y_phase - (i4_ref_chroma_y_phase << 1);
5099
640
            i4_y_phase_1 = (3 + i4_y_phase_0) & 0x7;
5100
640
            i4_y_phase_0 += 7;
5101
640
            i4_y_phase_0 &= 0x7;
5102
5103
640
            ps_lyr_ctxt->i4_x_phase_0 = i4_x_phase_0;
5104
640
            ps_lyr_ctxt->i4_x_phase_1 = i4_x_phase_1;
5105
640
            ps_lyr_ctxt->i4_y_phase_0 = i4_y_phase_0;
5106
640
            ps_lyr_ctxt->i4_y_phase_1 = i4_y_phase_1;
5107
5108
            /* Choose the appropriate chroma interpolation functions */
5109
640
            if((0 == i4_ref_chroma_x_phase) && (1 == i4_chroma_x_phase))
5110
0
            {
5111
0
                ps_lyr_ctxt->pf_horz_chroma_interpol = ps_ctxt->pf_horz_chroma_interpol[1];
5112
0
            }
5113
640
            else
5114
640
            {
5115
640
                ps_lyr_ctxt->pf_horz_chroma_interpol = ps_ctxt->pf_horz_chroma_interpol[0];
5116
640
            }
5117
5118
640
            i4_vert_flag = 0;
5119
640
            if(0 == i4_ref_chroma_y_phase)
5120
289
            {
5121
289
                if((1 == i4_chroma_y_phase) || (2 == i4_chroma_y_phase))
5122
0
                {
5123
0
                    i4_vert_flag = 1;
5124
0
                }
5125
289
            }
5126
351
            else if((2 == i4_ref_chroma_y_phase) && (0 == i4_chroma_y_phase))
5127
0
            {
5128
0
                i4_vert_flag = 2;
5129
0
            }
5130
5131
640
            if(1 == i4_vert_flag)
5132
0
            {
5133
0
                ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[1];
5134
0
            }
5135
640
            else if(2 == i4_vert_flag)
5136
0
            {
5137
0
                ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[2];
5138
0
            }
5139
640
            else
5140
640
            {
5141
640
                ps_lyr_ctxt->pf_vert_chroma_interpol = ps_ctxt->pf_vert_chroma_interpol[0];
5142
640
            }
5143
640
        }
5144
720
    }
5145
0
    else
5146
0
    {
5147
        /* should take false value */
5148
0
        if(SVCD_FALSE != ps_curr_lyr_res_prms->u1_remap_req_flag)
5149
0
        {
5150
0
            return NOT_OK;
5151
0
        }
5152
0
    }
5153
5154
    /* store the current layer width and height to context */
5155
720
    ps_ctxt->i4_ref_width = ps_curr_lyr_res_prms->i4_res_width;
5156
720
    ps_ctxt->i4_ref_height = ps_curr_lyr_res_prms->i4_res_height;
5157
5158
720
    return OK;
5159
720
}