Coverage Report

Created: 2025-08-28 06:38

/src/libhevc/encoder/ihevce_nbr_avail.c
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2018 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
******************************************************************************
23
* @file ihevce_nbr_avail.c
24
*
25
* @brief
26
*    This file contains function definitions and look up tables for various
27
*    neigbour avail flags in HEVC encoder
28
*
29
* @author
30
*    Ittiam
31
*
32
* List of Functions
33
*   <TODO: TO BE ADDED>
34
*
35
******************************************************************************
36
*/
37
38
/*****************************************************************************/
39
/* File Includes                                                             */
40
/*****************************************************************************/
41
/* System include files */
42
#include <stdio.h>
43
#include <string.h>
44
#include <stdlib.h>
45
#include <assert.h>
46
#include <stdarg.h>
47
#include <math.h>
48
49
/* User include files */
50
#include "ihevc_typedefs.h"
51
#include "itt_video_api.h"
52
#include "ihevce_api.h"
53
54
#include "rc_cntrl_param.h"
55
#include "rc_frame_info_collector.h"
56
#include "rc_look_ahead_params.h"
57
58
#include "ihevc_defs.h"
59
#include "ihevc_structs.h"
60
#include "ihevc_platform_macros.h"
61
#include "ihevc_deblk.h"
62
#include "ihevc_itrans_recon.h"
63
#include "ihevc_chroma_itrans_recon.h"
64
#include "ihevc_chroma_intra_pred.h"
65
#include "ihevc_intra_pred.h"
66
#include "ihevc_inter_pred.h"
67
#include "ihevc_mem_fns.h"
68
#include "ihevc_padding.h"
69
#include "ihevc_weighted_pred.h"
70
#include "ihevc_sao.h"
71
#include "ihevc_resi_trans.h"
72
#include "ihevc_quant_iquant_ssd.h"
73
#include "ihevc_cabac_tables.h"
74
75
#include "ihevce_defs.h"
76
#include "ihevce_lap_enc_structs.h"
77
#include "ihevce_multi_thrd_structs.h"
78
#include "ihevce_multi_thrd_funcs.h"
79
#include "ihevce_me_common_defs.h"
80
#include "ihevce_had_satd.h"
81
#include "ihevce_error_codes.h"
82
#include "ihevce_bitstream.h"
83
#include "ihevce_cabac.h"
84
#include "ihevce_rdoq_macros.h"
85
#include "ihevce_function_selector.h"
86
#include "ihevce_enc_structs.h"
87
#include "ihevce_nbr_avail.h"
88
89
/*****************************************************************************/
90
/* Function Definitions                                                      */
91
/*****************************************************************************/
92
93
/*!
94
******************************************************************************
95
* \if Function name : ihevce_set_ctb_nbr \endif
96
*
97
* \brief
98
*    This function sets the neighbour availability flags of ctb based on the
99
*    CTB position
100
*
101
* \date
102
*    18/09/2012
103
*
104
* \author
105
*    Ittiam
106
*
107
* \return
108
*    none
109
*
110
******************************************************************************
111
*/
112
void ihevce_set_ctb_nbr(
113
    nbr_avail_flags_t *ps_nbr,
114
    UWORD8 *pu1_nbr_map,
115
    WORD32 nbr_map_strd,
116
    WORD32 ctb_pos_x,
117
    WORD32 ctb_pos_y,
118
    frm_ctb_ctxt_t *ps_frm_ctb_prms)
119
476k
{
120
476k
    WORD32 ctr;
121
476k
    WORD32 *pi4_cur_ctb_tile_id;
122
476k
    WORD32 i4_curr_ctb_tile_id, i4_top_ctb_tile_id;
123
476k
    WORD32 i4_left_ctb_tile_id, i4_right_ctb_tile_id;
124
125
476k
    WORD32 ctb_size = ps_frm_ctb_prms->i4_ctb_size;
126
476k
    WORD32 num_ctb_horz = ps_frm_ctb_prms->i4_num_ctbs_horz;
127
476k
    WORD32 num_ctb_vert = ps_frm_ctb_prms->i4_num_ctbs_vert;
128
476k
    WORD32 cu_aligned_pic_wd = ps_frm_ctb_prms->i4_cu_aligned_pic_wd;
129
476k
    WORD32 cu_aligned_pic_ht = ps_frm_ctb_prms->i4_cu_aligned_pic_ht;
130
476k
    UWORD8 *pu1_top_nbr_map = pu1_nbr_map - nbr_map_strd;
131
476k
    UWORD8 *pu1_left_nbr_map = pu1_nbr_map - 1;
132
476k
    UWORD8 *pu1_top_lt_nbr_map = pu1_top_nbr_map - 1;
133
476k
    UWORD8 *pu1_top_rt_nbr_map = pu1_top_nbr_map + (ctb_size >> 2);
134
476k
    WORD32 num_4x4_ctb_x = (ctb_size >> 2);
135
476k
    WORD32 num_4x4_ctb_y = (ctb_size >> 2);
136
137
    /* Conditionally update num_4x4_ctb_x and num_4x4_ctb_y */
138
476k
    if(ctb_pos_y == (num_ctb_vert - 1))
139
317k
    {
140
317k
        num_4x4_ctb_y = (cu_aligned_pic_ht - ((num_ctb_vert - 1) * ctb_size)) / 4;
141
317k
    }
142
143
476k
    if(ctb_pos_x == (num_ctb_horz - 1))
144
290k
    {
145
290k
        num_4x4_ctb_x = (cu_aligned_pic_wd - ((num_ctb_horz - 1) * ctb_size)) / 4;
146
290k
    }
147
148
    /* Get Tile-ids of top, left and current CTBs */
149
476k
    pi4_cur_ctb_tile_id = ps_frm_ctb_prms->pi4_tile_id_map +
150
476k
                          ctb_pos_y * ps_frm_ctb_prms->i4_tile_id_ctb_map_stride + ctb_pos_x;
151
152
476k
    i4_curr_ctb_tile_id = *pi4_cur_ctb_tile_id;
153
476k
    i4_left_ctb_tile_id = *(pi4_cur_ctb_tile_id - 1);
154
476k
    i4_right_ctb_tile_id = *(pi4_cur_ctb_tile_id + 1);
155
476k
    i4_top_ctb_tile_id = *(pi4_cur_ctb_tile_id - ps_frm_ctb_prms->i4_tile_id_ctb_map_stride);
156
157
    /*********** Update Nbr availability in ps_nbr **********/
158
159
476k
    ps_nbr->u1_left_avail = (i4_left_ctb_tile_id == i4_curr_ctb_tile_id);
160
476k
    ps_nbr->u1_top_avail = (i4_top_ctb_tile_id == i4_curr_ctb_tile_id);
161
476k
    ps_nbr->u1_top_lt_avail = (ps_nbr->u1_left_avail && ps_nbr->u1_top_avail);
162
476k
    ps_nbr->u1_top_rt_avail = ps_nbr->u1_top_avail && (i4_right_ctb_tile_id == i4_curr_ctb_tile_id);
163
476k
    ps_nbr->u1_bot_lt_avail = 0; /* at ctb level bottom left is always not available */
164
165
    /*********** Update Nbr availability in pu1_nbr_map **********/
166
167
    /* NOTE: entire Nbr availability map is by default set to 0 */
168
476k
    *pu1_top_lt_nbr_map = ps_nbr->u1_top_lt_avail; /* Top-Left*/
169
170
476k
    memset(pu1_top_nbr_map, ps_nbr->u1_top_avail, num_4x4_ctb_x); /* Top */
171
172
7.85M
    for(ctr = 0; ctr < num_4x4_ctb_y; ctr++) /* Left */
173
7.37M
    {
174
7.37M
        *pu1_left_nbr_map = ps_nbr->u1_left_avail;
175
7.37M
        pu1_left_nbr_map += nbr_map_strd;
176
7.37M
    }
177
178
476k
    if((num_ctb_horz - 2) == ctb_pos_x) /* Top-Right */
179
26.9k
    {
180
        /* For the last but 1 ctb, if the last ctb is non-multiple of 64,
181
       then set the map accordingly */
182
26.9k
        WORD32 last_ctb_x = cu_aligned_pic_wd - ((num_ctb_horz - 1) * ctb_size);
183
184
26.9k
        num_4x4_ctb_x = MIN(last_ctb_x, MAX_TU_SIZE) / 4;
185
26.9k
        memset(pu1_top_rt_nbr_map, ps_nbr->u1_top_rt_avail, num_4x4_ctb_x);
186
26.9k
    }
187
449k
    else
188
449k
    {
189
449k
        memset(pu1_top_rt_nbr_map, ps_nbr->u1_top_rt_avail, (MAX_TU_SIZE / 4));
190
449k
    }
191
192
476k
    return;
193
476k
}
194
195
/*!
196
******************************************************************************
197
* \if Function name : ihevce_get_nbr_intra \endif
198
*
199
* \brief
200
*    This function sets the neighbour availability flags of given unit
201
*    based on the position and size
202
*
203
* \date
204
*    18/09/2012
205
*
206
* \author
207
*    Ittiam
208
*
209
* \return
210
*    none
211
*
212
******************************************************************************
213
*/
214
WORD32 ihevce_get_nbr_intra(
215
    nbr_avail_flags_t *ps_cu_nbr,
216
    UWORD8 *pu1_nbr_map,
217
    WORD32 nbr_map_strd,
218
    WORD32 unit_4x4_pos_x,
219
    WORD32 unit_4x4_pos_y,
220
    WORD32 unit_4x4_size)
221
40.5M
{
222
40.5M
    WORD32 nbr_tem_flags = 0;
223
40.5M
    WORD32 i;
224
225
40.5M
    UWORD8 *pu1_bot_lt_map;
226
40.5M
    UWORD8 *pu1_top_rt_map;
227
40.5M
    UWORD8 *pu1_top_lt_map;
228
40.5M
    UWORD8 *pu1_left_map;
229
40.5M
    UWORD8 *pu1_top_map;
230
231
    /* map is stored at 4x4 level increment to point to current cu 4x4 */
232
40.5M
    pu1_nbr_map += (unit_4x4_pos_x);
233
40.5M
    pu1_nbr_map += (unit_4x4_pos_y)*nbr_map_strd;
234
235
40.5M
    pu1_top_map = pu1_nbr_map - nbr_map_strd;
236
40.5M
    pu1_top_lt_map = pu1_top_map - 1;
237
40.5M
    pu1_left_map = (pu1_nbr_map - 1);
238
    /* use map to get top right availablility */
239
40.5M
    pu1_top_rt_map = pu1_nbr_map - nbr_map_strd;
240
40.5M
    pu1_top_rt_map += unit_4x4_size;
241
242
    /* use map to get bot left availablility */
243
40.5M
    pu1_bot_lt_map = pu1_nbr_map - 1;
244
40.5M
    pu1_bot_lt_map += unit_4x4_size * nbr_map_strd;
245
246
    /* Top flag */
247
40.5M
    ps_cu_nbr->u1_top_avail = *pu1_top_map;
248
249
    /* left flag */
250
40.5M
    ps_cu_nbr->u1_left_avail = *pu1_left_map;
251
252
    /* top left flag */
253
40.5M
    ps_cu_nbr->u1_top_lt_avail = *pu1_top_lt_map;
254
255
    /* top right flag */
256
40.5M
    ps_cu_nbr->u1_top_rt_avail = *pu1_top_rt_map;
257
258
    /* bottom left flag */
259
40.5M
    ps_cu_nbr->u1_bot_lt_avail = (*pu1_bot_lt_map);
260
261
    /* Update the neighbor availiblity flag according to the nbr_map */
262
40.5M
    nbr_tem_flags = 0;
263
264
202M
    for(i = 0; i < 4; i++)
265
162M
    {
266
162M
        nbr_tem_flags |= ((*pu1_bot_lt_map) << (3 - i));
267
162M
        pu1_bot_lt_map += (nbr_map_strd * 2);
268
162M
    }
269
270
202M
    for(i = 0; i < 4; i++)
271
162M
    {
272
162M
        nbr_tem_flags |= ((*pu1_left_map) << (7 - i));
273
162M
        pu1_left_map += (nbr_map_strd * 2);
274
162M
    }
275
202M
    for(i = 0; i < 4; i++)
276
162M
    {
277
162M
        nbr_tem_flags |= ((*pu1_top_map) << (i + 8));
278
162M
        pu1_top_map += 2;
279
162M
    }
280
202M
    for(i = 0; i < 4; i++)
281
162M
    {
282
162M
        nbr_tem_flags |= ((*pu1_top_rt_map) << (i + 12));
283
162M
        pu1_top_rt_map += 2;
284
162M
    }
285
40.5M
    nbr_tem_flags |= (*pu1_top_lt_map << 16);
286
287
40.5M
    return nbr_tem_flags;
288
40.5M
}
289
290
/*!
291
******************************************************************************
292
* \if Function name : ihevce_get_nbr_intra_mxn_tu \endif
293
*
294
* \brief
295
*    This function sets the neighbour availability flags of given unit
296
*    based on the position and size
297
*
298
* \date
299
*    24/06/2014
300
*
301
* \author
302
*    Ittiam
303
*
304
* \return
305
*    none
306
*
307
******************************************************************************
308
*/
309
WORD32 ihevce_get_nbr_intra_mxn_tu(
310
    UWORD8 *pu1_nbr_map,
311
    WORD32 nbr_map_strd,
312
    WORD32 unit_4x4_pos_x,
313
    WORD32 unit_4x4_pos_y,
314
    WORD32 unit_4x4_size_horz,
315
    WORD32 unit_4x4_size_vert)
316
19.5M
{
317
19.5M
    WORD32 nbr_tem_flags = 0;
318
19.5M
    WORD32 i;
319
320
19.5M
    UWORD8 *pu1_bot_lt_map;
321
19.5M
    UWORD8 *pu1_top_rt_map;
322
19.5M
    UWORD8 *pu1_top_lt_map;
323
19.5M
    UWORD8 *pu1_left_map;
324
19.5M
    UWORD8 *pu1_top_map;
325
326
    /* map is stored at 4x4 level increment to point to current cu 4x4 */
327
19.5M
    pu1_nbr_map += (unit_4x4_pos_x);
328
19.5M
    pu1_nbr_map += (unit_4x4_pos_y)*nbr_map_strd;
329
330
19.5M
    pu1_top_map = pu1_nbr_map - nbr_map_strd;
331
19.5M
    pu1_top_lt_map = pu1_top_map - 1;
332
19.5M
    pu1_left_map = (pu1_nbr_map - 1);
333
    /* use map to get top right availablility */
334
19.5M
    pu1_top_rt_map = pu1_nbr_map - nbr_map_strd;
335
19.5M
    pu1_top_rt_map += unit_4x4_size_horz;
336
337
    /* use map to get bot left availablility */
338
19.5M
    pu1_bot_lt_map = pu1_nbr_map - 1;
339
19.5M
    pu1_bot_lt_map += unit_4x4_size_vert * nbr_map_strd;
340
341
    /* Update the neighbor availiblity flag according to the nbr_map */
342
19.5M
    nbr_tem_flags = 0;
343
344
97.8M
    for(i = 0; i < 4; i++)
345
78.2M
    {
346
78.2M
        nbr_tem_flags |= ((*pu1_bot_lt_map) << (3 - i));
347
78.2M
        pu1_bot_lt_map += (nbr_map_strd * 2);
348
78.2M
    }
349
350
97.8M
    for(i = 0; i < 4; i++)
351
78.2M
    {
352
78.2M
        nbr_tem_flags |= ((*pu1_left_map) << (7 - i));
353
78.2M
        pu1_left_map += (nbr_map_strd * 2);
354
78.2M
    }
355
97.8M
    for(i = 0; i < 4; i++)
356
78.2M
    {
357
78.2M
        nbr_tem_flags |= ((*pu1_top_map) << (i + 8));
358
78.2M
        pu1_top_map += 2;
359
78.2M
    }
360
97.8M
    for(i = 0; i < 4; i++)
361
78.2M
    {
362
78.2M
        nbr_tem_flags |= ((*pu1_top_rt_map) << (i + 12));
363
78.2M
        pu1_top_rt_map += 2;
364
78.2M
    }
365
19.5M
    nbr_tem_flags |= (*pu1_top_lt_map << 16);
366
367
19.5M
    return nbr_tem_flags;
368
19.5M
}
369
370
/*!
371
******************************************************************************
372
* \if Function name : ihevce_get_intra_chroma_tu_nbr \endif
373
*
374
* \brief
375
*    This function sets the neighbour availability flags of a chroma
376
*    subTU based on luma availability and chroma format
377
*
378
* \date
379
*    04/07/2014
380
*
381
* \author
382
*    Ittiam
383
*
384
* \return
385
*    none
386
*
387
******************************************************************************
388
*/
389
WORD32 ihevce_get_intra_chroma_tu_nbr(
390
    WORD32 i4_luma_nbr_flags, WORD32 i4_subtu_idx, WORD32 i4_trans_size, UWORD8 u1_is_422)
391
26.5M
{
392
    /* TOP LEFT | TOP-RIGHT |  TOP   | LEFT    | BOTTOM LEFT*/
393
    /* (1 bit)     (4 bits)  (4 bits) (4 bits)  (4 bits)  */
394
    /* With reference to the above bit arrangement - */
395
    /* BL0 - Bit 3 */
396
    /* BL1 - Bit 2 */
397
    /* BL2 - Bit 1 */
398
    /* BL3 - Bit 0 */
399
    /* L0 - Bit 7 */
400
    /* L1 - Bit 6 */
401
    /* L2 - Bit 5 */
402
    /* L3 - Bit 4 */
403
    /* T0 - Bit 8 */
404
    /* T1 - Bit 9 */
405
    /* T2 - Bit 10 */
406
    /* T3 - Bit 11 */
407
    /* TR0 - Bit 12 */
408
    /* TR1 - Bit 13 */
409
    /* TR2 - Bit 14 */
410
    /* TR3 - Bit 15 */
411
26.5M
    if(u1_is_422)
412
0
    {
413
0
        if(0 == i4_subtu_idx)
414
0
        {
415
            /* If left is available for luma, then */
416
0
            if(i4_luma_nbr_flags & 0xf0)
417
0
            {
418
0
                switch(i4_trans_size)
419
0
                {
420
0
                case 4:
421
0
                {
422
                    /* BL0 - 1 */
423
                    /* BL1-3 - Luma_BL0-2 */
424
                    /*i4_luma_nbr_flags |= (i4_luma_nbr_flags & 0xe) >> 1;*/
425
0
                    i4_luma_nbr_flags |= 0x8;
426
427
                    /* L0-1 - 11 */
428
                    /* L2-3 - Luma_L2-3 */
429
0
                    i4_luma_nbr_flags |= 0xc0;
430
431
0
                    break;
432
0
                }
433
0
                case 8:
434
0
                {
435
                    /* BL0-1 - 11 */
436
                    /* BL1-3 - Luma_BL0-1 */
437
                    /*i4_luma_nbr_flags |= (i4_luma_nbr_flags & 0xc) >> 2;*/
438
0
                    i4_luma_nbr_flags |= 0xc;
439
440
                    /* L0-3 - 1111 */
441
0
                    i4_luma_nbr_flags |= 0xf0;
442
443
0
                    break;
444
0
                }
445
0
                case 16:
446
0
                {
447
                    /* BL0-3 - 1111 */
448
0
                    i4_luma_nbr_flags |= 0xf;
449
450
                    /* L0-3 - 1111 */
451
0
                    i4_luma_nbr_flags |= 0xf0;
452
453
0
                    break;
454
0
                }
455
0
                }
456
0
            }
457
0
        }
458
0
        else
459
0
        {
460
            /* Top right is always unavailable */
461
            /* Top is always available */
462
463
0
            i4_luma_nbr_flags &= (0xffff0fff);
464
465
            /* Top left is marked as available if */
466
            /* luma left is available */
467
0
            if(i4_luma_nbr_flags & 0xf0)
468
0
            {
469
0
                i4_luma_nbr_flags |= (1 << 16);
470
0
            }
471
472
0
            switch(i4_trans_size)
473
0
            {
474
0
            case 4:
475
0
            {
476
                /* T0 - 1 */
477
                /* T1-3 - 000 */
478
0
                i4_luma_nbr_flags |= 0x100;
479
0
                i4_luma_nbr_flags &= 0xfffff1ff;
480
481
0
                if(i4_luma_nbr_flags & 0xf0)
482
0
                {
483
0
                    i4_luma_nbr_flags |= 0x80;
484
0
                }
485
486
0
                if(i4_luma_nbr_flags & 0x8)
487
0
                {
488
0
                    i4_luma_nbr_flags |= 0x8;
489
0
                }
490
491
0
                break;
492
0
            }
493
0
            case 8:
494
0
            {
495
                /* T0-1 - 11 */
496
                /* T2-3 - 00 */
497
0
                i4_luma_nbr_flags |= 0x300;
498
0
                i4_luma_nbr_flags &= 0xfffff3ff;
499
500
0
                if(i4_luma_nbr_flags & 0xf0)
501
0
                {
502
0
                    i4_luma_nbr_flags |= 0xc0;
503
0
                }
504
505
0
                if((i4_luma_nbr_flags & 0xc) == 0x8)
506
0
                {
507
0
                    i4_luma_nbr_flags |= 0xc;
508
0
                }
509
0
                else if((i4_luma_nbr_flags & 0xc) == 0xc)
510
0
                {
511
0
                    i4_luma_nbr_flags |= 0xf;
512
0
                }
513
0
                else if((i4_luma_nbr_flags & 0xf) == 0xe)
514
0
                {
515
0
                    i4_luma_nbr_flags |= 0xf;
516
0
                }
517
518
0
                break;
519
0
            }
520
0
            case 16:
521
0
            {
522
                /* T0-3 - 1111 */
523
0
                i4_luma_nbr_flags |= 0xf00;
524
525
0
                if(i4_luma_nbr_flags & 0xf0)
526
0
                {
527
0
                    i4_luma_nbr_flags |= 0xf0;
528
0
                }
529
530
0
                if((i4_luma_nbr_flags & 0xf) == 0x8)
531
0
                {
532
0
                    i4_luma_nbr_flags |= 0xc;
533
0
                }
534
0
                else if((i4_luma_nbr_flags & 0xf) == 0xc)
535
0
                {
536
0
                    i4_luma_nbr_flags |= 0xf;
537
0
                }
538
0
                else if((i4_luma_nbr_flags & 0xf) == 0xe)
539
0
                {
540
0
                    i4_luma_nbr_flags |= 0xf;
541
0
                }
542
543
0
                break;
544
0
            }
545
0
            }
546
0
        }
547
0
    }
548
549
26.5M
    return i4_luma_nbr_flags;
550
26.5M
}
551
552
/*!
553
******************************************************************************
554
* \if Function name : ihevce_get_only_nbr_flag \endif
555
*
556
* \brief
557
*    This function sets the neighbour availability flags of given unit
558
*    based on the position, unit width and unit height
559
*
560
* \date
561
*    18/09/2012
562
*
563
* \author
564
*    Ittiam
565
*
566
* \return
567
*    none
568
*
569
******************************************************************************
570
*/
571
void ihevce_get_only_nbr_flag(
572
    nbr_avail_flags_t *ps_cu_nbr,
573
    UWORD8 *pu1_nbr_map,
574
    WORD32 nbr_map_strd,
575
    WORD32 unit_4x4_pos_x,
576
    WORD32 unit_4x4_pos_y,
577
    WORD32 unit_4x4_size_hz,
578
    WORD32 unit_4x4_size_vt)
579
24.3M
{
580
    /* map is stored at 4x4 level increment to point to current cu 4x4 */
581
24.3M
    pu1_nbr_map += (unit_4x4_pos_x);
582
24.3M
    pu1_nbr_map += (unit_4x4_pos_y)*nbr_map_strd;
583
584
    /* Top flag */
585
24.3M
    ps_cu_nbr->u1_top_avail = *(pu1_nbr_map - nbr_map_strd);
586
587
    /* left flag */
588
24.3M
    ps_cu_nbr->u1_left_avail = *(pu1_nbr_map - 1);
589
590
    /* top left flag */
591
24.3M
    ps_cu_nbr->u1_top_lt_avail = *(pu1_nbr_map - nbr_map_strd - 1);
592
593
    /* top right flag */
594
24.3M
    {
595
24.3M
        UWORD8 *pu1_top_rt_map;
596
        /* use map to get top right availablility */
597
24.3M
        pu1_top_rt_map = pu1_nbr_map - nbr_map_strd;
598
24.3M
        pu1_top_rt_map += unit_4x4_size_hz;
599
600
        /* store the availbility */
601
24.3M
        ps_cu_nbr->u1_top_rt_avail = *pu1_top_rt_map;
602
24.3M
    }
603
604
    /* bottom left flag */
605
24.3M
    {
606
24.3M
        UWORD8 *pu1_bot_lt_map;
607
608
        /* use map to get bot left availablility */
609
24.3M
        pu1_bot_lt_map = pu1_nbr_map - 1;
610
24.3M
        pu1_bot_lt_map += unit_4x4_size_vt * nbr_map_strd;
611
612
        /* store the availbility */
613
24.3M
        ps_cu_nbr->u1_bot_lt_avail = *pu1_bot_lt_map;
614
24.3M
    }
615
616
24.3M
    return;
617
24.3M
}
618
619
/*!
620
******************************************************************************
621
* \if Function name : ihevce_set_nbr_map \endif
622
*
623
* \brief
624
*    This function sets the neighbour availability flags of given value
625
*    based on the position and size
626
*
627
* \date
628
*    18/09/2012
629
*
630
* \author
631
*    Ittiam
632
*
633
* \return
634
*    none
635
*
636
******************************************************************************
637
*/
638
void ihevce_set_nbr_map(
639
    UWORD8 *pu1_nbr_map,
640
    WORD32 nbr_map_strd,
641
    WORD32 unit_4x4_pos_x,
642
    WORD32 unit_4x4_pos_y,
643
    WORD32 unit_4x4_size,
644
    WORD32 val)
645
79.0M
{
646
79.0M
    WORD32 i;
647
    /* map is stored at 4x4 level increment to point to current cu 4x4 */
648
79.0M
    pu1_nbr_map += (unit_4x4_pos_x);
649
79.0M
    pu1_nbr_map += (unit_4x4_pos_y)*nbr_map_strd;
650
651
    /* loops to set the flags for given size */
652
354M
    for(i = 0; i < unit_4x4_size; i++)
653
275M
    {
654
275M
        memset(pu1_nbr_map, val, sizeof(UWORD8) * unit_4x4_size);
655
        /* row level updates */
656
275M
        pu1_nbr_map += nbr_map_strd;
657
275M
    }
658
659
79.0M
    return;
660
79.0M
}
661
/*!
662
******************************************************************************
663
* \if Function name : ihevce_set_inter_nbr_map \endif
664
*
665
* \brief
666
*    This function sets the neighbour availability flags of given value
667
*    based on the position and horizontal width and vertical height
668
*
669
* \date
670
*    18/09/2012
671
*
672
* \author
673
*    Ittiam
674
*
675
* \return
676
*  none
677
* List of Functions
678
*
679
*
680
******************************************************************************
681
*/
682
void ihevce_set_inter_nbr_map(
683
    UWORD8 *pu1_nbr_map,
684
    WORD32 nbr_map_strd,
685
    WORD32 unit_4x4_pos_x,
686
    WORD32 unit_4x4_pos_y,
687
    WORD32 unit_4x4_size_hz,
688
    WORD32 unit_4x4_size_vt,
689
    WORD32 val)
690
5.49M
{
691
5.49M
    WORD32 i;
692
    /* map is stored at 4x4 level increment to point to current cu 4x4 */
693
5.49M
    pu1_nbr_map += (unit_4x4_pos_x);
694
5.49M
    pu1_nbr_map += (unit_4x4_pos_y)*nbr_map_strd;
695
5.49M
    {
696
        /* loops to set the flags for given size */
697
25.5M
        for(i = 0; i < unit_4x4_size_vt; i++)
698
20.0M
        {
699
20.0M
            memset(pu1_nbr_map, val, sizeof(UWORD8) * unit_4x4_size_hz);
700
            /* row level updates */
701
20.0M
            pu1_nbr_map += nbr_map_strd;
702
20.0M
        }
703
5.49M
    }
704
705
5.49M
    return;
706
5.49M
}