From fba807bead7f522ce914f6bf7a3c9ffb84b810fd Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Thu, 28 Jan 2021 04:03:37 +0900 Subject: [PATCH] nvh264sldec: Add support for output-delay to improve throughput performance NVDEC API support delaying getting decoded output, and recommended delay by API document is 4 frames. In case that throughput is more critical factor than latency, we can prefer delayed output as recommended by NVIDIA. Part-of: --- sys/nvcodec/gstnvh264dec.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/nvcodec/gstnvh264dec.c b/sys/nvcodec/gstnvh264dec.c index 8c33cd7cc0..1b7bbd81e6 100644 --- a/sys/nvcodec/gstnvh264dec.c +++ b/sys/nvcodec/gstnvh264dec.c @@ -156,6 +156,9 @@ static gboolean gst_nv_h264_dec_decode_slice (GstH264Decoder * decoder, GArray * ref_pic_list1); static gboolean gst_nv_h264_dec_end_picture (GstH264Decoder * decoder, GstH264Picture * picture); +static guint +gst_nv_h264_dec_get_preferred_output_delay (GstH264Decoder * decoder, + gboolean live); static void gst_nv_h264_dec_class_init (GstNvH264DecClass * klass) @@ -194,6 +197,8 @@ gst_nv_h264_dec_class_init (GstNvH264DecClass * klass) GST_DEBUG_FUNCPTR (gst_nv_h264_dec_decode_slice); h264decoder_class->end_picture = GST_DEBUG_FUNCPTR (gst_nv_h264_dec_end_picture); + h264decoder_class->get_preferred_output_delay = + GST_DEBUG_FUNCPTR (gst_nv_h264_dec_get_preferred_output_delay); GST_DEBUG_CATEGORY_INIT (gst_nv_h264_dec_debug, "nvh264dec", 0, "Nvidia H.264 Decoder"); @@ -780,6 +785,18 @@ gst_nv_h264_dec_end_picture (GstH264Decoder * decoder, GstH264Picture * picture) return ret; } +static guint +gst_nv_h264_dec_get_preferred_output_delay (GstH264Decoder * decoder, + gboolean live) +{ + /* Prefer to zero latency for live pipeline */ + if (live) + return 0; + + /* NVCODEC SDK uses 4 frame delay for better throughput performance */ + return 4; +} + typedef struct { GstCaps *sink_caps;