介紹
在有些應(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開始的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... "); 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責(zé)任編輯:haqQpBufShared(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文章
4900瀏覽量
70756 -
變量
+關(guān)注
關(guān)注
0文章
614瀏覽量
28964
原文標(biāo)題:設(shè)置I幀的QP,提高I幀的質(zhì)量
文章出處:【微信號(hào):FPGA-EETrend,微信公眾號(hào):FPGA開發(fā)圈】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。
發(fā)布評(píng)論請(qǐng)先 登錄
CYW20721如何在A2DP接收器中更改I2S時(shí)鐘設(shè)置?
ESP32P4示例工程中有用的i2c-tools調(diào)試工程
是否可以使用DMA和LPSPI的3字節(jié)幀大小?
如何獲取SMBus示例代碼?
用于 SPI 絕對(duì)編碼器的 Arduino 示例代碼

I2C總線設(shè)備地址設(shè)置方法
AN-840: 通過(guò)I2C接口更新代碼

LP589x和TLC698x示例代碼用戶指南

UART串口通信示例:開啟通信寶藏之門的定位模組LuatOS入門

BQ40Z80量產(chǎn)校準(zhǔn)代碼示例

評(píng)論