We are using the 1080P H264 encoder (h264fhdvenc) but have encountered the same problem with the 720P version (h264enc). Every few minutes, there will be some subtle corruption in one of the frames (as if a reference frame was lost or not updated), and then the errors will begin to diverge and become very noticeable. Depending on source content, the artifacts will often appear as very pronounced zebra patterns, and will not clear up until the next I-frame. Unfortunately, In our application, we can only afford to send I-frames at very infrequent intervals.
The frequency of encountering this error pattern depends on factors such as CPU and memory usage, but we just recently discovered a very strong correlation with the AAC audio encoder. Initially we had been testing with the default AAC mode (HEv2) and this was not a problem. However, some of our customers prefer to send two independent mono channels instead of a stereo pair, and this requires use of either the AAC HE or dual-mono mode. Unfortunately, the use of either of these two modes will result in video corruption at frequent intervals.
We are still testing and will need more time to determine if the AAC HEv2 mode successfully avoids video corruption in all of our usage configurations, and since we have made many adjustments during recent weeks, we will need to reevaluate which of these changes may also be helping the situation. Meanwhile, we have the following questions:
1. How can we prevent video corruption when using the AAC audio encoder in HE or dual-mono mode?
2. The h264fhdvenc encoder automatically inserts an I-frame after 32768 frames. Is there a way to prevent this?
3. The latest version of the h264fhdvenc encoder appears to be 01.10.02.06 but we cannot test this version without encountering the same problem discussed in this thread:
http://e2e.ti.com/support/embedded/multimedia_software_codecs/f/356/t/207461.aspx
The thread is supposed to have been answered but apparently nobody knows what the answer is. Do you think that this new version might address some of the problems that we have encountered?
h264fhdvenc encoder: 01.10.02.03
h264enc encoder: 1.20.02.00
AAC audio encoder: 1.20.005
Codec Server: 1.00.00.10
Codec Engine: 2.25.05.16
dsplinkk 1.65.02.09
Our current video encoder settings are listed below, but we have experimented with many of them and detected no effect on the video corruption problem.
void H264VENC_setinitparams(IH264VENC_Params *params) {
memset(params, 0, sizeof(IH264VENC_Params));
memcpy(¶ms->videncParams, &Venc1_Params_DEFAULT, sizeof(Venc1_Params_DEFAULT));
params->videncParams.encodingPreset = 0; //XDM_HIGH_SPEED;
params->videncParams.maxBitRate = 20000000;
params->videncParams.maxFrameRate = MAX_FRAMERATE*1000;
params->videncParams.maxHeight = 1088;
params->videncParams.maxWidth = 1920;
params->videncParams.rateControlPreset = IVIDEO_LOW_DELAY;
params->videncParams.dataEndianness = XDM_LE_32;
params->videncParams.maxInterFrameInterval = 0;
params->videncParams.inputChromaFormat = XDM_YUV_420SP;
params->videncParams.inputContentType = IVIDEO_PROGRESSIVE;
params->videncParams.reconChromaFormat = XDM_CHROMA_NA;
params->profileIdc = 77; // 100 high profile // 77 main profile // 66 base profile
params->levelIdc = 42; // level indication
params->EntropyCodingMode = 1; // 1 for CABAC
params->METype = 1;
params->ScalingMatType = 0;
params->ScalingFactor = 0;
params->videncParams.size = sizeof(IH264VENC_Params);
}
void H264FHDVENC_setrunparams(IH264FHDVENC_DynamicParams *params) {
memset(params, 0, sizeof(IH264FHDVENC_DynamicParams));
params->videncDynamicParams.inputHeight = MAX2_YSIZE;
params->videncDynamicParams.inputWidth = MAX_XSIZE;
params->videncDynamicParams.generateHeader = XDM_ENCODE_AU;
params->videncDynamicParams.forceFrame = IVIDEO_NA_FRAME;
params->videncDynamicParams.refFrameRate = MAX_FRAMERATE*1000;
params->videncDynamicParams.targetFrameRate = MAX_FRAMERATE*1000;
params->videncDynamicParams.targetBitRate = 2000000;//128000;
params->videncDynamicParams.captureWidth = 0;
params->videncDynamicParams.intraFrameInterval = 0; //30
params->videncDynamicParams.interFrameInterval = 1;
params->videncDynamicParams.mbDataFlag = 0;
params->videncDynamicParams.size = sizeof(IH264FHDVENC_DynamicParams);
params->OutBufSize = -1; // Size of the Output Buffer
params->QPISlice = 28; // Quant. param for I Slices (0-51)
params->QPSlice = 28; // Quant. param for non I Slices (0-51)
params->RateCtrlQpMax = 51; // Qp range max for Rate Control (Max: 51)
params->RateCtrlQpMin = 0; // Qp range min for Rate Control (Min: 0)
params->NumRowsInSlice = 0; // Number of MB rows in a Slice
// loop filter
params->LfDisableIdc = 1; // Loop Filter enable/disable control
params->LFAlphaC0Offset = 0; // Alpha & C0 offset div. 2, {-6, -5, ... 0, +1, .. +6}
params->LFBetaOffset = 0; // Beta offset div. 2, {-6, -5, ... 0, +1, .. +6}
params->ChromaQPOffset = 0; // Chroma QP offset (-12..12)
params->SecChromaQPOffset = 0; // Second Chroma QP offset (-12..12)
params->PicAFFFlag = 0; // Picture Adaptive Frame/Field
params->PicOrderCountType = 0; //IH264FHDVENC_POC_TYPE_0; // POC type
params->AdaptiveMBs = 0; // Number of the adaptive I MBs
params->SEIParametersFlag = 0; // XDAS_TRUE will give the SEI parameters
params->VUIParametersFlag = 0; // XDAS_TRUE will give the VUI parameters
params->VUIData.buf = NULL; //(XDAS_Int8 *)&vui_params; // pass pointer of vui structure
params->NALUnitCallback = 0; //callback_func; // can't get this to work
params->SkipStartCodesInCallback = 1; //0; // XDAS_TRUE will remove start codes from NAL in callback
params->Intra4x4EnableFlag = IH264FHDVENC_4x4_IP_FRAME; // 0 = NONE, 1 = I Frame, 2 = P, 3 = IP
params->BlockingCallFlag = 0; // Enable blocking calls support
params->MESelect = IH264FHDVENC_ME1080i; // ME algorithm control
//params->MESelect = IH264FHDVENC_ME720p; // ME algorithm control
params->ME1080iMode = IH264FHDVENC_PREDICTABLE_DMA; // IH264FHDVENC_HIGH_VIDEO_QUALITY
//params->ME1080iMode = IH264FHDVENC_HIGH_VIDEO_QUALITY;
params->MVDataFlag = 0; // Flag to generate MV and SAD Data
params->Transform8x8DisableFlag = 1; // 0 = Enabled, 1 = Disabled
params->Intra8x8EnableFlag = 0; // 0 = NONE, 1 = I Frame, 2 = P, 3 = IP
params->InterlaceReferenceMode = IH264FHDVENC_ONE_FIELD_DEFAULT; // 0 = One Default, 1 = Two Default, 2 = MRCF, 3 = Adaptive
params->ChromaConversionMode = IH264FHDVENC_CCV_LINEDROP; // 0 = line drop, 1 = Average
params->maxDelay = 1000; // maximum delay in ms
params->MaxSlicesSupported = 1; // maximum number of slices supported
//params->MaxSlicesSupported_IFrame = 1; // maximum number of slices supported
//params->MaxSlicesSupported_PFrame = 1; // maximum number of slices supported
params->sliceCodingParams.sliceUnitSize = 0; //1500; // Maximum size of the slice to be encoded
params->sliceCodingParams.sliceMode = 0; // No slice 2 = Slice based on packet size
params->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_DEFAULT;
params->sliceCodingParams.streamFormat = IH264_BYTE_STREAM;
params->sliceCodingParams.sliceStartOffset[0] = 0;
}