From 26cedfa9fa6726a327d770d13ef711fea8fec38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 21 May 2015 19:38:33 +0200 Subject: [PATCH] vaapidecode: calculate decoding latency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a naïve approach to the calculation of the VA-API decoding latency. It takes into consideration when the frame-rate has some insane value. https://bugzilla.gnome.org/show_bug.cgi?id=740419 --- gst/vaapi/gstvaapidecode.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gst/vaapi/gstvaapidecode.c b/gst/vaapi/gstvaapidecode.c index 4a7916ac65..ac4208e14a 100644 --- a/gst/vaapi/gstvaapidecode.c +++ b/gst/vaapi/gstvaapidecode.c @@ -226,6 +226,22 @@ gst_vaapidecode_update_src_caps (GstVaapiDecode * decode) gst_caps_set_features (state->caps, 0, features); gst_caps_replace (&decode->srcpad_caps, state->caps); gst_video_codec_state_unref (state); + + gint fps_n = GST_VIDEO_INFO_FPS_N (vi); + gint fps_d = GST_VIDEO_INFO_FPS_D (vi); + if (fps_n <= 0 || fps_d <= 0) { + GST_DEBUG_OBJECT (decode, "forcing 25/1 framerate for latency calculation"); + fps_n = 1; + fps_d = 25; + } + + /* For parsing/preparation purposes we'd need at least 1 frame + * latency in general, with perfectly known unit boundaries (NALU, + * AU), and up to 2 frames when we need to wait for the second frame + * start to determine the first frame is complete */ + GstClockTime latency = gst_util_uint64_scale (2 * GST_SECOND, fps_d, fps_n); + gst_video_decoder_set_latency (vdec, latency, latency); + return TRUE; }