哪位做过dvrrdk4多slice编码,除了修改outputdatamode、slicemode、sliceuintsize之外还需要修改哪些项呢?谢谢!
Ternence_Hsu:
你好;
需要在mcfw中enclink_h264.c 中添加:
dynamicParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_USERDEFINED;dynamicParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES;dynamicParams->sliceCodingParams.streamFormat = IH264_BYTE_STREAM;dynamicParams->sliceCodingParams.sliceUnitSize = 1200;注:按字节划分slice只支持baseline模式;
Ternence_Hsu:
建议查看手册:
DVRRDK_04.00.00.03/ti_tools/codecs/REL.500.V.H264AVC.E.IVAHD.02.00.04.01/500.V.H264AVC.E.IVAHD.02.00/IVAHD_001/Docs/H264_Encoder_HDVICP2_UserGuide.pdf
jack huang5:
回复 Ternence_Hsu:
我在enclink_h264_set_static_params和enclink_h264_set_dynamic_params中修改了sliceCodingParams,熵编码是CAVLC编码,但是编出来的还是单slice的码流,还有其他的参数要修改吗?谢谢!
修改后的代码static Int enclink_h264_set_static_params(IH264ENC_Params * staticParams, EncLink_AlgCreateParams * algCreateParams){ /* Initialize default values for static params */ *staticParams = H264ENC_TI_PARAMS;
/* Both width & height needs to be align with 2 bytes */ staticParams->videnc2Params.maxHeight = VpsUtils_align(algCreateParams->maxHeight, 2);
staticParams->videnc2Params.maxWidth = VpsUtils_align(algCreateParams->maxWidth, 16);
staticParams->videnc2Params.maxInterFrameInterval = algCreateParams->maxInterFrameInterval;
staticParams->videnc2Params.inputContentType = algCreateParams->inputContentType;
staticParams->videnc2Params.inputChromaFormat = algCreateParams->inputChromaFormat;
staticParams->videnc2Params.profile = algCreateParams->profile;
staticParams->videnc2Params.level = algCreateParams->level;
staticParams->videnc2Params.encodingPreset = algCreateParams->encodingPreset;
if ((staticParams->videnc2Params.encodingPreset == XDM_USER_DEFINED) && (algCreateParams->enableHighSpeed == TRUE)) { staticParams->interCodingParams.interCodingPreset = IH264_INTERCODING_HIGH_SPEED; staticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_HIGH_SPEED; staticParams->transformBlockSize = IH264_TRANSFORM_8x8; } /* In case of interlaced encode, below would be used. In case of progressive this will be ignored. */ //staticParams->interlaceCodingType = IH264_INTERLACE_FIELDONLY_SPF; staticParams->enableAnalyticinfo = algCreateParams->enableAnalyticinfo; staticParams->enableWatermark = algCreateParams->enableWaterMarking; staticParams->videnc2Params.rateControlPreset = IVIDEO_USER_DEFINED; staticParams->rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_USERDEFINED; staticParams->rateControlParams.scalingMatrixPreset = (IH264_HIGH_PROFILE == algCreateParams->profile) ? IH264_SCALINGMATRIX_NORMAL: IH264_SCALINGMATRIX_NONE; staticParams->rateControlParams.rcAlgo = algCreateParams->rateControlPreset; staticParams->videnc2Params.maxBitRate = algCreateParams->maxBitRate;
staticParams->videnc2Params.inputDataMode = IVIDEO_ENTIREFRAME; staticParams->videnc2Params.outputDataMode = IVIDEO_ENTIREFRAME;
/* Temporal restrictions with H.264 encoder */
/* Number of temporal layeers set to 1. This is the default value */ /* in the codec*/ if (0 == algCreateParams->numTemporalLayer) { staticParams->numTemporalLayer = IH264_TEMPORAL_LAYERS_1; } else { staticParams->numTemporalLayer = algCreateParams->numTemporalLayer; }
/*Note: Enabling this flag adds svc enxtension header to the stream, not all decoders are generally able to play back such a stream. */ /* Needs to be enabled to IH264_SVC_EXTENSION_FLAG_ENABLE for the svc extension headers to be present in the stream*/ /*!!! Note: This flag needs to be enabled for the temporalId to be parsed out from the stream.*/ staticParams->svcCodingParams.svcExtensionFlag = algCreateParams->enableSVCExtensionFlag;
/*Slice Coding Parameters*/ staticParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_DEFAULT; staticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_NONE; staticParams->sliceCodingParams.streamFormat = IH264_STREAM_FORMAT_DEFAULT;
/* To set IDR frame periodically instead of I Frame */ staticParams->IDRFrameInterval = 1;
/*To trigger workaround inside codec, where SAME_CODEC is overridden as same codec type*/ staticParams->reservedParams[1] = 0x5A3EC0DE; /* Enabling debug logging inside the codec. Details in appendix E in H.264 * encoder user guide. */#ifdef ENCLINK_H264_PERFORMANCE_LOGGING staticParams->debugTraceLevel = 1; staticParams->lastNFramesToLog = ENCLINK_H264_PROFILER_NUM_FRAMES;#endif /* We want SPS and PPS to be set for every intra frame. Hence configure the * the NALU control params to force encoder to insert SPS/PPS on every * I frame */ staticParams->nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_USERDEFINED; ENCLINK_H264_SETNALU_MASK_SPS(staticParams->nalUnitControlParams. naluPresentMaskIntraPicture); ENCLINK_H264_SETNALU_MASK_PPS(staticParams->nalUnitControlParams. naluPresentMaskIntraPicture);
ENCLINK_H264_SETNALU_MASK_SPS(staticParams->nalUnitControlParams. naluPresentMaskIDRPicture); ENCLINK_H264_SETNALU_MASK_PPS(staticParams->nalUnitControlParams. naluPresentMaskIDRPicture); ENCLINK_H264_SETNALU_MASK_SEI(staticParams->nalUnitControlParams. naluPresentMaskIDRPicture);
ENCLINK_H264_SETNALU_MASK_SPS(staticParams->nalUnitControlParams. naluPresentMaskStartOfSequence); ENCLINK_H264_SETNALU_MASK_PPS(staticParams->nalUnitControlParams. naluPresentMaskStartOfSequence); ENCLINK_H264_SETNALU_MASK_PPS(staticParams->nalUnitControlParams. naluPresentMaskStartOfSequence);
staticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC; if (algCreateParams->profile != IH264_HIGH_PROFILE) { memset (&staticParams->intraCodingParams, 0, sizeof(IH264ENC_IntraCodingParams)); staticParams->transformBlockSize = IH264_TRANSFORM_4x4; if (algCreateParams->profile == IH264_BASELINE_PROFILE) { staticParams->entropyCodingMode = IH264_ENTROPYCODING_CAVLC; } }
#if 1 staticParams->vuiCodingParams.vuiCodingPreset = IH264_VUICODING_USERDEFINED; staticParams->vuiCodingParams.hrdParamsPresentFlag = 1; staticParams->vuiCodingParams.timingInfoPresentFlag = 1;#endif
//modify#define SET_MEMB(memb, val) Vps_printf("%20s %d %d\n", #memb, memb, val); memb = val;#if 1 Vps_printf("staticParams->entropyCodingMode %d\n", staticParams->entropyCodingMode); SET_MEMB(staticParams->videnc2Params.outputDataMode, IVIDEO_SLICEMODE); SET_MEMB(staticParams->videnc2Params.numOutputDataUnits, 1); SET_MEMB(staticParams->sliceCodingParams.sliceCodingPreset, IH264_SLICECODING_USERDEFINED); SET_MEMB(staticParams->sliceCodingParams.sliceMode, IH264_SLICEMODE_BYTES); SET_MEMB(staticParams->sliceCodingParams.sliceUnitSize, 1200); SET_MEMB(staticParams->sliceCodingParams.streamFormat, IH264_BYTE_STREAM);#endif //modify
return 0;}
static Int enclink_h264_set_dynamic_params( EncLink_AlgCreateParams *algCreateParams, IH264ENC_DynamicParams *dynamicParams, EncLink_AlgDynamicParams *algDynamicParams){ *dynamicParams = H264ENC_TI_DYNAMICPARAMS;
dynamicParams->videnc2DynamicParams.inputWidth = algDynamicParams->inputWidth; dynamicParams->videnc2DynamicParams.inputHeight = algDynamicParams->inputHeight; dynamicParams->videnc2DynamicParams.captureWidth = algDynamicParams->inputPitch; dynamicParams->videnc2DynamicParams.targetBitRate = algDynamicParams->targetBitRate; dynamicParams->videnc2DynamicParams.targetFrameRate = algDynamicParams->targetFrameRate; dynamicParams->videnc2DynamicParams.interFrameInterval = algDynamicParams->interFrameInterval; dynamicParams->videnc2DynamicParams.intraFrameInterval = algDynamicParams->intraFrameInterval; dynamicParams->videnc2DynamicParams.mvAccuracy = algDynamicParams->mvAccuracy; dynamicParams->rateControlParams.VBRDuration = algDynamicParams->vbrDuration; dynamicParams->rateControlParams.VBRsensitivity = algDynamicParams->vbrSensitivity; dynamicParams->videnc2DynamicParams.refFrameRate = algDynamicParams->refFrameRate; dynamicParams->videnc2DynamicParams.ignoreOutbufSizeFlag = XDAS_TRUE; dynamicParams->videnc2DynamicParams.getBufferFxn = enclink_h264_dummy_get_buffer_fxn;
dynamicParams->rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_USERDEFINED; dynamicParams->rateControlParams.scalingMatrixPreset = (IH264_HIGH_PROFILE == algCreateParams->profile) ? IH264_SCALINGMATRIX_NORMAL: IH264_SCALINGMATRIX_NONE; dynamicParams->rateControlParams.qpMinI = algDynamicParams->qpMinI; dynamicParams->rateControlParams.qpMaxI = algDynamicParams->qpMaxI; dynamicParams->rateControlParams.qpI = algDynamicParams->qpInitI; dynamicParams->rateControlParams.qpMinP = algDynamicParams->qpMinP; dynamicParams->rateControlParams.qpMaxP = algDynamicParams->qpMaxP; dynamicParams->rateControlParams.qpP = algDynamicParams->qpInitP; dynamicParams->rateControlParams.rcAlgo = algDynamicParams->rcAlg;
dynamicParams->rateControlParams.discardSavedBits = 1;
if(dynamicParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC) { dynamicParams->rateControlParams.HRDBufferSize = 2 * algDynamicParams->targetBitRate; } else { dynamicParams->rateControlParams.HRDBufferSize = algDynamicParams->targetBitRate; }
dynamicParams->rateControlParams.enablePRC = FALSE; // PRC is turned off for video security dynamicParams->rateControlParams.initialBufferLevel = dynamicParams->rateControlParams.HRDBufferSize;
dynamicParams->rateControlParams.frameSkipThMulQ5 = 0; dynamicParams->rateControlParams.vbvUseLevelThQ5 = 0;
dynamicParams->rateControlParams.maxPicSizeRatioI = 640; dynamicParams->rateControlParams.skipDistributionWindowLength = 5; dynamicParams->rateControlParams.numSkipInDistributionWindow = 2;
//modify SET_MEMB(dynamicParams->sliceCodingParams.sliceCodingPreset, IH264_SLICECODING_USERDEFINED); SET_MEMB(dynamicParams->sliceCodingParams.sliceMode, IH264_SLICEMODE_BYTES); SET_MEMB(dynamicParams->sliceCodingParams.sliceUnitSize, 1200); SET_MEMB(dynamicParams->sliceCodingParams. streamFormat, IH264_BYTE_STREAM); dynamicParams->videnc2DynamicParams.putDataFxn = cbDataSyncPutFxn; dynamicParams->videnc2DynamicParams.putDataHandle = dynamicParams; //modify
return 0;}
Ternence_Hsu:
回复 jack huang5:
你好;
你只需要在
static Int enclink_h264_set_dynamic_params(IH264ENC_DynamicParams *dynamicParams,EncLink_AlgDynamicParams *algDynamicParams)这个函数的最后加上我上面的4行代码就可以了, 用baseline编码,其他什么都不需要修改
jack huang5:
回复 Ternence_Hsu:
只修改enclink_h264_set_dynamic_params也是不行的,我在调用enclink_h264_set_dynamic_params之后调用enclink_h264_print_dynamic_params看到参数是对的,请问有什么调试方法验证吗?怎么确认参数已经正确的设置到编码器的内部?谢谢!
[m3video][m3vpss ] 8265130: SWMS0 : Loading Horizontal Co-effs (UPSCALE)[m3video] ——— CH 0 : H264 ENC : Dynamic Params ——-[m3vpss ] 8265130: SWMS : Co-effs Loading … DONE !!![m3video][m3video] videnc2DynamicParams -> inputHeight : 576[m3video] videnc2DynamicParams -> inputWidth : 704[m3video] videnc2DynamicParams -> refFrameRate : 30000[m3video] videnc2DynamicParams -> targetFrameRate : 30000[m3video] videnc2DynamicParams -> targetBitRate : 1600000[m3video] videnc2DynamicParams -> intraFrameInterval : 1800[m3video] videnc2DynamicParams -> generateHeader : 0[m3video] videnc2DynamicParams -> captureWidth : 1920[m3video] videnc2DynamicParams -> forceFrame : -1[m3video] videnc2DynamicParams -> interFrameInterval : 1[m3video] videnc2DynamicParams -> mvAccuracy : 2[m3video] videnc2DynamicParams -> sampleAspectRatioHeight : 1[m3video] videnc2DynamicParams -> sampleAspectRatioWidth : 1[m3video] videnc2DynamicParams -> ignoreOutbufSizeFlag : 1[m3video] videnc2DynamicParams -> lateAcquireArg : -1[m3video][m3video] rateControlParams -> rateControlParamsPreset : 1[m3video] rateControlParams -> scalingMatrixPreset : 0[m3video] rateControlParams -> rcAlgo : 1[m3video] rateControlParams -> qpI : -1[m3video] rateControlParams -> qpMaxI : 50[m3video] rateControlParams -> qpMinI : 10[m3video] rateControlParams -> qpP : -1[m3video] rateControlParams -> qpMaxP : 50[m3video] rateControlParams -> qpMinP : 10[m3video] rateControlParams -> qpOffsetB : 4[m3video] rateControlParams -> qpMaxB : 44[m3video] rateControlParams -> qpMinB : 10[m3video] rateControlParams -> allowFrameSkip : 0[m3video] rateControlParams -> removeExpensiveCoeff : 0[m3video] rateControlParams -> chromaQPIndexOffset : 0[m3video] rateControlParams -> IPQualityFactor : 0[m3video] rateControlParams -> initialBufferLevel : 160[m3video] rateControlParams -> HRDBufferSize : 160[m3video] rateControlParams -> minPicSizeRatioI : 0[m3video] rateControlParams -> maxPicSizeRatioI : 640[m3video] rateControlParams -> minPicSizeRatioP : 0[m3video] rateControlParams -> maxPicSizeRatioP : 0[m3video] rateControlParams -> minPicSizeRatioB : 0[m3video] rateControlParams -> maxPicSizeRatioB : 0[m3video] rateControlParams -> enablePRC : 0[m3video] rateControlParams -> enablePartialFrameSkip : 0[m3video] rateControlParams -> discardSavedBits : 1[m3video] rateControlParams -> VBRDuration : 8[m3video] rateControlParams -> VBRsensitivity : 0[m3video] rateControlParams -> skipDistributionWindowLength : 5[m3video] rateControlParams -> numSkipInDistributionWindow : 2[m3video] rateControlParams -> enableHRDComplianceMode : 1[m3video] rateControlParams -> frameSkipThMulQ5 : 0[m3video] rateControlParams -> vbvUseLevelThQ5 : 0[m3video][m3video] interCodingParams -> interCodingPreset : 0[m3video] interCodingParams -> searchRangeHorP : 144[m3video] interCodingParams -> searchRangeVerP : 32[m3video] interCodingParams -> searchRangeHorB : 144[m3video] interCodingParams -> searchRangeVerB : 16[m3video] interCodingParams -> interCodingBias : 1[m3video] interCodingParams -> skipMVCodingBias : 1[m3video] interCodingParams -> minBlockSizeP : 0[m3video] interCodingParams -> minBlockSizeB : 0[m3video] interCodingParams -> meAlgoMode : 0[m3video][m3video] intraCodingParams -> intraCodingPreset : 0[m3video] intraCodingParams -> lumaIntra4x4Enable : 0[m3video] intraCodingParams -> lumaIntra8x8Enable : 255[m3video] intraCodingParams -> lumaIntra16x16Enable : 15[m3video] intraCodingParams -> chromaIntra8x8Enable : 15[m3video] intraCodingParams -> chromaComponentEnable : 1[m3video] intraCodingParams -> intraRefreshMethod : 0[m3video] intraCodingParams -> intraRefreshRate : 0[m3video] intraCodingParams -> gdrOverlapRowsBtwFrames : 0[m3video] intraCodingParams -> constrainedIntraPredEnable : 0host] [ 0] 33ms, 7930 -> 16130 129Kbps 0Min[m3video] intraCodingParams -> intraCodingBias : 0[m3video][m3video] sliceCodingParams -> sliceCodingPreset : 1[m3video] sliceCodingParams -> sliceMode : 2[m3video] sliceCodingParams -> sliceUnitSize : 1200[m3video] sliceCodingParams -> sliceStartOffset : [0 0 0][m3video] sliceCodingParams -> streamFormat : 0[m3video][m3video] sliceGroupChangeCycle : 0[m3video] searchCenter : 32767[m3video] enableStaticMBCount : 0[m3video] enableROI : 0[m3video][m3video]host] [ 1] 23ms, 10238 -> 6980 184Kbps 0Minhost] [ 2] 24ms, 9587 -> 443 188Kbps 0Min
[host] 948: IPC_BITS_IN : Stop Done !!![m3video] 8265407: DECODE: Stop in progress !!![m3vpss ] 8265408: SWMS: Stop in Progress !!![m3video] 8265407: DECODE: Stop Done !!!
Ternence_Hsu:
回复 jack huang5:
你参数设置对了,你能发一小段码流,让我分析一下吗?
jack huang5:
回复 Ternence_Hsu:
码流见附件,谢谢!
Ternence_Hsu:
回复 jack huang5:
你好;
从你打印
[m3video] sliceCodingParams -> sliceCodingPreset: 1 [m3video] sliceCodingParams -> sliceMode: 2 [m3video] sliceCodingParams -> sliceUnitSize: 1200可以看出,配置是没有问题的;
当时刚才看你的码流,确实还是单个slice
Ternence_Hsu:
回复 jack huang5:
你好;
这个是我修改过的代码,你对比一下;
会不会你还有其他地方的改动导致的呢 ?
jack huang5:
回复 Ternence_Hsu:
我们的版本不一样,我的是DVRRDK04.01.00.02,编码器是H264ENC_TI DEV.500.V.H264AVC.E.IVAHD.02.00.06.00,附件是代码,是这个编码器不支持吗?还是参数设置的问题?谢谢!