1 /*
2 * Copyright (c) 2018, 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_hevc_vdenc_huc_forceqp.h
24 //! \brief    Defines of the HUC ForceQP of HEVC VDENC
25 //!
26 
27 #ifndef __CODECHAL_HEVC_VDENC_ROI_HUC_FORCEQP_H__
28 #define __CODECHAL_HEVC_VDENC_ROI_HUC_FORCEQP_H__
29 
30 #include "encode_hevc_vdenc_roi_strategy.h"
31 
32 namespace encode
33 {
34 
35 class HucForceQpROI : public RoiStrategy
36 {
37 public:
38     HucForceQpROI(
39         EncodeAllocator *allocator,
40         MediaFeatureManager *featureManager,
41         PMOS_INTERFACE osInterface);
42 
~HucForceQpROI()43     virtual ~HucForceQpROI() {}
44 
45     //!
46     //! \brief    Setup the ROI regione
47     //!
48     //! \param    [in] overlap
49     //!           Overlap between ROI and dirty ROI
50     //! \return   MOS_STATUS
51     //!           MOS_STATUS_SUCCESS if success, else fail reason
52     //!
53     virtual MOS_STATUS SetupRoi(RoiOverlap &overlap) override;
54 
55     //!
56     //! \brief    Set VDENC_PIPE_BUF_ADDR parameters
57     //!
58     //! \param    [in] streamIn
59     //!           Stream in buffer
60     //! \param    [out] PipeBufAddrParams
61     //!           Pipe buf addr parameters
62     //!
63     //! \return   void
64     //!
SetVdencPipeBufAddrParams(PMOS_RESOURCE streamin,MHW_VDBOX_PIPE_BUF_ADDR_PARAMS & pipeBufAddrParams)65     void SetVdencPipeBufAddrParams(PMOS_RESOURCE streamin,
66         MHW_VDBOX_PIPE_BUF_ADDR_PARAMS &pipeBufAddrParams) override
67     {
68         pipeBufAddrParams.presVdencStreamInBuffer = m_hucRoiOutput;
69         return;
70     }
71 
GetStreamInBuf()72     PMOS_RESOURCE GetStreamInBuf() const override { return m_hucRoiOutput; }
73 
74     //!
75     //! \brief    Setup HuC BRC init/reset parameters
76     //!
77     //! \param    [out] hucVdencBrcInitDmem
78     //!           pointer of PCODECHAL_VDENC_HEVC_HUC_BRC_INIT_DMEM_G12
79     //! \return   MOS_STATUS
80     //!           MOS_STATUS_SUCCESS if success, else fail reason
81     //!
SetDmemHuCBrcInitReset(VdencHevcHucBrcInitDmem * hucVdencBrcInitDmem)82     MOS_STATUS SetDmemHuCBrcInitReset(
83         VdencHevcHucBrcInitDmem *hucVdencBrcInitDmem) override
84     {
85         ENCODE_CHK_NULL_RETURN(hucVdencBrcInitDmem);
86 
87         hucVdencBrcInitDmem->StreamInROIEnable_U8     = 1;
88         hucVdencBrcInitDmem->StreamInSurfaceEnable_U8 = 1;
89         return MOS_STATUS_SUCCESS;
90     }
91 
92 private:
93     static constexpr uint32_t m_roiStreamInBufferSize =
94         65536 * CODECHAL_CACHELINE_SIZE; //!< ROI Streamin buffer size (part of BRC Update)
95 
96     static constexpr uint32_t m_deltaQpBufferSize = 65536;
97 
98 
99     uint32_t m_deltaQpRoiBufferSize = m_deltaQpBufferSize; //!< VDEnc DeltaQp for ROI buffer size
100     uint32_t m_HucForceQpROIBufferSize = m_roiStreamInBufferSize; //!< BRC ROI input buffer size
101 
102     MOS_RESOURCE *m_deltaQpBuffer = nullptr;
103     MOS_RESOURCE *m_hucRoiOutput = nullptr;
104 
105 MEDIA_CLASS_DEFINE_END(encode__HucForceQpROI)
106 };
107 
108 }  // namespace encode
109 #endif  //<! __CODECHAL_HEVC_VDENC_ROI_HUC_FORCEQP_H__