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.

HEVC encoder in with enabled tiles artifacts

Other Parts Discussed in Thread: SYSBIOS

Hi,

I run HEVC 1.0.0.44 encoder on single DSP on 8 cores encoding live SD stream. When tiles are disabled it works perfect (few days of continuous encoding).

When I test the same configuration but with tiles on I get artifacts:

          enableTiles = 1;
          numTileColumns = 2;
          numTileRows = 4;


You can find HEVC elementary streams with tiles disabled and enabled by the following URL:

drive.google.com/.../view


Can you help me find the cause of the artifacts?

Also you can find logs from my application when the tiles are enabled. Strange points there:

1) Many shared memory keys are intended to be used by two users (user_ids=0,1) but in fact keyCreate for the keys is called only on core#0. No corresponding keyCreate calls on core#1:

shmem name=shared_mem_CABAC_Context00 user_id=0 num_users=2 user_ids=0,1 type=DDR_CACHED size=1600 alignment=128
shmem name=shared_mem_CABAC_Context00 user_id=0 num_users=2 user_ids=0,1 type=DDR_CACHED size=1600 alignment=128
shmem name=shared_mem_bitout00 user_id=0 num_users=2 user_ids=0,1 type=DDR_CACHED size=24 alignment=128
shmem name=shared_mem_bitout00 user_id=0 num_users=2 user_ids=0,1 type=DDR_CACHED size=24 alignment=128
shmem name=shared_mem_bitconsumed00 user_id=0 num_users=2 user_ids=0,1 type=DDR_CACHED size=40 alignment=128
shmem name=shared_mem_bitconsumed00 user_id=0 num_users=2 user_ids=0,1 type=DDR_CACHED size=40 alignment=128
shmem name=shared_mem_CABAC_params00 user_id=0 num_users=2 user_ids=0,1 type=DDR_CACHED size=24 alignment=128
shmem name=shared_mem_CABAC_params00 user_id=0 num_users=2 user_ids=0,1 type=DDR_CACHED size=24 alignment=128

etc.


2) Strange shared memory key with only one user:

shmem name=shared_mem_chip2chip user_id=0 num_users=1 user_ids=0 type=DDR_UNCACHED size=816 alignment=128

Regards,

Andrey Lisnevich

  • Hi Andrew,

        It would be better to take newer version of encoder.

    Can you please share the config with which you are observing artifacts.

    Regards

    Kuladeepak

  • Hi Kuladeepak,

    It is the latest official release I know.

    The configuration:

    params.videnc2Params.encodingPreset= XDM_USER_DEFINED;
    params.videnc2Params.rateControlPreset = IVIDEO_STORAGE;
    params.videnc2Params.maxWidth = 704;
    params.videnc2Params.maxHeight = 576;

    params.videnc2Params.dataEndianness = XDM_BYTE;
    params.videnc2Params.maxInterFrameInterval = 1;
    params.videnc2Params.maxBitRate= 600000;
    params.videnc2Params.minBitRate= 600000;
    params.videnc2Params.inputChromaFormat = XDM_YUV_420P;
    params.videnc2Params.inputContentType = IVIDEO_PROGRESSIVE;
    params.videnc2Params.operatingMode = IVIDEO_ENCODE_ONLY;
    params.videnc2Params.profile = IH265_MAIN_PROFILE;
    params.videnc2Params.level = IH265_LEVEL_41;
    params.videnc2Params.inputDataMode = IVIDEO_ENTIREFRAME;
    params.videnc2Params.outputDataMode= IVIDEO_ENTIREFRAME;
    params.videnc2Params.numInputDataUnits = 1;
    params.videnc2Params.numOutputDataUnits= 1;

    int i;
    for (i = 0 ; i < IVIDEO_MAX_NUM_METADATA_PLANES; i++) {
    videnc2Params.metadataType[i] = IVIDEO_METADATAPLANE_NONE;
    }

    params.scalingMatrixPreset = IH265_SCALINGMATRIXPRESET_DEFAULT;
    params.decRefreshType = 0;
    params.decRefreshInterval = 1;
    params.enableTransQuantBypass = 0;
    params.maxPoc = 256;
    params.enableTransformSkip = 0;
    params.maxIntraFrameInterval = 120;
    params.enableWPP = 0;
    params.maxNumRefFrames = 1;
    params.enableVirtualTile = 0;
    params.debugTraceLevel = 0;
    params.lastNFramesToLog = 0;

    params.rateControlParams.rateControlParamsPreset = IH265_RATECONTROLPARAMS_USERDEFINED;
    params.rateControlParams.rcAlgo = 0;
    params.rateControlParams.qpI = -1;
    params.rateControlParams.qpMaxI = 40;
    params.rateControlParams.qpMinI = 12;
    params.rateControlParams.qpP = 28;
    params.rateControlParams.qpMaxP = 51;
    params.rateControlParams.qpMinP = 12;
    params.rateControlParams.qpOffsetB = 4;
    params.rateControlParams.qpMaxB = 51;
    params.rateControlParams.qpMinB = 12;
    params.rateControlParams.enableFrameSkip = 0;
    params.rateControlParams.enablePartialFrameSkip = 0;
    params.rateControlParams.qualityFactorIP = 0;
    params.rateControlParams.cbQPIndexOffset = 2;
    params.rateControlParams.crQPIndexOffset = 2;
    params.rateControlParams.initialBufferLevel = 1200000;
    params.rateControlParams.hrdBufferSize = 1200000;
    params.rateControlParams.enableHRDComplianceMode = 0;
    params.rateControlParams.maxFrameSkipCnt = 0;
    params.rateControlParams.SubFrameRC = 1;
    params.rateControlParams.maxDeltaQP = 0;
    params.rateControlParams.enablePRC = 0;

    params.loopFilterParams.loopFilterParamsPreset = IH265_SLICECODINGPRESET_USERDEFINED;
    params.loopFilterParams.enableDeblockFilter = 1;
    params.loopFilterParams.enableSaoFilter = 1;
    params.loopFilterParams.enableLoopFilterSliceBoundary = 0;
    params.loopFilterParams.enableLoopFilterTileBoundary = 0;
    params.loopFilterParams.separateCbCrSAO = 0;
    params.loopFilterParams.offsetLoopFilterInPPSFlag = 0;
    params.loopFilterParams.offsetDeblockBetaDiv2 = 0;
    params.loopFilterParams.offsetDeblockTcDiv2 = 0;

    params.gopCntrlParams.gopCntrlParamsPreset = IH265_GOPCTRLPRESET_DEFAULT;

    params.sliceCodingParams.sliceCodingPreset = IH265_SLICECODINGPRESET_USERDEFINED;
    params.sliceCodingParams.sliceCodingMode = 0;
    params.sliceCodingParams.sliceCodingArg = 0;
    params.sliceCodingParams.enableTiles = 1;
    params.sliceCodingParams.numTileColumns = 2;
    params.sliceCodingParams.numTileRows = 3;
    params.sliceCodingParams.enableDependentSlice = 0;

    params.intraCodingParams.intraCodingPreset = IH265_INTRACODINGPRESET_USERDEFINED;
    params.intraCodingParams.intraRefreshMethod = 0;
    params.intraCodingParams.intraRefreshRate = 0;
    params.intraCodingParams.constrainedIntraPredEnable = 0;
    params.intraCodingParams.enableStrongIntraSmoothing = 1;
    params.intraCodingParams.matchYCbCrIntraMode = 0;
    params.intraCodingParams.enableLumaIntra4x4Mode = 0;
    params.intraCodingParams.enableLumaIntra8x8Mode = 0;
    params.intraCodingParams.enableLumaIntra16x16Mode = 0;
    params.intraCodingParams.enableLumaIntra32x32Mode = 0;
    params.intraCodingParams.enableChromaIntra4x4Mode = 0;
    params.intraCodingParams.enableChromaIntra8x8Mode = 0;
    params.intraCodingParams.enableChromaIntra16x16Mode = 0;

    params.interCodingParams.interCodingPreset = IH265_INTERCODINGPRESET_USERDEFINED;
    params.interCodingParams.enableTmvp = 0;
    params.interCodingParams.searchRangeHorP = 144;
    params.interCodingParams.searchRangeVerP = 32;
    params.interCodingParams.searchRangeHorB = 144;
    params.interCodingParams.searchRangeVerB = 32;
    params.interCodingParams.interCodingBias = 0;
    params.interCodingParams.skipMVCodingBias = 0;
    params.interCodingParams.numMergeCandidates = 3;
    params.interCodingParams.enableBiPredMode = 0;
    params.interCodingParams.enableFastIntraAlgo = 1;

    params.vuiCodingParams.vuiCodingPreset = IH265_VUICODINGPRESET_DEFAULT;
    params.vuiCodingParams.aspectRatioInfoPresentFlag = 1;
    params.vuiCodingParams.aspectRatioIdc = IH265_ASPECTRATIO_EXTENDED;
    params.vuiCodingParams.videoSignalTypePresentFlag = 0;
    params.vuiCodingParams.videoFormat = 0;
    params.vuiCodingParams.videoFullRangeFlag = 0;
    params.vuiCodingParams.colourDescriptionPresentFlag = 0;
    params.vuiCodingParams.colourPrimaries = 0;
    params.vuiCodingParams.transferCharacteristics = 0;
    params.vuiCodingParams.matrixCoefficients = 0;
    params.vuiCodingParams.timingInfoPresentFlag = 0;

    params.seiParams.enableSeiFlag = 0;

    params.ctbCodingParams.maxCTBSize = 64;
    params.ctbCodingParams.maxCUDepth = 3;

    dynamicParams.videnc2DynamicParams.forceFrame = IVIDEO_NA_FRAME;
    dynamicParams.videnc2DynamicParams.generateHeader = XDM_ENCODE_AU;
    dynamicParams.videnc2DynamicParams.ignoreOutbufSizeFlag = XDAS_FALSE;
    dynamicParams.videnc2DynamicParams.inputWidth = 704;
    dynamicParams.videnc2DynamicParams.inputHeight = 576;
    dynamicParams.videnc2DynamicParams.interFrameInterval = 1;
    dynamicParams.videnc2DynamicParams.intraFrameInterval = 120;
    dynamicParams.videnc2DynamicParams.mvAccuracy = IVIDENC2_MOTIONVECTOR_QUARTERPEL;
    dynamicParams.videnc2DynamicParams.putDataFxn = NULL;
    dynamicParams.videnc2DynamicParams.putDataHandle = 0;
    dynamicParams.videnc2DynamicParams.getDataFxn = NULL;
    dynamicParams.videnc2DynamicParams.getDataHandle = 0;
    dynamicParams.videnc2DynamicParams.getBufferFxn = NULL;
    dynamicParams.videnc2DynamicParams.getBufferHandle = 0;
    dynamicParams.videnc2DynamicParams.refFrameRate = 25000;
    dynamicParams.videnc2DynamicParams.targetFrameRate = 25000;
    dynamicParams.videnc2DynamicParams.sampleAspectRatioWidth = 1;
    dynamicParams.videnc2DynamicParams.sampleAspectRatioHeight = 1;
    dynamicParams.videnc2DynamicParams.targetBitRate = 600000;

    memcpy(&dynamicParams.rateControlParams, &params.rateControlParams, sizeof(params.rateControlParams));
    memcpy(&dynamicParams.loopFilterParams, &params.loopFilterParams, sizeof(params.loopFilterParams));
    memcpy(&dynamicParams.intraCodingParams, &params.intraCodingParams, sizeof(params.intraCodingParams));
    memcpy(&dynamicParams.interCodingParams, &params.interCodingParams, sizeof(params.interCodingParams));
    memcpy(&dynamicParams.ctbCodingParams, &params.ctbCodingParams, sizeof(params.ctbCodingParams));
    memcpy(&dynamicParams.sliceCodingParams, &params.sliceCodingParams, sizeof(params.sliceCodingParams));

    dynamicParams.enableTransQuantBypass = params.enableTransQuantBypass;
    dynamicParams.enableTransformSkip = params.enableTransformSkip;
    dynamicParams.enableROI = 0;

    Regards,
    Andrey Lisnevich
  • Hi Andrew,
       We checked encoder with the given config. We were not able to observe hang nor Artifact.
    One parameter SubFrameRC should be zero when tile is enabled.

    If you still facing issue, Can you share the demo setup. Is this issue is consistent or random.

    Regards
    Kuladeepak

  • Hi Kuladeepak,

    If SubFrameRC should be zero when tile is enabled it is better to validate it and return appropriate error to user.

    With SubFrameRC=0 I still get artifacts but much more less than it was before with SubFrameRC=1.

    Regards,

    Andrey Lisnevich

  • Hi Kuladeepak,

    More evidences on artifacts: hevc_tiles_artifacts

    There you can find screenshots and videos produced by HEVC encoder. out_2_tiles.265 and out_4_tiles.265 are videos with artifacts. out_no_tiles.265 is how the stream should look like without artifacts.


    All 3 streams were produced by the same code, only tiles parameters differ:

    # out_2_tiles.265
    enableTiles = 1;
    numTileColumns = 1;
    numTileRows = 2;

    # out_4_tiles.265
    enableTiles = 1;
    numTileColumns = 2;
    numTileRows = 2;

    # out_no_tiles.265
    enableTiles = 0;
    numTileColumns = 1;
    numTileRows = 1;

    subFrameRC=1 in all the tests. All other parameters are the same as in configuration posted above.

    After multiple run of all the test visually results are the same.

    I will try to share the code of the demo shortly.

    Regards,
    Andrey Lisnevich

  • Hi Andrew,
       I analysed the 265 and Color patch is observed when CU is encoded in inter CU and that to at the tile edge.
    Artifacts are not observed here with multi tile in multi-chip/Single-chip. And you are not using latest code. You can find the latest RTSC package in the below link where package was shared. It would be better check withh latest library.

    Regards
    Kuladeepak

  • Hi Kuladeepak,

    With the latest HEVC 2.0.0.0 my demo just crashes inside encoder's process call. With 1.0.0.44 it works. Can you please check why:

    [C66xx_0] Type: HEVC
    Create encoder buffers
    minNumInBufs 3
    minNumOutBufs 1
    minInBufSize[0] 405504 0
    minInBufSize[1] 101376 0
    minInBufSize[2] 101376 0
    minOutBufSize[0] 456192 0
    Master encoder #1 initialized 704x576@25p
    [C66xx_1] Slave encoder #1 initialized
    [C66xx_2] Slave encoder #1 initialized
    [C66xx_3] Slave encoder #1 initialized
    [C66xx_4] Slave encoder #1 initialized
    [C66xx_5] Slave encoder #1 initialized
    [C66xx_6] Slave encoder #1 initialized
    [C66xx_7] Slave encoder #1 initialized
    process begin
    [C66xx_0] process begin
    [C66xx_1] process begin
    [C66xx_2] process begin
    [C66xx_3] process begin
    [C66xx_4] process begin
    [C66xx_5] process begin
    [C66xx_6] process begin
    [C66xx_3] 2=0x0 A3=0x0
    A4=0x0 A5=0x10000
    A6=0xd0 A7=0x800000
    A8=0x2725200 A9=0x1
    A10=0x90 A11=0x849368
    A12=0x0 A13=0xc361d06
    A14=0x0 A15=0xb
    A16=0x84ac30 A17=0x0
    A18=0x84ac14 A19=0x10
    A20=0x10001 A21=0x10001
    A22=0x10001 A23=0x10001
    A24=0x0 A25=0x0
    A26=0x0 A27=0x300
    A28=0x2 A29=0x4
    A30=0x2 A31=0x1
    B0=0x1 B1=0x0
    B2=0x0 B3=0xc3ade10
    B4=0x0 B5=0xc3da632
    B6=0x11860010 B7=0xc7a
    B8=0x0 B9=0x3cc
    B10=0xc3db6f8 B11=0x90
    B12=0x3 B13=0x1
    B14=0x86ee50 B15=0x84ac30
    B16=0x0 B17=0x19000
    B18=0x0 B19=0x0
    B20=0x0 B21=0x0
    B22=0x0 B23=0x0
    B24=0x5affa6 B25=0x84c00081
    B26=0x0 B27=0x0
    B28=0x0 B29=0x84a7f8
    B30=0x0 B31=0x1
    NTSR=0x1020d
    ITSR=0x420d
    IRP=0xc2f1080
    SSR=0x0
    AMR=0x0
    RILC=0x10
    ILC=0x0
    Exception at 0x0
    EFR=0x2 NRP=0x0
    Internal exception: IERR=0x1
    Instruction fetch exception
    [t=0x0000008e:1e61f093] ti.sysbios.family.c64p.Exception: ERROR: line 256: E_exceptionMax: pc = 0x00000000, sp = 0x0084ac30.
    ti.sysbios.family.c64p.Exception: line 256: E_exceptionMax: pc = 0x00000000, sp = 0x0084ac30.
    xdc.runtime.Error.raise: terminating execution

    The demo should be just run on 8 cores of EVM: 1665.hevc_tiles_artifacts.zip

    Regards,

    Andrey Lisnevich

  • Hi Andrew,

        Crash is happening when "GateMP_enter(gate)" is called in one of the Lock Acquire function.

    Was not able to step in to debug more.

    Regards

    Kuladeepak

  • Hi Kuladeepak,

    Yes it does few successful lockAcquire with GateMP_enter calls on one of the cores and then GateMP_enter do crash.
    Since the same code but compiled with 1.0.0.44 works without crash I suspect memory corruption by HEVC 2.0.0.0 encoder.

    Currently I can't test with latest HEVC encoder.

    Regards,
    Andrey Lisnevich
  • Andrey,

    I did a quick comparison between both version's folder. I noticed few changes in TestApp files. Changes are mainly for new added codec params, buffers and memory sizes. I was wondering if you already took care of these changes.

    Also, for your information, after drop 1.0.0.44 we introduce few changes in our MCSDK video host  demoBufferPools.c in order to enable beyond 1080p. Please see attached file for your reference.

    2133.demoBufferPools.c

    Thank you,

    Paula

  • Hi Paula,

    We have no code from MCSDK Video Demo in our project. We use Video Demo for reference and sometimes use similar approaches.

    The problem is that 1.0.0.44 works with our code (few days of encoding live stream) but 2.0.0.0 crash during first process call. Demo crashes on any resolution. We do SD resolution for simplicity.

    It looks like memory corruption because the same code works with previous version and crash occures in GateMP functionality. We have few issues upcoming and can't resolve them because you ask to integrate 2.0.0.0 that is not working.

    Can you please check why?

    Regards,

    Andrey Lisnevich

  • Hi Andrey Lisnevich,

        Can you please increase the stack size to 0x2500 for both master and slave in ComponentTask.c.

    With these changes latest lib works.

    Regards

    Kuladeepak

       

  • Thanks Kuladeepak,


    It was stack overflow. With your changes HEVC 2.0.0.0 works but artifacts are still there. Good point - there are not so many artifacts as in 1.0.0.44.

    I created for you demo to reproduce:

    3731.hevc_tiles_artifacts.zip

    Run it on 8 cores. Wait for about 100000 words. Pause. Save memory from address 0x98000000 of size in words that are generated to out.265 file.

    Screenshot

    Generated results

    No tiles (reference how it should look): 7433.no_tiles.zip

    8 tiles (with artifacts): 1157.8_tiles.zip

    Regards,

    Andrey Lisnevich

    2 954