Skip to content

Commit

Permalink
[HEVC Encode FEI] Fix QP reporting issue for HEVC FEI max frame size …
Browse files Browse the repository at this point in the history
…feature(CL#751641)

Description:
1. This issue is caused by that CumulativeQp read from HCP Qp Status Count register has accumulation unit of LCU size not 4x4 size.
2. For every pass, frame delta QP should be set as current pass delta QP which is passed from application, and this delta QP will be used in next pass.

Change-Id: I9a0ca7fb387c40df406c3a53f62ccce020f9c910
  • Loading branch information
Chengwei_Wang authored and Sherry-Lin committed Mar 26, 2018
1 parent defaf9a commit 3d843ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2079,11 +2079,13 @@ MOS_STATUS CodechalEncodeHevcBase::GetStatusReport(

if (m_frameWidth != 0 && m_frameHeight != 0)
{
//The CumulativeQp from the PAK has accumulation unit of 4x4, so we align and divide height, width by 4
//The CumulativeQp from the PAK has accumulation unit of LCU, so we align and divide height, width by LCU size
uint32_t log2LcuSize = m_hevcSeqParams->log2_max_coding_block_size_minus3 + 3;

encodeStatusReport->QpY = encodeStatusReport->AverageQp =
(uint8_t)(((uint32_t)encodeStatus->QpStatusCount.hcpCumulativeQP)
/ ((MOS_ALIGN_CEIL(m_frameWidth, 4) >> 2) *
(MOS_ALIGN_CEIL(m_frameHeight, 4) >> 2)));
/ ((MOS_ALIGN_CEIL(m_frameWidth, (1 << log2LcuSize)) >> log2LcuSize) *
(MOS_ALIGN_CEIL(m_frameHeight, (1 << log2LcuSize)) >> log2LcuSize)));
}

if (!Mos_ResourceIsNull(&m_resFrameStatStreamOutBuffer))
Expand Down
14 changes: 10 additions & 4 deletions media_driver/agnostic/gen9/hw/vdbox/mhw_vdbox_hcp_g9_X.h
Original file line number Diff line number Diff line change
Expand Up @@ -1481,10 +1481,16 @@ class MhwVdboxHcpInterfaceG9 : public MhwVdboxHcpInterfaceGeneric<THcpCmds>
// Add for multiple pass
if (params->maxFrameSize > 0 && params->deltaQp)
{
cmd.DW10_11.Value[0] = (params->deltaQp[3] << 24) | (params->deltaQp[2] << 16) |
(params->deltaQp[1] << 8) | params->deltaQp[0];
cmd.DW10_11.Value[1] = (params->deltaQp[7] << 24) | (params->deltaQp[6] << 16) |
(params->deltaQp[5] << 8) | params->deltaQp[4];
uint8_t hevcMaxPassNum = 8;

// When current pass is less than the max number of pass, set the delta QP.
if (params->currPass < hevcMaxPassNum)
{
cmd.DW10_11.Value[0] = (params->deltaQp[params->currPass] << 24) | (params->deltaQp[params->currPass] << 16) |
(params->deltaQp[params->currPass] << 8) | params->deltaQp[params->currPass];
cmd.DW10_11.Value[1] = (params->deltaQp[params->currPass] << 24) | (params->deltaQp[params->currPass] << 16) |
(params->deltaQp[params->currPass] << 8) | params->deltaQp[params->currPass];
}

// If the calculated value of max frame size exceeded 14 bits, need set the unit as 4K byte. Else, set the unit as 32 byte.
if (params->maxFrameSize >= (0x1 << 14) * 32)
Expand Down

0 comments on commit 3d843ba

Please sign in to comment.