nvcodec: nv{vp8,vp9}sldec: Implement get_preferred_output_delay()
authorSeungha Yang <seungha@centricular.com>
Thu, 30 Sep 2021 15:27:42 +0000 (00:27 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 2 Oct 2021 12:11:48 +0000 (12:11 +0000)
Equivalent to that of nvh264sldec. Use render delay in case of non-live
pipeline for the better throughput performance.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/987>

subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp8dec.c
subprojects/gst-plugins-bad/sys/nvcodec/gstnvvp9dec.c

index e2739e0..36c7826 100644 (file)
@@ -80,6 +80,8 @@ static GstFlowReturn gst_nv_vp8_dec_decode_picture (GstVp8Decoder * decoder,
     GstVp8Picture * picture, GstVp8Parser * parser);
 static GstFlowReturn gst_nv_vp8_dec_output_picture (GstVp8Decoder *
     decoder, GstVideoCodecFrame * frame, GstVp8Picture * picture);
+static guint gst_nv_vp8_dec_get_preferred_output_delay (GstVp8Decoder * decoder,
+    gboolean is_live);
 
 static void
 gst_nv_vp8_dec_class_init (GstNvVp8DecClass * klass)
@@ -105,6 +107,8 @@ gst_nv_vp8_dec_class_init (GstNvVp8DecClass * klass)
       GST_DEBUG_FUNCPTR (gst_nv_vp8_dec_decode_picture);
   vp8decoder_class->output_picture =
       GST_DEBUG_FUNCPTR (gst_nv_vp8_dec_output_picture);
+  vp8decoder_class->get_preferred_output_delay =
+      GST_DEBUG_FUNCPTR (gst_nv_vp8_dec_get_preferred_output_delay);
 
   GST_DEBUG_CATEGORY_INIT (gst_nv_vp8_dec_debug,
       "nvvp8dec", 0, "NVIDIA VP8 Decoder");
@@ -254,7 +258,8 @@ gst_nv_vp8_dec_new_sequence (GstVp8Decoder * decoder,
 
     if (!gst_nv_decoder_configure (self->decoder,
             cudaVideoCodec_VP8, &info, self->width, self->height,
-            NUM_OUTPUT_VIEW)) {
+            /* +4 for render delay */
+            NUM_OUTPUT_VIEW + 4)) {
       GST_ERROR_OBJECT (self, "Failed to configure decoder");
       return GST_FLOW_NOT_NEGOTIATED;
     }
@@ -430,6 +435,18 @@ error:
   return GST_FLOW_ERROR;
 }
 
+static guint
+gst_nv_vp8_dec_get_preferred_output_delay (GstVp8Decoder * decoder,
+    gboolean is_live)
+{
+  /* Prefer to zero latency for live pipeline */
+  if (is_live)
+    return 0;
+
+  /* NVCODEC SDK uses 4 frame delay for better throughput performance */
+  return 4;
+}
+
 typedef struct
 {
   GstCaps *sink_caps;
index e64b6e4..0368961 100644 (file)
@@ -83,6 +83,8 @@ static GstFlowReturn gst_nv_vp9_dec_decode_picture (GstVp9Decoder * decoder,
     GstVp9Picture * picture, GstVp9Dpb * dpb);
 static GstFlowReturn gst_nv_vp9_dec_output_picture (GstVp9Decoder *
     decoder, GstVideoCodecFrame * frame, GstVp9Picture * picture);
+static guint gst_nv_vp9_dec_get_preferred_output_delay (GstVp9Decoder * decoder,
+    gboolean is_live);
 
 static void
 gst_nv_vp9_dec_class_init (GstNvVp9DecClass * klass)
@@ -110,6 +112,8 @@ gst_nv_vp9_dec_class_init (GstNvVp9DecClass * klass)
       GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_decode_picture);
   vp9decoder_class->output_picture =
       GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_output_picture);
+  vp9decoder_class->get_preferred_output_delay =
+      GST_DEBUG_FUNCPTR (gst_nv_vp9_dec_get_preferred_output_delay);
 
   GST_DEBUG_CATEGORY_INIT (gst_nv_vp9_dec_debug,
       "nvvp9dec", 0, "NVIDIA VP9 Decoder");
@@ -260,6 +264,7 @@ gst_nv_vp9_dec_new_sequence (GstVp9Decoder * decoder,
   gst_video_info_set_format (&info, out_format, self->width, self->height);
   if (!gst_nv_decoder_configure (self->decoder,
           cudaVideoCodec_VP9, &info, self->width, self->height,
+          /* +4 for render delay */
           NUM_OUTPUT_VIEW)) {
     GST_ERROR_OBJECT (self, "Failed to configure decoder");
     return GST_FLOW_NOT_NEGOTIATED;
@@ -518,6 +523,18 @@ error:
   return GST_FLOW_ERROR;
 }
 
+static guint
+gst_nv_vp9_dec_get_preferred_output_delay (GstVp9Decoder * decoder,
+    gboolean is_live)
+{
+  /* Prefer to zero latency for live pipeline */
+  if (is_live)
+    return 0;
+
+  /* NVCODEC SDK uses 4 frame delay for better throughput performance */
+  return 4;
+}
+
 typedef struct
 {
   GstCaps *sink_caps;