1 /*
2 * Copyright (c) 2022, 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 //!
24 //! \file     decode_scalability_singlepipe_next.h
25 //! \brief    Defines the common interface for decode scalability singlepipe mode.
26 //! \details  The decode scalability singlepipe interface is further sub-divided by codecs,
27 //!           this file is for the base interface which is shared by all codecs.
28 //!
29 
30 #ifndef __DECODE_SCALABILITY_SINGLEPIPE_NEXT_H__
31 #define __DECODE_SCALABILITY_SINGLEPIPE_NEXT_H__
32 #include "mos_defs.h"
33 #include "mos_os.h"
34 #include "codec_hw_next.h"
35 #include "media_scalability_singlepipe_next.h"
36 #include "decode_scalability_option.h"
37 
38 namespace decode
39 {
40 
41 class DecodeScalabilitySinglePipeNext: public MediaScalabilitySinglePipeNext
42 {
43 public:
44     //!
45     //! \brief  decode scalability singlepipe constructor
46     //! \param  [in] hwInterface
47     //!         Pointer to HwInterface
48     //! \param  [in] mediaContext
49     //!         Pointer to MediaContext
50     //! \param  [in] componentType
51     //!         Component type
52     //!
53     DecodeScalabilitySinglePipeNext(void *hwInterface, MediaContext *mediaContext, uint8_t componentType);
54 
55     //!
56     //! \brief  decode scalability singlepipe destructor
57     //!
~DecodeScalabilitySinglePipeNext()58     virtual ~DecodeScalabilitySinglePipeNext(){};
59 
60     //!
61     //! \brief    Copy constructor
62     //!
63     DecodeScalabilitySinglePipeNext(const DecodeScalabilitySinglePipeNext &) = delete;
64 
65     //!
66     //! \brief    Copy assignment operator
67     //!
68     DecodeScalabilitySinglePipeNext &operator=(const DecodeScalabilitySinglePipeNext &) = delete;
69 
70     //!
71     //! \brief   Initialize the decode single scalability
72     //! \details It will prepare the resources needed in scalability
73     //!          and initialize the state of scalability
74     //! \param   [in] option
75     //!          Input scalability option
76     //! \return  MOS_STATUS
77     //!          MOS_STATUS_SUCCESS if success, else fail reason
78     //!
79     virtual MOS_STATUS Initialize(const MediaScalabilityOption &option) override;
80 
81     //!
82     //! \brief  Update the media scalability singlepipe mode state
83     //! \param  [in] statePars
84     //!         parameters to update the state
85     //! \return MOS_STATUS
86     //!         MOS_STATUS_SUCCESS if success, else fail reason
87     //!
88     virtual MOS_STATUS UpdateState(void *statePars) override;
89 
90     //!
91     //! \brief  Verify command buffer
92     //! \param  [in] requestedSize
93     //!         requested size for command buffer
94     //! \param  [in] requestedPatchListSize
95     //!         requested size for patched list
96     //! \param  [out] singleTaskPhaseSupportedInPak
97     //!         Inidcate if to use single task phase in pak.
98     //! \return MOS_STATUS
99     //!         MOS_STATUS_SUCCESS if success, else fail reason
100     //!
101     virtual MOS_STATUS VerifyCmdBuffer(uint32_t requestedSize,
102                 uint32_t requestedPatchListSize,
103                 bool &singleTaskPhaseSupportedInPak)  override;
104     //!
105     //! \brief  Create decode single pipe
106     //! \param  [in] hwInterface
107     //!         void type hw interface
108     //! \param  [in] mediaContext
109     //!         required media context to create single pipe
110     //! \param  [in] componentType
111     //!         Inidcate component.
112     //! \return MOS_STATUS
113     //!         MOS_STATUS_SUCCESS if success, else fail reason
114     //!
115     static MOS_STATUS  CreateDecodeSinglePipe(void *hwInterface, MediaContext *mediaContext, uint8_t componentType);
116 
117 protected:
118     //!
119     //! \brief  Verify command buffer size and patch list size, reallocate if required
120     //! \return MOS_STATUS
121     //!         MOS_STATUS_SUCCESS if success, else fail reason
122     //!
123     virtual MOS_STATUS VerifySpaceAvailable(uint32_t requestedSize,
124                 uint32_t requestedPatchListSize,
125                 bool &singleTaskPhaseSupportedInPak) override;
126 
127     //!
128     //! \brief    Resizes the cmd buffer and patch list with cmd buffer header
129     //!
130     //! \param    [in] requestedCommandBufferSize
131     //!           Requested resize command buffer size
132     //! \param    [in] requestedPatchListSize
133     //!           Requested resize patchlist size
134     //!
135     //! \return   MOS_STATUS
136     //!           MOS_STATUS_SUCCESS if success, else fail reason
137     //!
138     virtual MOS_STATUS ResizeCommandBufferAndPatchList(
139         uint32_t                    requestedCommandBufferSize,
140         uint32_t                    requestedPatchListSize) override;
141 
142     virtual MOS_STATUS SendAttrWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested) override;
143 
144 private:
145     CodechalHwInterfaceNext *m_hwInterface = nullptr;
146 
147 MEDIA_CLASS_DEFINE_END(decode__DecodeScalabilitySinglePipeNext)
148 };
149 
150 }
151 #endif // !__MEDIA_SCALABILITY_SINGLEPIPE_NEXT_H__
152 
153