1 /*
2 * Copyright (c) 2020-2023, 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     encode_avc_vdenc_const_settings.h
24 //! \brief    Defines the common interface for avc vdenc const settings
25 //! \details  The default setting is further sub-divided by platform type
26 //!           this file is for the base interface which is shared by all components.
27 //!
28 #ifndef __ENCODE_AVC_VDENC_CONST_SETTINGS_H__
29 #define __ENCODE_AVC_VDENC_CONST_SETTINGS_H__
30 
31 #include "codec_def_common_encode.h"
32 #include "codec_def_encode_avc.h"
33 #include "encode_const_settings.h"
34 #include "media_class_trace.h"
35 #include "media_feature_const_settings.h"
36 #include "mos_defs.h"
37 #include <stdint.h>
38 #if _ENCODE_RESERVED
39 #include "encode_avc_vdenc_const_settings_ext.h"
40 #endif // _ENCODE_RESERVED
41 
42 namespace encode
43 {
44 
45 struct AvcVdencCMD3ConstSettings
46 {
47     static const uint8_t  AvcVdencCMD3ConstSettings_0[8][52];
48     static const uint8_t  AvcVdencCMD3ConstSettings_1[3][12];
49     static const uint8_t  AvcVdencCMD3ConstSettings_2[3][13];
50     static const uint8_t  AvcVdencCMD3ConstSettings_3[3][52];
51     static const uint8_t  AvcVdencCMD3ConstSettings_4[52];
52     static const uint16_t AvcVdencCMD3ConstSettings_5[4][2][40];
53     static const uint16_t AvcVdencCMD3ConstSettings_6[4][2][40];
54     static const uint16_t par31Table[2][3][2][52];
55     static const uint16_t par32Table[2][3][2][52];
56 };
57 
58 struct AvcVdencBrcSettings
59 {
60     uint32_t  vdencBrcPakStatsBufferSize;
61     uint32_t  vdencBrcStatsBufferSize;
62     uint32_t  vdencBrcDbgBufferSize;
63     uint32_t  vdencBrcHistoryBufferSize;
64 
65     uint32_t  vdboxHucVdencBrcInitKernelDescriptor;        //!< Huc Vdenc Brc init kernel descriptor
66     uint32_t  vdboxHucVdencBrcUpdateKernelDescriptor;      //!< Huc Vdenc Brc update kernel descriptor
67 
68     double   *BRC_DevThreshI0_FP_NEG;                      //!< Negative BRC threshold for I frame
69     double   *BRC_DevThreshI0_FP_POS;                      //!< Positive BRC threshold for I frame
70     double   *BRC_DevThreshPB0_FP_NEG;                     //!< Negative BRC threshold for P/B frame
71     double   *BRC_DevThreshPB0_FP_POS;                     //!< Positive BRC threshold for P/B frame
72     double   *BRC_DevThreshVBR0_NEG;                       //!< Negative BRC threshold for VBR mode
73     double   *BRC_DevThreshVBR0_POS;                       //!< Positive BRC threshold for VBR mode
74 
75     int8_t   *BRC_LowDelay_DevThreshPB0_S8;                //!< Low Delay BRC threshold for P/B frame
76     int8_t   *BRC_LowDelay_DevThreshI0_S8;                 //!< Low Delay BRC threshold for I frame
77     int8_t   *BRC_LowDelay_DevThreshVBR0_S8;               //!< Low Delay BRC threshold for VBR Mode
78 
79     int8_t   *BRC_INIT_DistQPDelta_I8;                     //!< Distortion QP Delta
80     uint8_t  *BRC_EstRateThreshP0_U8;                      //!< Estimate Rate Thresh of P frame
81     uint8_t  *BRC_EstRateThreshI0_U8;                      //!< Estimate Rate Thresh of I frame
82 
83     int8_t   *brcInitDistQpDeltaI8;
84     int8_t   *brcInitDistQpDeltaI8LowDelay;
85 
86     uint16_t *BRC_UPD_start_global_adjust_frame;           //!< Start Global Adjust Frame
87     uint8_t  *BRC_UPD_global_rate_ratio_threshold;         //!< Global Rate Ratio Threshold
88     uint8_t  *BRC_UPD_slwin_global_rate_ratio_threshold;   //!< Slide Window Global Rate Ratio Threshold
89     uint8_t  *BRC_UPD_start_global_adjust_mult;            //!< Start Global Adjust Multiply
90     uint8_t  *BRC_UPD_start_global_adjust_div;             //!< Start Global Adjust Division
91     int8_t   *BRC_UPD_global_rate_ratio_threshold_qp;      //!< Global Rate Ratio QP Threshold
92 
93     int8_t   *BRC_UPD_GlobalRateQPAdjTabI_U8;              //!< I Picture Global Rate QP Adjustment Table.
94     int8_t   *BRC_UPD_GlobalRateQPAdjTabP_U8;              //!< P Picture Global Rate QP Adjustment Table.
95     int8_t   *BRC_UPD_SlWinGlobalRateQPAdjTabP_U8;         //!< P picture Global Rate QP Adjustment Table for Sliding Window BRC
96     int8_t   *BRC_UPD_GlobalRateQPAdjTabB_U8;              //!< B Picture Global Rate QP Adjustment Table.
97     uint8_t  *BRC_UPD_DistThreshldI_U8;                    //!< I Picture Distortion THreshold.
98     uint8_t  *BRC_UPD_DistThreshldP_U8;                    //!< P Picture Distortion THreshold.
99     uint8_t  *BRC_UPD_DistThreshldB_U8;                    //!< B Picture Distortion THreshold.
100     int8_t   *CBR_UPD_DistQPAdjTabI_U8;                    //!< I Picture Distortion QP Adjustment Table under CBR Mode.
101     int8_t   *CBR_UPD_DistQPAdjTabP_U8;                    //!< P Picture Distortion QP Adjustment Table under CBR Mode.
102     int8_t   *CBR_UPD_DistQPAdjTabB_U8;                    //!< B Picture Distortion QP Adjustment Table under CBR Mode.
103     int8_t   *VBR_UPD_DistQPAdjTabI_U8;                    //!< I Picture Distortion QP Adjustment Table under VBR Mode.
104     int8_t   *VBR_UPD_DistQPAdjTabP_U8;                    //!< P Picture Distortion QP Adjustment Table under VBR Mode.
105     int8_t   *VBR_UPD_DistQPAdjTabB_U8;                    //!< B Picture Distortion QP Adjustment Table under VBR Mode.
106     int8_t   *CBR_UPD_FrmSzAdjTabI_S8;                     //!< I Picture Frame Size Adjustment Table under CBR Mode.
107     int8_t   *CBR_UPD_FrmSzAdjTabP_S8;                     //!< P Picture Frame Size Adjustment Table under CBR Mode.
108     int8_t   *CBR_UPD_FrmSzAdjTabB_S8;                     //!< B Picture Frame Size Adjustment Table under CBR Mode.
109     int8_t   *VBR_UPD_FrmSzAdjTabI_S8;                     //!< I Picture Frame Size Adjustment Table under VBR Mode.
110     int8_t   *VBR_UPD_FrmSzAdjTabP_S8;                     //!< P Picture Frame Size Adjustment Table under VBR Mode.
111     int8_t   *VBR_UPD_FrmSzAdjTabB_S8;                     //!< B Picture Frame Size Adjustment Table under VBR Mode.
112     int8_t   *QVBR_UPD_FrmSzAdjTabP_S8;                    //!< P Picture Frame Size Adjustment Table under QVBR Mode.
113     int8_t   *LOW_DELAY_UPD_FrmSzAdjTabI_S8;               //!< I Picture Frame Size Adjustment Table under Low Delay Mode.
114     int8_t   *LOW_DELAY_UPD_FrmSzAdjTabP_S8;               //!< P Picture Frame Size Adjustment Table under Low Delay Mode.
115     int8_t   *LOW_DELAY_UPD_FrmSzAdjTabB_S8;               //!< B Picture Frame Size Adjustment Table under Low Delay Mode.
116     uint8_t  *BRC_UPD_FrmSzMinTabP_U8;                     //!< I Picture Minimum Frame Size Table.
117     uint8_t  *BRC_UPD_FrmSzMinTabI_U8;                     //!< P Picture Minimum Frame Size Table.
118     uint8_t  *BRC_UPD_FrmSzMaxTabP_U8;                     //!< I Picture Maximum Frame Size Table.
119     uint8_t  *BRC_UPD_FrmSzMaxTabI_U8;                     //!< P Picture Maximum Frame Size Table.
120     uint8_t  *BRC_UPD_FrmSzSCGTabP_U8;                     //!<
121     uint8_t  *BRC_UPD_FrmSzSCGTabI_U8;                     //!<
122 
123     uint8_t  *BRC_UPD_I_IntraNonPred;                      //!< Cost Table for Intra Non-Prediction
124     uint8_t  *BRC_UPD_I_Intra8x8;                          //!< Cost Table for Intra 8x8
125     uint8_t  *BRC_UPD_I_Intra4x4;                          //!< Cost Table for Intra 4x4
126     uint8_t  *BRC_UPD_P_IntraNonPred;                      //!< Cost Table for Intra Non-Prediction
127     uint8_t  *BRC_UPD_P_Intra16x16;                        //!< Cost Table for Intra 16x16
128     uint8_t  *BRC_UPD_P_Intra8x8;                          //!< Cost Table for Intra 8x8
129     uint8_t  *BRC_UPD_P_Intra4x4;                          //!< Cost Table for Intra 4x4
130     uint8_t  *BRC_UPD_P_Inter16x8;                         //!< Cost Table for Inter 16x8
131     uint8_t  *BRC_UPD_P_Inter8x8;                          //!< Cost Table for Inter 8x8
132     uint8_t  *BRC_UPD_P_Inter16x16;                        //!< Cost Table for Inter 16x16
133     uint8_t  *BRC_UPD_P_RefId;                             //!< Cost Table for Reference Index
134 };
135 
136 struct AvcVdencFeatureSettings : VdencFeatureSettings
137 {
138     uint32_t  singlePassMinFrameWidth = 0;
139     uint32_t  singlePassMinFrameHeight = 0;
140     uint32_t  singlePassMinFramePer100s = 0;
141 
142     uint32_t  interMbMaxSize = 0;
143     uint32_t  intraMbMaxSize = 0;
144 
145     bool     *perfModeEnabled = nullptr;
146 
147     uint8_t   DefaultIntraRounding     = 0;
148     uint8_t   DefaultInterRounding     = 0;
149     uint8_t   StaticIntraRounding[4]   = {};
150     uint8_t   StaticInterRounding[4]   = {};
151     const uint8_t *AdaptiveIntraRounding[4] = {nullptr, nullptr, nullptr, nullptr};
152     const uint8_t *AdaptiveInterRounding[4] = {nullptr, nullptr, nullptr, nullptr};
153 
154     uint16_t *SliceSizeThrsholdsI = nullptr;
155     uint16_t *SliceSizeThrsholdsP = nullptr;
156 
157     uint32_t *TrellisQuantizationRounding = nullptr;
158     bool     *TrellisQuantizationEnable   = nullptr;
159 
160     uint8_t  *columnScan4x4 = nullptr;
161     uint8_t  *columnScan8x8 = nullptr;
162 
163     AvcVdencCMD3ConstSettings *vdencCMD3Table = nullptr;
164     AvcVdencBrcSettings      brcSettings      = {};
165 };
166 
167 struct AvcVdencBrcConstSettings
168 {
169     static constexpr uint32_t  m_vdencBrcPakStatsBufferSize = 204;                   //!< Vdenc bitrate control PAK buffer size
170     static constexpr uint32_t  m_vdencBrcStatsBufferSize    = 80;                    //!< Vdenc bitrate control buffer size
171     static constexpr uint32_t  m_vdencBrcDbgBufferSize      = 0x1000;
172     static constexpr uint32_t  m_vdencBrcHistoryBufferSize  = 0x1000;
173     static constexpr uint32_t  m_numDevThreshlds            = 8;
174 
175     static const uint32_t m_vdboxHucVdencBrcInitKernelDescriptor = 4;                //!< Huc Vdenc Brc init kernel descriptor
176     static const uint32_t m_vdboxHucVdencBrcUpdateKernelDescriptor = 5;              //!< Huc Vdenc Brc update kernel descriptor
177 
178     static const double   m_BRC_DevThreshI0_FP_NEG[m_numDevThreshlds / 2];   //!< Negative BRC threshold for I frame
179     static const double   m_BRC_DevThreshI0_FP_POS[m_numDevThreshlds / 2];   //!< Positive BRC threshold for I frame
180     static const double   m_BRC_DevThreshPB0_FP_NEG[m_numDevThreshlds / 2];  //!< Negative BRC threshold for P/B frame
181     static const double   m_BRC_DevThreshPB0_FP_POS[m_numDevThreshlds / 2];  //!< Positive BRC threshold for P/B frame
182     static const double   m_BRC_DevThreshVBR0_NEG[m_numDevThreshlds / 2];    //!< Negative BRC threshold for VBR mode
183     static const double   m_BRC_DevThreshVBR0_POS[m_numDevThreshlds / 2];    //!< Positive BRC threshold for VBR mode
184 
185     static const int8_t   m_BRC_LowDelay_DevThreshPB0_S8[8];                         //!< Low Delay BRC threshold for P/B frame
186     static const int8_t   m_BRC_LowDelay_DevThreshI0_S8[8];                          //!< Low Delay BRC threshold for I frame
187     static const int8_t   m_BRC_LowDelay_DevThreshVBR0_S8[8];                        //!< Low Delay BRC threshold for VBR Mode
188 
189     static const int8_t   m_BRC_INIT_DistQPDelta_I8[4];                              //!< Distortion QP Delta
190     static const uint8_t  m_BRC_EstRateThreshP0_U8[7];                               //!< Estimate Rate Thresh of P frame
191     static const uint8_t  m_BRC_EstRateThreshI0_U8[7];                               //!< Estimate Rate Thresh of I frame
192 
193     static const int8_t   m_brcInitDistQpDeltaI8[4];
194     static const int8_t   m_brcInitDistQpDeltaI8LowDelay[4];
195 
196     static const uint16_t m_BRC_UPD_start_global_adjust_frame[4];                    //!< Start Global Adjust Frame
197     static const uint8_t  m_BRC_UPD_global_rate_ratio_threshold[7];                  //!< Global Rate Ratio Threshold
198     static const uint8_t  m_BRC_UPD_slwin_global_rate_ratio_threshold[7];            //!< Slide Window Global Rate Ratio Threshold
199     static const uint8_t  m_BRC_UPD_start_global_adjust_mult[5];                     //!< Start Global Adjust Multiply
200     static const uint8_t  m_BRC_UPD_start_global_adjust_div[5];                      //!< Start Global Adjust Division
201     static const int8_t   m_BRC_UPD_global_rate_ratio_threshold_qp[8];               //!< Global Rate Ratio QP Threshold
202 
203     static const int8_t   m_BRC_UPD_GlobalRateQPAdjTabI_U8[64];                      //!< I Picture Global Rate QP Adjustment Table.
204     static const int8_t   m_BRC_UPD_GlobalRateQPAdjTabP_U8[64];                      //!< P Picture Global Rate QP Adjustment Table.
205     static const int8_t   m_BRC_UPD_SlWinGlobalRateQPAdjTabP_U8[64];                 //!< P picture Global Rate QP Adjustment Table for Sliding Window BRC
206     static const int8_t   m_BRC_UPD_GlobalRateQPAdjTabB_U8[64];                      //!< B Picture Global Rate QP Adjustment Table.
207     static const uint8_t  m_BRC_UPD_DistThreshldI_U8[10];                            //!< I Picture Distortion THreshold.
208     static const uint8_t  m_BRC_UPD_DistThreshldP_U8[10];                            //!< P Picture Distortion THreshold.
209     static const uint8_t  m_BRC_UPD_DistThreshldB_U8[10];                            //!< P Picture Distortion THreshold.
210     static const int8_t   m_CBR_UPD_DistQPAdjTabI_U8[81];                            //!< I Picture Distortion QP Adjustment Table under CBR Mode.
211     static const int8_t   m_CBR_UPD_DistQPAdjTabP_U8[81];                            //!< P Picture Distortion QP Adjustment Table under CBR Mode.
212     static const int8_t   m_CBR_UPD_DistQPAdjTabB_U8[81];                            //!< B Picture Distortion QP Adjustment Table under CBR Mode.
213     static const int8_t   m_VBR_UPD_DistQPAdjTabI_U8[81];                            //!< I Picture Distortion QP Adjustment Table under VBR Mode.
214     static const int8_t   m_VBR_UPD_DistQPAdjTabP_U8[81];                            //!< P Picture Distortion QP Adjustment Table under VBR Mode.
215     static const int8_t   m_VBR_UPD_DistQPAdjTabB_U8[81];                            //!< B Picture Distortion QP Adjustment Table under VBR Mode.
216     static const int8_t   m_CBR_UPD_FrmSzAdjTabI_S8[72];                             //!< I Picture Frame Size Adjustment Table under CBR Mode.
217     static const int8_t   m_CBR_UPD_FrmSzAdjTabP_S8[72];                             //!< P Picture Frame Size Adjustment Table under CBR Mode.
218     static const int8_t   m_CBR_UPD_FrmSzAdjTabB_S8[72];                             //!< B Picture Frame Size Adjustment Table under CBR Mode.
219     static const int8_t   m_VBR_UPD_FrmSzAdjTabI_S8[72];                             //!< I Picture Frame Size Adjustment Table under VBR Mode.
220     static const int8_t   m_VBR_UPD_FrmSzAdjTabP_S8[72];                             //!< P Picture Frame Size Adjustment Table under VBR Mode.
221     static const int8_t   m_VBR_UPD_FrmSzAdjTabB_S8[72];                             //!< B Picture Frame Size Adjustment Table under VBR Mode.
222     static const int8_t   m_QVBR_UPD_FrmSzAdjTabP_S8[72];                            //!< P Picture Frame Size Adjustment Table under QVBR Mode.
223     static const int8_t   m_LOW_DELAY_UPD_FrmSzAdjTabI_S8[72];                       //!< I Picture Frame Size Adjustment Table under Low Delay Mode.
224     static const int8_t   m_LOW_DELAY_UPD_FrmSzAdjTabP_S8[72];                       //!< P Picture Frame Size Adjustment Table under Low Delay Mode.
225     static const int8_t   m_LOW_DELAY_UPD_FrmSzAdjTabB_S8[72];                       //!< B Picture Frame Size Adjustment Table under Low Delay Mode.
226     static const uint8_t  m_BRC_UPD_FrmSzMinTabP_U8[9];                              //!< I Picture Minimum Frame Size Table.
227     static const uint8_t  m_BRC_UPD_FrmSzMinTabI_U8[9];                              //!< P Picture Minimum Frame Size Table.
228     static const uint8_t  m_BRC_UPD_FrmSzMaxTabP_U8[9];                              //!< I Picture Maximum Frame Size Table.
229     static const uint8_t  m_BRC_UPD_FrmSzMaxTabI_U8[9];                              //!< P Picture Maximum Frame Size Table.
230     static const uint8_t  m_BRC_UPD_FrmSzSCGTabP_U8[9];                              //!<
231     static const uint8_t  m_BRC_UPD_FrmSzSCGTabI_U8[9];                              //!<
232 
233     static const uint8_t  m_BRC_UPD_I_IntraNonPred[42];                              //!< Cost Table for Intra Non-Prediction
234     static const uint8_t  m_BRC_UPD_I_Intra8x8[42];                                  //!< Cost Table for Intra 8x8
235     static const uint8_t  m_BRC_UPD_I_Intra4x4[42];                                  //!< Cost Table for Intra 4x4
236     static const uint8_t  m_BRC_UPD_P_IntraNonPred[42];                              //!< Cost Table for Intra Non-Prediction
237     static const uint8_t  m_BRC_UPD_P_Intra16x16[42];                                //!< Cost Table for Intra 16x16
238     static const uint8_t  m_BRC_UPD_P_Intra8x8[42];                                  //!< Cost Table for Intra 8x8
239     static const uint8_t  m_BRC_UPD_P_Intra4x4[42];                                  //!< Cost Table for Intra 4x4
240     static const uint8_t  m_BRC_UPD_P_Inter16x8[42];                                 //!< Cost Table for Inter 16x8
241     static const uint8_t  m_BRC_UPD_P_Inter8x8[42];                                  //!< Cost Table for Inter 8x8
242     static const uint8_t  m_BRC_UPD_P_Inter16x16[42];                                //!< Cost Table for Inter 16x16
243     static const uint8_t  m_BRC_UPD_P_RefId[42];                                     //!< Cost Table for Reference Index
244 };
245 
246 struct LutModeConstSettings
247 {
248     static constexpr uint32_t INTRA_NONPRED    = 0x00;
249     static constexpr uint32_t INTRA            = 0x01;
250     static constexpr uint32_t INTRA_16x16      = 0x01;
251     static constexpr uint32_t INTRA_8x8        = 0x02;
252     static constexpr uint32_t INTRA_4x4        = 0x03;
253     static constexpr uint32_t INTER_BWD        = 0x09;
254     static constexpr uint32_t REF_ID           = 0x0A;
255     static constexpr uint32_t INTRA_CHROMA     = 0x0B;
256     static constexpr uint32_t INTER            = 0x08;
257     static constexpr uint32_t INTER_16x16      = 0x08;
258     static constexpr uint32_t INTER_16x8       = 0x04;
259     static constexpr uint32_t INTER_8x16       = 0x04;
260     static constexpr uint32_t INTER_8x8q       = 0x05;
261     static constexpr uint32_t INTER_8x4q       = 0x06;
262     static constexpr uint32_t INTER_4x8q       = 0x06;
263     static constexpr uint32_t INTER_4x4q       = 0x07;
264     static constexpr uint32_t INTER_16x8_FIELD = 0x06;
265     static constexpr uint32_t INTER_8x8_FIELD  = 0x07;
266 };
267 
268 struct RdModeConstSettings
269 {
270     static constexpr uint32_t INTRA_MPM    = 0;
271     static constexpr uint32_t INTRA_16X16  = 1;
272     static constexpr uint32_t INTRA_8X8    = 2;
273     static constexpr uint32_t INTRA_4X4    = 3;
274     static constexpr uint32_t INTER_16X8   = 4;
275     static constexpr uint32_t INTER_8X8    = 5;
276     static constexpr uint32_t INTER_8X4    = 6;
277     static constexpr uint32_t INTER_16X16  = 7;
278     static constexpr uint32_t INTER_BWD    = 8;
279     static constexpr uint32_t REF_ID       = 9;
280     static constexpr uint32_t INTRA_CHROMA = 10;
281     static constexpr uint32_t SKIP_16X16   = 11;
282     static constexpr uint32_t DIRECT_16X16 = 12;
283 };
284 
285 class EncodeAvcVdencConstSettings : public VdencConstSettings
286 {
287 public:
288 
289     //!
290     //! \brief  EncodeAvcVdencConstSettings constructor
291     //!
292     EncodeAvcVdencConstSettings() = default;
293 
294     EncodeAvcVdencConstSettings(PMOS_INTERFACE osInterface);
295 
296     //!
297     //! \brief  EncodeAvcVdencConstSettings deconstructor
298     //!
~EncodeAvcVdencConstSettings()299     virtual ~EncodeAvcVdencConstSettings() {};
300 
301     //!
302     //! \brief  Prepare const settings
303     //! \return MOS_STATUS
304     //!         MOS_STATUS_SUCCESS if success, else fail reason
305     //!
306     MOS_STATUS PrepareConstSettings() override;
307 
308     MOS_STATUS Update(void *params) override;
309 
310 protected:
311 
312     //!
313     //! \brief  Prepare common settings
314     //! \return MOS_STATUS
315     //!         MOS_STATUS_SUCCESS if success, else fail reason
316     //!
317     virtual MOS_STATUS SetCommonSettings() override;
318 
319     //!
320     //! \brief  Prepare BRC related settings
321     //! \return MOS_STATUS
322     //!         MOS_STATUS_SUCCESS if success, else fail reason
323     //!
324     virtual MOS_STATUS SetBrcSettings() override;
325 
SetVdencCmd2Settings()326     MOS_STATUS SetVdencCmd2Settings() override
327     {
328         return MOS_STATUS_SUCCESS;
329     }
330 
331     virtual MOS_STATUS SetVdencCmd3Settings();
332 
SetVdencAvcImgStateSettings()333     virtual MOS_STATUS SetVdencAvcImgStateSettings()
334     {
335         return MOS_STATUS_SUCCESS;
336     }
337 
338     static constexpr uint32_t  m_singlePassMinFrameWidth   = 3840;
339     static constexpr uint32_t  m_singlePassMinFrameHeight  = 2160;
340     static constexpr uint32_t  m_singlePassMinFramePer100s = 6000;
341 
342     static constexpr uint32_t  m_interMbMaxSize            = 4095;               //! AVC inter macroblock max size
343     static constexpr uint32_t  m_intraMbMaxSize            = 2700;               //! AVC intra macroblock max size
344 
345     static const bool    m_perfModeEnabled[NUM_VDENC_TARGET_USAGE_MODES];
346 
347     static constexpr uint8_t  defIntraRounding             = 5;
348     static constexpr uint8_t  defInterRounding             = 2;
349 
350     static constexpr uint8_t  interRoundingP               = 3;
351     static constexpr uint8_t  interRoundingB               = 0;
352     static constexpr uint8_t  interRoundingBR              = 2;
353 
354     static const uint8_t adaptiveRoundingIntra_P_G1[CODEC_AVC_NUM_QP];         //!< Per-QP rounding table for Intra MBs in P frames (GOP1)
355     static const uint8_t adaptiveRoundingIntra_P[CODEC_AVC_NUM_QP];            //!< Per-QP rounding table for Intra MBs in P frames
356     static const uint8_t adaptiveRoundingIntra_B[CODEC_AVC_NUM_QP];            //!< Per-QP rounding table for Intra MBs in non-ref B frames
357     static const uint8_t adaptiveRoundingIntra_BR[CODEC_AVC_NUM_QP];           //!< Per-QP rounding table for Intra MBs in ref B frames
358     static const uint8_t adaptiveRoundingInter_P_G1[CODEC_AVC_NUM_QP];         //!< Per-QP rounding table for Inter MBs in P frames (GOP1)
359     static const uint8_t adaptiveRoundingInter_P[CODEC_AVC_NUM_QP];            //!< Per-QP rounding table for Inter MBs in P frames
360     static const uint8_t adaptiveRoundingInter_B[CODEC_AVC_NUM_QP];            //!< Per-QP rounding table for Intra MBs in non-ref B frames
361     static const uint8_t adaptiveRoundingInter_BR[CODEC_AVC_NUM_QP];           //!< Per-QP rounding table for Intra MBs in ref B frames
362 
363     static const uint16_t  m_SliceSizeThrsholdsI[CODEC_AVC_NUM_QP];              //!< I picture slice size conformance thresholds table.
364     static const uint16_t  m_SliceSizeThrsholdsP[CODEC_AVC_NUM_QP];              //!< P picture slice size conformance thresholds table.
365 
366     static const uint32_t  m_trellisQuantizationRounding[NUM_VDENC_TARGET_USAGE_MODES];
367     static const bool      m_trellisQuantizationEnable[NUM_TARGET_USAGE_MODES];
368 
369     static const uint8_t   m_columnScan4x4[16];                                  //!< AVC column scan order for 4x4 block
370     static const uint8_t   m_columnScan8x8[64];                                  //!< AVC column scan order for 8x8 block
371 
372     AvcVdencBrcConstSettings      m_brcSettings;
373     AvcVdencCMD3ConstSettings     m_CMD3Settings;
374 
375     PCODEC_AVC_ENCODE_SEQUENCE_PARAMS m_avcSeqParams   = nullptr;
376     PCODEC_AVC_ENCODE_PIC_PARAMS      m_avcPicParams   = nullptr;
377     PCODEC_AVC_ENCODE_SLICE_PARAMS    m_avcSliceParams = nullptr;
378 
379     int32_t m_qp                   = 0;
380 
381 MEDIA_CLASS_DEFINE_END(encode__EncodeAvcVdencConstSettings)
382 };
383 
384 }
385 #endif // !__ENCODE_AVC_VDENC_CONST_SETTINGS_H__
386