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.

dm36x H264 encoder

Is it possible to set custom resolution, e.g. 712x570 to h264 encoder?

  • Hi,

    Which software are you using and what is you encoder version?

  • I use H.264 Base/Main/High Profile Encode Version 02.30.00.06 (Dec 2012) and DMAI

    I try to put in encoder buffer with 712x570 frame. If I set dimensions to 712x570 -> encoder crashing, if I set 720 x 576 it works, but image is like this

  • Can you share all the encoder parameters?

  • params->maxWidth = envp->imageWidth; //720
    params->maxHeight = Dmai_roundUp(envp->imageHeight, CODECHEIGHTALIGN); //576
    params->inputChromaFormat = XDM_YUV_420SP;
    params->reconChromaFormat = XDM_YUV_420SP;
    params->maxFrameRate = envp->videoFrameRate; //25000
    params->encodingPreset = XDM_USER_DEFINED; 
    params->rateControlPreset = IVIDEO_USER_DEFINED;
    params->maxBitRate = 8000000;
    
    dynParams->targetBitRate = envp->videoBitRate*0.9;
    dynParams->inputWidth = envp->imageWidth; // 720 or 712
    dynParams->inputHeight = envp->imageHeight; // 576 or 570
    dynParams->captureWidth = Dmai_roundUp(BufferGfx_calcLineLength(envp->imageWidth, colorSpace), 32);
    dynParams->refFrameRate = params->maxFrameRate;
    dynParams->targetFrameRate = params->maxFrameRate;
    dynParams->intraFrameInterval = 0;
    dynParams->interFrameInterval = 0;
    
    h264Params.videncParams = *params;
    h264Params.videncParams.size = sizeof(IH264VENC_Params);
    
    h264Params.encQuality = 1;
    h264Params.transform8x8FlagIntraFrame = 1;
    h264Params.transform8x8FlagInterFrame = 1;
    h264Params.numTemporalLayers = 0;
    h264Params.outputDataMode = IH264VENC_TI_ENTIREFRAME; 
    h264Params.sliceFormat = IH264VENC_TI_BYTESTREAM; 
    h264Params.EnableLongTermFrame = 0; 
    h264Params.entropyMode = 1;
    h264Params.enableVUIparams = (0x1 << 1); 
    
    h264DynParams.videncDynamicParams = *dynParams;
    h264DynParams.videncDynamicParams.size = sizeof(IH264VENC_DynamicParams);
    
    h264DynParams.VUI_Buffer = &VUI_Buffer;
    h264DynParams.VUI_Buffer->aspectRatioInfoPresentFlag = 1;
    h264DynParams.VUI_Buffer->overscanInfoPresentFlag = 0;
    h264DynParams.VUI_Buffer->videoSignalTypePresentFlag = 0;
    h264DynParams.VUI_Buffer->timingInfoPresentFlag = 1;
    h264DynParams.VUI_Buffer->numUnitsInTicks = 1;
    h264DynParams.VUI_Buffer->timeScale = params->maxFrameRate / 1000;
    h264DynParams.VUI_Buffer->fixedFrameRateFlag = 1; 
    h264DynParams.VUI_Buffer->nalHrdParameterspresentFlag = 1;
    h264DynParams.VUI_Buffer->picStructPresentFlag = 1;
    
    // Recommended values
    h264DynParams.initQ = -1;
    h264DynParams.rcQMin = 4;
    h264DynParams.rcQMinI = 4;
    h264DynParams.rcQMax = 44;
    h264DynParams.rcQMaxI = 40;
    
    h264DynParams.resetHDVICPeveryFrame = 0; 
    h264DynParams.maxDelay = gblGetDelay();
    h264DynParams.idrFrameInterval = 15;
    h264DynParams.rcAlgo = 1;
    
    hVe1 = Venc1_create(envp->hEngine, envp->videoEncoder, (IVIDENC1_Params *) &h264Params, (IVIDENC1_DynamicParams *) &h264DynParams);

    And this is graphic buffer param:

    BufferGfx_calcDimensions(videoStd, colorSpace, &gfxAttrs.dim); // colorspace is yuv420sp
    gfxAttrs.dim.width = 720; // or 712
    gfxAttrs.dim.height = 576; // or 570
    gfxAttrs.dim.lineLength = Dmai_roundUp(BufferGfx_calcLineLength(gfxAttrs.dim.width, colorSpace), 32); // for 712x570 it calc linelength = 736
    gfxAttrs.colorSpace = colorSpace; // yuv420sp
    bufSize = gfxAttrs.dim.lineLength * gfxAttrs.dim.height * 3 / 2; //but i have frame which size is 712 * 570 * 3 / 2
    
    hVideoBufTab = BufTab_create(NUM_CAPTURE_BUFS, bufSize, BufferGfx_getBufferAttrs(&gfxAttrs));

  • Hi,

    1.W.r.t snap shot, it seems like pitch is going wrong.
    2. Encoder should throw an error saying unsupported width/height. It shouldn't crash. You can refer the sample test application provided with your encoder package. Or try setting the resolution you want in sample test application.
    3. Please use encQuality =0/2/3
  • Now Im writing realtime loopback sample app with DEI. After that Ill try to write this sample with encoding.
    Why you not recomend to use encQuality = 1 ? encQuality = 1- version 1.1, backward compatible
    with improved video quality mode. This flag was added at last version of codec.
  • Okay,
    For encQuality=2 gives you better quality compared to encQuality = 1.

  • I wrote test application without encoding. It has some issues and it display wrong image. Now I trying to get correct frames after DEI in realtime. Here are sources github.com/.../videoloop_dei
  • Hi,

    Could you try with the sample test application provided with the codec? It will give you correct frames. You can take it as a reference.

  • Hi,
    Finaly I finished simple videoloop app. Problem was in Display buffer. It needs linelength width is divided 32.

    Dmai_roundUp(BufferGfx_calcLineLength(gfxAttrs.dim.width, colorSpace), 32);

    for 712 it returning 736. I cutted off frame and got resolution 704x570. I think if I give to encoder 704x570 frame, it will work fine.

  • Hi,

    Nice to know it got resolved.

    As said earlier it was pitch issue. Width of input frame in pixels. Input width can be changed before the start of encoding within the
    limits of maximum width set in creation phase. inputWidth must be multiples of two. Please refer user guide for more details.