After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 790478 - nvdec: seeking causes timestamps to shift breaking lipsync
nvdec: seeking causes timestamps to shift breaking lipsync
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-11-17 06:17 UTC by Matthew Waters (ystreet00)
Modified: 2017-11-22 07:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
nvdec: implement flush/drain (2.95 KB, patch)
2017-11-17 06:18 UTC, Matthew Waters (ystreet00)
committed Details | Review

Description Matthew Waters (ystreet00) 2017-11-17 06:17:54 UTC
See commit
Comment 1 Matthew Waters (ystreet00) 2017-11-17 06:18:34 UTC
Created attachment 363884 [details] [review]
nvdec: implement flush/drain
Comment 2 Sebastian Dröge (slomo) 2017-11-17 10:09:15 UTC
Comment on attachment 363884 [details] [review]
nvdec: implement flush/drain

In the first case (flush) you'd like to get all frames discarded ASAP, while in the second all pending frames should go downstream.

Is this correctly handled, is it possible to do the flushing faster without trying to push frames downstream first? Note also that pushing a frame downstream with return FLUSHING, which might stop it from outputting (and thus discarding) any further frames?
Comment 3 Matthew Waters (ystreet00) 2017-11-20 05:18:08 UTC
(In reply to Sebastian Dröge (slomo) from comment #2)
> In the first case (flush) you'd like to get all frames discarded ASAP, while
> in the second all pending frames should go downstream.

There is no 'discard inflight frames' in the API so we can't differentiate those two cases to the library.

> Is this correctly handled, is it possible to do the flushing faster without
> trying to push frames downstream first?

You mean calling release_frame() instead of finish_frame() ?  Otherwise, no.

> Note also that pushing a frame
> downstream with return FLUSHING, which might stop it from outputting (and
> thus discarding) any further frames?

Huh? Which case are we talking about now?

The entire decode sequence is synchronous and there is only ever one frame in flight between decode and display at a time so this is currently not a problem.

In any case, attempting to drop or release frames in flush also breaks lipsync in the same way.
Comment 4 Sebastian Dröge (slomo) 2017-11-20 07:59:38 UTC
There are not multiple frames in flight if there are B frames?

The case I was thinking of is that during flushing, downstream will return GST_FLOW_FLUSHING. If there were multiple frames in flight, this would potentially cause only the first to be tried to be pushed, and the others to be kept around still.
Comment 5 Matthew Waters (ystreet00) 2017-11-20 08:20:10 UTC
(In reply to Sebastian Dröge (slomo) from comment #4)
> There are not multiple frames in flight if there are B frames?

There's only 0, or 1 frames in flight between decode and display regardless of B frames which is where this matters in nvdec's frame handling.  Any frames that are subsequently parsed will not find a corresponding GstVideoCodecFrame (because videodecoder clears the list of frames) and will thus be dropped automatically.

> The case I was thinking of is that during flushing, downstream will return
> GST_FLOW_FLUSHING. If there were multiple frames in flight, this would
> potentially cause only the first to be tried to be pushed, and the others to
> be kept around still.

See above.
Comment 6 Matthew Waters (ystreet00) 2017-11-22 03:52:48 UTC
commit 4e422bec4fa7be03f7540c2c1d939b36305d0fb3
Author: Matthew Waters <matthew@centricular.com>
Date:   Fri Nov 17 17:09:22 2017 +1100

    nvdec: implement flush/drain
    
    Fixes outputted frame sequence when performing a seek
    
    i.e. when seeking backwards, the first frame after the seek was a frame
    from the future.  This would result in GstVideoDecoder essentially
    marking all the timestamps as essentially bogus and the base class would
    attempt to compensate.  A visible indication of this was 'decreasing timestamp'
    warning after a seek.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790478
Comment 7 Nicolas Dufresne (ndufresne) 2017-11-22 04:05:06 UTC
It's strange that both your flush and drain implementation are so similar. It gives me the impression that you push the remaining frames on flush, which is wrong, you should drop them.
Comment 8 Sebastian Dröge (slomo) 2017-11-22 07:47:15 UTC
See above, but pushing them on flush *will* drop them ;)