1 /* 2 * Copyright(c) 2019 Intel Corporation 3 * 4 * This source code is subject to the terms of the BSD 2 Clause License and 5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6 * was not distributed with this source code in the LICENSE file, you can 7 * obtain it at https://www.aomedia.org/license/software-license. If the Alliance for Open 8 * Media Patent License 1.0 was not distributed with this source code in the 9 * PATENTS file, you can obtain it at https://www.aomedia.org/license/patent-license. 10 */ 11 12 #ifndef EbPredictionStructure_h 13 #define EbPredictionStructure_h 14 15 #include "EbDefinitions.h" 16 #include "EbObject.h" 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 /************************************************ 21 * Defines 22 ************************************************/ 23 #define FLAT_PREDICTION_STRUCTURE_PERIOD 1 24 #define TWO_LEVEL_HIERARCHICAL_PREDICTION_STRUCTURE_PERIOD 2 25 #define THREE_LEVEL_HIERARCHICAL_PREDICTION_STRUCTURE_PERIOD 4 26 #define FOUR_LEVEL_HIERARCHICAL_PREDICTION_STRUCTURE_PERIOD 8 27 #define MAX_PREDICTION_STRUCTURE_PERIOD 64 28 29 /************************************************ 30 * RPS defines 31 ************************************************/ 32 #define RPS_UNUSED ~0 33 #define MAX_NUM_OF_NEGATIVE_REF_PICS 5 34 #define MAX_NUM_OF_POSITIVE_REF_PICS 5 35 #define MAX_NUM_OF_REF_PICS_TOTAL (MAX_NUM_OF_POSITIVE_REF_PICS + MAX_NUM_OF_NEGATIVE_REF_PICS) 36 37 /************************************************ 38 * Reference List 39 * 40 * reference_list - Contains the deltaPOCs of 41 * the pictures referenced by the current 42 * picture. 43 ************************************************/ 44 typedef struct ReferenceList { 45 int32_t *reference_list; 46 uint32_t reference_list_count; 47 } ReferenceList; 48 49 /************************************************ 50 * Dependent List 51 * 52 * list_count - Contains count of how 53 * deep into list should be used 54 * depending on how many references are 55 * being used in the prediction structure. 56 * 57 * list - Contains the deltaPOCs of 58 * pictures that reference the current picture. 59 * The dependent list pictures must be grouped 60 * by the referenceCount group in ascending 61 * order. The grouping is not display order! 62 ************************************************/ 63 typedef struct DependentList { 64 int32_t *list; 65 uint32_t list_count; 66 } DependentList; 67 68 /************************************************ 69 * Prediction Structure Config 70 * Contains a collection of basic control data 71 * for the basic prediction structure. 72 ************************************************/ 73 typedef struct PredictionStructureConfig { 74 uint32_t entry_count; 75 PredictionStructureConfigEntry *entry_array; 76 } PredictionStructureConfig; 77 78 /************************************************ 79 * Prediction Structure Entry 80 * Contains the reference and dependent lists 81 * for a particular picture in the Prediction 82 * Structure. 83 ************************************************/ 84 typedef struct PredictionStructureEntry { 85 ReferenceList ref_list0; 86 ReferenceList ref_list1; 87 DependentList dep_list0; 88 DependentList dep_list1; 89 uint32_t temporal_layer_index; 90 uint32_t decode_order; 91 EbBool is_referenced; 92 } PredictionStructureEntry; 93 94 /************************************************ 95 * Prediction Structure 96 * Contains a collection of control and RPS 97 * data types for an entire Prediction Structure 98 ************************************************/ 99 typedef struct PredictionStructure { 100 EbDctor dctor; 101 uint32_t pred_struct_entry_count; 102 PredictionStructureEntry **pred_struct_entry_ptr_array; 103 EbPred pred_type; 104 uint32_t temporal_layer_count; 105 uint32_t pred_struct_period; 106 uint32_t maximum_extent; 107 108 // Section Indices 109 uint32_t leading_pic_index; 110 uint32_t init_pic_index; 111 uint32_t steady_state_index; 112 113 //private use only 114 int32_t * decode_order_table; 115 uint32_t *display_order_table; 116 EbBool * timeline_map; 117 } PredictionStructure; 118 119 /************************************************ 120 * Prediction Structure Group 121 * Contains the control structures for all 122 * supported prediction structures. 123 ************************************************/ 124 typedef struct PredictionStructureGroup { 125 EbDctor dctor; 126 PredictionStructure **prediction_structure_ptr_array; 127 uint32_t prediction_structure_count; 128 void * priv; /* private member*/ 129 uint8_t ref_count_used; 130 } PredictionStructureGroup; 131 132 /************************************************ 133 * Declarations 134 ************************************************/ 135 extern EbErrorType prediction_structure_group_ctor(PredictionStructureGroup *pred_struct_group_ptr, 136 uint8_t mrp_init_level, 137 EbEncMode enc_mode, 138 EbSvtAv1EncConfiguration *config); 139 140 extern PredictionStructure *get_prediction_structure( 141 PredictionStructureGroup *prediction_structure_group_ptr, EbPred pred_structure, 142 uint32_t number_of_references, uint32_t levels_of_hierarchy); 143 typedef enum { 144 LAST = 0, 145 LAST2 = 1, 146 LAST3 = 2, 147 GOLD = 3, 148 BWD = 4, 149 ALT2 = 5, 150 ALT = 6 151 } REF_FRAME_MINUS1; 152 typedef struct Av1RpsNode { 153 uint8_t refresh_frame_mask; 154 uint8_t ref_dpb_index[7]; //LAST-LAST2-LAST3-GOLDEN-BWD-ALT2-ALT 155 uint64_t ref_poc_array[7]; //decoder based ref poc array //LAST-LAST2-LAST3-GOLDEN-BWD-ALT2-ALT 156 } Av1RpsNode; 157 158 #ifdef __cplusplus 159 } 160 #endif 161 #endif // EbPredictionStructure_h 162