1 /*
2 * Copyright (c) 2018, 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_predication.cpp
25 //! \brief    Defines the common interface for decode predication
26 //! \details  The decode predication interface implements the decode predication feature.
27 //!
28 #include "decode_predication.h"
29 #include "decode_utils.h"
30 
31 namespace decode {
32 
DecodePredication(DecodeAllocator & allocator)33 DecodePredication::DecodePredication(DecodeAllocator& allocator) :
34     m_allocator(&allocator)
35 {
36 
37 }
38 
~DecodePredication()39 DecodePredication::~DecodePredication()
40 {
41     if (m_allocator)
42     {
43         m_allocator->Destroy(m_predicationBuffer);
44     }
45     MOS_Delete(m_resPredication);
46 }
47 
Update(void * params)48 MOS_STATUS DecodePredication::Update(void *params)
49 {
50     DECODE_FUNC_CALL();
51 
52     DECODE_CHK_NULL(params);
53 
54     CodechalDecodeParams* decodeParams = (CodechalDecodeParams*)params;
55     m_predicationEnabled = decodeParams->m_predicationEnabled;
56     if (!m_predicationEnabled)
57     {
58         return MOS_STATUS_SUCCESS;
59     }
60 
61     m_predicationNotEqualZero = decodeParams->m_predicationNotEqualZero;
62     m_predicationResOffset    = decodeParams->m_predicationResOffset;
63 
64     if (m_resPredication == nullptr)
65     {
66         m_resPredication = MOS_New(MOS_BUFFER);
67     }
68 
69     DECODE_CHK_NULL(m_resPredication);
70     if (decodeParams->m_presPredication != nullptr)
71     {
72         m_resPredication->OsResource = *decodeParams->m_presPredication;
73     }
74     else
75     {
76         MOS_ZeroMemory(m_resPredication, sizeof(MOS_BUFFER));
77     }
78 
79     if (m_predicationBuffer == nullptr)
80     {
81         m_predicationBuffer = m_allocator->AllocateBuffer(sizeof(uint32_t), "PredicationBuffer");
82         DECODE_CHK_NULL(m_predicationBuffer);
83     }
84 
85     *(decodeParams->m_tempPredicationBuffer) = &m_predicationBuffer->OsResource;
86 
87     return MOS_STATUS_SUCCESS;
88 }
89 
90 }
91