Merge pull request #999 from ruil2/format_update
add max nal size setting in gmp wrapper
This commit is contained in:
commit
ac1630f435
@ -204,7 +204,7 @@ class OpenH264VideoEncoder : public GMPVideoEncoder {
|
||||
if (rv) {
|
||||
return GMPVideoGenericErr;
|
||||
}
|
||||
|
||||
if (maxPayloadSize <= 0) {
|
||||
SEncParamBase param;
|
||||
memset (¶m, 0, sizeof (param));
|
||||
|
||||
@ -228,6 +228,7 @@ class OpenH264VideoEncoder : public GMPVideoEncoder {
|
||||
<< codecSettings.mMinBitrate
|
||||
<< "; Max: "
|
||||
<< codecSettings.mMaxBitrate);
|
||||
|
||||
param.iRCMode = RC_BITRATE_MODE;
|
||||
|
||||
// TODO(ekr@rtfm.com). Scary conversion from unsigned char to float below.
|
||||
@ -239,6 +240,60 @@ class OpenH264VideoEncoder : public GMPVideoEncoder {
|
||||
GMPLOG (GL_ERROR, "Couldn't initialize encoder");
|
||||
return GMPVideoGenericErr;
|
||||
}
|
||||
} else {
|
||||
SEncParamExt param;
|
||||
memset (¶m, 0, sizeof (param));
|
||||
encoder_->GetDefaultParams (¶m);
|
||||
|
||||
GMPLOG (GL_INFO, "Initializing encoder at "
|
||||
<< codecSettings.mWidth
|
||||
<< "x"
|
||||
<< codecSettings.mHeight
|
||||
<< "@"
|
||||
<< static_cast<int> (codecSettings.mMaxFramerate)
|
||||
<< "max payload size="
|
||||
<< maxPayloadSize);
|
||||
|
||||
// Translate parameters.
|
||||
param.iUsageType = CAMERA_VIDEO_REAL_TIME;
|
||||
param.iInputCsp = videoFormatI420;
|
||||
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);
|
||||
//for controlling the NAL size (normally for packetization-mode=0)
|
||||
param.uiMaxNalSize = maxPayloadSize;
|
||||
|
||||
// TODO(ekr@rtfm.com). Scary conversion from unsigned char to float below.
|
||||
param.fMaxFrameRate = static_cast<float> (codecSettings.mMaxFramerate);
|
||||
|
||||
// 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;
|
||||
|
||||
// Based on guidance from Cisco.
|
||||
layer->sSliceCfg.uiSliceMode = SM_DYN_SLICE;
|
||||
layer->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = maxPayloadSize;
|
||||
|
||||
rv = encoder_->InitializeExt (¶m);
|
||||
if (rv) {
|
||||
GMPLOG (GL_ERROR, "Couldn't initialize encoder");
|
||||
return GMPVideoGenericErr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
max_payload_size_ = maxPayloadSize;
|
||||
callback_ = callback;
|
||||
|
Loading…
Reference in New Issue
Block a user