介紹
在有些應(yīng)用中,發(fā)現(xiàn)I幀不夠大。MPSoC VCU CtrlSW可以設(shè)置每一幀的QP大小。因此,可以通過設(shè)置I幀的QP,提高I幀的大小,從而提高I幀的質(zhì)量。
代碼
下面是設(shè)置I幀的QP的示例代碼。
GOP長度變量
在struct EncoderSink : IFrameSink的定義里添加GOP的成員變量,記錄GOP長度。
#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長度
在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長度,確定每個GOP開始的I幀。然后再設(shè)置QP的值。可以試試20-35之間的QP值。QP值是20時,能帶來很好的圖像質(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文章
4788瀏覽量
68612 -
MPSoC
+關(guān)注
關(guān)注
0文章
198瀏覽量
24282
發(fā)布評論請先 登錄
相關(guān)推薦
以太網(wǎng)幀格式和功能詳解
以太網(wǎng)幀結(jié)構(gòu)是怎樣的
can標準幀和擴展幀能否共存
can標準幀和擴展幀的區(qū)別
can網(wǎng)絡(luò)數(shù)據(jù)幀的特點
can數(shù)據(jù)幀有哪幾個域組成
CAN數(shù)據(jù)幀的各個域及其作用
EtherCAT 數(shù)據(jù)幀格式和尋址方式簡介
![EtherCAT 數(shù)據(jù)<b class='flag-5'>幀</b>格式和尋址方式簡介](https://file.elecfans.com/web2/M00/50/DA/pYYBAGLH6TyAB71EAAAPQ7KgtYA038.png)
AMD HYPR-RX支持AMD幀生成技術(shù),助力即刻提升游戲性能
![AMD HYPR-RX支持AMD<b class='flag-5'>幀</b>生成技術(shù),助力即刻提升游戲性能](https://file1.elecfans.com/web2/M00/C4/79/wKgZomXzwmWAGzDSAAFKBhkI1OU363.jpg)
為了提高應(yīng)用的安全性,TLD7002-16ES的幀間延遲應(yīng)該更長還是更短?
CAN總線上可以同時存在標準幀和擴展幀嗎?
使用MODBUS協(xié)議的時候可以不用設(shè)置數(shù)據(jù)幀格式了嗎?
CAN通信協(xié)議中有哪幾種幀類型?CAN通信中幀格式的作用
MODBUS通訊之數(shù)據(jù)幀格式解讀
![MODBUS通訊之數(shù)據(jù)<b class='flag-5'>幀</b>格式解讀](https://file.elecfans.com/web2/M00/09/16/pYYBAGD0FvWAeWpFAAAb1Fux1oA753.jpg)
評論