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_utils.c */ 24 /* */ 25 /* Description : MVCD Utility functions used by 'imvcd_api.c' */ 26 /* */ 27 /*****************************************************************************/ 28 29 #ifndef _IMVCD_UTILS_H_ 30 #define _IMVCD_UTILS_H_ 31 32 #include <stdbool.h> 33 #include <string.h> 34 35 #include "ih264_typedefs.h" 36 #include "imvc_defs.h" 37 #include "ih264d_mvpred.h" 38 #include "ih264d_structs.h" 39 #include "imvcd_structs.h" 40 41 #define SWAP(x, y, data_type) \ 42 { \ 43 data_type temp; \ 44 memcpy(&temp, &y, sizeof(data_type)); \ 45 memcpy(&y, &x, sizeof(data_type)); \ 46 memcpy(&x, &temp, sizeof(data_type)); \ 47 } 48 49 extern IV_API_CALL_STATUS_T imvcd_get_next_display_au_buf(mvc_dec_ctxt_t *ps_mvcd_ctxt); 50 51 extern UWORD32 imvcd_get_num_mbs_in_level(UWORD8 u1_level_idc); 52 53 extern WORD32 imvcd_allocate_dynamic_bufs(mvc_dec_ctxt_t *ps_mvcd_ctxt); 54 55 extern WORD16 imvcd_free_dynamic_bufs(mvc_dec_ctxt_t *ps_mvcd_ctxt); 56 57 extern WORD32 imvcd_init_au_buffers(mvc_dec_ctxt_t *ps_mvcd_ctxt); 58 59 extern WORD32 imvcd_init_au_mv_pred_bufs(mvc_dec_ctxt_t *ps_mvcd_ctxt); 60 61 extern void imvcd_convert_au_buf_to_view_buf(mvc_au_buffer_t *ps_au_buf, pic_buffer_t *ps_view_buf, 62 UWORD16 u2_view_order_id, UWORD16 u2_view_id); 63 64 extern void imvcd_init_ref_idx_to_ref_buf_map(mvc_dec_ctxt_t *ps_mvcd_ctxt); 65 66 extern void imvcd_ivp_buf_copier(mvc_au_buffer_t *ps_au_buf_src, mvc_au_buffer_t *ps_au_buf_dst, 67 mvc_au_mv_pred_t *ps_au_mv_data_src, 68 mvc_au_mv_pred_t *ps_au_mv_data_dst, UWORD16 u2_src_view_id, 69 UWORD16 u2_dst_view_id); 70 71 /* Function defined in 'ih264d_utils.c' and declared nowhere else */ 72 extern WORD32 ih264d_init_dec_mb_grp(dec_struct_t *ps_dec); 73 74 extern void ih264d_init_cabac_contexts(UWORD8 u1_slice_type, dec_struct_t *ps_dec); 75 76 extern void ih264d_get_implicit_weights(dec_struct_t *ps_dec); 77 78 extern void imvcd_free_ref_bufs(mvc_au_buf_mgr_t *ps_mvc_au_buf_mgr, 79 mvc_au_mv_pred_buf_mgr_t *ps_mvc_au_mv_pred_buf_mgr, 80 WORD32 i4_pic_buf_id); 81 82 extern void imvcd_release_all_ref_bufs(mvc_dec_ctxt_t *ps_mvcd_ctxt, WORD32 i4_num_bufs); 83 84 extern void imvcd_free_ref_and_io_bufs(mvc_au_buf_mgr_t *ps_mvc_au_buf_mgr, 85 mvc_au_mv_pred_buf_mgr_t *ps_mvc_au_mv_pred_buf_mgr, 86 WORD32 i4_pic_buf_id); 87 88 extern void imvcd_release_all_ref_and_io_bufs(mvc_dec_ctxt_t *ps_mvcd_ctxt, WORD32 i4_num_bufs); 89 90 extern bool is_header_decoded(WORD32 i4_header_decoded, AVC_EXT_NALU_ID_T e_nalu_id); 91 92 extern bool is_mvc_nalu(AVC_EXT_NALU_ID_T e_nalu_id); 93 94 extern bool is_slice_nalu_type(AVC_EXT_NALU_ID_T e_nalu_id); 95 96 extern nalu_mvc_ext_t *imvcd_get_cur_nalu_mvc_ext(mvc_dec_ctxt_t *ps_mvcd_ctxt); 97 98 extern nalu_mvc_ext_t *imvcd_get_nalu_mvc_ext(nalu_mvc_ext_t *ps_nalu_mvc_exts, 99 UWORD16 u2_num_views_decoded, UWORD16 u2_view_id); 100 101 extern ref_pic_list_mod_data_t *imvcd_get_cur_ref_pic_list_mod_data(mvc_dec_ctxt_t *ps_mvcd_ctxt); 102 103 extern subset_sps_t *imvcd_get_valid_subset_sps(mvc_dec_ctxt_t *ps_mvcd_ctxt); 104 105 extern void imvcd_modulate_max_disp_seq(dec_struct_t *ps_view_ctxt); 106 107 extern mv_pred_t imvcd_get_default_mv_pred(void); 108 109 extern UWORD32 imvcd_get_max_num_ivp_refs(mvc_dec_ctxt_t *ps_mvcd_ctxt); 110 111 extern bool imvcd_is_idr_au(mvc_dec_ctxt_t *ps_mvcd_ctxt); 112 113 extern coordinates_t imvcd_get_buf_pad_dims(bool b_is_chroma); 114 115 extern WORD32 imvcd_get_ref_pic_pad_offset(WORD32 i4_stride, bool b_is_chroma); 116 117 extern UWORD32 imvcd_get_next_bits(dec_bit_stream_t *ps_bitstream); 118 119 extern void imvcd_set_view_buf_id_to_buf_map(dec_struct_t *ps_view_ctxt); 120 121 #endif 122