nvdec: Tell the parser we have complete pictures
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 22 Jan 2020 15:26:02 +0000 (10:26 -0500)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Sat, 25 Jan 2020 13:39:03 +0000 (13:39 +0000)
This sets the CUVID_PKT_ENDOFPICTURE flag in order to inform the decoder that
we have a complete picture. This should remove one frame latency otherwise
introduce by NVidia parser.

sys/nvcodec/gstnvdec.c
sys/nvcodec/gstnvdec.h

index f2cffff..fddc1c9 100644 (file)
@@ -881,6 +881,18 @@ gst_nvdec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
       GstBuffer *codec_data = gst_value_get_buffer (codec_data_value);
       gst_buffer_replace (&nvdec->codec_data, codec_data);
     }
+
+    /* For all CODEC we get completre picture ... */
+    nvdec->recv_complete_picture = TRUE;
+
+    /* Except for JPEG, for which it depends on the caps */
+    if (klass->codec_type == cudaVideoCodec_JPEG) {
+      gboolean parsed;
+      if (gst_structure_get_boolean (str, "parsed", &parsed))
+        nvdec->recv_complete_picture = parsed;
+      else
+        nvdec->recv_complete_picture = FALSE;
+    }
   }
 
   return ret;
@@ -1123,6 +1135,9 @@ gst_nvdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame)
   packet.timestamp = frame->pts;
   packet.flags |= CUVID_PKT_TIMESTAMP;
 
+  if (nvdec->recv_complete_picture)
+    packet.flags |= CUVID_PKT_ENDOFPICTURE;
+
   nvdec->state = GST_NVDEC_STATE_PARSE;
   nvdec->last_ret = GST_FLOW_OK;
 
index 65bd011..bdace4c 100644 (file)
@@ -89,6 +89,7 @@ struct _GstNvDec
   GstNvDecMemType mem_type;
 
   GstBuffer *codec_data;
+  gboolean recv_complete_picture;
 };
 
 struct _GstNvDecClass