Low latency with h264_cuvid in ffmpeg

hi, I used h264_cuvid to decode h264. but I find 5 frame latency, and then I change ffmpeg(cuviddec.c)
from
ctx->cuparseinfo.ulMaxDisplayDelay = 4;
to
ctx->cuparseinfo.ulMaxDisplayDelay = 0;
now it with 1 frame delay,I used h264(cpu) for decode,it with 0 frame delay.
search for the forums,I find the CUVID_PKT_ENDOFSTREAM,and force set it.it will always display the first frame.
but if I add

static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt)
{
	......
	if (avpkt && avpkt->size) {

		cupkt.payload_size = avpkt->size;

		cupkt.payload = avpkt->data;

		if (avpkt->pts != AV_NOPTS_VALUE) {

			cupkt.flags = CUVID_PKT_TIMESTAMP;

			if (avctx->pkt_timebase.num && avctx->pkt_timebase.den)

				cupkt.timestamp = av_rescale_q(avpkt->pts, avctx->pkt_timebase, (AVRational){1, 10000000});

			else

				cupkt.timestamp = avpkt->pts;

		}

	} else {

		cupkt.flags = CUVID_PKT_ENDOFSTREAM;

		ctx->decoder_flushing = 1;

	}
            // I add (cupkt.flags = CUVID_PKT_ENDOFSTREAM;) here
	ret = CHECK_CU(ctx->cvdl->cuvidParseVideoData(ctx->cuparser, &cupkt));
	......
}