1 /*
2 * Copyright (c) 2017, 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 //! \file codechal_encode_wp_g9.cpp
24 //! \brief This file implements the weighted prediction feature for all codecs on Gen9 platform
25 //!
26
27 #include "codechal_encoder_base.h"
28 #include "codechal_encode_wp_g9.h"
29 #include "codeckrnheader.h"
30
CodechalEncodeWPG9(CodechalEncoderState * encoder)31 CodechalEncodeWPG9::CodechalEncodeWPG9(CodechalEncoderState* encoder)
32 : CodechalEncodeWP(encoder)
33 {
34 m_kernelUID = IDR_CODEC_AllAVCEnc;
35 }
36
InitKernelState()37 MOS_STATUS CodechalEncodeWPG9::InitKernelState()
38 {
39 CODECHAL_ENCODE_FUNCTION_ENTER;
40
41 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
42
43 if (!m_kernelState)
44 {
45 CODECHAL_ENCODE_CHK_NULL_RETURN(m_kernelState = MOS_New(MHW_KERNEL_STATE));
46 }
47
48 uint8_t* binary;
49 CODECHAL_ENCODE_CHK_STATUS_RETURN(CodecHalGetKernelBinaryAndSize(
50 m_kernelBase,
51 m_kernelUID,
52 &binary,
53 &m_combinedKernelSize));
54
55 auto kernelSize = m_combinedKernelSize;
56 CODECHAL_KERNEL_HEADER currKrnHeader;
57 CODECHAL_ENCODE_CHK_STATUS_RETURN(pfnGetKernelHeaderAndSize(
58 binary,
59 ENC_WP,
60 0,
61 &currKrnHeader,
62 &kernelSize));
63
64 m_kernelState->KernelParams.iBTCount = wpNumSurfaces;
65 m_kernelState->KernelParams.iThreadCount = m_renderInterface->GetHwCaps()->dwMaxThreads;
66 m_kernelState->KernelParams.iCurbeLength = m_curbeLength;
67 m_kernelState->KernelParams.iBlockWidth = CODECHAL_MACROBLOCK_WIDTH;
68 m_kernelState->KernelParams.iBlockHeight = CODECHAL_MACROBLOCK_HEIGHT;
69 m_kernelState->KernelParams.iIdCount = 1;
70 m_kernelState->KernelParams.iInlineDataLength = 0;
71 m_kernelState->dwCurbeOffset = m_stateHeapInterface->GetSizeofCmdInterfaceDescriptorData();
72 m_kernelState->KernelParams.pBinary = binary + (currKrnHeader.KernelStartPointer << MHW_KERNEL_OFFSET_SHIFT);
73 m_kernelState->KernelParams.iSize = kernelSize;
74 CODECHAL_ENCODE_CHK_STATUS_RETURN(m_stateHeapInterface->CalculateSshAndBtSizesRequested(
75 m_kernelState->KernelParams.iBTCount,
76 &m_kernelState->dwSshSize,
77 &m_kernelState->dwBindingTableSize));
78
79 CODECHAL_ENCODE_CHK_NULL_RETURN(m_renderInterface->m_stateHeapInterface);
80 CODECHAL_ENCODE_CHK_STATUS_RETURN(m_hwInterface->MhwInitISH(m_renderInterface->m_stateHeapInterface, m_kernelState));
81
82 return eStatus;
83 }
84