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_av1_vdenc_lpla_enc.h 24 //! \brief Defines for encode av1 lowpower lookahead(Encode Pass) feature 25 //! 26 27 #ifndef __ENCODE_AV1_VDENC_LPLA_ENC_H__ 28 #define __ENCODE_AV1_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_av1_brc_update_packet.h" 35 #include "encode_av1_brc_init_packet.h" 36 #include "encode_lpla.h" 37 38 namespace encode 39 { 40 class AV1VdencLplaEnc : public MediaFeature, public mhw::vdbox::huc::Itf::ParSetting 41 { 42 public: 43 AV1VdencLplaEnc( 44 MediaFeatureManager *featureManager, 45 EncodeAllocator *allocator, 46 CodechalHwInterfaceNext *hwInterface, 47 void *constSettings); 48 49 virtual ~AV1VdencLplaEnc(); 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) override; 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) override; 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 MHW_SETPAR_DECL_HDR(HUC_DMEM_STATE); 80 81 protected: 82 CODEC_AV1_ENCODE_SEQUENCE_PARAMS *m_av1SeqParams = nullptr; //!< Pointer to sequence parameter 83 CODEC_AV1_ENCODE_PICTURE_PARAMS *m_av1PicParams = nullptr; //!< Pointer to picture parameter 84 85 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 86 mutable bool m_initDeltaQP = true; //!< Initial delta QP 87 mutable uint32_t m_prevQpModulationStrength = 0; //!< Previous QP Modulation strength 88 uint32_t m_prevTargetFrameSize = 0; //!< Target frame size of previous frame. 89 uint32_t m_averageFrameSize = 0; //!< Average frame size based on targed bitrate and frame rate, in unit of bits 90 EncodeLPLA * m_lplaHelper = nullptr; //!< Lookahead helper 91 92 EncodeAllocator *m_allocator = nullptr; 93 94 MEDIA_CLASS_DEFINE_END(encode__AV1VdencLplaEnc) 95 }; 96 } // encode 97 98 #endif 99