1 /*
2 * Copyright (c) 2017, 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     media_ddi_encode_fei_avc.h
24 //! \brief    Defines class for DDI media avc fei encode
25 //!
26 
27 #ifndef __MEDIA_DDI_ENCODE_FEI_AVC_H__
28 #define __MEDIA_DDI_ENCODE_FEI_AVC_H__
29 
30 #include "media_ddi_encode_avc.h"
31 
32 //!
33 //! \class  DdiEncodeAvcFei
34 //! \brief  Ddi encode AVC FEI
35 //!
36 class DdiEncodeAvcFei : public DdiEncodeAvc
37 {
38 public:
39     //!
40     //! \brief   Constructor
41     //!
DdiEncodeAvcFei()42     DdiEncodeAvcFei() {}
43 
44     //!
45     //! \brief   Destructor
46     //!
47     virtual ~DdiEncodeAvcFei();
48 
49     virtual VAStatus ContextInitialize(CodechalSetting * codecHalSettings);
50 
51     virtual VAStatus EncodeInCodecHal(uint32_t numSlices);
52 
53     virtual VAStatus ResetAtFrameLevel();
54 
55     virtual VAStatus RenderPicture(
56         VADriverContextP ctx,
57         VAContextID      context,
58         VABufferID       *buffers,
59         int32_t          numBuffers);
60 
61     //!
62     //! \brief    Add ENC output buffer information
63     //! \details  Add ENC output buffer information to
64     //!           status report queue. This function will
65     //!           be invoked at RenderPicture
66     //!
67     //! \param    [in] encBuf
68     //!           Pointer to ENC mv output buffer
69     //! \param    [in] typeIdx
70     //!           DDI_ENCODE_FEI_ENC_BUFFER_TYPE
71     //!
72     //! \return   VAStatus
73     //!           VA_STATUS_SUCCESS if successful, else fail reason
74     //!
75     VAStatus AddToEncStatusReportQueue(
76         void                           *encBuf,
77         DDI_ENCODE_FEI_ENC_BUFFER_TYPE typeIdx);
78 
79     //!
80     //! \brief    Update position
81     //! \details  Update position after add ENC output buffer
82     //!           to status report queue. This function will be
83     //!           invoked at RenderPicture
84     //!
85     //! \return   VAStatus
86     //!           VA_STATUS_SUCCESS if successful, else fail reason
87     //!
88     VAStatus AddToEncStatusReportQueueUpdatePos();
89 
90     //!
91     //! \brief    Add preenc output buffer info to status report queue
92     //! \details  Add preenc output buffer info to status report queue,
93     //!           this function will be invoked at RenderPicture
94     //!
95     //! \param    [in] preEncBuf
96     //!           Pointer to PreEnc mv buffer
97     //! \param    [in] typeIdx
98     //!           DDI_ENCODE_PRE_ENC_BUFFER_TYPE
99     //!
100     //! \return   VAStatus
101     //!           VA_STATUS_SUCCESS if successful, else fail reason
102     //!
103     VAStatus AddToPreEncStatusReportQueue(
104         void                           *preEncBuf,
105         DDI_ENCODE_PRE_ENC_BUFFER_TYPE typeIdx);
106 
107     //!
108     //! \brief    Update position
109     //! \details  Update position after add preenc buffer to
110     //!           status report queue, this funciton will be
111     //!           invoked at RenderPicture
112     //!
113     //! \return   VAStatus
114     //!           VA_STATUS_SUCCESS if successful, else fail reason
115     //!
116     VAStatus AddToPreEncStatusReportQueueUpdatePos();
117 
118     //!
119     //! \brief    Parse FEI picture parameters
120     //! \details  Parse FEI picture parameters
121     //!
122     //! \param    [in] data
123     //!           Pointer to buffer VAEncMiscParameterFEIFrameControlH264Intel
124     //!
125     //! \return   VAStatus
126     //!           VA_STATUS_SUCCESS if successful, else fail reason
127     //!
128     VAStatus ParseMiscParamFeiPic(void *data);
129 
130     virtual VAStatus ParseMiscParams(void *ptr);
131 
132     //!
133     //! \brief    Parse statistics data to preenc parameters
134     //! \details  Parse statistics data to preenc parameters
135     //!
136     //! \param    [in] mediaCtx
137     //!           Pointer to DDI_MEDIA_CONTEXT
138     //! \param    [in] ptr
139     //!           Pointer to buffer VAStatsStatisticsParameter16x16Intel
140     //! \return   VAStatus
141     //!           VA_STATUS_SUCCESS if successful, else fail reason
142     //!
143     VAStatus ParseStatsParams(
144         DDI_MEDIA_CONTEXT *mediaCtx,
145         void              *ptr);
146 
147 private:
148     //! \brief H.264 Inverse Quantization Matrix Buffer.
149     PCODEC_AVC_IQ_MATRIX_PARAMS iqMatrixParams = nullptr;
150 
151     //! \brief H.264 Inverse Quantization Weight Scale.
152     PCODEC_AVC_ENCODE_IQ_WEIGTHSCALE_LISTS iqWeightScaleLists = nullptr;
153 };
154 #endif /* __MEDIA_DDI_ENCODE_FEI_AVC_H__ */
155