Skip to content

Commit

Permalink
[Encode] SVN Backmerge - Encoder codechal changes
Browse files Browse the repository at this point in the history
SVN Backmerge - Encoder codechal changes #1

Change-Id: I67188ff41e483925c630f414eeb2dd23078dd7ce
  • Loading branch information
habuzaina authored and intel-mediadev committed Feb 7, 2020
1 parent 7709507 commit 6de2414
Show file tree
Hide file tree
Showing 14 changed files with 305 additions and 61 deletions.
2 changes: 2 additions & 0 deletions media_driver/agnostic/common/codec/hal/codechal_encode_avc.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ typedef struct _CODECHAL_ENCODE_AVC_MBENC_SURFACE_PARAMS
PCODEC_AVC_REF_PIC_SELECT_LIST pWeightedPredOutputPicSelectList;
bool bUseWeightedSurfaceForL0;
bool bUseWeightedSurfaceForL1;
PMOS_RESOURCE presMbInlineData;
PMOS_RESOURCE presVMEOutSurface;
} CODECHAL_ENCODE_AVC_MBENC_SURFACE_PARAMS, *PCODECHAL_ENCODE_AVC_MBENC_SURFACE_PARAMS;

typedef struct _CODECHAL_ENCODE_AVC_MFE_MBENC_CURBE_PARAMS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2616,8 +2616,17 @@ MOS_STATUS CodechalEncodeAvcBase::SetPictureStructs()
}
else if (m_codecFunction == CODECHAL_FUNCTION_ENC_PAK)
{
// the actual MbCode/MvData surface to be allocated later
m_trackedBuf->SetAllocationFlag(true);
if (m_encodeParams.presMbCodeSurface == nullptr ||
Mos_ResourceIsNull(m_encodeParams.presMbCodeSurface))
{
// the actual MbCode/MvData surface to be allocated later
m_trackedBuf->SetAllocationFlag(true);
}
else
{
m_resMbCodeSurface = *(m_encodeParams.presMbCodeSurface);
m_resMvDataSurface = *(m_encodeParams.presMbCodeSurface);
}
}
else if (CodecHalIsFeiEncode(m_codecFunction))
{
Expand Down Expand Up @@ -3309,7 +3318,7 @@ CODECHAL_DEBUG_TOOL(
auto picIdx = m_picIdx[refPic.FrameIdx].ucPicIdx;
auto frameStoreId = m_refList[picIdx]->ucFrameId;
CODECHAL_ENCODE_CHK_NULL_RETURN(m_debugInterface);

MOS_ZeroMemory(&refSurface, sizeof(refSurface));
refSurface.Format = Format_NV12;
refSurface.OsResource = *(param.presReferences[frameStoreId]);
Expand All @@ -3323,8 +3332,8 @@ CODECHAL_DEBUG_TOOL(
CodechalDbgAttr::attrReferenceSurfaces,
refSurfName.c_str()));
}
}
for (uint8_t i = 0; i < numrefL1; i++)
}
for (uint8_t i = 0; i < numrefL1; i++)
{
if (m_pictureCodingType == B_TYPE && m_avcSliceParams->RefPicList[1][i].PicFlags != PICTURE_INVALID)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,8 @@ class CodechalEncodeAvcBase : public CodechalEncoderState
PCODEC_AVC_IQ_MATRIX_PARAMS m_avcIQMatrixParams = nullptr; //!< Pointer to IQMaxtrix parameter
PCODEC_AVC_ENCODE_IQ_WEIGTHSCALE_LISTS m_avcIQWeightScaleLists = nullptr; //!< Pointer to IQWidght ScaleLists
CODEC_AVC_ENCODE_USER_FLAGS m_userFlags; //!< Encoder user flag settings
uint32_t m_reconFrameSurfaceId[CODEC_AVC_NUM_UNCOMPRESSED_SURFACE];
CODECHAL_ENCODE_AVC_ENCODER_USAGE m_encoderUsage;

CODEC_PIC_ID m_picIdx[CODEC_AVC_MAX_NUM_REF_FRAME]; //!< Picture index
PCODEC_REF_LIST m_refList[CODEC_AVC_NUM_UNCOMPRESSED_SURFACE]; //!< Pointer to reference list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,12 +865,12 @@ MOS_STATUS CodechalEncodeHevcBase::SetSequenceStructs()
break;
}

if (m_hevcSeqParams->RateControlMethod == RATECONTROL_ICQ ||
if (m_hevcSeqParams->RateControlMethod == RATECONTROL_ICQ ||
m_hevcSeqParams->RateControlMethod == RATECONTROL_QVBR ||
m_hevcPicParams->NumROI)
{
// ICQ or ROI must result in LCU-based BRC to be enabled.
m_lcuBrcEnabled = true;
m_lcuBrcEnabled = true;
}
}

Expand Down Expand Up @@ -1300,7 +1300,7 @@ MOS_STATUS CodechalEncodeHevcBase::SetSliceStructs()
startLCU += slcParams->NumLCUsInSlice;
}
}

if (m_lowDelay && !m_sameRefList)
{
CODECHAL_ENCODE_NORMALMESSAGE("Attention: LDB frame but with different L0/L1 list !");
Expand Down Expand Up @@ -1800,13 +1800,13 @@ uint32_t CodechalEncodeHevcBase::GetProfileLevelMaxFrameSize()
GetMaxMBPS(levelIdc, &maxMBPS, &maxBytePerPic);
auto maxBytePerPicNot0 = (uint64_t)((((float_t)maxMBPS * (float_t)m_hevcSeqParams->FrameRate.Denominator) / (float_t)m_hevcSeqParams->FrameRate.Numerator) * formatFactor);
uint32_t profileLevelMaxFrame = 0;

uint32_t userMaxFrameSize = m_hevcSeqParams->UserMaxIFrameSize;
if ((m_hevcPicParams->CodingType != I_TYPE) && (m_hevcSeqParams->UserMaxPBFrameSize > 0))
{
userMaxFrameSize = m_hevcSeqParams->UserMaxPBFrameSize;
}

if (userMaxFrameSize != 0)
{
profileLevelMaxFrame = (uint32_t)MOS_MIN(userMaxFrameSize, maxBytePerPic);
Expand Down Expand Up @@ -3389,7 +3389,7 @@ MOS_STATUS CodechalEncodeHevcBase::DumpPicParams(
}

oss << "CodingType = " << +picParams->CodingType << std::endl;
oss << "HierarchLevelPlus1 = " << +picParams->HierarchLevelPlus1 << std::endl;
oss << "HierarchLevelPlus1 = " << +picParams->HierarchLevelPlus1 << std::endl;
oss << "NumSlices = " << +picParams->NumSlices << std::endl;
oss << "tiles_enabled_flag = " << +picParams->tiles_enabled_flag << std::endl;

Expand Down Expand Up @@ -3789,7 +3789,7 @@ MOS_STATUS CodechalEncodeHevcBase::PopulateDdiParam(
m_hevcPar->ISliceQP = hevcPicParams->QpY + hevcSlcParams->slice_qp_delta;
m_hevcPar->StartFrameNum = 0;
m_hevcPar->ProfileIDC = hevcSeqParams->general_profile_idc;
m_hevcPar->LevelIDC = hevcSeqParams->Level;
m_hevcPar->LevelIDC = hevcSeqParams->Level;
m_hevcPar->NumP = 0;
m_hevcPar->NumB = hevcSeqParams->GopPicSize - 1;
m_hevcPar->NumSlices = hevcPicParams->NumSlices;
Expand Down
15 changes: 10 additions & 5 deletions media_driver/agnostic/common/codec/hal/codechal_encoder_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ MOS_STATUS CodechalEncoderState::CreateGpuContexts()
bool setVideoNode = false;

// Create Video Context
if (MEDIA_IS_SKU(m_skuTable, FtrVcs2) ||
if (MEDIA_IS_SKU(m_skuTable, FtrVcs2) ||
(MOS_VE_MULTINODESCALING_SUPPORTED(m_osInterface) && m_numVdbox > 1)) // Eventually move this functionality to Mhw
{
setVideoNode = false;
Expand Down Expand Up @@ -3044,7 +3044,7 @@ MOS_STATUS CodechalEncoderState::StartStatusReport(
}

CODECHAL_ENCODE_CHK_STATUS_RETURN(m_perfProfiler->AddPerfCollectStartCmd((void*)this, m_osInterface, m_miInterface, cmdBuffer));

return eStatus;
}

Expand Down Expand Up @@ -3156,7 +3156,7 @@ MOS_STATUS CodechalEncoderState::EndStatusReport(
}

CODECHAL_ENCODE_CHK_STATUS_RETURN(m_perfProfiler->AddPerfCollectEndCmd((void*)this, m_osInterface, m_miInterface, cmdBuffer));

return eStatus;
}

Expand Down Expand Up @@ -3688,7 +3688,7 @@ MOS_STATUS CodechalEncoderState::ReadCounterValue(uint16_t index, EncodeStatusRe
//Report back in Big endian
encodeStatusReport->HWCounterValue.Count = SwapEndianness(encodeStatusReport->HWCounterValue.Count);
//IV value computation
encodeStatusReport->HWCounterValue.IV = *(++address2Counter);
encodeStatusReport->HWCounterValue.IV = *(++address2Counter);
encodeStatusReport->HWCounterValue.IV = SwapEndianness(encodeStatusReport->HWCounterValue.IV);
CODECHAL_ENCODE_NORMALMESSAGE(
"encodeStatusReport->HWCounterValue.Count = 0x%llx, encodeStatusReport->HWCounterValue.IV = 0x%llx",
Expand Down Expand Up @@ -3802,7 +3802,7 @@ MOS_STATUS CodechalEncoderState::GetStatusReport(
CODECHAL_DEBUG_TOOL(
m_statusReportDebugInterface->m_bufferDumpFrameNum = encodeStatus->dwStoredData;
)

// Current command is executed
if (m_osInterface->pfnIsGPUHung(m_osInterface))
{
Expand Down Expand Up @@ -4472,6 +4472,11 @@ MOS_STATUS CodechalEncoderState::ExecuteEnc(
else
{
CODECHAL_ENCODE_NORMALMESSAGE("App provides MbCode and MvData buffer!");
if(CODECHAL_AVC == m_standard)
{
m_currRefList->resRefMbCodeBuffer = m_resMbCodeSurface;
m_currRefList->resRefMvDataBuffer = m_resMvDataSurface;
}
}

m_trackedBuf->SetAllocationFlag(false);
Expand Down
21 changes: 18 additions & 3 deletions media_driver/agnostic/common/codec/hal/codechal_encoder_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,9 +896,9 @@ struct EncodeStatusReport

/*! \brief indicate whether it is single stream encoder or MFE.
*
* For single stream encoder (regular), this value should be set to default 0. For Multi-Frame-Encoder (MFE), this value is the StreamId that is set by application.
* For single stream encoder (regular), this value should be set to default 0. For Multi-Frame-Encoder (MFE), this value is the StreamId that is set by application.
*/
uint32_t StreamId;
uint32_t StreamId;

uint8_t cqmHint; //!< CQM hint. 0x00 - flat matrix; 0x01 - enable CQM; 0xFF - invalid hint; other vlaues are reserved.
};
Expand Down Expand Up @@ -1627,6 +1627,13 @@ class CodechalEncoderState : public Codechal
// ME
MHW_KERNEL_STATE m_meKernelStates[CODECHAL_ENCODE_ME_IDX_NUM]; //!< ME kernel states
MeKernelBindingTable m_meBindingTable = {}; //!< ME binding table
bool bStreamOutEnable;
MOS_RESOURCE StreamOutBuffer; // StreamOut buffer

//GVA paramters to change inter and intra rounding
bool bCoeffRoundTag;
uint32_t uiRoundIntra;
uint32_t uiRoundInter;

// Ds+Copy kernel optimization
uint8_t m_outputChromaFormat = (uint8_t)HCP_CHROMA_FORMAT_YUV420; //!< 1: 420 2: 422 3: 444
Expand Down Expand Up @@ -1701,6 +1708,14 @@ class CodechalEncoderState : public Codechal
MHW_VDBOX_NODE_IND m_vdboxIndex; //!< Index of vdbox
MediaPerfProfiler *m_perfProfiler = nullptr; //!< Performance data profiler
PMOS_GPUCTX_CREATOPTIONS m_gpuCtxCreatOpt = nullptr; //!< Used for creating GPU context
bool intraModeMaskControl;
uint32_t intraModeMask; // to disable intra mode
bool interMbTransformSizeControl;
bool interMbTransform8x8Enabled;

PMOS_RESOURCE presMbInlineData;
PMOS_RESOURCE presMbConstSurface;
PMOS_RESOURCE presVMEOutSurface;

#if (_DEBUG || _RELEASE_INTERNAL)
bool m_mmcUserFeatureUpdated; //!< indicate if the user feature is updated with MMC state
Expand Down Expand Up @@ -2126,7 +2141,7 @@ class CodechalEncoderState : public Codechal

//!
//! \brief Check Resolution Change and CSC
//!
//!
//! \details On resolution change, resize internal buffer
//! Check raw surface to set flag for CSC operation
//!
Expand Down
1 change: 1 addition & 0 deletions media_driver/agnostic/common/codec/hal/codechal_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include "media_interfaces_mhw.h"

#include "gfxmacro.h"
//------------------------------------------------------------------------------
// Macros specific to MOS_CODEC_SUBCOMP_HW sub-comp
//------------------------------------------------------------------------------
Expand Down
62 changes: 60 additions & 2 deletions media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4079,7 +4079,7 @@ MOS_STATUS CodechalVdencAvcState::SetSequenceStructs()
(CODEC_AVC_PROFILE_IDC)(seqParams->Profile),
(CODEC_AVC_LEVEL_IDC)(seqParams->Level),
seqParams->FramesPer100Sec);

m_lookaheadDepth = seqParams->LookaheadDepth;

return eStatus;
Expand Down Expand Up @@ -4186,6 +4186,13 @@ MOS_STATUS CodechalVdencAvcState::SetPictureStructs()
m_avcPicParam,
&(m_resVdencStreamInBuffer[m_currRecycledBufIdx])));
}
if(m_avcPicParam->ForceSkip.Enable && (m_pictureCodingType != I_TYPE))
{
m_avcPicParam->ForceSkip.Enable = 1;
CODECHAL_ENCODE_CHK_STATUS_RETURN( SetupForceSkipStreamIn(m_avcPicParam, &(m_resVdencStreamInBuffer[m_currRecycledBufIdx])) );
}
else
m_avcPicParam->ForceSkip.Enable = 0;

return eStatus;
}
Expand Down Expand Up @@ -4694,6 +4701,57 @@ MOS_STATUS CodechalVdencAvcState::SetupDirtyROI(PMOS_RESOURCE vdencStreamIn)
return eStatus;
}

MOS_STATUS CodechalVdencAvcState::SetupForceSkipStreamIn(PCODEC_AVC_ENCODE_PIC_PARAMS picParams, PMOS_RESOURCE vdencStreamIn)
{
int32_t i;
uint32_t uiCurX, uiCurY;
//PVDENC_STREAMIN_STATE_CMD pData;
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;

uint32_t CleanHorizontalStartMB = (picParams->ForceSkip.Xpos >> 4);
uint32_t CleanHorizontalEndMB = (picParams->ForceSkip.Xpos + picParams->ForceSkip.Width) >> 4;
uint32_t CleanVerticalStartMB = (picParams->ForceSkip.Ypos >> 4);
uint32_t CleanVerticalEndMB = (picParams->ForceSkip.Ypos + picParams->ForceSkip.Height) >> 4;

CODECHAL_ENCODE_FUNCTION_ENTER;
CODECHAL_ENCODE_CHK_NULL_RETURN(picParams);
CODECHAL_ENCODE_CHK_NULL_RETURN(vdencStreamIn);

MOS_LOCK_PARAMS lockFlags;
MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS));
lockFlags.WriteOnly = 1;

CODECHAL_VDENC_STREAMIN_STATE *pData = (CODECHAL_VDENC_STREAMIN_STATE*)m_osInterface->pfnLockResource(
m_osInterface,
vdencStreamIn,
&lockFlags);
CODECHAL_ENCODE_CHK_NULL_RETURN(pData);
MOS_ZeroMemory(pData, m_picHeightInMb * m_picWidthInMb * CODECHAL_VDENC_STREAMIN_STATE::byteSize);

for (uint16_t i = 0; i < m_picHeightInMb * m_picWidthInMb; i++)
{
uint32_t XPosInMbs = (i % m_picWidthInMb);
uint32_t YPosInMbs = (i / m_picWidthInMb);

if (XPosInMbs < CleanHorizontalStartMB || YPosInMbs < CleanVerticalStartMB
|| XPosInMbs >= CleanHorizontalEndMB || YPosInMbs >= CleanVerticalEndMB)
{
pData->DW0.Forceskip = true;
}
else
{
pData->DW0.Forceskip = false;
}

pData++;
}

m_osInterface->pfnUnlockResource(
m_osInterface,
vdencStreamIn);
return eStatus;
}

MOS_STATUS CodechalVdencAvcState::HuCBrcInitReset()
{
MOS_STATUS eStatus = MOS_STATUS_SUCCESS;
Expand Down Expand Up @@ -6286,7 +6344,7 @@ MOS_STATUS CodechalVdencAvcState::ExecuteSliceLevel()
m_newPpsHeader = 0;
m_newSeqHeader = 0;
}

CODECHAL_DEBUG_TOOL(
CODECHAL_ENCODE_CHK_STATUS_RETURN(PopulateSliceStateParam(
m_adaptiveRoundingInterEnable,
Expand Down
14 changes: 14 additions & 0 deletions media_driver/agnostic/common/codec/hal/codechal_vdenc_avc.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,20 @@ class CodechalVdencAvcState : public CodechalEncodeAvcBase
virtual MOS_STATUS SetupROIStreamIn(
PCODEC_AVC_ENCODE_PIC_PARAMS picParams,
PMOS_RESOURCE vdencStreamIn);
//!
//! \brief Set VDENC ForceSkip StreamIn Surface state
//!
//! \param [in] picParams
//! Pointer to CODEC_AVC_ENCODE_PIC_PARAMS.
//! \param [in] vdencStreamIn
//! StreamIn Surface Resource.
//!
//! \return MOS_STATUS
//! MOS_STATUS_SUCCESS if success, else fail reason
//!
MOS_STATUS SetupForceSkipStreamIn(
PCODEC_AVC_ENCODE_PIC_PARAMS picParams,
PMOS_RESOURCE vdencStreamIn);

//!
//! \brief Sort and set distinct delta QPs
Expand Down
Loading

0 comments on commit 6de2414

Please sign in to comment.