Coverage Report

Created: 2026-01-09 06:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libavc/decoder/svc/isvcd_residual_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_residual_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_residual_chroma_dyadic_alt()
33
 *  - isvcd_residual_chroma_dyadic()
34
 *  - isvcd_residual_luma_dyadic()
35
 *  - isvcd_ref_layer_ptr_incr()
36
 *  - isvcd_residual_reflayer_const_non_boundary_mb()
37
 *  - isvcd_residual_reflayer_const_boundary_mb()
38
 *  - isvcd_residual_reflayer_const()
39
 *  - isvcd_interpolate_residual()
40
 *  - isvcd_residual_samp_mb()
41
 *  - isvcd_residual_samp_mb_dyadic()
42
 *  - isvcd_residual_samp_populate_list()
43
 *  - isvcd_residual_samp_res_init()
44
 *
45
 * @remarks
46
 *  None
47
 *
48
 *******************************************************************************
49
 */
50
51
#include <assert.h>
52
#include <string.h>
53
#include "ih264_typedefs.h"
54
#include "ih264_macros.h"
55
#include "ih264_platform_macros.h"
56
#include "ih264d_bitstrm.h"
57
#include "ih264d_defs.h"
58
#include "ih264d_debug.h"
59
#include "isvcd_structs.h"
60
#include "ih264d_defs.h"
61
#include "ih264d_parse_cavlc.h"
62
#include "ih264d_mb_utils.h"
63
#include "ih264d_deblocking.h"
64
#include "ih264d_dpb_manager.h"
65
#include "ih264d_mvpred.h"
66
#include "ih264d_inter_pred.h"
67
#include "ih264d_process_pslice.h"
68
#include "ih264d_error_handler.h"
69
#include "ih264d_cabac.h"
70
#include "ih264d_debug.h"
71
#include "ih264d_tables.h"
72
#include "ih264d_parse_slice.h"
73
#include "ih264d_utils.h"
74
#include "ih264d_parse_islice.h"
75
#include "ih264d_process_bslice.h"
76
#include "ih264d_process_intra_mb.h"
77
#include "ih264_debug.h"
78
79
/*****************************************************************************/
80
/*                                                                           */
81
/*  Function Name : isvcd_residual_chroma_dyadic_alt                          */
82
/*                                                                           */
83
/*  Description   : this fucntion does the upsampling of chroma residuals for*/
84
/*                  Dyadic cases and specific chroma phase cases             */
85
/*                                                                           */
86
/*  Inputs        : pv_residual_samp_ctxt : Residual upsampling context      */
87
/*                  pu1_inp_data : input 8 bit data pointer                  */
88
/*                  i4_inp_data_stride : input buffer stride                 */
89
/*                  pi2_out_res : output 16 bit buffer pointer               */
90
/*                  i4_out_res_stride : Output buffer stride                 */
91
/*                  pu1_inp_bitmap : input packed sign bit data pointer      */
92
/*                  i4_inp_bitmap_stride : sign bit buffer stride            */
93
/*                  i4_start_bit_pos : bit position in the byte of packed    */
94
/*                                      sign values                          */
95
/*  Globals       : none                                                     */
96
/*  Processing    : it does the upsampling with intial phase values          */
97
/*                                                                           */
98
/*  Outputs       : Upsampled residuals for chroma                           */
99
/*  Returns       : none                                                     */
100
/*                                                                           */
101
/*  Issues        : none                                                     */
102
/*                                                                           */
103
/*  Revision History:                                                        */
104
/*                                                                           */
105
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
106
/*         25 09 2021   vijayakumar          creation                        */
107
/*                                                                           */
108
/*****************************************************************************/
109
void isvcd_residual_chroma_dyadic_alt(void *pv_residual_samp_ctxt, UWORD16 u2_mb_x, UWORD16 u2_mb_y,
110
                                      mem_element_t *ps_ref_mb_mode, WORD16 *pi2_inp_data,
111
                                      WORD32 i4_inp_data_stride, WORD16 *pi2_out_res,
112
                                      WORD32 i4_out_res_stride, WORD32 i4_cr_flag)
113
0
{
114
0
    residual_sampling_ctxt_t *ps_ctxt;
115
0
    res_lyr_ctxt *ps_lyr_ctxt;
116
0
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
117
0
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
118
    /* ----------------- Processing ------------------------------- */
119
0
    {
120
0
        ref_pixel_map_t *ps_pos_phase;
121
0
        residual_samp_map_ctxt_t *ps_chroma_map;
122
0
        ref_mb_map_t *ps_x_off_len_chroma;
123
0
        ref_mb_map_t *ps_y_off_len_chroma;
124
0
        WORD32 i4_i;
125
0
        WORD16 *pi2_ref_data_byte;
126
0
        WORD32 *pi4_ref_array;
127
0
        WORD32 i4_phase1, i4_phase2;
128
0
        WORD32 i4_offset_x, i4_offset_y;
129
0
        WORD32 i4_chrm_horz_int_mode, i4_chrm_vert_int_mode;
130
0
        WORD32 i4_horz_intp_ctr = SUB_BLOCK_HEIGHT;
131
132
0
        ps_chroma_map = &ps_lyr_ctxt->s_chroma_map_ctxt;
133
0
        ps_x_off_len_chroma = ps_chroma_map->ps_x_offset_length;
134
0
        ps_y_off_len_chroma = ps_chroma_map->ps_y_offset_length;
135
136
        /* get the actual offset for the buffers */
137
0
        i4_offset_x = ps_x_off_len_chroma[u2_mb_x].i2_offset;
138
0
        i4_offset_y = ps_y_off_len_chroma[u2_mb_y].i2_offset;
139
140
0
        {
141
0
            UWORD8 u1_mask;
142
0
            WORD32 i4_mb_x, i4_mb_y;
143
0
            WORD32 i4_chrm_nnz;
144
0
            WORD32 i4_num_element_stride;
145
0
            inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms, *ps_inter_lyr_mb_prms_curr;
146
147
0
            u1_mask = (SVCD_TRUE == i4_cr_flag) ? 0xF0 : 0x0F;
148
149
            /* Top Left */
150
0
            i4_mb_x = i4_offset_x >> 3;
151
0
            i4_mb_y = i4_offset_y >> 3;
152
153
            /* get the location of the byte which has the current mb mode */
154
0
            ps_inter_lyr_mb_prms = ps_ref_mb_mode->pv_buffer;
155
0
            i4_num_element_stride = ps_ref_mb_mode->i4_num_element_stride;
156
157
0
            ps_inter_lyr_mb_prms_curr = ps_inter_lyr_mb_prms + i4_mb_x;
158
0
            ps_inter_lyr_mb_prms_curr += i4_mb_y * i4_num_element_stride;
159
0
            i4_chrm_nnz = ps_inter_lyr_mb_prms_curr->u1_chroma_nnz & u1_mask;
160
161
            /* Top Right */
162
0
            i4_mb_x = (i4_offset_x + 4) >> 3;
163
0
            ps_inter_lyr_mb_prms_curr = ps_inter_lyr_mb_prms + i4_mb_x;
164
0
            ps_inter_lyr_mb_prms_curr += i4_mb_y * i4_num_element_stride;
165
0
            i4_chrm_nnz |= ps_inter_lyr_mb_prms_curr->u1_chroma_nnz & u1_mask;
166
167
            /* Bottom Left */
168
0
            i4_mb_x = i4_offset_x >> 3;
169
0
            i4_mb_y = (i4_offset_y + 4) >> 3;
170
0
            ps_inter_lyr_mb_prms_curr = ps_inter_lyr_mb_prms + i4_mb_x;
171
0
            ps_inter_lyr_mb_prms_curr += i4_mb_y * i4_num_element_stride;
172
0
            i4_chrm_nnz |= ps_inter_lyr_mb_prms_curr->u1_chroma_nnz & u1_mask;
173
174
            /* Bottom Right */
175
0
            i4_mb_x = (i4_offset_x + 4) >> 3;
176
0
            ps_inter_lyr_mb_prms_curr = ps_inter_lyr_mb_prms + i4_mb_x;
177
0
            ps_inter_lyr_mb_prms_curr += i4_mb_y * i4_num_element_stride;
178
179
0
            i4_chrm_nnz |= ps_inter_lyr_mb_prms_curr->u1_chroma_nnz & u1_mask;
180
0
            if(0 == i4_chrm_nnz)
181
0
            {
182
0
                return;
183
0
            }
184
0
        }
185
186
0
        i4_chrm_horz_int_mode = ps_lyr_ctxt->i4_chrm_horz_int_mode;
187
0
        i4_chrm_vert_int_mode = ps_lyr_ctxt->i4_chrm_vert_int_mode;
188
189
0
        if(0 == i4_chrm_horz_int_mode)
190
0
        {
191
0
            if(i4_offset_x >= 0)
192
0
            {
193
0
                pi2_inp_data++;
194
0
            }
195
0
        }
196
197
0
        if(0 == i4_chrm_vert_int_mode)
198
0
        {
199
0
            if(i4_offset_y >= 0)
200
0
            {
201
0
                pi2_inp_data += i4_inp_data_stride;
202
0
            }
203
0
        }
204
0
        else
205
0
        {
206
            /* extra additional row of interpolation required for this case */
207
0
            i4_horz_intp_ctr++;
208
0
        }
209
210
        /* ----------- Horizontal Interpolation ---------------- */
211
0
        pi2_ref_data_byte = pi2_inp_data;
212
0
        ps_pos_phase = ps_lyr_ctxt->s_chroma_map_ctxt.ps_x_pos_phase;
213
214
0
        pi4_ref_array = (WORD32 *) ps_ctxt->pi2_refarray_buffer;
215
0
        i4_phase1 = ps_pos_phase[0].i2_phase;
216
0
        i4_phase2 = (i4_phase1 + 8) & 0x0F;
217
218
        /* interchange the phase values for corner case */
219
0
        if(1 == i4_chrm_horz_int_mode)
220
0
        {
221
0
            WORD32 i4_temp;
222
0
            i4_temp = i4_phase1;
223
0
            i4_phase1 = i4_phase2;
224
0
            i4_phase2 = i4_temp;
225
0
        }
226
227
0
        for(i4_i = 0; i4_i < i4_horz_intp_ctr; i4_i++)
228
0
        {
229
0
            WORD16 i2_coeff1, i2_coeff2;
230
231
0
            i2_coeff1 = (WORD16) (pi2_ref_data_byte[0]);
232
233
0
            if(0 == i4_chrm_horz_int_mode)
234
0
            {
235
                /* populate the first inter sample */
236
0
                *pi4_ref_array++ = i2_coeff1 << 4;
237
0
            }
238
239
            /* unroll count 1 */
240
0
            i2_coeff2 = (WORD16) (pi2_ref_data_byte[2]);
241
242
            /* populate 2 samples based on current coeffs */
243
0
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff1 + i4_phase2 * i2_coeff2);
244
0
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff1 + i4_phase1 * i2_coeff2);
245
246
            /* unroll count 2 */
247
0
            i2_coeff1 = (WORD16) (pi2_ref_data_byte[4]);
248
249
            /* populate 2 samples based on current coeffs */
250
0
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff2 + i4_phase2 * i2_coeff1);
251
0
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff2 + i4_phase1 * i2_coeff1);
252
253
            /* unroll count 3 */
254
0
            i2_coeff2 = (WORD16) (pi2_ref_data_byte[6]);
255
256
            /* populate 2 samples based on current coeffs */
257
0
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff1 + i4_phase2 * i2_coeff2);
258
0
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff1 + i4_phase1 * i2_coeff2);
259
260
            /* populate the last inter sample */
261
0
            *pi4_ref_array++ = i2_coeff2 << 4;
262
263
0
            if(1 == i4_chrm_horz_int_mode)
264
0
            {
265
0
                i2_coeff1 = (WORD16) (pi2_ref_data_byte[4]);
266
267
                /* populate the last inter sample */
268
0
                *pi4_ref_array++ = i2_coeff1 << 4;
269
0
            }
270
271
            /* vertical loop updates */
272
0
            pi2_ref_data_byte = pi2_inp_data + ((i4_i + 1) * i4_inp_data_stride);
273
0
        }
274
275
        /* ----------- Vertical Interpolation ---------------- */
276
0
        pi4_ref_array = (WORD32 *) ps_ctxt->pi2_refarray_buffer;
277
0
        ps_pos_phase = ps_lyr_ctxt->s_chroma_map_ctxt.ps_y_pos_phase;
278
0
        i4_phase1 = ps_pos_phase[0].i2_phase;
279
0
        i4_phase2 = (i4_phase1 + 8) & 0x0F;
280
281
        /* interchange the phase values for corner case */
282
0
        if(0 != i4_chrm_vert_int_mode)
283
0
        {
284
0
            WORD32 i4_temp;
285
0
            i4_temp = i4_phase1;
286
0
            i4_phase1 = i4_phase2;
287
0
            i4_phase2 = i4_temp;
288
0
        }
289
290
0
        for(i4_i = 0; i4_i < BLOCK_WIDTH; i4_i++)
291
0
        {
292
0
            WORD16 *pi2_out;
293
0
            WORD32 *pi4_ref_array_temp;
294
0
            WORD32 i4_horz_samp_1, i4_horz_samp_2;
295
0
            pi2_out = pi2_out_res;
296
0
            pi4_ref_array_temp = pi4_ref_array;
297
298
            /* populate the first inter sample */
299
0
            i4_horz_samp_1 = *pi4_ref_array_temp;
300
0
            pi4_ref_array_temp += BLOCK_WIDTH;
301
302
0
            if(1 != i4_chrm_vert_int_mode)
303
0
            {
304
0
                *pi2_out = (i4_horz_samp_1 + 8) >> 4;
305
0
                pi2_out += i4_out_res_stride;
306
0
            }
307
308
0
            if(2 == i4_chrm_vert_int_mode)
309
0
            {
310
0
                i4_horz_samp_1 = *pi4_ref_array_temp;
311
0
                pi4_ref_array_temp += BLOCK_WIDTH;
312
0
                *pi2_out = (i4_horz_samp_1 + 8) >> 4;
313
0
                pi2_out += i4_out_res_stride;
314
0
            }
315
316
            /* unroll count 1 */
317
0
            i4_horz_samp_2 = *pi4_ref_array_temp;
318
0
            pi4_ref_array_temp += BLOCK_WIDTH;
319
320
            /* populate 2 samples based on current coeffs */
321
0
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_1 + i4_phase2 * i4_horz_samp_2 + 128) >> 8;
322
0
            pi2_out += i4_out_res_stride;
323
324
            /* unroll count 2 */
325
0
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_1 + i4_phase1 * i4_horz_samp_2 + 128) >> 8;
326
0
            pi2_out += i4_out_res_stride;
327
328
            /* unroll count 3 */
329
0
            i4_horz_samp_1 = *pi4_ref_array_temp;
330
0
            pi4_ref_array_temp += BLOCK_WIDTH;
331
332
            /* populate 2 samples based on current coeffs */
333
0
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_2 + i4_phase2 * i4_horz_samp_1 + 128) >> 8;
334
0
            pi2_out += i4_out_res_stride;
335
336
            /* unroll count 4 */
337
0
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_2 + i4_phase1 * i4_horz_samp_1 + 128) >> 8;
338
0
            pi2_out += i4_out_res_stride;
339
340
            /* unroll count 5 */
341
0
            i4_horz_samp_2 = *pi4_ref_array_temp;
342
343
            /* populate 2 samples based on current coeffs */
344
0
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_1 + i4_phase2 * i4_horz_samp_2 + 128) >> 8;
345
0
            pi2_out += i4_out_res_stride;
346
347
            /* unroll count 6 */
348
0
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_1 + i4_phase1 * i4_horz_samp_2 + 128) >> 8;
349
0
            pi2_out += i4_out_res_stride;
350
351
0
            if(2 != i4_chrm_vert_int_mode)
352
0
            {
353
                /* populate the last inter sample */
354
0
                *pi2_out = (i4_horz_samp_2 + 8) >> 4;
355
356
0
                if(1 == i4_chrm_vert_int_mode)
357
0
                {
358
0
                    pi2_out += i4_out_res_stride;
359
0
                    pi4_ref_array_temp += BLOCK_WIDTH;
360
0
                    i4_horz_samp_1 = *pi4_ref_array_temp;
361
362
                    /* populate the last inter sample */
363
0
                    *pi2_out = (i4_horz_samp_1 + 8) >> 4;
364
0
                }
365
0
            }
366
            /* horizontal loop updates */
367
0
            pi4_ref_array++;
368
0
            pi2_out_res += 2;
369
0
        }
370
0
    }
371
0
    return;
372
0
}
373
374
/*****************************************************************************/
375
/*                                                                           */
376
/*  Function Name : isvcd_residual_chroma_dyadic                              */
377
/*                                                                           */
378
/*  Description   : this fucntion does the upsampling of chroma residuals for*/
379
/*                  Dyadic cases                                             */
380
/*                                                                           */
381
/*  Inputs        : pv_residual_samp_ctxt : Residual upsampling context      */
382
/*                  pu1_inp_data : input 8 bit data pointer                  */
383
/*                  i4_inp_data_stride : input buffer stride                 */
384
/*                  pi2_out_res : output 16 bit buffer pointer               */
385
/*                  i4_out_res_stride : Output buffer stride                 */
386
/*                  pu1_inp_bitmap : input packed sign bit data pointer      */
387
/*                  i4_inp_bitmap_stride : sign bit buffer stride            */
388
/*                  i4_start_bit_pos : bit position in the byte of packed    */
389
/*                                      sign values                          */
390
/*  Globals       : none                                                     */
391
/*  Processing    : it does the upsampling with intial phase values          */
392
/*                                                                           */
393
/*  Outputs       : Upsampled residuals for chroma                           */
394
/*  Returns       : none                                                     */
395
/*                                                                           */
396
/*  Issues        : none                                                     */
397
/*                                                                           */
398
/*  Revision History:                                                        */
399
/*                                                                           */
400
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
401
/*         25 09 2021   vijayakumar          creation                        */
402
/*                                                                           */
403
/*****************************************************************************/
404
void isvcd_residual_chroma_dyadic(void *pv_residual_samp_ctxt, WORD16 *pi2_inp_data,
405
                                  WORD32 i4_inp_data_stride, WORD16 *pi2_out_res,
406
                                  WORD32 i4_out_res_stride)
407
2.32k
{
408
2.32k
    residual_sampling_ctxt_t *ps_ctxt;
409
2.32k
    res_lyr_ctxt *ps_lyr_ctxt;
410
2.32k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
411
2.32k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
412
    /* ----------------- Processing ------------------------------- */
413
2.32k
    {
414
2.32k
        WORD32 i4_i;
415
2.32k
        WORD16 *pi2_ref_data_byte;
416
2.32k
        WORD32 *pi4_ref_array;
417
2.32k
        ref_pixel_map_t *ps_pos_phase;
418
2.32k
        WORD32 i4_phase1, i4_phase2;
419
420
2.32k
        pi2_ref_data_byte = pi2_inp_data;
421
2.32k
        ps_pos_phase = ps_lyr_ctxt->s_chroma_map_ctxt.ps_x_pos_phase;
422
423
        /* ----------- Horizontal Interpolation ---------------- */
424
2.32k
        pi4_ref_array = (WORD32 *) ps_ctxt->pi2_refarray_buffer;
425
2.32k
        i4_phase1 = ps_pos_phase[0].i2_phase;
426
2.32k
        i4_phase2 = (i4_phase1 + 8) & 0x0F;
427
428
11.6k
        for(i4_i = 0; i4_i < SUB_BLOCK_HEIGHT; i4_i++)
429
9.28k
        {
430
9.28k
            WORD16 i2_coeff1, i2_coeff2;
431
9.28k
            i2_coeff1 = (WORD16) (pi2_ref_data_byte[0]);
432
433
            /* populate the first inter sample */
434
9.28k
            *pi4_ref_array++ = i2_coeff1 << 4;
435
436
            /* unroll count 1 */
437
9.28k
            i2_coeff2 = (WORD16) (pi2_ref_data_byte[2]);
438
439
            /* populate 2 samples based on current coeffs */
440
9.28k
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff1 + i4_phase2 * i2_coeff2);
441
442
            /* unroll count 2 */
443
9.28k
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff1 + i4_phase1 * i2_coeff2);
444
445
            /* unroll count 3 */
446
9.28k
            i2_coeff1 = (WORD16) (pi2_ref_data_byte[4]);
447
448
            /* populate 2 samples based on current coeffs */
449
9.28k
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff2 + i4_phase2 * i2_coeff1);
450
451
            /* unroll count 4 */
452
9.28k
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff2 + i4_phase1 * i2_coeff1);
453
454
            /* unroll count 5 */
455
9.28k
            i2_coeff2 = (WORD16) (pi2_ref_data_byte[6]);
456
457
            /* populate 2 samples based on current coeffs */
458
9.28k
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff1 + i4_phase2 * i2_coeff2);
459
460
            /* unroll count 6 */
461
9.28k
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff1 + i4_phase1 * i2_coeff2);
462
463
            /* populate the last inter sample */
464
9.28k
            *pi4_ref_array++ = i2_coeff2 << 4;
465
466
            /* vertical loop uopdates */
467
9.28k
            pi2_ref_data_byte = pi2_inp_data + ((i4_i + 1) * i4_inp_data_stride);
468
9.28k
        }
469
470
        /* ----------- Vertical Interpolation ---------------- */
471
2.32k
        pi4_ref_array = (WORD32 *) ps_ctxt->pi2_refarray_buffer;
472
2.32k
        ps_pos_phase = ps_lyr_ctxt->s_chroma_map_ctxt.ps_y_pos_phase;
473
2.32k
        i4_phase1 = ps_pos_phase[0].i2_phase;
474
2.32k
        i4_phase2 = (i4_phase1 + 8) & 0x0F;
475
476
20.8k
        for(i4_i = 0; i4_i < BLOCK_WIDTH; i4_i++)
477
18.5k
        {
478
18.5k
            WORD16 *pi2_out;
479
18.5k
            WORD32 *pi4_ref_array_temp;
480
18.5k
            WORD32 i4_horz_samp_1, i4_horz_samp_2;
481
18.5k
            pi2_out = pi2_out_res;
482
18.5k
            pi4_ref_array_temp = pi4_ref_array;
483
484
            /* populate the first inter sample */
485
18.5k
            i4_horz_samp_1 = *pi4_ref_array_temp;
486
18.5k
            pi4_ref_array_temp += BLOCK_WIDTH;
487
18.5k
            *pi2_out = (i4_horz_samp_1 + 8) >> 4;
488
18.5k
            pi2_out += i4_out_res_stride;
489
490
            /* unroll count 1 */
491
18.5k
            i4_horz_samp_2 = *pi4_ref_array_temp;
492
18.5k
            pi4_ref_array_temp += BLOCK_WIDTH;
493
494
            /* populate 2 samples based on current coeffs */
495
18.5k
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_1 + i4_phase2 * i4_horz_samp_2 + 128) >> 8;
496
18.5k
            pi2_out += i4_out_res_stride;
497
498
            /* unroll count 2 */
499
18.5k
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_1 + i4_phase1 * i4_horz_samp_2 + 128) >> 8;
500
18.5k
            pi2_out += i4_out_res_stride;
501
502
            /* unroll count 3 */
503
18.5k
            i4_horz_samp_1 = *pi4_ref_array_temp;
504
18.5k
            pi4_ref_array_temp += BLOCK_WIDTH;
505
506
            /* populate 2 samples based on current coeffs */
507
18.5k
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_2 + i4_phase2 * i4_horz_samp_1 + 128) >> 8;
508
18.5k
            pi2_out += i4_out_res_stride;
509
510
            /* unroll count 4 */
511
18.5k
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_2 + i4_phase1 * i4_horz_samp_1 + 128) >> 8;
512
18.5k
            pi2_out += i4_out_res_stride;
513
514
            /* unroll count 5 */
515
18.5k
            i4_horz_samp_2 = *pi4_ref_array_temp;
516
517
            /* populate 2 samples based on current coeffs */
518
18.5k
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_1 + i4_phase2 * i4_horz_samp_2 + 128) >> 8;
519
18.5k
            pi2_out += i4_out_res_stride;
520
521
            /* unroll count 6 */
522
18.5k
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_1 + i4_phase1 * i4_horz_samp_2 + 128) >> 8;
523
18.5k
            pi2_out += i4_out_res_stride;
524
525
            /* populate the last inter sample */
526
18.5k
            *pi2_out = (i4_horz_samp_2 + 8) >> 4;
527
528
            /* horizontal loop updates */
529
18.5k
            pi4_ref_array++;
530
18.5k
            pi2_out_res += 2;
531
18.5k
        }
532
2.32k
    }
533
2.32k
    return;
534
2.32k
}
535
536
/*****************************************************************************/
537
/*                                                                           */
538
/*  Function Name : isvcd_residual_luma_dyadic                                */
539
/*                                                                           */
540
/*  Description   : this fucntion does the upsampling of luma residuals for  */
541
/*                  Dyadic cases                                             */
542
/*                                                                           */
543
/*  Inputs        : pv_residual_samp_ctxt : Residual upsampling context      */
544
/*                  pu1_inp_data : input 8 bit data pointer                  */
545
/*                  i4_inp_data_stride : input buffer stride                 */
546
/*                  pi2_out_res : output 16 bit buffer pointer               */
547
/*                  i4_out_res_stride : Output buffer stride                 */
548
/*                  pu1_inp_bitmap : input packed sign bit data pointer      */
549
/*                  i4_inp_bitmap_stride : sign bit buffer stride            */
550
/*                  ps_ref_mb_mode : reference mb mode pointer of base layer */
551
/*                  ps_coord : mb co-ordinate pointer                        */
552
/*  Globals       : none                                                     */
553
/*  Processing    : it does the upsampling with fixed phase values and       */
554
/*                  reference layer transform size                           */
555
/*  Outputs       : Upsampled residuals for luma                             */
556
/*  Returns       : none                                                     */
557
/*                                                                           */
558
/*  Issues        : none                                                     */
559
/*                                                                           */
560
/*  Revision History:                                                        */
561
/*                                                                           */
562
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
563
/*         25 09 2021   vijayakumar          creation                        */
564
/*                                                                           */
565
/*****************************************************************************/
566
void isvcd_residual_luma_dyadic(void *pv_residual_samp_ctxt, WORD16 *pi2_inp_data,
567
                                WORD32 i4_inp_data_stride, WORD16 *pi2_out_res,
568
                                WORD32 i4_out_res_stride, mem_element_t *ps_ref_mb_mode,
569
                                UWORD16 u2_mb_x, UWORD16 u2_mb_y, WORD32 i4_ref_nnz,
570
                                WORD32 i4_ref_tx_size)
571
572
17.8k
{
573
17.8k
    WORD16 *pi2_refarray_buffer;
574
17.8k
    WORD32 i4_blk_ctr;
575
17.8k
    residual_sampling_ctxt_t *ps_ctxt;
576
577
17.8k
    UNUSED(ps_ref_mb_mode);
578
17.8k
    UNUSED(u2_mb_x);
579
17.8k
    UNUSED(u2_mb_y);
580
581
17.8k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
582
17.8k
    pi2_refarray_buffer = ps_ctxt->pi2_refarray_buffer;
583
584
    /* based on transform size the counter and interpolation width and */
585
    /* height are intialised as follows                                */
586
17.8k
    if((i4_ref_tx_size) && (0 != i4_ref_nnz))
587
1.32k
    {
588
1.32k
        WORD16 *pi2_ref_data_byte;
589
1.32k
        WORD32 *pi4_ref_array;
590
1.32k
        WORD32 i4_i, i4_j;
591
592
1.32k
        pi2_ref_data_byte = pi2_inp_data;
593
594
        /* ----------- Horizontal Interpolation ---------------- */
595
1.32k
        pi4_ref_array = (WORD32 *) pi2_refarray_buffer;
596
11.9k
        for(i4_i = 0; i4_i < BLOCK_HEIGHT; i4_i++)
597
10.5k
        {
598
10.5k
            WORD16 i2_coeff1, i2_coeff2;
599
10.5k
            i2_coeff1 = (WORD16) (*pi2_ref_data_byte++);
600
601
            /* populate the first inter sample */
602
10.5k
            *pi4_ref_array++ = i2_coeff1 << 2;
603
604
84.7k
            for(i4_j = 0; i4_j < 14; i4_j += 2)
605
74.1k
            {
606
74.1k
                i2_coeff2 = (WORD16) (*pi2_ref_data_byte++);
607
608
                /* populate 2 samples based on current coeffs */
609
74.1k
                *pi4_ref_array++ = ((i2_coeff1 << 1) + (i2_coeff1) + (i2_coeff2));
610
74.1k
                *pi4_ref_array++ = ((i2_coeff2 << 1) + (i2_coeff2) + (i2_coeff1));
611
612
                /* store the coeff 2 to coeff 1 */
613
                /* (used in next iteration)     */
614
74.1k
                i2_coeff1 = i2_coeff2;
615
74.1k
            }
616
617
            /* populate the last inter sample */
618
10.5k
            *pi4_ref_array++ = i2_coeff1 << 2;
619
620
            /* vertical loop uopdates */
621
10.5k
            pi2_ref_data_byte = pi2_inp_data + ((i4_i + 1) * i4_inp_data_stride);
622
10.5k
        }
623
624
        /* ----------- Vertical Interpolation ---------------- */
625
1.32k
        pi4_ref_array = (WORD32 *) pi2_refarray_buffer;
626
627
22.5k
        for(i4_i = 0; i4_i < MB_WIDTH; i4_i++)
628
21.1k
        {
629
21.1k
            WORD32 *pi4_ref_array_temp;
630
21.1k
            WORD16 *pi2_out;
631
21.1k
            WORD32 i4_horz_samp_1, i4_horz_samp_2;
632
633
21.1k
            pi4_ref_array_temp = pi4_ref_array;
634
21.1k
            pi2_out = pi2_out_res;
635
21.1k
            i4_horz_samp_1 = *pi4_ref_array_temp;
636
637
            /* populate the first inter sample */
638
21.1k
            *pi2_out = (i4_horz_samp_1 + 2) >> 2;
639
21.1k
            pi2_out += i4_out_res_stride;
640
641
169k
            for(i4_j = 0; i4_j < 14; i4_j += 2)
642
148k
            {
643
148k
                pi4_ref_array_temp += MB_WIDTH;
644
148k
                i4_horz_samp_2 = *pi4_ref_array_temp;
645
646
                /* populate 2 samples based on current coeffs */
647
148k
                *pi2_out = ((i4_horz_samp_1 << 1) + (i4_horz_samp_1) + (i4_horz_samp_2) + 8) >> 4;
648
148k
                pi2_out += i4_out_res_stride;
649
148k
                *pi2_out = ((i4_horz_samp_2 << 1) + (i4_horz_samp_2) + (i4_horz_samp_1) + 8) >> 4;
650
148k
                pi2_out += i4_out_res_stride;
651
652
                /* store the coeff 2 to coeff 1 */
653
                /* (used in next iteration)     */
654
148k
                i4_horz_samp_1 = i4_horz_samp_2;
655
148k
            }
656
657
            /* populate the first inter sample */
658
21.1k
            *pi2_out = (i4_horz_samp_1 + 2) >> 2;
659
660
            /* horizontal loop updates */
661
21.1k
            pi4_ref_array++;
662
21.1k
            pi2_out_res++;
663
21.1k
        }
664
1.32k
    }
665
16.5k
    else
666
16.5k
    {
667
        /* ----------------------------------------------------------------- */
668
        /* LOOP over number of blocks                                        */
669
        /* ----------------------------------------------------------------- */
670
82.5k
        for(i4_blk_ctr = 0; i4_blk_ctr < 4; i4_blk_ctr++)
671
66.0k
        {
672
66.0k
            WORD16 *pi2_ref_data_byte;
673
66.0k
            WORD32 *pi4_ref_array;
674
66.0k
            WORD32 i4_i;
675
676
            /* if reference layer is not coded then no processing */
677
66.0k
            if(0 != (i4_ref_nnz & 0x1))
678
8.88k
            {
679
8.88k
                pi2_ref_data_byte = pi2_inp_data;
680
681
                /* ----------- Horizontal Interpolation ---------------- */
682
8.88k
                pi4_ref_array = (WORD32 *) pi2_refarray_buffer;
683
684
44.4k
                for(i4_i = 0; i4_i < SUB_BLOCK_HEIGHT; i4_i++)
685
35.5k
                {
686
35.5k
                    WORD16 i2_coeff1, i2_coeff2;
687
35.5k
                    i2_coeff1 = (WORD16) (*pi2_ref_data_byte++);
688
689
                    /* populate the first inter sample */
690
35.5k
                    *pi4_ref_array++ = i2_coeff1 << 2;
691
692
35.5k
                    i2_coeff2 = (WORD16) (*pi2_ref_data_byte++);
693
694
                    /* populate 2 samples based on current coeffs */
695
35.5k
                    *pi4_ref_array++ = ((i2_coeff1 << 1) + (i2_coeff1) + (i2_coeff2));
696
35.5k
                    *pi4_ref_array++ = ((i2_coeff2 << 1) + (i2_coeff2) + (i2_coeff1));
697
698
35.5k
                    i2_coeff1 = (WORD16) (*pi2_ref_data_byte++);
699
700
                    /* populate 2 samples based on current coeffs */
701
35.5k
                    *pi4_ref_array++ = ((i2_coeff2 << 1) + (i2_coeff2) + (i2_coeff1));
702
35.5k
                    *pi4_ref_array++ = ((i2_coeff1 << 1) + (i2_coeff1) + (i2_coeff2));
703
704
35.5k
                    i2_coeff2 = (WORD16) (*pi2_ref_data_byte++);
705
706
                    /* populate 2 samples based on current coeffs */
707
35.5k
                    *pi4_ref_array++ = ((i2_coeff1 << 1) + (i2_coeff1) + (i2_coeff2));
708
35.5k
                    *pi4_ref_array++ = ((i2_coeff2 << 1) + (i2_coeff2) + (i2_coeff1));
709
710
                    /* populate the last inter sample */
711
35.5k
                    *pi4_ref_array++ = i2_coeff2 << 2;
712
713
                    /* vertical loop uopdates */
714
35.5k
                    pi2_ref_data_byte = pi2_inp_data + ((i4_i + 1) * i4_inp_data_stride);
715
35.5k
                }
716
717
                /* ----------- Vertical Interpolation ---------------- */
718
8.88k
                pi4_ref_array = (WORD32 *) pi2_refarray_buffer;
719
720
79.9k
                for(i4_i = 0; i4_i < BLOCK_WIDTH; i4_i++)
721
71.0k
                {
722
71.0k
                    WORD32 *pi4_ref_array_temp;
723
71.0k
                    WORD16 *pi2_out;
724
71.0k
                    WORD32 i4_horz_samp_1, i4_horz_samp_2;
725
726
71.0k
                    pi4_ref_array_temp = pi4_ref_array;
727
71.0k
                    pi2_out = pi2_out_res;
728
71.0k
                    i4_horz_samp_1 = *pi4_ref_array_temp;
729
730
                    /* populate the first inter sample */
731
71.0k
                    *pi2_out = (i4_horz_samp_1 + 2) >> 2;
732
71.0k
                    pi2_out += i4_out_res_stride;
733
734
                    /* unroll loop count 1 */
735
71.0k
                    pi4_ref_array_temp += BLOCK_WIDTH;
736
71.0k
                    i4_horz_samp_2 = *pi4_ref_array_temp;
737
738
                    /* populate 2 samples based on current coeffs */
739
71.0k
                    *pi2_out =
740
71.0k
                        ((i4_horz_samp_1 << 1) + (i4_horz_samp_1) + (i4_horz_samp_2) + 8) >> 4;
741
71.0k
                    pi2_out += i4_out_res_stride;
742
71.0k
                    *pi2_out =
743
71.0k
                        ((i4_horz_samp_2 << 1) + (i4_horz_samp_2) + (i4_horz_samp_1) + 8) >> 4;
744
71.0k
                    pi2_out += i4_out_res_stride;
745
746
                    /* unroll loop count 2 */
747
71.0k
                    pi4_ref_array_temp += BLOCK_WIDTH;
748
71.0k
                    i4_horz_samp_1 = *pi4_ref_array_temp;
749
750
                    /* populate 2 samples based on current coeffs */
751
71.0k
                    *pi2_out =
752
71.0k
                        ((i4_horz_samp_2 << 1) + (i4_horz_samp_2) + (i4_horz_samp_1) + 8) >> 4;
753
71.0k
                    pi2_out += i4_out_res_stride;
754
71.0k
                    *pi2_out =
755
71.0k
                        ((i4_horz_samp_1 << 1) + (i4_horz_samp_1) + (i4_horz_samp_2) + 8) >> 4;
756
71.0k
                    pi2_out += i4_out_res_stride;
757
758
                    /* unroll loop count 3 */
759
71.0k
                    pi4_ref_array_temp += BLOCK_WIDTH;
760
71.0k
                    i4_horz_samp_2 = *pi4_ref_array_temp;
761
762
                    /* populate 2 samples based on current coeffs */
763
71.0k
                    *pi2_out =
764
71.0k
                        ((i4_horz_samp_1 << 1) + (i4_horz_samp_1) + (i4_horz_samp_2) + 8) >> 4;
765
71.0k
                    pi2_out += i4_out_res_stride;
766
71.0k
                    *pi2_out =
767
71.0k
                        ((i4_horz_samp_2 << 1) + (i4_horz_samp_2) + (i4_horz_samp_1) + 8) >> 4;
768
71.0k
                    pi2_out += i4_out_res_stride;
769
770
                    /* populate the last inter sample */
771
71.0k
                    *pi2_out = (i4_horz_samp_2 + 2) >> 2;
772
773
                    /* horizontal loop updates */
774
71.0k
                    pi4_ref_array++;
775
71.0k
                    pi2_out_res++;
776
71.0k
                }
777
8.88k
            }
778
57.1k
            else
779
57.1k
            {
780
57.1k
                pi2_out_res += BLOCK_WIDTH;
781
57.1k
            }
782
783
            /* Block level loop updates */
784
66.0k
            if(1 == i4_blk_ctr)
785
16.5k
            {
786
16.5k
                pi2_inp_data -= SUB_BLOCK_WIDTH;
787
16.5k
                pi2_inp_data += (i4_inp_data_stride * SUB_BLOCK_HEIGHT);
788
16.5k
                pi2_out_res -= MB_WIDTH;
789
16.5k
                pi2_out_res += (i4_out_res_stride * BLOCK_HEIGHT);
790
16.5k
                i4_ref_nnz >>= 2;
791
16.5k
            }
792
49.5k
            else
793
49.5k
            {
794
49.5k
                pi2_inp_data += SUB_BLOCK_WIDTH;
795
49.5k
            }
796
797
66.0k
            i4_ref_nnz >>= 1;
798
799
66.0k
        } /* end of loop over all the blocks */
800
16.5k
    }
801
17.8k
    return;
802
17.8k
}
803
804
/*****************************************************************************/
805
/*                                                                           */
806
/*  Function Name :  isvcd_ref_layer_ptr_incr                                 */
807
/*                                                                           */
808
/*  Description   :  this function returns the pointer increments for        */
809
/*                   the operand2 of the bilinear interpolation              */
810
/*  Inputs        : pi1_ref_mb_modes : reference mb modes                    */
811
/*                  i4_ref_mode_stride : mb mode buffer stride               */
812
/*                    i4_element_size : size of reference mb mode            */
813
/*                  i4_x_offset : ref offset x                               */
814
/*                  i4_y_offset : ref offset y                               */
815
/*                    i4_refary_wd : reference array width                   */
816
/*                    i4_refary_ht : reference array height                  */
817
/*                  pu1_ref_x_ptr_incr : ptr increment buffer for x          */
818
/*                  pu1_ref_y_ptr_incr : ptr increment buffer for y          */
819
/*                    i4_chroma_flag : chroma processing flag                */
820
/*  Globals       : none                                                     */
821
/*  Processing    : it calculates the increment as per the transform size    */
822
/*                                                                           */
823
/*  Outputs       : none                                                     */
824
/*  Returns       : none                                                     */
825
/*                                                                           */
826
/*  Issues        : none                                                     */
827
/*                                                                           */
828
/*  Revision History:                                                        */
829
/*                                                                           */
830
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
831
/*         18 08 2021   Kishore              creation                        */
832
/*                                                                           */
833
/*****************************************************************************/
834
WORD32 isvcd_ref_layer_ptr_incr(WORD8 *pi1_ref_mb_modes, WORD32 i4_ref_mode_stride,
835
                                WORD32 i4_element_size, WORD32 i4_x_offset, WORD32 i4_y_offset,
836
                                WORD32 i4_refary_wd, WORD32 i4_refary_ht,
837
                                UWORD8 *pu1_ref_x_ptr_incr, UWORD8 *pu1_ref_y_ptr_incr,
838
                                WORD32 i4_chroma_flag)
839
338k
{
840
338k
    WORD32 i4_x, i4_y;
841
338k
    WORD32 i4_x_idx, i4_y_idx;
842
338k
    WORD32 i4_prev_x, i4_prev_y;
843
338k
    WORD32 i4_const_val;
844
338k
    WORD32 i4_pos_x, i4_pos_y;
845
338k
    WORD32 i4_trans_size;
846
338k
    WORD32 i4_act_ary_wd, i4_act_ary_ht;
847
338k
    WORD32 i4_and_const;
848
338k
    UWORD8 *pu1_incr_x, *pu1_incr_y;
849
338k
    WORD32 i4_mb_sft;
850
338k
    WORD32 i4_mb_x, i4_mb_y;
851
338k
    WORD8 *pi1_ref_mb_modes_incr;
852
338k
    WORD8 *pi1_ref_mb_modes_incr_temp;
853
338k
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
854
338k
    WORD32 i4_mb_x_strt, i4_mb_y_strt;
855
338k
    WORD32 i4_mb_quard1_part_x, i4_mb_quard1_part_y;
856
338k
    WORD32 i4_x_ref, i4_y_ref;
857
338k
    WORD32 i4_tx_size, i4_tx_size_q0, i4_tx_size_q1, i4_tx_size_q2, i4_tx_size_q3;
858
338k
    WORD8 i1_mb_mode_q0, i1_mb_mode_q1, i1_mb_mode_q2, i1_mb_mode_q3;
859
338k
    WORD32 i4_mb_wd;
860
338k
    WORD32 i4_mb_ht;
861
862
338k
    i4_mb_wd = MB_WIDTH >> i4_chroma_flag;
863
338k
    i4_mb_ht = MB_HEIGHT >> i4_chroma_flag;
864
865
    /* Memset to 1 the increment buffers */
866
338k
    memset(pu1_ref_x_ptr_incr, 1, (i4_refary_wd * i4_refary_ht));
867
338k
    memset(pu1_ref_y_ptr_incr, 1, (i4_refary_wd * i4_refary_ht));
868
869
    /* Initialise actual width and height */
870
338k
    i4_act_ary_wd = i4_refary_wd;
871
338k
    i4_act_ary_ht = i4_refary_ht;
872
873
    /* Initialize x and y */
874
338k
    i4_x = 0;
875
338k
    i4_y = 0;
876
338k
    i4_prev_y = 0;
877
338k
    i4_mb_sft = (MB_WIDTH_SHIFT - i4_chroma_flag);
878
879
    /* Loop over all MBs in the reference array */
880
338k
    if(0 == i4_chroma_flag)
881
112k
    {
882
112k
        i4_x_ref = i4_x_offset + 0;
883
112k
        i4_y_ref = i4_y_offset + 0;
884
112k
        i4_mb_x_strt = i4_x_ref % i4_mb_wd;
885
112k
        i4_mb_y_strt = i4_y_ref % i4_mb_ht;
886
112k
        i4_mb_quard1_part_x = i4_mb_wd - i4_mb_x_strt;
887
112k
        i4_mb_quard1_part_y = i4_mb_ht - i4_mb_y_strt;
888
889
112k
        if(!(i4_mb_quard1_part_x >= 0))
890
0
        {
891
0
            return NOT_OK;
892
0
        }
893
112k
        if(!(i4_mb_quard1_part_y >= 0))
894
0
        {
895
0
            return NOT_OK;
896
0
        }
897
898
        /* Take care of negative offsets */
899
112k
        if(i4_x_ref > 0)
900
74.0k
        {
901
74.0k
            i4_mb_x = (i4_x_ref >> i4_mb_sft);
902
74.0k
        }
903
38.7k
        else
904
38.7k
        {
905
38.7k
            i4_mb_x = 0;
906
38.7k
        }
907
112k
        if(i4_y_ref > 0)
908
94.8k
        {
909
94.8k
            i4_mb_y = (i4_y_ref >> i4_mb_sft);
910
94.8k
        }
911
17.8k
        else
912
17.8k
        {
913
17.8k
            i4_mb_y = 0;
914
17.8k
        }
915
916
        /* get the location of the byte which has the current mb mode */
917
112k
        pi1_ref_mb_modes_incr = pi1_ref_mb_modes + (i4_mb_y * i4_ref_mode_stride * i4_element_size);
918
112k
        pi1_ref_mb_modes_incr += (i4_mb_x * i4_element_size);
919
112k
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr;
920
112k
        i1_mb_mode_q0 = ps_inter_lyr_mb_prms->i1_mb_mode;
921
112k
        i4_tx_size_q0 =
922
112k
            (i1_mb_mode_q0 <= SVC_INTER_MB)
923
112k
                ? ((ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1 : ps_inter_lyr_mb_prms->i1_tx_size)
924
112k
                : 1;
925
926
112k
        pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr;
927
112k
        if(i4_mb_quard1_part_x > 0)
928
112k
        {
929
112k
            pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr + i4_element_size;
930
112k
            ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
931
112k
            i1_mb_mode_q1 = ps_inter_lyr_mb_prms->i1_mb_mode;
932
112k
            i4_tx_size_q1 =
933
112k
                (i1_mb_mode_q1 <= SVC_INTER_MB)
934
112k
                    ? ((ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1
935
103k
                                                              : ps_inter_lyr_mb_prms->i1_tx_size)
936
112k
                    : 1;
937
112k
        }
938
939
112k
        if(i4_mb_quard1_part_y > 0)
940
112k
        {
941
112k
            pi1_ref_mb_modes_incr_temp =
942
112k
                pi1_ref_mb_modes_incr + (i4_ref_mode_stride * i4_element_size);
943
112k
            ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
944
112k
            i1_mb_mode_q2 = ps_inter_lyr_mb_prms->i1_mb_mode;
945
112k
            i4_tx_size_q2 =
946
112k
                (i1_mb_mode_q2 <= SVC_INTER_MB)
947
112k
                    ? ((ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1
948
103k
                                                              : ps_inter_lyr_mb_prms->i1_tx_size)
949
112k
                    : 1;
950
112k
        }
951
952
112k
        if((i4_mb_quard1_part_x > 0) && (i4_mb_quard1_part_y > 0))
953
112k
        {
954
112k
            pi1_ref_mb_modes_incr_temp =
955
112k
                pi1_ref_mb_modes_incr + (i4_ref_mode_stride * i4_element_size) + i4_element_size;
956
112k
            ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
957
112k
            i1_mb_mode_q3 = ps_inter_lyr_mb_prms->i1_mb_mode;
958
112k
            i4_tx_size_q3 =
959
112k
                (i1_mb_mode_q3 <= SVC_INTER_MB)
960
112k
                    ? ((ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1
961
105k
                                                              : ps_inter_lyr_mb_prms->i1_tx_size)
962
112k
                    : 1;
963
112k
        }
964
965
112k
        do
966
451k
        {
967
451k
            WORD32 i4_idx;
968
451k
            WORD32 i4_wd, i4_ht;
969
451k
            WORD32 i4_max_pos_x, i4_max_pos_y;
970
971
451k
            i4_prev_x = i4_x;
972
451k
            i4_x_ref = i4_x_offset + i4_x;
973
451k
            i4_y_ref = i4_y_offset + i4_y;
974
451k
            i4_tx_size = i4_tx_size_q0;
975
451k
            if(i4_x >= i4_mb_quard1_part_x)
976
148k
            {
977
148k
                if(i4_y < i4_mb_quard1_part_y)
978
85.8k
                {
979
85.8k
                    i4_tx_size = i4_tx_size_q1;
980
85.8k
                }
981
62.2k
                else if(i4_y >= i4_mb_quard1_part_y)
982
62.2k
                {
983
62.2k
                    i4_tx_size = i4_tx_size_q3;
984
62.2k
                }
985
148k
            }
986
302k
            else if(i4_x < i4_mb_quard1_part_x)
987
302k
            {
988
302k
                if(i4_y >= i4_mb_quard1_part_y)
989
127k
                {
990
127k
                    i4_tx_size = i4_tx_size_q2;
991
127k
                }
992
302k
            }
993
994
            /* Get the transform size as 4 or 8 */
995
451k
            i4_trans_size = ((i4_tx_size + 1) << 2);
996
451k
            i4_const_val = i4_trans_size - 1;
997
451k
            i4_and_const = i4_const_val;
998
999
            /* Fill horizontal tx block edges of current reference mb with 0 */
1000
451k
            pu1_incr_x = pu1_ref_x_ptr_incr + i4_x;
1001
451k
            pu1_incr_x += (i4_y * i4_refary_wd);
1002
451k
            i4_ht = (16 - (i4_y_ref & 0xF));
1003
451k
            i4_ht = MIN((i4_act_ary_ht - i4_y), i4_ht);
1004
1005
451k
            i4_x_idx = i4_x;
1006
451k
            i4_pos_x = i4_x_ref & 0xF;
1007
451k
            i4_max_pos_x = 16;
1008
451k
            i4_x += (16 - i4_pos_x);
1009
1010
            /* Get the transform block edge pos */
1011
451k
            i4_idx = (i4_const_val - (i4_pos_x & i4_and_const));
1012
451k
            i4_x_idx += i4_idx;
1013
1014
1.09M
            while((i4_pos_x < i4_max_pos_x) && (i4_x_idx < i4_act_ary_wd))
1015
642k
            {
1016
642k
                WORD32 i4_i;
1017
642k
                UWORD8 *pu1_incr;
1018
1019
642k
                pu1_incr = pu1_incr_x + i4_idx;
1020
4.56M
                for(i4_i = 0; i4_i < i4_ht; i4_i++)
1021
3.92M
                {
1022
                    /* Fill the block edge with 0s */
1023
3.92M
                    *pu1_incr = 0;
1024
3.92M
                    pu1_incr += i4_refary_wd;
1025
3.92M
                }
1026
1027
                /* Updates */
1028
642k
                i4_pos_x += i4_trans_size;
1029
642k
                pu1_incr_x += i4_trans_size;
1030
642k
                i4_x_idx += MIN(i4_trans_size, (i4_act_ary_wd - i4_x_idx));
1031
642k
            }
1032
1033
            /* Fill vertical tx block edges of current reference mb with 0 */
1034
451k
            pu1_incr_y = pu1_ref_y_ptr_incr + i4_prev_x;
1035
451k
            pu1_incr_y += (i4_y * i4_refary_wd);
1036
451k
            i4_wd = (16 - (i4_x_ref & 0xF));
1037
451k
            i4_wd = MIN((i4_act_ary_wd - i4_prev_x), i4_wd);
1038
451k
            i4_y_idx = i4_y;
1039
451k
            i4_pos_y = i4_y_ref & 0xF;
1040
451k
            i4_max_pos_y = 16;
1041
451k
            i4_y += (16 - i4_pos_y);
1042
1043
            /* Get the transform block edge pos */
1044
451k
            i4_idx = (i4_const_val - (i4_pos_y & i4_and_const));
1045
451k
            i4_y_idx += i4_idx;
1046
1047
1.06M
            while((i4_pos_y < i4_max_pos_y) && (i4_y_idx < i4_act_ary_ht))
1048
610k
            {
1049
610k
                WORD32 i4_i;
1050
610k
                UWORD8 *pu1_incr;
1051
1052
610k
                pu1_incr = pu1_incr_y + i4_idx * i4_refary_wd;
1053
4.49M
                for(i4_i = 0; i4_i < i4_wd; i4_i++)
1054
3.88M
                {
1055
                    /* Fill the block edge with 0s */
1056
3.88M
                    *pu1_incr = 0;
1057
3.88M
                    pu1_incr++;
1058
3.88M
                }
1059
1060
                /* Updates */
1061
610k
                i4_pos_y += i4_trans_size;
1062
610k
                pu1_incr_y += i4_trans_size * i4_refary_wd;
1063
610k
                i4_y_idx += MIN(i4_trans_size, (i4_act_ary_ht - i4_y_idx));
1064
610k
            }
1065
1066
            /* Loop updates */
1067
451k
            if(i4_x < i4_act_ary_wd)
1068
225k
            {
1069
225k
                i4_y = i4_prev_y;
1070
225k
            }
1071
225k
            else if(i4_y < i4_act_ary_ht)
1072
112k
            {
1073
112k
                i4_prev_y = i4_y;
1074
112k
                i4_x = 0;
1075
112k
            }
1076
1077
451k
        } while((i4_y < i4_act_ary_ht) || (i4_x < i4_act_ary_wd));
1078
1079
112k
    } /* End of if 0 == i4_chroma_flag */
1080
225k
    else
1081
225k
    {
1082
        /* Set the transform size as 4 */
1083
225k
        i4_trans_size = 4;
1084
225k
        i4_const_val = 3;
1085
1086
225k
        do
1087
902k
        {
1088
902k
            WORD32 i4_x_ref, i4_y_ref;
1089
902k
            WORD32 i4_idx;
1090
902k
            WORD32 i4_wd, i4_ht;
1091
902k
            WORD32 i4_max_pos_x, i4_max_pos_y;
1092
1093
902k
            i4_prev_x = i4_x;
1094
902k
            i4_x_ref = i4_x_offset + i4_x;
1095
902k
            i4_y_ref = i4_y_offset + i4_y;
1096
1097
            /* Fill horizontal tx block edges of current reference mb with 0 */
1098
902k
            pu1_incr_x = pu1_ref_x_ptr_incr + i4_x;
1099
902k
            pu1_incr_x += (i4_y * i4_refary_wd);
1100
902k
            i4_ht = (8 - (i4_y_ref & 0x7));
1101
902k
            i4_ht = MIN((i4_act_ary_ht - i4_y), i4_ht);
1102
902k
            i4_x_idx = i4_x;
1103
902k
            i4_pos_x = i4_x_ref & 0x7;
1104
902k
            i4_max_pos_x = 8;
1105
902k
            i4_x += (8 - i4_pos_x);
1106
1107
            /* Get the transform block edge pos */
1108
902k
            i4_idx = (i4_const_val - (i4_pos_x & 0x3));
1109
902k
            i4_x_idx += i4_idx;
1110
1111
1.64M
            while((i4_pos_x < i4_max_pos_x) && (i4_x_idx < i4_act_ary_wd))
1112
745k
            {
1113
745k
                WORD32 i4_i;
1114
745k
                UWORD8 *pu1_incr;
1115
1116
745k
                pu1_incr = pu1_incr_x + i4_idx;
1117
3.22M
                for(i4_i = 0; i4_i < i4_ht; i4_i++)
1118
2.47M
                {
1119
                    /* Fill the block edge with 0s */
1120
2.47M
                    *pu1_incr = 0;
1121
2.47M
                    pu1_incr += i4_refary_wd;
1122
2.47M
                }
1123
1124
                /* Updates */
1125
745k
                i4_pos_x += i4_trans_size;
1126
745k
                pu1_incr_x += i4_trans_size;
1127
745k
                i4_x_idx += MIN(i4_trans_size, (i4_act_ary_wd - i4_x_idx));
1128
745k
            }
1129
1130
            /* Fill vertical tx block edges of current reference mb with 0 */
1131
902k
            pu1_incr_y = pu1_ref_y_ptr_incr + i4_prev_x;
1132
902k
            pu1_incr_y += (i4_y * i4_refary_wd);
1133
902k
            i4_wd = (8 - (i4_x_ref & 0x7));
1134
902k
            i4_wd = MIN((i4_act_ary_wd - i4_prev_x), i4_wd);
1135
902k
            i4_y_idx = i4_y;
1136
902k
            i4_pos_y = i4_y_ref & 0x7;
1137
902k
            i4_max_pos_y = 8;
1138
902k
            i4_y += (8 - i4_pos_y);
1139
1140
            /* Get the transform block edge pos */
1141
902k
            i4_idx = (i4_const_val - (i4_pos_y & 0x3));
1142
902k
            i4_y_idx += i4_idx;
1143
1144
1.64M
            while((i4_pos_y < i4_max_pos_y) && (i4_y_idx < i4_act_ary_ht))
1145
746k
            {
1146
746k
                WORD32 i4_i;
1147
746k
                UWORD8 *pu1_incr;
1148
1149
746k
                pu1_incr = pu1_incr_y + i4_idx * i4_refary_wd;
1150
3.22M
                for(i4_i = 0; i4_i < i4_wd; i4_i++)
1151
2.48M
                {
1152
                    /* Fill the block edge with 0s */
1153
2.48M
                    *pu1_incr = 0;
1154
2.48M
                    pu1_incr++;
1155
2.48M
                }
1156
1157
                /* Updates */
1158
746k
                i4_pos_y += i4_trans_size;
1159
746k
                pu1_incr_y += i4_trans_size * i4_refary_wd;
1160
746k
                i4_y_idx += MIN(i4_trans_size, (i4_act_ary_ht - i4_y_idx));
1161
746k
            }
1162
1163
            /* Loop updates */
1164
902k
            if(i4_x < i4_act_ary_wd)
1165
451k
            {
1166
451k
                i4_y = i4_prev_y;
1167
451k
            }
1168
451k
            else if(i4_y < i4_act_ary_ht)
1169
225k
            {
1170
225k
                i4_prev_y = i4_y;
1171
225k
                i4_x = 0;
1172
225k
            }
1173
1174
902k
        } while((i4_y < i4_act_ary_ht) || (i4_x < i4_act_ary_wd));
1175
1176
225k
    } /* End of chroma */
1177
338k
    return OK;
1178
1179
338k
} /* End of "isvcd_ref_layer_ptr_incr" */
1180
1181
void isvcd_residual_reflayer_const_non_boundary_mb(
1182
    WORD16 *pi2_inp_data, WORD32 i4_inp_data_stride, WORD16 *pi2_ref_array, WORD32 i4_refarray_wd,
1183
    WORD32 i4_refarray_ht, WORD32 i4_ref_mb_type_q0, WORD32 i4_ref_mb_type_q1,
1184
    WORD32 i4_ref_mb_type_q2, WORD32 i4_ref_mb_type_q3, WORD32 i4_mb_quard1_part_x,
1185
    WORD32 i4_mb_quard1_part_y, WORD32 i4_chroma_flag)
1186
52.1k
{
1187
52.1k
    WORD32 i4_x_ref, i4_y_ref;
1188
52.1k
    WORD32 i4_x, i4_y;
1189
52.1k
    WORD32 i4_ref_mb_type;
1190
52.1k
    WORD16 *pi2_ref_data_byte;
1191
52.1k
    WORD16 *pi2_ref_array_temp;
1192
1193
488k
    for(i4_y = 0; i4_y < i4_refarray_ht; i4_y++)
1194
436k
    {
1195
4.30M
        for(i4_x = 0; i4_x < i4_refarray_wd; i4_x++)
1196
3.86M
        {
1197
3.86M
            i4_y_ref = i4_y;
1198
3.86M
            i4_x_ref = i4_x;
1199
1200
3.86M
            i4_ref_mb_type = i4_ref_mb_type_q0;
1201
3.86M
            if(i4_x >= i4_mb_quard1_part_x)
1202
1.93M
            {
1203
1.93M
                if(i4_y < i4_mb_quard1_part_y)
1204
993k
                {
1205
993k
                    i4_ref_mb_type = i4_ref_mb_type_q1;
1206
993k
                }
1207
940k
                else if(i4_y >= i4_mb_quard1_part_y)
1208
940k
                {
1209
940k
                    i4_ref_mb_type = i4_ref_mb_type_q3;
1210
940k
                }
1211
1.93M
            }
1212
1.93M
            else if(i4_x < i4_mb_quard1_part_x)
1213
1.93M
            {
1214
1.93M
                if(i4_y >= i4_mb_quard1_part_y)
1215
940k
                {
1216
940k
                    i4_ref_mb_type = i4_ref_mb_type_q2;
1217
940k
                }
1218
1.93M
            }
1219
1220
            /****************************************************************/
1221
            /* Reference layer Residual Buffer is maintained as 8-bit data  */
1222
            /* Buffer and 1-bit sign bit packed buffer. Sign Byte is read   */
1223
            /* and sign of the data sample is extracted depending upon bit  */
1224
            /* postition.                                                   */
1225
            /****************************************************************/
1226
1227
            /* update the buffer pointers to appropriate locations */
1228
3.86M
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1229
3.86M
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1230
1231
            /* extract the residual value and fill the buffer */
1232
3.86M
            if(SVC_INTER_MB == i4_ref_mb_type)
1233
3.39M
            {
1234
                /* derive the reference data pointers */
1235
3.39M
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1236
3.39M
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1237
1238
                /* store the residual value */
1239
3.39M
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1240
3.39M
            }
1241
469k
            else
1242
469k
            {
1243
                /* if non inter MB then store the 0 */
1244
469k
                *pi2_ref_array_temp = 0;
1245
469k
            }
1246
3.86M
        }
1247
436k
    }
1248
52.1k
}
1249
1250
void isvcd_residual_reflayer_const_boundary_mb(WORD16 *pi2_inp_data, WORD32 i4_inp_data_stride,
1251
                                               WORD16 *pi2_ref_array, WORD32 i4_refarray_wd,
1252
                                               WORD32 i4_refarray_ht, WORD32 i4_ref_wd,
1253
                                               WORD32 i4_ref_ht, WORD32 i4_x_offset,
1254
                                               WORD32 i4_y_offset, WORD32 i4_ref_mb_type_q0,
1255
                                               WORD32 i4_ref_mb_type_q1, WORD32 i4_ref_mb_type_q2,
1256
                                               WORD32 i4_ref_mb_type_q3, WORD32 i4_mb_quard1_part_x,
1257
                                               WORD32 i4_mb_quard1_part_y, WORD32 i4_chroma_flag)
1258
246k
{
1259
246k
    WORD32 i4_x_ref, i4_y_ref;
1260
246k
    WORD32 i4_x, i4_y;
1261
246k
    WORD16 *pi2_ref_data_byte;
1262
246k
    WORD16 *pi2_ref_array_temp;
1263
1264
    /*Quard 0*/
1265
1.69M
    for(i4_y = 0; i4_y < i4_mb_quard1_part_y; i4_y++)
1266
1.45M
    {
1267
14.8M
        for(i4_x = 0; i4_x < i4_mb_quard1_part_x; i4_x++)
1268
13.4M
        {
1269
13.4M
            i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, i4_y + i4_y_offset));
1270
13.4M
            i4_x_ref = MAX(0, MIN(i4_ref_wd - 1, i4_x + i4_x_offset));
1271
1272
            /****************************************************************/
1273
            /* Reference layer Residual Buffer is maintained as 8-bit data  */
1274
            /* Buffer and 1-bit sign bit packed buffer. Sign Byte is read   */
1275
            /* and sign of the data sample is extracted depending upon bit  */
1276
            /* postition.                                                   */
1277
            /****************************************************************/
1278
1279
            /* update the buffer pointers to appropriate locations */
1280
13.4M
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1281
13.4M
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1282
1283
            /* extract the residual value and fill the buffer */
1284
13.4M
            if(SVC_INTER_MB == i4_ref_mb_type_q0)
1285
12.8M
            {
1286
                /* input pointer will be pointing to (xoffset,yoffset) */
1287
                /* So subtract the correction to reference location    */
1288
12.8M
                if(0 <= i4_x_offset)
1289
5.60M
                {
1290
                    /* if only inside frame dimension */
1291
5.60M
                    i4_x_ref = i4_x_ref - i4_x_offset;
1292
5.60M
                }
1293
1294
12.8M
                if(0 <= i4_y_offset)
1295
8.23M
                {
1296
                    /* if only inside frame dimension */
1297
8.23M
                    i4_y_ref = i4_y_ref - i4_y_offset;
1298
8.23M
                }
1299
                /* derive the reference data pointers */
1300
1301
12.8M
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1302
12.8M
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1303
1304
                /* store the residual value */
1305
12.8M
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1306
12.8M
            }
1307
523k
            else
1308
523k
            {
1309
                /* if non inter MB then store the 0 */
1310
523k
                *pi2_ref_array_temp = 0;
1311
523k
            }
1312
13.4M
        }
1313
1.45M
    }
1314
1315
    /*Quard 1*/
1316
1.69M
    for(i4_y = 0; i4_y < i4_mb_quard1_part_y; i4_y++)
1317
1.45M
    {
1318
3.15M
        for(i4_x = i4_mb_quard1_part_x; i4_x < i4_refarray_wd; i4_x++)
1319
1.69M
        {
1320
1.69M
            i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, i4_y + i4_y_offset));
1321
1.69M
            i4_x_ref = MAX(0, MIN(i4_ref_wd - 1, i4_x + i4_x_offset));
1322
1323
            /****************************************************************/
1324
            /* Reference layer Residual Buffer is maintained as 8-bit data  */
1325
            /* Buffer and 1-bit sign bit packed buffer. Sign Byte is read   */
1326
            /* and sign of the data sample is extracted depending upon bit  */
1327
            /* postition.                                                   */
1328
            /****************************************************************/
1329
1330
            /* update the buffer pointers to appropriate locations */
1331
1.69M
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1332
1.69M
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1333
1334
            /* extract the residual value and fill the buffer */
1335
1.69M
            if(SVC_INTER_MB == i4_ref_mb_type_q1)
1336
1.56M
            {
1337
                /* input pointer will be pointing to (xoffset,yoffset) */
1338
                /* So subtract the correction to reference location    */
1339
1.56M
                if(0 <= i4_x_offset)
1340
1.56M
                {
1341
                    /* if only inside frame dimension */
1342
1.56M
                    i4_x_ref = i4_x_ref - i4_x_offset;
1343
1.56M
                }
1344
1.56M
                if(0 <= i4_y_offset)
1345
604k
                {
1346
                    /* if only inside frame dimension */
1347
604k
                    i4_y_ref = i4_y_ref - i4_y_offset;
1348
604k
                }
1349
                /* derive the reference data pointers */
1350
1351
1.56M
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1352
1.56M
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1353
1354
                /* store the residual value */
1355
1.56M
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1356
1.56M
            }
1357
131k
            else
1358
131k
            {
1359
                /* if non inter MB then store the 0 */
1360
131k
                *pi2_ref_array_temp = 0;
1361
131k
            }
1362
1.69M
        }
1363
1.45M
    }
1364
1365
    /*Quard 2*/
1366
985k
    for(i4_y = i4_mb_quard1_part_y; i4_y < i4_refarray_ht; i4_y++)
1367
739k
    {
1368
8.20M
        for(i4_x = 0; i4_x < i4_mb_quard1_part_x; i4_x++)
1369
7.46M
        {
1370
7.46M
            i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, i4_y + i4_y_offset));
1371
7.46M
            i4_x_ref = MAX(0, MIN(i4_ref_wd - 1, i4_x + i4_x_offset));
1372
1373
            /****************************************************************/
1374
            /* Reference layer Residual Buffer is maintained as 8-bit data  */
1375
            /* Buffer and 1-bit sign bit packed buffer. Sign Byte is read   */
1376
            /* and sign of the data sample is extracted depending upon bit  */
1377
            /* postition.                                                   */
1378
            /****************************************************************/
1379
1380
            /* update the buffer pointers to appropriate locations */
1381
7.46M
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1382
7.46M
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1383
1384
            /* extract the residual value and fill the buffer */
1385
7.46M
            if(SVC_INTER_MB == i4_ref_mb_type_q2)
1386
7.07M
            {
1387
                /* input pointer will be pointing to (xoffset,yoffset) */
1388
                /* So subtract the correction to reference location    */
1389
7.07M
                if(0 <= i4_x_offset)
1390
2.77M
                {
1391
                    /* if only inside frame dimension */
1392
2.77M
                    i4_x_ref = i4_x_ref - i4_x_offset;
1393
2.77M
                }
1394
7.07M
                if(0 <= i4_y_offset)
1395
7.07M
                {
1396
                    /* if only inside frame dimension */
1397
7.07M
                    i4_y_ref = i4_y_ref - i4_y_offset;
1398
7.07M
                }
1399
                /* derive the reference data pointers */
1400
7.07M
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1401
7.07M
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1402
1403
                /* store the residual value */
1404
7.07M
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1405
7.07M
            }
1406
393k
            else
1407
393k
            {
1408
                /* if non inter MB then store the 0 */
1409
393k
                *pi2_ref_array_temp = 0;
1410
393k
            }
1411
7.46M
        }
1412
739k
    }
1413
1414
    /*Quard 3*/
1415
985k
    for(i4_y = i4_mb_quard1_part_y; i4_y < i4_refarray_ht; i4_y++)
1416
739k
    {
1417
1.11M
        for(i4_x = i4_mb_quard1_part_x; i4_x < i4_refarray_wd; i4_x++)
1418
379k
        {
1419
379k
            i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, i4_y + i4_y_offset));
1420
379k
            i4_x_ref = MAX(0, MIN(i4_ref_wd - 1, i4_x + i4_x_offset));
1421
1422
            /****************************************************************/
1423
            /* Reference layer Residual Buffer is maintained as 8-bit data  */
1424
            /* Buffer and 1-bit sign bit packed buffer. Sign Byte is read   */
1425
            /* and sign of the data sample is extracted depending upon bit  */
1426
            /* postition.                                                   */
1427
            /****************************************************************/
1428
1429
            /* update the buffer pointers to appropriate locations */
1430
379k
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1431
379k
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1432
1433
            /* extract the residual value and fill the buffer */
1434
379k
            if(SVC_INTER_MB == i4_ref_mb_type_q3)
1435
379k
            {
1436
                /* input pointer will be pointing to (xoffset,yoffset) */
1437
                /* So subtract the correction to reference location    */
1438
379k
                if(0 <= i4_x_offset)
1439
379k
                {
1440
                    /* if only inside frame dimension */
1441
379k
                    i4_x_ref = i4_x_ref - i4_x_offset;
1442
379k
                }
1443
379k
                if(0 <= i4_y_offset)
1444
379k
                {
1445
                    /* if only inside frame dimension */
1446
379k
                    i4_y_ref = i4_y_ref - i4_y_offset;
1447
379k
                }
1448
                /* derive the reference data pointers */
1449
379k
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1450
379k
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1451
1452
                /* store the residual value */
1453
379k
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1454
379k
            }
1455
0
            else
1456
0
            {
1457
                /* if non inter MB then store the 0 */
1458
0
                *pi2_ref_array_temp = 0;
1459
0
            }
1460
379k
        }
1461
739k
    }
1462
246k
}
1463
1464
/*****************************************************************************/
1465
/*                                                                           */
1466
/*  Function Name : isvcd_residual_reflayer_const                             */
1467
/*                                                                           */
1468
/*  Description   :  This function constructs the reference array buffer     */
1469
/*                    used for residual resampling of a component in an MB   */
1470
/*                                                                           */
1471
/*  Inputs        : pv_residual_samp_ctxt: intra sampling context            */
1472
/*                  pu1_inp : input (reference layer data)                   */
1473
/*                  i4_inp_stride : input buffer stride                      */
1474
/*                  pu1_inp_bitmap : input (reference layer sign bits)       */
1475
/*                  i4_inp_stride : input buffer stride                      */
1476
/*                  ps_ref_mb_mode : ref layer mb mode buffer desc           */
1477
/*                  pi4_refarr_wd : pointer to store the reference array WD  */
1478
/*                  pi4_refarr_ht : pointer to store the reference array HT  */
1479
/*                  pi4_x_offset : pointer to store the reference X offset   */
1480
/*                  pi4_y_offset : pointer to store the reference Y offset   */
1481
/*                  ps_coord     : mb co-ordinate structure                  */
1482
/*                  i4_chroma_flag : chroma processing flag                  */
1483
/*  Globals       : none                                                     */
1484
/*  Processing    : it fills the reference layer data if they are falling in */
1485
/*                  INTRA MB region. If all the pixels are not filled  it    */
1486
/*                  calls the border extension algorithm to fill them        */
1487
/*  Outputs       : none                                                     */
1488
/*  Returns       : none                                                     */
1489
/*                                                                           */
1490
/*  Issues        : none                                                     */
1491
/*                                                                           */
1492
/*  Revision History:                                                        */
1493
/*                                                                           */
1494
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1495
/*         06 07 2021   vijayakumar          creation                        */
1496
/*                                                                           */
1497
/*****************************************************************************/
1498
WORD32 isvcd_residual_reflayer_const(void *pv_residual_samp_ctxt, WORD16 *pi2_inp_data,
1499
                                     WORD32 i4_inp_data_stride, mem_element_t *ps_ref_mb_mode,
1500
                                     WORD32 *pi4_refarr_wd, mb_coord_t *ps_coord,
1501
                                     WORD32 i4_chroma_flag)
1502
338k
{
1503
338k
    residual_sampling_ctxt_t *ps_ctxt;
1504
338k
    res_lyr_ctxt *ps_lyr_ctxt;
1505
338k
    WORD8 *pi1_ref_mb_modes;
1506
338k
    WORD32 i4_ref_mode_stride;
1507
338k
    WORD32 i4_element_size;
1508
338k
    WORD32 i4_ref_wd;
1509
338k
    WORD32 i4_ref_ht;
1510
338k
    WORD32 i4_x_offset;
1511
338k
    WORD32 i4_y_offset;
1512
338k
    WORD32 i4_refarray_wd;
1513
338k
    WORD32 i4_refarray_ht;
1514
338k
    WORD8 i1_edge_mb;
1515
338k
    WORD16 *pi2_ref_array;
1516
338k
    WORD32 i4_mb_sft;
1517
338k
    WORD32 i4_mb_x, i4_mb_y;
1518
338k
    WORD32 i4_mb_x_strt, i4_mb_y_strt;
1519
338k
    WORD32 i4_mb_quard1_part_x, i4_mb_quard1_part_y;
1520
338k
    WORD8 *pi1_ref_mb_modes_incr;
1521
338k
    WORD8 *pi1_ref_mb_modes_incr_temp;
1522
338k
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
1523
1524
338k
    WORD32 i4_mb_wd;
1525
338k
    WORD32 i4_mb_ht;
1526
338k
    WORD32 i4_x_ref, i4_y_ref;
1527
338k
    WORD32 i4_ref_mb_type_q0, i4_ref_mb_type_q1, i4_ref_mb_type_q2, i4_ref_mb_type_q3;
1528
338k
    WORD8 i1_mb_mode_q0, i1_mb_mode_q1, i1_mb_mode_q2, i1_mb_mode_q3;
1529
338k
    WORD32 ret;
1530
1531
338k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
1532
338k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1533
338k
    pi2_ref_array = ps_ctxt->pi2_refarray_buffer;
1534
1535
338k
    pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode->pv_buffer;
1536
338k
    i4_ref_mode_stride = ps_ref_mb_mode->i4_num_element_stride;
1537
338k
    i4_element_size = ps_ref_mb_mode->i4_element_size;
1538
1539
338k
    if(NULL == pi1_ref_mb_modes)
1540
0
    {
1541
0
        return NOT_OK;
1542
0
    }
1543
1544
338k
    i4_mb_wd = MB_WIDTH >> i4_chroma_flag;
1545
338k
    i4_mb_ht = MB_HEIGHT >> i4_chroma_flag;
1546
1547
    /* ----------------------------------------------------------------- */
1548
    /* Deriving the parameters required for further processing           */
1549
    /* ----------------------------------------------------------------- */
1550
338k
    {
1551
338k
        ref_mb_map_t *ps_x_off_len;
1552
338k
        ref_mb_map_t *ps_y_off_len;
1553
338k
        WORD32 i4_mbaddr_x;
1554
338k
        WORD32 i4_mbaddr_y;
1555
338k
        WORD32 i4_base_width;
1556
338k
        WORD32 i4_base_height;
1557
338k
        residual_samp_map_ctxt_t *ps_map_ctxt;
1558
1559
338k
        if(1 == i4_chroma_flag)
1560
225k
            ps_map_ctxt = &ps_lyr_ctxt->s_chroma_map_ctxt;
1561
112k
        else
1562
112k
            ps_map_ctxt = &ps_lyr_ctxt->s_luma_map_ctxt;
1563
1564
338k
        i4_mbaddr_y = ps_coord->u2_mb_y;
1565
338k
        i4_mbaddr_x = ps_coord->u2_mb_x;
1566
338k
        i4_base_width = ps_lyr_ctxt->i4_ref_width;
1567
338k
        i4_base_height = ps_lyr_ctxt->i4_ref_height;
1568
338k
        i4_ref_wd = i4_base_width >> i4_chroma_flag;
1569
338k
        i4_ref_ht = i4_base_height >> i4_chroma_flag;
1570
1571
        /* --------------------------------------------------------------------- */
1572
        /* Extracting information from the mapping context                       */
1573
        /* --------------------------------------------------------------------- */
1574
338k
        ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
1575
338k
        ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
1576
338k
        i4_x_offset = ps_x_off_len[i4_mbaddr_x].i2_offset;
1577
338k
        i4_y_offset = ps_y_off_len[i4_mbaddr_y].i2_offset;
1578
338k
        i4_refarray_wd = ps_x_off_len[i4_mbaddr_x].i2_length;
1579
338k
        i4_refarray_ht = ps_y_off_len[i4_mbaddr_y].i2_length;
1580
338k
    }
1581
1582
    /* Call the module to fill the increments based on transform blocks */
1583
338k
    ret = isvcd_ref_layer_ptr_incr(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
1584
338k
                                   i4_x_offset, i4_y_offset, i4_refarray_wd, i4_refarray_ht,
1585
338k
                                   ps_ctxt->pu1_ref_x_ptr_incr, ps_ctxt->pu1_ref_y_ptr_incr,
1586
338k
                                   i4_chroma_flag);
1587
1588
338k
    if(ret != OK)
1589
0
    {
1590
0
        return ret;
1591
0
    }
1592
338k
    i4_mb_sft = (MB_WIDTH_SHIFT - i4_chroma_flag);
1593
1594
    /* --------------------------------------------------------------------- */
1595
    /* MB Level Resampling for the MB - Pointers sent for MB in both layers  */
1596
    /* This has been written according to the dyadic case                    */
1597
    /* --------------------------------------------------------------------- */
1598
338k
    i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, 0 + i4_y_offset));
1599
338k
    i4_x_ref = MAX(0, MIN(i4_ref_wd - 1, 0 + i4_x_offset));
1600
338k
    i4_mb_x_strt = i4_x_ref % i4_mb_wd;
1601
338k
    i4_mb_y_strt = i4_y_ref % i4_mb_ht;
1602
1603
338k
    i4_mb_quard1_part_x = i4_mb_wd - i4_mb_x_strt;
1604
338k
    i4_mb_quard1_part_y = i4_mb_ht - i4_mb_y_strt;
1605
338k
    if(!(i4_mb_quard1_part_x >= 0))
1606
0
    {
1607
0
        return NOT_OK;
1608
0
    }
1609
338k
    if(!(i4_mb_quard1_part_y >= 0))
1610
0
    {
1611
0
        return NOT_OK;
1612
0
    }
1613
1614
338k
    i4_mb_x = (i4_x_ref >> i4_mb_sft);
1615
338k
    i4_mb_y = (i4_y_ref >> i4_mb_sft);
1616
1617
    /* get the location of the byte which has the current mb mode */
1618
338k
    pi1_ref_mb_modes_incr = pi1_ref_mb_modes + (i4_mb_y * i4_ref_mode_stride * i4_element_size);
1619
338k
    pi1_ref_mb_modes_incr += (i4_mb_x * i4_element_size);
1620
338k
    ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr;
1621
338k
    i1_mb_mode_q0 = ps_inter_lyr_mb_prms->i1_mb_mode;
1622
338k
    i1_mb_mode_q1 = i1_mb_mode_q0;
1623
338k
    i1_mb_mode_q2 = i1_mb_mode_q0;
1624
338k
    i1_mb_mode_q3 = i1_mb_mode_q0;
1625
1626
338k
    pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr;
1627
338k
    if(i4_mb_quard1_part_x > 0)
1628
338k
    {
1629
338k
        pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr + i4_element_size;
1630
338k
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
1631
338k
        i1_mb_mode_q1 = ps_inter_lyr_mb_prms->i1_mb_mode;
1632
338k
    }
1633
1634
338k
    if(i4_mb_quard1_part_y > 0)
1635
338k
    {
1636
338k
        pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr + (i4_ref_mode_stride * i4_element_size);
1637
338k
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
1638
338k
        i1_mb_mode_q2 = ps_inter_lyr_mb_prms->i1_mb_mode;
1639
338k
    }
1640
1641
338k
    if((i4_mb_quard1_part_x > 0) && (i4_mb_quard1_part_y > 0))
1642
338k
    {
1643
338k
        pi1_ref_mb_modes_incr_temp =
1644
338k
            pi1_ref_mb_modes_incr + (i4_ref_mode_stride * i4_element_size) + i4_element_size;
1645
338k
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
1646
338k
        i1_mb_mode_q3 = ps_inter_lyr_mb_prms->i1_mb_mode;
1647
338k
    }
1648
1649
338k
    i4_ref_mb_type_q0 = (i1_mb_mode_q0 <= SVC_INTER_MB) ? SVC_INTER_MB : SVC_INTRA_MB;
1650
338k
    i4_ref_mb_type_q1 = (i1_mb_mode_q1 <= SVC_INTER_MB) ? SVC_INTER_MB : SVC_INTRA_MB;
1651
338k
    i4_ref_mb_type_q2 = (i1_mb_mode_q2 <= SVC_INTER_MB) ? SVC_INTER_MB : SVC_INTRA_MB;
1652
338k
    i4_ref_mb_type_q3 = (i1_mb_mode_q3 <= SVC_INTER_MB) ? SVC_INTER_MB : SVC_INTRA_MB;
1653
1654
338k
    i1_edge_mb = (ps_coord->u2_mb_x == 0 || ps_coord->u2_mb_y == 0 ||
1655
186k
                  (ps_coord->u2_mb_x == ((ps_lyr_ctxt->i4_curr_width >> MB_WIDTH_SHIFT) - 1)) ||
1656
99.4k
                  (ps_coord->u2_mb_y == ((ps_lyr_ctxt->i4_curr_height >> MB_HEIGHT_SHIFT) - 1)));
1657
338k
    if(i1_edge_mb)
1658
246k
    {
1659
246k
        ps_ctxt->pf_residual_reflayer_const_boundary_mb(
1660
246k
            pi2_inp_data, i4_inp_data_stride, pi2_ref_array, i4_refarray_wd, i4_refarray_ht,
1661
246k
            i4_ref_wd, i4_ref_ht, i4_x_offset, i4_y_offset, i4_ref_mb_type_q0, i4_ref_mb_type_q1,
1662
246k
            i4_ref_mb_type_q2, i4_ref_mb_type_q3, i4_mb_quard1_part_x, i4_mb_quard1_part_y,
1663
246k
            i4_chroma_flag);
1664
246k
    }
1665
92.0k
    else
1666
92.0k
    {
1667
92.0k
        ps_ctxt->pf_residual_reflayer_const_non_boundary_mb(
1668
92.0k
            pi2_inp_data, i4_inp_data_stride, pi2_ref_array, i4_refarray_wd, i4_refarray_ht,
1669
92.0k
            i4_ref_mb_type_q0, i4_ref_mb_type_q1, i4_ref_mb_type_q2, i4_ref_mb_type_q3,
1670
92.0k
            i4_mb_quard1_part_x, i4_mb_quard1_part_y, i4_chroma_flag);
1671
92.0k
    }
1672
    /* store the values into the place holders */
1673
338k
    *pi4_refarr_wd = i4_refarray_wd;
1674
1675
338k
    return OK;
1676
338k
}
1677
1678
/*****************************************************************************/
1679
/*                                                                           */
1680
/*  Function Name : isvcd_interpolate_residual                                */
1681
/*                                                                           */
1682
/*  Description   : This function takes the refernce array buffer and perform*/
1683
/*                    interpolation of a component to find the residual      */
1684
/*                     resampled value                                       */
1685
/*  Inputs        : pv_residual_samp_ctxt : residual sampling context        */
1686
/*                  pi2_out : output buffer pointer                          */
1687
/*                  i4_out_stride : output buffer stride                     */
1688
/*                  i4_refarray_wd : reference array width                   */
1689
/*                  i4_x_offset : offset in reference layer in horz direction*/
1690
/*                  ps_coord : current mb co-ordinate                        */
1691
/*                  i4_chroma_flag : chroma processing flag                  */
1692
/*  Globals       : none                                                     */
1693
/*  Processing    : it does the interpolation in vertical direction followed */
1694
/*                  by horizontal direction                                  */
1695
/*  Outputs       : resampled pixels                                         */
1696
/*  Returns       : none                                                     */
1697
/*                                                                           */
1698
/*  Issues        : none                                                     */
1699
/*                                                                           */
1700
/*  Revision History:                                                        */
1701
/*                                                                           */
1702
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1703
/*         06 07 2021   vijayakumar          creation                        */
1704
/*                                                                           */
1705
/*****************************************************************************/
1706
void isvcd_interpolate_residual(void *pv_residual_samp_ctxt, WORD16 *pi2_out, WORD32 i4_out_stride,
1707
                                WORD32 i4_refarray_wd, UWORD16 u2_mb_x, UWORD16 u2_mb_y,
1708
                                WORD32 i4_chroma_flag)
1709
192k
{
1710
192k
    residual_sampling_ctxt_t *ps_ctxt;
1711
192k
    residual_samp_map_ctxt_t *ps_map_ctxt;
1712
192k
    res_lyr_ctxt *ps_lyr_ctxt;
1713
192k
    ref_pixel_map_t *ps_x_pos_phase;
1714
192k
    ref_pixel_map_t *ps_y_pos_phase;
1715
1716
192k
    WORD32 i4_x, i4_y;
1717
192k
    WORD32 i4_frm_mb_x, i4_frm_mb_y;
1718
192k
    WORD32 i4_temp_array_ht;
1719
192k
    WORD32 i4_mb_wd;
1720
192k
    WORD32 i4_mb_ht;
1721
192k
    WORD16 *pi2_ref_array;
1722
192k
    UWORD8 *pu1_ref_x_ptr_incr, *pu1_ref_y_ptr_incr;
1723
1724
192k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
1725
192k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1726
192k
    pi2_ref_array = ps_ctxt->pi2_refarray_buffer;
1727
192k
    pu1_ref_x_ptr_incr = ps_ctxt->pu1_ref_x_ptr_incr;
1728
192k
    pu1_ref_y_ptr_incr = ps_ctxt->pu1_ref_y_ptr_incr;
1729
1730
    /* --------------------------------------------------------------------- */
1731
    /* Extracting information from the mapping context                       */
1732
    /* --------------------------------------------------------------------- */
1733
192k
    if(1 == i4_chroma_flag)
1734
128k
        ps_map_ctxt = &ps_lyr_ctxt->s_chroma_map_ctxt;
1735
64.1k
    else
1736
64.1k
        ps_map_ctxt = &ps_lyr_ctxt->s_luma_map_ctxt;
1737
1738
192k
    i4_mb_wd = MB_WIDTH >> i4_chroma_flag;
1739
192k
    i4_mb_ht = MB_HEIGHT >> i4_chroma_flag;
1740
1741
192k
    ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase;
1742
192k
    ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase;
1743
192k
    i4_temp_array_ht = i4_mb_ht;
1744
192k
    i4_frm_mb_y = u2_mb_y * i4_mb_ht;
1745
192k
    i4_frm_mb_x = u2_mb_x * i4_mb_wd;
1746
1747
    /* --------------------------------------------------------------------- */
1748
    /* Loop for interpolation                                                */
1749
    /* --------------------------------------------------------------------- */
1750
2.24M
    for(i4_y = 0; i4_y < (i4_temp_array_ht); i4_y++)
1751
2.05M
    {
1752
26.6M
        for(i4_x = 0; i4_x < (i4_mb_wd); i4_x++)
1753
24.6M
        {
1754
24.6M
            WORD32 i4_i;
1755
24.6M
            WORD32 i4_y_ref;
1756
24.6M
            WORD32 i4_y_phase;
1757
24.6M
            WORD32 i4_x_ref;
1758
24.6M
            WORD32 i4_x_phase;
1759
24.6M
            WORD32 i4_x_ref_round;
1760
24.6M
            WORD16 *pi2_out_curr;
1761
24.6M
            WORD32 ai4_temp_pred[2] = {0};
1762
24.6M
            UWORD8 *pu1_ref_y_ptr_incr_temp;
1763
24.6M
            WORD32 *pi4_temp_pred;
1764
24.6M
            UWORD8 u1_incr_y;
1765
24.6M
            WORD16 i2_res;
1766
1767
            /* derive the current output pointer */
1768
24.6M
            pi2_out_curr = pi2_out + (i4_x << i4_chroma_flag) + (i4_y * i4_out_stride);
1769
1770
            /* -------------------------------------------------------------- */
1771
            /* Finding the offset                                             */
1772
            /* -------------------------------------------------------------- */
1773
24.6M
            i4_y_ref = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_ref_pos;
1774
24.6M
            i4_y_phase = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_phase;
1775
24.6M
            i4_x_ref = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_ref_pos;
1776
24.6M
            i4_x_phase = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_phase;
1777
1778
            /* horizontal processing*/
1779
73.8M
            for(i4_i = 0; i4_i < 2; i4_i++)
1780
49.2M
            {
1781
49.2M
                UWORD8 *pu1_ref_x_ptr_incr_temp;
1782
49.2M
                UWORD8 u1_incr;
1783
49.2M
                WORD16 *pi2_ref_array_1, *pi2_ref_array_2;
1784
1785
                /* derive appropriate pointers */
1786
49.2M
                pu1_ref_x_ptr_incr_temp = pu1_ref_x_ptr_incr + i4_x_ref;
1787
49.2M
                pu1_ref_x_ptr_incr_temp += ((i4_y_ref + i4_i) * i4_refarray_wd);
1788
49.2M
                u1_incr = *pu1_ref_x_ptr_incr_temp;
1789
49.2M
                pi2_ref_array_1 = pi2_ref_array + i4_x_ref;
1790
49.2M
                pi2_ref_array_1 += ((i4_y_ref + i4_i) * i4_refarray_wd);
1791
1792
49.2M
                if(!u1_incr)
1793
15.9M
                {
1794
15.9M
                    pi2_ref_array_1 += (i4_x_phase >> 3);
1795
15.9M
                }
1796
1797
49.2M
                pi2_ref_array_2 = pi2_ref_array_1 + u1_incr;
1798
49.2M
                ai4_temp_pred[i4_i] =
1799
49.2M
                    (16 - i4_x_phase) * (*pi2_ref_array_1) + i4_x_phase * (*pi2_ref_array_2);
1800
49.2M
            }
1801
1802
            /* vertical processing */
1803
24.6M
            i4_x_ref_round = (i4_x_ref + (i4_x_phase >> 3));
1804
24.6M
            pu1_ref_y_ptr_incr_temp =
1805
24.6M
                pu1_ref_y_ptr_incr + i4_x_ref_round + (i4_y_ref * i4_refarray_wd);
1806
24.6M
            u1_incr_y = *pu1_ref_y_ptr_incr_temp;
1807
1808
24.6M
            pi4_temp_pred = &ai4_temp_pred[0];
1809
24.6M
            if(!u1_incr_y)
1810
7.95M
            {
1811
7.95M
                pi4_temp_pred += (i4_y_phase >> 3);
1812
7.95M
            }
1813
1814
24.6M
            i2_res = (((16 - i4_y_phase) * pi4_temp_pred[0] +
1815
24.6M
                       i4_y_phase * pi4_temp_pred[u1_incr_y] + 128) >>
1816
24.6M
                      8);
1817
1818
            /* store back the final residual */
1819
24.6M
            *pi2_out_curr = i2_res;
1820
24.6M
        } /* end of loop over width */
1821
2.05M
    }     /* end of loop over height */
1822
1823
192k
    return;
1824
192k
} /* End of Interpolation Function */
1825
/*****************************************************************************/
1826
/*                                                                           */
1827
/*  Function Name : isvcd_residual_samp_mb                                    */
1828
/*                                                                           */
1829
/*  Description   : MB level function whcih perform the residual resampling  */
1830
/*                  of data of an MB (luma and chroma insclusive)            */
1831
/*                                                                           */
1832
/*  Inputs        : pv_residual_samp_ctxt : residual sampling context        */
1833
/*                  ps_ref_luma : reference layer luma data buffer desc      */
1834
/*                  ps_ref_chroma : reference layer chroma data buffer desc  */
1835
/*                  ps_ref_luma_bitmap : ref layer luma bit map buffer desc  */
1836
/*                  ps_ref_chroma_bitmap : ref layer chroma bit map buff des */
1837
/*                  ps_ref_mb_mode : ref layer mb mode map buff desc         */
1838
/*                  ps_out_luma : current layer out luma buffer desc         */
1839
/*                  ps_out_chroma : current layer out chroma buffer desc     */
1840
/*                  ps_mb_coord : current mb coorinate                       */
1841
/*  Globals       : none                                                     */
1842
/*  Processing    : it calls the reference layer construction followed by    */
1843
/*                   interplaotion function for luma and cb and cr           */
1844
/*  Outputs       : inter resampled data of current MB                       */
1845
/*  Returns       : none                                                     */
1846
/*                                                                           */
1847
/*  Issues        : none                                                     */
1848
/*                                                                           */
1849
/*  Revision History:                                                        */
1850
/*                                                                           */
1851
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1852
/*         26 06 2021   vijayakumar          creation                        */
1853
/*                                                                           */
1854
/*****************************************************************************/
1855
WORD32 isvcd_residual_samp_mb(void *pv_residual_samp_ctxt, mem_element_t *ps_ref_luma,
1856
                              mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode,
1857
                              mem_element_t *ps_out_luma, mem_element_t *ps_out_chroma,
1858
                              UWORD16 u2_mb_x, UWORD16 u2_mb_y)
1859
112k
{
1860
    /* --------------------------------------------------------------------- */
1861
    /* I/O buffer params                                                     */
1862
    /* --------------------------------------------------------------------- */
1863
112k
    residual_sampling_ctxt_t *ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
1864
112k
    WORD16 *pi2_inp;
1865
112k
    WORD16 *pi2_out;
1866
112k
    WORD32 i4_inp_stride;
1867
112k
    WORD32 i4_out_stride;
1868
112k
    WORD32 i4_refarray_wd;
1869
112k
    mb_coord_t s_mb_coord = {0};
1870
112k
    WORD32 ret;
1871
112k
    s_mb_coord.u2_mb_x = u2_mb_x;
1872
112k
    s_mb_coord.u2_mb_y = u2_mb_y;
1873
1874
    /* --------------------------------------------------------------------- */
1875
    /* LUMA PROCESSING                                                        */
1876
    /* --------------------------------------------------------------------- */
1877
112k
    pi2_inp = (WORD16 *) ps_ref_luma->pv_buffer;
1878
112k
    pi2_out = (WORD16 *) ps_out_luma->pv_buffer;
1879
112k
    i4_inp_stride = ps_ref_luma->i4_num_element_stride;
1880
112k
    i4_out_stride = ps_out_luma->i4_num_element_stride;
1881
1882
    /* ------- Constructing refSampleArray ----------------------- */
1883
112k
    ret = isvcd_residual_reflayer_const(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
1884
112k
                                        ps_ref_mb_mode, &i4_refarray_wd, &s_mb_coord, 0);
1885
1886
112k
    if(ret != OK) return ret;
1887
    /* ---- Interpolation process for Residual prediction     ------ */
1888
112k
    ps_ctxt->pf_interpolate_residual(pv_residual_samp_ctxt, pi2_out, i4_out_stride, i4_refarray_wd,
1889
112k
                                     s_mb_coord.u2_mb_x, s_mb_coord.u2_mb_y, 0);
1890
1891
    /* --------------------------------------------------------------------- */
1892
    /* CHROMA PROCESSING                                                       */
1893
    /* --------------------------------------------------------------------- */
1894
    /* CB */
1895
112k
    pi2_inp = (WORD16 *) ps_ref_chroma->pv_buffer;
1896
112k
    pi2_out = (WORD16 *) ps_out_chroma->pv_buffer;
1897
112k
    i4_inp_stride = ps_ref_chroma->i4_num_element_stride;
1898
112k
    i4_out_stride = ps_out_chroma->i4_num_element_stride;
1899
1900
    /* ------- Constructing refSampleArray ----------------------- */
1901
112k
    ret = isvcd_residual_reflayer_const(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
1902
112k
                                        ps_ref_mb_mode, &i4_refarray_wd, &s_mb_coord, 1);
1903
1904
112k
    if(ret != OK) return ret;
1905
    /* ---- Interpolation process for Residual prediction     ------ */
1906
112k
    ps_ctxt->pf_interpolate_residual(pv_residual_samp_ctxt, pi2_out, i4_out_stride, i4_refarray_wd,
1907
112k
                                     s_mb_coord.u2_mb_x, s_mb_coord.u2_mb_y, 1);
1908
1909
    /* CR */
1910
112k
    pi2_inp += 1;
1911
112k
    pi2_out += 1;
1912
1913
    /* ------- Constructing refSampleArray ----------------------- */
1914
112k
    ret = isvcd_residual_reflayer_const(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
1915
112k
                                        ps_ref_mb_mode, &i4_refarray_wd, &s_mb_coord, 1);
1916
1917
112k
    if(ret != OK) return ret;
1918
    /* ---- Interpolation process for Residual prediction --------- */
1919
112k
    ps_ctxt->pf_interpolate_residual(pv_residual_samp_ctxt, pi2_out, i4_out_stride, i4_refarray_wd,
1920
112k
                                     s_mb_coord.u2_mb_x, s_mb_coord.u2_mb_y, 1);
1921
112k
    return OK;
1922
112k
}
1923
/*****************************************************************************/
1924
/*                                                                           */
1925
/*  Function Name : isvcd_residual_samp_mb_dyadic                             */
1926
/*                                                                           */
1927
/*  Description   : MB level function whcih perform the residual resampling  */
1928
/*                  of data of an MB (luma and chroma insclusive)            */
1929
/*                  for Dyadic cases                                         */
1930
/*  Inputs        : pv_residual_samp_ctxt : residual sampling context        */
1931
/*                  ps_ref_luma : reference layer luma data buffer desc      */
1932
/*                  ps_ref_chroma : reference layer chroma data buffer desc  */
1933
/*                  ps_ref_luma_bitmap : ref layer luma bit map buffer desc  */
1934
/*                  ps_ref_chroma_bitmap : ref layer chroma bit map buff des */
1935
/*                  ps_ref_mb_mode : ref layer mb mode map buff desc         */
1936
/*                  ps_out_luma : current layer out luma buffer desc         */
1937
/*                  ps_out_chroma : current layer out chroma buffer desc     */
1938
/*                  ps_mb_coord : current mb coorinate                       */
1939
/*  Globals       : none                                                     */
1940
/*  Processing    : it calls the reference layer construction followed by    */
1941
/*                   interplaotion function for luma and cb and cr           */
1942
/*  Outputs       : inter resampled data of current MB                       */
1943
/*  Returns       : none                                                     */
1944
/*                                                                           */
1945
/*  Issues        : none                                                     */
1946
/*                                                                           */
1947
/*  Revision History:                                                        */
1948
/*                                                                           */
1949
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
1950
/*         26 06 2021   vijayakumar          creation                        */
1951
/*                                                                           */
1952
/*****************************************************************************/
1953
WORD32 isvcd_residual_samp_mb_dyadic(void *pv_residual_samp_ctxt, mem_element_t *ps_ref_luma,
1954
                                     mem_element_t *ps_ref_chroma, mem_element_t *ps_ref_mb_mode,
1955
                                     mem_element_t *ps_out_luma, mem_element_t *ps_out_chroma,
1956
                                     UWORD16 u2_mb_x, UWORD16 u2_mb_y)
1957
36.4k
{
1958
36.4k
    residual_sampling_ctxt_t *ps_ctxt;
1959
36.4k
    res_lyr_ctxt *ps_lyr_ctxt;
1960
    /* --------------------------------------------------------------------- */
1961
    /* I/O buffer params                                                     */
1962
    /* --------------------------------------------------------------------- */
1963
36.4k
    WORD16 *pi2_inp;
1964
36.4k
    WORD16 *pi2_out;
1965
36.4k
    WORD32 i4_inp_stride;
1966
36.4k
    WORD32 i4_out_stride;
1967
36.4k
    WORD32 i4_luma_nnz;
1968
36.4k
    WORD32 i4_chroma_nnz;
1969
36.4k
    WORD32 i4_tx_size;
1970
1971
36.4k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
1972
36.4k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1973
1974
    /* --------------------------------------------------------------------- */
1975
    /* LUMA PROCESSING                                                        */
1976
    /* --------------------------------------------------------------------- */
1977
36.4k
    pi2_inp = (WORD16 *) ps_ref_luma->pv_buffer;
1978
36.4k
    pi2_out = (WORD16 *) ps_out_luma->pv_buffer;
1979
36.4k
    i4_inp_stride = ps_ref_luma->i4_num_element_stride;
1980
36.4k
    i4_out_stride = ps_out_luma->i4_num_element_stride;
1981
1982
36.4k
    {
1983
36.4k
        WORD32 i4_offset_x, i4_offset_y;
1984
36.4k
        residual_samp_map_ctxt_t *ps_luma_map;
1985
36.4k
        ref_mb_map_t *ps_x_off_len_luma;
1986
36.4k
        ref_mb_map_t *ps_y_off_len_luma;
1987
1988
36.4k
        ps_luma_map = &ps_lyr_ctxt->s_luma_map_ctxt;
1989
36.4k
        ps_x_off_len_luma = ps_luma_map->ps_x_offset_length;
1990
36.4k
        ps_y_off_len_luma = ps_luma_map->ps_y_offset_length;
1991
1992
        /* get the actual offset for the buffers */
1993
36.4k
        i4_offset_x = ps_x_off_len_luma[u2_mb_x].i2_offset;
1994
36.4k
        i4_offset_y = ps_y_off_len_luma[u2_mb_y].i2_offset;
1995
1996
36.4k
        {
1997
36.4k
            inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
1998
36.4k
            WORD32 i4_mb_x, i4_mb_y;
1999
36.4k
            UWORD16 u2_luma_mask = 0x0033;
2000
36.4k
            UWORD8 u1_chrm_mask = 0x11;
2001
36.4k
            WORD32 i4_luma_rt_sft_amt = 0;
2002
36.4k
            WORD32 i4_chrm_rt_sft_amt = 0;
2003
2004
36.4k
            i4_mb_x = ((i4_offset_x + 1) >> MB_WIDTH_SHIFT);
2005
36.4k
            i4_mb_y = ((i4_offset_y + 1) >> MB_HEIGHT_SHIFT);
2006
2007
            /* get the location of the byte which has the current mb mode */
2008
36.4k
            ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) ps_ref_mb_mode->pv_buffer;
2009
36.4k
            ps_inter_lyr_mb_prms += i4_mb_x;
2010
36.4k
            ps_inter_lyr_mb_prms += i4_mb_y * ps_ref_mb_mode->i4_num_element_stride;
2011
2012
            /* get the approp block in base layer in horz direction */
2013
36.4k
            if(0 != ((i4_offset_x + 1) & 15))
2014
18.8k
            {
2015
18.8k
                u2_luma_mask <<= 2;
2016
18.8k
                i4_luma_rt_sft_amt += 2;
2017
18.8k
                u1_chrm_mask <<= 1;
2018
18.8k
                i4_chrm_rt_sft_amt += 1;
2019
18.8k
            }
2020
            /* get the approp block in base layer in vert direction */
2021
36.4k
            if(0 != ((i4_offset_y + 1) & 15))
2022
17.5k
            {
2023
17.5k
                u2_luma_mask <<= 8;
2024
17.5k
                i4_luma_rt_sft_amt += 8;
2025
2026
17.5k
                u1_chrm_mask <<= 2;
2027
17.5k
                i4_chrm_rt_sft_amt += 2;
2028
17.5k
            }
2029
2030
            /* extract the nnz and store it */
2031
36.4k
            i4_luma_nnz = (ps_inter_lyr_mb_prms->u2_luma_nnz & u2_luma_mask) >> i4_luma_rt_sft_amt;
2032
36.4k
            i4_chroma_nnz =
2033
36.4k
                (ps_inter_lyr_mb_prms->u1_chroma_nnz & u1_chrm_mask) >> i4_chrm_rt_sft_amt;
2034
36.4k
            i4_tx_size =
2035
36.4k
                (ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1 : ps_inter_lyr_mb_prms->i1_tx_size;
2036
36.4k
        }
2037
2038
        /* since in dyadic case the window width and height will be 10x10   */
2039
        /* and the window start offsets will be always 1 column left and    */
2040
        /* 1 row above the block boundary. so the pointer and the required  */
2041
        /* positions are appropriately modified                             */
2042
36.4k
        if(i4_offset_x >= 0)
2043
28.3k
        {
2044
28.3k
            pi2_inp++;
2045
28.3k
        }
2046
2047
36.4k
        if(i4_offset_y >= 0)
2048
32.3k
        {
2049
32.3k
            pi2_inp += i4_inp_stride;
2050
32.3k
        }
2051
2052
36.4k
        ps_ctxt->pf_residual_luma_dyadic(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride, pi2_out,
2053
36.4k
                                         i4_out_stride, ps_ref_mb_mode, u2_mb_x, u2_mb_y,
2054
36.4k
                                         i4_luma_nnz, i4_tx_size);
2055
36.4k
    }
2056
2057
    /* --------------------------------------------------------------------- */
2058
    /* CHROMA PROCESSING                                                       */
2059
    /* --------------------------------------------------------------------- */
2060
    /* CB */
2061
36.4k
    pi2_inp = (WORD16 *) ps_ref_chroma->pv_buffer;
2062
36.4k
    pi2_out = (WORD16 *) ps_out_chroma->pv_buffer;
2063
36.4k
    i4_inp_stride = ps_ref_chroma->i4_num_element_stride;
2064
36.4k
    i4_out_stride = ps_out_chroma->i4_num_element_stride;
2065
2066
    /* choose the appropriate chroma processing routine */
2067
36.4k
    if(SVCD_FALSE == ps_lyr_ctxt->i4_chrm_alt_proc)
2068
36.4k
    {
2069
36.4k
        WORD32 i4_offset_x, i4_offset_y;
2070
36.4k
        residual_samp_map_ctxt_t *ps_chroma_map;
2071
36.4k
        ref_mb_map_t *ps_x_off_len_chroma;
2072
36.4k
        ref_mb_map_t *ps_y_off_len_chroma;
2073
2074
36.4k
        ps_chroma_map = &ps_lyr_ctxt->s_chroma_map_ctxt;
2075
36.4k
        ps_x_off_len_chroma = ps_chroma_map->ps_x_offset_length;
2076
36.4k
        ps_y_off_len_chroma = ps_chroma_map->ps_y_offset_length;
2077
2078
        /* get the actual offset for the buffers */
2079
36.4k
        i4_offset_x = ps_x_off_len_chroma[u2_mb_x].i2_offset;
2080
36.4k
        i4_offset_y = ps_y_off_len_chroma[u2_mb_y].i2_offset;
2081
2082
        /* since in dyadic case the window width and height will be 6x6     */
2083
        /* and the window start offsets will be always 1 column left and    */
2084
        /* 1 row above the block boundary. so the pointer and the required  */
2085
        /* positions are appropriately modified                             */
2086
36.4k
        if(i4_offset_x >= 0)
2087
28.3k
        {
2088
28.3k
            pi2_inp += 2;
2089
28.3k
        }
2090
2091
36.4k
        if(i4_offset_y >= 0)
2092
32.3k
        {
2093
32.3k
            pi2_inp += i4_inp_stride;
2094
32.3k
        }
2095
2096
36.4k
        if(0 != (i4_chroma_nnz & 0x01))
2097
1.09k
        {
2098
1.09k
            ps_ctxt->pf_residual_chroma_dyadic(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
2099
1.09k
                                               pi2_out, i4_out_stride);
2100
1.09k
        }
2101
36.4k
    }
2102
0
    else
2103
0
    {
2104
0
        ps_ctxt->pf_residual_chroma_dyadic_alt(pv_residual_samp_ctxt, u2_mb_x, u2_mb_y,
2105
0
                                               ps_ref_mb_mode, pi2_inp, i4_inp_stride, pi2_out,
2106
0
                                               i4_out_stride, SVCD_FALSE);
2107
0
    }
2108
2109
    /* CR */
2110
36.4k
    pi2_inp += 1;
2111
36.4k
    pi2_out += 1;
2112
2113
36.4k
    if(SVCD_FALSE == ps_lyr_ctxt->i4_chrm_alt_proc)
2114
36.4k
    {
2115
36.4k
        if(0 != (i4_chroma_nnz & 0x10))
2116
1.23k
        {
2117
1.23k
            ps_ctxt->pf_residual_chroma_dyadic(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
2118
1.23k
                                               pi2_out, i4_out_stride);
2119
1.23k
        }
2120
36.4k
    }
2121
0
    else
2122
0
    {
2123
0
        ps_ctxt->pf_residual_chroma_dyadic_alt(pv_residual_samp_ctxt, u2_mb_x, u2_mb_y,
2124
0
                                               ps_ref_mb_mode, pi2_inp, i4_inp_stride, pi2_out,
2125
0
                                               i4_out_stride, SVCD_TRUE);
2126
0
    }
2127
36.4k
    return OK;
2128
36.4k
}
2129
2130
/*****************************************************************************/
2131
/*                                                                           */
2132
/*  Function Name : isvcd_residual_samp_populate_list                         */
2133
/*                                                                           */
2134
/*  Description   : This is a seq or frame level init function which fills   */
2135
/*                  all offsets, projected locations arrays based on         */
2136
/*                  the two resolutions  and cropping parameters             */
2137
/*  Inputs        : refer to doxygen comments below                          */
2138
/*  Globals       : none                                                     */
2139
/*  Processing    : it projects the locations and computes the values        */
2140
/*                                                                           */
2141
/*  Outputs       : none                                                     */
2142
/*  Returns       : none                                                     */
2143
/*                                                                           */
2144
/*  Issues        : none                                                     */
2145
/*                                                                           */
2146
/*  Revision History:                                                        */
2147
/*                                                                           */
2148
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
2149
/*         06 07 2021   vijayakumar          creation                        */
2150
/*                                                                           */
2151
/*****************************************************************************/
2152
void isvcd_residual_samp_populate_list(residual_samp_map_ctxt_t *ps_map_ctxt,
2153
                                       dec_seq_params_t *ps_sps,
2154
                                       dec_svc_seq_params_t *ps_subset_sps,
2155
                                       res_prms_t *ps_curr_res_prms, res_prms_t *ps_ref_res_prms,
2156
                                       WORD32 i4_chroma_flag)
2157
68.9k
{
2158
    /* --------------------------------------------------------------------- */
2159
    /* Local variables required for finding the mapping between the layers     */
2160
    /* --------------------------------------------------------------------- */
2161
68.9k
    UWORD32 u4_shift_x;
2162
68.9k
    UWORD32 u4_shift_y;
2163
68.9k
    UWORD32 u4_scale_x;
2164
68.9k
    UWORD32 u4_scale_y;
2165
68.9k
    WORD32 i4_offset_x;
2166
68.9k
    WORD32 i4_offset_y;
2167
68.9k
    WORD32 i4_add_x;
2168
68.9k
    WORD32 i4_add_y;
2169
68.9k
    WORD32 i4_delta_x;
2170
68.9k
    WORD32 i4_delta_y;
2171
68.9k
    WORD32 i4_refphase_x;
2172
68.9k
    WORD32 i4_refphase_y;
2173
68.9k
    WORD32 i4_phase_x;
2174
68.9k
    WORD32 i4_phase_y;
2175
68.9k
    WORD32 i4_sub_wd;
2176
68.9k
    WORD32 i4_sub_ht;
2177
68.9k
    WORD32 i4_mb_wd;
2178
68.9k
    WORD32 i4_mb_ht;
2179
    /* --------------------------------------------------------------------- */
2180
    /* Local Pointer Declaration for arrays in Mapping context                 */
2181
    /* --------------------------------------------------------------------- */
2182
68.9k
    ref_mb_map_t *ps_x_off_len;
2183
68.9k
    ref_mb_map_t *ps_y_off_len;
2184
68.9k
    UWORD32 i4_ref_wd;
2185
68.9k
    UWORD32 i4_ref_ht;
2186
68.9k
    UWORD32 i4_scaled_wd;
2187
68.9k
    UWORD32 i4_scaled_ht;
2188
68.9k
    WORD32 i4_curr_lyr_width;
2189
68.9k
    WORD32 i4_curr_lyr_height;
2190
2191
    /* --------------------------------------------------------------------- */
2192
    /* Local Flag Declaration                                                 */
2193
    /* --------------------------------------------------------------------- */
2194
68.9k
    WORD32 i4_ref_layer_field_pic_flag;
2195
68.9k
    WORD32 i4_field_pic_flag;
2196
68.9k
    WORD32 i4_frame_mbs_only_flag;
2197
68.9k
    WORD32 i4_ref_layer_frame_Mbs_only_flag;
2198
68.9k
    WORD32 i4_field_Mb_flag;
2199
68.9k
    WORD32 i4_bot_field_flag;
2200
2201
    /* --------------------------------------------------------------------- */
2202
    /* Cropping Parameters Declaration                                         */
2203
    /* --------------------------------------------------------------------- */
2204
68.9k
    WORD32 i4_scaled_ref_layer_left_offset;
2205
68.9k
    WORD32 i4_scaled_ref_layer_top_offset;
2206
2207
    /* --------------------------------------------------------------------- */
2208
    /* Hardcoding flag information    (assuming no field support) */
2209
    /* --------------------------------------------------------------------- */
2210
68.9k
    i4_ref_layer_field_pic_flag = SVCD_FALSE;
2211
68.9k
    i4_field_pic_flag = SVCD_FALSE;
2212
68.9k
    i4_frame_mbs_only_flag = SVCD_TRUE;
2213
68.9k
    i4_field_Mb_flag = SVCD_FALSE;
2214
68.9k
    i4_bot_field_flag = SVCD_FALSE;
2215
68.9k
    i4_ref_layer_frame_Mbs_only_flag = SVCD_TRUE;
2216
2217
    /* --------------------------------------------------------------------- */
2218
    /* Pointer and Paramater are intialized    - Chroma and Luma */
2219
    /* --------------------------------------------------------------------- */
2220
68.9k
    {
2221
68.9k
        WORD32 i4_base_width;
2222
68.9k
        WORD32 i4_base_height;
2223
68.9k
        WORD32 i4_ref_layer_chroma_phase_x_plus1_flag;
2224
68.9k
        WORD32 i4_ref_layer_chroma_phase_y_plus1;
2225
68.9k
        WORD32 i4_chroma_phase_x_plus1_flag;
2226
68.9k
        WORD32 i4_chroma_phase_y_plus1;
2227
2228
        /* ------------------------------------------------------------- */
2229
        /* HARD CODED FOR 420                                             */
2230
        /* ------------------------------------------------------------- */
2231
68.9k
        WORD32 i4_sub_wd_chroma = 2;
2232
68.9k
        WORD32 i4_sub_ht_chroma = 2;
2233
2234
68.9k
        i4_base_width = ps_ref_res_prms->i4_res_width;
2235
68.9k
        i4_base_height = ps_ref_res_prms->i4_res_height;
2236
2237
68.9k
        i4_ref_layer_chroma_phase_x_plus1_flag =
2238
68.9k
            ps_curr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag;
2239
68.9k
        i4_ref_layer_chroma_phase_y_plus1 = ps_curr_res_prms->i1_ref_lyr_chroma_phase_y_plus1;
2240
68.9k
        i4_chroma_phase_x_plus1_flag =
2241
68.9k
            ps_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_x_plus1_flag;
2242
68.9k
        i4_chroma_phase_y_plus1 =
2243
68.9k
            ps_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_y_plus1;
2244
68.9k
        i4_scaled_ref_layer_left_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_left;
2245
68.9k
        i4_scaled_ref_layer_top_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_top;
2246
2247
        /* ----------------------------------------------------------------- */
2248
        /* Computing Effective Frame Dimensions                                 */
2249
        /* ------------------------------------------------------------------*/
2250
68.9k
        i4_ref_wd = (i4_base_width >> i4_chroma_flag);
2251
68.9k
        i4_ref_ht = (i4_base_height >> i4_chroma_flag) * (1 + i4_ref_layer_field_pic_flag);
2252
68.9k
        i4_scaled_wd = ps_curr_res_prms->u2_scaled_ref_width;
2253
68.9k
        i4_scaled_ht = ps_curr_res_prms->u2_scaled_ref_height;
2254
68.9k
        i4_scaled_wd = (i4_scaled_wd >> i4_chroma_flag);
2255
68.9k
        i4_scaled_ht = (i4_scaled_ht >> i4_chroma_flag) * (1 + i4_field_pic_flag);
2256
2257
68.9k
        if(1 == i4_chroma_flag)
2258
34.4k
        {
2259
34.4k
            i4_refphase_x = i4_ref_layer_chroma_phase_x_plus1_flag - 1;
2260
34.4k
            i4_refphase_y = i4_ref_layer_chroma_phase_y_plus1 - 1;
2261
34.4k
            i4_phase_x = i4_chroma_phase_x_plus1_flag - 1;
2262
34.4k
            i4_phase_y = i4_chroma_phase_y_plus1 - 1;
2263
34.4k
            i4_sub_wd = i4_sub_wd_chroma;
2264
34.4k
            i4_sub_ht = i4_sub_ht_chroma;
2265
34.4k
            i4_mb_wd = MB_WIDTH >> 1;
2266
34.4k
            i4_mb_ht = MB_HEIGHT >> 1;
2267
34.4k
        }
2268
34.4k
        else
2269
34.4k
        {
2270
34.4k
            i4_refphase_x = 0;
2271
34.4k
            i4_refphase_y = 0;
2272
34.4k
            i4_phase_x = 0;
2273
34.4k
            i4_phase_y = 0;
2274
34.4k
            i4_sub_wd = 1;
2275
34.4k
            i4_sub_ht = 1;
2276
34.4k
            i4_mb_wd = MB_WIDTH;
2277
34.4k
            i4_mb_ht = MB_HEIGHT;
2278
34.4k
        }
2279
68.9k
    }
2280
2281
    /* --------------------------------------------------------------------- */
2282
    /* Derive shift x and y based on level idd                               */
2283
    /* --------------------------------------------------------------------- */
2284
68.9k
    if(ps_sps->u1_level_idc <= 30)
2285
64.8k
    {
2286
64.8k
        u4_shift_x = 16;
2287
64.8k
        u4_shift_y = 16;
2288
64.8k
    }
2289
4.19k
    else
2290
4.19k
    {
2291
4.19k
        u4_shift_x = 31 - isvcd_get_ceil_log2(i4_ref_wd);
2292
4.19k
        u4_shift_y = 31 - isvcd_get_ceil_log2(i4_ref_ht);
2293
4.19k
    }
2294
2295
    /* --------------------------------------------------------------------- */
2296
    /* The following condition is not true in our case for time being         */
2297
    /* --------------------------------------------------------------------- */
2298
68.9k
    if((SVCD_FALSE == i4_frame_mbs_only_flag) || (SVCD_FALSE == i4_ref_layer_frame_Mbs_only_flag))
2299
0
    {
2300
0
        i4_phase_y = i4_phase_y + 4 * i4_bot_field_flag;
2301
2302
0
        if(1 == i4_ref_layer_frame_Mbs_only_flag)
2303
0
            i4_refphase_y = (2 * i4_refphase_y) + 2;
2304
0
        else
2305
0
            i4_refphase_y = i4_refphase_y + (4 * i4_bot_field_flag);
2306
0
    }
2307
2308
    /* --------------------------------------------------------------------- */
2309
    /* Dx and Dy Computation - Ratio of the base and enhance layer width     */
2310
    /* --------------------------------------------------------------------- */
2311
68.9k
    u4_scale_x = ((i4_ref_wd << u4_shift_x) + (i4_scaled_wd >> 1)) / (i4_scaled_wd);
2312
2313
68.9k
    u4_scale_y = ((i4_ref_ht << u4_shift_y) + (i4_scaled_ht >> 1)) / (i4_scaled_ht);
2314
2315
68.9k
    i4_offset_x = i4_scaled_ref_layer_left_offset / i4_sub_wd;
2316
68.9k
    i4_add_x = (((i4_ref_wd * (2 + i4_phase_x)) << (u4_shift_x - 2)) + (i4_scaled_wd >> 1)) /
2317
68.9k
                   i4_scaled_wd +
2318
68.9k
               (1 << (u4_shift_x - 5));
2319
68.9k
    i4_delta_x = 4 * (2 + i4_refphase_x);
2320
2321
68.9k
    if((SVCD_TRUE == i4_frame_mbs_only_flag) && (SVCD_TRUE == i4_ref_layer_frame_Mbs_only_flag))
2322
68.9k
    {
2323
68.9k
        i4_offset_y = i4_scaled_ref_layer_top_offset / i4_sub_ht;
2324
68.9k
        i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (u4_shift_y - 2)) + (i4_scaled_ht >> 1)) /
2325
68.9k
                       i4_scaled_ht +
2326
68.9k
                   (1 << (u4_shift_y - 5));
2327
68.9k
        i4_delta_y = 4 * (2 + i4_refphase_y);
2328
68.9k
    }
2329
0
    else
2330
0
    {
2331
0
        i4_offset_y = i4_scaled_ref_layer_top_offset / (2 * i4_sub_ht);
2332
0
        i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (u4_shift_y - 3)) + (i4_scaled_ht >> 1)) /
2333
0
                       i4_scaled_ht +
2334
0
                   (1 << (u4_shift_y - 5));
2335
0
        i4_delta_y = 2 * (2 + i4_refphase_y);
2336
0
    }
2337
2338
    /* --------------------------------------------------------------------- */
2339
    /* Intializing Local Pointers    - Chroma and Luma                       */
2340
    /* --------------------------------------------------------------------- */
2341
68.9k
    ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
2342
68.9k
    ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
2343
68.9k
    i4_curr_lyr_width = ps_curr_res_prms->i4_res_width >> i4_chroma_flag;
2344
68.9k
    i4_curr_lyr_height = ps_curr_res_prms->i4_res_height >> i4_chroma_flag;
2345
2346
68.9k
    {
2347
68.9k
        WORD32 i4_i, i4_j;
2348
2349
        /* ----------------------------------------------------------------- */
2350
        /* Computation of offsetX refArrayW Xmin and Xmax Lists               */
2351
        /* ----------------------------------------------------------------- */
2352
307k
        for(i4_i = 0; i4_i < i4_curr_lyr_width; i4_i = i4_i + i4_mb_wd)
2353
238k
        {
2354
238k
            WORD32 i4_x_refmin16;
2355
238k
            WORD32 i4_x_refmax16;
2356
238k
            WORD32 i4_x_offset;
2357
2358
238k
            i4_x_refmin16 = (WORD64) (((WORD64) ((i4_i - i4_offset_x) * u4_scale_x) + i4_add_x) >>
2359
238k
                                      ((WORD32) (u4_shift_x - 4))) -
2360
238k
                            i4_delta_x;
2361
2362
238k
            i4_x_refmax16 =
2363
238k
                (WORD64) (((WORD64) (i4_i + i4_mb_wd - 1 - i4_offset_x) * u4_scale_x + i4_add_x) >>
2364
238k
                          ((WORD32) (u4_shift_x - 4))) -
2365
238k
                i4_delta_x;
2366
2367
            /* AC205 */
2368
238k
            i4_x_offset = i4_x_refmin16 >> 4;
2369
238k
            ps_x_off_len->i2_offset = i4_x_offset;
2370
238k
            ps_x_off_len->i2_length = (i4_x_refmax16 >> 4) - i4_x_offset + 2;
2371
2372
            /* increment the pointer */
2373
238k
            ps_x_off_len++;
2374
2375
238k
        } /* end of loop over current layer width */
2376
2377
        /* ----------------------------------------------------------------- */
2378
        /* Computation of offsetY refArrayH Ymin and Ymax Lists              */
2379
        /* ----------------------------------------------------------------- */
2380
703k
        for(i4_j = 0; i4_j < i4_curr_lyr_height; i4_j = i4_j + i4_mb_ht)
2381
634k
        {
2382
634k
            WORD32 i4_y_refmin16;
2383
634k
            WORD32 i4_y_refmax16;
2384
634k
            WORD32 i4_y_offset;
2385
2386
634k
            i4_y_refmin16 = (WORD64) (((WORD64) (i4_j - i4_offset_y) * u4_scale_y + i4_add_y) >>
2387
634k
                                      ((WORD32) (u4_shift_y - 4))) -
2388
634k
                            i4_delta_y;
2389
2390
634k
            i4_y_refmax16 =
2391
634k
                (WORD64) (((WORD64) (i4_j + i4_mb_ht - 1 - i4_offset_y) * u4_scale_y + i4_add_y) >>
2392
634k
                          ((WORD32) (u4_shift_y - 4))) -
2393
634k
                i4_delta_y;
2394
2395
            /* AC205 */
2396
634k
            i4_y_offset = i4_y_refmin16 >> 4;
2397
634k
            ps_y_off_len->i2_offset = i4_y_offset;
2398
634k
            ps_y_off_len->i2_length = (i4_y_refmax16 >> 4) - i4_y_offset + 2;
2399
2400
            /* increment the pointer */
2401
634k
            ps_y_off_len++;
2402
2403
634k
        } /* end of loop over current layer height */
2404
68.9k
    }
2405
2406
    /* --------------------------------------------------------------------- */
2407
    /* Computation of Xref and Xphase List as per standard                     */
2408
    /* --------------------------------------------------------------------- */
2409
68.9k
    ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
2410
68.9k
    ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
2411
2412
68.9k
    {
2413
68.9k
        WORD32 i4_xc;
2414
68.9k
        WORD32 i4_offset_x_index;
2415
68.9k
        ref_pixel_map_t *ps_x_pos_phase;
2416
2417
68.9k
        ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase;
2418
2419
2.92M
        for(i4_xc = 0; i4_xc < i4_curr_lyr_width; i4_xc++)
2420
2.85M
        {
2421
2.85M
            WORD32 i4_x_offset;
2422
2.85M
            WORD32 i4_x_ref16;
2423
2424
2.85M
            i4_offset_x_index = i4_xc / i4_mb_wd;
2425
2.85M
            i4_x_offset = ps_x_off_len[i4_offset_x_index].i2_offset;
2426
2.85M
            i4_x_ref16 = (WORD64) (((WORD64) (i4_xc - i4_offset_x) * u4_scale_x + i4_add_x) >>
2427
2.85M
                                   ((WORD32) (u4_shift_x - 4))) -
2428
2.85M
                         i4_delta_x;
2429
2430
            /* store the values */
2431
2.85M
            ps_x_pos_phase->i2_ref_pos = (i4_x_ref16 >> 4) - i4_x_offset;
2432
2.85M
            ps_x_pos_phase->i2_phase = (i4_x_ref16 - (16 * i4_x_offset)) & 15;
2433
2434
            /* increment the pointer */
2435
2.85M
            ps_x_pos_phase++;
2436
2.85M
        } /* end of loop over scaled width */
2437
68.9k
    }
2438
2439
    /* --------------------------------------------------------------------- */
2440
    /* Computation of Yref and Yphase List as per standard                     */
2441
    /* --------------------------------------------------------------------- */
2442
68.9k
    {
2443
68.9k
        WORD32 i4_yc;
2444
68.9k
        WORD32 i4_offset_y_index;
2445
68.9k
        ref_pixel_map_t *ps_y_pos_phase;
2446
2447
68.9k
        ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase;
2448
2449
7.68M
        for(i4_yc = 0; i4_yc < i4_curr_lyr_height; i4_yc++)
2450
7.61M
        {
2451
7.61M
            WORD32 i4_y_offset;
2452
7.61M
            WORD32 i4_y_ref16;
2453
2454
7.61M
            i4_offset_y_index = i4_yc / i4_mb_ht;
2455
7.61M
            i4_y_offset = ps_y_off_len[i4_offset_y_index].i2_offset;
2456
2457
7.61M
            if((SVCD_FALSE == i4_frame_mbs_only_flag) ||
2458
7.61M
               (SVCD_FALSE == i4_ref_layer_frame_Mbs_only_flag))
2459
0
            {
2460
0
                i4_yc = i4_yc >> (1 - i4_field_Mb_flag);
2461
0
            }
2462
2463
7.61M
            i4_y_ref16 = (WORD64) ((((WORD64) (i4_yc - i4_offset_y) * u4_scale_y + i4_add_y) >>
2464
7.61M
                                    ((WORD32) (u4_shift_y - 4))) -
2465
7.61M
                                   i4_delta_y);
2466
7.61M
            ps_y_pos_phase->i2_ref_pos = (i4_y_ref16 >> 4) - i4_y_offset;
2467
7.61M
            ps_y_pos_phase->i2_phase = (i4_y_ref16 - (16 * i4_y_offset)) & 15;
2468
2469
            /* increment the pointer */
2470
7.61M
            ps_y_pos_phase++;
2471
7.61M
        } /* end of loop over scaled height */
2472
68.9k
    }
2473
68.9k
    return;
2474
68.9k
}
2475
2476
/*****************************************************************************/
2477
/*                                                                           */
2478
/*  Function Name : isvcd_residual_samp_res_init                              */
2479
/*                                                                           */
2480
/*  Description   : this function calculates the scale factors and initialise*/
2481
/*                  the context structure                                    */
2482
/*                                                                           */
2483
/*  Inputs        : pv_residual_samp_ctxt: handle to private structure       */
2484
/*                  ps_curr_lyr_res_prms: pointer to current resolution      */
2485
/*                                               params                      */
2486
/*  Globals       : none                                                     */
2487
/*  Processing    : it stores the layer dimensions                           */
2488
/*                                                                           */
2489
/*  Outputs       : none                                                     */
2490
/*  Returns       : none                                                     */
2491
/*                                                                           */
2492
/*  Issues        : none                                                     */
2493
/*                                                                           */
2494
/*  Revision History:                                                        */
2495
/*                                                                           */
2496
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
2497
/*         26 06 2021   vijayakumar          creation                        */
2498
/*                                                                           */
2499
/*****************************************************************************/
2500
WORD32 isvcd_residual_samp_res_init(void *pv_svc_dec)
2501
135k
{
2502
135k
    residual_sampling_ctxt_t *ps_ctxt;
2503
135k
    res_lyr_ctxt *ps_lyr_ctxt;
2504
135k
    dec_seq_params_t *ps_sps;
2505
135k
    dec_svc_seq_params_t *ps_subset_sps;
2506
135k
    svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
2507
135k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
2508
2509
135k
    void *pv_residual_samp_ctxt = ps_svc_lyr_dec->pv_residual_sample_ctxt;
2510
135k
    res_prms_t *ps_curr_lyr_res_prms = &ps_svc_lyr_dec->s_res_prms;
2511
135k
    ref_mb_map_t **pps_luma_map_horz = &ps_svc_lyr_dec->ps_ressam_luma_map_horz;
2512
135k
    ref_mb_map_t **pps_chroma_map_horz = &ps_svc_lyr_dec->ps_ressam_chroma_map_horz;
2513
135k
    ref_mb_map_t **pps_luma_map_vert = &ps_svc_lyr_dec->ps_ressam_luma_map_vert;
2514
135k
    ref_mb_map_t **pps_chroma_map_vert = &ps_svc_lyr_dec->ps_ressam_chroma_map_vert;
2515
2516
135k
    if((NULL == pv_residual_samp_ctxt) || (NULL == ps_curr_lyr_res_prms) ||
2517
135k
       (NULL == pps_luma_map_horz) || (NULL == pps_chroma_map_horz) ||
2518
135k
       (NULL == pps_luma_map_vert) || (NULL == pps_chroma_map_vert))
2519
0
    {
2520
0
        return NOT_OK;
2521
0
    }
2522
2523
135k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
2524
2525
    /* if called for base resolution store deafult values */
2526
135k
    if(SVCD_TRUE == ps_svc_lyr_dec->u1_base_res_flag)
2527
101k
    {
2528
101k
        *pps_luma_map_horz = NULL;
2529
101k
        *pps_chroma_map_horz = NULL;
2530
101k
        *pps_luma_map_vert = NULL;
2531
101k
        *pps_chroma_map_vert = NULL;
2532
101k
        ps_ctxt->i4_res_lyr_id = -1;
2533
101k
        ps_ctxt->i4_ref_width = ps_curr_lyr_res_prms->i4_res_width;
2534
101k
        ps_ctxt->i4_ref_height = ps_curr_lyr_res_prms->i4_res_height;
2535
101k
        return OK;
2536
101k
    }
2537
2538
    /* derive the current sps */
2539
34.4k
    ps_sps = ps_dec->ps_cur_sps;
2540
34.4k
    ps_subset_sps = ps_svc_lyr_dec->ps_cur_subset_sps;
2541
2542
    /* store the res id appropriately */
2543
34.4k
    ps_ctxt->i4_res_lyr_id = ps_svc_lyr_dec->u1_layer_id - 1;
2544
2545
    /* get the current layer ctxt */
2546
34.4k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_svc_lyr_dec->u1_layer_id - 1];
2547
2548
    /* get the width and heights */
2549
34.4k
    ps_lyr_ctxt->i4_curr_width = ps_curr_lyr_res_prms->i4_res_width;
2550
34.4k
    ps_lyr_ctxt->i4_curr_height = ps_curr_lyr_res_prms->i4_res_height;
2551
34.4k
    ps_lyr_ctxt->i4_ref_width = ps_ctxt->i4_ref_width;
2552
34.4k
    ps_lyr_ctxt->i4_ref_height = ps_ctxt->i4_ref_height;
2553
2554
    /* store the strcuture pointer containing projected locations */
2555
34.4k
    *pps_luma_map_horz = ps_lyr_ctxt->s_luma_map_ctxt.ps_x_offset_length;
2556
34.4k
    *pps_chroma_map_horz = ps_lyr_ctxt->s_chroma_map_ctxt.ps_x_offset_length;
2557
34.4k
    *pps_luma_map_vert = ps_lyr_ctxt->s_luma_map_ctxt.ps_y_offset_length;
2558
34.4k
    *pps_chroma_map_vert = ps_lyr_ctxt->s_chroma_map_ctxt.ps_y_offset_length;
2559
2560
    /* check for recomputation of mapping required */
2561
34.4k
    if(SVCD_TRUE == ps_curr_lyr_res_prms->u1_remap_req_flag)
2562
34.4k
    {
2563
34.4k
        res_prms_t s_ref_res_prms = {0};
2564
2565
        /* store the reference layer resolution width and height */
2566
34.4k
        s_ref_res_prms.i4_res_width = ps_ctxt->i4_ref_width;
2567
34.4k
        s_ref_res_prms.i4_res_height = ps_ctxt->i4_ref_height;
2568
2569
        /* call the frame level projections calculation function */
2570
34.4k
        isvcd_residual_samp_populate_list(&ps_lyr_ctxt->s_luma_map_ctxt, ps_sps, ps_subset_sps,
2571
34.4k
                                          ps_curr_lyr_res_prms, &s_ref_res_prms, 0);
2572
34.4k
        isvcd_residual_samp_populate_list(&ps_lyr_ctxt->s_chroma_map_ctxt, ps_sps, ps_subset_sps,
2573
34.4k
                                          ps_curr_lyr_res_prms, &s_ref_res_prms, 1);
2574
2575
        /* default values for flags */
2576
34.4k
        ps_lyr_ctxt->pf_residual_samp_mb = &isvcd_residual_samp_mb;
2577
34.4k
        ps_lyr_ctxt->i4_chrm_horz_int_mode = 0;
2578
34.4k
        ps_lyr_ctxt->i4_chrm_vert_int_mode = 0;
2579
34.4k
        ps_lyr_ctxt->i4_chrm_alt_proc = SVCD_FALSE;
2580
2581
        /* Store the Dyadic flag */
2582
34.4k
        ps_lyr_ctxt->i4_dyadic_flag = ps_curr_lyr_res_prms->u1_dyadic_flag;
2583
2584
        /* set the appropriate chroma processing routine based on */
2585
        /* phase values */
2586
34.4k
        if(SVCD_TRUE == ps_curr_lyr_res_prms->u1_dyadic_flag)
2587
15.5k
        {
2588
15.5k
            WORD32 i4_ref_layer_chroma_phase_x_plus1_flag;
2589
15.5k
            WORD32 i4_ref_layer_chroma_phase_y_plus1;
2590
15.5k
            WORD32 i4_chroma_phase_x_plus1_flag;
2591
15.5k
            WORD32 i4_chroma_phase_y_plus1;
2592
2593
15.5k
            ps_lyr_ctxt->pf_residual_samp_mb = &isvcd_residual_samp_mb_dyadic;
2594
15.5k
            i4_ref_layer_chroma_phase_x_plus1_flag =
2595
15.5k
                ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag;
2596
15.5k
            i4_ref_layer_chroma_phase_y_plus1 =
2597
15.5k
                ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_y_plus1;
2598
15.5k
            i4_chroma_phase_x_plus1_flag =
2599
15.5k
                ps_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_x_plus1_flag;
2600
15.5k
            i4_chroma_phase_y_plus1 =
2601
15.5k
                ps_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_y_plus1;
2602
15.5k
            if((0 == i4_ref_layer_chroma_phase_x_plus1_flag) && (1 == i4_chroma_phase_x_plus1_flag))
2603
0
            {
2604
0
                ps_lyr_ctxt->i4_chrm_horz_int_mode = 1;
2605
0
                ps_lyr_ctxt->i4_chrm_alt_proc = SVCD_TRUE;
2606
0
            }
2607
2608
15.5k
            if((0 == i4_ref_layer_chroma_phase_y_plus1) && (1 == i4_chroma_phase_y_plus1))
2609
0
            {
2610
0
                ps_lyr_ctxt->i4_chrm_vert_int_mode = 1;
2611
0
                ps_lyr_ctxt->i4_chrm_alt_proc = SVCD_TRUE;
2612
0
            }
2613
2614
15.5k
            if((0 == i4_ref_layer_chroma_phase_y_plus1) && (2 == i4_chroma_phase_y_plus1))
2615
0
            {
2616
0
                ps_lyr_ctxt->i4_chrm_vert_int_mode = 1;
2617
0
                ps_lyr_ctxt->i4_chrm_alt_proc = SVCD_TRUE;
2618
0
            }
2619
2620
15.5k
            if((2 == i4_ref_layer_chroma_phase_y_plus1) && (0 == i4_chroma_phase_y_plus1))
2621
0
            {
2622
0
                ps_lyr_ctxt->i4_chrm_vert_int_mode = 2;
2623
0
                ps_lyr_ctxt->i4_chrm_alt_proc = SVCD_TRUE;
2624
0
            }
2625
15.5k
        }
2626
34.4k
    }
2627
0
    else
2628
0
    {
2629
        /* should take false value */
2630
0
        if(SVCD_FALSE != ps_curr_lyr_res_prms->u1_remap_req_flag)
2631
0
        {
2632
0
            return NOT_OK;
2633
0
        }
2634
0
    }
2635
2636
    /* store the current layer width and height to context */
2637
34.4k
    ps_ctxt->i4_ref_width = ps_curr_lyr_res_prms->i4_res_width;
2638
34.4k
    ps_ctxt->i4_ref_height = ps_curr_lyr_res_prms->i4_res_height;
2639
2640
    /* assert on max ranges of width and shift values */
2641
34.4k
    if((ps_lyr_ctxt->i4_curr_width > H264_MAX_FRAME_WIDTH) ||
2642
34.4k
       (ps_lyr_ctxt->i4_ref_width > H264_MAX_FRAME_WIDTH) ||
2643
34.4k
       (ps_lyr_ctxt->i4_curr_height > H264_MAX_FRAME_HEIGHT) ||
2644
34.4k
       (ps_lyr_ctxt->i4_ref_height > H264_MAX_FRAME_HEIGHT))
2645
0
    {
2646
0
        return NOT_OK;
2647
0
    }
2648
34.4k
    return OK;
2649
34.4k
}