xref: /aosp_15_r20/external/libavc/decoder/ih264d_cabac.h (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
1*495ae853SAndroid Build Coastguard Worker /******************************************************************************
2*495ae853SAndroid Build Coastguard Worker  *
3*495ae853SAndroid Build Coastguard Worker  * Copyright (C) 2015 The Android Open Source Project
4*495ae853SAndroid Build Coastguard Worker  *
5*495ae853SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
6*495ae853SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
7*495ae853SAndroid Build Coastguard Worker  * You may obtain a copy of the License at:
8*495ae853SAndroid Build Coastguard Worker  *
9*495ae853SAndroid Build Coastguard Worker  * http://www.apache.org/licenses/LICENSE-2.0
10*495ae853SAndroid Build Coastguard Worker  *
11*495ae853SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
12*495ae853SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
13*495ae853SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*495ae853SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
15*495ae853SAndroid Build Coastguard Worker  * limitations under the License.
16*495ae853SAndroid Build Coastguard Worker  *
17*495ae853SAndroid Build Coastguard Worker  *****************************************************************************
18*495ae853SAndroid Build Coastguard Worker  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19*495ae853SAndroid Build Coastguard Worker */
20*495ae853SAndroid Build Coastguard Worker /*!
21*495ae853SAndroid Build Coastguard Worker  ***************************************************************************
22*495ae853SAndroid Build Coastguard Worker  * \file ih264d_cabac.h
23*495ae853SAndroid Build Coastguard Worker  *
24*495ae853SAndroid Build Coastguard Worker  * \brief
25*495ae853SAndroid Build Coastguard Worker  *    This file contains declarations of Binary decoding routines and tables.
26*495ae853SAndroid Build Coastguard Worker  *
27*495ae853SAndroid Build Coastguard Worker  * \date
28*495ae853SAndroid Build Coastguard Worker  *    04/02/2003
29*495ae853SAndroid Build Coastguard Worker  *
30*495ae853SAndroid Build Coastguard Worker  * \author  NS
31*495ae853SAndroid Build Coastguard Worker  ***************************************************************************
32*495ae853SAndroid Build Coastguard Worker  */
33*495ae853SAndroid Build Coastguard Worker 
34*495ae853SAndroid Build Coastguard Worker #ifndef _IH264D_CABAC_H_
35*495ae853SAndroid Build Coastguard Worker #define _IH264D_CABAC_H_
36*495ae853SAndroid Build Coastguard Worker 
37*495ae853SAndroid Build Coastguard Worker #include "ih264_typedefs.h"
38*495ae853SAndroid Build Coastguard Worker #include "ih264_macros.h"
39*495ae853SAndroid Build Coastguard Worker #include "ih264_platform_macros.h"
40*495ae853SAndroid Build Coastguard Worker #include "ih264d_bitstrm.h"
41*495ae853SAndroid Build Coastguard Worker #include "ih264d_defs.h"
42*495ae853SAndroid Build Coastguard Worker 
43*495ae853SAndroid Build Coastguard Worker #define   B_BITS    10
44*495ae853SAndroid Build Coastguard Worker 
45*495ae853SAndroid Build Coastguard Worker #define   HALF      (1 << (B_BITS-1))
46*495ae853SAndroid Build Coastguard Worker #define   QUARTER   (1 << (B_BITS-2))
47*495ae853SAndroid Build Coastguard Worker 
48*495ae853SAndroid Build Coastguard Worker #define CTXT_UNUSED   {0,64}
49*495ae853SAndroid Build Coastguard Worker #define NUM_MB_SKIP_CTXT  6
50*495ae853SAndroid Build Coastguard Worker #define NUM_MB_TYPE_CTXT  9
51*495ae853SAndroid Build Coastguard Worker #define NUM_SUBMB_TYPE_CTXT 7
52*495ae853SAndroid Build Coastguard Worker #define NUM_REF_IDX_CTXT  6
53*495ae853SAndroid Build Coastguard Worker #define NUM_MB_QP_DELTA 4
54*495ae853SAndroid Build Coastguard Worker #define NUM_PRED_MODE 6
55*495ae853SAndroid Build Coastguard Worker #define NUM_MB_FIELD    3
56*495ae853SAndroid Build Coastguard Worker #define NUM_CBP 12
57*495ae853SAndroid Build Coastguard Worker #define NUM_CTX_MVD 14
58*495ae853SAndroid Build Coastguard Worker 
59*495ae853SAndroid Build Coastguard Worker /* Residual block cabac context parameters */
60*495ae853SAndroid Build Coastguard Worker #define NUM_CTX_CAT 6
61*495ae853SAndroid Build Coastguard Worker #define NUM_LUMA_CTX_CAT 3
62*495ae853SAndroid Build Coastguard Worker #define NUM_CTX_CODED_BLOCK 4
63*495ae853SAndroid Build Coastguard Worker /* Luma CtxSigCoeff + CtxLastCoeff = 15 + 15 = 30 */
64*495ae853SAndroid Build Coastguard Worker #define NUM_LUMA_CTX_SIG_COEF 30
65*495ae853SAndroid Build Coastguard Worker /* Chroma DC CtxSigCoeff + CtxLastCoeff = 3 + 3 = 6 */
66*495ae853SAndroid Build Coastguard Worker #define NUM_CTX_CHROMA_DC_SIG_COEF 6
67*495ae853SAndroid Build Coastguard Worker /* Chroma AC CtxSigCoeff + CtxLastCoeff = 14 + 14 = 28 */
68*495ae853SAndroid Build Coastguard Worker #define NUM_CTX_CHROMA_AC_SIG_COEF 28
69*495ae853SAndroid Build Coastguard Worker #define NUM_CTX_ABS_LEVEL 10
70*495ae853SAndroid Build Coastguard Worker 
71*495ae853SAndroid Build Coastguard Worker #define LUMA_DC_CTXCAT    0
72*495ae853SAndroid Build Coastguard Worker #define LUMA_AC_CTXCAT    1
73*495ae853SAndroid Build Coastguard Worker #define LUMA_4X4_CTXCAT   2
74*495ae853SAndroid Build Coastguard Worker #define CHROMA_DC_CTXCAT  3
75*495ae853SAndroid Build Coastguard Worker #define CHROMA_AC_CTXCAT  4
76*495ae853SAndroid Build Coastguard Worker #define LUMA_8X8_CTXCAT   5
77*495ae853SAndroid Build Coastguard Worker 
78*495ae853SAndroid Build Coastguard Worker /*****************************************************************************/
79*495ae853SAndroid Build Coastguard Worker /* Constant Macros                                                           */
80*495ae853SAndroid Build Coastguard Worker /*****************************************************************************/
81*495ae853SAndroid Build Coastguard Worker #define NUM_CABAC_CTXTS 460
82*495ae853SAndroid Build Coastguard Worker #define QP_RANGE        52
83*495ae853SAndroid Build Coastguard Worker #define NUM_CAB_INIT_IDC_PLUS_ONE 4
84*495ae853SAndroid Build Coastguard Worker #define LAST_COEFF_CTXT_MINUS_SIG_COEFF_CTXT 61
85*495ae853SAndroid Build Coastguard Worker #define LAST_COEFF_CTXT_MINUS_SIG_COEFF_CTXT_8X8 15
86*495ae853SAndroid Build Coastguard Worker 
87*495ae853SAndroid Build Coastguard Worker /*bits 0 to 5 :state
88*495ae853SAndroid Build Coastguard Worker  bit 6:mps*/
89*495ae853SAndroid Build Coastguard Worker typedef struct
90*495ae853SAndroid Build Coastguard Worker {
91*495ae853SAndroid Build Coastguard Worker     UWORD8 u1_mps_state; /* state number */
92*495ae853SAndroid Build Coastguard Worker } bin_ctxt_model_t;
93*495ae853SAndroid Build Coastguard Worker 
94*495ae853SAndroid Build Coastguard Worker typedef struct
95*495ae853SAndroid Build Coastguard Worker 
96*495ae853SAndroid Build Coastguard Worker {
97*495ae853SAndroid Build Coastguard Worker     /* Neighbour availability Variables needed to get CtxtInc, for CABAC */
98*495ae853SAndroid Build Coastguard Worker     UWORD8 u1_mb_type; /** macroblock type: I/P/B/SI/SP */
99*495ae853SAndroid Build Coastguard Worker     UWORD8 u1_cbp; /** Coded Block Pattern */
100*495ae853SAndroid Build Coastguard Worker     UWORD8 u1_intra_chroma_pred_mode;
101*495ae853SAndroid Build Coastguard Worker 
102*495ae853SAndroid Build Coastguard Worker     /*************************************************************************/
103*495ae853SAndroid Build Coastguard Worker     /*               Arrangnment of DC CSBP                                  */
104*495ae853SAndroid Build Coastguard Worker     /*        bits:  b7  b6  b5  b4  b3  b2  b1  b0                          */
105*495ae853SAndroid Build Coastguard Worker     /*        CSBP:   x   x   x   x   x  Vdc Udc Ydc                         */
106*495ae853SAndroid Build Coastguard Worker     /*************************************************************************/
107*495ae853SAndroid Build Coastguard Worker     UWORD8 u1_yuv_dc_csbp;
108*495ae853SAndroid Build Coastguard Worker     WORD8 i1_ref_idx[4];
109*495ae853SAndroid Build Coastguard Worker     UWORD8 u1_mv[4][4];
110*495ae853SAndroid Build Coastguard Worker     UWORD8 u1_transform8x8_ctxt;
111*495ae853SAndroid Build Coastguard Worker } ctxt_inc_mb_info_t;
112*495ae853SAndroid Build Coastguard Worker 
113*495ae853SAndroid Build Coastguard Worker #define ONE_RIGHT_SHIFTED_BY_8 1<<8
114*495ae853SAndroid Build Coastguard Worker #define ONE_RIGHT_SHIFTED_BY_9    1<<9
115*495ae853SAndroid Build Coastguard Worker #define ONE_RIGHT_SHIFTED_BY_14 1<<14
116*495ae853SAndroid Build Coastguard Worker typedef struct
117*495ae853SAndroid Build Coastguard Worker {
118*495ae853SAndroid Build Coastguard Worker     UWORD32 u4_code_int_range;
119*495ae853SAndroid Build Coastguard Worker     UWORD32 u4_code_int_val_ofst;
120*495ae853SAndroid Build Coastguard Worker     const void *cabac_table;
121*495ae853SAndroid Build Coastguard Worker     void * pv_codec_handle; /* For Error Handling */
122*495ae853SAndroid Build Coastguard Worker } decoding_envirnoment_t;
123*495ae853SAndroid Build Coastguard Worker 
124*495ae853SAndroid Build Coastguard Worker WORD32 ih264d_init_cabac_dec_envirnoment(decoding_envirnoment_t * ps_cab_env,
125*495ae853SAndroid Build Coastguard Worker                                        dec_bit_stream_t *ps_bitstrm);
126*495ae853SAndroid Build Coastguard Worker 
127*495ae853SAndroid Build Coastguard Worker UWORD32 ih264d_decode_bin(UWORD32 u4_ctx_inc,
128*495ae853SAndroid Build Coastguard Worker                           bin_ctxt_model_t *ps_bin_ctxt,
129*495ae853SAndroid Build Coastguard Worker                           dec_bit_stream_t *ps_bitstrm,
130*495ae853SAndroid Build Coastguard Worker                           decoding_envirnoment_t *ps_cab_env);
131*495ae853SAndroid Build Coastguard Worker UWORD8 ih264d_decode_terminate(decoding_envirnoment_t * ps_cab_env,
132*495ae853SAndroid Build Coastguard Worker                                dec_bit_stream_t * ps_bitstrm);
133*495ae853SAndroid Build Coastguard Worker 
134*495ae853SAndroid Build Coastguard Worker UWORD32 ih264d_decode_bins_tunary(UWORD8 u1_max_bins,
135*495ae853SAndroid Build Coastguard Worker                                   UWORD32 u4_ctx_inc,
136*495ae853SAndroid Build Coastguard Worker                                   bin_ctxt_model_t *ps_src_bin_ctxt,
137*495ae853SAndroid Build Coastguard Worker                                   dec_bit_stream_t *ps_bitstrm,
138*495ae853SAndroid Build Coastguard Worker                                   decoding_envirnoment_t *ps_cab_env);
139*495ae853SAndroid Build Coastguard Worker 
140*495ae853SAndroid Build Coastguard Worker UWORD32 ih264d_decode_bins(UWORD8 u1_max_bins,
141*495ae853SAndroid Build Coastguard Worker                            UWORD32 u4_ctx_inc,
142*495ae853SAndroid Build Coastguard Worker                            bin_ctxt_model_t *ps_src_bin_ctxt,
143*495ae853SAndroid Build Coastguard Worker                            dec_bit_stream_t *ps_bitstrm,
144*495ae853SAndroid Build Coastguard Worker                            decoding_envirnoment_t *ps_cab_env);
145*495ae853SAndroid Build Coastguard Worker UWORD32 ih264d_decode_bins_unary(UWORD8 u1_max_bins,
146*495ae853SAndroid Build Coastguard Worker                                  UWORD32 u4_ctx_inc,
147*495ae853SAndroid Build Coastguard Worker                                  bin_ctxt_model_t *ps_src_bin_ctxt,
148*495ae853SAndroid Build Coastguard Worker                                  dec_bit_stream_t *ps_bitstrm,
149*495ae853SAndroid Build Coastguard Worker                                  decoding_envirnoment_t *ps_cab_env);
150*495ae853SAndroid Build Coastguard Worker 
151*495ae853SAndroid Build Coastguard Worker UWORD32 ih264d_decode_bypass_bins_unary(decoding_envirnoment_t *ps_cab_env,
152*495ae853SAndroid Build Coastguard Worker                                         dec_bit_stream_t *ps_bitstrm);
153*495ae853SAndroid Build Coastguard Worker 
154*495ae853SAndroid Build Coastguard Worker UWORD32 ih264d_decode_bypass_bins(decoding_envirnoment_t *ps_cab_env,
155*495ae853SAndroid Build Coastguard Worker                                   UWORD8 u1_max_bins,
156*495ae853SAndroid Build Coastguard Worker                                   dec_bit_stream_t *ps_bitstrm);
157*495ae853SAndroid Build Coastguard Worker 
158*495ae853SAndroid Build Coastguard Worker /*****************************************************************************/
159*495ae853SAndroid Build Coastguard Worker /* Function Macros                                                           */
160*495ae853SAndroid Build Coastguard Worker /*****************************************************************************/
161*495ae853SAndroid Build Coastguard Worker 
162*495ae853SAndroid Build Coastguard Worker /*****************************************************************************/
163*495ae853SAndroid Build Coastguard Worker /* Defining a macro for renormalization*/
164*495ae853SAndroid Build Coastguard Worker /*****************************************************************************/
165*495ae853SAndroid Build Coastguard Worker 
166*495ae853SAndroid Build Coastguard Worker /*we renormalize every time the number bits(which are read ahead of time) we have
167*495ae853SAndroid Build Coastguard Worker  consumed in the u4_ofst exceeds 23*/
168*495ae853SAndroid Build Coastguard Worker 
169*495ae853SAndroid Build Coastguard Worker #define RENORM_RANGE_OFFSET(u4_codeIntRange_m,u4_codeIntValOffset_m,u4_offset_m,pu4_buffer_m) \
170*495ae853SAndroid Build Coastguard Worker   {                                                                                         \
171*495ae853SAndroid Build Coastguard Worker     UWORD32 read_bits_m,u4_clz_m  ;                                                         \
172*495ae853SAndroid Build Coastguard Worker     u4_clz_m = CLZ(u4_codeIntRange_m);                                                  \
173*495ae853SAndroid Build Coastguard Worker     NEXTBITS(read_bits_m,(u4_offset_m+23),pu4_buffer_m,u4_clz_m)                            \
174*495ae853SAndroid Build Coastguard Worker     FLUSHBITS(u4_offset_m,(u4_clz_m))                                                       \
175*495ae853SAndroid Build Coastguard Worker     u4_codeIntRange_m = u4_codeIntRange_m << u4_clz_m;                                      \
176*495ae853SAndroid Build Coastguard Worker     u4_codeIntValOffset_m = (u4_codeIntValOffset_m << u4_clz_m) | read_bits_m;              \
177*495ae853SAndroid Build Coastguard Worker   }
178*495ae853SAndroid Build Coastguard Worker 
179*495ae853SAndroid Build Coastguard Worker /*****************************************************************************/
180*495ae853SAndroid Build Coastguard Worker /* Defining a macro for checking if the symbol is MPS*/
181*495ae853SAndroid Build Coastguard Worker /*****************************************************************************/
182*495ae853SAndroid Build Coastguard Worker 
183*495ae853SAndroid Build Coastguard Worker #define CHECK_IF_LPS(u4_codeIntRange_m,u4_codeIntValOffset_m,u4_symbol_m,                   \
184*495ae853SAndroid Build Coastguard Worker                     u4_codeIntRangeLPS_m,u1_mps_state_m,table_lookup_m)                     \
185*495ae853SAndroid Build Coastguard Worker {                                                                                         \
186*495ae853SAndroid Build Coastguard Worker   if(u4_codeIntValOffset_m >= u4_codeIntRange_m)                                            \
187*495ae853SAndroid Build Coastguard Worker   {                                                                                         \
188*495ae853SAndroid Build Coastguard Worker       u4_symbol_m = 1 - u4_symbol_m;                                                        \
189*495ae853SAndroid Build Coastguard Worker       u4_codeIntValOffset_m -= u4_codeIntRange_m;                                           \
190*495ae853SAndroid Build Coastguard Worker       u4_codeIntRange_m = u4_codeIntRangeLPS_m;                                             \
191*495ae853SAndroid Build Coastguard Worker       u1_mps_state_m = (table_lookup_m >> 15) & 0x7F;                                       \
192*495ae853SAndroid Build Coastguard Worker   }                                                                                         \
193*495ae853SAndroid Build Coastguard Worker }
194*495ae853SAndroid Build Coastguard Worker 
195*495ae853SAndroid Build Coastguard Worker /*!
196*495ae853SAndroid Build Coastguard Worker  **************************************************************************
197*495ae853SAndroid Build Coastguard Worker  * \if Function name : DECODE_ONE_BIN_MACRO \endif
198*495ae853SAndroid Build Coastguard Worker  *
199*495ae853SAndroid Build Coastguard Worker  * \brief
200*495ae853SAndroid Build Coastguard Worker  *    This function implements decoding process of a decision as defined
201*495ae853SAndroid Build Coastguard Worker  *    in 9.3.3.2.2.
202*495ae853SAndroid Build Coastguard Worker  *
203*495ae853SAndroid Build Coastguard Worker  * \return
204*495ae853SAndroid Build Coastguard Worker  *    Returns symbol decoded.
205*495ae853SAndroid Build Coastguard Worker  *
206*495ae853SAndroid Build Coastguard Worker  * \note
207*495ae853SAndroid Build Coastguard Worker  *    It is specified in 9.3.3.2.3.2 that, one of the input to this function
208*495ae853SAndroid Build Coastguard Worker  *    is CtxIdx. CtxIdx is used to identify state and MPS of that context
209*495ae853SAndroid Build Coastguard Worker  *    (Refer Fig 9.11 - Flowchart for encoding a decision). To suffice that
210*495ae853SAndroid Build Coastguard Worker  *    here we pass a pointer bin_ctxt_model_t which contains these values.
211*495ae853SAndroid Build Coastguard Worker  *
212*495ae853SAndroid Build Coastguard Worker  **************************************************************************
213*495ae853SAndroid Build Coastguard Worker  */
214*495ae853SAndroid Build Coastguard Worker 
215*495ae853SAndroid Build Coastguard Worker #define DECODE_ONE_BIN_MACRO(p_binCtxt_arg ,u4_code_int_range,u4_code_int_val_ofst,       \
216*495ae853SAndroid Build Coastguard Worker                      pu4_table_arg,                                                \
217*495ae853SAndroid Build Coastguard Worker                      p_DecBitStream_arg,u4_symbol)                                           \
218*495ae853SAndroid Build Coastguard Worker {                                                                                       \
219*495ae853SAndroid Build Coastguard Worker     bin_ctxt_model_t *p_binCtxt_m = (bin_ctxt_model_t *) p_binCtxt_arg;                           \
220*495ae853SAndroid Build Coastguard Worker     dec_bit_stream_t *p_DecBitStream_m = (dec_bit_stream_t *) p_DecBitStream_arg;                 \
221*495ae853SAndroid Build Coastguard Worker     const UWORD32 *pu4_table_m = (const UWORD32 *) pu4_table_arg;                         \
222*495ae853SAndroid Build Coastguard Worker                                                                                         \
223*495ae853SAndroid Build Coastguard Worker     UWORD32 u4_quantCodeIntRange_m,u4_codeIntRangeLPS_m;                                    \
224*495ae853SAndroid Build Coastguard Worker     UWORD32 u1_mps_state_m;                                                               \
225*495ae853SAndroid Build Coastguard Worker     UWORD32 table_lookup_m;                                                               \
226*495ae853SAndroid Build Coastguard Worker     UWORD32 u4_clz_m;                                                                     \
227*495ae853SAndroid Build Coastguard Worker                                                                                         \
228*495ae853SAndroid Build Coastguard Worker     u1_mps_state_m = (p_binCtxt_m->u1_mps_state);                                           \
229*495ae853SAndroid Build Coastguard Worker     u4_clz_m = CLZ(u4_code_int_range);                                                  \
230*495ae853SAndroid Build Coastguard Worker     u4_quantCodeIntRange_m = u4_code_int_range << u4_clz_m;                                   \
231*495ae853SAndroid Build Coastguard Worker     u4_quantCodeIntRange_m = (u4_quantCodeIntRange_m >> 29) & 0x3;                          \
232*495ae853SAndroid Build Coastguard Worker     table_lookup_m = pu4_table_m[(u1_mps_state_m << 2)+u4_quantCodeIntRange_m];                 \
233*495ae853SAndroid Build Coastguard Worker     u4_codeIntRangeLPS_m = table_lookup_m & 0xff;                                           \
234*495ae853SAndroid Build Coastguard Worker                                                                                         \
235*495ae853SAndroid Build Coastguard Worker     u4_codeIntRangeLPS_m = u4_codeIntRangeLPS_m << (23 - u4_clz_m);                           \
236*495ae853SAndroid Build Coastguard Worker     u4_code_int_range = u4_code_int_range - u4_codeIntRangeLPS_m;                             \
237*495ae853SAndroid Build Coastguard Worker     u4_symbol = ((u1_mps_state_m>> 6) & 0x1);                                             \
238*495ae853SAndroid Build Coastguard Worker     /*if mps*/                                                                          \
239*495ae853SAndroid Build Coastguard Worker     u1_mps_state_m = (table_lookup_m >> 8) & 0x7F;                                          \
240*495ae853SAndroid Build Coastguard Worker     if(u4_code_int_val_ofst >= u4_code_int_range)                                          \
241*495ae853SAndroid Build Coastguard Worker   {                                                                                     \
242*495ae853SAndroid Build Coastguard Worker                                                                                         \
243*495ae853SAndroid Build Coastguard Worker     u4_symbol = 1 - u4_symbol;                                                          \
244*495ae853SAndroid Build Coastguard Worker     u4_code_int_val_ofst -= u4_code_int_range;                                             \
245*495ae853SAndroid Build Coastguard Worker     u4_code_int_range = u4_codeIntRangeLPS_m;                                               \
246*495ae853SAndroid Build Coastguard Worker     u1_mps_state_m = (table_lookup_m >> 15) & 0x7F;                                         \
247*495ae853SAndroid Build Coastguard Worker   }                                                                                     \
248*495ae853SAndroid Build Coastguard Worker     if(u4_code_int_range < ONE_RIGHT_SHIFTED_BY_8)                                        \
249*495ae853SAndroid Build Coastguard Worker     {                                                                                   \
250*495ae853SAndroid Build Coastguard Worker         UWORD32 *pu4_buffer,u4_offset;                                                  \
251*495ae853SAndroid Build Coastguard Worker         UWORD32 read_bits,u4_clz_m  ;                                                     \
252*495ae853SAndroid Build Coastguard Worker                                                                                         \
253*495ae853SAndroid Build Coastguard Worker         pu4_buffer = p_DecBitStream_m->pu4_buffer;                                         \
254*495ae853SAndroid Build Coastguard Worker         u4_offset = p_DecBitStream_m->u4_ofst;                                          \
255*495ae853SAndroid Build Coastguard Worker         u4_clz_m = CLZ(u4_code_int_range);                                              \
256*495ae853SAndroid Build Coastguard Worker         NEXTBITS(read_bits,(u4_offset+23),pu4_buffer,u4_clz_m)                            \
257*495ae853SAndroid Build Coastguard Worker         FLUSHBITS(u4_offset,(u4_clz_m))                                                   \
258*495ae853SAndroid Build Coastguard Worker         u4_code_int_range = u4_code_int_range << u4_clz_m;                                    \
259*495ae853SAndroid Build Coastguard Worker         u4_code_int_val_ofst= (u4_code_int_val_ofst << u4_clz_m) | read_bits;               \
260*495ae853SAndroid Build Coastguard Worker                                                                                         \
261*495ae853SAndroid Build Coastguard Worker                                                                                         \
262*495ae853SAndroid Build Coastguard Worker         p_DecBitStream_m->u4_ofst = u4_offset;                                          \
263*495ae853SAndroid Build Coastguard Worker     }                                                                                   \
264*495ae853SAndroid Build Coastguard Worker     p_binCtxt_m->u1_mps_state = u1_mps_state_m;                                             \
265*495ae853SAndroid Build Coastguard Worker }
266*495ae853SAndroid Build Coastguard Worker 
267*495ae853SAndroid Build Coastguard Worker #endif  /*  _IH264D_CABAC_H_ */
268