Skip to content

Commit

Permalink
Fixed unlimited vector grow in EncTools BRC (#6224)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergey Plotnikov <[email protected]>
  • Loading branch information
gfxVPLsdm and splotnikv authored Dec 12, 2023
1 parent c8ef176 commit 32830a2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions _studio/enctools/include/mfx_enctools_brc.h
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ class BRC_EncToolBase
mfxStatus ProcessFrame(mfxU32 dispOrder, mfxEncToolsBRCQuantControl *pFrameQp, mfxEncToolsHintQPMap* qpMapHint) override;
mfxStatus UpdateFrame(mfxU32 dispOrder, mfxEncToolsBRCStatus *pFrameSts) override;
mfxStatus GetHRDPos(mfxU32 dispOrder, mfxEncToolsBRCHRDPos *pHRDPos) override;
mfxStatus DiscardFrame(mfxU32 dispOrder) override;

protected:

Expand Down
1 change: 1 addition & 0 deletions _studio/enctools/include/mfx_ienctools.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct IEncToolsBRC
virtual mfxStatus ProcessFrame(mfxU32 /*dispOrder*/, mfxEncToolsBRCQuantControl*, mfxEncToolsHintQPMap*) = 0;
virtual mfxStatus UpdateFrame(mfxU32 /*dispOrder*/, mfxEncToolsBRCStatus*) = 0;
virtual mfxStatus GetHRDPos(mfxU32 /*dispOrder*/, mfxEncToolsBRCHRDPos*) = 0;
virtual mfxStatus DiscardFrame(mfxU32 /*dispOrder*/) = 0;
};

namespace EncToolsFuncs
Expand Down
8 changes: 8 additions & 0 deletions _studio/enctools/src/mfx_enctools_brc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,14 @@ mfxStatus BRC_EncToolBase::GetHRDPos(mfxU32 dispOrder, mfxEncToolsBRCHRDPos *pHR
return MFX_ERR_NONE;
}

mfxStatus BRC_EncToolBase::DiscardFrame(mfxU32 dispOrder){
auto frameStructItr = std::find_if(m_FrameStruct.begin(), m_FrameStruct.end(), CompareByDisplayOrder(dispOrder));
if(frameStructItr != m_FrameStruct.end()){
m_FrameStruct.erase(frameStructItr);
}
return MFX_ERR_NONE;
}

static mfxU8 SelectQp(mfxF64 erate[52], mfxF64 budget)
{
for (mfxU8 qp = 1; qp < 52; qp++)
Expand Down
4 changes: 4 additions & 0 deletions _studio/enctools/src/mfx_enctools_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,10 @@ mfxStatus EncTools::Discard(mfxU32 displayOrder)
mfxStatus sts = MFX_ERR_NONE;
if (isPreEncSCD(m_config, m_ctrl))
sts = m_scd.CompleteFrame(displayOrder);
if (IsOn(m_config.BRC))
{
m_brc->DiscardFrame(displayOrder);
}
return sts;
}

Expand Down

0 comments on commit 32830a2

Please sign in to comment.