| 1 | /* |
| 2 | * Copyright (c) 2018-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 | //! \file codechal_encode_sfc_g11.cpp |
| 24 | //! \brief Implements the encode interface extension for CSC via VEBox/SFC. |
| 25 | //! \details Downsampling in this case is supported by the VEBox fixed function HW unit. |
| 26 | //! |
| 27 | |
| 28 | #include "codechal_encode_sfc_g11.h" |
| 29 | #include "codechal_encoder_base.h" |
| 30 | #include "mhw_sfc_g11_X.h" |
| 31 | |
| 32 | MOS_STATUS CodecHalEncodeSfcG11::SetVeboxDiIecpParams( |
| 33 | PMHW_VEBOX_DI_IECP_CMD_PARAMS params) |
| 34 | { |
| 35 | MOS_ALLOC_GFXRES_PARAMS allocParamsForBufferLinear; |
| 36 | MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 37 | |
| 38 | CODECHAL_ENCODE_FUNCTION_ENTER; |
| 39 | CODECHAL_ENCODE_CHK_NULL_RETURN(params); |
| 40 | |
| 41 | params->dwStartingX = 0; |
| 42 | params->dwEndingX = m_inputSurfaceRegion.Width - 1; // Must be taken from SPS |
| 43 | params->dwCurrInputSurfOffset = m_inputSurface->dwOffset; |
| 44 | params->pOsResCurrInput = &m_inputSurface->OsResource; |
| 45 | params->CurrInputSurfCtrl.Value = 0; //Keep it here untill VPHAL moving to new CMD definition and remove this parameter definition. |
| 46 | |
| 47 | CodecHalGetResourceInfo( |
| 48 | m_osInterface, |
| 49 | m_inputSurface); |
| 50 | params->CurInputSurfMMCState = (MOS_MEMCOMP_STATE)(m_inputSurface->CompressionMode); |
| 51 | |
| 52 | // Allocate Resource to avoid Page Fault issue since HW will access it |
| 53 | if (Mos_ResourceIsNull(&m_resLaceOrAceOrRgbHistogram)) |
| 54 | { |
| 55 | MOS_ZeroMemory(&allocParamsForBufferLinear, sizeof(MOS_ALLOC_GFXRES_PARAMS)); |
| 56 | allocParamsForBufferLinear.Type = MOS_GFXRES_BUFFER; |
| 57 | allocParamsForBufferLinear.TileType = MOS_TILE_LINEAR; |
| 58 | allocParamsForBufferLinear.Format = Format_Buffer; |
| 59 | allocParamsForBufferLinear.dwBytes = GetResLaceOrAceOrRgbHistogramBufferSize(); |
| 60 | allocParamsForBufferLinear.pBufName = "ResLaceOrAceOrRgbHistogram"; |
| 61 | |
| 62 | m_osInterface->pfnAllocateResource( |
| 63 | m_osInterface, |
| 64 | &allocParamsForBufferLinear, |
| 65 | &m_resLaceOrAceOrRgbHistogram); |
| 66 | } |
| 67 | |
| 68 | params->pOsResLaceOrAceOrRgbHistogram = &m_resLaceOrAceOrRgbHistogram; |
| 69 | |
| 70 | // Allocate Resource to avoid Page Fault issue since HW will access it |
| 71 | if (Mos_ResourceIsNull(&m_resStatisticsOutput)) |
| 72 | { |
| 73 | MOS_ZeroMemory(&allocParamsForBufferLinear, sizeof(MOS_ALLOC_GFXRES_PARAMS)); |
| 74 | allocParamsForBufferLinear.Type = MOS_GFXRES_BUFFER; |
| 75 | allocParamsForBufferLinear.TileType = MOS_TILE_LINEAR; |
| 76 | allocParamsForBufferLinear.Format = Format_Buffer; |
| 77 | allocParamsForBufferLinear.dwBytes = GetSfcVeboxStatisticsSize(); |
| 78 | allocParamsForBufferLinear.pBufName = "ResStatisticsOutput"; |
| 79 | |
| 80 | m_osInterface->pfnAllocateResource( |
| 81 | m_osInterface, |
| 82 | &allocParamsForBufferLinear, |
| 83 | &m_resStatisticsOutput); |
| 84 | } |
| 85 | |
| 86 | params->pOsResStatisticsOutput = &m_resStatisticsOutput; |
| 87 | |
| 88 | return eStatus; |
| 89 | } |