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