Home | History | Annotate | Download | only in common
      1 /******************************************************************************
      2 *
      3 * Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
      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 
     19 /**
     20  *******************************************************************************
     21  * @file
     22  *  ihevc_structs.h
     23  *
     24  * @brief
     25  *  Structure definitions used in the code
     26  *
     27  * @author
     28  *  Ittiam
     29  *
     30  * @par List of Functions:
     31  *
     32  * @remarks
     33  *  None
     34  *
     35  *******************************************************************************
     36  */
     37 
     38 #ifndef _IHEVC_STRUCTS_H_
     39 #define _IHEVC_STRUCTS_H_
     40 
     41 /**
     42  * Picture buffer
     43  */
     44 typedef struct
     45 {
     46     UWORD8 *pu1_luma;
     47     UWORD8 *pu1_chroma;
     48 
     49     WORD32 i4_abs_poc;
     50     WORD32 i4_poc_lsb;
     51     /** Used to store display Timestamp for current buffer */
     52     WORD32 u4_ts;
     53     UWORD8 u1_used_as_ref;
     54 
     55     UWORD8 u1_free_delay_cnt;
     56 
     57     /**
     58      * buffer ID from buffer manager
     59      */
     60     UWORD8 u1_buf_id;
     61 
     62 }pic_buf_t;
     63 
     64 
     65 /**
     66  * Reference List
     67  */
     68 typedef struct
     69 {
     70     void *pv_pic_buf;
     71 
     72     void *pv_mv_buf;
     73 
     74     UWORD8 u1_used_as_ref;
     75 
     76 }ref_list_t;
     77 
     78 
     79 /**
     80  * SAO
     81  */
     82 typedef struct
     83 {
     84     /**
     85      * sao_type_idx_luma
     86      */
     87     UWORD32      b3_y_type_idx   : 3;
     88 
     89     /**
     90      * luma SaoOffsetVal[1]
     91      */
     92     WORD32      b4_y_offset_1   : 4;
     93 
     94     /**
     95      * luma SaoOffsetVal[2]
     96      */
     97     WORD32      b4_y_offset_2   : 4;
     98 
     99     /**
    100      * luma SaoOffsetVal[3]
    101      */
    102     WORD32      b4_y_offset_3   : 4;
    103 
    104     /**
    105      * luma SaoOffsetVal[4]
    106      */
    107     WORD32      b4_y_offset_4   : 4;
    108 
    109     /**
    110      * luma sao_band_position
    111      */
    112     UWORD32      b5_y_band_pos   : 5;
    113 
    114     WORD32                      : 0;
    115 
    116     /**
    117      * sao_type_idx_chroma
    118      */
    119     UWORD32      b3_cb_type_idx  : 3;
    120 
    121     /**
    122      * chroma SaoOffsetVal[1]
    123      */
    124     WORD32      b4_cb_offset_1  : 4;
    125 
    126     /**
    127      * chroma SaoOffsetVal[2]
    128      */
    129     WORD32      b4_cb_offset_2  : 4;
    130 
    131     /**
    132      * chroma SaoOffsetVal[3]
    133      */
    134     WORD32      b4_cb_offset_3  : 4;
    135 
    136     /**
    137      * chroma SaoOffsetVal[4]
    138      */
    139     WORD32      b4_cb_offset_4  : 4;
    140 
    141     /**
    142      * cb sao_band_position
    143      */
    144     UWORD32      b5_cb_band_pos  : 5;
    145 
    146     WORD32                      : 0;
    147 
    148     /**
    149      * sao_type_idx_chroma
    150      */
    151     UWORD32      b3_cr_type_idx  : 3;
    152 
    153     /**
    154      * chroma SaoOffsetVal[1]
    155      */
    156     WORD32      b4_cr_offset_1  : 4;
    157 
    158     /**
    159      * chroma SaoOffsetVal[2]
    160      */
    161     WORD32      b4_cr_offset_2  : 4;
    162 
    163     /**
    164      * chroma SaoOffsetVal[3]
    165      */
    166     WORD32      b4_cr_offset_3  : 4;
    167 
    168     /**
    169      * chroma SaoOffsetVal[4]
    170      */
    171     WORD32      b4_cr_offset_4  : 4;
    172 
    173     /**
    174      * cr sao_band_position
    175      */
    176     UWORD32      b5_cr_band_pos  : 5;
    177 
    178     WORD32                      : 0;
    179 
    180 }sao_t;
    181 
    182 /**
    183  * SAO
    184  */
    185 typedef struct
    186 {
    187     /**
    188      * sao_type_idx_luma
    189      */
    190     UWORD32      b3_y_type_idx   : 3;
    191 
    192     /**
    193      * luma SaoOffsetVal[1]
    194      */
    195     WORD32      b8_y_offset_1   : 8;
    196 
    197     /**
    198      * luma SaoOffsetVal[2]
    199      */
    200     WORD32      b8_y_offset_2   : 8;
    201 
    202     /**
    203      * luma SaoOffsetVal[3]
    204      */
    205     WORD32      b8_y_offset_3   : 8;
    206 
    207     /**
    208      * luma SaoOffsetVal[4]
    209      */
    210     WORD32      b8_y_offset_4   : 8;
    211 
    212     /**
    213      * luma sao_band_position
    214      */
    215     UWORD32      b5_y_band_pos   : 5;
    216 
    217     WORD32                      : 0;
    218 
    219     /**
    220      * sao_type_idx_chroma
    221      */
    222     UWORD32      b3_cb_type_idx  : 3;
    223 
    224     /**
    225      * chroma SaoOffsetVal[1]
    226      */
    227     WORD32      b8_cb_offset_1  : 8;
    228 
    229     /**
    230      * chroma SaoOffsetVal[2]
    231      */
    232     WORD32      b8_cb_offset_2  : 8;
    233 
    234     /**
    235      * chroma SaoOffsetVal[3]
    236      */
    237     WORD32      b8_cb_offset_3  : 8;
    238 
    239     /**
    240      * chroma SaoOffsetVal[4]
    241      */
    242     WORD32      b8_cb_offset_4  : 8;
    243 
    244     /**
    245      * cb sao_band_position
    246      */
    247     UWORD32      b5_cb_band_pos  : 5;
    248 
    249     WORD32                      : 0;
    250 
    251     /**
    252      * sao_type_idx_chroma
    253      */
    254     UWORD32      b3_cr_type_idx  : 3;
    255 
    256     /**
    257      * chroma SaoOffsetVal[1]
    258      */
    259     WORD32      b8_cr_offset_1  : 8;
    260 
    261     /**
    262      * chroma SaoOffsetVal[2]
    263      */
    264     WORD32      b8_cr_offset_2  : 8;
    265 
    266     /**
    267      * chroma SaoOffsetVal[3]
    268      */
    269     WORD32      b8_cr_offset_3  : 8;
    270 
    271     /**
    272      * chroma SaoOffsetVal[4]
    273      */
    274     WORD32      b8_cr_offset_4  : 8;
    275 
    276     /**
    277      * cr sao_band_position
    278      */
    279     UWORD32      b5_cr_band_pos  : 5;
    280 
    281     WORD32                      : 0;
    282 
    283 }sao_10bd_t;
    284 
    285 /**
    286  * Motion vector
    287  */
    288 typedef struct
    289 {
    290     /**
    291      * Horizontal Motion Vector
    292      */
    293     WORD16 i2_mvx;
    294 
    295     /**
    296      * Vertical Motion Vector
    297      */
    298     WORD16 i2_mvy;
    299 }mv_t;
    300 
    301 /*****************************************************************************/
    302 /* Following results in packed 48 bit structure. If mv_t included            */
    303 /*  ref_pic_buf_id, then 8 bits will be wasted for each mv for aligning.     */
    304 /*  Also using mv_t as elements directly instead of a pointer to l0 and l1   */
    305 /*  mvs. Since pointer takes 4 bytes and MV itself is 4 bytes. It does not   */
    306 /*  really help using pointers.                                              */
    307 /*****************************************************************************/
    308 
    309 /**
    310  * PU Motion Vector info
    311  */
    312 typedef struct
    313 {
    314     /**
    315      *  L0 Motion Vector
    316      */
    317     mv_t s_l0_mv;
    318 
    319     /**
    320      *  L1 Motion Vector
    321      */
    322     mv_t s_l1_mv;
    323 
    324     /**
    325      *  L0 Ref index
    326      */
    327     WORD8   i1_l0_ref_idx;
    328 
    329     /**
    330      *  L1 Ref index
    331      */
    332     WORD8   i1_l1_ref_idx;
    333 
    334     /**
    335      *  L0 Ref Pic Buf ID
    336      */
    337     WORD8 i1_l0_ref_pic_buf_id;
    338 
    339     /**
    340      *  L1 Ref Pic Buf ID
    341      */
    342     WORD8 i1_l1_ref_pic_buf_id;
    343 
    344 }pu_mv_t;
    345 
    346 /**
    347  * PU information
    348  */
    349 typedef struct
    350 {
    351 
    352     /**
    353      *  PU motion vectors
    354      */
    355     pu_mv_t     mv;
    356 
    357     /**
    358      *  PU X position in terms of min PU (4x4) units
    359      */
    360     UWORD32     b4_pos_x        : 4;
    361 
    362     /**
    363      *  PU Y position in terms of min PU (4x4) units
    364      */
    365     UWORD32     b4_pos_y        : 4;
    366 
    367     /**
    368      *  PU width in pixels = (b4_wd + 1) << 2
    369      */
    370     UWORD32     b4_wd           : 4;
    371 
    372     /**
    373      *  PU height in pixels = (b4_ht + 1) << 2
    374      */
    375     UWORD32     b4_ht           : 4;
    376 
    377     /**
    378      *  Intra or Inter flag for each partition - 0 or 1
    379      */
    380     UWORD32     b1_intra_flag   : 1;
    381 
    382 
    383     /**
    384      *  PRED_L0, PRED_L1, PRED_BI - Initialized in parsing only for MVP case
    385      */
    386     UWORD32     b2_pred_mode    : 2;
    387 
    388 
    389 /**
    390      *  Merge flag for each partition - 0 or 1
    391      */
    392     UWORD32     b1_merge_flag   : 1;
    393 
    394     /**
    395      *  Merge index for each partition - 0 to 4
    396      */
    397     UWORD32     b3_merge_idx    : 3;
    398 
    399     /*************************************************************************/
    400     /* Following two flags can be overloaded with b3_merge_idx if there      */
    401     /* is need for additional bits                                           */
    402     /*************************************************************************/
    403 
    404     /**
    405      *  If merge is zero, following gives presence of mvd for L0 MV
    406      */
    407     UWORD32     b1_l0_mvp_idx   : 1;
    408 
    409     /**
    410      *  If merge is zero, following gives presence of mvd for L1 MV
    411      */
    412     UWORD32     b1_l1_mvp_idx   : 1;
    413 
    414     /**
    415      * Partition mode - Needed during MV merge stage
    416      * Note: Part mode can be derived using pu_wd, pu_ht and minCB size
    417      * If there is a need for bits, the following can be removed at the cost
    418      * of more control code in MV Merge
    419      */
    420     UWORD32      b3_part_mode    : 3;
    421 
    422     /**
    423      * Partition index - Needed during MV merge stage
    424      */
    425     UWORD32      b2_part_idx     : 2;
    426 
    427 
    428 }pu_t;
    429 
    430 /**
    431  * TU information
    432  */
    433 typedef struct
    434 {
    435     /**
    436      *  TU X position in terms of min TU (4x4) units
    437      */
    438     UWORD32      b4_pos_x            : 4;
    439 
    440     /**
    441      *  TU Y position in terms of min TU (4x4) units
    442      */
    443     UWORD32     b4_pos_y            : 4;
    444 
    445 
    446     /*************************************************************************/
    447     /* Luma TU size (width or height) = 1 << (b3_size + 2)                   */
    448     /*   i.e. 0 : 4, 1 : 8, 2: 16, 3: 32, 4: 64                              */
    449     /* Note: Though 64 x 64 TU is not possible, this size is supported to    */
    450     /* signal SKIP CUs or PCM CUs etc where transform is not called          */
    451     /* Chroma width will be half of luma except for 4x4 luma                 */
    452     /*************************************************************************/
    453     /**
    454      * Luma TU size (width or height)
    455      */
    456     UWORD32     b3_size             : 3; //To be changed.
    457 
    458     /*************************************************************************/
    459     /* Chroma present : For 4x4 Luma TUs only the fourth one contains Cb     */
    460     /* Cr info. For the first three TUs in 8x8 (for 4x4 luma) this will      */
    461     /* be zero. For all the other cases this will be 1                       */
    462     /*************************************************************************/
    463 
    464     /**
    465      * 4x4 Luma TUs only the fourth one contains cb,cr
    466      * TODO: Check if this is really needed, cb_cbf and cr_cbf should be enough
    467      */
    468 
    469     /**
    470      *  Y CBF
    471      */
    472     UWORD32      b1_y_cbf            : 1;
    473 
    474     /**
    475      *  Cb CBF
    476      */
    477     UWORD32      b1_cb_cbf           : 1;
    478 
    479 
    480     /**
    481      *  Cr CBF
    482      */
    483     UWORD32     b1_cr_cbf           : 1;
    484 
    485 
    486     /**
    487      *  Flag to indicate if it is the first TU in a CU
    488      */
    489     UWORD32     b1_first_tu_in_cu       : 1;
    490 
    491     /**
    492      *  Transform quant bypass flag
    493      */
    494     UWORD32     b1_transquant_bypass  : 1;
    495 
    496     /**
    497      *  Y Qp
    498      */
    499     //UWORD32     b6_qp               : 6; // BUG_FIX related to nighbour QP's in case of negative QP for HBD.
    500     WORD32     b7_qp               : 7;
    501 
    502 
    503     /**
    504      *  Luma Intra Mode 0 - 34
    505      */
    506     UWORD32    b6_luma_intra_mode      : 6;
    507 
    508     /*************************************************************************/
    509     /* Chroma Intra Mode Index 0 - 4: Actual mode (0, 1, 10, 26, 34, X) to be*/
    510     /* derived using luma_intra_mode and the following                       */
    511     /*************************************************************************/
    512     /**
    513      * Chroma Intra Mode Index 0 - 4
    514      */
    515     UWORD32    b3_chroma_intra_mode_idx    : 3;
    516 
    517 }tu_t;
    518 
    519 /**
    520  * CU information
    521  */
    522 typedef struct
    523 {
    524 
    525     /**
    526      *  CU X position in terms of min CU (8x8) units
    527      */
    528     UWORD32 b3_cu_pos_x :3;
    529 
    530     /**
    531      *  CU Y position in terms of min CU (8x8) units
    532      */
    533     UWORD32 b3_cu_pos_y :3;
    534 
    535     /**
    536      *  CU size in terms of min CU (8x8) units
    537      */
    538     UWORD32 b4_cu_size :4;
    539 
    540     /**
    541      *  transquant bypass flag ; 0 for this encoder
    542      */
    543     UWORD32 b1_tq_bypass_flag :1;
    544 
    545     /**
    546      *  CU skip flag
    547      */
    548     UWORD32 b1_skip_flag :1;
    549 
    550     /**
    551      *  intra / inter CU flag
    552      */
    553     UWORD32 b1_pred_mode_flag :1;
    554 
    555     /**
    556      *  indicates partition information for CU
    557      *  For intra 0 : for 2Nx2N / 1 for NxN iff CU=minCBsize
    558      *  For inter 0 : @sa PART_SIZE_E
    559      */
    560     UWORD32 b3_part_mode :3;
    561 
    562     /**
    563      *  0 for this encoder
    564      */
    565     UWORD32 b1_pcm_flag :1;
    566 
    567     /**
    568      *  only applicable for intra cu
    569      */
    570     UWORD32 b3_chroma_intra_pred_mode :3;
    571 
    572     /**
    573      * only applicable for intra cu
    574      */
    575     UWORD32 b1_prev_intra_luma_pred_flag0 :1;
    576 
    577     /**
    578      * only applicable for intra cu and pred_mode=NxN
    579      */
    580     UWORD32 b1_prev_intra_luma_pred_flag1 :1;
    581 
    582     /**
    583      * only applicable for intra cu and pred_mode=NxN
    584      */
    585     UWORD32 b1_prev_intra_luma_pred_flag2 :1;
    586 
    587     /**
    588      * only applicable for intra cu and pred_mode=NxN
    589      */
    590     UWORD32 b1_prev_intra_luma_pred_flag3 :1;
    591 
    592     /**
    593      *  only applicable for luma intra cu
    594      */
    595     UWORD32 b2_mpm_idx0 :2;
    596 
    597     /**
    598      *  only applicable for intra cu and pred_mode=NxN
    599      */
    600     UWORD32 b2_mpm_idx1 :2;
    601 
    602     /**
    603      *  only applicable for intra cu and pred_mode=NxN
    604      */
    605     UWORD32 b2_mpm_idx2 :2;
    606 
    607     /**
    608      *  only applicable for intra cu and pred_mode=NxN
    609      */
    610     UWORD32 b2_mpm_idx3 :2;
    611 
    612     /**
    613      *  only applicable for intra cu
    614      */
    615     UWORD32 b5_rem_intra_pred_mode0 :5;
    616 
    617     /**
    618      *  only applicable for intra cu and pred_mode=NxN
    619      */
    620     UWORD32 b5_rem_intra_pred_mode1 :5;
    621 
    622     /**
    623      *  only applicable for intra cu and pred_mode=NxN
    624      */
    625     UWORD32 b5_rem_intra_pred_mode2 :5;
    626 
    627     /**
    628      *  only applicable for intra cu and pred_mode=NxN
    629      */
    630     UWORD32 b5_rem_intra_pred_mode3 :5;
    631 
    632     /**
    633      *  no residue flag for cu
    634      */
    635     UWORD32 b1_no_residual_syntax_flag :1;
    636 
    637 }cu_t;
    638 
    639 /*****************************************************************************/
    640 /* Since the following data will be accessed linearly (no random access      */
    641 /*  is needed for this) there is no need to store a frame level offset for   */
    642 /*  each CTB's TU data. Only a pointer to this is stored in CTB's structure  */
    643 /*****************************************************************************/
    644 
    645 typedef struct
    646 {
    647     /*************************************************************************/
    648     /* Number of TUs filled in as_tu                                         */
    649     /* Having the first entry as 32 bit data, helps in keeping each of       */
    650     /* the structures aligned to 32 bits at CTB level                        */
    651     /*************************************************************************/
    652     /**
    653      * Number of TUs filled in as_tu
    654      */
    655     WORD32 i4_tu_cnt;
    656 
    657     /**
    658      *  Array to map each min TU unit to a corresponding entry in as_tu
    659      */
    660     UWORD8 au1_tu_map[MAX_TU_IN_CTB];
    661 
    662     /*************************************************************************/
    663     /* TU level information                                                  */
    664     /* Though the allocation for as_pu as done to handle worst case data,    */
    665     /* only valid number of TUs will be filled in the following array.       */
    666     /* Next CTB starts after the valid as_tu entries                         */
    667     /*************************************************************************/
    668     /**
    669      *  TU level information
    670      */
    671     tu_t as_tu[MAX_TU_IN_CTB];
    672 
    673 }ctb_tu_list_t;
    674 
    675 /*****************************************************************************/
    676 /* Info from last TU row of CTB is stored in a row level neighbour buffer    */
    677 /* , which will be used for Boundary Strength computation                    */
    678 /*****************************************************************************/
    679 /**
    680  *  CTB neighbor info
    681  */
    682 typedef struct
    683 {
    684     /**
    685      *  Slice index of the ctb
    686      */
    687     UWORD16 u2_slice_idx;
    688 
    689     /*************************************************************************/
    690     /* CBF of bottom TU row (replicated in 4 pixel boundary)                 */
    691     /* MSB contains CBF of first TU in the last row and LSB contains CBF     */
    692     /* of last TU in the last row                                            */
    693     /*************************************************************************/
    694     /**
    695      * CBF of bottom TU row
    696      */
    697     UWORD16 u2_packed_cbf;
    698 
    699     /*************************************************************************/
    700     /* QP of bottom TU row (replicated at 8 pixel boundary (Since QP can     */
    701     /* not change at less than min CU granularity)                           */
    702     /*************************************************************************/
    703     /**
    704      * QP of bottom TU row
    705      */
    706     UWORD8 au1_qp[MAX_CU_IN_CTB_ROW];
    707 
    708 }ctb_top_ny_info_t;
    709 
    710 /**
    711  *  CTB level info
    712  */
    713 typedef struct _ctb_t
    714 {
    715     /*************************************************************************/
    716     /* Tile boundary can be detected by looking at tile start x and tile     */
    717     /* start y.  And based on the tile, slice and frame boundary the         */
    718     /* following will be initialized.                                        */
    719     /*************************************************************************/
    720     /**
    721      *  Pointer to left CTB
    722      */
    723     /*  If not available, this will be set to NULL   */
    724     struct _ctb_t *ps_ctb_left;
    725 
    726     /**
    727      *  Pointer to top-left CTB
    728      */
    729     /* If not available, this will be set to NULL   */
    730     ctb_top_ny_info_t *ps_ctb_ny_topleft;
    731 
    732     /**
    733      *  Pointer to top CTB
    734      */
    735     /* If not available, this will be set to NULL  */
    736     ctb_top_ny_info_t *ps_ctb_ny_top;
    737 
    738     /**
    739      *  Pointer to top-right CTB
    740      */
    741     /* If not available, this will be set to NULL */
    742     ctb_top_ny_info_t *ps_ctb_ny_topright;
    743 
    744     /*************************************************************************/
    745     /* Pointer to PU data.                                                   */
    746     /* This points to a MV Bank stored at frame level. Though this           */
    747     /* pointer can be derived by reading offset at frame level, it is        */
    748     /* stored here for faster access. Can be removed if storage of CTB       */
    749     /* structure is critical                                                 */
    750     /*************************************************************************/
    751     /**
    752      * Pointer to PU data
    753      */
    754     pu_t *ps_pu;
    755 
    756     /*************************************************************************/
    757     /* Pointer to a PU map stored at frame level,                            */
    758     /* Though this pointer can be derived by multiplying CTB adress with     */
    759     /* number of minTUs in a CTB, it is stored here for faster access.       */
    760     /* Can be removed if storage of CTB structure is critical                */
    761     /*************************************************************************/
    762     /**
    763      * Pointer to a PU map stored at frame level
    764      */
    765     UWORD8 *pu1_pu_map;
    766 
    767     /**
    768      *  Number of TUs filled in as_tu
    769      */
    770     /*************************************************************************/
    771     /* Having the first entry as 32 bit data, helps in keeping each of       */
    772     /* the structures aligned to 32 bits at CTB level                        */
    773     /*************************************************************************/
    774     WORD32 i4_tu_cnt;
    775 
    776     /**
    777      *  Array to map each min TU unit to a corresponding entry in as_tu
    778      */
    779     UWORD8 *pu1_tu_map;
    780 
    781     /**
    782      *  TU level information
    783      */
    784     /*************************************************************************/
    785     /* Though the allocation for as_pu as done to handle worst case data,    */
    786     /* only valid number of TUs will be filled in the following array.       */
    787     /* Next CTB starts after the valid as_tu entries                         */
    788     /*************************************************************************/
    789     tu_t *ps_tu;
    790 
    791     /**
    792      *  Pointer to transform coeff data
    793      */
    794     /*************************************************************************/
    795     /* Following format is repeated for every coded TU                       */
    796     /* Luma Block                                                            */
    797     /* num_coeffs      : 16 bits                                             */
    798     /* zero_cols       : 8 bits ( 1 bit per 4 columns)                       */
    799     /* sig_coeff_map   : ((TU Size * TU Size) + 31) >> 5 number of WORD32s   */
    800     /* coeff_data      : Non zero coefficients                               */
    801     /* Cb Block (only for last TU in 4x4 case else for every luma TU)        */
    802     /* num_coeffs      : 16 bits                                             */
    803     /* zero_cols       : 8 bits ( 1 bit per 4 columns)                       */
    804     /* sig_coeff_map   : ((TU Size * TU Size) + 31) >> 5 number of WORD32s   */
    805     /* coeff_data      : Non zero coefficients                               */
    806     /* Cr Block (only for last TU in 4x4 case else for every luma TU)        */
    807     /* num_coeffs      : 16 bits                                             */
    808     /* zero_cols       : 8 bits ( 1 bit per 4 columns)                       */
    809     /* sig_coeff_map   : ((TU Size * TU Size) + 31) >> 5 number of WORD32s   */
    810     /* coeff_data      : Non zero coefficients                               */
    811     /*************************************************************************/
    812     void            *pv_coeff_data;
    813 
    814     /**
    815      *  Slice to which the CTB belongs to
    816      */
    817     WORD32 i4_slice_idx;
    818 
    819     /**
    820      *  CTB column position
    821      */
    822     WORD32 i4_pos_x;
    823 
    824     /**
    825      *  CTB row position
    826      */
    827     WORD32 i4_pos_y;
    828 
    829     /**
    830      *  Number of PUs filled in ps_pu
    831      */
    832     WORD32 i4_pu_cnt;
    833 
    834     /**
    835      *  Index of current PU being processed in ps_pu
    836      */
    837     /*  Scratch variable set to 0 at the start of any PU processing function */
    838     WORD32 i4_pu_idx;
    839 
    840     /**
    841      * Vertical Boundary strength
    842      */
    843     /* Two bits per edge.
    844     Stored in format. BS[15] | BS[14] | .. |BS[0]*/
    845     UWORD32 *pu4_vert_bs;
    846 
    847     /**
    848      * Horizontal Boundary strength
    849      */
    850 
    851     /* Two bits per edge.
    852     Stored in format. BS[15] | BS[14] | .. |BS[0]*/
    853     UWORD32 *pu4_horz_bs;
    854 
    855     /**
    856      *  Qp array stored for each 8x8 pixels
    857      */
    858     UWORD8 *pu1_qp;
    859 
    860     /**
    861      *  Pointer to current frame's pu_t array
    862      */
    863     pu_t *ps_frm_pu;
    864 
    865     /**
    866      * Pointer to current frame's pu_t index array, which stores starting index
    867      * of pu_t for every CTB
    868      */
    869     UWORD32 *pu4_frm_pu_idx;
    870 
    871     /**
    872      *  Pointer to current frame's pu map array
    873      */
    874     UWORD8 *pu1_frm_pu_map;
    875 
    876     /*************************************************************************/
    877     /* Need to add encoder specific elements for identifying the order of    */
    878     /* coding for CU, TU and PU if any                                       */
    879     /*************************************************************************/
    880 }ctb_t;
    881 
    882 /*****************************************************************************/
    883 /* The following can be used to typecast coefficient data that is stored     */
    884 /*  per subblock. Note that though i2_level is shown as an array that        */
    885 /*  holds 16 coefficients, only the first few entries will be valid. Next    */
    886 /*  subblocks data starts after the valid number of coefficients. Number     */
    887 /*  of non-zero coefficients will be derived using number of non-zero bits   */
    888 /*  in sig coeff map                                                         */
    889 /*****************************************************************************/
    890 /**
    891  * Structure to hold coefficient info for a 4x4 subblock
    892  */
    893 typedef struct
    894 {
    895     /**
    896      * sub block position
    897      */
    898     UWORD16 u2_subblk_pos;
    899 
    900     /**
    901      * significant coefficient map
    902      */
    903     UWORD16 u2_sig_coeff_map;
    904 
    905     /**
    906      * holds 16 coefficients
    907      */
    908     WORD16  ai2_level[SUBBLK_COEFF_CNT];
    909 }tu_sblk_coeff_data_t;
    910 
    911 
    912 
    913 /*************************************************************************/
    914 /* The following describes how each of the CU cases are handled          */
    915 /*************************************************************************/
    916 
    917 /*************************************************************************/
    918 /* For SKIP CU                                                           */
    919 /* One Inter PU with appropriate MV                                      */
    920 /* One TU which says Y, Cb and Cr CBF is zero with size equal to CB size */
    921 /*************************************************************************/
    922 
    923 /*************************************************************************/
    924 /* For Inter CU                                                          */
    925 /* M Inter PU with appropriate MVs (M between 1 to 4)                    */
    926 /* N TU (N is number of TU in CU)                                        */
    927 /*************************************************************************/
    928 
    929 /*************************************************************************/
    930 /* For Intra CU                                                          */
    931 /* N TU (N is number of TU in CU)                                        */
    932 /* N Intra PU with appropriate pred modes for luma and chroma            */
    933 /*************************************************************************/
    934 
    935 /*************************************************************************/
    936 /* For Intra PCM CU                                                      */
    937 /* One TU which says transquant bypass is 1  with size equal to CB size  */
    938 /* 1 Intra PU with pcm flag set to 1(which ensures no intra pred is done)*/
    939 /*************************************************************************/
    940 
    941 /*************************************************************************/
    942 /* For a CU where cu_transquant_bypass_flag is 1                         */
    943 /* One TU which says transquant bypass is 1  with size equal to CB size  */
    944 /* N Intra/Inter PUs                                                     */
    945 /*************************************************************************/
    946 
    947 /*************************************************************************/
    948 /* For a CU where no_residual_syntax_flag is 1                           */
    949 /* One TU which says Y, Cb, Cr CBF is 0  with size equal to CB size      */
    950 /* N Inter PUs                                                           */
    951 /*************************************************************************/
    952 
    953 
    954 /**
    955  * Structure giving information about the tile
    956  */
    957 typedef struct
    958 {
    959     /* X position of the tile in the current frame in CTB units */
    960     UWORD8 u1_pos_x;
    961 
    962     /* Y position of the tile in the current frame in CTB units */
    963     UWORD8 u1_pos_y;
    964 
    965     /* Tile width in CTB units */
    966     UWORD16 u2_wd;
    967 
    968     /* Tile height in CTB units */
    969     UWORD16 u2_ht;
    970 
    971 }tile_t;
    972 
    973 /**
    974  * Structure to hold Profile tier level info for a given layer
    975  */
    976 
    977 typedef struct
    978 {
    979     /**
    980      *  NAL unit type
    981      */
    982     WORD8 i1_nal_unit_type;
    983 
    984     /**
    985      *  NAL temporal id
    986      */
    987     WORD8 i1_nuh_temporal_id;
    988 }nal_header_t;
    989 
    990 /**
    991  * Structure to hold Profile tier level info for a given layer
    992  */
    993 
    994 typedef struct
    995 {
    996     /**
    997      *  profile_space
    998      */
    999     WORD8 i1_profile_space;
   1000 
   1001     /**
   1002      *  tier_flag
   1003      */
   1004     WORD8 i1_tier_flag;
   1005 
   1006     /**
   1007      *  profile_idc
   1008      */
   1009     WORD8 i1_profile_idc;
   1010 
   1011     /**
   1012      *  profile_compatibility_flag[]
   1013      */
   1014     WORD8 ai1_profile_compatibility_flag[MAX_PROFILE_COMPATBLTY];
   1015 
   1016     /**
   1017      * progressive_source_flag
   1018      */
   1019     WORD8 i1_general_progressive_source_flag;
   1020 
   1021     /**
   1022      * interlaced_source_flag
   1023      */
   1024     WORD8 i1_general_interlaced_source_flag;
   1025 
   1026     /**
   1027      * non_packed_constraint_flag
   1028      */
   1029     WORD8 i1_general_non_packed_constraint_flag;
   1030 
   1031     /**
   1032      * frame_only_constraint_flag
   1033      */
   1034     WORD8 i1_frame_only_constraint_flag;
   1035 
   1036     /**
   1037      * general_max_12bit_constraint_flag
   1038      */
   1039     WORD8 i1_general_max_12bit_constraint_flag;
   1040 
   1041     /**
   1042      * general_max_10bit_constraint_flag
   1043      */
   1044     WORD8 i1_general_max_10bit_constraint_flag;
   1045 
   1046     /**
   1047      * general_max_8bit_constraint_flag
   1048      */
   1049     WORD8 i1_general_max_8bit_constraint_flag;
   1050 
   1051     /**
   1052      * general_max_422chroma_constraint_flag
   1053      */
   1054     WORD8 i1_general_max_422chroma_constraint_flag;
   1055 
   1056     /**
   1057      * general_max_420chroma_constraint_flag
   1058      */
   1059     WORD8 i1_general_max_420chroma_constraint_flag;
   1060 
   1061     /**
   1062      * general_max_monochrome_constraint_flag
   1063      */
   1064     WORD8 i1_general_max_monochrome_constraint_flag;
   1065 
   1066     /**
   1067      * general_intra_constraint_flag
   1068      */
   1069     WORD8 i1_general_intra_constraint_flag;
   1070 
   1071     /**
   1072      * general_one_picture_only_constraint_flag
   1073      */
   1074     WORD8 i1_general_one_picture_only_constraint_flag;
   1075 
   1076     /**
   1077      * general_lower_bit_rate_constraint_flag
   1078      */
   1079     WORD8 i1_general_lower_bit_rate_constraint_flag;
   1080 
   1081     /**
   1082      *  level_idc
   1083      */
   1084     UWORD8 u1_level_idc;
   1085 }profile_tier_lvl_t;
   1086 
   1087 /**
   1088  * Structure to hold Profile tier level info for all layers
   1089  */
   1090 typedef struct
   1091 {
   1092     /**
   1093      *  Profile and tier information for general
   1094      */
   1095     profile_tier_lvl_t s_ptl_gen;
   1096 
   1097     /**
   1098      *  sub_layer_profile_present_flag[]
   1099      */
   1100     WORD8 ai1_sub_layer_profile_present_flag[VPS_MAX_SUB_LAYERS - 1];
   1101 
   1102     /**
   1103      *  sub_layer_level_present_flag[]
   1104      */
   1105     WORD8 ai1_sub_layer_level_present_flag[VPS_MAX_SUB_LAYERS - 1];
   1106 
   1107     /**
   1108      *  Profile and tier information for sub layers
   1109      */
   1110     profile_tier_lvl_t as_ptl_sub[VPS_MAX_SUB_LAYERS - 1];
   1111 
   1112 }profile_tier_lvl_info_t;
   1113 
   1114 /**
   1115  * Structure to hold short term reference picture set info
   1116  */
   1117 typedef struct
   1118 {
   1119     /**
   1120      *  delta_poc_s0_minus1[ i ] and delta_poc_s1_minus1[ i ]
   1121      */
   1122     WORD16 ai2_delta_poc[MAX_DPB_SIZE];
   1123 
   1124     /**
   1125      *  inter_ref_pic_set_prediction_flag
   1126      */
   1127     WORD8 i1_inter_ref_pic_set_prediction_flag;
   1128 
   1129     /**
   1130      *  num_negative_pics
   1131      */
   1132     WORD8 i1_num_neg_pics;
   1133 
   1134     /**
   1135      *  num_positive_pics
   1136      */
   1137     WORD8 i1_num_pos_pics;
   1138 
   1139     /**
   1140      *  used_by_curr_pic_s0_flag[ i ] and used_by_curr_pic_s1_flag[i]
   1141      */
   1142     WORD8 ai1_used[MAX_DPB_SIZE];
   1143 
   1144     /**
   1145      *  Ref Idc
   1146      */
   1147     WORD8 ai1_ref_idc[MAX_DPB_SIZE];
   1148 
   1149     /**
   1150      *  Sum of positive and negative pics for each refence
   1151      */
   1152     WORD8 i1_num_delta_pocs;
   1153 
   1154     /**
   1155      *  Number of ref_idc
   1156      */
   1157     WORD8 i1_num_ref_idc;
   1158 }stref_picset_t;
   1159 
   1160 /**
   1161  * Structure to hold weighted prediction info such as weights and offsets
   1162  */
   1163 typedef struct
   1164 {
   1165     /** luma_log2_weight_denom */
   1166     WORD8 i1_luma_log2_weight_denom;
   1167 
   1168     /** delta_chroma_log2_weight_denom */
   1169     WORD8 i1_chroma_log2_weight_denom;
   1170 
   1171 
   1172     /** luma_weight_l0_flag[ i ] */
   1173     WORD8 i1_luma_weight_l0_flag[MAX_DPB_SIZE];
   1174 
   1175     /** chroma_weight_l0_flag[ i ] */
   1176     WORD8 i1_chroma_weight_l0_flag[MAX_DPB_SIZE];
   1177 
   1178     /** delta_luma_weight_l0[ i ] */
   1179     WORD16 i2_luma_weight_l0[MAX_DPB_SIZE];
   1180 
   1181     /** luma_offset_l0[ i ] */
   1182     WORD16 i2_luma_offset_l0[MAX_DPB_SIZE];
   1183 
   1184     /** delta_chroma_weight_l0[ i ][ j ] */
   1185     WORD16 i2_chroma_weight_l0_cb[MAX_DPB_SIZE];
   1186 
   1187     /** delta_chroma_offset_l0[ i ][ j ] */
   1188     WORD16 i2_chroma_offset_l0_cb[MAX_DPB_SIZE];
   1189 
   1190     /** delta_chroma_weight_l0[ i ][ j ] */
   1191     WORD16 i2_chroma_weight_l0_cr[MAX_DPB_SIZE];
   1192 
   1193     /** delta_chroma_offset_l0[ i ][ j ] */
   1194     WORD16 i2_chroma_offset_l0_cr[MAX_DPB_SIZE];
   1195 
   1196     /** luma_weight_l1_flag[ i ] */
   1197     WORD8 i1_luma_weight_l1_flag[MAX_DPB_SIZE];
   1198 
   1199     /** chroma_weight_l1_flag[ i ] */
   1200     WORD8 i1_chroma_weight_l1_flag[MAX_DPB_SIZE];
   1201 
   1202     /** delta_luma_weight_l1[ i ] */
   1203     WORD16 i2_luma_weight_l1[MAX_DPB_SIZE];
   1204 
   1205     /** luma_offset_l1[ i ] */
   1206     WORD16 i2_luma_offset_l1[MAX_DPB_SIZE];
   1207 
   1208     /** delta_chroma_weight_l1[ i ][ j ] */
   1209     WORD16 i2_chroma_weight_l1_cb[MAX_DPB_SIZE];
   1210 
   1211     /** delta_chroma_offset_l1[ i ][ j ] */
   1212     WORD16 i2_chroma_offset_l1_cb[MAX_DPB_SIZE];
   1213 
   1214     /** delta_chroma_weight_l1[ i ][ j ] */
   1215     WORD16 i2_chroma_weight_l1_cr[MAX_DPB_SIZE];
   1216 
   1217     /** delta_chroma_offset_l1[ i ][ j ] */
   1218     WORD16 i2_chroma_offset_l1_cr[MAX_DPB_SIZE];
   1219 
   1220 }pred_wt_ofst_t;
   1221 
   1222 
   1223 /**
   1224  * Structure to hold Reference picture list modification info
   1225  */
   1226 typedef struct
   1227 {
   1228     /* ref_pic_list_modification_flag_l0 */
   1229     WORD8 i1_ref_pic_list_modification_flag_l0;
   1230 
   1231     /* list_entry_l0[ i ] */
   1232     WORD8 i1_list_entry_l0[16];
   1233 
   1234     /* ref_pic_list_modification_flag_l1 */
   1235     WORD8 i1_ref_pic_list_modification_flag_l1;
   1236 
   1237     /* list_entry_l1[ i ] */
   1238     WORD8 i1_list_entry_l1[16];
   1239 
   1240     /* Reference POC values for L0,L1 */
   1241     WORD32 i4_ref_poc_l0[16];
   1242     WORD32 i4_ref_poc_l1[16];
   1243 }rplm_t;
   1244 
   1245 
   1246 /**
   1247  * Structure to hold VPS info
   1248  */
   1249 typedef struct
   1250 {
   1251     /**
   1252      *  video_parameter_set_id
   1253      */
   1254     WORD8 i1_vps_id;
   1255 
   1256     /**
   1257      *  vps_temporal_id_nesting_flag
   1258      */
   1259     WORD8 i1_vps_temporal_id_nesting_flag;
   1260     /**
   1261      * sub_layer_ordering_info_present_flag
   1262      */
   1263     WORD8 i1_sub_layer_ordering_info_present_flag;
   1264     /**
   1265      *  vps_max_sub_layers_minus1
   1266      */
   1267     WORD8 i1_vps_max_sub_layers;
   1268 
   1269     /**
   1270      *  vps_max_dec_pic_buffering
   1271      */
   1272     WORD8 ai1_vps_max_dec_pic_buffering[VPS_MAX_SUB_LAYERS];
   1273 
   1274     /**
   1275      *  vps_max_num_reorder_pics
   1276      */
   1277     WORD8 ai1_vps_max_num_reorder_pics[VPS_MAX_SUB_LAYERS];
   1278 
   1279     /**
   1280      *  vps_max_latency_increase
   1281      */
   1282     WORD8 ai1_vps_max_latency_increase[VPS_MAX_SUB_LAYERS];
   1283 
   1284     /**
   1285      *  vps_num_hrd_parameters
   1286      */
   1287     WORD8 i1_vps_num_hrd_parameters;
   1288 
   1289     /**
   1290      * vps_max_nuh_reserved_zero_layer_id
   1291      */
   1292     WORD8 i1_vps_max_nuh_reserved_zero_layer_id;
   1293 
   1294     /**
   1295      * vps_num_op_sets
   1296      */
   1297     WORD8 i1_vps_num_op_sets;
   1298 
   1299     /**
   1300      * layer_id_included_flag
   1301      */
   1302     //WORD8 ai1_layer_id_included_flag[2][MAX_NUH_LAYERS];
   1303     /**
   1304      *  Profile, Tier and Level info
   1305      */
   1306     profile_tier_lvl_info_t s_ptl;
   1307 
   1308     /**
   1309      * bit_rate_info_present_flag[i]
   1310      */
   1311     WORD8 ai1_bit_rate_info_present_flag[VPS_MAX_SUB_LAYERS];
   1312 
   1313 
   1314     /**
   1315      * pic_rate_info_present_flag[i]
   1316      */
   1317     WORD8 ai1_pic_rate_info_present_flag[VPS_MAX_SUB_LAYERS];
   1318 
   1319     /**
   1320      * avg_bit_rate[i]
   1321      */
   1322     UWORD16 au2_avg_bit_rate[VPS_MAX_SUB_LAYERS];
   1323     /**
   1324      * max_bit_rate[i]
   1325      */
   1326     UWORD16 au2_max_bit_rate[VPS_MAX_SUB_LAYERS];
   1327     /**
   1328      * constant_pic_rate_idc[i]
   1329      */
   1330     WORD8 ai1_constant_pic_rate_idc[VPS_MAX_SUB_LAYERS];
   1331     /**
   1332      * avg_pic_rate[i]
   1333      */
   1334     UWORD16 au2_avg_pic_rate[VPS_MAX_SUB_LAYERS];
   1335 }vps_t;
   1336 
   1337 /**
   1338  * Sub-layer HRD parameters Info
   1339  */
   1340 typedef struct
   1341 {
   1342     /**
   1343     *  (together with bit_rate_scale) specifies the
   1344     *  maximum input bit rate for the i-th CPB
   1345     */
   1346     UWORD32 au4_bit_rate_value_minus1[32];
   1347     /**
   1348     *  together with cpb_size_scale to specify the
   1349     *  CPB size when the CPB operates at the access unit level.
   1350     */
   1351     UWORD32 au4_cpb_size_value_minus1[32];
   1352 
   1353     /**
   1354     * together with cpb_size_du_scale to specify the CPB size
   1355     * when the CPB operates at sub-picture level
   1356     */
   1357     UWORD32 au4_cpb_size_du_value_minus1[32];
   1358 
   1359     /**
   1360     * specifies the maximum input bit rate for the i-th CPB when the CPB
   1361     * operates at the sub-picture level. bit_rate_du_value_minus1[ i ]
   1362     * shall be in the range of 0 to 2^32 - 2
   1363     */
   1364     UWORD32 au4_bit_rate_du_value_minus1[32];
   1365 
   1366     /**
   1367     * if 1, specifies that the HSS operates in a constant bit rate (CBR) mode
   1368     * if 0, specifies that the HSS operates in a intermittent bit rate (CBR) mode
   1369     */
   1370     UWORD8  au1_cbr_flag[32];
   1371 
   1372 }sub_lyr_hrd_params_t;
   1373 
   1374 /**
   1375  * HRD parameters Info
   1376  */
   1377 typedef struct
   1378 {
   1379 
   1380     /**
   1381     *   Indicates the presence of the
   1382     *   num_units_in_ticks, time_scale flag
   1383     */
   1384     UWORD8 u1_timing_info_present_flag;
   1385 
   1386     /**
   1387     *   Number of units that
   1388     *   correspond to one increment of the
   1389     *   clock. Indicates the  resolution
   1390     */
   1391     UWORD32 u4_num_units_in_tick;
   1392 
   1393     /**
   1394     *   The number of time units that pass in one second
   1395     */
   1396     UWORD32 u4_time_scale;
   1397 
   1398     /**
   1399     * Nal- hrd parameters flag
   1400     */
   1401     UWORD8 u1_nal_hrd_parameters_present_flag;
   1402 
   1403     /**
   1404     * VCL- hrd parameters flag
   1405     */
   1406     UWORD8 u1_vcl_hrd_parameters_present_flag;
   1407 
   1408     /**
   1409     * Indicates the presence of NAL-HRD params or VCL_HRD params
   1410     * in the bitstream
   1411     */
   1412     UWORD8 u1_cpbdpb_delays_present_flag;
   1413 
   1414     /**
   1415     * specifies that sub-picture level CPB removal delay parameters are
   1416     * present in picture timing SEI messages
   1417     */
   1418     UWORD8 u1_sub_pic_cpb_params_present_flag;
   1419 
   1420     /**
   1421     * specify the clock sub-tick
   1422     * (the minimum interval of time that can be represented in the coded data when sub_pic_cpb_params_present_flag is equal to 1)
   1423     */
   1424     UWORD8 u1_tick_divisor_minus2;
   1425 
   1426     /**
   1427     * specifies the length, in bits for the du cpb delay syntax in pt_sei
   1428     */
   1429     UWORD8 u1_du_cpb_removal_delay_increment_length_minus1;
   1430 
   1431     /**
   1432     * Indicates presence of sub_pic_cpb_params in pic timing sei
   1433     */
   1434     UWORD8 u1_sub_pic_cpb_params_in_pic_timing_sei_flag;
   1435 
   1436     /**
   1437     * specifies the length, in bits, of the pic_dpb_output_du_delay syntax
   1438     * element in the picture timing SEI message and the
   1439     * pic_spt_dpb_output_du_delay syntax element in the decoding unit
   1440     * information SEI message
   1441      */
   1442     UWORD8 u1_dpb_output_delay_du_length_minus1;
   1443 
   1444     /**
   1445     * (together with bit_rate_value_minus1) specifies the
   1446     * maximum input bit rate of the i-th CPB
   1447     */
   1448     UWORD32 u4_bit_rate_scale;
   1449 
   1450     /**
   1451     * (together with cpb_size_du_value_minus1) specfies
   1452     * CPB size of the i-th CPB when the CPB operates
   1453     * at the access unit level
   1454     */
   1455     UWORD32 u4_cpb_size_scale;
   1456 
   1457     /**
   1458     * (together with cpb_size_du_value_minus1) specfies
   1459     * CPB size of the i-th CPB when the CPB operates
   1460     * at the sub-picture level
   1461     */
   1462     UWORD32 u4_cpb_size_du_scale;
   1463 
   1464 
   1465     /**
   1466     * specifies the length, in bits for initial cpb delay (nal/vcl)sysntax in bp sei
   1467     */
   1468     UWORD8  u1_initial_cpb_removal_delay_length_minus1;
   1469 
   1470     /**
   1471     * specifies the length, in bits for the au cpb delay syntax in pt_sei
   1472     */
   1473     UWORD8  u1_au_cpb_removal_delay_length_minus1;
   1474 
   1475     /**
   1476     * specifies the length, in bits, of the pic_dpb_output_delay syntax element in the pt SEI message
   1477     */
   1478     UWORD8  u1_dpb_output_delay_length_minus1;
   1479 
   1480     /**
   1481     * if 1, , for the highest temporal sub-layers, the temporal distance between the HRD output times
   1482     *  of consecutive pictures in output order is constrained refer to Table E-6
   1483     */
   1484     UWORD8 au1_fixed_pic_rate_general_flag[6];
   1485 
   1486     UWORD8 au1_fixed_pic_rate_within_cvs_flag[6];
   1487 
   1488     /**
   1489     * if 1, , for the highest temporal sub-layers, the temporal distance (in clock ticks) between the
   1490     * element units that specify HRD output times of consecutive pictures in output order is constrained
   1491     * refer to Table E-6
   1492     */
   1493     UWORD8 au1_elemental_duration_in_tc_minus1[6];
   1494 
   1495     /**
   1496     * specifies the HRD operational mode
   1497     */
   1498     UWORD8 au1_low_delay_hrd_flag[6];
   1499 
   1500     /**
   1501     * 1 specifies the number of alternative CPB specifications in the
   1502     * bitstream of the cvs when HighestTid is equal to i
   1503     */
   1504     UWORD8 au1_cpb_cnt_minus1[6];
   1505 
   1506 
   1507     /**
   1508     *  VUI level Sub-layer HRD parameters
   1509     */
   1510     sub_lyr_hrd_params_t as_sub_layer_hrd_params[6];
   1511 
   1512 }hrd_params_t;
   1513 
   1514 
   1515 /**
   1516  * Structure to hold VUI parameters Info
   1517  */
   1518 typedef struct
   1519 {
   1520     /**
   1521     *  indicates the presence of aspect_ratio
   1522     */
   1523     UWORD8 u1_aspect_ratio_info_present_flag;
   1524 
   1525     /**
   1526     *  specifies the aspect ratio of the luma samples
   1527     */
   1528     UWORD8 u1_aspect_ratio_idc;
   1529 
   1530     /**
   1531     *  width of the luma samples. user dependent
   1532     */
   1533     UWORD16 u2_sar_width;
   1534 
   1535     /**
   1536     *  hieght of the luma samples. user dependent
   1537     */
   1538     UWORD16 u2_sar_height;
   1539 
   1540     /**
   1541     * if 1, specifies that the overscan_appropriate_flag is present
   1542     * if 0, the preferred display method for the video signal is unspecified
   1543     */
   1544     UWORD8 u1_overscan_info_present_flag;
   1545 
   1546     /**
   1547     * if 1,indicates that the cropped decoded pictures output
   1548     * are suitable for display using overscan
   1549     */
   1550     UWORD8 u1_overscan_appropriate_flag;
   1551 
   1552     /**
   1553     * if 1 specifies that video_format, video_full_range_flag and
   1554     * colour_description_present_flag are present
   1555     */
   1556     UWORD8 u1_video_signal_type_present_flag;
   1557 
   1558     /**
   1559     *
   1560     */
   1561     UWORD8 u1_video_format;
   1562 
   1563     /**
   1564     * indicates the black level and range of the luma and chroma signals
   1565     */
   1566     UWORD8 u1_video_full_range_flag;
   1567 
   1568     /**
   1569     * if 1,to 1 specifies that colour_primaries, transfer_characteristics
   1570     * and matrix_coefficients are present
   1571     */
   1572     UWORD8 u1_colour_description_present_flag;
   1573 
   1574     /**
   1575     * indicates the chromaticity coordinates of the source primaries
   1576     */
   1577     UWORD8 u1_colour_primaries;
   1578 
   1579     /**
   1580     * indicates the opto-electronic transfer characteristic of the source picture
   1581     */
   1582     UWORD8 u1_transfer_characteristics;
   1583 
   1584     /**
   1585     * the matrix coefficients used in deriving luma and chroma signals
   1586     * from the green, blue, and red primaries
   1587     */
   1588     UWORD8 u1_matrix_coefficients;
   1589 
   1590     /**
   1591     * if 1, specifies that chroma_sample_loc_type_top_field and
   1592     * chroma_sample_loc_type_bottom_field are present
   1593     */
   1594     UWORD8 u1_chroma_loc_info_present_flag;
   1595 
   1596     /**
   1597     * location of chroma samples
   1598     */
   1599     UWORD8 u1_chroma_sample_loc_type_top_field;
   1600 
   1601     UWORD8 u1_chroma_sample_loc_type_bottom_field;
   1602 
   1603     /**
   1604     * if 1, indicates that the value of all decoded chroma samples is
   1605     * equal to 1 << ( BitDepthC - 1 )
   1606     */
   1607     UWORD8 u1_neutral_chroma_indication_flag;
   1608 
   1609     /**
   1610     *  1 indicates that the coded video sequence conveys pictures that represent fields
   1611     *  0 indicates the pictures that represents field
   1612     */
   1613     UWORD8 u1_field_seq_flag;
   1614 
   1615     /**
   1616     * specifies that picture timing SEI messages are present for every picture
   1617     */
   1618     UWORD8 u1_frame_field_info_present_flag;
   1619 
   1620     /**
   1621     * 1 indicates that the default display window parameters follow next in the VUI
   1622     */
   1623     UWORD8 u1_default_display_window_flag;
   1624 
   1625     /**
   1626     * specify the samples of the pictures in the coded video sequence
   1627     * that are within the default display window,
   1628     * in terms of a rectangular region specified in picture coordinates for display
   1629     */
   1630     UWORD32 u4_def_disp_win_left_offset;
   1631 
   1632     UWORD32 u4_def_disp_win_right_offset;
   1633 
   1634     UWORD32 u4_def_disp_win_top_offset;
   1635 
   1636     UWORD32 u4_def_disp_win_bottom_offset;
   1637 
   1638     /**
   1639     *  to 1 specifies that the syntax structure hrd_parameters is present in the vui_parameters syntax structue
   1640     */
   1641     UWORD8 u1_vui_hrd_parameters_present_flag;
   1642 
   1643     /**
   1644     *  VUI level HRD parameters
   1645     */
   1646     hrd_params_t s_vui_hrd_parameters;
   1647 
   1648     /**
   1649     *   Indicates the presence of the
   1650     *   num_units_in_ticks, time_scale flag
   1651     */
   1652     UWORD8 u1_vui_timing_info_present_flag;
   1653 
   1654     /**
   1655     *   Number of units that
   1656     *   correspond to one increment of the
   1657     *   clock. Indicates the  resolution
   1658     */
   1659     UWORD32 u4_vui_num_units_in_tick;
   1660 
   1661     /**
   1662     *   The number of time units that pass in one second
   1663     */
   1664     UWORD32 u4_vui_time_scale;
   1665     /**
   1666     * if 1, indicates that the POC for each picture in the coded video sequence (cvs) (not the first picture), in decoding order,
   1667     * is proportional to the output time of the picture relative to that of the first picture in the cvs
   1668     */
   1669     UWORD8 u1_poc_proportional_to_timing_flag;
   1670 
   1671     /**
   1672     * num_ticks_poc_diff_one_minus1 plus 1 specifies the number of clock ticks
   1673     * corresponding to a difference of poc values equal to 1
   1674     */
   1675     UWORD8 u1_num_ticks_poc_diff_one_minus1;
   1676 
   1677     /**
   1678     * 1, specifies that the following cvs bitstream restriction parameters are present
   1679     */
   1680     UWORD8 u1_bitstream_restriction_flag;
   1681 
   1682     /**
   1683     *  if 1, indicates that each pps that is active in the cvs has
   1684     *  the same value of the tile syntax elements
   1685     */
   1686     UWORD8 u1_tiles_fixed_structure_flag;
   1687 
   1688     /**
   1689     * if 0, indicates that no pel outside the pic boundaries and
   1690     * no sub-pels derived using pels outside the pic boundaries is used for inter prediction
   1691     */
   1692     UWORD8 u1_motion_vectors_over_pic_boundaries_flag;
   1693 
   1694     /**
   1695     * if 1, indicates
   1696     * all P/B slices belonging to the same pic have an identical refpic list0,
   1697     * all B slices that belong to the same picture have an identical refpic list1.
   1698     */
   1699     UWORD8 u1_restricted_ref_pic_lists_flag;
   1700 
   1701     /**
   1702     *   min_spatial_segmentation_idc, when not equal to 0, establishes a bound on the maximum possible size of distinct
   1703     *   coded spatial segmentation regions in the pictures of the CVS. When min_spatial_segmentation_idc is not present, it is
   1704     *   inferred to be equal to 0. The value of min_spatial_segmentation_idc shall be in the range of 0 to 4095, inclusive.
   1705     *
   1706     *   can be used by a decoder to calculate the maximum number of luma samples to be processed by one processing thread
   1707     *
   1708     *   If tiles=0 and entropy_sync=0 then
   1709     *       no slice shall exceed ( 4 * PicSizeInSamplesY ) / minSpatialSegmentationTimes4 luma samples
   1710     *
   1711     *   If tiles=1 and entropy_sync=0 then
   1712     *       no tile shall exceed ( 4 * PicSizeInSamplesY ) / minSpatialSegmentationTimes4 luma samples
   1713     *
   1714     *   If tiles=0 and entropy_sync=1 then
   1715     *       ( 2 * pic_height_in_luma_samples + pic_width_in_luma_samples ) * CtbSizeY
   1716     *               <= ( 4 * PicSizeInSamplesY ) / minSpatialSegmentationTimes4
   1717     */
   1718     UWORD32 u4_min_spatial_segmentation_idc;
   1719     /**
   1720     * Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units
   1721     * associated with any coded picture
   1722     */
   1723     UWORD8 u1_max_bytes_per_pic_denom;
   1724 
   1725     /**
   1726     *  Indicates an upper bound for the number of bits of coding_unit() data
   1727     */
   1728     UWORD8 u1_max_bits_per_mincu_denom;
   1729 
   1730     /**
   1731     * Indicate the maximum absolute value of a decoded horizontal MV component
   1732     * in quarter-pel luma units
   1733     */
   1734     UWORD8 u1_log2_max_mv_length_horizontal;
   1735 
   1736     /**
   1737     * Indicate the maximum absolute value of a decoded vertical MV component
   1738     * in quarter-pel luma units
   1739     */
   1740     UWORD8 u1_log2_max_mv_length_vertical;
   1741 
   1742 
   1743 }vui_t;
   1744 
   1745 
   1746 /**
   1747  * Structure to hold SPS info
   1748  */
   1749 typedef struct
   1750 {
   1751     /**
   1752      * pic_width_in_luma_samples
   1753      */
   1754     WORD16 i2_pic_width_in_luma_samples;
   1755 
   1756     /**
   1757      *  pic_height_in_luma_samples
   1758      */
   1759     WORD16 i2_pic_height_in_luma_samples;
   1760 
   1761     /**
   1762      *  pic_crop_left_offset
   1763      */
   1764     WORD16 i2_pic_crop_left_offset;
   1765 
   1766     /**
   1767      *  pic_crop_right_offset
   1768      */
   1769     WORD16 i2_pic_crop_right_offset;
   1770 
   1771     /**
   1772      *  pic_crop_top_offset
   1773      */
   1774     WORD16 i2_pic_crop_top_offset;
   1775 
   1776     /**
   1777      *  pic_crop_bottom_offset
   1778      */
   1779     WORD16 i2_pic_crop_bottom_offset;
   1780 
   1781     /**
   1782      *  seq_parameter_set_id
   1783      */
   1784     WORD8 i1_sps_id;
   1785 
   1786     /**
   1787      *  video_parameter_set_id
   1788      */
   1789     WORD8 i1_vps_id;
   1790 
   1791     /**
   1792      *  sps_max_sub_layers_minus1
   1793      */
   1794     WORD8 i1_sps_max_sub_layers;
   1795 
   1796     /**
   1797      *  chroma_format_idc
   1798      */
   1799     WORD8 i1_chroma_format_idc;
   1800 
   1801     /**
   1802      * Bit depth of luma samples
   1803      */
   1804     WORD8 i1_bit_depth_luma_minus8;
   1805 
   1806     /**
   1807      * Bit depth of chrma samples
   1808      */
   1809     WORD8 i1_bit_depth_chroma_minus8;
   1810 
   1811     /* separate_colour_plane_flag */
   1812     WORD8 i1_separate_colour_plane_flag;
   1813 
   1814     /**
   1815      *  pic_cropping_flag
   1816      */
   1817     WORD8 i1_pic_cropping_flag;
   1818 
   1819     /**
   1820      *  pcm_enabled_flag
   1821      */
   1822     WORD8 i1_pcm_enabled_flag;
   1823 
   1824     /**
   1825      *  pcm_sample_bit_depth_luma
   1826      */
   1827     WORD8 i1_pcm_sample_bit_depth_luma;
   1828 
   1829     /**
   1830      *  pcm_sample_bit_depth_chroma
   1831      */
   1832     WORD8 i1_pcm_sample_bit_depth_chroma;
   1833 
   1834     /**
   1835      *  log2_max_pic_order_cnt_lsb_minus4
   1836      */
   1837     WORD8 i1_log2_max_pic_order_cnt_lsb;
   1838     /**
   1839      * sps_sub_layer_ordering_info_present_flag
   1840      */
   1841     WORD8 i1_sps_sub_layer_ordering_info_present_flag;
   1842     /**
   1843      *  sps_max_dec_pic_buffering
   1844      */
   1845     WORD8 ai1_sps_max_dec_pic_buffering[SPS_MAX_SUB_LAYERS];
   1846 
   1847     /**
   1848      *  sps_max_num_reorder_pics
   1849      */
   1850     WORD8 ai1_sps_max_num_reorder_pics[SPS_MAX_SUB_LAYERS];
   1851 
   1852     /**
   1853      *  sps_max_latency_increase
   1854      */
   1855     WORD8 ai1_sps_max_latency_increase[SPS_MAX_SUB_LAYERS];
   1856 
   1857     /**
   1858      *  log2_min_coding_block_size_minus3
   1859      */
   1860     WORD8 i1_log2_min_coding_block_size;
   1861 
   1862     /**
   1863      *  log2_diff_max_min_coding_block_size
   1864      */
   1865     WORD8 i1_log2_diff_max_min_coding_block_size;
   1866 
   1867     /**
   1868      *  log2_min_transform_block_size_minus2
   1869      */
   1870     WORD8 i1_log2_min_transform_block_size;
   1871 
   1872     /**
   1873      *  log2_diff_max_min_transform_block_size
   1874      */
   1875     WORD8 i1_log2_diff_max_min_transform_block_size;
   1876 
   1877     /**
   1878      *  log2_min_pcm_coding_block_size_minus3
   1879      */
   1880     WORD8 i1_log2_min_pcm_coding_block_size;
   1881 
   1882     /**
   1883      *  log2_diff_max_min_pcm_coding_block_size
   1884      */
   1885     WORD8 i1_log2_diff_max_min_pcm_coding_block_size;
   1886 
   1887     /**
   1888      *  max_transform_hierarchy_depth_inter
   1889      */
   1890     WORD8 i1_max_transform_hierarchy_depth_inter;
   1891 
   1892     /**
   1893      *  max_transform_hierarchy_depth_intra
   1894      */
   1895     WORD8 i1_max_transform_hierarchy_depth_intra;
   1896 
   1897     /**
   1898      *  scaling_list_enable_flag
   1899      */
   1900     WORD8 i1_scaling_list_enable_flag;
   1901 
   1902     /**
   1903      *  sps_scaling_list_data_present_flag
   1904      */
   1905     WORD8 i1_sps_scaling_list_data_present_flag;
   1906 
   1907     /**
   1908      *  amp_enabled_flag
   1909      */
   1910     WORD8 i1_amp_enabled_flag;
   1911 
   1912     /**
   1913      *  sample_adaptive_offset_enabled_flag
   1914      */
   1915     WORD8 i1_sample_adaptive_offset_enabled_flag;
   1916 
   1917     /**
   1918      *  pcm_loop_filter_disable_flag
   1919      */
   1920     WORD8 i1_pcm_loop_filter_disable_flag;
   1921 
   1922     /**
   1923      *  sps_temporal_id_nesting_flag
   1924      */
   1925     WORD8 i1_sps_temporal_id_nesting_flag;
   1926 
   1927     /**
   1928      *  num_short_term_ref_pic_sets
   1929      */
   1930     WORD8 i1_num_short_term_ref_pic_sets;
   1931 
   1932     /**
   1933      *  long_term_ref_pics_present_flag
   1934      */
   1935     WORD8 i1_long_term_ref_pics_present_flag;
   1936 
   1937     /**
   1938      *  num_long_term_ref_pics_sps
   1939      */
   1940     WORD8 i1_num_long_term_ref_pics_sps;
   1941 
   1942     /**
   1943      *  lt_ref_pic_poc_lsb_sps[]
   1944      */
   1945     WORD8 ai1_lt_ref_pic_poc_lsb_sps[MAX_LTREF_PICS_SPS];
   1946 
   1947     /**
   1948      *  used_by_curr_pic_lt_sps_flag[]
   1949      */
   1950     WORD8 ai1_used_by_curr_pic_lt_sps_flag[MAX_LTREF_PICS_SPS];
   1951 
   1952     /**
   1953      *  sps_temporal_mvp_enable_flag
   1954      */
   1955     WORD8 i1_sps_temporal_mvp_enable_flag;
   1956 
   1957     /**
   1958      * strong_intra_smoothing_enable_flag
   1959      */
   1960     WORD8 i1_strong_intra_smoothing_enable_flag;
   1961 
   1962     /**
   1963      *  vui_parameters_present_flag
   1964      */
   1965     WORD8 i1_vui_parameters_present_flag;
   1966 
   1967     /**
   1968      * vui parameters Structure info
   1969      */
   1970     vui_t s_vui_parameters;
   1971 
   1972     /**
   1973      *  Log2(CTB Size) in luma units
   1974      */
   1975 
   1976     WORD8 i1_log2_ctb_size;
   1977 
   1978     /**
   1979      * Maximum transform block size
   1980      */
   1981     WORD8 i1_log2_max_transform_block_size;
   1982 
   1983     /**
   1984      *  Picture width in CTB units
   1985      */
   1986 
   1987     WORD16 i2_pic_wd_in_ctb;
   1988 
   1989     /**
   1990      *  Picture height in CTB units
   1991      */
   1992 
   1993     WORD16 i2_pic_ht_in_ctb;
   1994 
   1995     /**
   1996      * Picture width in min CB units
   1997      */
   1998 
   1999     WORD16 i2_pic_wd_in_min_cb;
   2000 
   2001     /**
   2002      *  Picture height in min CB units
   2003      */
   2004 
   2005     WORD16 i2_pic_ht_in_min_cb;
   2006 
   2007     /**
   2008      *  Picture size in CTB units
   2009      */
   2010     WORD32 i4_pic_size_in_ctb;
   2011 
   2012     /**
   2013      *  Profile, Tier and Level info
   2014      */
   2015 
   2016     profile_tier_lvl_info_t s_ptl;
   2017 
   2018     /**
   2019      *  Short term reference pic set
   2020      */
   2021     stref_picset_t as_stref_picset[MAX_STREF_PICS_SPS];
   2022 
   2023     /**
   2024      *  Pointer to scaling matrix
   2025      */
   2026     /*************************************************************************/
   2027     /* Contanis the matrice in the following order in a 1D buffer            */
   2028     /* Intra 4 x 4 Y, 4 x 4 U, 4 x 4 V                                       */
   2029     /* Inter 4 x 4 Y, 4 x 4 U, 4 x 4 V                                       */
   2030     /* Intra 8 x 8 Y, 8 x 8 U, 8 x 8 V                                       */
   2031     /* Inter 8 x 8 Y, 8 x 8 U, 8 x 8 V                                       */
   2032     /* Intra 16x16 Y, 16x16 U, 16x16 V                                       */
   2033     /* Inter 16x16 Y, 16x16 U, 16x16 V                                       */
   2034     /* Intra 32x32 Y                                                         */
   2035     /* Inter 32x32 Y                                                         */
   2036     /*************************************************************************/
   2037     WORD16 *pi2_scaling_mat;
   2038 
   2039 
   2040     /*
   2041      * Flag indicating if the SPS is parsed
   2042      */
   2043     WORD8 i1_sps_valid;
   2044 
   2045 }sps_t;
   2046 
   2047 /**
   2048  * Structure to hold PPS info
   2049  */
   2050 typedef struct
   2051 {
   2052     /**
   2053      *  Pointer to scaling matrix
   2054      */
   2055     /*************************************************************************/
   2056     /* Contanis the matrice in the following order in a 1D buffer            */
   2057     /* Intra 4 x 4 Y, 4 x 4 U, 4 x 4 V                                       */
   2058     /* Inter 4 x 4 Y, 4 x 4 U, 4 x 4 V                                       */
   2059     /* Intra 8 x 8 Y, 8 x 8 U, 8 x 8 V                                       */
   2060     /* Inter 8 x 8 Y, 8 x 8 U, 8 x 8 V                                       */
   2061     /* Intra 16x16 Y, 16x16 U, 16x16 V                                       */
   2062     /* Inter 16x16 Y, 16x16 U, 16x16 V                                       */
   2063     /* Intra 32x32 Y                                                         */
   2064     /* Inter 32x32 Y                                                         */
   2065     /*************************************************************************/
   2066     WORD16 *pi2_scaling_mat;
   2067 
   2068     /**
   2069      *  Pointer to an array containing tile info such as position, width, height
   2070      *  of each tile
   2071      */
   2072 
   2073     /* column_width_minus1[ i ] and row_height_minus1[ i ] */
   2074     tile_t *ps_tile;
   2075 
   2076     /**
   2077      *  pic_parameter_set_id
   2078      */
   2079     WORD8 i1_pps_id;
   2080 
   2081     /**
   2082      *  seq_parameter_set_id
   2083      */
   2084     WORD8 i1_sps_id;
   2085 
   2086     /**
   2087      *  sign_data_hiding_flag
   2088      */
   2089     WORD8 i1_sign_data_hiding_flag;
   2090 
   2091     /**
   2092      *  cabac_init_present_flag
   2093      */
   2094     WORD8 i1_cabac_init_present_flag;
   2095 
   2096     /**
   2097      *  num_ref_idx_l0_default_active_minus1
   2098      */
   2099     WORD8 i1_num_ref_idx_l0_default_active;
   2100 
   2101     /**
   2102      * num_ref_idx_l1_default_active_minus1
   2103      */
   2104     WORD8 i1_num_ref_idx_l1_default_active;
   2105 
   2106     /**
   2107      *  pic_init_qp_minus26
   2108      */
   2109     WORD8 i1_pic_init_qp;
   2110 
   2111     /**
   2112      *  constrained_intra_pred_flag
   2113      */
   2114     WORD8 i1_constrained_intra_pred_flag;
   2115 
   2116     /**
   2117      *  transform_skip_enabled_flag
   2118      */
   2119     WORD8 i1_transform_skip_enabled_flag;
   2120 
   2121     /**
   2122      *  cu_qp_delta_enabled_flag
   2123      */
   2124     WORD8 i1_cu_qp_delta_enabled_flag;
   2125 
   2126     /**
   2127      * diff_cu_qp_delta_depth
   2128      */
   2129     WORD8 i1_diff_cu_qp_delta_depth;
   2130 
   2131     /**
   2132      *  pic_cb_qp_offset
   2133      */
   2134     WORD8 i1_pic_cb_qp_offset;
   2135 
   2136     /**
   2137      *  pic_cr_qp_offset
   2138      */
   2139     WORD8 i1_pic_cr_qp_offset;
   2140 
   2141     /**
   2142      *  pic_slice_level_chroma_qp_offsets_present_flag
   2143      */
   2144     WORD8 i1_pic_slice_level_chroma_qp_offsets_present_flag;
   2145 
   2146     /**
   2147      *  weighted_pred_flag
   2148      */
   2149     WORD8 i1_weighted_pred_flag;
   2150 
   2151     /**
   2152      *  weighted_bipred_flag
   2153      */
   2154     WORD8 i1_weighted_bipred_flag;
   2155 
   2156     /**
   2157      *  output_flag_present_flag
   2158      */
   2159     WORD8 i1_output_flag_present_flag;
   2160 
   2161     /**
   2162      *  transquant_bypass_enable_flag
   2163      */
   2164     WORD8 i1_transquant_bypass_enable_flag;
   2165 
   2166     /**
   2167      *  dependent_slice_enabled_flag
   2168      */
   2169     WORD8 i1_dependent_slice_enabled_flag;
   2170 
   2171     /**
   2172      *  tiles_enabled_flag
   2173      */
   2174     WORD8 i1_tiles_enabled_flag;
   2175 
   2176     /**
   2177      *  entropy_coding_sync_enabled_flag
   2178      */
   2179     WORD8 i1_entropy_coding_sync_enabled_flag;
   2180 
   2181     /**
   2182      * entropy_slice_enabled_flag
   2183      */
   2184     WORD8 i1_entropy_slice_enabled_flag;
   2185 
   2186     /**
   2187      *  num_tile_columns_minus1
   2188      */
   2189     WORD8 i1_num_tile_columns;
   2190 
   2191     /**
   2192      *  num_tile_rows_minus1
   2193      */
   2194     WORD8 i1_num_tile_rows;
   2195 
   2196     /**
   2197      *  uniform_spacing_flag
   2198      */
   2199     WORD8 i1_uniform_spacing_flag;
   2200 
   2201     /**
   2202      *  loop_filter_across_tiles_enabled_flag
   2203      */
   2204     WORD8 i1_loop_filter_across_tiles_enabled_flag;
   2205 
   2206     /**
   2207      *  loop_filter_across_slices_enabled_flag
   2208      */
   2209     WORD8 i1_loop_filter_across_slices_enabled_flag;
   2210 
   2211     /**
   2212      *  deblocking_filter_control_present_flag
   2213      */
   2214     WORD8 i1_deblocking_filter_control_present_flag;
   2215 
   2216     /**
   2217      *  deblocking_filter_override_enabled_flag
   2218      */
   2219     WORD8 i1_deblocking_filter_override_enabled_flag;
   2220 
   2221     /**
   2222      *  pic_disable_deblocking_filter_flag
   2223      */
   2224     WORD8 i1_pic_disable_deblocking_filter_flag;
   2225 
   2226     /**
   2227      *  beta_offset_div2
   2228      */
   2229     WORD8 i1_beta_offset_div2;
   2230 
   2231     /**
   2232      *  tc_offset_div2
   2233      */
   2234     WORD8 i1_tc_offset_div2;
   2235 
   2236     /**
   2237      *  pps_scaling_list_data_present_flag
   2238      */
   2239     WORD8 i1_pps_scaling_list_data_present_flag;
   2240 
   2241     /**
   2242      * lists_modification_present_flag
   2243      */
   2244     WORD8 i1_lists_modification_present_flag;
   2245 
   2246     /**
   2247      * num_extra_slice_header_bits
   2248      */
   2249     WORD8 i1_num_extra_slice_header_bits;
   2250 
   2251     /**
   2252      *  log2_parallel_merge_level_minus2
   2253      */
   2254     WORD8 i1_log2_parallel_merge_level;
   2255 
   2256     /**
   2257      *  slice_header_extension_present_flag
   2258      */
   2259     WORD8 i1_slice_header_extension_present_flag;
   2260 
   2261     /**
   2262      *  slice_extension_present_flag
   2263      */
   2264     WORD8 i1_slice_extension_present_flag;
   2265 
   2266     /**
   2267      *  scaling_list_dc_coef_minus8
   2268      */
   2269     /*************************************************************************/
   2270     /* DC value of the scaling list                                          */
   2271     /* Only 16 x 16 and 32 x 32 scaling lists have valid entries.            */
   2272     /* Entries stored for all sizes for uniformity.                          */
   2273     /* Remaining will be initialized to default values if used               */
   2274     /*************************************************************************/
   2275     UWORD8 au1_scaling_list_dc_coef[TOTAL_SCALE_MAT_COUNT];
   2276 
   2277     /**
   2278      * Log2MinCuQpDeltaSize
   2279      */
   2280     WORD8 i1_log2_min_cu_qp_delta_size;
   2281 
   2282 
   2283     /*
   2284      * Flag indicating if the PPS is parsed
   2285      */
   2286     WORD8 i1_pps_valid;
   2287 
   2288 }pps_t;
   2289 
   2290 
   2291 
   2292 /**
   2293  * Buffering Period SEI parameters Info
   2294  */
   2295 typedef struct
   2296 {
   2297     /**
   2298     * specifies SPS Id active for the coded picture assosiated
   2299     * with the bp message.
   2300     */
   2301     UWORD8  u1_sps_id;
   2302 
   2303     /**
   2304     * Derived from Hrd parameters
   2305     */
   2306     UWORD8  u1_sub_pic_cpb_params_present_flag;
   2307 
   2308     /**
   2309     * specifies the presence of the initial_alt_cpb_removal_delay[ i ]
   2310     * and initial_alt_cpb_removal_offset[ i ] syntax elements
   2311     */
   2312     UWORD8  u1_rap_cpb_params_present_flag;
   2313 
   2314     /**
   2315     * cbp removal delay used in buffering period SEI
   2316     */
   2317     UWORD32 cpb_delay_offset;
   2318 
   2319     /**
   2320     * dbp removal delay used in buffering period SEI
   2321     */
   2322     UWORD32 dpb_delay_offset;
   2323 
   2324     /**
   2325     * concatanation flag
   2326     */
   2327     UWORD8 concatenation_flag;
   2328 
   2329     /**
   2330     * delata cbp removal delay
   2331     */
   2332     UWORD32 au_cpb_removal_delay_delta_minus1;
   2333 
   2334     /**
   2335     * specify the default initial CPB removal delays, respectively,
   2336     * for the CPB when the NAL HRD parameters are in use
   2337     */
   2338     UWORD32 au4_nal_initial_cpb_removal_delay[32];
   2339 
   2340     /**
   2341     * specify the alternate initial CPB removal delays, respectively,
   2342     * for the CPB when the NAL HRD parameters are in use
   2343     */
   2344     UWORD32 au4_nal_initial_alt_cpb_removal_delay[32];
   2345 
   2346     /**
   2347     * specify the initial CPB removal delay offset, respectively,
   2348     * for the CPB when the NAL HRD parameters are in use
   2349     */
   2350     UWORD32 au4_nal_initial_cpb_removal_delay_offset[32];
   2351 
   2352     /**
   2353     * specify the alternate initial CPB removal delays offsets, respectively,
   2354     * for the CPB when the NAL HRD parameters are in use
   2355     */
   2356     UWORD32 au4_nal_initial_alt_cpb_removal_delay_offset[32];
   2357 
   2358     /**
   2359     * specify the default initial CPB removal delays, respectively,
   2360     * for the CPB when the VCL HRD parameters are in use
   2361     */
   2362     UWORD32 au4_vcl_initial_cpb_removal_delay[32];
   2363 
   2364     /**
   2365     * specify the initial alt CPB removal delays , respectively,
   2366     * for the CPB when the VCL HRD parameters are in use
   2367     */
   2368     UWORD32 au4_vcl_initial_alt_cpb_removal_delay[32];
   2369 
   2370     /**
   2371     * specify the initial CPB removal delay offset, respectively,
   2372     * for the CPB when the VCL HRD parameters are in use
   2373     */
   2374     UWORD32 au4_vcl_initial_cpb_removal_delay_offset[32];
   2375 
   2376     /**
   2377     * specify the alternate initial CPB removal delays offsets, respectively,
   2378     * for the CPB when the VCL HRD parameters are in use
   2379     */
   2380     UWORD32 au4_vcl_initial_alt_cpb_removal_delay_offset[32];
   2381 
   2382     /**
   2383     *  Inital CPB removal delay
   2384     */
   2385     UWORD32 u4_initial_cpb_removal_delay_length;
   2386 
   2387     /**
   2388     *  CPB cnt for corr. sublayer
   2389     */
   2390     UWORD32 u4_cpb_cnt;
   2391 
   2392 
   2393     /**
   2394     * VBV buffer size used in buffering period SEI
   2395     */
   2396     UWORD32 u4_buffer_size_sei;
   2397 
   2398     /**
   2399     * Encoder buffer fullness  used in buffering period SEI
   2400     */
   2401     UWORD32 u4_dbf_sei;
   2402 
   2403     /**
   2404     * target bitrate used in buffering period SEI
   2405     */
   2406     UWORD32 u4_target_bit_rate_sei;
   2407 
   2408 
   2409 
   2410 
   2411 }buf_period_sei_params_t;
   2412 
   2413 
   2414 /**
   2415  * Picture Timing SEI parameters Info
   2416  */
   2417 typedef struct
   2418 {
   2419     /**
   2420     * derived from vui parameters
   2421     */
   2422     UWORD8 u1_frame_field_info_present_flag;
   2423 
   2424     /**
   2425     * indicates whether a picture should be displayed as a
   2426     * frame or as one or more fields
   2427     */
   2428     UWORD32 u4_pic_struct;
   2429 
   2430     UWORD8  u1_num_clk_ticks;
   2431 
   2432     /**
   2433     * indicates whether a scan-type of the pic should be interpreted
   2434     * as progressive or interlaced
   2435     */
   2436     UWORD8 u1_progressive_source_idc;
   2437 
   2438     /**
   2439     * if 1, indicates if the current pic is a duplicte pic in output order
   2440     */
   2441     UWORD8 u1_duplicate_flag;
   2442 
   2443     /**
   2444     * specifies the number clock ticks between the nominal CPB removal time
   2445     * au associated with the pt SEI message and
   2446     * the preceding au in decoding order that contained a bp SEI message
   2447     */
   2448     UWORD32 u4_au_cpb_removal_delay_minus1;
   2449 
   2450     /**
   2451     * compute the DPB output time of the picture
   2452     */
   2453     UWORD32 u4_pic_dpb_output_delay;
   2454 
   2455     UWORD32 u4_pic_dpb_output_du_delay;
   2456 
   2457     /**
   2458     * specifies the number of decoding units in the access unit
   2459     * the picture timing SEI message is associated with
   2460     */
   2461     UWORD32 u4_num_decoding_units_minus1;
   2462 
   2463     /**
   2464     * if 1 specifies that the du_common_cpb_removal_delay_increment_minus1 is present
   2465     */
   2466     UWORD32 u4_du_common_cpb_removal_delay_flag;
   2467 
   2468     /**
   2469     * specifies the duration, in units of clock sub-ticks,
   2470     * between the nominal CPB removal times of any two consecutive decoding units
   2471     * in decoding order in the access unit associated with the pt_SEI message
   2472     */
   2473     UWORD32 u4_du_common_cpb_removal_delay_increment_minus1; //same as u4_du_cpb_removal_delay_increment_minus1
   2474 
   2475     /**
   2476     * specifies the number of NAL units in the decoding unit of the access unit
   2477     * the picture timing SEI message is associated with.
   2478     * range from 0 to (pic size in ctby - 1)
   2479     */
   2480     UWORD32 u4_num_nalus_in_du_minus1;
   2481 
   2482     /**
   2483     * specifies the duration, in units of clock sub-ticks,
   2484     * between the nominal CPB removal times of the ( i + 1 )-th decoding unit and the i-th decoding unit,
   2485     * in decoding order, in the access unit associated with the pt_SEI message
   2486     */
   2487     UWORD32 u4_du_cpb_removal_delay_increment_minus1;
   2488 
   2489 
   2490 }pic_timing_sei_params_t;
   2491 
   2492 /**
   2493  * Structure to hold Recovery point SEI parameters Info
   2494  */
   2495 typedef struct
   2496 {
   2497     /**
   2498     * specifies the recovery point of output pictures in output order
   2499     */
   2500     WORD32 i4_recovery_poc_cnt;
   2501 
   2502     UWORD8 u1_exact_match_flag;
   2503 
   2504     /**
   2505     * indicates the presence or absence of a broken link in the NAL unit
   2506     * stream at the location of the recovery point SEI message
   2507     */
   2508 
   2509     UWORD8 u1_broken_link_flag;
   2510 
   2511 }recovery_point_sei_params_t;
   2512 /**
   2513  * Structure to hold active parameter parameter set SEI parameters Info
   2514  */
   2515 typedef struct
   2516 {
   2517     /*
   2518     * active vps id
   2519     */
   2520 
   2521     UWORD8 u1_active_video_parameter_set_id;
   2522 
   2523     /*
   2524     * default set to zero.
   2525     */
   2526     UWORD8 u1_self_contained_cvs_flag;
   2527 
   2528     UWORD8 u1_no_parameter_set_update_flag;
   2529 
   2530     UWORD8 u1_num_sps_ids_minus1;
   2531 
   2532     /*
   2533     * active sps id
   2534     */
   2535     UWORD8 au1_active_seq_parameter_set_id[15];
   2536 
   2537 }active_parameter_set_sei_param_t;
   2538 
   2539 /**
   2540  * Structure to hold SEI parameters Info
   2541  */
   2542 typedef struct
   2543 {
   2544 
   2545     WORD8 i1_sei_parameters_present_flag;
   2546 
   2547     WORD8 i1_aud_present_flag;
   2548 
   2549     WORD8 i1_buf_period_params_present_flag;
   2550 
   2551     WORD8 i1_pic_timing_params_present_flag;
   2552 
   2553     WORD8 i1_recovery_point_params_present_flag;
   2554 
   2555     buf_period_sei_params_t  s_buf_period_sei_params;
   2556 
   2557     pic_timing_sei_params_t  s_pic_timing_sei_params;
   2558 
   2559     recovery_point_sei_params_t s_recovery_point_params;
   2560 
   2561     active_parameter_set_sei_param_t s_active_parameter_set_sei_params;
   2562 
   2563 
   2564 } sei_params_t;
   2565 
   2566 
   2567 
   2568 /**
   2569  * Structure to hold slice header info
   2570  */
   2571 typedef struct
   2572 {
   2573     /**
   2574      *  entry_point_offset[ i ]
   2575      */
   2576     WORD32 *pi4_entry_point_offset;
   2577 
   2578     /**
   2579      *  poc_lsb_lt[ i ]
   2580      */
   2581     WORD32 ai4_poc_lsb_lt[MAX_DPB_SIZE];
   2582 
   2583     /**
   2584      *  slice_header_extension_length
   2585      */
   2586     WORD16 i2_slice_header_extension_length;
   2587 
   2588     /**
   2589      *  slice_address
   2590      */
   2591     WORD16 i2_slice_address;
   2592 
   2593     /**
   2594      *  first_slice_in_pic_flag
   2595      */
   2596     WORD8 i1_first_slice_in_pic_flag;
   2597 
   2598     /* PPS id */
   2599     WORD8 i1_pps_id;
   2600     /**
   2601      *  no_output_of_prior_pics_flag
   2602      */
   2603     WORD8 i1_no_output_of_prior_pics_flag;
   2604 
   2605     /**
   2606      *  dependent_slice_flag
   2607      */
   2608     WORD8 i1_dependent_slice_flag;
   2609 
   2610     /**
   2611      *  slice_type
   2612      */
   2613     WORD8 i1_slice_type;
   2614 
   2615     /**
   2616      *  pic_output_flag
   2617      */
   2618     WORD8 i1_pic_output_flag;
   2619 
   2620     /**
   2621      *  colour_plane_id
   2622      */
   2623     WORD8 i1_colour_plane_id;
   2624 
   2625     /**
   2626      *  pic_order_cnt_lsb
   2627      */
   2628     WORD32 i4_pic_order_cnt_lsb;
   2629 
   2630     /**
   2631      *  absolute pic_order_cnt
   2632      */
   2633     WORD32 i4_abs_pic_order_cnt;
   2634 
   2635     /**
   2636      *  short_term_ref_pic_set_sps_flag
   2637      */
   2638     WORD8 i1_short_term_ref_pic_set_sps_flag;
   2639 
   2640     /**
   2641      *  short_term_ref_pic_set_idx
   2642      */
   2643     WORD8 i1_short_term_ref_pic_set_idx;
   2644 
   2645     /**
   2646      *  num_long_term_sps
   2647      */
   2648     WORD8 i1_num_long_term_sps;
   2649 
   2650     /**
   2651      *  num_long_term_pics
   2652      */
   2653     WORD8 i1_num_long_term_pics;
   2654 
   2655     /**
   2656      *  lt_idx_sps[ i ]
   2657      */
   2658     WORD8 ai1_lt_idx_sps[MAX_DPB_SIZE];
   2659 
   2660     /**
   2661      *  used_by_curr_pic_lt_flag[ i ]
   2662      */
   2663     WORD8 ai1_used_by_curr_pic_lt_flag[MAX_DPB_SIZE];
   2664 
   2665     /**
   2666      *  delta_poc_msb_present_flag[ i ]
   2667      */
   2668     WORD8 ai1_delta_poc_msb_present_flag[MAX_DPB_SIZE];
   2669 
   2670     /**
   2671      *  delta_poc_msb_cycle_lt[ i ]
   2672      */
   2673     WORD8 ai1_delta_poc_msb_cycle_lt[MAX_DPB_SIZE];
   2674 
   2675     /**
   2676      *  slice_sao_luma_flag
   2677      */
   2678     WORD8 i1_slice_sao_luma_flag;
   2679 
   2680     /**
   2681      *  slice_sao_chroma_flag
   2682      */
   2683     WORD8 i1_slice_sao_chroma_flag;
   2684 
   2685     /**
   2686      *  slice_temporal_mvp_enable_flag
   2687      */
   2688     WORD8 i1_slice_temporal_mvp_enable_flag;
   2689 
   2690     /**
   2691      *  num_ref_idx_active_override_flag
   2692      */
   2693     WORD8 i1_num_ref_idx_active_override_flag;
   2694 
   2695     /**
   2696      *  num_ref_idx_l0_active_minus1
   2697      */
   2698     WORD8 i1_num_ref_idx_l0_active;
   2699 
   2700     /**
   2701      *  num_ref_idx_l1_active_minus1
   2702      */
   2703     WORD8 i1_num_ref_idx_l1_active;
   2704 
   2705     /**
   2706      *  mvd_l1_zero_flag
   2707      */
   2708     WORD8 i1_mvd_l1_zero_flag;
   2709 
   2710     /**
   2711      *  cabac_init_flag
   2712      */
   2713     WORD8 i1_cabac_init_flag;
   2714 
   2715     /**
   2716      *  collocated_from_l0_flag
   2717      */
   2718     WORD8 i1_collocated_from_l0_flag;
   2719 
   2720     /**
   2721      *  collocated_ref_idx
   2722      */
   2723     WORD8 i1_collocated_ref_idx;
   2724 
   2725     /**
   2726      * five_minus_max_num_merge_cand
   2727      */
   2728     WORD8 i1_max_num_merge_cand;
   2729 
   2730     /**
   2731      *  slice_qp_delta
   2732      */
   2733     WORD8 i1_slice_qp_delta;
   2734 
   2735     /**
   2736      *  slice_cb_qp_offset
   2737      */
   2738     WORD8 i1_slice_cb_qp_offset;
   2739 
   2740     /**
   2741      *  slice_cr_qp_offset
   2742      */
   2743     WORD8 i1_slice_cr_qp_offset;
   2744 
   2745     /**
   2746      *  deblocking_filter_override_flag
   2747      */
   2748     WORD8 i1_deblocking_filter_override_flag;
   2749 
   2750     /**
   2751      *  slice_disable_deblocking_filter_flag
   2752      */
   2753     WORD8 i1_slice_disable_deblocking_filter_flag;
   2754 
   2755     /**
   2756      *  beta_offset_div2
   2757      */
   2758     WORD8 i1_beta_offset_div2;
   2759 
   2760     /**
   2761      *  tc_offset_div2
   2762      */
   2763     WORD8 i1_tc_offset_div2;
   2764 
   2765     /**
   2766      *  slice_loop_filter_across_slices_enabled_flag
   2767      */
   2768     WORD8 i1_slice_loop_filter_across_slices_enabled_flag;
   2769 
   2770     /**
   2771      *  NUmber of entry point offsets
   2772      */
   2773     WORD32 i4_num_entry_point_offsets;
   2774 
   2775     /**
   2776      *  offset_len_minus1
   2777      */
   2778     WORD8 i1_offset_len;
   2779 
   2780     /**
   2781      *  Entry point offsets
   2782      */
   2783     WORD32 *pu4_entry_point_offset;
   2784 
   2785     /**
   2786      * Short term reference picture set
   2787      */
   2788     stref_picset_t s_stref_picset;
   2789 
   2790     /**
   2791      *  Weight and offset info for Weighted prediction
   2792      */
   2793     pred_wt_ofst_t s_wt_ofst;
   2794 
   2795     /**
   2796      *  Reference prediction list modification
   2797      */
   2798     rplm_t s_rplm;
   2799 
   2800     /**
   2801      *  First CTB' X pos : slice_address % i2_pic_wd_in_ctb
   2802      */
   2803     WORD16 i2_ctb_x;
   2804 
   2805     /**
   2806      *  First CTB' Y pos : slice_address / i2_pic_wd_in_ctb
   2807      */
   2808     WORD16 i2_ctb_y;
   2809 
   2810     /**
   2811      * L0 Reference pic lists
   2812      */
   2813     ref_list_t as_ref_pic_list0[MAX_DPB_SIZE];
   2814 
   2815     /**
   2816      * L1 Reference pic lists
   2817      */
   2818     ref_list_t as_ref_pic_list1[MAX_DPB_SIZE];
   2819 
   2820     /**
   2821      * NAL unit type of the slice
   2822      */
   2823     WORD8 i1_nal_unit_type;
   2824 
   2825     /**
   2826      * Low delay check flag
   2827      */
   2828     WORD8 i1_low_delay_flag;
   2829 
   2830     /**
   2831      * The last independent slice's start ctb_x
   2832      * If the current slice is independent, it is the same as the current CTBs ctb_x
   2833      */
   2834     WORD16 i2_independent_ctb_x;
   2835 
   2836     /**
   2837      * The last independent slice's start ctb_y
   2838      * If the current slice is independent, it is the same as the current CTBs ctb_y
   2839      */
   2840     WORD16 i2_independent_ctb_y;
   2841 
   2842 
   2843     UWORD8 u1_parse_data_init_done;
   2844 
   2845     /**
   2846      * Temporal ID in NAL header
   2847      */
   2848     WORD32 u4_nuh_temporal_id;
   2849 }slice_header_t;
   2850 
   2851 
   2852 
   2853 
   2854 
   2855 
   2856 
   2857 
   2858 #endif /* _IHEVC_STRUCTS_H_ */
   2859