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