介紹
在有些應(yīng)用中,發(fā)現(xiàn)I幀不夠大。MPSoC VCU CtrlSW可以設(shè)置每一幀的QP大小。因此,可以通過(guò)設(shè)置I幀的QP,提高I幀的大小,從而提高I幀的質(zhì)量。
代碼
下面是設(shè)置I幀的QP的示例代碼。
GOP長(zhǎng)度變量
在struct EncoderSink : IFrameSink的定義里添加GOP的成員變量,記錄GOP長(zhǎng)度。
#if USER_I_FRAME_QP
// USER_I_FRAME_QP changes START
float uFrameRate = 0.0f;
int uGopLength = 0;
// USER_I_FRAME_QP changes END
#endif // USER_I_FRAME_QP
記錄GOP長(zhǎng)度
在EncoderSink 的EncoderSink函數(shù)設(shè)置GOP的變量的值。
struct EncoderSink : IFrameSink
{
EncoderSink(ConfigFile const& cfg, AL_IEncScheduler* pScheduler, AL_TAllocator* pAllocator
) :
CmdFile(cfg.sCmdFileName, false),
EncCmd(CmdFile.fp, cfg.RunInfo.iScnChgLookAhead, cfg.Settings.tChParam[0].tGopParam.uFreqLT),
twoPassMngr(cfg.sTwoPassFileName, cfg.Settings.TwoPass, cfg.Settings.bEnableFirstPassSceneChangeDetection, cfg.Settings.tChParam[0].tGopParam.uGopLength,
cfg.Settings.tChParam[0].tRCParam.uCPBSize / 90, cfg.Settings.tChParam[0].tRCParam.uInitialRemDelay / 90, cfg.MainInput.FileInfo.FrameRate),
qpBuffers{cfg.Settings, cfg.RunInfo.eGenerateQpMode},
pAllocator{pAllocator},
pSettings{&cfg.Settings}
{
#if USER_I_FRAME_QP
// USER_I_FRAME_QP changes STARTED ----------------------------------
uFrameRate = cfg.Settings.tChParam.tRCParam.uFrameRate;
uGopLength = cfg.Settings.tChParam.tGopParam.uGopLength;
// USER_I_FRAME_QP changes END --------------------------------------
#endif // USER_I_FRAME_QP
}
設(shè)置QP
在EncoderSink 的ProcessFrame函數(shù)里,根據(jù)GOP長(zhǎng)度,確定每個(gè)GOP開(kāi)始的I幀。然后再設(shè)置QP的值。可以試試20-35之間的QP值。QP值是20時(shí),能帶來(lái)很好的圖像質(zhì)量。
void ProcessFrame(AL_TBuffer* Src) override
{
if(m_picCount == 0)
m_StartTime = GetPerfTime();
if(!Src)
{
LogVerbose("Flushing...\n\n");
if(!AL_Encoder_Process(hEnc, nullptr, nullptr))
throw std::runtime_error("Failed");
return;
}
DisplayFrameStatus(m_picCount);
if(twoPassMngr.iPass)
{
auto pPictureMetaTP = AL_TwoPassMngr_CreateAndAttachTwoPassMetaData(Src);
if(twoPassMngr.iPass == 2)
twoPassMngr.GetFrame(pPictureMetaTP);
}
AL_TBuffer* QpBuf = qpBuffers.getBuffer(m_picCount);
std::shared_ptr QpBufShared(QpBuf, [&](AL_TBuffer* pBuf) { qpBuffers.releaseBuffer(pBuf); });
if(pSettings->hRcPluginDmaContext != NULL)
RCPlugin_SetNextFrameQP(pSettings, pAllocator);
#if USER_I_FRAME_QP
if( 0 == (m_picCount%uGopLength) )
{
AL_Encoder_SetQP(hEnc, 20 );
}
#endif // USER_I_FRAME_QP
if(!AL_Encoder_Process(hEnc, Src, QpBuf))
throw std::runtime_error("Failed");
m_picCount++;
m_picGopCount++;
}
審核編輯:郭婷
-
代碼
+關(guān)注
關(guān)注
30文章
4927瀏覽量
72509 -
MPSoC
+關(guān)注
關(guān)注
0文章
202瀏覽量
25012
發(fā)布評(píng)論請(qǐng)先 登錄
為什么無(wú)法在 USB3 Vision 上傳輸虛擬幀?
CYW20721如何在A2DP接收器中更改I2S時(shí)鐘設(shè)置?
Denebola RDK上配置的幀大小與實(shí)際幀大小不一致是怎么回事?
如何在SJA1110中配置IEEE802.1CB幀復(fù)制和冗余消除 (FRER)?
HarmonyOS應(yīng)用高負(fù)載場(chǎng)景分幀渲染
是否可以使用DMA和LPSPI的3字節(jié)幀大?。?/a>
工業(yè)與IT網(wǎng)絡(luò)中的以太網(wǎng)數(shù)據(jù)幀:格式與用途全解析
CCD ICX274 + VSP01M01如何實(shí)現(xiàn)單幀的觸發(fā)采集,寄存器如何設(shè)置?
EtherCAT數(shù)據(jù)幀結(jié)構(gòu)解析
I2C總線設(shè)備地址設(shè)置方法
基于Vector工具進(jìn)行CAN協(xié)議錯(cuò)誤幀的分析實(shí)踐

如何設(shè)置I幀的QP提高I幀的質(zhì)量
評(píng)論