This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C66x H.264 encoder output with rcAlgo = CBR

Hello,

When I set rcAlgo = 1 [CBR (Constant Bit Rate) rate control algorithm (frame skips enabled)] I get corrupted output - check cbr.264 file.

When rcAlgo is set to 0 [VBR] or 2 [Constrained CBR (Constant Bit Rate) rate control algorithm (frame skips disabled)] I get good output using the same code - check vbr.264 file.

Can you help to get correct H.264 stream in CBR mode?

Configuration is:

# General
entropyCodingMode = 1; # 0: CAVLC, 1: CABAC (for HP and MP only)
gopStructure = 0; # 0: NONUNIFORM = IBBPBBP, 1: UNIFORM = BBIBBPBB
IDRFrameInterval = 2; #  0: Only first I frame as IDR, 1: All I frames are IDR, 2: 1 out of 2 I frames are IDR starting from first I frame
transformBlockSize = 0; #  Transform blocks size. 0: 4x4, 1: 8x8 (valid for HP only), 2: adaptive - encoder decides as per content
log2MaxFNumMinus4 = 10; #  Limits the maximum frame number in the bit-stream to (1<< (log2MaxFNumMinus4 + 4)) Range[0,12]
picOrderCountType = 0; #  POC type: 0, 1, 2
interlaceCodingType = 4; # 0: PICAFF (not supported), 1: MBAFF (not supported), 2: FIELDONLY_MRF, 3: FIELDONLY_ARF, 4: FIELDONLY_SPF (adaptive)

encodingPreset = 3; # 0: DEFAULT, 1: HIGH_QUALITY, 2: HIGH_SPEED, 3: USER_DEFINED. If not USER_DEFINED most of configuration parameters are chosen by encoder, thus ignored.
rateControlPreset = 5; #  1: LOW_DELAY,  2: STORAGE, 4: NONE,  5: USER_DEFINED
maxWidth = 720;
maxHeight = 576;
maxInterFrameInterval = 3; #  Max I to P frame distance. 1: no B frames, 2: one B frame, 3: two B frames, etc [1, 255]
maxBitRate = 747000; # In bits per second. Should be valid as per LEVEL limit
minBitRate = 0; # In bits per second
profile = 77; # 66: BASELINE, 77: MAIN, 100: HIGH
level = 30; # 9: 1b, 10: 1.0, 11: 1.1, 12, 13, 20: 2.0, 21, 22, 30, 31, 32, 40, 41, 42, 50, 51

# Rate control
rateControlParamsPreset = 1; # 0: Default, 1: User defined
rcAlgo = 1; # Rate control algorithm used, 0: Variable Bitrate, 1 : Constant bitrate (low dealy), 2: Constrained CBR (No Frame Skips). Useful only if rateControlPreset is set to USER_DEFINED
qpI = -1; # Initial QP for I/IDR frames, -1 indicates codec chosen
qpP = -1; # Initial QP for P frames
qpOffsetB = 4; # Offset of B frames QP from P frames
qpMaxI = 30; # Maximum QP for I/IDR frames
qpMinI = 10; # Minimum QP for I/IDR frames
qpMaxP = 40; # Maximum QP for P frames
qpMinP = 10; # Minimum QP for P frames
qpMaxB = 40; # Maximum QP for B frames
qpMinB = 10; # Minimum QP for B frames
# For Baseline and Main profiles CbQPIndexOffset and CrQPIndexOffset should be equal
CbQPIndexOffset = 0; # Specifies offset to be added to luma QP for addressing QPC values table for Cb components
CrQPIndexOffset = 0; # Specifies offset to be added to luma QP for addressing QPC values table for Cr components
initialBufferLevel = 250000; # Initial Buffer level for HRD compliance, keep same as HRDBufferSize for best quality
HRDBufferSize = 250000; # Hypothetical Reference Decoder Buffer Size in bits - 2*bitrate for VBR, 1⁄2*targetBitRate for CBR
enablePRC = 1; # Control Flag to enable MB level Perceptual Rate Control, 0 => Disable, 1 => Enable
frameSkipAfterSceneChange = 1; # 0=> no forced skip after scenechange, 1 => force skip frame after coding scene change frame.
scalingMatrixPreset = 0; # Scaling Matrix selection of encoder avaliable in HP only, 0: no scaling matrices, 1: normal, 2: noisy, 3 : standard default, 4 : user defined

# Inter coding
interCodingPreset = 1; # Inter coding mode preset, 0 => deafult values, 1 => user defined
MvRangeVerP = 32; # Vertical Motion Vector Range for P frames in integer pixels, Range supported is 16 to 496
MvRangeHorP = 144; # Horizontal Motion Vector Range for P frames in integer pixels, Range supported is 16 to 496
MvRangeVerB = 32; # Vertical Motion Vector Range for B frames in integer pixels, Range supported is 16 to 496
MvRangeHorB = 144; # Horizontal Motion Vector Range for B frames in integer pixels, Range supported is 16 to 496
maxMVperMB = 4; # Maximum MV per MB (Values of 1 & 4 are valid)

# Intra coding
intraCodingPreset = 1; # Intra coding mode preset, 0 => deafult values, 1 => user defined
enableIntraPartition = 4; # 0 => INTRA_PARTITION_NONE , 1 => INTRA_PARTITION_ISLICES, 2 => INTRA_PARTITION_IPSLICES, 3 => INTRA_PARTITION_IBSLICES, 4 => INTRA_PARTITION_IPBSLICES.
intraRefreshMethod = 1; # IH264_INTRAREFRESH_NONE  = 0, IH264_INTRAREFRESH_CYCLIC_MBS = 1
intraRefreshRate = 0; # Rate at which intra MB Refresh is done. e.g. 10 indicates every 10th MB will coded as Intra in inter pictures.
constrainedIntraPredEnable = 0; # Controls the intra macroblock coding in inter slices

# Slice coding
sliceCodingPreset = 0; # Preset value for slice coding mode, 0 => deafult values, 1 => user defined
streamFormat = 0; # Type of bitstream to be encoded. Only value 0 is supprted (Byte stream format)
sliceMode = 0; # Type of slice coding, 0 => slice coding mode is frame based, 1 => Slices are controlled based upon number of Macroblocks
sliceUnitSize = 0; # Number of macroblocks per slice

# Loop filter
loopfilterPreset = 1; # Preset value for loop filter operation parameters, 0 => default values, 1 => user defined
loopfilterDisableIDC = 0; # Disable H.264 loop filter, (0=Filter, 1= NoFilter, 2 = No loop filter across slices)
filterOffsetA = 0; # Alpha offset for loop filter
filterOffsetB = 0; # Beta offset for loop filter

# VUI coding
vuiCodingPreset = 1; # Preset value for VUI Control Params, 0 => deafult values, 1 => user defined
aspectRatioInfoPresentFlag = 1; # Controls the insertion of aspect ratio information in VUI part of bit-stream
aspectRatioIdc = 255; # Aspect ratio ID. See IH264HPVENC_AspectRatioIdc. IH264HP_ASPECTRATIO_EXTENDED = 255 for dynamic aspect ratio.
videoSignalTypePresentFlag = 0; # controls the insertion of video signal type in VUI part of bit-stream
videoFormat = 2; # Video signal type, 0: Component, 1: PAL, 2: NTSC, 3: SECAM, 4: MAC, 5: Unspecified
videoFullRangeFlag = 0; # Flag to specify Range of the pixels
colourDescriptionPresentFlag = 1; # Specifies whether colour_primaries, transfer_characteristics and matrix_coefficients are present or not.
colourPrimaries = 5; # chromaticity coordinates of the source primaries(Table E-3 in standard)
transferCharacteristics = 5; # opto-electronic transfer characteristic of the source picture(Table E-4 in standard)
matrixCoefficients = 5; # matrix coefficients used in deriving Y,Cb,Cr signals from the G,B,R primaries(Table E-5 in standard)
timingInfoPresentFlag = 1; # Controls the insertion of timing info related parameters in VUI part of bit-stream

# Dynamic
intraFrameInterval = 6; # The number of frames between two I frames. 0: IPPPP..., 1: IIII..., 2: IPIPIPIPI, 3: IPPIPPIPPI or IPBIPBIPBI, etc.
mvAccuracy = 0; # Motion vectors accuracy. 0: integer pel., 2: quarter pel.
sampleAspectRatioWidth = 1;
sampleAspectRatioHeight = 1;
bitRate = 747000;
interFrameInterval = 3; #  Max I to P frame distance. 1: no B frames, 2: one B frame, 3: two B frames, etc [1, 255]
frameRate = 25;
width = 720;
height = 576;

Regards,

Andrey Lisnevich

h264.zip
  • Hi Andrey,

    We have the following suggestions at high level, for your configurations:

    Here we have observed lot of frequent skip frames continuously which degrades quality significantly.

    When we use CBR configuration with low bit rate for non-videoconferencing streams, it will be better to have relaxation with intra frame interval, hrd buffer size etc.

    Instead of 6, please check with intraframe interval 96.

    Even for CBR case also, you can have HRD buffer size as  2* target bit rate.

    MV accuracy can be quarter pel.

    I will update soon with more inputs after taking a close look at the issue.

    Regards

    Sudheesh

  • Hi,

    I know about HRD buffer and intraframe interval. I set Intraframe interval to 6 for testing to see GOP structure when frames are skipping.

    But problem is not in quality - image is shaking back and forward. Looks like H.264 stream is corrupted.

    Regards,

    Andrey Lisnevich

  • Hi Andrey,

    We are currently working on this issue and it seems we need some more time to fix the issue.

    Thanks and regards

    Sudheesh

  • Hi Andrey,

    We have found issue with CBR sequence when frameskip comes at B frame.

    It is fine if there are no frameskips at B frames.

    We are trying to resolve this issue.

    Regards

    Sudheesh

  • Hi Andrey, when you have an opportunity could you please try attached lib?

    Attached library (not final version)  contains fix for

    1. Skip frame issue – Image shaking issue
    2. I frame flickering – Image flickering issue

     Still we are doing some testing but please let us know how it works in your side.

    2072.h264hpvenc_ti.le66

    Thank you,

    Paula

  • Andrey, a quick note, please try above lib with gopStructure = 0

    thank you,

    Paula