Merge pull request #1184 in FS/freeswitch from feature/FS-9137-update-openh264-to-1.5.0 to master
updated to 1.6.0 * commit '8df7fe34673409639b5b914d1eeaca89bc87d0e7': FS-9137 update to openh264 release 1.6.0 FS-9137 update to openh264 release 1.5.0 and tweak some params
This commit is contained in:
commit
5619ffded0
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2015, Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Copyright (C) 2005-2017, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
|
@ -43,7 +43,7 @@
|
|||
#define NAL_HEADER_ADD_0X30BYTES 50
|
||||
#endif
|
||||
|
||||
#define FPS 15.0f // frame rate
|
||||
#define FPS 30.0f // frame rate
|
||||
#define H264_NALU_BUFFER_SIZE 65536
|
||||
#define SLICE_SIZE SWITCH_DEFAULT_VIDEO_SIZE //NALU Slice Size
|
||||
|
||||
|
@ -80,6 +80,7 @@ typedef struct h264_codec_context_s {
|
|||
} h264_codec_context_t;
|
||||
|
||||
int FillSpecificParameters(h264_codec_context_t *context) {
|
||||
int sane = 0;
|
||||
SEncParamExt *param;
|
||||
|
||||
param = &context->encoder_params;
|
||||
|
@ -98,11 +99,16 @@ int FillSpecificParameters(h264_codec_context_t *context) {
|
|||
context->bandwidth = switch_calc_bitrate(context->codec_settings.video.width, context->codec_settings.video.height, 1, 15);
|
||||
}
|
||||
|
||||
if (context->bandwidth > 5120) {
|
||||
context->bandwidth = 5120;
|
||||
sane = switch_calc_bitrate(1920, 1080, 2, 30);
|
||||
|
||||
if (context->bandwidth > sane) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "BITRATE TRUNCATED TO %d\n", sane);
|
||||
context->bandwidth = sane;
|
||||
}
|
||||
|
||||
/* Test for temporal, spatial, SNR scalability */
|
||||
context->bandwidth *= 1024;
|
||||
|
||||
param->fMaxFrameRate = FPS * 2;
|
||||
param->iPicWidth = context->codec_settings.video.width; // width of picture in samples
|
||||
param->iPicHeight = context->codec_settings.video.height; // height of picture in samples
|
||||
param->iTargetBitrate = context->bandwidth;
|
||||
|
@ -132,22 +138,20 @@ int FillSpecificParameters(h264_codec_context_t *context) {
|
|||
int iIndexLayer = 0;
|
||||
param->sSpatialLayers[iIndexLayer].iVideoWidth = context->codec_settings.video.width;
|
||||
param->sSpatialLayers[iIndexLayer].iVideoHeight = context->codec_settings.video.height;
|
||||
param->sSpatialLayers[iIndexLayer].fFrameRate = (double) (FPS * 1.0f);
|
||||
param->sSpatialLayers[iIndexLayer].fFrameRate = FPS;
|
||||
// param->sSpatialLayers[iIndexLayer].iQualityLayerNum = 1;
|
||||
param->sSpatialLayers[iIndexLayer].iSpatialBitrate = param->iTargetBitrate;
|
||||
//param->sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = param->iTargetBitrate;
|
||||
//param->sSpatialLayers[iIndexLayer].uiLevelIdc = LEVEL_3_1;
|
||||
param->sSpatialLayers[iIndexLayer].iMaxSpatialBitrate = UNSPECIFIED_BIT_RATE;
|
||||
param->sSpatialLayers[iIndexLayer].uiLevelIdc = LEVEL_4_1;
|
||||
param->sSpatialLayers[iIndexLayer].uiProfileIdc = PRO_BASELINE;
|
||||
|
||||
|
||||
param->iUsageType = CAMERA_VIDEO_REAL_TIME;
|
||||
param->bEnableFrameCroppingFlag = 1;
|
||||
//param->iMaxBitrate = 1250000;
|
||||
//param->iTargetBitrate = 1250000;
|
||||
param->iMaxBitrate = UNSPECIFIED_BIT_RATE;
|
||||
|
||||
#ifdef MT_ENABLED
|
||||
param->sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_DYN_SLICE;
|
||||
param->sSpatialLayers[iIndexLayer].sSliceCfg.sSliceArgument.uiSliceSizeConstraint = SLICE_SIZE;
|
||||
param->sSpatialLayers[iIndexLayer].sSliceArgument.uiSliceMode = SM_SIZELIMITED_SLICE;
|
||||
param->sSpatialLayers[iIndexLayer].sSliceArgument.uiSliceSizeConstraint = SLICE_SIZE;
|
||||
param->uiMaxNalSize = SLICE_SIZE + NAL_HEADER_ADD_0X30BYTES;
|
||||
#else
|
||||
param->sSpatialLayers[iIndexLayer].sSliceCfg.uiSliceMode = SM_SINGLE_SLICE;
|
||||
|
@ -171,7 +175,6 @@ long set_decoder_options(ISVCDecoder *decoder)
|
|||
// EBufferProperty eOutputProperty = BUFFER_HOST;
|
||||
long ret = 0;
|
||||
|
||||
ret += decoder->SetOption(DECODER_OPTION_DATAFORMAT, &iColorFormat);
|
||||
// ret += decoder->SetOption(DECODER_OPTION_OUTPUT_PROPERTY, &eOutputProperty);
|
||||
|
||||
return ret;
|
||||
|
@ -454,7 +457,6 @@ static switch_status_t switch_h264_init(switch_codec_t *codec, switch_codec_flag
|
|||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
context->decoder_params.eOutputColorFormat = videoFormatI420;
|
||||
context->decoder_params.uiTargetDqLayer = (uint8_t) -1;
|
||||
context->decoder_params.eEcActiveIdc = ERROR_CON_SLICE_COPY;
|
||||
context->decoder_params.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;
|
||||
|
@ -513,7 +515,7 @@ static switch_status_t init_encoder(h264_codec_context_t *context, uint32_t widt
|
|||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Codec ready; picture size %dx%d Bandwidth: %d\n",
|
||||
context->encoder_params.iPicWidth, context->encoder_params.iPicHeight, context->codec_settings.video.bandwidth);
|
||||
context->encoder_params.iPicWidth, context->encoder_params.iPicHeight, context->bandwidth);
|
||||
|
||||
|
||||
context->encoder_initialized = SWITCH_TRUE;
|
||||
|
@ -796,6 +798,10 @@ static switch_status_t switch_h264_destroy(switch_codec_t *codec)
|
|||
SWITCH_MODULE_LOAD_FUNCTION(mod_openh264_load)
|
||||
{
|
||||
switch_codec_interface_t *codec_interface;
|
||||
OpenH264Version ver;
|
||||
|
||||
ver = WelsGetCodecVersion();
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "OpenH264 version %u.%u.%u.%u\n", ver.uMajor, ver.uMinor, ver.uRevision, ver.uReserved);
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
@ -804,7 +810,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_openh264_load)
|
|||
switch_core_codec_add_video_implementation(pool, codec_interface, 99, "H264", NULL,
|
||||
switch_h264_init, switch_h264_encode, switch_h264_decode, switch_h264_control, switch_h264_destroy);
|
||||
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue