Skip to content

Commit fa20557

Browse files
DaShi-Gitintel-mediadev
authored andcommitted
[Encode] add hevc height padding for VC.
add padding for unaligned height.
1 parent 9f00b3e commit fa20557

File tree

5 files changed

+209
-0
lines changed

5 files changed

+209
-0
lines changed

media_softlet/agnostic/Xe3_M_plus/Xe3_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe3_lpm_base.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#if _KERNEL_RESERVED
3535
#include "encode_hevc_vdenc_saliency.h"
3636
#endif
37+
#include "encode_vdenc_hevc_height_padding.h"
3738

3839
namespace encode
3940
{
@@ -99,6 +100,10 @@ MOS_STATUS EncodeHevcVdencFeatureManagerXe3_Lpm_Base::CreateFeatures(void *const
99100
HevcVdencSaliency *hevcSaliency = MOS_New(HevcVdencSaliency, this, m_allocator, m_hwInterface, constSettings);
100101
ENCODE_CHK_STATUS_RETURN(RegisterFeatures(FeatureIDs::saliencyFeature, hevcSaliency, {HevcPipeline::encodePreEncPacket}));
101102
#endif
103+
104+
HevcVdencHeightPadding *hevcHeightPadding = MOS_New(HevcVdencHeightPadding, this, m_allocator, m_hwInterface, constSettings);
105+
ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcVdencHeightPaddingFeature, hevcHeightPadding));
106+
102107
return MOS_STATUS_SUCCESS;
103108
}
104109

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Copyright (c) 2025, 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_height_padding.cpp
24+
//! \brief Defines the Xe3_LPM+ Base interface for hevc encode height padding features
25+
//!
26+
27+
#include "encode_vdenc_hevc_height_padding.h"
28+
#include "encode_hevc_vdenc_feature_manager.h"
29+
30+
namespace encode
31+
{
32+
33+
MOS_STATUS HevcVdencHeightPadding::Update(void *params)
34+
{
35+
ENCODE_FUNC_CALL();
36+
37+
ENCODE_CHK_NULL_RETURN(params);
38+
EncoderParams *encodeParams = static_cast<EncoderParams *>(params);
39+
m_hevcSeqParams = static_cast<PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS>(encodeParams->pSeqParams);
40+
ENCODE_CHK_NULL_RETURN(m_hevcSeqParams);
41+
m_hevcPicParams = static_cast<PCODEC_HEVC_ENCODE_PICTURE_PARAMS>(encodeParams->pPicParams);
42+
ENCODE_CHK_NULL_RETURN(m_hevcPicParams);
43+
44+
uint32_t oriHeight = (m_hevcSeqParams->wFrameHeightInMinCbMinus1 + 1) << (m_hevcSeqParams->log2_min_coding_block_size_minus3 + 3);
45+
m_enabled = oriHeight % 8 == 0 && oriHeight % 16 != 0
46+
&& m_hevcSeqParams->ScenarioInfo == ESCENARIO_VIDEOCONFERENCE
47+
&& !m_hevcPicParams->tiles_enabled_flag
48+
&& m_hevcPicParams->TargetFrameSize == 0;
49+
if (m_enabled)
50+
{
51+
ENCODE_CHK_NULL_RETURN(encodeParams->psRawSurface);
52+
PMOS_SURFACE rawSurface = encodeParams->psRawSurface;
53+
ENCODE_CHK_NULL_RETURN(encodeParams->psReconSurface);
54+
PMOS_SURFACE reconSurface = encodeParams->psReconSurface;
55+
m_alignedHeight = MOS_ALIGN_CEIL(oriHeight, 16);
56+
ENCODE_CHK_NULL_RETURN(m_allocator);
57+
ENCODE_CHK_STATUS_RETURN(m_allocator->GetSurfaceInfo(rawSurface));
58+
ENCODE_CHK_STATUS_RETURN(m_allocator->GetSurfaceInfo(reconSurface));
59+
if (rawSurface->Format != Format_NV12 || rawSurface->YoffsetForUplane < m_alignedHeight || reconSurface->YoffsetForUplane < m_alignedHeight)
60+
{
61+
m_enabled = false;
62+
}
63+
}
64+
65+
return MOS_STATUS_SUCCESS;
66+
}
67+
68+
MHW_SETPAR_DECL_SRC(VDENC_CMD2, HevcVdencHeightPadding)
69+
{
70+
ENCODE_FUNC_CALL();
71+
72+
if (!m_enabled)
73+
{
74+
return MOS_STATUS_SUCCESS;
75+
}
76+
77+
params.height = m_alignedHeight;
78+
79+
return MOS_STATUS_SUCCESS;
80+
}
81+
82+
MHW_SETPAR_DECL_SRC(VDENC_HEVC_VP9_TILE_SLICE_STATE, HevcVdencHeightPadding)
83+
{
84+
ENCODE_FUNC_CALL();
85+
86+
if (!m_enabled)
87+
{
88+
return MOS_STATUS_SUCCESS;
89+
}
90+
91+
// currently no tiling supports
92+
params.tileHeight = m_alignedHeight;
93+
94+
return MOS_STATUS_SUCCESS;
95+
}
96+
97+
MHW_SETPAR_DECL_SRC(HCP_PIC_STATE, HevcVdencHeightPadding)
98+
{
99+
ENCODE_FUNC_CALL();
100+
101+
if (!m_enabled)
102+
{
103+
return MOS_STATUS_SUCCESS;
104+
}
105+
106+
params.frameheightinmincbminus1 = (m_alignedHeight >> (m_hevcSeqParams->log2_min_coding_block_size_minus3 + 3)) - 1;
107+
108+
return MOS_STATUS_SUCCESS;
109+
}
110+
111+
MHW_SETPAR_DECL_SRC(AQM_PIC_STATE, HevcVdencHeightPadding)
112+
{
113+
ENCODE_FUNC_CALL();
114+
115+
if (!m_enabled)
116+
{
117+
return MOS_STATUS_SUCCESS;
118+
}
119+
120+
params.FrameHeightInPixelMinus1 = m_alignedHeight - 1;
121+
122+
return MOS_STATUS_SUCCESS;
123+
}
124+
} // namespace encode
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (c) 2025, 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_height_padding.h
24+
//! \brief Defines for Xe3_LPM+ hevc height padding feature
25+
//!
26+
#ifndef __ENCODE_HEVC_VDENC_HEIGHT_PADDING_H__
27+
#define __ENCODE_HEVC_VDENC_HEIGHT_PADDING_H__
28+
29+
#include "encode_allocator.h"
30+
#include "encode_hevc_basic_feature.h"
31+
#include "mhw_vdbox_aqm_itf.h"
32+
33+
namespace encode
34+
{
35+
class HevcVdencHeightPadding : public MediaFeature, public mhw::vdbox::vdenc::Itf::ParSetting, public mhw::vdbox::hcp::Itf::ParSetting, public mhw::vdbox::aqm::Itf::ParSetting
36+
{
37+
public:
38+
HevcVdencHeightPadding(
39+
MediaFeatureManager *featureManager,
40+
EncodeAllocator *allocator,
41+
CodechalHwInterfaceNext *hwInterface,
42+
void *constSettings) : MediaFeature(constSettings, hwInterface ? hwInterface->GetOsInterface() : nullptr), m_allocator(allocator)
43+
{
44+
ENCODE_FUNC_CALL();
45+
}
46+
47+
~HevcVdencHeightPadding() {}
48+
49+
//!
50+
//! \brief Update encode parameter
51+
//! \param [in] params
52+
//! Pointer to parameters
53+
//! \return MOS_STATUS
54+
//! MOS_STATUS_SUCCESS if success, else fail reason
55+
//!
56+
virtual MOS_STATUS Update(void *params) override;
57+
58+
MHW_SETPAR_DECL_HDR(VDENC_CMD2);
59+
60+
MHW_SETPAR_DECL_HDR(VDENC_HEVC_VP9_TILE_SLICE_STATE);
61+
62+
MHW_SETPAR_DECL_HDR(HCP_PIC_STATE);
63+
64+
MHW_SETPAR_DECL_HDR(AQM_PIC_STATE);
65+
66+
protected:
67+
PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS m_hevcSeqParams = nullptr;
68+
PCODEC_HEVC_ENCODE_PICTURE_PARAMS m_hevcPicParams = nullptr;
69+
uint32_t m_alignedHeight = 0;
70+
EncodeAllocator *m_allocator = nullptr;
71+
72+
MEDIA_CLASS_DEFINE_END(encode__HevcVdencHeightPadding)
73+
};
74+
75+
} // namespace encode
76+
77+
#endif // !__ENCODE_HEVC_VDENC_HEIGHT_PADDING_H__

media_softlet/agnostic/common/codec/hal/enc/hevc/features/media_hevc_feature_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct HevcFeatureIDs : public FeatureIDs
4646
hevcVdencFastPassFeature,
4747
hevcAqm,
4848
hevcSaliencyFeature,
49+
hevcVdencHeightPaddingFeature,
4950
};
5051
};
5152

media_softlet/agnostic/common/codec/hal/enc/hevc/features/media_srcs.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ set(TMP_SOURCES_
3838
${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_preenc.cpp
3939
${CMAKE_CURRENT_LIST_DIR}/encode_hevc_aqm.cpp
4040
${CMAKE_CURRENT_LIST_DIR}/encode_vdenc_hevc_fastpass.cpp
41+
${CMAKE_CURRENT_LIST_DIR}/encode_vdenc_hevc_height_padding.cpp
4142
)
4243

4344
set(TMP_HEADERS_
@@ -58,6 +59,7 @@ set(TMP_HEADERS_
5859
${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_preenc.h
5960
${CMAKE_CURRENT_LIST_DIR}/encode_hevc_aqm.h
6061
${CMAKE_CURRENT_LIST_DIR}/encode_vdenc_hevc_fastpass.h
62+
${CMAKE_CURRENT_LIST_DIR}/encode_vdenc_hevc_height_padding.h
6163
)
6264

6365
set(SOFTLET_ENCODE_HEVC_HEADERS_

0 commit comments

Comments
 (0)