1 /******************************************************************************
2  *
3  * Copyright (C) 2015 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *****************************************************************************
18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 #ifndef _IH264D_PARSE_CAVLC_H_
21 #define _IH264D_PARSE_CAVLC_H_
22 /*!
23  **************************************************************************
24  * \file ih264d_parse_cavlc.h
25  *
26  * \brief
27  *    Declaration of UVLC and CAVLC functions
28  *
29  * \date
30  *    18/12/2002
31  *
32  * \author  AI
33  **************************************************************************
34  */
35 #include "ih264_typedefs.h"
36 #include "ih264_macros.h"
37 #include "ih264_platform_macros.h"
38 #include "ih264d_bitstrm.h"
39 #include "ih264d_structs.h"
40 #include "ih264d_cabac.h"
41 
42 enum cavlcTableNum
43 {
44     tableTotalZeroOffset,
45     tableTotalZero,
46     tableRunBefore,
47     codeGx,
48     chromTab,
49     offsetNumVlcTab
50 };
51 
52 WORD32 ih264d_uvlc(dec_bit_stream_t *ps_bitstrm,
53                    UWORD32 u4_range,
54                    UWORD32 *pi_bitstrm_ofst,
55                    UWORD8 u1_flag,
56                    UWORD32 u4_bitstrm_ofst,
57                    UWORD32 *pi_bitstrm_buf);
58 
59 UWORD32 ih264d_uev(UWORD32 *pu4_bitstrm_ofst, UWORD32 *pu4_bitstrm_buf);
60 
61 WORD32 ih264d_sev(UWORD32 *pu4_bitstrm_ofst, UWORD32 *pu4_bitstrm_buf);
62 
63 UWORD32 ih264d_tev_range1(UWORD32 *pu4_bitstrm_ofst,
64                           UWORD32 *pu4_bitstrm_buf);
65 
66 UWORD8 RestOfResidualBlockCavlc(WORD16 *pi2_coeff_block,
67                                 UWORD32 u1_ofst_is_dc_max_coef_scale_fact,
68                                 UWORD32 u4_total_coeff_trail_one,
69                                 dec_bit_stream_t *ps_bitstrm,
70                                 UWORD8 *pu1_invscan);
71 
72 WORD32 ih264d_cavlc_4x4res_block_totalcoeff_1( UWORD32 u4_isdc,
73                                            UWORD32 u4_total_coeff_trail_one,
74                                            dec_bit_stream_t *ps_bitstrm);
75 
76 WORD32 ih264d_cavlc_4x4res_block_totalcoeff_2to10(UWORD32 u4_isdc,
77                                                UWORD32 u4_total_coeff_trail_one,
78                                                dec_bit_stream_t *ps_bitstrm);
79 
80 WORD32 ih264d_cavlc_4x4res_block_totalcoeff_11to16(UWORD32 u4_isdc,
81                                                 UWORD32 u4_total_coeff_trail_one,
82                                                 dec_bit_stream_t *ps_bitstrm);
83 
84 WORD32 ih264d_cavlc_parse4x4coeff_n0to7(WORD16 *pi2_coeff_block,
85                                         UWORD32 u4_isdc,
86                                         WORD32 u4_n,
87                                         dec_struct_t *ps_dec,
88                                         UWORD32 *pu4_total_coeff);
89 
90 WORD32 ih264d_cavlc_parse4x4coeff_n8(WORD16 *pi2_coeff_block,
91                                       UWORD32 u4_isdc,
92                                       WORD32 u4_n,
93                                       dec_struct_t *ps_dec,
94                                       UWORD32 *pu4_total_coeff);
95 
96 void ih264d_cavlc_parse_chroma_dc(dec_mb_info_t *ps_cur_mb_info,
97                                   WORD16 *pi2_coeff_block,
98                                   dec_bit_stream_t *ps_bitstrm,
99                                   UWORD32 u4_scale_u,
100                                   UWORD32 u4_scale_v,
101                                   WORD32 i4_mb_inter_inc);
102 
103 WORD32 ih264d_cavlc_parse_8x8block_none_available(WORD16 *pi2_coeff_block,
104                                                   UWORD32 u4_sub_block_strd,
105                                                   UWORD32 u4_isdc,
106                                                   dec_struct_t * ps_dec,
107                                                   UWORD8 *pu1_top_nnz,
108                                                   UWORD8 *pu1_left_nnz,
109                                                   UWORD8 u1_tran_form8x8,
110                                                   UWORD8 u1_mb_field_decodingflag,
111                                                   UWORD32 *pu4_csbp);
112 
113 WORD32 ih264d_cavlc_parse_8x8block_left_available(WORD16 *pi2_coeff_block,
114                                                   UWORD32 u4_sub_block_strd,
115                                                   UWORD32 u4_isdc,
116                                                   dec_struct_t * ps_dec,
117                                                   UWORD8 *pu1_top_nnz,
118                                                   UWORD8 *pu1_left_nnz,
119                                                   UWORD8 u1_tran_form8x8,
120                                                   UWORD8 u1_mb_field_decodingflag,
121                                                   UWORD32 *pu4_csbp);
122 
123 WORD32 ih264d_cavlc_parse_8x8block_top_available(WORD16 *pi2_coeff_block,
124                                                  UWORD32 u4_sub_block_strd,
125                                                  UWORD32 u4_isdc,
126                                                  dec_struct_t * ps_dec,
127                                                  UWORD8 *pu1_top_nnz,
128                                                  UWORD8 *pu1_left_nnz,
129                                                  UWORD8 u1_tran_form8x8,
130                                                  UWORD8 u1_mb_field_decodingflag,
131                                                  UWORD32 *pu4_csbp);
132 
133 WORD32 ih264d_cavlc_parse_8x8block_both_available(WORD16 *pi2_coeff_block,
134                                                   UWORD32 u4_sub_block_strd,
135                                                   UWORD32 u4_isdc,
136                                                   dec_struct_t * ps_dec,
137                                                   UWORD8 *pu1_top_nnz,
138                                                   UWORD8 *pu1_left_nnz,
139                                                   UWORD8 u1_tran_form8x8,
140                                                   UWORD8 u1_mb_field_decodingflag,
141                                                   UWORD32 *pu4_csbp);
142 
143 WORD8 ResidualBlockChromaDC(WORD16 *pi2_level, dec_bit_stream_t *ps_bitstrm);
144 
145 void ih264d_parse_pmb_ref_index_cavlc_range1(UWORD32 u4_num_part,
146                                              dec_bit_stream_t *ps_bitstrm,
147                                              WORD8 *pi1_ref_idx,
148                                              UWORD32 u4_num_ref_idx_active_minus1);
149 
150 WORD32 ih264d_parse_pmb_ref_index_cavlc(UWORD32 u4_num_part,
151                                       dec_bit_stream_t *ps_bitstrm,
152                                       WORD8 *pi1_ref_idx,
153                                       UWORD32 u4_num_ref_idx_active_minus1);
154 
155 void ih264d_parse_bmb_ref_index_cavlc_range1(UWORD32 u4_num_part,
156                                              dec_bit_stream_t *ps_bitstrm,
157                                              WORD8 *pi1_ref_idx,
158                                              UWORD32 u4_num_ref_idx_active_minus1);
159 
160 WORD32 ih264d_parse_bmb_ref_index_cavlc(UWORD32 u4_num_part,
161                                       dec_bit_stream_t *ps_bitstrm,
162                                       WORD8 *pi1_ref_idx,
163                                       UWORD32 u4_num_ref_idx_active_minus1);
164 
165 #endif  /* _IH264D_PARSE_CAVLC_H_ */
166