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