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_decode_sfc_avc.cpp
24 //! \brief Implements the decode interface extension for CSC and scaling via SFC for AVC decoder.
25 //! \details Downsampling in this case is supported by the SFC fixed function HW unit.
26 //!
27
28 #include "codechal_decode_sfc_avc.h"
29
CheckAndInitialize(PCODECHAL_DECODE_PROCESSING_PARAMS decProcessingParams,PCODEC_AVC_PIC_PARAMS picParams,uint32_t width,uint32_t height,bool deblockingEnabled)30 MOS_STATUS CodechalAvcSfcState::CheckAndInitialize(
31 PCODECHAL_DECODE_PROCESSING_PARAMS decProcessingParams,
32 PCODEC_AVC_PIC_PARAMS picParams,
33 uint32_t width,
34 uint32_t height,
35 bool deblockingEnabled)
36 {
37 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
38
39 CODECHAL_HW_FUNCTION_ENTER;
40
41 m_sfcPipeOut = false;
42
43 if (CodecHal_PictureIsFrame(picParams->CurrPic) &&
44 !picParams->seq_fields.mb_adaptive_frame_field_flag &&
45 IsSfcOutputSupported(decProcessingParams, MhwSfcInterface::SFC_PIPE_MODE_VDBOX))
46 {
47 this->m_deblockingEnabled = deblockingEnabled;
48 this->m_inputFrameWidth = width;
49 this->m_inputFrameHeight = height;
50
51 CODECHAL_HW_CHK_STATUS_RETURN(Initialize(
52 decProcessingParams,
53 MhwSfcInterface::SFC_PIPE_MODE_VDBOX));
54
55 m_sfcPipeOut = true;
56 }
57
58 if (decProcessingParams->bIsReferenceOnlyPattern)
59 {
60 m_sfcPipeOut = false;
61 }
62
63 return eStatus;
64 }
65
UpdateInputInfo(PMHW_SFC_STATE_PARAMS sfcStateParams)66 MOS_STATUS CodechalAvcSfcState::UpdateInputInfo(
67 PMHW_SFC_STATE_PARAMS sfcStateParams)
68 {
69 MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
70
71 CODECHAL_HW_FUNCTION_ENTER;
72
73 sfcStateParams->sfcPipeMode = MEDIASTATE_SFC_PIPE_VD_TO_SFC;
74 sfcStateParams->dwAVSFilterMode = MEDIASTATE_SFC_AVS_FILTER_5x5;
75
76 sfcStateParams->dwVDVEInputOrderingMode = m_deblockingEnabled ? MEDIASTATE_SFC_INPUT_ORDERING_VD_16x16_SHIFT : MEDIASTATE_SFC_INPUT_ORDERING_VD_16x16_NOSHIFT;
77 sfcStateParams->dwInputChromaSubSampling = MEDIASTATE_SFC_CHROMA_SUBSAMPLING_420;
78
79 sfcStateParams->dwInputFrameWidth = m_inputFrameWidth;
80 sfcStateParams->dwInputFrameHeight = m_inputFrameHeight;
81
82 return eStatus;
83 }
84