1 /*
2 * Copyright (c) 2020-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 //!
24 //! \file     decode_hevc_downsampling_packet.h
25 //! \brief    Defines the common interface for Hevc deocde down sampling sub packet
26 //! \details  The Hevc decode down sampling sub packet interface is unified interface
27 //!           for down sampling function, used by main packet on demand.
28 //!
29 
30 #ifndef __DECODE_HEVC_DOWNSAMPLING_PACKET_H__
31 #define __DECODE_HEVC_DOWNSAMPLING_PACKET_H__
32 
33 #include "decode_downsampling_packet.h"
34 #include "decode_hevc_pipeline.h"
35 
36 #ifdef _DECODE_PROCESSING_SUPPORTED
37 
38 namespace decode
39 {
40 
41 class HevcDownSamplingPkt : public DecodeDownSamplingPkt
42 {
43 public:
44     //!
45     //! \brief  Decode down sampling sub packet constructor
46     //!
47     HevcDownSamplingPkt(DecodePipeline *pipeline, CodechalHwInterfaceNext *hwInterface);
48 
~HevcDownSamplingPkt()49     virtual ~HevcDownSamplingPkt() {}
50 
51     //!
52     //! \brief  Initialize the Hevc down sampling sub packet
53     //! \return MOS_STATUS
54     //!         MOS_STATUS_SUCCESS if success, else fail reason
55     //!
56     virtual MOS_STATUS Init() override;
57 
58 protected:
59     virtual MOS_STATUS InitSfcParams(VDBOX_SFC_PARAMS &sfcParams) override;
60     virtual MOS_STATUS InitSfcScalabParams(SCALABILITY_PARAMS &scalabilityParams);
61 
62     //!
63     //! \brief  Initialize SFC scalability source params for current pipe
64     //! \param  [in] hevcPipeline
65     //!         Hevc pipeline
66     //! \param  [in] hevcBasicFeature
67     //!         Hevc basic feature
68     //! \param  [out] scalabilityParams
69     //!         Scalability parames
70     //! \param  [out] tileColIndex
71     //!         Tile coloumn index
72     //! \param  [out] tileColCount
73     //!         Tile coloumn count
74     //! \return MOS_STATUS
75     //!         MOS_STATUS_SUCCESS if success, else fail reason
76     //!
77     virtual MOS_STATUS InitSfcScalabSrcParams(
78         HevcPipeline &hevcPipeline, HevcBasicFeature &hevcBasicFeature,
79         SCALABILITY_PARAMS &scalabilityParams, uint32_t &tileColIndex, uint32_t &tileColCount);
80     //!
81     //! \brief  Initialize SFC scalability destination params for current pipe
82     //! \param  [in] hevcPipeline
83     //!         Hevc pipeline
84     //! \param  [in] hevcBasicFeature
85     //!         Hevc basic feature
86     //! \param  [out] scalabilityParams
87     //!         Scalability parames
88     //! \param  [in] tileColIndex
89     //!         Tile coloumn index
90     //! \param  [in] tileColCount
91     //!         Tile coloumn count
92     //! \return MOS_STATUS
93     //!         MOS_STATUS_SUCCESS if success, else fail reason
94     //!
95     virtual MOS_STATUS InitSfcScalabDstParams(
96         HevcPipeline &hevcPipeline, HevcBasicFeature &hevcBasicFeature,
97         SCALABILITY_PARAMS &scalabilityParams, const uint32_t &tileColIndex, const uint32_t &tileColCount);
98 
99     virtual MOS_STATUS SetSfcMode(MEDIA_SFC_INTERFACE_MODE &mode) override;
100 
101     static constexpr uint32_t m_ildbXOffset      = 5;
102     static constexpr uint32_t m_tileOffsetXBasic = 8;
103     static constexpr uint32_t m_tileOffsetX444   = 3;
104     static constexpr uint32_t m_betaPrecision    = 5;
105     static constexpr uint32_t m_oneBySfFractionPrecision = 19;
106 
107     uint32_t m_firstValidTileIndex = 0;
108     uint32_t m_lastValidTileIndex  = 0;
109     uint32_t m_dstXLandingCount    = 0;
110     uint32_t m_lastDstEndX         = 0;
111 
112 #if (_DEBUG || _RELEASE_INTERNAL)
113     uint32_t m_dbgOvrdWidthInMinCb = 0;
114 #endif
115 MEDIA_CLASS_DEFINE_END(decode__HevcDownSamplingPkt)
116 };
117 
118 }
119 
120 #endif  // !_DECODE_PROCESSING_SUPPORTED
121 #endif  // !__DECODE_HEVC_DOWNSAMPLING_PACKET_H__
122