1 /* 2 * Copyright (c) 2017, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file codec_def_encode_vp8.h 24 //! \brief Defines encode VP8 types and macros shared by CodecHal, MHW, and DDI layer 25 //! \details Applies to VP8 encode only. Should not contain any DDI specific code. 26 //! 27 #ifndef __CODEC_DEF_ENCODE_VP8_H__ 28 #define __CODEC_DEF_ENCODE_VP8_H__ 29 30 #define ENCODE_VP8_BRC_HISTORY_BUFFER_SIZE 704 31 #define ENCODE_VP8_BRC_PAK_QP_TABLE_SIZE 2880 32 #define VP8_QINDEX_Y1_DC 0 33 #define VP8_QINDEX_UV_DC 1 34 #define VP8_QINDEX_UV_AC 2 35 #define VP8_QINDEX_Y2_DC 3 36 #define VP8_QINDEX_Y2_AC 4 37 38 #define ENCODE_VP8_NUM_MAX_L0_REF 3 // used in LibVa 39 40 #define CODECHAL_VP8_MAX_QP 128 41 #define CODECHAL_VP8_MB_CODE_SIZE 204 42 #define CODECHAL_VP8_MB_MV_CODE_SIZE 64 43 #define CODECHAL_VP8_MB_MV_CODE_OFFSET_ALIGNMENT 4096 44 #define CODECHAL_VP8_MB_CODE_ALIGNMENT 32 45 #define CODECHAL_VP8_FRAME_HEADER_SIZE 4096 46 #define CODECHAL_VP8_MAX_SEGMENTS 4 47 #define CODECHAL_VP8_ME_ME_DATA_SIZE_MULTIPLIER 3 48 49 //VP8 Sequence Params 50 typedef struct _CODEC_VP8_ENCODE_SEQUENCE_PARAMS 51 { 52 uint16_t FrameWidth : 14; 53 uint16_t FrameWidthScale : 2; 54 uint16_t FrameHeight : 14; 55 uint16_t FrameHeightScale : 2; 56 57 uint16_t GopPicSize; 58 59 uint8_t TargetUsage; 60 uint8_t RateControlMethod; 61 uint32_t TargetBitRate[256]; // One per temporal layer 62 uint32_t MaxBitRate; 63 uint32_t MinBitRate; 64 uint32_t InitVBVBufferFullnessInBit; 65 uint32_t VBVBufferSizeInBit; 66 67 union 68 { 69 struct 70 { 71 uint32_t ResetBRC : 1; 72 uint32_t NoFrameHeaderInsertion : 1; 73 uint32_t UseRawReconRef : 1; 74 uint32_t MBBRC : 4; 75 uint32_t bReserved : 25; 76 }; 77 uint32_t sFlags; 78 }; 79 80 uint32_t UserMaxFrameSize; 81 uint16_t AVBRAccuracy; 82 uint16_t AVBRConvergence; 83 uint16_t FramesPer100Sec[256]; // One per temporal layer 84 uint8_t NumTemporalLayersMinus1; 85 } CODEC_VP8_ENCODE_SEQUENCE_PARAMS, *PCODEC_VP8_ENCODE_SEQUENCE_PARAMS; 86 //Picture Params 87 typedef struct _CODEC_VP8_ENCODE_PIC_PARAMS 88 { 89 90 CODEC_PICTURE CurrOriginalPic; 91 CODEC_PICTURE CurrReconstructedPic; 92 CODEC_PICTURE LastRefPic; 93 CODEC_PICTURE GoldenRefPic; 94 CODEC_PICTURE AltRefPic; 95 96 union 97 { 98 uint32_t uPicFlags; 99 100 struct 101 { 102 uint32_t frame_type : 1; 103 uint32_t version : 3; 104 uint32_t show_frame : 1; 105 uint32_t color_space : 1; 106 uint32_t clamping_type : 1; 107 uint32_t segmentation_enabled : 1; 108 uint32_t update_mb_segmentation_map : 1; 109 uint32_t update_segment_feature_data : 1; 110 uint32_t filter_type : 1; 111 uint32_t loop_filter_adj_enable : 1; 112 uint32_t CodedCoeffTokenPartition : 2; 113 uint32_t refresh_golden_frame : 1; 114 uint32_t refresh_alternate_frame : 1; 115 uint32_t copy_buffer_to_golden : 2; 116 uint32_t copy_buffer_to_alternate : 2; 117 uint32_t sign_bias_golden : 1; 118 uint32_t sign_bias_alternate : 1; 119 uint32_t refresh_entropy_probs : 1; 120 uint32_t refresh_last : 1; 121 uint32_t mb_no_coeff_skip : 1; 122 uint32_t forced_lf_adjustment : 1; 123 uint32_t ref_frame_ctrl : 3; 124 uint32_t : 3; 125 }; 126 }; 127 128 char loop_filter_level[4]; 129 char ref_lf_delta[4]; 130 char mode_lf_delta[4]; 131 uint8_t sharpness_level; 132 uint32_t StatusReportFeedbackNumber; 133 uint8_t ClampQindexHigh; 134 uint8_t ClampQindexLow; 135 uint8_t temporal_id; 136 uint8_t first_ref; 137 uint8_t second_ref; 138 139 } CODEC_VP8_ENCODE_PIC_PARAMS, *PCODEC_VP8_ENCODE_PIC_PARAMS; 140 141 //Quant Data 142 typedef struct _CODEC_VP8_ENCODE_QUANT_DATA 143 { 144 uint8_t QIndex[4]; 145 char QIndexDelta[5]; 146 } CODEC_VP8_ENCODE_QUANT_DATA, *PCODEC_VP8_ENCODE_QUANT_DATA; 147 148 #endif 149