1 /****************************************************************************** 2 * 3 * Copyright (C) 2021 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 21 /*****************************************************************************/ 22 /* */ 23 /* File Name : imvcd_nalu_parser.h */ 24 /* */ 25 /* Description : Functions for MVC NALU parsing */ 26 /* */ 27 /*****************************************************************************/ 28 29 #ifndef _IMVCD_DPB_MANAGER_H_ 30 #define _IMVCD_DPB_MANAGER_H_ 31 #include <stdbool.h> 32 #include <string.h> 33 34 #include "ih264_typedefs.h" 35 #include "ih264_error.h" 36 #include "ih264_buf_mgr.h" 37 #include "ih264_disp_mgr.h" 38 #include "ih264d_dpb_manager.h" 39 #include "imvcd_defs.h" 40 #include "imvcd_structs.h" 41 #include "imvcd_utils.h" 42 43 #define NUM_MMCO_CMD_IDS ((RESET_ALL_PICTURES) + 1) 44 45 typedef struct mvc_dpb_info_t 46 { 47 mvc_au_buffer_t *ps_au_buf; 48 49 struct mvc_dpb_info_t *ps_prev_short; 50 51 struct mvc_dpb_info_t *ps_prev_long; 52 53 struct field_t s_top_field; 54 55 struct field_t s_bot_field; 56 57 bool b_used_as_ref; 58 59 } mvc_dpb_info_t; 60 61 typedef struct display_buf_info_t 62 { 63 WORD32 i4_poc; 64 65 WORD32 i4_poc_buf_id; 66 67 WORD32 i4_frame_num; 68 } display_buf_info_t; 69 70 typedef struct dpb_ivp_ctxt_t 71 { 72 sps_mvc_ext_t *ps_sps_mvc_ext; 73 74 nalu_mvc_ext_t *ps_nalu_mvc_exts; 75 76 UWORD8 au1_au_buf_ids[MVC_MAX_REF_PICS]; 77 78 UWORD8 au1_mv_buf_ids[MVC_MAX_REF_PICS]; 79 80 UWORD32 u4_num_ivp_refs; 81 } dpb_ivp_ctxt_t; 82 83 typedef struct mvc_dpb_manager_t 84 { 85 /** DPB in default index order */ 86 mvc_au_buffer_t *aps_def_dpb[MVC_MAX_REF_PICS]; 87 88 /** DPB in reordered index order, 0-fwd,1-bwd */ 89 mvc_au_buffer_t *aps_mod_dpb[2][MVC_MAX_REF_PICS]; 90 91 /** DPB in reordered index order, 0-fwd,1-bwd */ 92 mvc_au_buffer_t as_init_dpb[2][MVC_MAX_REF_PICS]; 93 94 /** Replicates view level data in 'aps_mod_dpb' */ 95 pic_buffer_t *aps_view_mod_dpb[2][MVC_MAX_REF_PICS]; 96 97 /** Replicates view level data in 'aps_init_dpb' */ 98 pic_buffer_t as_view_init_dpb[2][MVC_MAX_REF_PICS]; 99 100 mvc_dpb_info_t as_dpb_info[MVC_MAX_REF_PICS]; 101 102 display_buf_info_t as_display_buf_info[MAX_FRAMES]; 103 104 dpb_ivp_ctxt_t s_dpb_ivp_ctxt; 105 106 mvc_dpb_info_t *ps_dpb_st_head; 107 108 mvc_dpb_info_t *ps_dpb_lt_head; 109 110 mvc_au_buf_mgr_t *ps_mvc_au_buf_mgr; 111 112 mvc_au_mv_pred_buf_mgr_t *ps_mvc_au_mv_pred_buf_mgr; 113 114 disp_mgr_t *ps_disp_buf_mgr; 115 116 WORD32 ai4_gaps_start_frm_num[MAX_FRAMES]; 117 118 WORD32 ai4_gaps_end_frm_num[MAX_FRAMES]; 119 120 WORD8 ai1_gaps_per_seq[MAX_FRAMES]; 121 122 UWORD8 au1_num_active_st_refs[2]; 123 124 UWORD8 au1_num_active_lt_refs[2]; 125 126 WORD32 i4_max_pic_num; 127 128 WORD32 i4_display_delay; 129 130 WORD32 i4_cur_display_seq; 131 132 UWORD16 u2_num_views; 133 134 UWORD8 u1_num_st_ref_bufs; 135 136 UWORD8 u1_num_lt_ref_bufs; 137 138 UWORD8 u1_max_lt_frame_idx; 139 140 UWORD8 u1_num_gaps; 141 142 WORD8 i1_poc_buf_id_entries; 143 144 WORD8 i1_gaps_deleted; 145 146 UWORD8 u1_mmco_error_in_seq; 147 148 } mvc_dpb_manager_t; 149 150 /* Function declarations */ 151 extern void imvcd_init_dpb_mgr(mvc_dpb_manager_t *ps_dpb_mgr, mvc_au_buf_mgr_t *ps_mvc_au_buf_mgr, 152 mvc_au_mv_pred_buf_mgr_t *ps_mvc_au_mv_pred_buf_mgr, 153 disp_mgr_t *ps_disp_buf_mgr); 154 155 extern WORD32 imvcd_dpb_assign_display_seq(mvc_dpb_manager_t *ps_dpb_mgr); 156 157 extern WORD32 imvcd_dpb_insert_pic_in_display_list(mvc_dpb_manager_t *ps_dpb_mgr, 158 WORD32 i4_display_poc, UWORD32 u4_frame_num, 159 WORD32 i4_buf_id); 160 161 extern WORD32 imvcd_dpb_do_mmco_for_gaps(mvc_dpb_manager_t *ps_dpb_mgr, UWORD8 u1_num_ref_frames); 162 163 extern void imvcd_dpb_delete_nonref_nondisplay_pics(mvc_dpb_manager_t *ps_dpb_mgr); 164 165 extern void imvcd_reset_dpb(mvc_dpb_manager_t *ps_dpb_mgr); 166 167 extern void imvcd_dpb_release_display_bufs(mvc_dpb_manager_t *ps_dpb_mgr); 168 169 extern void imvcd_assign_pic_num(mvc_dpb_manager_t *ps_dpb_mgr, WORD32 i4_max_frame_num, 170 WORD32 i4_cur_frame_num, 171 bool b_are_gaps_in_frame_num_value_allowed); 172 173 extern UWORD8 imvcd_dpb_st_lt_deduplicator(mvc_dpb_manager_t *ps_dpb_mgr); 174 175 extern WORD32 imvcd_init_ref_pic_list(mvc_dpb_manager_t *ps_dpb_mgr, 176 nalu_mvc_ext_t *ps_cur_nalu_mvc_ext, 177 mvc_au_buffer_t *ps_cur_au, UWORD16 u2_view_order_id); 178 179 extern WORD32 imvcd_dpb_reorder_ref_pic_list(mvc_dpb_manager_t *ps_dpb_mgr, 180 nalu_mvc_ext_t *ps_cur_nalu_mvc_ext, 181 mvc_au_buffer_t *ps_cur_au, 182 ref_pic_list_mod_data_t *ps_ref_pic_list_mod_data, 183 UWORD16 u2_view_order_id); 184 185 extern WORD32 imvcd_dpb_insert_st_node(mvc_dpb_manager_t *ps_dpb_mgr, mvc_au_buffer_t *ps_au_buf); 186 187 extern WORD32 imvcd_dpb_delete_st_node_or_make_lt(mvc_dpb_manager_t *ps_dpb_mgr, 188 WORD32 i4_frame_num, UWORD32 u4_lt_idx); 189 190 extern WORD32 imvcd_dpb_do_mmco(dpb_commands_t *ps_dpb_cmds, mvc_dpb_manager_t *ps_dpb_mgr, 191 mvc_au_buffer_t *ps_cur_au, UWORD8 u1_max_num_ref_frames, 192 UWORD8 u1_curr_pic_in_err); 193 194 extern WORD32 imvcd_dpb_update_default_index_list(mvc_dpb_manager_t *ps_dpb_mgr); 195 196 extern void imvcd_dpb_set_display_num(mvc_dpb_manager_t *ps_dpb_mgr, WORD32 i4_display_num); 197 198 extern void imvcd_dpb_set_max_pic_num(mvc_dpb_manager_t *ps_dpb_mgr, WORD32 i4_max_pic_num); 199 200 extern void imvcd_dpb_set_num_views(mvc_dpb_manager_t *ps_dpb_mgr, UWORD16 u2_num_views); 201 202 extern void imvcd_dpb_set_display_delay(mvc_dpb_manager_t *ps_dpb_mgr, WORD32 i4_display_delay); 203 204 extern void imvcd_dpb_init_au_bufs(mvc_dpb_manager_t *ps_dpb_mgr, mvc_au_buffer_t *ps_cur_au); 205 206 extern void imvcd_dpb_init_view_bufs(mvc_dpb_manager_t *ps_dpb_mgr, UWORD16 u2_view_order_id, 207 UWORD16 u2_view_id); 208 209 extern void imvcd_dpb_init_ivp_ctxt(mvc_dpb_manager_t *ps_dpb_mgr, sps_mvc_ext_t *ps_sps_mvc_ext, 210 nalu_mvc_ext_t *ps_nalu_mvc_exts); 211 212 extern void imvcd_dpb_reset_ivp_ctxt(mvc_dpb_manager_t *ps_dpb_mgr); 213 214 extern pic_buffer_t **imvcd_dpb_get_view_ref_pic_list(mvc_dpb_manager_t *ps_dpb_mgr, 215 UWORD16 u2_view_order_id, UWORD16 u2_view_id, 216 UWORD8 u1_pred_dir); 217 218 extern bool imvcd_dpb_is_diff_poc_valid(mvc_dpb_manager_t *ps_dpb_mgr, WORD32 i4_curr_poc); 219 220 #endif 221