1 /* 2 * Copyright (c) 2021, 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_vdenc_lpla_analysis.h 24 //! \brief Defines for encode hevc lowpower lookahead(Encode Pass) feature 25 //! 26 27 #ifndef __ENCODE_HEVC_VDENC_LPLA_ENC_H__ 28 #define __ENCODE_HEVC_VDENC_LPLA_ENC_H__ 29 30 #include "media_feature.h" 31 #include "encode_allocator.h" 32 #include "encode_basic_feature.h" 33 #include "encode_pipeline.h" 34 #include "encode_huc_brc_update_packet.h" 35 #include "encode_huc_brc_init_packet.h" 36 #include "encode_lpla.h" 37 38 namespace encode 39 { 40 class HEVCVdencLplaEnc : public MediaFeature 41 { 42 public: 43 HEVCVdencLplaEnc( 44 MediaFeatureManager *featureManager, 45 EncodeAllocator *allocator, 46 CodechalHwInterfaceNext *hwInterface, 47 void *constSettings); 48 49 virtual ~HEVCVdencLplaEnc(); 50 51 //! 52 //! \brief Init lpla encode pass features related parameter 53 //! \param [in] settings 54 //! Pointer to settings 55 //! \return MOS_STATUS 56 //! MOS_STATUS_SUCCESS if success, else fail reason 57 //! 58 MOS_STATUS Init(void *settings); 59 60 //! 61 //! \brief Update cqp basic features related parameter 62 //! \param [in] params 63 //! Pointer to parameters 64 //! \return MOS_STATUS 65 //! MOS_STATUS_SUCCESS if success, else fail reason 66 //! 67 MOS_STATUS Update(void *params); 68 69 //! 70 //! \brief Setup/configure encoder based on sequence parameter set 71 //! \details It is invoked when the encoder receives a new sequence parameter set and it would 72 //! set up and configure the encoder state that used for the sequence 73 //! 74 //! \return MOS_STATUS 75 //! MOS_STATUS_SUCCESS if success, else fail reason 76 //! 77 MOS_STATUS SetSequenceStructs(); 78 79 //! 80 //! \brief Setup/configure encoder based on picture parameter set 81 //! \details It is invoked for every picture and it would set up and configure the 82 // encoder state that used for current picture 83 //! 84 //! \return MOS_STATUS 85 //! MOS_STATUS_SUCCESS if success, else fail reason 86 //! 87 MOS_STATUS SetPictureStructs(); 88 89 MOS_STATUS SetHucBrcUpdateExtBuffer( 90 VdencHevcHucBrcUpdateDmem *hucVdencBrcUpdateDmem, 91 bool isLastPass); 92 93 MOS_STATUS SetDmemForInit(VdencHevcHucBrcInitDmem *hucVdencBrcInitDmem); 94 95 protected: 96 CODEC_HEVC_ENCODE_SEQUENCE_PARAMS *m_hevcSeqParams = nullptr; //!< Pointer to sequence parameter 97 CODEC_HEVC_ENCODE_PICTURE_PARAMS *m_hevcPicParams = nullptr; //!< Pointer to picture parameter 98 99 uint32_t m_targetBufferFulness = 0; //!< Target encode buffer fulness in bits, used by BRC and calculated from initial buffer fulness, target frame size (from DDI) and average frame size 100 bool m_initDeltaQP = true; //!< Initial delta QP 101 uint32_t m_prevQpModulationStrength = 0; //!< Previous QP Modulation strength 102 uint32_t m_prevTargetFrameSize = 0; //!< Target frame size of previous frame. 103 uint32_t m_averageFrameSize = 0; //!< Average frame size based on targed bitrate and frame rate, in unit of bits 104 EncodeLPLA * m_lplaHelper = nullptr; //!< Lookahead helper 105 106 MEDIA_CLASS_DEFINE_END(encode__HEVCVdencLplaEnc) 107 }; 108 } // encode 109 110 #endif 111