1 /*
2 * Copyright (c) 2020-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 encode_hevc_vdenc_preenc.cpp
24 //! \brief Defines the common interface for encode hevc preenc parameter
25 //!
26
27 #include "encode_hevc_basic_feature.h"
28 #include "encode_hevc_vdenc_preenc.h"
29 #include "encode_allocator.h"
30
31 namespace encode
32 {
HevcVdencPreEnc(MediaFeatureManager * featureManager,EncodeAllocator * allocator,CodechalHwInterfaceNext * hwInterface,TrackedBuffer * trackedBuf,RecycleResource * recycleBuf,void * constSettings)33 HevcVdencPreEnc::HevcVdencPreEnc(
34 MediaFeatureManager *featureManager,
35 EncodeAllocator * allocator,
36 CodechalHwInterfaceNext *hwInterface,
37 TrackedBuffer * trackedBuf,
38 RecycleResource * recycleBuf,
39 void * constSettings) : PreEncBasicFeature(featureManager, allocator, hwInterface, trackedBuf, recycleBuf, constSettings)
40 {
41 ENCODE_FUNC_CALL();
42 auto encFeatureManager = (featureManager);
43 ENCODE_CHK_NULL_NO_STATUS_RETURN(encFeatureManager);
44
45 m_allocator = allocator;
46
47 m_basicFeature = dynamic_cast<HevcBasicFeature *>(encFeatureManager->GetFeature(HevcFeatureIDs::basicFeature));
48 ENCODE_CHK_NULL_NO_STATUS_RETURN(m_basicFeature);
49 }
50
~HevcVdencPreEnc()51 HevcVdencPreEnc::~HevcVdencPreEnc()
52 {
53 }
54
PreparePreEncConfig(void * params)55 MOS_STATUS HevcVdencPreEnc::PreparePreEncConfig(void *params)
56 {
57 ENCODE_FUNC_CALL();
58 ENCODE_CHK_NULL_RETURN(params);
59
60 EncoderParams *encodeParams = (EncoderParams *)params;
61
62 m_hevcSeqParams = static_cast<PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS>(encodeParams->pSeqParams);
63 ENCODE_CHK_NULL_RETURN(m_hevcSeqParams);
64 m_hevcPicParams = static_cast<PCODEC_HEVC_ENCODE_PICTURE_PARAMS>(encodeParams->pPicParams);
65 ENCODE_CHK_NULL_RETURN(m_hevcPicParams);
66 m_hevcSliceParams = static_cast<PCODEC_HEVC_ENCODE_SLICE_PARAMS>(encodeParams->pSliceParams);
67 ENCODE_CHK_NULL_RETURN(m_hevcSliceParams);
68 m_nalUnitParams = encodeParams->ppNALUnitParams;
69 ENCODE_CHK_NULL_RETURN(m_nalUnitParams);
70 m_NumNalUnits = encodeParams->uiNumNalUnits;
71
72 m_preEncConfig.LowDelayMode = m_hevcSeqParams->LowDelayMode;
73 m_preEncConfig.BitDepthLumaMinus8 = m_hevcSeqParams->bit_depth_luma_minus8;
74 m_preEncConfig.BitDepthChromaMinus8 = m_hevcSeqParams->bit_depth_chroma_minus8;
75 m_preEncConfig.CodingType = (uint8_t)m_basicFeature->m_pictureCodingType;
76 m_preEncConfig.CurrReconstructedPic = m_hevcPicParams->CurrReconstructedPic;
77 for (auto i = 0; i < CODEC_MAX_NUM_REF_FRAME_HEVC; i++)
78 {
79 m_preEncConfig.RefFrameList[i] = m_hevcPicParams->RefFrameList[i];
80 m_preEncConfig.RefFramePOCList[i] = m_hevcPicParams->RefFramePOCList[i];
81 }
82 for (auto i = 0; i < 2; i++)
83 {
84 for (auto ii = 0; ii < CODEC_MAX_NUM_REF_FRAME_HEVC; ii++)
85 {
86 m_preEncConfig.RefPicList[i][ii] = m_hevcSliceParams->RefPicList[i][ii];
87 }
88 }
89 m_preEncConfig.CurrPicOrderCnt = m_hevcPicParams->CurrPicOrderCnt;
90 m_preEncConfig.HierarchicalFlag = m_hevcSeqParams->HierarchicalFlag;
91 m_preEncConfig.HierarchLevelPlus1 = m_hevcPicParams->HierarchLevelPlus1;
92 m_preEncConfig.GopRefDist = m_hevcSeqParams->GopRefDist;
93 m_preEncConfig.SliceType = m_hevcSliceParams->slice_type;
94 m_preEncConfig.CurrOriginalPic = m_hevcPicParams->CurrOriginalPic;
95 m_preEncConfig.UsedAsRef = m_hevcPicParams->bUsedAsRef;
96 m_preEncConfig.InputColorSpace = m_hevcSeqParams->InputColorSpace;
97
98 for (uint8_t i = 0; i < CODEC_MAX_NUM_REF_FRAME_HEVC; i++)
99 {
100 m_preEncConfig.PicIdx[i] = m_basicFeature->m_ref.GetPicIndex(i);
101 }
102
103 m_preEncConfig.RefList = m_basicFeature->m_ref.GetRefList();
104
105 return MOS_STATUS_SUCCESS;
106 }
107
108 } // namespace encode
109