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 749258 - basesink: fix QoS/lateness checking if subclass implements prepare/prepare_list vfuncs
basesink: fix QoS/lateness checking if subclass implements prepare/prepare_li...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 742916 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2015-05-12 10:05 UTC by Jian Li
Modified: 2015-05-14 08:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.03 KB, patch)
2015-05-12 10:05 UTC, Jian Li
needs-work Details | Review
update patch (1.51 KB, patch)
2015-05-14 07:58 UTC, Jian Li
committed Details | Review

Description Jian Li 2015-05-12 10:05:47 UTC
Created attachment 303252 [details] [review]
patch

In basesink functions gst_base_sink_chain_unlocked(), below code is used to checking if buffer is late before doing prepare call to save some effort:
    if (syncable && do_sync)
      late =
          gst_base_sink_is_too_late (basesink, obj, rstart, rstop,
          GST_CLOCK_EARLY, 0, FALSE);

    if (G_UNLIKELY (late))
      goto dropped;

But this code has problem, it should calculate jitter based on current media clock, rather than just passing 0. I found it will drop all the frames when rewind in slow speed, such as -2X. 

I made a patch to fix this issue, please check it.
Comment 1 Sebastian Dröge (slomo) 2015-05-12 10:12:51 UTC
This is probably related to bug #742916, can you confirm?
Comment 2 Jian Li 2015-05-13 06:48:06 UTC
Looks like this patch do the sync waiting (with gst_base_sink_do_sync) before prepare call, will this cause buffer late in the next gst_base_sink_do_sync() call, as it may cost some time from sync in prepare to sync in render? 

I think in prepare, just need to check if current buffer time is late than media time, if late drop it to save some prepare effort. I believe this is the original purpose of this code.
Comment 3 Sebastian Dröge (slomo) 2015-05-13 10:56:19 UTC
*** Bug 742916 has been marked as a duplicate of this bug. ***
Comment 4 Sebastian Dröge (slomo) 2015-05-13 10:58:45 UTC
Review of attachment 303252 [details] [review]:

I agree, your patch makes more sense.

::: libs/gst/base/gstbasesink.c
@@ +3367,3 @@
+        base_time = GST_ELEMENT_CAST (basesink)->base_time;
+        stime = base_time + gst_base_sink_adjust_time (basesink, rstart);
+        now = gst_clock_get_time (clock);

When accessing the clock and base time directly like this, you need to take the object lock all the time.

@@ +3371,2 @@
           gst_base_sink_is_too_late (basesink, obj, rstart, rstop,
+              GST_CLOCK_EARLY, GST_CLOCK_DIFF (stime, now), FALSE);

Not sure if EARLY is always correct here... it might depend on whether stime>now or not, no?
Comment 5 Jian Li 2015-05-14 07:58:04 UTC
I think EARLY is OK, it just reuse gst_base_sink_is_too_late()  to check if the buffer is late, so use EARLY can hard code to make this function work.

Please check the updated patch based on your comments.
Comment 6 Jian Li 2015-05-14 07:58:25 UTC
Created attachment 303352 [details] [review]
update patch
Comment 7 Sebastian Dröge (slomo) 2015-05-14 08:20:12 UTC
Thanks! I just moved the lock a little bit before merging.

commit 4f79c5e8da516c137d4c9b0175ccb0a2ab147a6b
Author: Jian <Jian.Li@freescale.com>
Date:   Thu May 14 15:49:43 2015 +0800

    basesink: Fix QoS/lateness checking if subclass implements prepare/prepare_list vfuncs
    
    In basesink functions gst_base_sink_chain_unlocked(), below code is used to
    checking if buffer is late before doing prepare call to save some effort:
        if (syncable && do_sync)
          late =
              gst_base_sink_is_too_late (basesink, obj, rstart, rstop,
              GST_CLOCK_EARLY, 0, FALSE);
    
        if (G_UNLIKELY (late))
          goto dropped;
    
    But this code has problem, it should calculate jitter based on current media
    clock, rather than just passing 0. I found it will drop all the frames when
    rewind in slow speed, such as -2X.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749258