H265 Encoding Little QP values failing

Hello,
I am writing some research paper on h265 Encoding on Jetson XAVIER NX. We are comparing encoding from XAVIER NX hardware encoder with a reference implementation of h265 software encoding. We are working with constant QP values.

It seems XAVIER NX encoding has some problems with little QP values. At first it matches the reference, then it gets worse.

RDXavier646

Maybe it is some configuration problem? I am using NvEncoder CPP class.

This is my function in which I create and configure the encoder.


#define SET_HW_PRESET
#define SET_PROFILE
#define NVBUFFER_FMT NvBufferColorFormat_NV12_10LE
#define INPUT_V4L2_FMT V4L2_PIX_FMT_P010M
#define ENCODER_PROFILE V4L2_MPEG_VIDEO_H265_PROFILE_MAIN10

bool Encoder::createVideoEncoder(float fps, int width, int height, int QP) {
    int ret = 0;

    m_VideoEncoder = NvVideoEncoder::createVideoEncoder("enc0");
    if (!m_VideoEncoder)
        ORIGINATE_ERROR("Could not create m_VideoEncoderoder");

    ret = m_VideoEncoder->setCapturePlaneFormat(ENCODER_PIXFMT, width,
                                                height, 2 * 1024 * 1024);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set capture plane format");


    ret = m_VideoEncoder->setOutputPlaneFormat(INPUT_V4L2_FMT, width,height);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set output plane format");
    

    ret = m_VideoEncoder->setFrameRate(int(fps*100), 100);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set m_VideoEncoderoder framerate");

#ifdef SET_HW_PRESET
    ret = m_VideoEncoder->setHWPresetType(V4L2_ENC_HW_PRESET_SLOW);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set m_VideoEncoderoder HW Preset");
#endif

#ifdef SET_PROFILE
    ret = m_VideoEncoder->setProfile(ENCODER_PROFILE);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set m_VideoEncoderoder profile");
#endif

    ret = m_VideoEncoder->setIFrameInterval(30);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set I-frame interval");

    std::cout << "QP: " << QP << std::endl;

    ret = m_VideoEncoder->setConstantQp(QP);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set constant qp");

    ret = m_VideoEncoder->setNumReferenceFrames(1);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set number of reference frames");

    ret = m_VideoEncoder->setInsertVuiEnabled(true);
    if (ret < 0)
        ORIGINATE_ERROR("Could not set m_VideoEncoderoder InsertVui");

    /* Query, Export and Map the output plane buffers so that we can read
       raw data into the buffers */
    //ret = m_VideoEncoder->output_plane.reqbufs(V4L2_MEMORY_DMABUF,5);
    ret = m_VideoEncoder->output_plane.setupPlane(V4L2_MEMORY_DMABUF, 5, true, false);
    if (ret < 0)
        ORIGINATE_ERROR("Could not setup output plane");

    /* Query, Export and Map the output plane buffers so that we can write
       m_VideoEncoderoded data from the buffers */
    ret = m_VideoEncoder->capture_plane.setupPlane(V4L2_MEMORY_MMAP, 6, true, false);
    if (ret < 0)
        ORIGINATE_ERROR("Could not setup capture plane");

    printf("create video encoder return true\n");
    return true;
}

You have any idea what could be configured wrong?

Best regards,
jb

Hi,
Please check if the issue can be reproduced by running 01_video_encode sample. If yes, please share the command so that we can set up and try.

And for information, do you use Jetpack 4.6.4 or 5.1.1?

./video_encode ~/EncodeHSIImages/project/HSI_test_images/2022_44x64yuv420_10bituint16_msb_aligned.yuv 512 512 H265 /home/jetson/haip2022.h265 -p main10 --insert-vui -MinQpI 0 -MaxQpI 0 -MinQpB 0 -MaxQpB 0 -MinQpP 0 -MaxQpP 0 -hpt 4 -l high6.2 -bd 10

R32 (release), REVISION: 6.1, GCID: 27863751, BOARD: t186ref, EABI: aarch64, DATE: Mon Jul 26 19:36:31 UTC 2021

Hi,
Please set min QP to 1 and max QP to 2. In the setup, all framea are quamtized in QP=1. Please check if you can get expected result in the setup.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.