1 /*
2 * Copyright (c) 2020, 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_fullenc.h
24 //! \brief    Defines for vdenc full-enc feature
25 //!
26 #ifndef __HEVC_VDENC_FULL_ENC_H__
27 #define __HEVC_VDENC_FULL_ENC_H__
28 
29 #include "media_feature.h"
30 #include "encode_allocator.h"
31 #include "mhw_vdbox_vdenc_itf.h"
32 #include "encode_hevc_vdenc_feature_manager.h"
33 #include "encode_hevc_vdenc_preenc.h"
34 
35 namespace encode
36 {
37     class HevcVdencFullEnc : public MediaFeature, public mhw::vdbox::vdenc::Itf::ParSetting
38     {
39 #undef MAX
40 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
41         enum EncodeFullencDef0
42         {
43             SINGLE_PASS_ENC = 0,
44             PRE_ENC_PASS,
45             FULL_ENC_PASS
46         };
47 
48         typedef struct mfxI16PAIR
49         {
50             short x, y;  // integer pair
51         } mfxI16PAIR;
52 
53         typedef mfxI16PAIR I16PAIR;
54 
55         struct EncodeFullencDef1
56         {
57             I16PAIR  mv;
58             uint16_t intraSAD;
59             uint16_t interSAD;
60         };
61 
62     public:
63         HevcVdencFullEnc(
64             MediaFeatureManager *featureManager,
65             EncodeAllocator *allocator,
66             CodechalHwInterfaceNext *hwInterface,
67             void *constSettings);
68 
69         virtual ~HevcVdencFullEnc();
70 
71         //!
72         //! \brief  Init full-enc basic features related parameter
73         //!
74         //! \param  [in] settings
75         //!         Pointer to settings
76         //!
77         //! \return MOS_STATUS
78         //!         MOS_STATUS_SUCCESS if success, else fail reason
79         //!
80         MOS_STATUS Init(void *settings) override;
81 
82         //!
83         //! \brief  Update full-enc features related parameter
84         //!
85         //! \param  [in] params
86         //!         Pointer to parameters
87         //!
88         //! \return MOS_STATUS
89         //!         MOS_STATUS_SUCCESS if success, else fail reason
90         //!
91         MOS_STATUS Update(void *params) override;
92 #if USE_CODECHAL_DEBUG_TOOL
93         MOS_STATUS EncodeFullencFuntion0();
94 #endif
95         MHW_SETPAR_DECL_HDR(VDENC_PIPE_MODE_SELECT);
96 
97         MHW_SETPAR_DECL_HDR(VDENC_PIPE_BUF_ADDR_STATE);
98 
99     protected:
100         PMOS_INTERFACE      m_osInterface    = nullptr;           //!< Os Inteface
101         EncodeBasicFeature  *m_basicFeature  = nullptr;         //!< EncodeBasicFeature
102         HevcVdencPreEnc     *m_preEncFeature = nullptr;
103 
104         PMOS_RESOURCE       EncodeFullencMember0 = nullptr;
105         PMOS_RESOURCE       EncodeFullencMember1 = nullptr;
106 
107         uint32_t m_encodeMode = 0;
108 
109         uint8_t  EncodeFullencMember2 = 0;  //0:32x32, 1:16x16, 2:8x8
110         uint8_t  EncodeFullencMember3 = 0;
111         uint8_t  EncodeFullencMember4 = 0;
112         uint32_t EncodeFullencMember5 = 0;
113 
114         EncodeAllocator *m_allocator = nullptr;
115 
116         MOS_STATUS UpdateTrackedBufferParameters();
117         MOS_STATUS UpdatePreEncSize();
118 
119 #if USE_CODECHAL_DEBUG_TOOL
120         FILE *pfile0 = nullptr;
121         FILE *pfile1 = nullptr;
122 #endif
123     MEDIA_CLASS_DEFINE_END(encode__HevcVdencFullEnc)
124     };
125 
126 }  // namespace encode
127 
128 #endif  // !__HEVC_VDENC_FULL_ENC_H__
129 
130