ref: 128546b99229a0dc3d42052c8f1e45a9b0b83116
parent: 9512515a41173c4bcf7acbd15ca56305f430667b
author: ruil2 <ruil2@cisco.com>
date: Tue Nov 11 09:18:02 EST 2014
add maxnalsize control for gmp wrapper
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3668,13 +3668,12 @@
pCtx->eLastNalPriority = eNalRefIdc;
pFbi->iLayerNum = iLayerNum;
pFbi->iSubSeqId = GetSubSequenceId (pCtx, eFrameType);
+
WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerNum = %d,iSubSeqId = %d", iLayerNum,
pFbi->iSubSeqId);
for (int32_t i = 0; i < iLayerNum; i++)
WelsLog (pLogCtx, WELS_LOG_DEBUG, "WelsEncoderEncodeExt() OutputInfo iLayerId = %d,iNalType = %d,iNalCount = %d", i,
pFbi->sLayerInfo[i].uiLayerType, pFbi->sLayerInfo[i].iNalCount);
-
-
WelsEmms();
pFbi->eFrameType = eFrameType;
--- a/module/gmp-openh264.cpp
+++ b/module/gmp-openh264.cpp
@@ -210,9 +210,9 @@
Error (GMPGenericErr);
return;
}
-
- SEncParamBase param;
+ SEncParamExt param;
memset (¶m, 0, sizeof (param));
+ encoder_->GetDefaultParams (¶m);
GMPLOG (GL_INFO, "Initializing encoder at "
<< codecSettings.mWidth
@@ -219,35 +219,50 @@
<< "x"
<< codecSettings.mHeight
<< "@"
- << static_cast<int> (codecSettings.mMaxFramerate)
- << "max payload size="
- << maxPayloadSize);
+ << static_cast<int> (codecSettings.mMaxFramerate));
// Translate parameters.
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
param.iPicWidth = codecSettings.mWidth;
param.iPicHeight = codecSettings.mHeight;
+ param.iRCMode = RC_BITRATE_MODE;
param.iTargetBitrate = codecSettings.mStartBitrate * 1000;
+ param.iMaxBitrate = codecSettings.mMaxBitrate * 1000;
GMPLOG (GL_INFO, "Initializing Bit Rate at: Start: "
<< codecSettings.mStartBitrate
<< "; Min: "
<< codecSettings.mMinBitrate
<< "; Max: "
- << codecSettings.mMaxBitrate);
- param.iRCMode = RC_BITRATE_MODE;
+ << codecSettings.mMaxBitrate
+ << "; Max payload size:"
+ << maxPayloadSize);
+ param.uiMaxNalSize = maxPayloadSize;
+
// TODO(ekr@rtfm.com). Scary conversion from unsigned char to float below.
param.fMaxFrameRate = static_cast<float> (codecSettings.mMaxFramerate);
- rv = encoder_->Initialize (¶m);
+ // Set up layers. Currently we have one layer.
+ SSpatialLayerConfig* layer = ¶m.sSpatialLayers[0];
+
+ layer->iVideoWidth = codecSettings.mWidth;
+ layer->iVideoHeight = codecSettings.mHeight;
+ layer->fFrameRate = param.fMaxFrameRate;
+ layer->iSpatialBitrate = param.iTargetBitrate;
+ layer->iMaxSpatialBitrate = param.iMaxBitrate;
+
+ //for controlling the NAL size (normally for packetization-mode=0)
+ if (maxPayloadSize != 0) {
+ layer->sSliceCfg.uiSliceMode = SM_DYN_SLICE;
+ layer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = maxPayloadSize;
+ }
+ rv = encoder_->InitializeExt (¶m);
if (rv) {
GMPLOG (GL_ERROR, "Couldn't initialize encoder");
Error (GMPGenericErr);
return;
}
-
max_payload_size_ = maxPayloadSize;
-
GMPLOG (GL_INFO, "Initialized encoder");
}
@@ -382,7 +397,7 @@
src.pData[3] = nullptr;
src.iPicWidth = inputImage->Width();
src.iPicHeight = inputImage->Height();
- src.uiTimeStamp = inputImage->Timestamp()/1000; //encoder needs millisecond
+ src.uiTimeStamp = inputImage->Timestamp() / 1000; //encoder needs millisecond
const SSourcePicture* pics = &src;
int result = encoder_->EncodeFrame (pics, &encoded);
@@ -628,7 +643,7 @@
dState,
renderTimeMs));
if (dState) {
- Error(GMPGenericErr);
+ Error (GMPGenericErr);
}
}