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 //!
24 //! \file decode_hevc_phase_real_tile.cpp
25 //! \brief Defines the interface for Hevc decode real tile phase.
26 //!
27
28 #include "decode_hevc_phase_real_tile.h"
29 #include "decode_hevc_basic_feature.h"
30 #include "decode_utils.h"
31
32 namespace decode
33 {
34
Initialize(uint8_t pass,uint8_t pipe,uint8_t activePipeNum)35 MOS_STATUS HevcPhaseRealTile::Initialize(uint8_t pass, uint8_t pipe, uint8_t activePipeNum)
36 {
37 DECODE_FUNC_CALL();
38 DECODE_CHK_STATUS(HevcPhase::Initialize(pass, pipe, activePipeNum));
39
40 auto featureManager = m_pipeline->GetFeatureManager();
41 DECODE_CHK_NULL(featureManager);
42 auto basicFeature = dynamic_cast<HevcBasicFeature*>(
43 featureManager->GetFeature(FeatureIDs::basicFeature));
44 DECODE_CHK_NULL(basicFeature);
45 PCODEC_HEVC_PIC_PARAMS picParams = basicFeature->m_hevcPicParams;
46 DECODE_CHK_NULL(picParams);
47 m_numTileColumns = picParams->num_tile_columns_minus1 + 1;
48
49 return MOS_STATUS_SUCCESS;
50 }
51
GetCmdBufIndex()52 uint32_t HevcPhaseRealTile::GetCmdBufIndex()
53 {
54 DECODE_FUNC_CALL();
55 DECODE_ASSERT(m_scalabOption.GetNumPipe() > 1);
56 if (!m_pipeline->IsPhasedSubmission() || m_pipeline->IsParallelSubmission())
57 {
58 return m_secondaryCmdBufIdxBase + GetPipe();
59 }
60 else
61 {
62 /* 3 tiles 2 pipe for example:
63 cur pass cur pip
64 0 0, 1 2 cmd buffer needed
65 1 0 1 cmd buffer needed
66 all of 3 tiles cmd ready, submit 3 cmd togather
67 */
68 return m_secondaryCmdBufIdxBase + GetPipe() + (GetPass() * m_scalabOption.GetNumPipe());
69 }
70 }
71
GetSubmissionType()72 uint32_t HevcPhaseRealTile::GetSubmissionType()
73 {
74 DECODE_FUNC_CALL();
75 if (IsFirstPipe())
76 {
77 return SUBMISSION_TYPE_MULTI_PIPE_MASTER;
78 }
79 else if (IsLastPipeOfPass())
80 {
81 return SUBMISSION_TYPE_MULTI_PIPE_SLAVE |
82 SUBMISSION_TYPE_MULTI_PIPE_FLAGS_LAST_PIPE |
83 ((GetPipe() - 1) << SUBMISSION_TYPE_MULTI_PIPE_SLAVE_INDEX_SHIFT);
84 }
85 else
86 {
87 return SUBMISSION_TYPE_MULTI_PIPE_SLAVE |
88 ((GetPipe() - 1) << SUBMISSION_TYPE_MULTI_PIPE_SLAVE_INDEX_SHIFT);
89 }
90 }
91
GetMode(uint32_t & pipeWorkMode,uint32_t & multiEngineMode)92 MOS_STATUS HevcPhaseRealTile::GetMode(uint32_t &pipeWorkMode, uint32_t &multiEngineMode)
93 {
94 DECODE_FUNC_CALL();
95 pipeWorkMode = MHW_VDBOX_HCP_PIPE_WORK_MODE_CABAC_REAL_TILE;
96 if (IsFirstPipe())
97 {
98 if (IsLastPipeOfPic())
99 {
100 // if current pass is last pass and last pass only has one pipe, then it will work on leagcy mode
101 multiEngineMode = MHW_VDBOX_HCP_MULTI_ENGINE_MODE_FE_LEGACY;
102 }
103 else
104 {
105 multiEngineMode = MHW_VDBOX_HCP_MULTI_ENGINE_MODE_LEFT;
106 }
107 }
108 else if (IsLastPipeOfPass())
109 {
110 multiEngineMode = MHW_VDBOX_HCP_MULTI_ENGINE_MODE_RIGHT;
111 }
112 else
113 {
114 multiEngineMode = MHW_VDBOX_HCP_MULTI_ENGINE_MODE_MIDDLE;
115 }
116 return MOS_STATUS_SUCCESS;
117 }
118
GetPktId()119 uint32_t HevcPhaseRealTile::GetPktId()
120 {
121 DECODE_FUNC_CALL();
122 return DecodePacketId(m_pipeline, hevcRealTilePacketId);
123 }
124
ImmediateSubmit()125 bool HevcPhaseRealTile::ImmediateSubmit()
126 {
127 DECODE_FUNC_CALL();
128 return (IsLastPipeOfPic());
129 }
130
RequiresContextSwitch()131 bool HevcPhaseRealTile::RequiresContextSwitch()
132 {
133 DECODE_FUNC_CALL();
134 if (m_pipeline->IsShortFormat())
135 {
136 return false; // Don't need switch since same context as s2l phase
137 }
138 else
139 {
140 return (IsFirstPipe() && IsFirstPass()); // Switch at first pipe of first pass
141 }
142 }
143
144 }
145