rockchip-linux / mpp

Media Process Platform (MPP) module
598 stars 171 forks source link

Questions about HEVC encoder "base:low_delay" #601

Open MarcusMathiassen opened 6 months ago

MarcusMathiassen commented 6 months ago

Hi,

I am trying to get the encoder (on an RK3588) to output as fast as possible. Currently using MPP_TIMEOUT_BLOCK with a MPP_BUFFER_TYPE_EXT_DMA buffer which seems to block for about ~14.5ms before giving me a frame back. I went looking through the Developer Guide and found the "base:low_delay" option (found in the CN version — missing from the EN version though so maybe it is quite a recent addition) and thought it looked interesting.

From what I can tell from the source it looks like we set something like the below:

    mpp_enc_cfg_set_s32(cfg, "base:low_delay", 1);
    mpp_enc_cfg_set_u32(cfg, "split:mode", MPP_ENC_SPLIT_BY_CTU);
    mpp_enc_cfg_set_u32(cfg, "split:arg", 32);
    mpp_enc_cfg_set_u32(cfg, "split:out", MPP_ENC_SPLIT_OUT_LOWDELAY);
    mpp_enc_cfg_set_u32(cfg, "rc:drop_mode", MPP_ENC_RC_DROP_FRM_DISABLED);
    mpp_enc_cfg_set_u32(cfg, "rc:max_reenc_times", 0);
    mpp_enc_cfg_set_u32(cfg, "rc:super_mode", MPP_ENC_RC_SUPER_FRM_NONE);

It enables both a low_delay_part_mode and low_delay_output flag that gets used during encoding. Now exactly how one uses it I am not sure.

Is there any more information about it? Or example to look at? Also would this be the way to get the lowest possible latency or are there other things to consider as well?

Thanks, Marc

HermanChen commented 4 months ago

The low-delay mode is a special mode for jpeg slice encoding. The input jpeg can be splited into several segment, encoded one by one and output each segment when it finished.

If you want to get data quickly you can use split mode in mpi_enc_test with split:out set to MPP_ENC_SPLIT_OUT_LOWDELAY