Hamsalekha S | 8d3d303 | 2015-03-13 21:24:58 +0530 | [diff] [blame] | 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_DPB_MANAGER_H_ |
| 21 | #define _IH264D_DPB_MANAGER_H_ |
| 22 | /*! |
| 23 | *************************************************************************** |
| 24 | * \file ih264d_dpb_manager.h |
| 25 | * |
| 26 | * \brief |
| 27 | * Decoded Picture Buffer Manager Include File |
| 28 | * |
| 29 | * Detailed_description |
| 30 | * |
| 31 | * \date |
| 32 | * 19-12-2002 |
| 33 | * |
| 34 | * \author Sriram Sethuraman |
| 35 | *************************************************************************** |
| 36 | */ |
| 37 | #include "ih264_typedefs.h" |
| 38 | #include "ih264_macros.h" |
| 39 | #include "ih264_platform_macros.h" |
| 40 | #include "ih264d_bitstrm.h" |
| 41 | #include "ih264d_defs.h" |
| 42 | |
| 43 | #define END_OF_MMCO 0 |
| 44 | #define MARK_ST_PICNUM_AS_NONREF 1 |
| 45 | #define MARK_LT_INDEX_AS_NONREF 2 |
| 46 | #define MARK_ST_PICNUM_AS_LT_INDEX 3 |
| 47 | #define SET_MAX_LT_INDEX 4 |
| 48 | #define RESET_REF_PICTURES 5 |
| 49 | #define SET_LT_INDEX 6 |
| 50 | #define RESET_NONREF_PICTURES 7 |
| 51 | #define RESET_ALL_PICTURES 8 |
| 52 | |
Aasaipriya Chandran | 083b9fc | 2020-06-10 13:42:04 +0530 | [diff] [blame] | 53 | #define NO_LONG_TERM_INDICIES 255 |
Hamsalekha S | 8d3d303 | 2015-03-13 21:24:58 +0530 | [diff] [blame] | 54 | struct field_t |
| 55 | { |
| 56 | /* picNum of tbe reference field */ |
| 57 | WORD32 i4_pic_num; |
| 58 | |
| 59 | /* assigned when used for long term reference */ |
| 60 | /* else MAX_REF_BUFS+1 */ |
| 61 | UWORD8 u1_long_term_frame_idx; |
| 62 | |
| 63 | /* 0 : unused for reference */ |
| 64 | /* 1 : used for short term reference */ |
| 65 | /* 2 : used for long term reference */ |
| 66 | UWORD8 u1_reference_info; |
| 67 | }; |
| 68 | |
| 69 | |
| 70 | struct dpb_info_t |
| 71 | { |
| 72 | struct pic_buffer_t *ps_pic_buf; /** Pointer to picture buffer structure */ |
| 73 | WORD32 i4_frame_num; /** frame number of picture - unique for each ref*/ |
| 74 | struct dpb_info_t *ps_prev_short;/** Link to the DPB with previous picNum */ |
| 75 | struct dpb_info_t *ps_prev_long; /** Link to the DPB with previous long term frame*/ |
| 76 | struct field_t s_top_field; /** Contains information of the top_field |
| 77 | reference info, pic num and longt term frame idx */ |
| 78 | struct field_t s_bot_field; /** Contains information of the bot_field |
| 79 | reference info, pic num and longt term frame idx */ |
| 80 | UWORD8 u1_buf_id; /** bufID from bufAPI */ |
| 81 | UWORD8 u1_used_as_ref; /** whether buffer is used as ref for frame or |
| 82 | complementary reference field pair */ |
| 83 | UWORD8 u1_lt_idx; /** If buf is assigned long-term index; else MAX_REF_BUFS+1 */ |
| 84 | |
| 85 | }; |
| 86 | |
| 87 | typedef struct |
| 88 | { |
| 89 | struct pic_buffer_t *ps_def_dpb[MAX_REF_BUFS];/** DPB in default index order */ |
| 90 | struct pic_buffer_t *ps_mod_dpb[2][2 * MAX_REF_BUFS];/** DPB in reordered index order, 0-fwd,1-bwd */ |
| 91 | struct pic_buffer_t *ps_init_dpb[2][2 * MAX_REF_BUFS];/** DPB in reordered index order, 0-fwd,1-bwd */ |
| 92 | struct dpb_info_t *ps_dpb_st_head; /** Pointer to the most recent picNum */ |
| 93 | struct dpb_info_t *ps_dpb_ht_head; /** Pointer to the smallest LT index */ |
| 94 | struct dpb_info_t as_dpb_info[MAX_REF_BUFS]; /** Physical storage for dpbInfo for ref bufs */ |
| 95 | UWORD8 u1_num_st_ref_bufs; /** Number of short term ref. buffers */ |
| 96 | UWORD8 u1_num_lt_ref_bufs; /** Number of long term ref. buffer */ |
Aasaipriya Chandran | 083b9fc | 2020-06-10 13:42:04 +0530 | [diff] [blame] | 97 | UWORD8 u1_max_lt_frame_idx; /** Maximum long term frame index */ |
Hamsalekha S | 8d3d303 | 2015-03-13 21:24:58 +0530 | [diff] [blame] | 98 | UWORD8 u1_num_gaps; /** Total number of outstanding gaps */ |
| 99 | void * pv_codec_handle; /* For Error Handling */ |
| 100 | WORD32 i4_max_frm_num; /** Max frame number */ |
| 101 | WORD32 ai4_gaps_start_frm_num[MAX_FRAMES];/** start frame number for a gap seqn */ |
| 102 | WORD32 ai4_gaps_end_frm_num[MAX_FRAMES]; /** start frame number for a gap seqn */ |
| 103 | WORD8 ai1_gaps_per_seq[MAX_FRAMES]; /** number of gaps with each gap seqn */ |
| 104 | WORD32 ai4_poc_buf_id_map[MAX_FRAMES][3]; |
| 105 | WORD8 i1_poc_buf_id_entries; |
| 106 | WORD8 i1_gaps_deleted; |
| 107 | UWORD16 u2_pic_wd; |
| 108 | UWORD16 u2_pic_ht; |
| 109 | }dpb_manager_t; |
| 110 | |
| 111 | /** Structure store the MMC Commands */ |
| 112 | struct MMCParams |
| 113 | { |
| 114 | UWORD32 u4_mmco; /** memory managemet control operation */ |
| 115 | UWORD32 u4_diff_pic_num; /** diff Of Pic Nums Minus1 */ |
| 116 | UWORD32 u4_lt_idx; /** Long Term Pic Idx */ |
| 117 | UWORD32 u4_max_lt_idx_plus1; /** MaxLongTermPicIdxPlus1 */ |
| 118 | }; |
| 119 | |
| 120 | typedef struct |
| 121 | { |
| 122 | UWORD8 u1_dpb_commands_read; /** Flag to indicate that DBP commands are read */ |
| 123 | UWORD8 u1_buf_mode; /** decoder Pic bugffering mode*/ |
| 124 | UWORD8 u1_num_of_commands; /** Number of MMC commands */ |
| 125 | /* These variables are ised in case of IDR pictures only */ |
| 126 | UWORD8 u1_idr_pic; /** = 1 ,IDR pic */ |
| 127 | UWORD8 u1_no_output_of_prior_pics_flag; |
| 128 | UWORD8 u1_long_term_reference_flag; |
| 129 | struct MMCParams as_mmc_params[MAX_REF_BUFS]; /* < Buffer to store MMC commands */ |
| 130 | UWORD8 u1_dpb_commands_read_slc; |
| 131 | }dpb_commands_t; |
| 132 | |
| 133 | void ih264d_init_ref_bufs(dpb_manager_t *ps_dpb_mgr); |
| 134 | |
| 135 | WORD32 ih264d_insert_st_node(dpb_manager_t *ps_dpb_mgr, |
| 136 | struct pic_buffer_t *ps_pic_buf, |
| 137 | UWORD8 u1_buf_id, |
| 138 | UWORD32 u2_cur_pic_num); |
| 139 | WORD32 ih264d_update_default_index_list(dpb_manager_t *ps_dpb_mgr); |
| 140 | WORD32 ih264d_do_mmco_buffer(dpb_commands_t *ps_dpb_cmds, |
| 141 | dpb_manager_t *ps_dpb_mgr, |
| 142 | UWORD8 u1_numRef_frames_for_seq, |
| 143 | UWORD32 u4_cur_pic_num, |
| 144 | UWORD32 u2_u4_max_pic_num_minus1, |
| 145 | UWORD8 u1_nal_unit_type, |
| 146 | struct pic_buffer_t *ps_pic_buf, |
| 147 | UWORD8 u1_buf_id, |
| 148 | UWORD8 u1_fld_pic_flag, |
| 149 | UWORD8 u1_curr_pic_in_err); |
| 150 | void ih264d_release_pics_in_dpb(void *pv_dec, |
| 151 | UWORD8 u1_disp_bufs); |
| 152 | void ih264d_reset_ref_bufs(dpb_manager_t *ps_dpb_mgr); |
| 153 | WORD32 ih264d_delete_st_node_or_make_lt(dpb_manager_t *ps_dpb_mgr, |
| 154 | WORD32 u4_pic_num, |
| 155 | UWORD32 u4_lt_idx, |
| 156 | UWORD8 u1_fld_pic_flag); |
| 157 | |
| 158 | WORD32 ih264d_delete_gap_frm_mmco(dpb_manager_t *ps_dpb_mgr, |
| 159 | WORD32 i4_frame_num, |
| 160 | UWORD8 *pu1_del_node); |
| 161 | |
| 162 | WORD32 ih264d_delete_gap_frm_sliding(dpb_manager_t *ps_dpb_mgr, |
| 163 | WORD32 i4_frame_num, |
| 164 | UWORD8 *pu1_del_node); |
| 165 | |
| 166 | WORD32 ih264d_do_mmco_for_gaps(dpb_manager_t *ps_dpb_mgr, |
| 167 | UWORD8 u1_num_ref_frames); |
| 168 | |
| 169 | WORD32 ih264d_insert_pic_in_display_list(dpb_manager_t *ps_dpb_mgr, |
| 170 | UWORD8 u1_buf_id, |
| 171 | WORD32 i4_display_poc, |
| 172 | UWORD32 u4_frame_num); |
| 173 | void ih264d_delete_nonref_nondisplay_pics(dpb_manager_t *ps_dpb_mgr); |
| 174 | #endif /* _IH264D_DPB_MANAGER_H_ */ |