| 1 |
/* |
| 2 |
* Copyright (c) 2017-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 |
//! \file codechal_decode_sfc_hevc.cpp |
| 24 |
//! \brief Implements the decode interface extension for CSC and scaling via SFC for HEVC decoder. |
| 25 |
//! \details Downsampling in this case is supported by the SFC fixed function HW unit. |
| 26 |
//! |
| 27 |
|
| 28 |
#include "codechal_decoder.h" |
| 29 |
#include "codechal_decode_sfc_hevc.h" |
| 30 |
|
| 31 |
MOS_STATUS CodechalHevcSfcState::CheckAndInitialize( |
| 32 |
DecodeProcessingParams *decProcessingParams, |
| 33 |
PCODEC_HEVC_PIC_PARAMS hevcPicParams) |
| 34 |
{ |
| 35 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 36 |
|
| 37 |
CODECHAL_HW_FUNCTION_ENTER; |
| 38 |
|
| 39 |
if (decProcessingParams) |
| 40 |
{ |
| 41 |
if (IsSfcOutputSupported(decProcessingParams, MhwSfcInterface::SFC_PIPE_MODE_VEBOX)) |
| 42 |
{ |
| 43 |
m_sfcPipeOut = true; |
| 44 |
|
| 45 |
// Set the input region as the HCP output frame region |
| 46 |
m_inputFrameWidth = hevcPicParams->PicWidthInMinCbsY << (hevcPicParams->log2_min_luma_coding_block_size_minus3 + 3); |
| 47 |
m_inputFrameHeight = hevcPicParams->PicHeightInMinCbsY << (hevcPicParams->log2_min_luma_coding_block_size_minus3 + 3); |
| 48 |
decProcessingParams->m_inputSurfaceRegion.m_x = 0; |
| 49 |
decProcessingParams->m_inputSurfaceRegion.m_y = 0; |
| 50 |
decProcessingParams->m_inputSurfaceRegion.m_width = m_inputFrameWidth; |
| 51 |
decProcessingParams->m_inputSurfaceRegion.m_height = m_inputFrameHeight; |
| 52 |
|
| 53 |
// SFC Initialization. |
| 54 |
// Initialize once for most of the resources |
| 55 |
// Destroy them in CodecHalHevc_Destroy() |
| 56 |
CODECHAL_HW_CHK_STATUS_RETURN(Initialize( |
| 57 |
decProcessingParams, |
| 58 |
MhwSfcInterface::SFC_PIPE_MODE_VEBOX)); |
| 59 |
if(m_decoder) |
| 60 |
{ |
| 61 |
m_decoder->SetVdSfcSupportedFlag(true); |
| 62 |
} |
| 63 |
} |
| 64 |
else |
| 65 |
{ |
| 66 |
if(m_decoder) |
| 67 |
{ |
| 68 |
m_decoder->SetVdSfcSupportedFlag(false); |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
return eStatus; |
| 74 |
} |
| 75 |
|
| 76 |
MOS_STATUS CodechalHevcSfcState::UpdateInputInfo( |
| 77 |
PMHW_SFC_STATE_PARAMS sfcStateParams) |
| 78 |
{ |
| 79 |
MOS_STATUS eStatus = MOS_STATUS_SUCCESS; |
| 80 |
|
| 81 |
CODECHAL_HW_FUNCTION_ENTER; |
| 82 |
|
| 83 |
uint16_t widthAlignUnit, heightAlignUnit; |
| 84 |
|
| 85 |
sfcStateParams->sfcPipeMode = MEDIASTATE_SFC_PIPE_VE_TO_SFC; |
| 86 |
sfcStateParams->dwAVSFilterMode = MEDIASTATE_SFC_AVS_FILTER_8x8; |
| 87 |
sfcStateParams->dwVDVEInputOrderingMode = MEDIASTATE_SFC_INPUT_ORDERING_VE_4x8; |
| 88 |
sfcStateParams->dwInputChromaSubSampling = MEDIASTATE_SFC_CHROMA_SUBSAMPLING_420; //IN: NV12 - How about P010? |
| 89 |
|
| 90 |
// Adjust SFC input surface alignment. |
| 91 |
// As VEBOX doesn't do scaling, input size equals to output size |
| 92 |
// For the VEBOX output to SFC, width is multiple of 16 and height is multiple of 4 |
| 93 |
widthAlignUnit = m_sfcInterface->m_veWidthAlignment; |
| 94 |
heightAlignUnit = m_sfcInterface->m_veHeightAlignment; |
| 95 |
|
| 96 |
sfcStateParams->dwInputFrameWidth = MOS_ALIGN_CEIL(m_inputSurface->dwWidth, widthAlignUnit); |
| 97 |
sfcStateParams->dwInputFrameHeight = MOS_ALIGN_CEIL(m_inputSurface->dwHeight, heightAlignUnit); |
| 98 |
|
| 99 |
return eStatus; |
| 100 |
} |