Coverage Report

Created: 2026-09-03 07:17

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.01k
{
408
2.01k
    residual_sampling_ctxt_t *ps_ctxt;
409
2.01k
    res_lyr_ctxt *ps_lyr_ctxt;
410
2.01k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
411
2.01k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
412
    /* ----------------- Processing ------------------------------- */
413
2.01k
    {
414
2.01k
        WORD32 i4_i;
415
2.01k
        WORD16 *pi2_ref_data_byte;
416
2.01k
        WORD32 *pi4_ref_array;
417
2.01k
        ref_pixel_map_t *ps_pos_phase;
418
2.01k
        WORD32 i4_phase1, i4_phase2;
419
420
2.01k
        pi2_ref_data_byte = pi2_inp_data;
421
2.01k
        ps_pos_phase = ps_lyr_ctxt->s_chroma_map_ctxt.ps_x_pos_phase;
422
423
        /* ----------- Horizontal Interpolation ---------------- */
424
2.01k
        pi4_ref_array = (WORD32 *) ps_ctxt->pi2_refarray_buffer;
425
2.01k
        i4_phase1 = ps_pos_phase[0].i2_phase;
426
2.01k
        i4_phase2 = (i4_phase1 + 8) & 0x0F;
427
428
10.0k
        for(i4_i = 0; i4_i < SUB_BLOCK_HEIGHT; i4_i++)
429
8.06k
        {
430
8.06k
            WORD16 i2_coeff1, i2_coeff2;
431
8.06k
            i2_coeff1 = (WORD16) (pi2_ref_data_byte[0]);
432
433
            /* populate the first inter sample */
434
8.06k
            *pi4_ref_array++ = i2_coeff1 << 4;
435
436
            /* unroll count 1 */
437
8.06k
            i2_coeff2 = (WORD16) (pi2_ref_data_byte[2]);
438
439
            /* populate 2 samples based on current coeffs */
440
8.06k
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff1 + i4_phase2 * i2_coeff2);
441
442
            /* unroll count 2 */
443
8.06k
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff1 + i4_phase1 * i2_coeff2);
444
445
            /* unroll count 3 */
446
8.06k
            i2_coeff1 = (WORD16) (pi2_ref_data_byte[4]);
447
448
            /* populate 2 samples based on current coeffs */
449
8.06k
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff2 + i4_phase2 * i2_coeff1);
450
451
            /* unroll count 4 */
452
8.06k
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff2 + i4_phase1 * i2_coeff1);
453
454
            /* unroll count 5 */
455
8.06k
            i2_coeff2 = (WORD16) (pi2_ref_data_byte[6]);
456
457
            /* populate 2 samples based on current coeffs */
458
8.06k
            *pi4_ref_array++ = ((16 - i4_phase2) * i2_coeff1 + i4_phase2 * i2_coeff2);
459
460
            /* unroll count 6 */
461
8.06k
            *pi4_ref_array++ = ((16 - i4_phase1) * i2_coeff1 + i4_phase1 * i2_coeff2);
462
463
            /* populate the last inter sample */
464
8.06k
            *pi4_ref_array++ = i2_coeff2 << 4;
465
466
            /* vertical loop uopdates */
467
8.06k
            pi2_ref_data_byte = pi2_inp_data + ((i4_i + 1) * i4_inp_data_stride);
468
8.06k
        }
469
470
        /* ----------- Vertical Interpolation ---------------- */
471
2.01k
        pi4_ref_array = (WORD32 *) ps_ctxt->pi2_refarray_buffer;
472
2.01k
        ps_pos_phase = ps_lyr_ctxt->s_chroma_map_ctxt.ps_y_pos_phase;
473
2.01k
        i4_phase1 = ps_pos_phase[0].i2_phase;
474
2.01k
        i4_phase2 = (i4_phase1 + 8) & 0x0F;
475
476
18.1k
        for(i4_i = 0; i4_i < BLOCK_WIDTH; i4_i++)
477
16.1k
        {
478
16.1k
            WORD16 *pi2_out;
479
16.1k
            WORD32 *pi4_ref_array_temp;
480
16.1k
            WORD32 i4_horz_samp_1, i4_horz_samp_2;
481
16.1k
            pi2_out = pi2_out_res;
482
16.1k
            pi4_ref_array_temp = pi4_ref_array;
483
484
            /* populate the first inter sample */
485
16.1k
            i4_horz_samp_1 = *pi4_ref_array_temp;
486
16.1k
            pi4_ref_array_temp += BLOCK_WIDTH;
487
16.1k
            *pi2_out = (i4_horz_samp_1 + 8) >> 4;
488
16.1k
            pi2_out += i4_out_res_stride;
489
490
            /* unroll count 1 */
491
16.1k
            i4_horz_samp_2 = *pi4_ref_array_temp;
492
16.1k
            pi4_ref_array_temp += BLOCK_WIDTH;
493
494
            /* populate 2 samples based on current coeffs */
495
16.1k
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_1 + i4_phase2 * i4_horz_samp_2 + 128) >> 8;
496
16.1k
            pi2_out += i4_out_res_stride;
497
498
            /* unroll count 2 */
499
16.1k
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_1 + i4_phase1 * i4_horz_samp_2 + 128) >> 8;
500
16.1k
            pi2_out += i4_out_res_stride;
501
502
            /* unroll count 3 */
503
16.1k
            i4_horz_samp_1 = *pi4_ref_array_temp;
504
16.1k
            pi4_ref_array_temp += BLOCK_WIDTH;
505
506
            /* populate 2 samples based on current coeffs */
507
16.1k
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_2 + i4_phase2 * i4_horz_samp_1 + 128) >> 8;
508
16.1k
            pi2_out += i4_out_res_stride;
509
510
            /* unroll count 4 */
511
16.1k
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_2 + i4_phase1 * i4_horz_samp_1 + 128) >> 8;
512
16.1k
            pi2_out += i4_out_res_stride;
513
514
            /* unroll count 5 */
515
16.1k
            i4_horz_samp_2 = *pi4_ref_array_temp;
516
517
            /* populate 2 samples based on current coeffs */
518
16.1k
            *pi2_out = ((16 - i4_phase2) * i4_horz_samp_1 + i4_phase2 * i4_horz_samp_2 + 128) >> 8;
519
16.1k
            pi2_out += i4_out_res_stride;
520
521
            /* unroll count 6 */
522
16.1k
            *pi2_out = ((16 - i4_phase1) * i4_horz_samp_1 + i4_phase1 * i4_horz_samp_2 + 128) >> 8;
523
16.1k
            pi2_out += i4_out_res_stride;
524
525
            /* populate the last inter sample */
526
16.1k
            *pi2_out = (i4_horz_samp_2 + 8) >> 4;
527
528
            /* horizontal loop updates */
529
16.1k
            pi4_ref_array++;
530
16.1k
            pi2_out_res += 2;
531
16.1k
        }
532
2.01k
    }
533
2.01k
    return;
534
2.01k
}
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
23.1k
{
573
23.1k
    WORD16 *pi2_refarray_buffer;
574
23.1k
    WORD32 i4_blk_ctr;
575
23.1k
    residual_sampling_ctxt_t *ps_ctxt;
576
577
23.1k
    UNUSED(ps_ref_mb_mode);
578
23.1k
    UNUSED(u2_mb_x);
579
23.1k
    UNUSED(u2_mb_y);
580
581
23.1k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
582
23.1k
    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
23.1k
    if((i4_ref_tx_size) && (0 != i4_ref_nnz))
587
1.67k
    {
588
1.67k
        WORD16 *pi2_ref_data_byte;
589
1.67k
        WORD32 *pi4_ref_array;
590
1.67k
        WORD32 i4_i, i4_j;
591
592
1.67k
        pi2_ref_data_byte = pi2_inp_data;
593
594
        /* ----------- Horizontal Interpolation ---------------- */
595
1.67k
        pi4_ref_array = (WORD32 *) pi2_refarray_buffer;
596
15.0k
        for(i4_i = 0; i4_i < BLOCK_HEIGHT; i4_i++)
597
13.3k
        {
598
13.3k
            WORD16 i2_coeff1, i2_coeff2;
599
13.3k
            i2_coeff1 = (WORD16) (*pi2_ref_data_byte++);
600
601
            /* populate the first inter sample */
602
13.3k
            *pi4_ref_array++ = i2_coeff1 << 2;
603
604
106k
            for(i4_j = 0; i4_j < 14; i4_j += 2)
605
93.5k
            {
606
93.5k
                i2_coeff2 = (WORD16) (*pi2_ref_data_byte++);
607
608
                /* populate 2 samples based on current coeffs */
609
93.5k
                *pi4_ref_array++ = ((i2_coeff1 << 1) + (i2_coeff1) + (i2_coeff2));
610
93.5k
                *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
93.5k
                i2_coeff1 = i2_coeff2;
615
93.5k
            }
616
617
            /* populate the last inter sample */
618
13.3k
            *pi4_ref_array++ = i2_coeff1 << 2;
619
620
            /* vertical loop uopdates */
621
13.3k
            pi2_ref_data_byte = pi2_inp_data + ((i4_i + 1) * i4_inp_data_stride);
622
13.3k
        }
623
624
        /* ----------- Vertical Interpolation ---------------- */
625
1.67k
        pi4_ref_array = (WORD32 *) pi2_refarray_buffer;
626
627
28.3k
        for(i4_i = 0; i4_i < MB_WIDTH; i4_i++)
628
26.7k
        {
629
26.7k
            WORD32 *pi4_ref_array_temp;
630
26.7k
            WORD16 *pi2_out;
631
26.7k
            WORD32 i4_horz_samp_1, i4_horz_samp_2;
632
633
26.7k
            pi4_ref_array_temp = pi4_ref_array;
634
26.7k
            pi2_out = pi2_out_res;
635
26.7k
            i4_horz_samp_1 = *pi4_ref_array_temp;
636
637
            /* populate the first inter sample */
638
26.7k
            *pi2_out = (i4_horz_samp_1 + 2) >> 2;
639
26.7k
            pi2_out += i4_out_res_stride;
640
641
213k
            for(i4_j = 0; i4_j < 14; i4_j += 2)
642
187k
            {
643
187k
                pi4_ref_array_temp += MB_WIDTH;
644
187k
                i4_horz_samp_2 = *pi4_ref_array_temp;
645
646
                /* populate 2 samples based on current coeffs */
647
187k
                *pi2_out = ((i4_horz_samp_1 << 1) + (i4_horz_samp_1) + (i4_horz_samp_2) + 8) >> 4;
648
187k
                pi2_out += i4_out_res_stride;
649
187k
                *pi2_out = ((i4_horz_samp_2 << 1) + (i4_horz_samp_2) + (i4_horz_samp_1) + 8) >> 4;
650
187k
                pi2_out += i4_out_res_stride;
651
652
                /* store the coeff 2 to coeff 1 */
653
                /* (used in next iteration)     */
654
187k
                i4_horz_samp_1 = i4_horz_samp_2;
655
187k
            }
656
657
            /* populate the first inter sample */
658
26.7k
            *pi2_out = (i4_horz_samp_1 + 2) >> 2;
659
660
            /* horizontal loop updates */
661
26.7k
            pi4_ref_array++;
662
26.7k
            pi2_out_res++;
663
26.7k
        }
664
1.67k
    }
665
21.5k
    else
666
21.5k
    {
667
        /* ----------------------------------------------------------------- */
668
        /* LOOP over number of blocks                                        */
669
        /* ----------------------------------------------------------------- */
670
107k
        for(i4_blk_ctr = 0; i4_blk_ctr < 4; i4_blk_ctr++)
671
86.0k
        {
672
86.0k
            WORD16 *pi2_ref_data_byte;
673
86.0k
            WORD32 *pi4_ref_array;
674
86.0k
            WORD32 i4_i;
675
676
            /* if reference layer is not coded then no processing */
677
86.0k
            if(0 != (i4_ref_nnz & 0x1))
678
7.75k
            {
679
7.75k
                pi2_ref_data_byte = pi2_inp_data;
680
681
                /* ----------- Horizontal Interpolation ---------------- */
682
7.75k
                pi4_ref_array = (WORD32 *) pi2_refarray_buffer;
683
684
38.7k
                for(i4_i = 0; i4_i < SUB_BLOCK_HEIGHT; i4_i++)
685
31.0k
                {
686
31.0k
                    WORD16 i2_coeff1, i2_coeff2;
687
31.0k
                    i2_coeff1 = (WORD16) (*pi2_ref_data_byte++);
688
689
                    /* populate the first inter sample */
690
31.0k
                    *pi4_ref_array++ = i2_coeff1 << 2;
691
692
31.0k
                    i2_coeff2 = (WORD16) (*pi2_ref_data_byte++);
693
694
                    /* populate 2 samples based on current coeffs */
695
31.0k
                    *pi4_ref_array++ = ((i2_coeff1 << 1) + (i2_coeff1) + (i2_coeff2));
696
31.0k
                    *pi4_ref_array++ = ((i2_coeff2 << 1) + (i2_coeff2) + (i2_coeff1));
697
698
31.0k
                    i2_coeff1 = (WORD16) (*pi2_ref_data_byte++);
699
700
                    /* populate 2 samples based on current coeffs */
701
31.0k
                    *pi4_ref_array++ = ((i2_coeff2 << 1) + (i2_coeff2) + (i2_coeff1));
702
31.0k
                    *pi4_ref_array++ = ((i2_coeff1 << 1) + (i2_coeff1) + (i2_coeff2));
703
704
31.0k
                    i2_coeff2 = (WORD16) (*pi2_ref_data_byte++);
705
706
                    /* populate 2 samples based on current coeffs */
707
31.0k
                    *pi4_ref_array++ = ((i2_coeff1 << 1) + (i2_coeff1) + (i2_coeff2));
708
31.0k
                    *pi4_ref_array++ = ((i2_coeff2 << 1) + (i2_coeff2) + (i2_coeff1));
709
710
                    /* populate the last inter sample */
711
31.0k
                    *pi4_ref_array++ = i2_coeff2 << 2;
712
713
                    /* vertical loop uopdates */
714
31.0k
                    pi2_ref_data_byte = pi2_inp_data + ((i4_i + 1) * i4_inp_data_stride);
715
31.0k
                }
716
717
                /* ----------- Vertical Interpolation ---------------- */
718
7.75k
                pi4_ref_array = (WORD32 *) pi2_refarray_buffer;
719
720
69.8k
                for(i4_i = 0; i4_i < BLOCK_WIDTH; i4_i++)
721
62.0k
                {
722
62.0k
                    WORD32 *pi4_ref_array_temp;
723
62.0k
                    WORD16 *pi2_out;
724
62.0k
                    WORD32 i4_horz_samp_1, i4_horz_samp_2;
725
726
62.0k
                    pi4_ref_array_temp = pi4_ref_array;
727
62.0k
                    pi2_out = pi2_out_res;
728
62.0k
                    i4_horz_samp_1 = *pi4_ref_array_temp;
729
730
                    /* populate the first inter sample */
731
62.0k
                    *pi2_out = (i4_horz_samp_1 + 2) >> 2;
732
62.0k
                    pi2_out += i4_out_res_stride;
733
734
                    /* unroll loop count 1 */
735
62.0k
                    pi4_ref_array_temp += BLOCK_WIDTH;
736
62.0k
                    i4_horz_samp_2 = *pi4_ref_array_temp;
737
738
                    /* populate 2 samples based on current coeffs */
739
62.0k
                    *pi2_out =
740
62.0k
                        ((i4_horz_samp_1 << 1) + (i4_horz_samp_1) + (i4_horz_samp_2) + 8) >> 4;
741
62.0k
                    pi2_out += i4_out_res_stride;
742
62.0k
                    *pi2_out =
743
62.0k
                        ((i4_horz_samp_2 << 1) + (i4_horz_samp_2) + (i4_horz_samp_1) + 8) >> 4;
744
62.0k
                    pi2_out += i4_out_res_stride;
745
746
                    /* unroll loop count 2 */
747
62.0k
                    pi4_ref_array_temp += BLOCK_WIDTH;
748
62.0k
                    i4_horz_samp_1 = *pi4_ref_array_temp;
749
750
                    /* populate 2 samples based on current coeffs */
751
62.0k
                    *pi2_out =
752
62.0k
                        ((i4_horz_samp_2 << 1) + (i4_horz_samp_2) + (i4_horz_samp_1) + 8) >> 4;
753
62.0k
                    pi2_out += i4_out_res_stride;
754
62.0k
                    *pi2_out =
755
62.0k
                        ((i4_horz_samp_1 << 1) + (i4_horz_samp_1) + (i4_horz_samp_2) + 8) >> 4;
756
62.0k
                    pi2_out += i4_out_res_stride;
757
758
                    /* unroll loop count 3 */
759
62.0k
                    pi4_ref_array_temp += BLOCK_WIDTH;
760
62.0k
                    i4_horz_samp_2 = *pi4_ref_array_temp;
761
762
                    /* populate 2 samples based on current coeffs */
763
62.0k
                    *pi2_out =
764
62.0k
                        ((i4_horz_samp_1 << 1) + (i4_horz_samp_1) + (i4_horz_samp_2) + 8) >> 4;
765
62.0k
                    pi2_out += i4_out_res_stride;
766
62.0k
                    *pi2_out =
767
62.0k
                        ((i4_horz_samp_2 << 1) + (i4_horz_samp_2) + (i4_horz_samp_1) + 8) >> 4;
768
62.0k
                    pi2_out += i4_out_res_stride;
769
770
                    /* populate the last inter sample */
771
62.0k
                    *pi2_out = (i4_horz_samp_2 + 2) >> 2;
772
773
                    /* horizontal loop updates */
774
62.0k
                    pi4_ref_array++;
775
62.0k
                    pi2_out_res++;
776
62.0k
                }
777
7.75k
            }
778
78.3k
            else
779
78.3k
            {
780
78.3k
                pi2_out_res += BLOCK_WIDTH;
781
78.3k
            }
782
783
            /* Block level loop updates */
784
86.0k
            if(1 == i4_blk_ctr)
785
21.5k
            {
786
21.5k
                pi2_inp_data -= SUB_BLOCK_WIDTH;
787
21.5k
                pi2_inp_data += (i4_inp_data_stride * SUB_BLOCK_HEIGHT);
788
21.5k
                pi2_out_res -= MB_WIDTH;
789
21.5k
                pi2_out_res += (i4_out_res_stride * BLOCK_HEIGHT);
790
21.5k
                i4_ref_nnz >>= 2;
791
21.5k
            }
792
64.5k
            else
793
64.5k
            {
794
64.5k
                pi2_inp_data += SUB_BLOCK_WIDTH;
795
64.5k
            }
796
797
86.0k
            i4_ref_nnz >>= 1;
798
799
86.0k
        } /* end of loop over all the blocks */
800
21.5k
    }
801
23.1k
    return;
802
23.1k
}
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
327k
{
840
327k
    WORD32 i4_x, i4_y;
841
327k
    WORD32 i4_x_idx, i4_y_idx;
842
327k
    WORD32 i4_prev_x, i4_prev_y;
843
327k
    WORD32 i4_const_val;
844
327k
    WORD32 i4_pos_x, i4_pos_y;
845
327k
    WORD32 i4_trans_size;
846
327k
    WORD32 i4_act_ary_wd, i4_act_ary_ht;
847
327k
    WORD32 i4_and_const;
848
327k
    UWORD8 *pu1_incr_x, *pu1_incr_y;
849
327k
    WORD32 i4_mb_sft;
850
327k
    WORD32 i4_mb_x, i4_mb_y;
851
327k
    WORD8 *pi1_ref_mb_modes_incr;
852
327k
    WORD8 *pi1_ref_mb_modes_incr_temp;
853
327k
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
854
327k
    WORD32 i4_mb_x_strt, i4_mb_y_strt;
855
327k
    WORD32 i4_mb_quard1_part_x, i4_mb_quard1_part_y;
856
327k
    WORD32 i4_x_ref, i4_y_ref;
857
327k
    WORD32 i4_tx_size, i4_tx_size_q0, i4_tx_size_q1, i4_tx_size_q2, i4_tx_size_q3;
858
327k
    WORD8 i1_mb_mode_q0, i1_mb_mode_q1, i1_mb_mode_q2, i1_mb_mode_q3;
859
327k
    WORD32 i4_mb_wd;
860
327k
    WORD32 i4_mb_ht;
861
862
327k
    i4_mb_wd = MB_WIDTH >> i4_chroma_flag;
863
327k
    i4_mb_ht = MB_HEIGHT >> i4_chroma_flag;
864
865
    /* Memset to 1 the increment buffers */
866
327k
    memset(pu1_ref_x_ptr_incr, 1, (i4_refary_wd * i4_refary_ht));
867
327k
    memset(pu1_ref_y_ptr_incr, 1, (i4_refary_wd * i4_refary_ht));
868
869
    /* Initialise actual width and height */
870
327k
    i4_act_ary_wd = i4_refary_wd;
871
327k
    i4_act_ary_ht = i4_refary_ht;
872
873
    /* Initialize x and y */
874
327k
    i4_x = 0;
875
327k
    i4_y = 0;
876
327k
    i4_prev_y = 0;
877
327k
    i4_mb_sft = (MB_WIDTH_SHIFT - i4_chroma_flag);
878
879
    /* Loop over all MBs in the reference array */
880
327k
    if(0 == i4_chroma_flag)
881
109k
    {
882
109k
        i4_x_ref = i4_x_offset + 0;
883
109k
        i4_y_ref = i4_y_offset + 0;
884
109k
        i4_mb_x_strt = i4_x_ref % i4_mb_wd;
885
109k
        i4_mb_y_strt = i4_y_ref % i4_mb_ht;
886
109k
        i4_mb_quard1_part_x = i4_mb_wd - i4_mb_x_strt;
887
109k
        i4_mb_quard1_part_y = i4_mb_ht - i4_mb_y_strt;
888
889
109k
        if(!(i4_mb_quard1_part_x >= 0))
890
0
        {
891
0
            return NOT_OK;
892
0
        }
893
109k
        if(!(i4_mb_quard1_part_y >= 0))
894
0
        {
895
0
            return NOT_OK;
896
0
        }
897
898
        /* Take care of negative offsets */
899
109k
        if(i4_x_ref > 0)
900
72.1k
        {
901
72.1k
            i4_mb_x = (i4_x_ref >> i4_mb_sft);
902
72.1k
        }
903
36.9k
        else
904
36.9k
        {
905
36.9k
            i4_mb_x = 0;
906
36.9k
        }
907
109k
        if(i4_y_ref > 0)
908
92.3k
        {
909
92.3k
            i4_mb_y = (i4_y_ref >> i4_mb_sft);
910
92.3k
        }
911
16.7k
        else
912
16.7k
        {
913
16.7k
            i4_mb_y = 0;
914
16.7k
        }
915
916
        /* get the location of the byte which has the current mb mode */
917
109k
        pi1_ref_mb_modes_incr = pi1_ref_mb_modes + (i4_mb_y * i4_ref_mode_stride * i4_element_size);
918
109k
        pi1_ref_mb_modes_incr += (i4_mb_x * i4_element_size);
919
109k
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr;
920
109k
        i1_mb_mode_q0 = ps_inter_lyr_mb_prms->i1_mb_mode;
921
109k
        i4_tx_size_q0 =
922
109k
            (i1_mb_mode_q0 <= SVC_INTER_MB)
923
109k
                ? ((ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1 : ps_inter_lyr_mb_prms->i1_tx_size)
924
109k
                : 1;
925
926
109k
        pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr;
927
109k
        if(i4_mb_quard1_part_x > 0)
928
109k
        {
929
109k
            pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr + i4_element_size;
930
109k
            ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
931
109k
            i1_mb_mode_q1 = ps_inter_lyr_mb_prms->i1_mb_mode;
932
109k
            i4_tx_size_q1 =
933
109k
                (i1_mb_mode_q1 <= SVC_INTER_MB)
934
109k
                    ? ((ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1
935
101k
                                                              : ps_inter_lyr_mb_prms->i1_tx_size)
936
109k
                    : 1;
937
109k
        }
938
939
109k
        if(i4_mb_quard1_part_y > 0)
940
109k
        {
941
109k
            pi1_ref_mb_modes_incr_temp =
942
109k
                pi1_ref_mb_modes_incr + (i4_ref_mode_stride * i4_element_size);
943
109k
            ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
944
109k
            i1_mb_mode_q2 = ps_inter_lyr_mb_prms->i1_mb_mode;
945
109k
            i4_tx_size_q2 =
946
109k
                (i1_mb_mode_q2 <= SVC_INTER_MB)
947
109k
                    ? ((ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1
948
103k
                                                              : ps_inter_lyr_mb_prms->i1_tx_size)
949
109k
                    : 1;
950
109k
        }
951
952
109k
        if((i4_mb_quard1_part_x > 0) && (i4_mb_quard1_part_y > 0))
953
109k
        {
954
109k
            pi1_ref_mb_modes_incr_temp =
955
109k
                pi1_ref_mb_modes_incr + (i4_ref_mode_stride * i4_element_size) + i4_element_size;
956
109k
            ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
957
109k
            i1_mb_mode_q3 = ps_inter_lyr_mb_prms->i1_mb_mode;
958
109k
            i4_tx_size_q3 =
959
109k
                (i1_mb_mode_q3 <= SVC_INTER_MB)
960
109k
                    ? ((ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1
961
103k
                                                              : ps_inter_lyr_mb_prms->i1_tx_size)
962
109k
                    : 1;
963
109k
        }
964
965
109k
        do
966
436k
        {
967
436k
            WORD32 i4_idx;
968
436k
            WORD32 i4_wd, i4_ht;
969
436k
            WORD32 i4_max_pos_x, i4_max_pos_y;
970
971
436k
            i4_prev_x = i4_x;
972
436k
            i4_x_ref = i4_x_offset + i4_x;
973
436k
            i4_y_ref = i4_y_offset + i4_y;
974
436k
            i4_tx_size = i4_tx_size_q0;
975
436k
            if(i4_x >= i4_mb_quard1_part_x)
976
144k
            {
977
144k
                if(i4_y < i4_mb_quard1_part_y)
978
83.5k
                {
979
83.5k
                    i4_tx_size = i4_tx_size_q1;
980
83.5k
                }
981
60.7k
                else if(i4_y >= i4_mb_quard1_part_y)
982
60.7k
                {
983
60.7k
                    i4_tx_size = i4_tx_size_q3;
984
60.7k
                }
985
144k
            }
986
292k
            else if(i4_x < i4_mb_quard1_part_x)
987
292k
            {
988
292k
                if(i4_y >= i4_mb_quard1_part_y)
989
123k
                {
990
123k
                    i4_tx_size = i4_tx_size_q2;
991
123k
                }
992
292k
            }
993
994
            /* Get the transform size as 4 or 8 */
995
436k
            i4_trans_size = ((i4_tx_size + 1) << 2);
996
436k
            i4_const_val = i4_trans_size - 1;
997
436k
            i4_and_const = i4_const_val;
998
999
            /* Fill horizontal tx block edges of current reference mb with 0 */
1000
436k
            pu1_incr_x = pu1_ref_x_ptr_incr + i4_x;
1001
436k
            pu1_incr_x += (i4_y * i4_refary_wd);
1002
436k
            i4_ht = (16 - (i4_y_ref & 0xF));
1003
436k
            i4_ht = MIN((i4_act_ary_ht - i4_y), i4_ht);
1004
1005
436k
            i4_x_idx = i4_x;
1006
436k
            i4_pos_x = i4_x_ref & 0xF;
1007
436k
            i4_max_pos_x = 16;
1008
436k
            i4_x += (16 - i4_pos_x);
1009
1010
            /* Get the transform block edge pos */
1011
436k
            i4_idx = (i4_const_val - (i4_pos_x & i4_and_const));
1012
436k
            i4_x_idx += i4_idx;
1013
1014
1.06M
            while((i4_pos_x < i4_max_pos_x) && (i4_x_idx < i4_act_ary_wd))
1015
628k
            {
1016
628k
                WORD32 i4_i;
1017
628k
                UWORD8 *pu1_incr;
1018
1019
628k
                pu1_incr = pu1_incr_x + i4_idx;
1020
4.45M
                for(i4_i = 0; i4_i < i4_ht; i4_i++)
1021
3.82M
                {
1022
                    /* Fill the block edge with 0s */
1023
3.82M
                    *pu1_incr = 0;
1024
3.82M
                    pu1_incr += i4_refary_wd;
1025
3.82M
                }
1026
1027
                /* Updates */
1028
628k
                i4_pos_x += i4_trans_size;
1029
628k
                pu1_incr_x += i4_trans_size;
1030
628k
                i4_x_idx += MIN(i4_trans_size, (i4_act_ary_wd - i4_x_idx));
1031
628k
            }
1032
1033
            /* Fill vertical tx block edges of current reference mb with 0 */
1034
436k
            pu1_incr_y = pu1_ref_y_ptr_incr + i4_prev_x;
1035
436k
            pu1_incr_y += (i4_y * i4_refary_wd);
1036
436k
            i4_wd = (16 - (i4_x_ref & 0xF));
1037
436k
            i4_wd = MIN((i4_act_ary_wd - i4_prev_x), i4_wd);
1038
436k
            i4_y_idx = i4_y;
1039
436k
            i4_pos_y = i4_y_ref & 0xF;
1040
436k
            i4_max_pos_y = 16;
1041
436k
            i4_y += (16 - i4_pos_y);
1042
1043
            /* Get the transform block edge pos */
1044
436k
            i4_idx = (i4_const_val - (i4_pos_y & i4_and_const));
1045
436k
            i4_y_idx += i4_idx;
1046
1047
1.03M
            while((i4_pos_y < i4_max_pos_y) && (i4_y_idx < i4_act_ary_ht))
1048
595k
            {
1049
595k
                WORD32 i4_i;
1050
595k
                UWORD8 *pu1_incr;
1051
1052
595k
                pu1_incr = pu1_incr_y + i4_idx * i4_refary_wd;
1053
4.38M
                for(i4_i = 0; i4_i < i4_wd; i4_i++)
1054
3.79M
                {
1055
                    /* Fill the block edge with 0s */
1056
3.79M
                    *pu1_incr = 0;
1057
3.79M
                    pu1_incr++;
1058
3.79M
                }
1059
1060
                /* Updates */
1061
595k
                i4_pos_y += i4_trans_size;
1062
595k
                pu1_incr_y += i4_trans_size * i4_refary_wd;
1063
595k
                i4_y_idx += MIN(i4_trans_size, (i4_act_ary_ht - i4_y_idx));
1064
595k
            }
1065
1066
            /* Loop updates */
1067
436k
            if(i4_x < i4_act_ary_wd)
1068
218k
            {
1069
218k
                i4_y = i4_prev_y;
1070
218k
            }
1071
218k
            else if(i4_y < i4_act_ary_ht)
1072
109k
            {
1073
109k
                i4_prev_y = i4_y;
1074
109k
                i4_x = 0;
1075
109k
            }
1076
1077
436k
        } while((i4_y < i4_act_ary_ht) || (i4_x < i4_act_ary_wd));
1078
1079
109k
    } /* End of if 0 == i4_chroma_flag */
1080
218k
    else
1081
218k
    {
1082
        /* Set the transform size as 4 */
1083
218k
        i4_trans_size = 4;
1084
218k
        i4_const_val = 3;
1085
1086
218k
        do
1087
872k
        {
1088
872k
            WORD32 i4_x_ref, i4_y_ref;
1089
872k
            WORD32 i4_idx;
1090
872k
            WORD32 i4_wd, i4_ht;
1091
872k
            WORD32 i4_max_pos_x, i4_max_pos_y;
1092
1093
872k
            i4_prev_x = i4_x;
1094
872k
            i4_x_ref = i4_x_offset + i4_x;
1095
872k
            i4_y_ref = i4_y_offset + i4_y;
1096
1097
            /* Fill horizontal tx block edges of current reference mb with 0 */
1098
872k
            pu1_incr_x = pu1_ref_x_ptr_incr + i4_x;
1099
872k
            pu1_incr_x += (i4_y * i4_refary_wd);
1100
872k
            i4_ht = (8 - (i4_y_ref & 0x7));
1101
872k
            i4_ht = MIN((i4_act_ary_ht - i4_y), i4_ht);
1102
872k
            i4_x_idx = i4_x;
1103
872k
            i4_pos_x = i4_x_ref & 0x7;
1104
872k
            i4_max_pos_x = 8;
1105
872k
            i4_x += (8 - i4_pos_x);
1106
1107
            /* Get the transform block edge pos */
1108
872k
            i4_idx = (i4_const_val - (i4_pos_x & 0x3));
1109
872k
            i4_x_idx += i4_idx;
1110
1111
1.59M
            while((i4_pos_x < i4_max_pos_x) && (i4_x_idx < i4_act_ary_wd))
1112
722k
            {
1113
722k
                WORD32 i4_i;
1114
722k
                UWORD8 *pu1_incr;
1115
1116
722k
                pu1_incr = pu1_incr_x + i4_idx;
1117
3.12M
                for(i4_i = 0; i4_i < i4_ht; i4_i++)
1118
2.40M
                {
1119
                    /* Fill the block edge with 0s */
1120
2.40M
                    *pu1_incr = 0;
1121
2.40M
                    pu1_incr += i4_refary_wd;
1122
2.40M
                }
1123
1124
                /* Updates */
1125
722k
                i4_pos_x += i4_trans_size;
1126
722k
                pu1_incr_x += i4_trans_size;
1127
722k
                i4_x_idx += MIN(i4_trans_size, (i4_act_ary_wd - i4_x_idx));
1128
722k
            }
1129
1130
            /* Fill vertical tx block edges of current reference mb with 0 */
1131
872k
            pu1_incr_y = pu1_ref_y_ptr_incr + i4_prev_x;
1132
872k
            pu1_incr_y += (i4_y * i4_refary_wd);
1133
872k
            i4_wd = (8 - (i4_x_ref & 0x7));
1134
872k
            i4_wd = MIN((i4_act_ary_wd - i4_prev_x), i4_wd);
1135
872k
            i4_y_idx = i4_y;
1136
872k
            i4_pos_y = i4_y_ref & 0x7;
1137
872k
            i4_max_pos_y = 8;
1138
872k
            i4_y += (8 - i4_pos_y);
1139
1140
            /* Get the transform block edge pos */
1141
872k
            i4_idx = (i4_const_val - (i4_pos_y & 0x3));
1142
872k
            i4_y_idx += i4_idx;
1143
1144
1.59M
            while((i4_pos_y < i4_max_pos_y) && (i4_y_idx < i4_act_ary_ht))
1145
724k
            {
1146
724k
                WORD32 i4_i;
1147
724k
                UWORD8 *pu1_incr;
1148
1149
724k
                pu1_incr = pu1_incr_y + i4_idx * i4_refary_wd;
1150
3.13M
                for(i4_i = 0; i4_i < i4_wd; i4_i++)
1151
2.40M
                {
1152
                    /* Fill the block edge with 0s */
1153
2.40M
                    *pu1_incr = 0;
1154
2.40M
                    pu1_incr++;
1155
2.40M
                }
1156
1157
                /* Updates */
1158
724k
                i4_pos_y += i4_trans_size;
1159
724k
                pu1_incr_y += i4_trans_size * i4_refary_wd;
1160
724k
                i4_y_idx += MIN(i4_trans_size, (i4_act_ary_ht - i4_y_idx));
1161
724k
            }
1162
1163
            /* Loop updates */
1164
872k
            if(i4_x < i4_act_ary_wd)
1165
436k
            {
1166
436k
                i4_y = i4_prev_y;
1167
436k
            }
1168
436k
            else if(i4_y < i4_act_ary_ht)
1169
218k
            {
1170
218k
                i4_prev_y = i4_y;
1171
218k
                i4_x = 0;
1172
218k
            }
1173
1174
872k
        } while((i4_y < i4_act_ary_ht) || (i4_x < i4_act_ary_wd));
1175
1176
218k
    } /* End of chroma */
1177
327k
    return OK;
1178
1179
327k
} /* 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
49.2k
{
1187
49.2k
    WORD32 i4_x_ref, i4_y_ref;
1188
49.2k
    WORD32 i4_x, i4_y;
1189
49.2k
    WORD32 i4_ref_mb_type;
1190
49.2k
    WORD16 *pi2_ref_data_byte;
1191
49.2k
    WORD16 *pi2_ref_array_temp;
1192
1193
461k
    for(i4_y = 0; i4_y < i4_refarray_ht; i4_y++)
1194
412k
    {
1195
4.06M
        for(i4_x = 0; i4_x < i4_refarray_wd; i4_x++)
1196
3.65M
        {
1197
3.65M
            i4_y_ref = i4_y;
1198
3.65M
            i4_x_ref = i4_x;
1199
1200
3.65M
            i4_ref_mb_type = i4_ref_mb_type_q0;
1201
3.65M
            if(i4_x >= i4_mb_quard1_part_x)
1202
1.82M
            {
1203
1.82M
                if(i4_y < i4_mb_quard1_part_y)
1204
931k
                {
1205
931k
                    i4_ref_mb_type = i4_ref_mb_type_q1;
1206
931k
                }
1207
896k
                else if(i4_y >= i4_mb_quard1_part_y)
1208
896k
                {
1209
896k
                    i4_ref_mb_type = i4_ref_mb_type_q3;
1210
896k
                }
1211
1.82M
            }
1212
1.82M
            else if(i4_x < i4_mb_quard1_part_x)
1213
1.82M
            {
1214
1.82M
                if(i4_y >= i4_mb_quard1_part_y)
1215
896k
                {
1216
896k
                    i4_ref_mb_type = i4_ref_mb_type_q2;
1217
896k
                }
1218
1.82M
            }
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.65M
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1229
3.65M
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1230
1231
            /* extract the residual value and fill the buffer */
1232
3.65M
            if(SVC_INTER_MB == i4_ref_mb_type)
1233
3.27M
            {
1234
                /* derive the reference data pointers */
1235
3.27M
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1236
3.27M
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1237
1238
                /* store the residual value */
1239
3.27M
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1240
3.27M
            }
1241
378k
            else
1242
378k
            {
1243
                /* if non inter MB then store the 0 */
1244
378k
                *pi2_ref_array_temp = 0;
1245
378k
            }
1246
3.65M
        }
1247
412k
    }
1248
49.2k
}
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
238k
{
1259
238k
    WORD32 i4_x_ref, i4_y_ref;
1260
238k
    WORD32 i4_x, i4_y;
1261
238k
    WORD16 *pi2_ref_data_byte;
1262
238k
    WORD16 *pi2_ref_array_temp;
1263
1264
    /*Quard 0*/
1265
1.63M
    for(i4_y = 0; i4_y < i4_mb_quard1_part_y; i4_y++)
1266
1.39M
    {
1267
14.3M
        for(i4_x = 0; i4_x < i4_mb_quard1_part_x; i4_x++)
1268
12.9M
        {
1269
12.9M
            i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, i4_y + i4_y_offset));
1270
12.9M
            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
12.9M
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1281
12.9M
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1282
1283
            /* extract the residual value and fill the buffer */
1284
12.9M
            if(SVC_INTER_MB == i4_ref_mb_type_q0)
1285
12.5M
            {
1286
                /* input pointer will be pointing to (xoffset,yoffset) */
1287
                /* So subtract the correction to reference location    */
1288
12.5M
                if(0 <= i4_x_offset)
1289
5.58M
                {
1290
                    /* if only inside frame dimension */
1291
5.58M
                    i4_x_ref = i4_x_ref - i4_x_offset;
1292
5.58M
                }
1293
1294
12.5M
                if(0 <= i4_y_offset)
1295
8.19M
                {
1296
                    /* if only inside frame dimension */
1297
8.19M
                    i4_y_ref = i4_y_ref - i4_y_offset;
1298
8.19M
                }
1299
                /* derive the reference data pointers */
1300
1301
12.5M
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1302
12.5M
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1303
1304
                /* store the residual value */
1305
12.5M
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1306
12.5M
            }
1307
362k
            else
1308
362k
            {
1309
                /* if non inter MB then store the 0 */
1310
362k
                *pi2_ref_array_temp = 0;
1311
362k
            }
1312
12.9M
        }
1313
1.39M
    }
1314
1315
    /*Quard 1*/
1316
1.63M
    for(i4_y = 0; i4_y < i4_mb_quard1_part_y; i4_y++)
1317
1.39M
    {
1318
3.02M
        for(i4_x = i4_mb_quard1_part_x; i4_x < i4_refarray_wd; i4_x++)
1319
1.63M
        {
1320
1.63M
            i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, i4_y + i4_y_offset));
1321
1.63M
            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.63M
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1332
1.63M
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1333
1334
            /* extract the residual value and fill the buffer */
1335
1.63M
            if(SVC_INTER_MB == i4_ref_mb_type_q1)
1336
1.51M
            {
1337
                /* input pointer will be pointing to (xoffset,yoffset) */
1338
                /* So subtract the correction to reference location    */
1339
1.51M
                if(0 <= i4_x_offset)
1340
1.51M
                {
1341
                    /* if only inside frame dimension */
1342
1.51M
                    i4_x_ref = i4_x_ref - i4_x_offset;
1343
1.51M
                }
1344
1.51M
                if(0 <= i4_y_offset)
1345
582k
                {
1346
                    /* if only inside frame dimension */
1347
582k
                    i4_y_ref = i4_y_ref - i4_y_offset;
1348
582k
                }
1349
                /* derive the reference data pointers */
1350
1351
1.51M
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1352
1.51M
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1353
1354
                /* store the residual value */
1355
1.51M
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1356
1.51M
            }
1357
110k
            else
1358
110k
            {
1359
                /* if non inter MB then store the 0 */
1360
110k
                *pi2_ref_array_temp = 0;
1361
110k
            }
1362
1.63M
        }
1363
1.39M
    }
1364
1365
    /*Quard 2*/
1366
961k
    for(i4_y = i4_mb_quard1_part_y; i4_y < i4_refarray_ht; i4_y++)
1367
722k
    {
1368
7.99M
        for(i4_x = 0; i4_x < i4_mb_quard1_part_x; i4_x++)
1369
7.27M
        {
1370
7.27M
            i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, i4_y + i4_y_offset));
1371
7.27M
            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.27M
            pi2_ref_array_temp = pi2_ref_array + i4_x;
1382
7.27M
            pi2_ref_array_temp += i4_y * i4_refarray_wd;
1383
1384
            /* extract the residual value and fill the buffer */
1385
7.27M
            if(SVC_INTER_MB == i4_ref_mb_type_q2)
1386
7.06M
            {
1387
                /* input pointer will be pointing to (xoffset,yoffset) */
1388
                /* So subtract the correction to reference location    */
1389
7.06M
                if(0 <= i4_x_offset)
1390
2.85M
                {
1391
                    /* if only inside frame dimension */
1392
2.85M
                    i4_x_ref = i4_x_ref - i4_x_offset;
1393
2.85M
                }
1394
7.06M
                if(0 <= i4_y_offset)
1395
7.06M
                {
1396
                    /* if only inside frame dimension */
1397
7.06M
                    i4_y_ref = i4_y_ref - i4_y_offset;
1398
7.06M
                }
1399
                /* derive the reference data pointers */
1400
7.06M
                pi2_ref_data_byte = pi2_inp_data + (i4_x_ref << i4_chroma_flag);
1401
7.06M
                pi2_ref_data_byte += i4_y_ref * i4_inp_data_stride;
1402
1403
                /* store the residual value */
1404
7.06M
                *pi2_ref_array_temp = (WORD16) (*pi2_ref_data_byte);
1405
7.06M
            }
1406
208k
            else
1407
208k
            {
1408
                /* if non inter MB then store the 0 */
1409
208k
                *pi2_ref_array_temp = 0;
1410
208k
            }
1411
7.27M
        }
1412
722k
    }
1413
1414
    /*Quard 3*/
1415
961k
    for(i4_y = i4_mb_quard1_part_y; i4_y < i4_refarray_ht; i4_y++)
1416
722k
    {
1417
1.10M
        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
722k
    }
1462
238k
}
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
327k
{
1503
327k
    residual_sampling_ctxt_t *ps_ctxt;
1504
327k
    res_lyr_ctxt *ps_lyr_ctxt;
1505
327k
    WORD8 *pi1_ref_mb_modes;
1506
327k
    WORD32 i4_ref_mode_stride;
1507
327k
    WORD32 i4_element_size;
1508
327k
    WORD32 i4_ref_wd;
1509
327k
    WORD32 i4_ref_ht;
1510
327k
    WORD32 i4_x_offset;
1511
327k
    WORD32 i4_y_offset;
1512
327k
    WORD32 i4_refarray_wd;
1513
327k
    WORD32 i4_refarray_ht;
1514
327k
    WORD8 i1_edge_mb;
1515
327k
    WORD16 *pi2_ref_array;
1516
327k
    WORD32 i4_mb_sft;
1517
327k
    WORD32 i4_mb_x, i4_mb_y;
1518
327k
    WORD32 i4_mb_x_strt, i4_mb_y_strt;
1519
327k
    WORD32 i4_mb_quard1_part_x, i4_mb_quard1_part_y;
1520
327k
    WORD8 *pi1_ref_mb_modes_incr;
1521
327k
    WORD8 *pi1_ref_mb_modes_incr_temp;
1522
327k
    inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
1523
1524
327k
    WORD32 i4_mb_wd;
1525
327k
    WORD32 i4_mb_ht;
1526
327k
    WORD32 i4_x_ref, i4_y_ref;
1527
327k
    WORD32 i4_ref_mb_type_q0, i4_ref_mb_type_q1, i4_ref_mb_type_q2, i4_ref_mb_type_q3;
1528
327k
    WORD8 i1_mb_mode_q0, i1_mb_mode_q1, i1_mb_mode_q2, i1_mb_mode_q3;
1529
327k
    WORD32 ret;
1530
1531
327k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
1532
327k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1533
327k
    pi2_ref_array = ps_ctxt->pi2_refarray_buffer;
1534
1535
327k
    pi1_ref_mb_modes = (WORD8 *) ps_ref_mb_mode->pv_buffer;
1536
327k
    i4_ref_mode_stride = ps_ref_mb_mode->i4_num_element_stride;
1537
327k
    i4_element_size = ps_ref_mb_mode->i4_element_size;
1538
1539
327k
    if(NULL == pi1_ref_mb_modes)
1540
0
    {
1541
0
        return NOT_OK;
1542
0
    }
1543
1544
327k
    i4_mb_wd = MB_WIDTH >> i4_chroma_flag;
1545
327k
    i4_mb_ht = MB_HEIGHT >> i4_chroma_flag;
1546
1547
    /* ----------------------------------------------------------------- */
1548
    /* Deriving the parameters required for further processing           */
1549
    /* ----------------------------------------------------------------- */
1550
327k
    {
1551
327k
        ref_mb_map_t *ps_x_off_len;
1552
327k
        ref_mb_map_t *ps_y_off_len;
1553
327k
        WORD32 i4_mbaddr_x;
1554
327k
        WORD32 i4_mbaddr_y;
1555
327k
        WORD32 i4_base_width;
1556
327k
        WORD32 i4_base_height;
1557
327k
        residual_samp_map_ctxt_t *ps_map_ctxt;
1558
1559
327k
        if(1 == i4_chroma_flag)
1560
218k
            ps_map_ctxt = &ps_lyr_ctxt->s_chroma_map_ctxt;
1561
109k
        else
1562
109k
            ps_map_ctxt = &ps_lyr_ctxt->s_luma_map_ctxt;
1563
1564
327k
        i4_mbaddr_y = ps_coord->u2_mb_y;
1565
327k
        i4_mbaddr_x = ps_coord->u2_mb_x;
1566
327k
        i4_base_width = ps_lyr_ctxt->i4_ref_width;
1567
327k
        i4_base_height = ps_lyr_ctxt->i4_ref_height;
1568
327k
        i4_ref_wd = i4_base_width >> i4_chroma_flag;
1569
327k
        i4_ref_ht = i4_base_height >> i4_chroma_flag;
1570
1571
        /* --------------------------------------------------------------------- */
1572
        /* Extracting information from the mapping context                       */
1573
        /* --------------------------------------------------------------------- */
1574
327k
        ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
1575
327k
        ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
1576
327k
        i4_x_offset = ps_x_off_len[i4_mbaddr_x].i2_offset;
1577
327k
        i4_y_offset = ps_y_off_len[i4_mbaddr_y].i2_offset;
1578
327k
        i4_refarray_wd = ps_x_off_len[i4_mbaddr_x].i2_length;
1579
327k
        i4_refarray_ht = ps_y_off_len[i4_mbaddr_y].i2_length;
1580
327k
    }
1581
1582
    /* Call the module to fill the increments based on transform blocks */
1583
327k
    ret = isvcd_ref_layer_ptr_incr(pi1_ref_mb_modes, i4_ref_mode_stride, i4_element_size,
1584
327k
                                   i4_x_offset, i4_y_offset, i4_refarray_wd, i4_refarray_ht,
1585
327k
                                   ps_ctxt->pu1_ref_x_ptr_incr, ps_ctxt->pu1_ref_y_ptr_incr,
1586
327k
                                   i4_chroma_flag);
1587
1588
327k
    if(ret != OK)
1589
0
    {
1590
0
        return ret;
1591
0
    }
1592
327k
    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
327k
    i4_y_ref = MAX(0, MIN(i4_ref_ht - 1, 0 + i4_y_offset));
1599
327k
    i4_x_ref = MAX(0, MIN(i4_ref_wd - 1, 0 + i4_x_offset));
1600
327k
    i4_mb_x_strt = i4_x_ref % i4_mb_wd;
1601
327k
    i4_mb_y_strt = i4_y_ref % i4_mb_ht;
1602
1603
327k
    i4_mb_quard1_part_x = i4_mb_wd - i4_mb_x_strt;
1604
327k
    i4_mb_quard1_part_y = i4_mb_ht - i4_mb_y_strt;
1605
327k
    if(!(i4_mb_quard1_part_x >= 0))
1606
0
    {
1607
0
        return NOT_OK;
1608
0
    }
1609
327k
    if(!(i4_mb_quard1_part_y >= 0))
1610
0
    {
1611
0
        return NOT_OK;
1612
0
    }
1613
1614
327k
    i4_mb_x = (i4_x_ref >> i4_mb_sft);
1615
327k
    i4_mb_y = (i4_y_ref >> i4_mb_sft);
1616
1617
    /* get the location of the byte which has the current mb mode */
1618
327k
    pi1_ref_mb_modes_incr = pi1_ref_mb_modes + (i4_mb_y * i4_ref_mode_stride * i4_element_size);
1619
327k
    pi1_ref_mb_modes_incr += (i4_mb_x * i4_element_size);
1620
327k
    ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr;
1621
327k
    i1_mb_mode_q0 = ps_inter_lyr_mb_prms->i1_mb_mode;
1622
327k
    i1_mb_mode_q1 = i1_mb_mode_q0;
1623
327k
    i1_mb_mode_q2 = i1_mb_mode_q0;
1624
327k
    i1_mb_mode_q3 = i1_mb_mode_q0;
1625
1626
327k
    pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr;
1627
327k
    if(i4_mb_quard1_part_x > 0)
1628
327k
    {
1629
327k
        pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr + i4_element_size;
1630
327k
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
1631
327k
        i1_mb_mode_q1 = ps_inter_lyr_mb_prms->i1_mb_mode;
1632
327k
    }
1633
1634
327k
    if(i4_mb_quard1_part_y > 0)
1635
327k
    {
1636
327k
        pi1_ref_mb_modes_incr_temp = pi1_ref_mb_modes_incr + (i4_ref_mode_stride * i4_element_size);
1637
327k
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
1638
327k
        i1_mb_mode_q2 = ps_inter_lyr_mb_prms->i1_mb_mode;
1639
327k
    }
1640
1641
327k
    if((i4_mb_quard1_part_x > 0) && (i4_mb_quard1_part_y > 0))
1642
327k
    {
1643
327k
        pi1_ref_mb_modes_incr_temp =
1644
327k
            pi1_ref_mb_modes_incr + (i4_ref_mode_stride * i4_element_size) + i4_element_size;
1645
327k
        ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) pi1_ref_mb_modes_incr_temp;
1646
327k
        i1_mb_mode_q3 = ps_inter_lyr_mb_prms->i1_mb_mode;
1647
327k
    }
1648
1649
327k
    i4_ref_mb_type_q0 = (i1_mb_mode_q0 <= SVC_INTER_MB) ? SVC_INTER_MB : SVC_INTRA_MB;
1650
327k
    i4_ref_mb_type_q1 = (i1_mb_mode_q1 <= SVC_INTER_MB) ? SVC_INTER_MB : SVC_INTRA_MB;
1651
327k
    i4_ref_mb_type_q2 = (i1_mb_mode_q2 <= SVC_INTER_MB) ? SVC_INTER_MB : SVC_INTRA_MB;
1652
327k
    i4_ref_mb_type_q3 = (i1_mb_mode_q3 <= SVC_INTER_MB) ? SVC_INTER_MB : SVC_INTRA_MB;
1653
1654
327k
    i1_edge_mb = (ps_coord->u2_mb_x == 0 || ps_coord->u2_mb_y == 0 ||
1655
182k
                  (ps_coord->u2_mb_x == ((ps_lyr_ctxt->i4_curr_width >> MB_WIDTH_SHIFT) - 1)) ||
1656
95.6k
                  (ps_coord->u2_mb_y == ((ps_lyr_ctxt->i4_curr_height >> MB_HEIGHT_SHIFT) - 1)));
1657
327k
    if(i1_edge_mb)
1658
238k
    {
1659
238k
        ps_ctxt->pf_residual_reflayer_const_boundary_mb(
1660
238k
            pi2_inp_data, i4_inp_data_stride, pi2_ref_array, i4_refarray_wd, i4_refarray_ht,
1661
238k
            i4_ref_wd, i4_ref_ht, i4_x_offset, i4_y_offset, i4_ref_mb_type_q0, i4_ref_mb_type_q1,
1662
238k
            i4_ref_mb_type_q2, i4_ref_mb_type_q3, i4_mb_quard1_part_x, i4_mb_quard1_part_y,
1663
238k
            i4_chroma_flag);
1664
238k
    }
1665
88.4k
    else
1666
88.4k
    {
1667
88.4k
        ps_ctxt->pf_residual_reflayer_const_non_boundary_mb(
1668
88.4k
            pi2_inp_data, i4_inp_data_stride, pi2_ref_array, i4_refarray_wd, i4_refarray_ht,
1669
88.4k
            i4_ref_mb_type_q0, i4_ref_mb_type_q1, i4_ref_mb_type_q2, i4_ref_mb_type_q3,
1670
88.4k
            i4_mb_quard1_part_x, i4_mb_quard1_part_y, i4_chroma_flag);
1671
88.4k
    }
1672
    /* store the values into the place holders */
1673
327k
    *pi4_refarr_wd = i4_refarray_wd;
1674
1675
327k
    return OK;
1676
327k
}
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
180k
{
1710
180k
    residual_sampling_ctxt_t *ps_ctxt;
1711
180k
    residual_samp_map_ctxt_t *ps_map_ctxt;
1712
180k
    res_lyr_ctxt *ps_lyr_ctxt;
1713
180k
    ref_pixel_map_t *ps_x_pos_phase;
1714
180k
    ref_pixel_map_t *ps_y_pos_phase;
1715
1716
180k
    WORD32 i4_x, i4_y;
1717
180k
    WORD32 i4_frm_mb_x, i4_frm_mb_y;
1718
180k
    WORD32 i4_temp_array_ht;
1719
180k
    WORD32 i4_mb_wd;
1720
180k
    WORD32 i4_mb_ht;
1721
180k
    WORD16 *pi2_ref_array;
1722
180k
    UWORD8 *pu1_ref_x_ptr_incr, *pu1_ref_y_ptr_incr;
1723
1724
180k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
1725
180k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1726
180k
    pi2_ref_array = ps_ctxt->pi2_refarray_buffer;
1727
180k
    pu1_ref_x_ptr_incr = ps_ctxt->pu1_ref_x_ptr_incr;
1728
180k
    pu1_ref_y_ptr_incr = ps_ctxt->pu1_ref_y_ptr_incr;
1729
1730
    /* --------------------------------------------------------------------- */
1731
    /* Extracting information from the mapping context                       */
1732
    /* --------------------------------------------------------------------- */
1733
180k
    if(1 == i4_chroma_flag)
1734
120k
        ps_map_ctxt = &ps_lyr_ctxt->s_chroma_map_ctxt;
1735
60.1k
    else
1736
60.1k
        ps_map_ctxt = &ps_lyr_ctxt->s_luma_map_ctxt;
1737
1738
180k
    i4_mb_wd = MB_WIDTH >> i4_chroma_flag;
1739
180k
    i4_mb_ht = MB_HEIGHT >> i4_chroma_flag;
1740
1741
180k
    ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase;
1742
180k
    ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase;
1743
180k
    i4_temp_array_ht = i4_mb_ht;
1744
180k
    i4_frm_mb_y = u2_mb_y * i4_mb_ht;
1745
180k
    i4_frm_mb_x = u2_mb_x * i4_mb_wd;
1746
1747
    /* --------------------------------------------------------------------- */
1748
    /* Loop for interpolation                                                */
1749
    /* --------------------------------------------------------------------- */
1750
2.10M
    for(i4_y = 0; i4_y < (i4_temp_array_ht); i4_y++)
1751
1.92M
    {
1752
25.0M
        for(i4_x = 0; i4_x < (i4_mb_wd); i4_x++)
1753
23.1M
        {
1754
23.1M
            WORD32 i4_i;
1755
23.1M
            WORD32 i4_y_ref;
1756
23.1M
            WORD32 i4_y_phase;
1757
23.1M
            WORD32 i4_x_ref;
1758
23.1M
            WORD32 i4_x_phase;
1759
23.1M
            WORD32 i4_x_ref_round;
1760
23.1M
            WORD16 *pi2_out_curr;
1761
23.1M
            WORD32 ai4_temp_pred[2] = {0};
1762
23.1M
            UWORD8 *pu1_ref_y_ptr_incr_temp;
1763
23.1M
            WORD32 *pi4_temp_pred;
1764
23.1M
            UWORD8 u1_incr_y;
1765
23.1M
            WORD16 i2_res;
1766
1767
            /* derive the current output pointer */
1768
23.1M
            pi2_out_curr = pi2_out + (i4_x << i4_chroma_flag) + (i4_y * i4_out_stride);
1769
1770
            /* -------------------------------------------------------------- */
1771
            /* Finding the offset                                             */
1772
            /* -------------------------------------------------------------- */
1773
23.1M
            i4_y_ref = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_ref_pos;
1774
23.1M
            i4_y_phase = ps_y_pos_phase[i4_y + i4_frm_mb_y].i2_phase;
1775
23.1M
            i4_x_ref = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_ref_pos;
1776
23.1M
            i4_x_phase = ps_x_pos_phase[i4_x + i4_frm_mb_x].i2_phase;
1777
1778
            /* horizontal processing*/
1779
69.3M
            for(i4_i = 0; i4_i < 2; i4_i++)
1780
46.2M
            {
1781
46.2M
                UWORD8 *pu1_ref_x_ptr_incr_temp;
1782
46.2M
                UWORD8 u1_incr;
1783
46.2M
                WORD16 *pi2_ref_array_1, *pi2_ref_array_2;
1784
1785
                /* derive appropriate pointers */
1786
46.2M
                pu1_ref_x_ptr_incr_temp = pu1_ref_x_ptr_incr + i4_x_ref;
1787
46.2M
                pu1_ref_x_ptr_incr_temp += ((i4_y_ref + i4_i) * i4_refarray_wd);
1788
46.2M
                u1_incr = *pu1_ref_x_ptr_incr_temp;
1789
46.2M
                pi2_ref_array_1 = pi2_ref_array + i4_x_ref;
1790
46.2M
                pi2_ref_array_1 += ((i4_y_ref + i4_i) * i4_refarray_wd);
1791
1792
46.2M
                if(!u1_incr)
1793
15.0M
                {
1794
15.0M
                    pi2_ref_array_1 += (i4_x_phase >> 3);
1795
15.0M
                }
1796
1797
46.2M
                pi2_ref_array_2 = pi2_ref_array_1 + u1_incr;
1798
46.2M
                ai4_temp_pred[i4_i] =
1799
46.2M
                    (16 - i4_x_phase) * (*pi2_ref_array_1) + i4_x_phase * (*pi2_ref_array_2);
1800
46.2M
            }
1801
1802
            /* vertical processing */
1803
23.1M
            i4_x_ref_round = (i4_x_ref + (i4_x_phase >> 3));
1804
23.1M
            pu1_ref_y_ptr_incr_temp =
1805
23.1M
                pu1_ref_y_ptr_incr + i4_x_ref_round + (i4_y_ref * i4_refarray_wd);
1806
23.1M
            u1_incr_y = *pu1_ref_y_ptr_incr_temp;
1807
1808
23.1M
            pi4_temp_pred = &ai4_temp_pred[0];
1809
23.1M
            if(!u1_incr_y)
1810
7.51M
            {
1811
7.51M
                pi4_temp_pred += (i4_y_phase >> 3);
1812
7.51M
            }
1813
1814
23.1M
            i2_res = (((16 - i4_y_phase) * pi4_temp_pred[0] +
1815
23.1M
                       i4_y_phase * pi4_temp_pred[u1_incr_y] + 128) >>
1816
23.1M
                      8);
1817
1818
            /* store back the final residual */
1819
23.1M
            *pi2_out_curr = i2_res;
1820
23.1M
        } /* end of loop over width */
1821
1.92M
    }     /* end of loop over height */
1822
1823
180k
    return;
1824
180k
} /* 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
109k
{
1860
    /* --------------------------------------------------------------------- */
1861
    /* I/O buffer params                                                     */
1862
    /* --------------------------------------------------------------------- */
1863
109k
    residual_sampling_ctxt_t *ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
1864
109k
    WORD16 *pi2_inp;
1865
109k
    WORD16 *pi2_out;
1866
109k
    WORD32 i4_inp_stride;
1867
109k
    WORD32 i4_out_stride;
1868
109k
    WORD32 i4_refarray_wd;
1869
109k
    mb_coord_t s_mb_coord = {0};
1870
109k
    WORD32 ret;
1871
109k
    s_mb_coord.u2_mb_x = u2_mb_x;
1872
109k
    s_mb_coord.u2_mb_y = u2_mb_y;
1873
1874
    /* --------------------------------------------------------------------- */
1875
    /* LUMA PROCESSING                                                        */
1876
    /* --------------------------------------------------------------------- */
1877
109k
    pi2_inp = (WORD16 *) ps_ref_luma->pv_buffer;
1878
109k
    pi2_out = (WORD16 *) ps_out_luma->pv_buffer;
1879
109k
    i4_inp_stride = ps_ref_luma->i4_num_element_stride;
1880
109k
    i4_out_stride = ps_out_luma->i4_num_element_stride;
1881
1882
    /* ------- Constructing refSampleArray ----------------------- */
1883
109k
    ret = isvcd_residual_reflayer_const(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
1884
109k
                                        ps_ref_mb_mode, &i4_refarray_wd, &s_mb_coord, 0);
1885
1886
109k
    if(ret != OK) return ret;
1887
    /* ---- Interpolation process for Residual prediction     ------ */
1888
109k
    ps_ctxt->pf_interpolate_residual(pv_residual_samp_ctxt, pi2_out, i4_out_stride, i4_refarray_wd,
1889
109k
                                     s_mb_coord.u2_mb_x, s_mb_coord.u2_mb_y, 0);
1890
1891
    /* --------------------------------------------------------------------- */
1892
    /* CHROMA PROCESSING                                                       */
1893
    /* --------------------------------------------------------------------- */
1894
    /* CB */
1895
109k
    pi2_inp = (WORD16 *) ps_ref_chroma->pv_buffer;
1896
109k
    pi2_out = (WORD16 *) ps_out_chroma->pv_buffer;
1897
109k
    i4_inp_stride = ps_ref_chroma->i4_num_element_stride;
1898
109k
    i4_out_stride = ps_out_chroma->i4_num_element_stride;
1899
1900
    /* ------- Constructing refSampleArray ----------------------- */
1901
109k
    ret = isvcd_residual_reflayer_const(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
1902
109k
                                        ps_ref_mb_mode, &i4_refarray_wd, &s_mb_coord, 1);
1903
1904
109k
    if(ret != OK) return ret;
1905
    /* ---- Interpolation process for Residual prediction     ------ */
1906
109k
    ps_ctxt->pf_interpolate_residual(pv_residual_samp_ctxt, pi2_out, i4_out_stride, i4_refarray_wd,
1907
109k
                                     s_mb_coord.u2_mb_x, s_mb_coord.u2_mb_y, 1);
1908
1909
    /* CR */
1910
109k
    pi2_inp += 1;
1911
109k
    pi2_out += 1;
1912
1913
    /* ------- Constructing refSampleArray ----------------------- */
1914
109k
    ret = isvcd_residual_reflayer_const(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
1915
109k
                                        ps_ref_mb_mode, &i4_refarray_wd, &s_mb_coord, 1);
1916
1917
109k
    if(ret != OK) return ret;
1918
    /* ---- Interpolation process for Residual prediction --------- */
1919
109k
    ps_ctxt->pf_interpolate_residual(pv_residual_samp_ctxt, pi2_out, i4_out_stride, i4_refarray_wd,
1920
109k
                                     s_mb_coord.u2_mb_x, s_mb_coord.u2_mb_y, 1);
1921
109k
    return OK;
1922
109k
}
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
57.2k
{
1958
57.2k
    residual_sampling_ctxt_t *ps_ctxt;
1959
57.2k
    res_lyr_ctxt *ps_lyr_ctxt;
1960
    /* --------------------------------------------------------------------- */
1961
    /* I/O buffer params                                                     */
1962
    /* --------------------------------------------------------------------- */
1963
57.2k
    WORD16 *pi2_inp;
1964
57.2k
    WORD16 *pi2_out;
1965
57.2k
    WORD32 i4_inp_stride;
1966
57.2k
    WORD32 i4_out_stride;
1967
57.2k
    WORD32 i4_luma_nnz;
1968
57.2k
    WORD32 i4_chroma_nnz;
1969
57.2k
    WORD32 i4_tx_size;
1970
1971
57.2k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
1972
57.2k
    ps_lyr_ctxt = &ps_ctxt->as_res_lyrs[ps_ctxt->i4_res_lyr_id];
1973
1974
    /* --------------------------------------------------------------------- */
1975
    /* LUMA PROCESSING                                                        */
1976
    /* --------------------------------------------------------------------- */
1977
57.2k
    pi2_inp = (WORD16 *) ps_ref_luma->pv_buffer;
1978
57.2k
    pi2_out = (WORD16 *) ps_out_luma->pv_buffer;
1979
57.2k
    i4_inp_stride = ps_ref_luma->i4_num_element_stride;
1980
57.2k
    i4_out_stride = ps_out_luma->i4_num_element_stride;
1981
1982
57.2k
    {
1983
57.2k
        WORD32 i4_offset_x, i4_offset_y;
1984
57.2k
        residual_samp_map_ctxt_t *ps_luma_map;
1985
57.2k
        ref_mb_map_t *ps_x_off_len_luma;
1986
57.2k
        ref_mb_map_t *ps_y_off_len_luma;
1987
1988
57.2k
        ps_luma_map = &ps_lyr_ctxt->s_luma_map_ctxt;
1989
57.2k
        ps_x_off_len_luma = ps_luma_map->ps_x_offset_length;
1990
57.2k
        ps_y_off_len_luma = ps_luma_map->ps_y_offset_length;
1991
1992
        /* get the actual offset for the buffers */
1993
57.2k
        i4_offset_x = ps_x_off_len_luma[u2_mb_x].i2_offset;
1994
57.2k
        i4_offset_y = ps_y_off_len_luma[u2_mb_y].i2_offset;
1995
1996
57.2k
        {
1997
57.2k
            inter_lyr_mb_prms_t *ps_inter_lyr_mb_prms;
1998
57.2k
            WORD32 i4_mb_x, i4_mb_y;
1999
57.2k
            UWORD16 u2_luma_mask = 0x0033;
2000
57.2k
            UWORD8 u1_chrm_mask = 0x11;
2001
57.2k
            WORD32 i4_luma_rt_sft_amt = 0;
2002
57.2k
            WORD32 i4_chrm_rt_sft_amt = 0;
2003
2004
57.2k
            i4_mb_x = ((i4_offset_x + 1) >> MB_WIDTH_SHIFT);
2005
57.2k
            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
57.2k
            ps_inter_lyr_mb_prms = (inter_lyr_mb_prms_t *) ps_ref_mb_mode->pv_buffer;
2009
57.2k
            ps_inter_lyr_mb_prms += i4_mb_x;
2010
57.2k
            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
57.2k
            if(0 != ((i4_offset_x + 1) & 15))
2014
29.6k
            {
2015
29.6k
                u2_luma_mask <<= 2;
2016
29.6k
                i4_luma_rt_sft_amt += 2;
2017
29.6k
                u1_chrm_mask <<= 1;
2018
29.6k
                i4_chrm_rt_sft_amt += 1;
2019
29.6k
            }
2020
            /* get the approp block in base layer in vert direction */
2021
57.2k
            if(0 != ((i4_offset_y + 1) & 15))
2022
28.0k
            {
2023
28.0k
                u2_luma_mask <<= 8;
2024
28.0k
                i4_luma_rt_sft_amt += 8;
2025
2026
28.0k
                u1_chrm_mask <<= 2;
2027
28.0k
                i4_chrm_rt_sft_amt += 2;
2028
28.0k
            }
2029
2030
            /* extract the nnz and store it */
2031
57.2k
            i4_luma_nnz = (ps_inter_lyr_mb_prms->u2_luma_nnz & u2_luma_mask) >> i4_luma_rt_sft_amt;
2032
57.2k
            i4_chroma_nnz =
2033
57.2k
                (ps_inter_lyr_mb_prms->u1_chroma_nnz & u1_chrm_mask) >> i4_chrm_rt_sft_amt;
2034
57.2k
            i4_tx_size =
2035
57.2k
                (ps_inter_lyr_mb_prms->i1_tx_size < 0) ? 1 : ps_inter_lyr_mb_prms->i1_tx_size;
2036
57.2k
        }
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
57.2k
        if(i4_offset_x >= 0)
2043
44.2k
        {
2044
44.2k
            pi2_inp++;
2045
44.2k
        }
2046
2047
57.2k
        if(i4_offset_y >= 0)
2048
51.3k
        {
2049
51.3k
            pi2_inp += i4_inp_stride;
2050
51.3k
        }
2051
2052
57.2k
        ps_ctxt->pf_residual_luma_dyadic(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride, pi2_out,
2053
57.2k
                                         i4_out_stride, ps_ref_mb_mode, u2_mb_x, u2_mb_y,
2054
57.2k
                                         i4_luma_nnz, i4_tx_size);
2055
57.2k
    }
2056
2057
    /* --------------------------------------------------------------------- */
2058
    /* CHROMA PROCESSING                                                       */
2059
    /* --------------------------------------------------------------------- */
2060
    /* CB */
2061
57.2k
    pi2_inp = (WORD16 *) ps_ref_chroma->pv_buffer;
2062
57.2k
    pi2_out = (WORD16 *) ps_out_chroma->pv_buffer;
2063
57.2k
    i4_inp_stride = ps_ref_chroma->i4_num_element_stride;
2064
57.2k
    i4_out_stride = ps_out_chroma->i4_num_element_stride;
2065
2066
    /* choose the appropriate chroma processing routine */
2067
57.2k
    if(SVCD_FALSE == ps_lyr_ctxt->i4_chrm_alt_proc)
2068
57.2k
    {
2069
57.2k
        WORD32 i4_offset_x, i4_offset_y;
2070
57.2k
        residual_samp_map_ctxt_t *ps_chroma_map;
2071
57.2k
        ref_mb_map_t *ps_x_off_len_chroma;
2072
57.2k
        ref_mb_map_t *ps_y_off_len_chroma;
2073
2074
57.2k
        ps_chroma_map = &ps_lyr_ctxt->s_chroma_map_ctxt;
2075
57.2k
        ps_x_off_len_chroma = ps_chroma_map->ps_x_offset_length;
2076
57.2k
        ps_y_off_len_chroma = ps_chroma_map->ps_y_offset_length;
2077
2078
        /* get the actual offset for the buffers */
2079
57.2k
        i4_offset_x = ps_x_off_len_chroma[u2_mb_x].i2_offset;
2080
57.2k
        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
57.2k
        if(i4_offset_x >= 0)
2087
44.2k
        {
2088
44.2k
            pi2_inp += 2;
2089
44.2k
        }
2090
2091
57.2k
        if(i4_offset_y >= 0)
2092
51.3k
        {
2093
51.3k
            pi2_inp += i4_inp_stride;
2094
51.3k
        }
2095
2096
57.2k
        if(0 != (i4_chroma_nnz & 0x01))
2097
871
        {
2098
871
            ps_ctxt->pf_residual_chroma_dyadic(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
2099
871
                                               pi2_out, i4_out_stride);
2100
871
        }
2101
57.2k
    }
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
57.2k
    pi2_inp += 1;
2111
57.2k
    pi2_out += 1;
2112
2113
57.2k
    if(SVCD_FALSE == ps_lyr_ctxt->i4_chrm_alt_proc)
2114
57.2k
    {
2115
57.2k
        if(0 != (i4_chroma_nnz & 0x10))
2116
1.14k
        {
2117
1.14k
            ps_ctxt->pf_residual_chroma_dyadic(pv_residual_samp_ctxt, pi2_inp, i4_inp_stride,
2118
1.14k
                                               pi2_out, i4_out_stride);
2119
1.14k
        }
2120
57.2k
    }
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
57.2k
    return OK;
2128
57.2k
}
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.2k
{
2158
    /* --------------------------------------------------------------------- */
2159
    /* Local variables required for finding the mapping between the layers     */
2160
    /* --------------------------------------------------------------------- */
2161
68.2k
    UWORD32 u4_shift_x;
2162
68.2k
    UWORD32 u4_shift_y;
2163
68.2k
    UWORD32 u4_scale_x;
2164
68.2k
    UWORD32 u4_scale_y;
2165
68.2k
    WORD32 i4_offset_x;
2166
68.2k
    WORD32 i4_offset_y;
2167
68.2k
    WORD32 i4_add_x;
2168
68.2k
    WORD32 i4_add_y;
2169
68.2k
    WORD32 i4_delta_x;
2170
68.2k
    WORD32 i4_delta_y;
2171
68.2k
    WORD32 i4_refphase_x;
2172
68.2k
    WORD32 i4_refphase_y;
2173
68.2k
    WORD32 i4_phase_x;
2174
68.2k
    WORD32 i4_phase_y;
2175
68.2k
    WORD32 i4_sub_wd;
2176
68.2k
    WORD32 i4_sub_ht;
2177
68.2k
    WORD32 i4_mb_wd;
2178
68.2k
    WORD32 i4_mb_ht;
2179
    /* --------------------------------------------------------------------- */
2180
    /* Local Pointer Declaration for arrays in Mapping context                 */
2181
    /* --------------------------------------------------------------------- */
2182
68.2k
    ref_mb_map_t *ps_x_off_len;
2183
68.2k
    ref_mb_map_t *ps_y_off_len;
2184
68.2k
    UWORD32 i4_ref_wd;
2185
68.2k
    UWORD32 i4_ref_ht;
2186
68.2k
    UWORD32 i4_scaled_wd;
2187
68.2k
    UWORD32 i4_scaled_ht;
2188
68.2k
    WORD32 i4_curr_lyr_width;
2189
68.2k
    WORD32 i4_curr_lyr_height;
2190
2191
    /* --------------------------------------------------------------------- */
2192
    /* Local Flag Declaration                                                 */
2193
    /* --------------------------------------------------------------------- */
2194
68.2k
    WORD32 i4_ref_layer_field_pic_flag;
2195
68.2k
    WORD32 i4_field_pic_flag;
2196
68.2k
    WORD32 i4_frame_mbs_only_flag;
2197
68.2k
    WORD32 i4_ref_layer_frame_Mbs_only_flag;
2198
68.2k
    WORD32 i4_field_Mb_flag;
2199
68.2k
    WORD32 i4_bot_field_flag;
2200
2201
    /* --------------------------------------------------------------------- */
2202
    /* Cropping Parameters Declaration                                         */
2203
    /* --------------------------------------------------------------------- */
2204
68.2k
    WORD32 i4_scaled_ref_layer_left_offset;
2205
68.2k
    WORD32 i4_scaled_ref_layer_top_offset;
2206
2207
    /* --------------------------------------------------------------------- */
2208
    /* Hardcoding flag information    (assuming no field support) */
2209
    /* --------------------------------------------------------------------- */
2210
68.2k
    i4_ref_layer_field_pic_flag = SVCD_FALSE;
2211
68.2k
    i4_field_pic_flag = SVCD_FALSE;
2212
68.2k
    i4_frame_mbs_only_flag = SVCD_TRUE;
2213
68.2k
    i4_field_Mb_flag = SVCD_FALSE;
2214
68.2k
    i4_bot_field_flag = SVCD_FALSE;
2215
68.2k
    i4_ref_layer_frame_Mbs_only_flag = SVCD_TRUE;
2216
2217
    /* --------------------------------------------------------------------- */
2218
    /* Pointer and Paramater are intialized    - Chroma and Luma */
2219
    /* --------------------------------------------------------------------- */
2220
68.2k
    {
2221
68.2k
        WORD32 i4_base_width;
2222
68.2k
        WORD32 i4_base_height;
2223
68.2k
        WORD32 i4_ref_layer_chroma_phase_x_plus1_flag;
2224
68.2k
        WORD32 i4_ref_layer_chroma_phase_y_plus1;
2225
68.2k
        WORD32 i4_chroma_phase_x_plus1_flag;
2226
68.2k
        WORD32 i4_chroma_phase_y_plus1;
2227
2228
        /* ------------------------------------------------------------- */
2229
        /* HARD CODED FOR 420                                             */
2230
        /* ------------------------------------------------------------- */
2231
68.2k
        WORD32 i4_sub_wd_chroma = 2;
2232
68.2k
        WORD32 i4_sub_ht_chroma = 2;
2233
2234
68.2k
        i4_base_width = ps_ref_res_prms->i4_res_width;
2235
68.2k
        i4_base_height = ps_ref_res_prms->i4_res_height;
2236
2237
68.2k
        i4_ref_layer_chroma_phase_x_plus1_flag =
2238
68.2k
            ps_curr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag;
2239
68.2k
        i4_ref_layer_chroma_phase_y_plus1 = ps_curr_res_prms->i1_ref_lyr_chroma_phase_y_plus1;
2240
68.2k
        i4_chroma_phase_x_plus1_flag =
2241
68.2k
            ps_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_x_plus1_flag;
2242
68.2k
        i4_chroma_phase_y_plus1 =
2243
68.2k
            ps_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_y_plus1;
2244
68.2k
        i4_scaled_ref_layer_left_offset = ps_curr_res_prms->s_ref_lyr_scaled_offset.i2_left;
2245
68.2k
        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.2k
        i4_ref_wd = (i4_base_width >> i4_chroma_flag);
2251
68.2k
        i4_ref_ht = (i4_base_height >> i4_chroma_flag) * (1 + i4_ref_layer_field_pic_flag);
2252
68.2k
        i4_scaled_wd = ps_curr_res_prms->u2_scaled_ref_width;
2253
68.2k
        i4_scaled_ht = ps_curr_res_prms->u2_scaled_ref_height;
2254
68.2k
        i4_scaled_wd = (i4_scaled_wd >> i4_chroma_flag);
2255
68.2k
        i4_scaled_ht = (i4_scaled_ht >> i4_chroma_flag) * (1 + i4_field_pic_flag);
2256
2257
68.2k
        if(1 == i4_chroma_flag)
2258
34.1k
        {
2259
34.1k
            i4_refphase_x = i4_ref_layer_chroma_phase_x_plus1_flag - 1;
2260
34.1k
            i4_refphase_y = i4_ref_layer_chroma_phase_y_plus1 - 1;
2261
34.1k
            i4_phase_x = i4_chroma_phase_x_plus1_flag - 1;
2262
34.1k
            i4_phase_y = i4_chroma_phase_y_plus1 - 1;
2263
34.1k
            i4_sub_wd = i4_sub_wd_chroma;
2264
34.1k
            i4_sub_ht = i4_sub_ht_chroma;
2265
34.1k
            i4_mb_wd = MB_WIDTH >> 1;
2266
34.1k
            i4_mb_ht = MB_HEIGHT >> 1;
2267
34.1k
        }
2268
34.1k
        else
2269
34.1k
        {
2270
34.1k
            i4_refphase_x = 0;
2271
34.1k
            i4_refphase_y = 0;
2272
34.1k
            i4_phase_x = 0;
2273
34.1k
            i4_phase_y = 0;
2274
34.1k
            i4_sub_wd = 1;
2275
34.1k
            i4_sub_ht = 1;
2276
34.1k
            i4_mb_wd = MB_WIDTH;
2277
34.1k
            i4_mb_ht = MB_HEIGHT;
2278
34.1k
        }
2279
68.2k
    }
2280
2281
    /* --------------------------------------------------------------------- */
2282
    /* Derive shift x and y based on level idd                               */
2283
    /* --------------------------------------------------------------------- */
2284
68.2k
    if(ps_sps->u1_level_idc <= 30)
2285
64.3k
    {
2286
64.3k
        u4_shift_x = 16;
2287
64.3k
        u4_shift_y = 16;
2288
64.3k
    }
2289
3.92k
    else
2290
3.92k
    {
2291
3.92k
        u4_shift_x = 31 - isvcd_get_ceil_log2(i4_ref_wd);
2292
3.92k
        u4_shift_y = 31 - isvcd_get_ceil_log2(i4_ref_ht);
2293
3.92k
    }
2294
2295
    /* --------------------------------------------------------------------- */
2296
    /* The following condition is not true in our case for time being         */
2297
    /* --------------------------------------------------------------------- */
2298
68.2k
    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.2k
    u4_scale_x = ((i4_ref_wd << u4_shift_x) + (i4_scaled_wd >> 1)) / (i4_scaled_wd);
2312
2313
68.2k
    u4_scale_y = ((i4_ref_ht << u4_shift_y) + (i4_scaled_ht >> 1)) / (i4_scaled_ht);
2314
2315
68.2k
    i4_offset_x = i4_scaled_ref_layer_left_offset / i4_sub_wd;
2316
68.2k
    i4_add_x = (((i4_ref_wd * (2 + i4_phase_x)) << (u4_shift_x - 2)) + (i4_scaled_wd >> 1)) /
2317
68.2k
                   i4_scaled_wd +
2318
68.2k
               (1 << (u4_shift_x - 5));
2319
68.2k
    i4_delta_x = 4 * (2 + i4_refphase_x);
2320
2321
68.2k
    if((SVCD_TRUE == i4_frame_mbs_only_flag) && (SVCD_TRUE == i4_ref_layer_frame_Mbs_only_flag))
2322
68.2k
    {
2323
68.2k
        i4_offset_y = i4_scaled_ref_layer_top_offset / i4_sub_ht;
2324
68.2k
        i4_add_y = (((i4_ref_ht * (2 + i4_phase_y)) << (u4_shift_y - 2)) + (i4_scaled_ht >> 1)) /
2325
68.2k
                       i4_scaled_ht +
2326
68.2k
                   (1 << (u4_shift_y - 5));
2327
68.2k
        i4_delta_y = 4 * (2 + i4_refphase_y);
2328
68.2k
    }
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.2k
    ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
2342
68.2k
    ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
2343
68.2k
    i4_curr_lyr_width = ps_curr_res_prms->i4_res_width >> i4_chroma_flag;
2344
68.2k
    i4_curr_lyr_height = ps_curr_res_prms->i4_res_height >> i4_chroma_flag;
2345
2346
68.2k
    {
2347
68.2k
        WORD32 i4_i, i4_j;
2348
2349
        /* ----------------------------------------------------------------- */
2350
        /* Computation of offsetX refArrayW Xmin and Xmax Lists               */
2351
        /* ----------------------------------------------------------------- */
2352
310k
        for(i4_i = 0; i4_i < i4_curr_lyr_width; i4_i = i4_i + i4_mb_wd)
2353
241k
        {
2354
241k
            WORD32 i4_x_refmin16;
2355
241k
            WORD32 i4_x_refmax16;
2356
241k
            WORD32 i4_x_offset;
2357
2358
241k
            i4_x_refmin16 = (WORD64) (((WORD64) ((i4_i - i4_offset_x) * u4_scale_x) + i4_add_x) >>
2359
241k
                                      ((WORD32) (u4_shift_x - 4))) -
2360
241k
                            i4_delta_x;
2361
2362
241k
            i4_x_refmax16 =
2363
241k
                (WORD64) (((WORD64) (i4_i + i4_mb_wd - 1 - i4_offset_x) * u4_scale_x + i4_add_x) >>
2364
241k
                          ((WORD32) (u4_shift_x - 4))) -
2365
241k
                i4_delta_x;
2366
2367
            /* AC205 */
2368
241k
            i4_x_offset = i4_x_refmin16 >> 4;
2369
241k
            ps_x_off_len->i2_offset = i4_x_offset;
2370
241k
            ps_x_off_len->i2_length = (i4_x_refmax16 >> 4) - i4_x_offset + 2;
2371
2372
            /* increment the pointer */
2373
241k
            ps_x_off_len++;
2374
2375
241k
        } /* end of loop over current layer width */
2376
2377
        /* ----------------------------------------------------------------- */
2378
        /* Computation of offsetY refArrayH Ymin and Ymax Lists              */
2379
        /* ----------------------------------------------------------------- */
2380
704k
        for(i4_j = 0; i4_j < i4_curr_lyr_height; i4_j = i4_j + i4_mb_ht)
2381
636k
        {
2382
636k
            WORD32 i4_y_refmin16;
2383
636k
            WORD32 i4_y_refmax16;
2384
636k
            WORD32 i4_y_offset;
2385
2386
636k
            i4_y_refmin16 = (WORD64) (((WORD64) (i4_j - i4_offset_y) * u4_scale_y + i4_add_y) >>
2387
636k
                                      ((WORD32) (u4_shift_y - 4))) -
2388
636k
                            i4_delta_y;
2389
2390
636k
            i4_y_refmax16 =
2391
636k
                (WORD64) (((WORD64) (i4_j + i4_mb_ht - 1 - i4_offset_y) * u4_scale_y + i4_add_y) >>
2392
636k
                          ((WORD32) (u4_shift_y - 4))) -
2393
636k
                i4_delta_y;
2394
2395
            /* AC205 */
2396
636k
            i4_y_offset = i4_y_refmin16 >> 4;
2397
636k
            ps_y_off_len->i2_offset = i4_y_offset;
2398
636k
            ps_y_off_len->i2_length = (i4_y_refmax16 >> 4) - i4_y_offset + 2;
2399
2400
            /* increment the pointer */
2401
636k
            ps_y_off_len++;
2402
2403
636k
        } /* end of loop over current layer height */
2404
68.2k
    }
2405
2406
    /* --------------------------------------------------------------------- */
2407
    /* Computation of Xref and Xphase List as per standard                     */
2408
    /* --------------------------------------------------------------------- */
2409
68.2k
    ps_x_off_len = ps_map_ctxt->ps_x_offset_length;
2410
68.2k
    ps_y_off_len = ps_map_ctxt->ps_y_offset_length;
2411
2412
68.2k
    {
2413
68.2k
        WORD32 i4_xc;
2414
68.2k
        WORD32 i4_offset_x_index;
2415
68.2k
        ref_pixel_map_t *ps_x_pos_phase;
2416
2417
68.2k
        ps_x_pos_phase = ps_map_ctxt->ps_x_pos_phase;
2418
2419
2.97M
        for(i4_xc = 0; i4_xc < i4_curr_lyr_width; i4_xc++)
2420
2.90M
        {
2421
2.90M
            WORD32 i4_x_offset;
2422
2.90M
            WORD32 i4_x_ref16;
2423
2424
2.90M
            i4_offset_x_index = i4_xc / i4_mb_wd;
2425
2.90M
            i4_x_offset = ps_x_off_len[i4_offset_x_index].i2_offset;
2426
2.90M
            i4_x_ref16 = (WORD64) (((WORD64) (i4_xc - i4_offset_x) * u4_scale_x + i4_add_x) >>
2427
2.90M
                                   ((WORD32) (u4_shift_x - 4))) -
2428
2.90M
                         i4_delta_x;
2429
2430
            /* store the values */
2431
2.90M
            ps_x_pos_phase->i2_ref_pos = (i4_x_ref16 >> 4) - i4_x_offset;
2432
2.90M
            ps_x_pos_phase->i2_phase = (i4_x_ref16 - (16 * i4_x_offset)) & 15;
2433
2434
            /* increment the pointer */
2435
2.90M
            ps_x_pos_phase++;
2436
2.90M
        } /* end of loop over scaled width */
2437
68.2k
    }
2438
2439
    /* --------------------------------------------------------------------- */
2440
    /* Computation of Yref and Yphase List as per standard                     */
2441
    /* --------------------------------------------------------------------- */
2442
68.2k
    {
2443
68.2k
        WORD32 i4_yc;
2444
68.2k
        WORD32 i4_offset_y_index;
2445
68.2k
        ref_pixel_map_t *ps_y_pos_phase;
2446
2447
68.2k
        ps_y_pos_phase = ps_map_ctxt->ps_y_pos_phase;
2448
2449
7.70M
        for(i4_yc = 0; i4_yc < i4_curr_lyr_height; i4_yc++)
2450
7.63M
        {
2451
7.63M
            WORD32 i4_y_offset;
2452
7.63M
            WORD32 i4_y_ref16;
2453
2454
7.63M
            i4_offset_y_index = i4_yc / i4_mb_ht;
2455
7.63M
            i4_y_offset = ps_y_off_len[i4_offset_y_index].i2_offset;
2456
2457
7.63M
            if((SVCD_FALSE == i4_frame_mbs_only_flag) ||
2458
7.63M
               (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.63M
            i4_y_ref16 = (WORD64) ((((WORD64) (i4_yc - i4_offset_y) * u4_scale_y + i4_add_y) >>
2464
7.63M
                                    ((WORD32) (u4_shift_y - 4))) -
2465
7.63M
                                   i4_delta_y);
2466
7.63M
            ps_y_pos_phase->i2_ref_pos = (i4_y_ref16 >> 4) - i4_y_offset;
2467
7.63M
            ps_y_pos_phase->i2_phase = (i4_y_ref16 - (16 * i4_y_offset)) & 15;
2468
2469
            /* increment the pointer */
2470
7.63M
            ps_y_pos_phase++;
2471
7.63M
        } /* end of loop over scaled height */
2472
68.2k
    }
2473
68.2k
    return;
2474
68.2k
}
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
137k
{
2502
137k
    residual_sampling_ctxt_t *ps_ctxt;
2503
137k
    res_lyr_ctxt *ps_lyr_ctxt;
2504
137k
    dec_seq_params_t *ps_sps;
2505
137k
    dec_svc_seq_params_t *ps_subset_sps;
2506
137k
    svc_dec_lyr_struct_t *ps_svc_lyr_dec = (svc_dec_lyr_struct_t *) pv_svc_dec;
2507
137k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
2508
2509
137k
    void *pv_residual_samp_ctxt = ps_svc_lyr_dec->pv_residual_sample_ctxt;
2510
137k
    res_prms_t *ps_curr_lyr_res_prms = &ps_svc_lyr_dec->s_res_prms;
2511
137k
    ref_mb_map_t **pps_luma_map_horz = &ps_svc_lyr_dec->ps_ressam_luma_map_horz;
2512
137k
    ref_mb_map_t **pps_chroma_map_horz = &ps_svc_lyr_dec->ps_ressam_chroma_map_horz;
2513
137k
    ref_mb_map_t **pps_luma_map_vert = &ps_svc_lyr_dec->ps_ressam_luma_map_vert;
2514
137k
    ref_mb_map_t **pps_chroma_map_vert = &ps_svc_lyr_dec->ps_ressam_chroma_map_vert;
2515
2516
137k
    if((NULL == pv_residual_samp_ctxt) || (NULL == ps_curr_lyr_res_prms) ||
2517
137k
       (NULL == pps_luma_map_horz) || (NULL == pps_chroma_map_horz) ||
2518
137k
       (NULL == pps_luma_map_vert) || (NULL == pps_chroma_map_vert))
2519
0
    {
2520
0
        return NOT_OK;
2521
0
    }
2522
2523
137k
    ps_ctxt = (residual_sampling_ctxt_t *) pv_residual_samp_ctxt;
2524
2525
    /* if called for base resolution store deafult values */
2526
137k
    if(SVCD_TRUE == ps_svc_lyr_dec->u1_base_res_flag)
2527
103k
    {
2528
103k
        *pps_luma_map_horz = NULL;
2529
103k
        *pps_chroma_map_horz = NULL;
2530
103k
        *pps_luma_map_vert = NULL;
2531
103k
        *pps_chroma_map_vert = NULL;
2532
103k
        ps_ctxt->i4_res_lyr_id = -1;
2533
103k
        ps_ctxt->i4_ref_width = ps_curr_lyr_res_prms->i4_res_width;
2534
103k
        ps_ctxt->i4_ref_height = ps_curr_lyr_res_prms->i4_res_height;
2535
103k
        return OK;
2536
103k
    }
2537
2538
    /* derive the current sps */
2539
34.1k
    ps_sps = ps_dec->ps_cur_sps;
2540
34.1k
    ps_subset_sps = ps_svc_lyr_dec->ps_cur_subset_sps;
2541
2542
    /* store the res id appropriately */
2543
34.1k
    ps_ctxt->i4_res_lyr_id = ps_svc_lyr_dec->u1_layer_id - 1;
2544
2545
    /* get the current layer ctxt */
2546
34.1k
    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.1k
    ps_lyr_ctxt->i4_curr_width = ps_curr_lyr_res_prms->i4_res_width;
2550
34.1k
    ps_lyr_ctxt->i4_curr_height = ps_curr_lyr_res_prms->i4_res_height;
2551
34.1k
    ps_lyr_ctxt->i4_ref_width = ps_ctxt->i4_ref_width;
2552
34.1k
    ps_lyr_ctxt->i4_ref_height = ps_ctxt->i4_ref_height;
2553
2554
    /* store the strcuture pointer containing projected locations */
2555
34.1k
    *pps_luma_map_horz = ps_lyr_ctxt->s_luma_map_ctxt.ps_x_offset_length;
2556
34.1k
    *pps_chroma_map_horz = ps_lyr_ctxt->s_chroma_map_ctxt.ps_x_offset_length;
2557
34.1k
    *pps_luma_map_vert = ps_lyr_ctxt->s_luma_map_ctxt.ps_y_offset_length;
2558
34.1k
    *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.1k
    if(SVCD_TRUE == ps_curr_lyr_res_prms->u1_remap_req_flag)
2562
34.1k
    {
2563
34.1k
        res_prms_t s_ref_res_prms = {0};
2564
2565
        /* store the reference layer resolution width and height */
2566
34.1k
        s_ref_res_prms.i4_res_width = ps_ctxt->i4_ref_width;
2567
34.1k
        s_ref_res_prms.i4_res_height = ps_ctxt->i4_ref_height;
2568
2569
        /* call the frame level projections calculation function */
2570
34.1k
        isvcd_residual_samp_populate_list(&ps_lyr_ctxt->s_luma_map_ctxt, ps_sps, ps_subset_sps,
2571
34.1k
                                          ps_curr_lyr_res_prms, &s_ref_res_prms, 0);
2572
34.1k
        isvcd_residual_samp_populate_list(&ps_lyr_ctxt->s_chroma_map_ctxt, ps_sps, ps_subset_sps,
2573
34.1k
                                          ps_curr_lyr_res_prms, &s_ref_res_prms, 1);
2574
2575
        /* default values for flags */
2576
34.1k
        ps_lyr_ctxt->pf_residual_samp_mb = &isvcd_residual_samp_mb;
2577
34.1k
        ps_lyr_ctxt->i4_chrm_horz_int_mode = 0;
2578
34.1k
        ps_lyr_ctxt->i4_chrm_vert_int_mode = 0;
2579
34.1k
        ps_lyr_ctxt->i4_chrm_alt_proc = SVCD_FALSE;
2580
2581
        /* Store the Dyadic flag */
2582
34.1k
        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.1k
        if(SVCD_TRUE == ps_curr_lyr_res_prms->u1_dyadic_flag)
2587
18.4k
        {
2588
18.4k
            WORD32 i4_ref_layer_chroma_phase_x_plus1_flag;
2589
18.4k
            WORD32 i4_ref_layer_chroma_phase_y_plus1;
2590
18.4k
            WORD32 i4_chroma_phase_x_plus1_flag;
2591
18.4k
            WORD32 i4_chroma_phase_y_plus1;
2592
2593
18.4k
            ps_lyr_ctxt->pf_residual_samp_mb = &isvcd_residual_samp_mb_dyadic;
2594
18.4k
            i4_ref_layer_chroma_phase_x_plus1_flag =
2595
18.4k
                ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_x_plus1_flag;
2596
18.4k
            i4_ref_layer_chroma_phase_y_plus1 =
2597
18.4k
                ps_curr_lyr_res_prms->i1_ref_lyr_chroma_phase_y_plus1;
2598
18.4k
            i4_chroma_phase_x_plus1_flag =
2599
18.4k
                ps_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_x_plus1_flag;
2600
18.4k
            i4_chroma_phase_y_plus1 =
2601
18.4k
                ps_subset_sps->s_sps_svc_ext.u1_seq_ref_layer_chroma_phase_y_plus1;
2602
18.4k
            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
18.4k
            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
18.4k
            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
18.4k
            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
18.4k
        }
2626
34.1k
    }
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.1k
    ps_ctxt->i4_ref_width = ps_curr_lyr_res_prms->i4_res_width;
2638
34.1k
    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.1k
    if((ps_lyr_ctxt->i4_curr_width > H264_MAX_FRAME_WIDTH) ||
2642
34.1k
       (ps_lyr_ctxt->i4_ref_width > H264_MAX_FRAME_WIDTH) ||
2643
34.1k
       (ps_lyr_ctxt->i4_curr_height > H264_MAX_FRAME_HEIGHT) ||
2644
34.1k
       (ps_lyr_ctxt->i4_ref_height > H264_MAX_FRAME_HEIGHT))
2645
0
    {
2646
0
        return NOT_OK;
2647
0
    }
2648
34.1k
    return OK;
2649
34.1k
}