mpp icon indicating copy to clipboard operation
mpp copied to clipboard

Reduce H265 decoding latency

Open gehee opened this issue 1 year ago • 8 comments

Hi,

I am using a modified version of mpi_dec_mt_test.c to decode a zerolatency H265 rtp stream and I am getting ~11ms in average between decode_put_packet and decode_get_frame. dmesg rkvdec log is showing 1000 us for the decode time. I am not using zero-copy buffer yet and I know it can reduce the time to display the frame, but what can be done to reduce the latency between decode_put_packet and decode_get_frame ?

gehee avatar Dec 28 '23 15:12 gehee

Do you check the packet and frame with the same pts? And also the stream reroder feature may effect the frame output order. Try control IMMEDIATE_OUT for decoding order output.

HermanChen avatar Dec 29 '23 01:12 HermanChen

the stream I am decoding does not have PTS, but I am comparing the POC values for when it's received vs when I get the frame back. It's a zero latency preset so the stream only has the following NALUs: VPS,SPS,PPS,IDR,non-IDR,non-IDR,.......VPS,SPS,PPS,IDR,non-IDR, non-IDR... etc.

Setting MPP_DEC_SET_IMMEDIATE_OUT had not impact on the decoding time, but removing MPP_DEC_SET_PARSER_SPLIT_MODE did. It went from 11ms to <3ms !!!

gehee avatar Dec 30 '23 03:12 gehee

If you can split the stream into a packet with the whole frame then you can set MPP_DEC_SET_PARSER_SPLIT_MODE to zero.

HermanChen avatar Jan 02 '24 00:01 HermanChen

I mean split the stream before put_packet

HermanChen avatar Jan 02 '24 00:01 HermanChen

Thanks @HermanChen; if my stream has multiple slices per frame, how should I format the MppPackets to avoid enabling MPP_DEC_SET_PARSER_SPLIT_MODE?

I have tried sending the whole frame in a single MppPacket, using one nal unit per slice with the 0001 prefix but mpp does not like it.

gehee avatar Mar 19 '24 02:03 gehee

Just enable MPP_DEC_SET_PARSER_SPLIT_MODE and send packet by slice or by length. Refer to mpi_dec_test or mpi_dec_mt_test.

HermanChen avatar Mar 19 '24 03:03 HermanChen

I am enabling slice to reduce glass to glass latency; If I enable MPP_DEC_SET_PARSER_SPLIT_MODE the latency is too high so I am trying to avoid it. Is there no other way?

gehee avatar Mar 19 '24 11:03 gehee

The hardware driver supports only frame by frame decoding so all slice in one frame should be all collected then start the hardware decoding.

HermanChen avatar Mar 20 '24 01:03 HermanChen