• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_STRUCTS_H_
21 #define _IH264D_STRUCTS_H_
22 
23 #include "ih264_typedefs.h"
24 #include "ih264_macros.h"
25 #include "ih264_platform_macros.h"
26 #include "iv.h"
27 #include "ivd.h"
28 
29 #include "ih264d_transfer_address.h"
30 #include "ih264d_defs.h"
31 #include "ih264d_defs.h"
32 #include "ih264d_bitstrm.h"
33 #include "ih264d_debug.h"
34 #include "ih264d_dpb_manager.h"
35 /* includes for CABAC */
36 #include "ih264d_cabac.h"
37 #include "ih264d_dpb_manager.h"
38 
39 #include "ih264d_vui.h"
40 #include "ih264d_sei.h"
41 #include "iv.h"
42 #include "ivd.h"
43 
44 #include "ih264_weighted_pred.h"
45 #include "ih264_trans_quant_itrans_iquant.h"
46 #include "ih264_inter_pred_filters.h"
47 #include "ih264_mem_fns.h"
48 #include "ih264_padding.h"
49 #include "ih264_intra_pred_filters.h"
50 #include "ih264_deblk_edge_filters.h"
51 
52 
53 
54 
55 
56 /** Number of Mb's whoose syntax will be read */
57 /************************************************************/
58 /* MB_GROUP should be a multiple of 2                       */
59 /************************************************************/
60 #define PARSE_MB_GROUP_4            4
61 
62 /* MV_SCRATCH_BUFS assumed to be pow(2) */
63 #define MV_SCRATCH_BUFS             4
64 
65 #define TOP_FIELD_ONLY      0x02
66 #define BOT_FIELD_ONLY      0x01
67 
68 #define MAX_REF_BUF_SIZE       (3776*2*2)
69 
70 struct _DecStruct;
71 struct _DecMbInfo;
72 
73 typedef enum
74 {
75     MB_TYPE_SI_SLICE = 0,
76     MB_TYPE_I_SLICE = 3,
77     MB_SKIP_FLAG_P_SLICE = 11,
78     MB_TYPE_P_SLICE = 14,
79     SUB_MB_TYPE_P_SLICE = 21,
80     MB_SKIP_FLAG_B_SLICE = 24,
81     MB_TYPE_B_SLICE = 27,
82     SUB_MB_TYPE_B_SLICE = 36,
83     MVD_X = 40,
84     MVD_Y = 47,
85     REF_IDX = 54,
86     MB_QP_DELTA = 60,
87     INTRA_CHROMA_PRED_MODE = 64,
88     PREV_INTRA4X4_PRED_MODE_FLAG = 68,
89     REM_INTRA4X4_PRED_MODE = 69,
90     MB_FIELD_DECODING_FLAG = 70,
91     CBP_LUMA = 73,
92     CBP_CHROMA = 77,
93     CBF = 85,
94     SIGNIFICANT_COEFF_FLAG_FRAME = 105,
95     SIGNIFICANT_COEFF_FLAG_FLD = 277,
96     LAST_SIGNIFICANT_COEFF_FLAG_FRAME = 166,
97     LAST_SIGNIFICANT_COEFF_FLAG_FLD = 338,
98     COEFF_ABS_LEVEL_MINUS1 = 227,
99 
100     /* High profile related Syntax element CABAC offsets */
101     TRANSFORM_SIZE_8X8_FLAG = 399,
102     SIGNIFICANT_COEFF_FLAG_8X8_FRAME = 402,
103     LAST_SIGNIFICANT_COEFF_FLAG_8X8_FRAME = 417,
104     COEFF_ABS_LEVEL_MINUS1_8X8 = 426,
105     SIGNIFICANT_COEFF_FLAG_8X8_FIELD = 436,
106     LAST_SIGNIFICANT_COEFF_FLAG_8X8_FIELD = 451
107 
108 } cabac_table_num_t;
109 
110 typedef enum
111 {
112     SIG_COEFF_CTXT_CAT_0_OFFSET = 0,
113     SIG_COEFF_CTXT_CAT_1_OFFSET = 15,
114     SIG_COEFF_CTXT_CAT_2_OFFSET = 29,
115     SIG_COEFF_CTXT_CAT_3_OFFSET = 44,
116     SIG_COEFF_CTXT_CAT_4_OFFSET = 47,
117     SIG_COEFF_CTXT_CAT_5_OFFSET = 0,
118     COEFF_ABS_LEVEL_CAT_0_OFFSET = 0,
119     COEFF_ABS_LEVEL_CAT_1_OFFSET = 10,
120     COEFF_ABS_LEVEL_CAT_2_OFFSET = 20,
121     COEFF_ABS_LEVEL_CAT_3_OFFSET = 30,
122     COEFF_ABS_LEVEL_CAT_4_OFFSET = 39,
123     COEFF_ABS_LEVEL_CAT_5_OFFSET = 0
124 } cabac_blk_cat_offset_t;
125 
126 /** Structure for the MV bank */
127 typedef struct _mv_pred_t
128 {
129     WORD16 i2_mv[4]; /** 0- mvFwdX, 1- mvFwdY, 2- mvBwdX, 3- mvBwdY */
130     WORD8 i1_ref_frame[2];
131 
132     UWORD8 u1_col_ref_pic_idx; /** Idx into the pic buff array */
133     UWORD8 u1_pic_type; /** Idx into the pic buff array */
134 
135 } mv_pred_t;
136 
137 typedef struct
138 {
139     WORD32 i4_mv_indices[16];
140     WORD8 i1_submb_num[16];
141     WORD8 i1_partitionsize[16];
142     WORD8 i1_num_partitions;
143     WORD8 u1_vert_mv_scale;
144     UWORD8 u1_col_zeroflag_change;
145 } directmv_t;
146 
147 typedef struct pic_buffer_t
148 {
149     /**Different components of the picture */
150     UWORD8 *pu1_buf1;
151     UWORD8 *pu1_buf2;
152     UWORD8 *pu1_buf3;
153     UWORD16 u2_disp_width; /** Width of the display luma frame in pixels */
154     UWORD16 u2_disp_height; /** Height of the display luma frame in pixels */
155     UWORD32 u4_time_stamp; /** Time at which frame has to be displayed */
156     UWORD16 u2_frm_wd_y; /** Width of the luma frame in pixels */
157     UWORD16 u2_frm_wd_uv; /** Width of the chroma frame */
158     UWORD16 u2_frm_ht_y; /** Height of the luma frame in pixels */
159     UWORD16 u2_frm_ht_uv; /** Height of the chroma frame */
160     /* Upto this is resembling the structure IH264DEC_DispUnit */
161 
162     /* If any member is to be added, add below this            */
163 
164     /* u4_ofst from start of picture buffer to display position for Y buffer  */
165     UWORD16 u2_crop_offset_y;
166 
167     /* u4_ofst from start of picture buffer to display position for UV buffer */
168     UWORD16 u2_crop_offset_uv;
169 
170     UWORD8 u1_is_short; /** (1: short 0: long) term ref pic */
171     UWORD8 u1_pic_type; /** frame / field / complementary field pair */
172     UWORD8 u1_pic_buf_id; /** Idx into the picBufAPI array */
173     UWORD8 u1_mv_buf_id;
174     WORD32 i4_seq;
175     UWORD8 *pu1_col_zero_flag;
176     mv_pred_t *ps_mv; /** Pointer to the MV bank array */
177     WORD32 i4_poc; /** POC */
178     WORD32 i4_pic_num;
179     WORD32 i4_frame_num;
180     WORD32 i4_top_field_order_cnt; /** TopPOC */
181     WORD32 i4_bottom_field_order_cnt; /** BottomPOC */
182     WORD32 i4_avg_poc; /** minPOC */
183     UWORD8 u1_picturetype; /*Same as u1_pic_type..u1_pic_type gets overwritten whereas
184      this doesnot get overwritten ...stores the pictype of
185      frame/complementary field pair/ mbaff */
186     UWORD8 u1_long_term_frm_idx;
187     UWORD8 u1_long_term_pic_num;
188     UWORD32 u4_pack_slc_typ; /* It will contain information about types of slices */
189 
190     /* ! */
191     UWORD32 u4_ts;
192     UWORD8 u1_pic_struct;/* Refer to SEI table D-1 */
193     sei s_sei_pic;
194 
195 } pic_buffer_t;
196 
197 typedef struct
198 {
199     void *u4_add[4];
200 } neighbouradd_t;
201 
202 typedef struct
203 {
204     const UWORD8 *pu1_inv_scan;
205     void *pv_table[6];
206 } cavlc_cntxt_t;
207 
208 /**
209  ************************************************************************
210  * \file ih264d_structs.h
211  *
212  * \brief
213  *    Structures used in the H.264 decoder
214  *
215  * \date
216  *    18/11/2002
217  *
218  * \author  Sriram Sethuraman
219  *
220  ************************************************************************
221  */
222 
223 /**
224  * Structure to represent a MV Bank buffer and col flag
225  */
226 typedef struct
227 {
228     /**
229      *  Pointer to buffer that holds col flag.
230      */
231     void *pv_col_zero_flag;
232 
233     /**
234      * Pointer to buffer that holds mv_pred
235      */
236     void *pv_mv;
237 
238  }col_mv_buf_t;
239 
240 
241 typedef struct
242 {
243     UWORD8 u1_dydx; /** 4*dy + dx for Y comp / 8*dy + dx for UV comp */
244     UWORD8 u1_is_bi_direct; /** 1: is bi-direct 0: forward / backward only   */
245     UWORD8 u1_wght_pred_type; /** 0-default 1-singleWeighted 2-BiWeighted      */
246     WORD8 i1_mb_partwidth; /** Width of MB partition                        */
247     WORD8 i1_mb_partheight; /** Height of MB partition                       */
248     WORD8 i1_mc_wd; /** Number of bytes in a DMA stride              */
249     WORD8 i1_dma_ht; /** Number of strides                            */
250 
251     WORD8 i1_pod_ht; /** Flag specifying height of pad on demand      */
252     /** 0 (No pod) -ve(Top pod) +ve(Bottom pod)      */
253     UWORD16 u2_dst_stride; /** Stride value of the destination              */
254     UWORD16 u2_u1_ref_buf_wd; /** Width of the ref buffer                      */
255     UWORD16 u2_frm_wd;
256     UWORD16 u2_dummy;
257 
258     UWORD8 *u1_pi1_wt_ofst_rec_v; /** Pointer to packed weight and u4_ofst          */
259     UWORD8 *pu1_rec_y_u; /** MB partition address in row buffer           */
260     UWORD8 *pu1_dma_dest_addr; /** Destination address for DMA transfer         */
261     UWORD8 *pu1_y_ref;
262     UWORD8 *pu1_u_ref;
263     UWORD8 *pu1_v_ref;
264 
265     UWORD8 *pu1_pred;
266     UWORD8 *pu1_pred_u;
267     UWORD8 *pu1_pred_v;
268     UWORD8 u1_dma_wd_y;
269     UWORD8 u1_dma_ht_y;
270     UWORD8 u1_dma_wd_uv;
271     UWORD8 u1_dma_ht_uv;
272 } pred_info_t;
273 
274 typedef struct
275 {
276     UWORD32 *pu4_wt_offst;
277     WORD16 i2_mv[2];
278 
279     /***************************************************/
280     /*packing information  i1_size_pos_info             */
281     /* bit 1:0 -> X position in terms of  (4x4) units   */
282     /* bit 3:2 -> Y position in terms of  (4x4) units   */
283     /* bit 5:4 -> PU width 0:4,1:8,2:16                 */
284     /* bit 7:6 -> PU height 0:4,1:8,2:16                */
285      /***************************************************/
286     WORD8 i1_size_pos_info;
287 
288     /***************************************************/
289     /*packing information ref idx info                 */
290     /* bit 5:0 ->ref_idx                              */
291     /* bit 6:7   -> 0:l0,1:l1,2:bipred                  */
292      /***************************************************/
293     WORD8 i1_ref_idx_info;
294 
295     WORD8 i1_buf_id;
296 
297 
298     UWORD8 u1_pic_type; /** frame /top field/bottom field/mbaff / complementary field pair */
299 
300 }pred_info_pkd_t;
301 /*! Sequence level parameters */
302 
303 typedef struct
304 {
305     UWORD8 u1_seq_parameter_set_id; /** id for the seq par set 0-31 */
306     UWORD8 u1_is_valid; /** is Seq Param set valid */
307 
308     UWORD16 u2_frm_wd_in_mbs; /** Frame width expressed in MB units */
309     UWORD16 u2_frm_ht_in_mbs; /** Frame height expressed in MB units */
310 
311     /* Following are derived from the above two */
312     UWORD16 u2_fld_ht_in_mbs; /** Field height expressed in MB units */
313     UWORD16 u2_max_mb_addr; /** Total number of macroblocks in a coded picture */
314     UWORD16 u2_total_num_of_mbs; /** Total number of macroblocks in a coded picture */
315     UWORD32 u4_fld_ht; /** field height */
316     UWORD32 u4_cwidth; /** chroma width */
317     UWORD32 u4_chr_frm_ht; /** chroma height */
318     UWORD32 u4_chr_fld_ht; /** chroma field height */
319     UWORD8 u1_mb_aff_flag; /** 0 - no mb_aff; 1 - uses mb_aff */
320 
321     UWORD8 u1_profile_idc; /** profile value */
322     UWORD8 u1_level_idc; /** level value */
323 
324     /* high profile related syntax elements   */
325     WORD32 i4_chroma_format_idc;
326     WORD32 i4_bit_depth_luma_minus8;
327     WORD32 i4_bit_depth_chroma_minus8;
328     WORD32 i4_qpprime_y_zero_transform_bypass_flag;
329     WORD32 i4_seq_scaling_matrix_present_flag;
330     UWORD8 u1_seq_scaling_list_present_flag[8];
331     UWORD8 u1_use_default_scaling_matrix_flag[8];
332     WORD16 i2_scalinglist4x4[6][16];
333     WORD16 i2_scalinglist8x8[2][64];
334     UWORD8 u1_more_than_one_slice_group_allowed_flag;
335     UWORD8 u1_arbitrary_slice_order_allowed_flag;
336     UWORD8 u1_redundant_slices_allowed_flag;
337     UWORD8 u1_bits_in_frm_num; /** Number of bits in frame num */
338     UWORD16 u2_u4_max_pic_num_minus1; /** Maximum frame num minus 1 */
339     UWORD8 u1_pic_order_cnt_type; /** 0 - 2 indicates the method to code picture order count */
340     UWORD8 u1_log2_max_pic_order_cnt_lsb_minus;
341     WORD32 i4_max_pic_order_cntLsb;
342     UWORD8 u1_num_ref_frames_in_pic_order_cnt_cycle;
343     UWORD8 u1_delta_pic_order_always_zero_flag;
344     WORD32 i4_ofst_for_non_ref_pic;
345     WORD32 i4_ofst_for_top_to_bottom_field;
346     WORD32 i4_ofst_for_ref_frame[MAX_NUM_REF_FRAMES_OFFSET];
347     UWORD8 u1_num_ref_frames;
348     UWORD8 u1_gaps_in_frame_num_value_allowed_flag;
349     UWORD8 u1_frame_mbs_only_flag; /** 1 - frame only; 0 - field/frame pic */
350     UWORD8 u1_direct_8x8_inference_flag;
351     UWORD8 u1_vui_parameters_present_flag;
352     vui_t s_vui;
353 } dec_seq_params_t;
354 
355 typedef struct
356 {
357     UWORD16 u2_frm_wd_in_mbs; /** Frame width expressed in MB units    */
358     UWORD16 u2_frm_ht_in_mbs; /** Frame height expressed in MB units   */
359     UWORD8 u1_frame_mbs_only_flag; /** 1 - frame only; 0 - field/frame pic  */
360     UWORD8 u1_profile_idc; /** profile value                        */
361     UWORD8 u1_level_idc; /** level value                          */
362     UWORD8 u1_direct_8x8_inference_flag;
363     UWORD8 u1_eoseq_pending;
364 } prev_seq_params_t;
365 
366 /** Picture level parameters */
367 typedef struct
368 {
369     dec_seq_params_t *ps_sps; /** applicable seq. parameter set */
370 
371     /* High profile related syntax elements */
372     WORD32 i4_transform_8x8_mode_flag;
373     WORD32 i4_pic_scaling_matrix_present_flag;
374     UWORD8 u1_pic_scaling_list_present_flag[8];
375     UWORD8 u1_pic_use_default_scaling_matrix_flag[8];
376     WORD16 i2_pic_scalinglist4x4[6][16];
377     WORD16 i2_pic_scalinglist8x8[2][64];
378     WORD8 i1_second_chroma_qp_index_offset;
379 
380     UWORD32 u4_slice_group_change_rate;
381     UWORD8 *pu1_slice_groupmb_map; /** MB map with slice membership labels */
382     UWORD8 u1_pic_parameter_set_id; /** id for the picture par set 0-255*/
383     UWORD8 u1_entropy_coding_mode; /** Entropy coding : 0-VLC; 1 - CABAC */
384     UWORD8 u1_num_slice_groups; /** Number of slice groups */
385     UWORD8 u1_pic_init_qp; /** Initial QPY for the picture {-26,25}*/
386     WORD8 i1_chroma_qp_index_offset; /** Chroma QP u4_ofst w.r.t QPY {-12,12} */
387     UWORD8 u1_dblk_filter_parms_flag; /** Slice layer has deblocking filter parameters */
388     UWORD8 u1_constrained_intra_pred_flag; /** Constrained intra prediction u4_flag */
389     UWORD8 u1_redundant_pic_cnt_present_flag; /** Redundant_pic_cnt is in slices using this PPS */
390     UWORD8 u1_pic_order_present_flag; /** Pic order present u4_flag */
391     UWORD8 u1_num_ref_idx_lx_active[2]; /** Maximum reference picture index in the reference list 0 : range [1 - 15] */
392     UWORD8 u1_wted_pred_flag;
393     UWORD8 u1_wted_bipred_idc;
394     UWORD8 u1_pic_init_qs;
395     UWORD8 u1_deblocking_filter_parameters_present_flag;
396     UWORD8 u1_vui_pic_parameters_flag;
397     UWORD8 u1_mb_slice_group_map_type;
398     UWORD8 u1_slice_group_change_direction_flag;
399     UWORD8 u1_frame_cropping_flag;
400     UWORD8 u1_frame_cropping_rect_left_ofst;
401     UWORD8 u1_frame_cropping_rect_right_ofst;
402     UWORD8 u1_frame_cropping_rect_top_ofst;
403     UWORD8 u1_frame_cropping_rect_bottom_ofst;
404     void * pv_codec_handle; /* For Error Handling */
405     WORD32 i4_top_field_order_cnt;
406     WORD32 i4_bottom_field_order_cnt;
407     WORD32 i4_avg_poc;
408     UWORD8 u1_is_valid; /** is Pic Param set valid */
409 } dec_pic_params_t;
410 
411 /** Picture Order Count Paramsters */
412 typedef struct
413 {
414     WORD32 i4_pic_order_cnt_lsb;
415     WORD32 i4_pic_order_cnt_msb;
416     WORD32 i4_delta_pic_order_cnt_bottom;
417     WORD32 i4_delta_pic_order_cnt[2];
418     WORD32 i4_prev_frame_num_ofst;
419     UWORD8 u1_mmco_equalto5;
420     UWORD8 u1_bot_field;
421     UWORD16 u2_frame_num;
422     WORD32 i4_top_field_order_count;
423     WORD32 i4_bottom_field_order_count;
424 } pocstruct_t;
425 
426 /*****************************************************************************/
427 /* parse_mb_pers_info contains necessary mb info data required persistently  */
428 /* in the form of top and left neighbours.                                   */
429 /*****************************************************************************/
430 typedef struct
431 {
432     void *u4_pic_addrress[4]; /* picture address for BS calc */
433     WORD8 pi1_intrapredmodes[4]; /* calc Intra pred modes */
434     UWORD8 pu1_nnz_y[4];
435     UWORD8 pu1_nnz_uv[4];
436     UWORD8 u1_mb_fld;
437     UWORD8 u1_mb_type;
438     UWORD16 u2_luma_csbp; /* Luma csbp used for BS calc */
439     UWORD8 u1_tran_form8x8;
440 } mb_neigbour_params_t;
441 
442 /* This info is required for decoding purposes except Deblockng */
443 typedef struct _DecMbInfo
444 {
445     UWORD8 u1_mb_type; /** macroblock type: I/P/B/SI/SP */
446     UWORD8 u1_chroma_pred_mode;
447     UWORD8 u1_cbp;
448     UWORD8 u1_mb_mc_mode; /** 16x16, 2 16x8, 2 8x16, 4 8x8 */
449     UWORD8 u1_topmb; /** top Mb u4_flag */
450     UWORD8 u1_mb_ngbr_availablity;
451     UWORD8 u1_end_of_slice;
452     UWORD8 u1_mb_field_decodingflag;
453     UWORD8 u1_topleft_mb_fld;
454     UWORD8 u1_topleft_mbtype;
455     WORD8 i1_offset;
456     UWORD8 u1_Mux;
457     UWORD8 u1_qp_div6;
458     UWORD8 u1_qp_rem6;
459     UWORD8 u1_qpc_div6;
460     UWORD8 u1_qpcr_div6;
461     UWORD8 u1_qpc_rem6;
462     UWORD8 u1_qpcr_rem6;
463     UWORD8 u1_tran_form8x8;
464     UWORD8 u1_num_pred_parts;
465     UWORD8 u1_yuv_dc_block_flag;
466     UWORD16 u2_top_right_avail_mask;
467     UWORD16 u2_top_left_avail_mask;
468     UWORD16 u2_luma_csbp; /** Coded 4x4 Sub Block Pattern */
469     UWORD16 u2_chroma_csbp; /** Coded 4x4 Sub Block Pattern */
470     UWORD16 u2_mbx;
471     UWORD16 u2_mby;
472     UWORD16 u2_mask[2];
473 
474     UWORD32 u4_pred_info_pkd_idx;
475 
476     mb_neigbour_params_t *ps_left_mb;
477     mb_neigbour_params_t *ps_top_mb;
478     mb_neigbour_params_t *ps_top_right_mb;
479     mb_neigbour_params_t *ps_curmb;
480 } dec_mb_info_t;
481 
482 
483 /** Slice level parameters */
484 typedef struct
485 {
486     dec_pic_params_t *ps_pps; /** PPS used */
487     WORD32 i4_delta_pic_order_cnt[2];
488     WORD32 i4_poc; /** Pic order cnt of picture to which slice belongs*/
489     UWORD32 u4_idr_pic_id; /** IDR pic ID */
490     UWORD16 u2_first_mb_in_slice; /** Address of first MB in slice*/
491     UWORD16 u2_frame_num; /** Frame number from prev IDR pic */
492 
493     UWORD8 u1_mbaff_frame_flag; /** Mb adaptive frame field u4_flag */
494     UWORD8 u1_field_pic_flag; /** Field picture or not */
495     UWORD8 u1_bottom_field_flag; /** If slice belongs to bot field pic */
496     UWORD8 u1_slice_type; /** I/P/B/SI/SP */
497     WORD32 i4_pic_order_cnt_lsb; /** Picture Order Count */
498     UWORD8 u1_slice_qp; /** Add slice_qp_delta to pic_init_QP */
499     UWORD8 u1_disable_dblk_filter_idc; /** 0-dblk all edges; 1 - suppress; 2 - suppress only edges */
500     WORD8 i1_slice_alpha_c0_offset; /** dblk: alpha and C0 table u4_ofst {-12,12}*/
501     WORD8 i1_slice_beta_offset; /** dblk: beta table u4_ofst {-12, 12}*/
502     UWORD8 u1_sp_for_switch_flag;
503     UWORD8 u1_no_output_of_prior_pics_flag;
504     UWORD8 u1_long_term_reference_flag;
505     UWORD8 u1_num_ref_idx_lx_active[2];
506     UWORD8 u1_cabac_init_idc; /** cabac_init_idc */
507     UWORD8 u1_num_ref_idx_active_override_flag;
508     UWORD8 u1_direct_spatial_mv_pred_flag;
509     WORD32 (*pf_decodeDirect)(struct _DecStruct *ps_dec,
510                               UWORD8 u1_wd_x,
511                               dec_mb_info_t *ps_cur_mb_info,
512                               UWORD8 u1_mb_num);
513     UWORD8 u1_redundant_pic_cnt;
514     WORD8 i1_slice_qs_delta;
515     UWORD8 u1_nal_ref_idc; /** NAL ref idc of the Slice NAL unit */
516     UWORD8 u1_nal_unit_type; /** NAL unit type of the Slice NAL */
517     UWORD8 u1_direct_8x8_inference_flag;
518     UWORD8 u1_mmco_equalto5; /** any of the MMCO command equal to 5 */
519     UWORD8 u1_pic_order_cnt_type;
520     pocstruct_t s_POC;
521     /* DataStructures required for weighted prediction */
522     UWORD16 u2_log2Y_crwd; /** Packed luma and chroma log2_weight_denom */
523     /* [list0/list1]:[ref pics index]:[0-Y 1-Cb 2-Cr] [weight/u4_ofst],
524      weights and offsets are signed numbers, since they are packed, it is defined
525      unsigned. LSB byte : weight and MSB byte: u4_ofst */
526     UWORD32 u4_wt_ofst_lx[2][MAX_REF_BUFS][3];
527     void * pv_codec_handle; /* For Error Handling */
528 
529     /*  This is used when reordering is done in Forward or    */
530     /*  backward lists. This is because reordering can point  */
531     /*  to any valid entry in initial list irrespective of    */
532     /*  num_ref_idx_active which could be overwritten using   */
533     /*  ref_idx_reorder_flag                                  */
534     UWORD8 u1_initial_list_size[2];
535     UWORD32 u4_mbs_in_slice;
536 } dec_slice_params_t;
537 
538 
539 typedef struct
540 {
541     UWORD8 u1_mb_type; /* Bit representations, X- reserved */
542     /** |Field/Frame|X|X|X|X|Bslice u4_flag|PRED_NON_16x16 u4_flag |Intra Mbflag| */
543     UWORD8 u1_mb_qp;
544     UWORD8 u1_deblocking_mode; /** dblk: Mode [ NO / NO TOP / NO LEFT] filter */
545     WORD8 i1_slice_alpha_c0_offset; /** dblk: alpha and C0 table u4_ofst {-12,12}*/
546     WORD8 i1_slice_beta_offset; /** dblk: beta table u4_ofst {-12, 12}*/
547     UWORD8 u1_single_call;
548     UWORD8 u1_topmb_qp;
549     UWORD8 u1_left_mb_qp;
550     UWORD32 u4_bs_table[10]; /* Boundary strength */
551 
552 } deblk_mb_t;
553 
554 typedef struct
555 {
556     UWORD8 u1_mb_type;
557     UWORD8 u1_mb_qp;
558 } deblkmb_neighbour_t;
559 
560 #define MAX_MV_RESIDUAL_INFO_PER_MB    32
561 #define MAX_REFIDX_INFO_PER_MB         4
562 #define PART_NOT_DIRECT                0
563 #define PART_DIRECT_8x8                1
564 #define PART_DIRECT_16x16              2
565 typedef struct
566 {
567     UWORD8 u1_is_direct;
568     UWORD8 u1_pred_mode;
569     UWORD8 u1_sub_mb_num;
570     UWORD8 u1_partheight;
571     UWORD8 u1_partwidth;
572 } parse_part_params_t;
573 
574 typedef struct
575 {
576     UWORD8 u1_isI_mb;
577     UWORD8 u1_num_part;
578     UWORD32 *pu4_wt_offst[MAX_REFIDX_INFO_PER_MB];
579     WORD8 i1_ref_idx[2][MAX_REFIDX_INFO_PER_MB];
580     UWORD8 u1_col_info[MAX_REFIDX_INFO_PER_MB];
581 } parse_pmbarams_t;
582 
583 typedef struct
584 {
585     UWORD8 u1_vert_pad_top; /* flip-flop u4_flag remembering pad area (Vert) */
586     UWORD8 u1_vert_pad_bot; /* flip-flop u4_flag remembering pad area (Vert) */
587     UWORD8 u1_horz_pad; /* flip-flop u4_flag remembering pad area (Vert) */
588     UWORD8 u1_pad_len_y_v; /* vertical pad amount for luma               */
589     UWORD8 u1_pad_len_cr_v; /* vertical pad amount for chroma             */
590 } pad_mgr_t;
591 
592 
593 #define ACCEPT_ALL_PICS   (0x00)
594 #define REJECT_CUR_PIC    (0x01)
595 #define REJECT_PB_PICS    (0x02)
596 
597 #define MASK_REJECT_CUR_PIC (0xFE)
598 #define MASK_REJECT_PB_PICS (0xFD)
599 
600 #define PIC_TYPE_UNKNOWN  (0xFF)
601 #define PIC_TYPE_I        (0x00)
602 #define SYNC_FRM_DEFAULT  (0xFFFFFFFF)
603 #define INIT_FRAME        (0xFFFFFF)
604 
605 typedef struct dec_err_status_t
606 {
607     UWORD8 u1_cur_pic_type;
608     UWORD8 u1_pic_aud_i;
609     UWORD8 u1_err_flag;
610     UWORD32 u4_frm_sei_sync;
611     UWORD32 u4_cur_frm;
612 } dec_err_status_t;
613 
614 /**************************************************************************/
615 /* Structure holds information about all high profile toolsets            */
616 /**************************************************************************/
617 typedef struct
618 {
619     /*****************************************/
620     /* variables required for scaling        */
621     /*****************************************/
622     UWORD8 u1_scaling_present;
623     WORD16 *pi2_scale_mat[8];
624 
625     /*************************************************/
626     /* scaling matrices for frame macroblocks after  */
627     /* inverse scanning                              */
628     /*************************************************/
629     WORD16 i2_scalinglist4x4[6][16];
630     WORD16 i2_scalinglist8x8[2][64];
631 
632 
633     /*****************************************/
634     /* variables required for transform8x8   */
635     /*****************************************/
636     UWORD8 u1_transform8x8_present;
637     UWORD8 u1_direct_8x8_inference_flag;
638     /* temporary variable to get noSubMbPartSizeLessThan8x8Flag from ih264d_parse_bmb_non_direct_cavlc */
639     UWORD8 u1_no_submb_part_size_lt8x8_flag;
640 
641     /* needed for inverse scanning */
642     cavlc_cntxt_t s_cavlc_ctxt;
643 
644     /* contexts for the CABAC related parsing */
645     bin_ctxt_model_t *ps_transform8x8_flag;
646     bin_ctxt_model_t *ps_sigcoeff_8x8_frame;
647     bin_ctxt_model_t *ps_last_sigcoeff_8x8_frame;
648     bin_ctxt_model_t *ps_coeff_abs_levelminus1;
649     bin_ctxt_model_t *ps_sigcoeff_8x8_field;
650     bin_ctxt_model_t *ps_last_sigcoeff_8x8_field;
651 
652 /* variables required for intra8x8 */
653 
654 /* variables required for handling different Qp for Cb and Cr */
655 
656 } high_profile_tools_t;
657 
658 typedef struct
659 {
660     UWORD32 u4_num_bufs; /* Number of buffers in each display frame. 2 for 420SP and 3 for 420P and so on */
661     void *buf[3]; /* Pointers to each of the components */
662     UWORD32 u4_bufsize[3];
663     UWORD32 u4_ofst[3];
664 } disp_buf_t;
665 typedef struct _dec_slice_struct
666 {
667     volatile UWORD32 u4_first_mb_in_slice;
668     volatile UWORD32 slice_type;
669     volatile UWORD16 u2_log2Y_crwd;
670     volatile void **ppv_map_ref_idx_to_poc;
671     volatile void *pv_tu_coeff_data_start;
672 } dec_slice_struct_t;
673 
674 /**
675  * Structure to hold coefficient info for a 4x4 transform
676  */
677 typedef struct
678 {
679     /**
680      * significant coefficient map
681      */
682     UWORD16 u2_sig_coeff_map;
683 
684     /**
685      * holds coefficients
686      */
687     WORD16  ai2_level[16];
688 }tu_sblk4x4_coeff_data_t;
689 
690 /**
691  * Structure to hold coefficient info for a 8x8 transform
692  */
693 typedef struct
694 {
695 
696     /**
697      * significant coefficient map
698      */
699     UWORD32 au4_sig_coeff_map[2];
700 
701     /**
702      * holds coefficients
703      */
704     WORD16  ai2_level[64];
705 }tu_blk8x8_coeff_data_t;
706 
707 /** Aggregating structure that is globally available */
708 typedef struct _DecStruct
709 {
710 
711     /* Add below all other static memory allocations and pointers to items
712      that are dynamically allocated once per session */
713     dec_bit_stream_t *ps_bitstrm;
714     dec_seq_params_t *ps_cur_sps;
715     dec_pic_params_t *ps_cur_pps;
716     dec_slice_params_t *ps_cur_slice;
717 
718     dec_pic_params_t *ps_pps;
719     dec_seq_params_t *ps_sps;
720     const UWORD16 *pu2_quant_scale_y;
721     const UWORD16 *pu2_quant_scale_u;
722     const UWORD16 *pu2_quant_scale_v;
723     UWORD16 u2_mbx;
724     UWORD16 u2_mby;
725 
726     UWORD16 u2_frm_wd_y; /** Width for luma buff */
727     UWORD16 u2_frm_ht_y; /** Height for luma buff */
728     UWORD16 u2_frm_wd_uv; /** Width for chroma buff */
729     UWORD16 u2_frm_ht_uv; /** Height for chroma buff */
730     UWORD16 u2_frm_wd_in_mbs; /** Frame width expressed in MB units */
731     UWORD16 u2_frm_ht_in_mbs; /** Frame height expressed in MB units */
732     WORD32 i4_submb_ofst; /** Offset in subMbs from the top left edge */
733     /* Pointer to colocated Zero frame Image, will be used in B_DIRECT mode */
734     /* colZeroFlag | // 0th bit
735      field_flag  | // 1st bit
736      XX          | // 2:3 bit don't cares
737      subMbMode   | // 4:5 bit
738      MbMode      | // 6:7 bit */
739 
740     UWORD8 *pu1_col_zero_flag;
741 
742     UWORD16 u2_pic_wd; /** Width of the picture being decoded */
743     UWORD16 u2_pic_ht; /** Height of the picture being decoded */
744 
745     UWORD8 u1_first_slice_in_stream;
746     UWORD8 u1_mb_ngbr_availablity;
747     UWORD8 u1_ref_idxl0_active_minus1;
748     UWORD8 u1_qp;
749     UWORD8 u1_qp_y_div6;
750     UWORD8 u1_qp_u_div6;
751     UWORD8 u1_qp_y_rem6;
752     UWORD8 u1_qp_u_rem6;
753 
754     /*********************************/
755     /* configurable mb-group numbers */
756     /* very critical to the decoder  */
757     /*********************************/
758     /************************************************************/
759     /* MB_GROUP should be a multiple of 2                       */
760     /************************************************************/
761     UWORD8 u1_recon_mb_grp;
762     UWORD8 u1_recon_mb_grp_pair;
763     /* Variables to handle Cabac */
764     decoding_envirnoment_t s_cab_dec_env; /* < Structure for decoding_envirnoment_t */
765     /* These things need to be updated at each MbLevel */
766     WORD8 i1_next_ctxt_idx; /* < next Ctxt Index */
767     UWORD8 u1_currB_type;
768     WORD8 i1_prev_mb_qp_delta; /* Prev MbQpDelta */
769     UWORD8 u1_nal_unit_type;
770 
771     ctxt_inc_mb_info_t *p_ctxt_inc_mb_map; /* Pointer to ctxt_inc_mb_info_t map */
772     ctxt_inc_mb_info_t *p_left_ctxt_mb_info; /* Pointer to left ctxt_inc_mb_info_t */
773     ctxt_inc_mb_info_t *p_top_ctxt_mb_info; /* Pointer to top ctxt_inc_mb_info_t */
774     ctxt_inc_mb_info_t *ps_curr_ctxt_mb_info; /* Pointer to current ctxt_inc_mb_info_t */
775     ctxt_inc_mb_info_t *ps_def_ctxt_mb_info; /* Pointer to default ctxt_inc_mb_info_t */
776 
777     /* mv contexts for mv decoding using cabac */
778     //UWORD8   u1_top_mv_ctxt_inc[4][4];
779     /* Dimensions for u1_left_mv_ctxt_inc_arr is [2][4][4] for Mbaff case */
780     UWORD8 u1_left_mv_ctxt_inc_arr[2][4][4];
781     UWORD8 (*pu1_left_mv_ctxt_inc)[4];
782 
783     UWORD8 u1_sub_mb_num;
784     UWORD8 u1_B; /** if B slice u1_B = 1 else 0 */
785     WORD16 i2_only_backwarddma_info_idx;
786     mv_pred_t *ps_mv; /** Pointer to the MV bank array */
787     mv_pred_t *ps_mv_bank_cur; /** Pointer to the MV bank array */
788     mv_pred_t s_default_mv_pred; /** Structure containing the default values
789      for MV predictor */
790 
791     pred_info_t *ps_pred; /** Stores info to cfg MC */
792     pred_info_t *ps_pred_start;
793 
794     UWORD32 u4_pred_info_idx;
795     pred_info_pkd_t *ps_pred_pkd;
796     pred_info_pkd_t *ps_pred_pkd_start;
797     UWORD32 u4_pred_info_pkd_idx;
798     UWORD8 *pu1_ref_buff; /** Destination buffer for DMAs */
799     UWORD32 u4_dma_buf_idx;
800 
801     UWORD8 *pu1_y;
802     UWORD8 *pu1_u;
803     UWORD8 *pu1_v;
804 
805     WORD16 *pi2_y_coeff;
806     UWORD8 *pu1_inv_scan;
807 
808     /**
809      * Pointer frame level TU subblock coeff data
810      */
811     void *pv_pic_tu_coeff_data;
812 
813     /**
814      * Pointer to TU subblock coeff data and number of subblocks and scan idx
815      * Incremented each time a coded subblock is processed
816      *
817      */
818     void *pv_parse_tu_coeff_data;
819     void *pv_prev_mb_parse_tu_coeff_data;
820 
821     void *pv_proc_tu_coeff_data;
822 
823     WORD16 *pi2_coeff_data;
824 
825     cavlc_cntxt_t s_cavlc_ctxt;
826 
827     UWORD32 u4_n_leftY[2];
828     UWORD32 u4_n_left_cr[2];
829     UWORD32 u4_n_left_temp_y;
830 
831     UWORD8 pu1_left_nnz_y[4];
832     UWORD8 pu1_left_nnz_uv[4];
833     UWORD32 u4_n_left_temp_uv;
834     /***************************************************************************/
835     /*          Base pointer to all the cabac contexts                         */
836     /***************************************************************************/
837     bin_ctxt_model_t *p_cabac_ctxt_table_t;
838 
839     /***************************************************************************/
840     /* cabac context pointers for every SE mapped into in p_cabac_ctxt_table_t */
841     /***************************************************************************/
842     bin_ctxt_model_t *p_mb_type_t;
843     bin_ctxt_model_t *p_mb_skip_flag_t;
844     bin_ctxt_model_t *p_sub_mb_type_t;
845     bin_ctxt_model_t *p_mvd_x_t;
846     bin_ctxt_model_t *p_mvd_y_t;
847     bin_ctxt_model_t *p_ref_idx_t;
848     bin_ctxt_model_t *p_mb_qp_delta_t;
849     bin_ctxt_model_t *p_intra_chroma_pred_mode_t;
850     bin_ctxt_model_t *p_prev_intra4x4_pred_mode_flag_t;
851     bin_ctxt_model_t *p_rem_intra4x4_pred_mode_t;
852     bin_ctxt_model_t *p_mb_field_dec_flag_t;
853     bin_ctxt_model_t *p_cbp_luma_t;
854     bin_ctxt_model_t *p_cbp_chroma_t;
855     bin_ctxt_model_t *p_cbf_t[NUM_CTX_CAT];
856     bin_ctxt_model_t *p_significant_coeff_flag_t[NUM_CTX_CAT];
857     bin_ctxt_model_t *p_coeff_abs_level_minus1_t[NUM_CTX_CAT];
858 
859     UWORD32 u4_num_pmbair; /** MB pair number */
860     mv_pred_t *ps_mv_left; /** Pointer to left motion vector bank */
861     mv_pred_t *ps_mv_top_left; /** Pointer to top left motion vector bank */
862     mv_pred_t *ps_mv_top_right; /** Pointer to top right motion vector bank */
863 
864     UWORD8 *pu1_left_yuv_dc_csbp;
865 
866 
867     deblkmb_neighbour_t deblk_left_mb[2];
868     deblkmb_neighbour_t *ps_deblk_top_mb;
869     neighbouradd_t (*ps_left_mvpred_addr)[2]; /* Left MvPred Address Ping Pong*/
870 
871     /***************************************************************************/
872     /*       Ref_idx contexts  are stored in the following way                 */
873     /*  Array Idx 0,1 for reference indices in Forward direction               */
874     /*  Array Idx 2,3 for reference indices in backward direction              */
875     /***************************************************************************/
876 
877     /* Dimensions for u1_left_ref_ctxt_inc_arr is [2][4] for Mbaff:Top and Bot */
878     WORD8 i1_left_ref_idx_ctx_inc_arr[2][4];
879     WORD8 *pi1_left_ref_idx_ctxt_inc;
880 
881     /*************************************************************************/
882     /*               Arrangnment of DC CSBP                                  */
883     /*        bits:  b7  b6  b5  b4  b3  b2  b1  b0                          */
884     /*        CSBP:   x   x   x   x   x  Vdc Udc Ydc                         */
885     /*************************************************************************/
886     /*************************************************************************/
887     /*  Points either to u1_yuv_dc_csbp_topmb or  u1_yuv_dc_csbp_bot_mb     */
888     /*************************************************************************/
889     UWORD8 u1_yuv_dc_csbp_topmb;
890     UWORD8 u1_yuv_dc_csbp_bot_mb;
891 
892     /* DMA SETUP */
893     tfr_ctxt_t s_tran_addrecon_parse;
894     tfr_ctxt_t s_tran_addrecon;
895     tfr_ctxt_t s_tran_iprecon;
896     tfr_ctxt_t *ps_frame_buf_ip_recon;
897     WORD8 i1_recon_in_thread3_flag;
898 
899     /* slice Header Simplification */
900     UWORD8 u1_pr_sl_type;
901     WORD32 i4_frametype;
902     UWORD32 u4_app_disp_width;
903     WORD32 i4_error_code;
904     UWORD32 u4_bitoffset;
905 
906     /* Variables added to handle field pics */
907 
908     UWORD8 u1_second_field;
909     WORD32 i4_pic_type;
910     WORD32 i4_content_type;
911     WORD32 i4_decode_header;
912     WORD32 i4_header_decoded;
913     UWORD32 u4_total_frames_decoded;
914 
915     ctxt_inc_mb_info_t *ps_left_mb_ctxt_info; /* structure containing the left MB's
916      context info, incase of Mbaff */
917     pocstruct_t s_prev_pic_poc;
918     pocstruct_t s_cur_pic_poc;
919     WORD32 i4_cur_display_seq;
920     WORD32 i4_prev_max_display_seq;
921     WORD32 i4_max_poc;
922     deblk_mb_t *ps_cur_deblk_mb;
923 
924     /* Pointers to local scratch buffers */
925     deblk_mb_t *ps_deblk_pic;
926 
927     /* Pointers to Picture Buffers (Given by BufAPI Lib) */
928     struct pic_buffer_t *ps_cur_pic; /** Pointer to Current picture buffer */
929 
930     /* Scratch Picture Buffers (Given by BufAPI Lib) */
931     struct pic_buffer_t s_cur_pic;
932 
933     /* Current Slice related information */
934     volatile UWORD16 u2_cur_slice_num;
935     volatile UWORD16 u2_cur_slice_num_dec_thread;
936 
937     /* Variables needed for Buffer API handling */
938     UWORD8 u1_nal_buf_id;
939     UWORD8 u1_pic_buf_id;
940     UWORD8 u1_pic_bufs;
941 
942     WORD16 *pi2_pred1; //[441];  /** Temp predictor buffer for MC */
943     /* Pointer to refernce Pic buffers list, 0:fwd, 1:bwd */
944     pic_buffer_t **ps_ref_pic_buf_lx[2];
945     /* refIdx to POC mapping */
946     void **ppv_map_ref_idx_to_poc;
947     void **ppv_map_ref_idx_to_poc_base;
948     UWORD32 *pu4_wts_ofsts_mat;
949     UWORD32 *pu4_wt_ofsts;
950     UWORD32 *pu4_mbaff_wt_mat;
951     /* Function pointers to read Params common to CAVLC and CABAC */
952     WORD32 (*pf_parse_inter_mb)(struct _DecStruct * ps_dec,
953                                 dec_mb_info_t * ps_cur_mb_info,
954                                 UWORD8 u1_mb_num,
955                                 UWORD8 u1_num_mbsNby2);
956     WORD32 (*pf_mvpred_ref_tfr_nby2mb)(struct _DecStruct * ps_dec,
957                                      UWORD8 u1_num_mbs,
958                                      UWORD8 u1_num_mbsNby2);
959 
960     WORD32 (*pf_parse_inter_slice)(struct _DecStruct * ps_dec,
961                                    dec_slice_params_t * ps_slice,
962                                    UWORD16 u2_first_mb_in_slice);
963 
964     UWORD32 (*pf_get_mb_info)(struct _DecStruct * ps_dec,
965                               const UWORD16 u2_cur_mb_address,
966                               dec_mb_info_t * ps_cur_mb_info,
967                               UWORD32 u4_mbskip_run);
968 
969     /* Variables for Decode Buffer Management */
970     dpb_manager_t *ps_dpb_mgr;
971     dpb_commands_t *ps_dpb_cmds;
972     dpb_commands_t s_dpb_cmds_scratch;
973 
974     /* Variables Required for N MB design */
975     dec_mb_info_t *ps_nmb_info;
976 
977     UWORD8 *pu1_y_intra_pred_line;
978     UWORD8 *pu1_u_intra_pred_line;
979     UWORD8 *pu1_v_intra_pred_line;
980 
981     UWORD8 *pu1_cur_y_intra_pred_line;
982     UWORD8 *pu1_cur_u_intra_pred_line;
983     UWORD8 *pu1_cur_v_intra_pred_line;
984 
985     UWORD8 *pu1_cur_y_intra_pred_line_base;
986     UWORD8 *pu1_cur_u_intra_pred_line_base;
987     UWORD8 *pu1_cur_v_intra_pred_line_base;
988 
989     UWORD8 *pu1_prev_y_intra_pred_line;
990     UWORD8 *pu1_prev_u_intra_pred_line;
991     UWORD8 *pu1_prev_v_intra_pred_line;
992 
993     UWORD32 u4_intra_pred_line_ofst;
994 
995     UWORD8 u1_res_changed;
996 
997     mv_pred_t *ps_mv_cur; /** pointer to current motion vector bank */
998     mv_pred_t *ps_mv_top; /** pointer to top motion vector bank */
999     mv_pred_t *ps_mv_top_right2;/** Pointer to top right motion vector bank */
1000     mv_pred_t *ps_mv_p[2]; /** Scratch ping motion vector bank */
1001     mv_pred_t *ps_mv_top_p[MV_SCRATCH_BUFS]; /** Scratch top pong motion vector bank */
1002     UWORD8 u1_mv_top_p;
1003 
1004     deblk_mb_t *ps_deblk_mbn;
1005 
1006     UWORD8 *pu1_temp_mc_buffer;
1007 
1008     struct _sei *ps_sei;
1009     struct _sei *ps_sei_parse;
1010     struct _sei s_sei_export;
1011 
1012     void *pv_disp_sei_params;
1013 
1014     UWORD8 u1_pic_struct_copy;
1015     /* Variables required for cropping */
1016     UWORD16 u2_disp_width;
1017     UWORD16 u2_disp_height;
1018     UWORD16 u2_crop_offset_y;
1019     UWORD16 u2_crop_offset_uv;
1020 
1021     /* Variable required to get presentation time stamp through application */
1022     UWORD32 u4_pts;
1023 
1024     /* Variables used for gaps in frame number */
1025     UWORD16 u2_prev_ref_frame_num;
1026 
1027     UWORD8 u1_mb_idx;
1028     struct pic_buffer_t *ps_col_pic;
1029     void (*pf_parse_mvdirect)(struct _DecStruct*,
1030                            struct pic_buffer_t*,
1031                            directmv_t*,
1032                            UWORD8,
1033                            WORD32,
1034                            dec_mb_info_t *);
1035     void *pv_dec_out;
1036     void *pv_dec_in;
1037     void *pv_scratch_sps_pps; /*used temeporarily store sps/ spps while parsing*/
1038 
1039     /* state pointers to mb and partition information */
1040     parse_pmbarams_t *ps_parse_mb_data;
1041     parse_part_params_t *ps_parse_part_params;
1042 
1043     /* scratch pointers to mb and partition information */
1044     parse_part_params_t *ps_part;
1045 
1046     UWORD8 u1_max_dec_frame_buffering;
1047     pad_mgr_t s_pad_mgr;
1048     UWORD8 (*pf_mvpred)(struct _DecStruct *ps_dec,
1049                         struct _DecMbInfo *ps_cur_mb_info,
1050                         mv_pred_t *ps_mv_pred,
1051                         mv_pred_t *ps_mv_nmb,
1052                         mv_pred_t *ps_mv_ntop,
1053                         UWORD8 u1_sub_mb_num,
1054                         UWORD8 uc_mb_part_width,
1055                         UWORD8 uc_lxstart,
1056                         UWORD8 uc_lxend,
1057                         UWORD8 u1_mb_mc_mode);
1058     void (*pf_compute_bs)(struct _DecStruct * ps_dec,
1059                          struct _DecMbInfo * ps_cur_mb_info,
1060                          const UWORD16 u2_mbxn_mb);
1061     UWORD8 u1_init_dec_flag;
1062     WORD32 i4_reorder_depth;
1063     prev_seq_params_t s_prev_seq_params;
1064     UWORD8 u1_cur_mb_fld_dec_flag; /* current Mb fld or Frm */
1065 
1066     UWORD8 u1_topleft_mb_fld;
1067     UWORD8 u1_topleft_mbtype;
1068     UWORD8 u1_topleft_mb_fld_bot;
1069     UWORD8 u1_topleft_mbtype_bot;
1070     WORD16 i2_prev_slice_mbx;
1071     WORD16 i2_prev_slice_mby;
1072     UWORD16 u2_top_left_mask;
1073     UWORD16 u2_top_right_mask;
1074     dec_err_status_t * ps_dec_err_status;
1075     /* Ensure pi1_left_pred_mode is aligned to 4 byte boundary,
1076     by declaring this after a pointer or an integer */
1077     WORD8 pi1_left_pred_mode[8];
1078 
1079     UWORD8 u1_mb_idx_mv;
1080     UWORD16 u2_mv_2mb[2];
1081     UWORD32 u4_skip_frm_mask;
1082 
1083     /* variable for finding the no.of mbs decoded in the current picture */
1084     UWORD16 u2_total_mbs_coded;
1085     /* member added for supporting fragmented annex - B */
1086 //  frg_annex_read_t s_frag_annex_read;
1087     /* added for vui_t, sei support*/
1088     WORD32 i4_vui_frame_rate;
1089     /* To Store the value of ref_idx_active for previous slice */
1090     /* useful in error handling                                */
1091     UWORD8 u1_num_ref_idx_lx_active_prev;
1092     /* Flag added to come out of process call in annex-b if&if frame is decoded */
1093     /* presence of access unit delimters and pps and sps                        */
1094     UWORD8 u1_frame_decoded_flag;
1095 
1096     /* To keep track of whether the last picture was decoded or not */
1097     /* in case of skip mode set by the application                  */
1098     UWORD8 u1_last_pic_not_decoded;
1099 
1100     WORD32 e_dec_status;
1101     UWORD32 u4_num_fld_in_frm;
1102 
1103     /* Function pointer for 4x4 residual cavlc parsing based on total coeff */
1104     WORD32 (*pf_cavlc_4x4res_block[3])(UWORD32 u4_isdc,
1105                                     UWORD32 u4_total_coeff_trail_one, /**TotalCoefficients<<16+trailingones*/
1106                                     dec_bit_stream_t *ps_bitstrm);
1107 
1108     /* Function pointer array for interpolate functions in called from motion compensattion module */
1109     void (*p_mc_interpolate_x_y[16][3])(UWORD8*,
1110                                         UWORD8*,
1111                                         UWORD8*,
1112                                         UWORD8,
1113                                         UWORD16,
1114                                         UWORD16,
1115                                         UWORD8);
1116 
1117     /**************************************************************************/
1118     /* Function pointer for 4x4 totalcoeff, trlone and residual cavlc parsing */
1119     /* based on u4_n (neigbourinng nnz average)                               */
1120     /* These point to two functions depending on (u4_n > 7) and (u4_n <= 7)   */
1121     /**************************************************************************/
1122     WORD32 (*pf_cavlc_parse4x4coeff[2])(WORD16 *pi2_coeff_block,
1123                                         UWORD32 u4_isdc, /* is it a DC block */
1124                                         WORD32 u4_n,
1125                                         struct _DecStruct *ps_dec, /** Decoder Parameters */
1126                                         UWORD32 *pu4_total_coeff);
1127 
1128     /**************************************************************************/
1129     /* Function pointer for luma 8x8block cavlc parsing based on top and left */
1130     /* neigbour availability.                                                 */
1131     /**************************************************************************/
1132     WORD32 (*pf_cavlc_parse_8x8block[4])(WORD16 *pi2_coeff_block,
1133                                          UWORD32 u4_sub_block_strd,
1134                                          UWORD32 u4_isdc,
1135                                          struct _DecStruct *ps_dec,
1136                                          UWORD8 *pu1_top_nnz,
1137                                          UWORD8 *pu1_left_nnz,
1138                                          UWORD8 u1_tran_form8x8,
1139                                          UWORD8 u1_mb_field_decodingflag,
1140                                          UWORD32 *pu4_csbp);
1141 
1142     /**************************************************************************/
1143     /* Ping pong top and current rows of mb neigbour_params                   */
1144     /**************************************************************************/
1145     mb_neigbour_params_t *ps_nbr_mb_row;
1146     mb_neigbour_params_t *ps_cur_mb_row;
1147     mb_neigbour_params_t *ps_top_mb_row;
1148 
1149     /**************************************************************************/
1150     /* Function pointer for 16x16 and non16x16 Bs1 calculations depending on   */
1151     /* P and B slice.                                                          */
1152     /***************************************************************************/
1153     void (*pf_fill_bs1[2][2])(mv_pred_t *ps_cur_mv_pred,
1154                               mv_pred_t *ps_top_mv_pred,
1155                               void **ppv_map_ref_idx_to_poc,
1156                               UWORD32 *pu4_bs_table, /* pointer to the BsTable array */
1157                               mv_pred_t *ps_leftmost_mv_pred,
1158                               neighbouradd_t *ps_left_addr,
1159                               void **u4_pic_addrress,
1160                               WORD32 i4_ver_mvlimit);
1161 
1162     void (*pf_fill_bs_xtra_left_edge[2])(UWORD32 *pu4_bs, /* Base pointer of BS table */
1163                                          WORD32 u4_left_mb_t_csbp, /* left mbpair's top csbp   */
1164                                          WORD32 u4_left_mb_b_csbp, /* left mbpair's bottom csbp*/
1165                                          WORD32 u4_cur_mb_csbp, /* csbp of current mb */
1166                                          UWORD32 u4_cur_mb_bot /* is top or bottom mb */
1167 
1168                                          );
1169     /* Function pointer array for BP and MP functions for MC*/
1170     void (*p_motion_compensate)(struct _DecStruct * ps_dec,
1171                                dec_mb_info_t *ps_cur_mb_info);
1172 
1173 
1174     void (*p_mc_dec_thread)(struct _DecStruct * ps_dec, dec_mb_info_t *ps_cur_mb_info);
1175 
1176     /* Function pointer array for BP and MP functions for formMbPartInfo*/
1177 
1178     WORD32 (*p_form_mb_part_info)(pred_info_pkd_t *ps_pred_pkd,
1179                                 struct _DecStruct * ps_dec,
1180                                      UWORD16 u2_mb_x,
1181                                      UWORD16 u2_mb_y,
1182                                      WORD32 mb_index,
1183                                      dec_mb_info_t *ps_cur_mb_info);
1184 
1185     WORD32 (*p_form_mb_part_info_thread)(pred_info_pkd_t *ps_pred_pkd,
1186                                 struct _DecStruct * ps_dec,
1187                                      UWORD16 u2_mb_x,
1188                                      UWORD16 u2_mb_y,
1189                                      WORD32 mb_index,
1190                                      dec_mb_info_t *ps_cur_mb_info);
1191 
1192 
1193     /* Required for cabac mbaff bottom mb */
1194     UWORD32 u4_next_mb_skip;
1195 
1196     void (*p_DeblockPicture[2])(struct _DecStruct *);
1197 
1198     /* ! */
1199     UWORD32 u4_ts;
1200     UWORD8 u1_flushfrm;
1201 
1202     /* Output format sent by the application */
1203     UWORD8 u1_chroma_format;
1204     UWORD8 u1_pic_decode_done;
1205     UWORD8 u1_slice_header_done;
1206     WORD32 init_done;
1207 
1208     /******************************************/
1209     /* For the high profile related variables */
1210     /******************************************/
1211     high_profile_tools_t s_high_profile;
1212     /* CBCR */
1213     UWORD8 u1_qp_v_div6;
1214     UWORD8 u1_qp_v_rem6;
1215     /*
1216      * TO help solve the dangling field case.
1217      * Check for the previous frame number and the current frame number.
1218      */
1219     UWORD16 u2_prv_frame_num;
1220     UWORD8 u1_top_bottom_decoded;
1221     UWORD8 u1_dangling_field;
1222 
1223     IVD_DISPLAY_FRAME_OUT_MODE_T                e_frm_out_mode;
1224 
1225     UWORD8 *pu1_bits_buf_static;
1226     UWORD8 *pu1_bits_buf_dynamic;
1227 
1228     UWORD32 u4_static_bits_buf_size;
1229     UWORD32 u4_dynamic_bits_buf_size;
1230 
1231     UWORD32 u4_num_disp_bufs_requested;
1232     WORD32 i4_display_delay;
1233     UWORD32 u4_slice_start_code_found;
1234 
1235     UWORD32 u4_nmb_deblk;
1236     UWORD32 u4_use_intrapred_line_copy;
1237     UWORD32 u4_num_mbs_prev_nmb;
1238     UWORD32 u4_num_mbs_cur_nmb;
1239     UWORD32 u4_app_deblk_disable_level;
1240     UWORD32 u4_app_disable_deblk_frm;
1241     WORD32 i4_mv_frac_mask;
1242 
1243     disp_buf_t disp_bufs[MAX_DISP_BUFS_NEW];
1244     UWORD32 u4_disp_buf_mapping[MAX_DISP_BUFS_NEW];
1245     UWORD32 u4_disp_buf_to_be_freed[MAX_DISP_BUFS_NEW];
1246     UWORD32 u4_share_disp_buf;
1247     UWORD32 u4_num_disp_bufs;
1248 
1249     UWORD32 u4_bs_deblk_thread_created;
1250     volatile UWORD32 u4_start_recon_deblk;
1251     void *pv_bs_deblk_thread_handle;
1252 
1253     UWORD32 u4_cur_bs_mb_num;
1254     UWORD32 u4_bs_cur_slice_num_mbs;
1255     UWORD32 u4_cur_deblk_mb_num;
1256     UWORD32 u4_sps_cnt_in_process;
1257     volatile UWORD16 u2_cur_slice_num_bs;
1258 
1259     UWORD32 u4_deblk_mb_x;
1260     UWORD32 u4_deblk_mb_y;
1261 
1262 
1263 
1264     iv_yuv_buf_t s_disp_frame_info;
1265     UWORD32 u4_fmt_conv_num_rows;
1266     UWORD32 u4_fmt_conv_cur_row;
1267     ivd_out_bufdesc_t *ps_out_buffer;
1268     ivd_get_display_frame_op_t s_disp_op;
1269     UWORD32 u4_output_present;
1270 
1271     volatile UWORD16 cur_dec_mb_num;
1272     volatile UWORD16 cur_recon_mb_num;
1273     volatile UWORD16 u2_cur_mb_addr;
1274     WORD16 i2_dec_thread_mb_y;
1275     WORD16 i2_recon_thread_mb_y;
1276 
1277     UWORD8 u1_separate_parse;
1278     UWORD32 u4_dec_thread_created;
1279     void *pv_dec_thread_handle;
1280     volatile UWORD8 *pu1_dec_mb_map;
1281     volatile UWORD8 *pu1_recon_mb_map;
1282     volatile UWORD16 *pu2_slice_num_map;
1283     dec_slice_struct_t *ps_dec_slice_buf;
1284     void *pv_map_ref_idx_to_poc_buf;
1285     dec_mb_info_t *ps_frm_mb_info;
1286     volatile dec_slice_struct_t * volatile ps_parse_cur_slice;
1287     volatile dec_slice_struct_t * volatile ps_decode_cur_slice;
1288     volatile dec_slice_struct_t * volatile ps_computebs_cur_slice;
1289     UWORD32 u4_cur_slice_decode_done;
1290     UWORD32 u4_extra_mem_used;
1291 
1292     /* 2 first slice not parsed , 1 :first slice parsed , 0 :first valid slice header parsed*/
1293     UWORD32 u4_first_slice_in_pic;
1294     UWORD32 u4_num_cores;
1295     IVD_ARCH_T e_processor_arch;
1296     IVD_SOC_T e_processor_soc;
1297 
1298     /**
1299      * Pictures that are are degraded
1300      * 0 : No degrade
1301      * 1 : Only on non-reference frames
1302      * 2 : Use interval specified by u4_nondegrade_interval
1303      * 3 : All non-key frames
1304      * 4 : All frames
1305      */
1306     WORD32 i4_degrade_pics;
1307 
1308     /**
1309      * Interval for pictures which are completely decoded without any degradation
1310      */
1311     WORD32 i4_nondegrade_interval;
1312 
1313     /**
1314      * bit position (lsb is zero): Type of degradation
1315      * 1 : Disable deblocking
1316      * 2 : Faster inter prediction filters
1317      * 3 : Fastest inter prediction filters
1318      */
1319     WORD32 i4_degrade_type;
1320 
1321     /** Degrade pic count, Used to maintain the interval between non-degraded pics
1322      *
1323      */
1324     WORD32 i4_degrade_pic_cnt;
1325     WORD32 i4_display_index;
1326     UWORD32 u4_pic_buf_got;
1327 
1328     /**
1329      * Col flag and mv pred buffer manager
1330      */
1331     void *pv_mv_buf_mgr;
1332 
1333     /**
1334      * Picture buffer manager
1335      */
1336     void *pv_pic_buf_mgr;
1337 
1338     /**
1339      * Display buffer manager
1340      */
1341     void *pv_disp_buf_mgr;
1342 
1343     void *apv_buf_id_pic_buf_map[MAX_DISP_BUFS_NEW];
1344 
1345     UWORD8 au1_pic_buf_id_mv_buf_id_map[MAX_DISP_BUFS_NEW];
1346 
1347     UWORD8 au1_pic_buf_ref_flag[MAX_DISP_BUFS_NEW];
1348 
1349     struct pic_buffer_t *ps_pic_buf_base;
1350 
1351     UWORD8 *pu1_ref_buff_base;
1352     col_mv_buf_t *ps_col_mv_base;
1353     void *(*pf_aligned_alloc)(void *pv_mem_ctxt, WORD32 alignment, WORD32 size);
1354     void (*pf_aligned_free)(void *pv_mem_ctxt, void *pv_buf);
1355     void *pv_mem_ctxt;
1356 
1357     UWORD8 *pu1_pic_buf_base;
1358     UWORD8 *pu1_mv_bank_buf_base;
1359     UWORD8 *pu1_init_dpb_base;
1360 
1361     ih264_default_weighted_pred_ft *pf_default_weighted_pred_luma;
1362 
1363     ih264_default_weighted_pred_ft *pf_default_weighted_pred_chroma;
1364 
1365     ih264_weighted_pred_ft *pf_weighted_pred_luma;
1366 
1367     ih264_weighted_pred_ft *pf_weighted_pred_chroma;
1368 
1369     ih264_weighted_bi_pred_ft *pf_weighted_bi_pred_luma;
1370 
1371     ih264_weighted_bi_pred_ft *pf_weighted_bi_pred_chroma;
1372 
1373     ih264_pad *pf_pad_top;
1374     ih264_pad *pf_pad_bottom;
1375     ih264_pad *pf_pad_left_luma;
1376     ih264_pad *pf_pad_left_chroma;
1377     ih264_pad *pf_pad_right_luma;
1378     ih264_pad *pf_pad_right_chroma;
1379 
1380     ih264_inter_pred_chroma_ft *pf_inter_pred_chroma;
1381 
1382     ih264_inter_pred_luma_ft *apf_inter_pred_luma[16];
1383 
1384     ih264_intra_pred_luma_ft *apf_intra_pred_luma_16x16[4];
1385 
1386     ih264_intra_pred_luma_ft *apf_intra_pred_luma_8x8[9];
1387 
1388     ih264_intra_pred_luma_ft *apf_intra_pred_luma_4x4[9];
1389 
1390     ih264_intra_pred_ref_filtering_ft *pf_intra_pred_ref_filtering;
1391 
1392     ih264_intra_pred_chroma_ft *apf_intra_pred_chroma[4];
1393 
1394     ih264_iquant_itrans_recon_ft *pf_iquant_itrans_recon_luma_4x4;
1395 
1396     ih264_iquant_itrans_recon_ft *pf_iquant_itrans_recon_luma_4x4_dc;
1397 
1398     ih264_iquant_itrans_recon_ft *pf_iquant_itrans_recon_luma_8x8;
1399 
1400     ih264_iquant_itrans_recon_ft *pf_iquant_itrans_recon_luma_8x8_dc;
1401 
1402     ih264_iquant_itrans_recon_chroma_ft *pf_iquant_itrans_recon_chroma_4x4;
1403 
1404     ih264_iquant_itrans_recon_chroma_ft *pf_iquant_itrans_recon_chroma_4x4_dc;
1405 
1406     ih264_ihadamard_scaling_ft *pf_ihadamard_scaling_4x4;
1407 
1408     /**
1409      * deblock vertical luma edge with blocking strength 4
1410      */
1411     ih264_deblk_edge_bs4_ft *pf_deblk_luma_vert_bs4;
1412 
1413     /**
1414      * deblock vertical luma edge with blocking strength less than 4
1415      */
1416     ih264_deblk_edge_bslt4_ft *pf_deblk_luma_vert_bslt4;
1417 
1418     /**
1419      * deblock vertical luma edge with blocking strength 4 for mbaff
1420      */
1421     ih264_deblk_edge_bs4_ft *pf_deblk_luma_vert_bs4_mbaff;
1422 
1423     /**
1424      * deblock vertical luma edge with blocking strength less than 4 for mbaff
1425      */
1426     ih264_deblk_edge_bslt4_ft *pf_deblk_luma_vert_bslt4_mbaff;
1427 
1428     /**
1429      * deblock vertical chroma edge with blocking strength 4
1430      */
1431     ih264_deblk_chroma_edge_bs4_ft *pf_deblk_chroma_vert_bs4;
1432 
1433     /**
1434      * deblock vertical chroma edge with blocking strength less than 4
1435      */
1436     ih264_deblk_chroma_edge_bslt4_ft *pf_deblk_chroma_vert_bslt4;
1437 
1438     /**
1439      * deblock vertical chroma edge with blocking strength 4 for mbaff
1440      */
1441     ih264_deblk_chroma_edge_bs4_ft *pf_deblk_chroma_vert_bs4_mbaff;
1442 
1443     /**
1444      * deblock vertical chroma edge with blocking strength less than 4 for mbaff
1445      */
1446     ih264_deblk_chroma_edge_bslt4_ft *pf_deblk_chroma_vert_bslt4_mbaff;
1447 
1448     /**
1449      * deblock horizontal luma edge with blocking strength 4
1450      */
1451     ih264_deblk_edge_bs4_ft *pf_deblk_luma_horz_bs4;
1452 
1453     /**
1454      * deblock horizontal luma edge with blocking strength less than 4
1455      */
1456     ih264_deblk_edge_bslt4_ft *pf_deblk_luma_horz_bslt4;
1457 
1458     /**
1459      * deblock horizontal chroma edge with blocking strength 4
1460      */
1461     ih264_deblk_chroma_edge_bs4_ft *pf_deblk_chroma_horz_bs4;
1462 
1463     /**
1464      * deblock horizontal chroma edge with blocking strength less than 4
1465      */
1466     ih264_deblk_chroma_edge_bslt4_ft *pf_deblk_chroma_horz_bslt4;
1467 
1468 
1469 } dec_struct_t;
1470 
1471 #endif /* _H264_DEC_STRUCTS_H */
1472