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 699187 - videorate: ends up outputting buffers with incorrect duration
videorate: ends up outputting buffers with incorrect duration
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: 1.1.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-04-28 23:16 UTC by Mathieu Duponchelle
Modified: 2013-05-09 14:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch trying to fix the problem. (1.42 KB, patch)
2013-04-28 23:18 UTC, Mathieu Duponchelle
needs-work Details | Review
New proposed patch to fix the issue. (1.05 KB, patch)
2013-04-29 14:56 UTC, Mathieu Duponchelle
rejected Details | Review
New proposed patch to fix the issue. (1.21 KB, patch)
2013-05-08 18:32 UTC, Mathieu Duponchelle
committed Details | Review

Description Mathieu Duponchelle 2013-04-28 23:16:57 UTC
In a GES test case, available here : https://github.com/MathieuDuponchelle/PitiviGes/blob/rendering/tests/check/ges/render.c#L243 we end up seeing, at the beginning of the transition, which is at the 5 seconds mark a buffer with an attributed duration of ~5 seconds. All the subsequent buffers get dropped until that duration is over.

the attached proposed patch resets the videorate->base_ts variable when getting a new segment event.
Comment 1 Mathieu Duponchelle 2013-04-28 23:18:54 UTC
Created attachment 242758 [details] [review]
Patch trying to fix the problem.
Comment 2 Sebastian Dröge (slomo) 2013-04-29 08:51:15 UTC
Review of attachment 242758 [details] [review]:

::: gst/videorate/gstvideorate.c
@@ +616,1 @@
         videorate->base_ts + gst_util_uint64_scale (videorate->out_frame_count,

I'm not sure this is correct in general. If videorate would be outputting a single segment and everything timestampped to running time it would be correct, but AFAUI videorate doesn't do that. Instead it generates timestamps inside the configured segment and closes gaps, etc.

As such the segment base should not be considered for buffer timestamps but kept in the downstream segment.

@@ +725,3 @@
+
+      /* Our new base for interpolation is now the segment base */
+      videorate->base_ts = videorate->segment.base;

5 lines (or so) above base_ts is set to 0. I think the line setting it to 0 should be removed if all this is correct
Comment 3 Mathieu Duponchelle 2013-04-29 14:55:48 UTC
Yep, that makes sense, then I think we should only not take the segment base into account for the next timestamp calculation. That new patch does that, doesn't break the test suite and yields the good results in our own test suite.
Comment 4 Mathieu Duponchelle 2013-04-29 14:56:30 UTC
Created attachment 242806 [details] [review]
New proposed patch to fix the issue.
Comment 5 Mathieu Duponchelle 2013-04-29 14:57:59 UTC
By the way, I'm curious to know how that part was working in 0.10, cause at that time the segment base was added as well, and it didn't create that problem.
Comment 6 Sebastian Dröge (slomo) 2013-04-29 17:07:24 UTC
While that looks correct there are still some other uses of segment.base that look a bit suspicious to me
Comment 7 Sebastian Dröge (slomo) 2013-05-07 07:38:09 UTC
Mathieu, any news on this? I saw you discussed some videorate things on IRC, do you know now how this is supposed to work?
Comment 8 Tim-Philipp Müller 2013-05-07 10:43:36 UTC
I think a unit test for -base would be in order.
Comment 9 Mathieu Duponchelle 2013-05-07 23:24:09 UTC
(In reply to comment #7)
> Mathieu, any news on this? I saw you discussed some videorate things on IRC, do
> you know now how this is supposed to work?

I do understand how it's supposed to work now :) We had other problems, addressed there : https://bugzilla.gnome.org/show_bug.cgi?id=699793 , which caused us to have wrong segments in the videorate as well, and made it difficult to finish this patch which is still incomplete as you mentioned in comment 6.
Comment 10 Mathieu Duponchelle 2013-05-08 18:30:16 UTC
Ok so further debugging our problem in GES led me to think that we actually can leave references to segment.base, as the calculated timestamp is actually relative to the base:

GST_BUFFER_TIMESTAMP (outbuf) = push_ts - videorate->segment.base;

I started writing a test, and realized that the behaviour is correct, except when we receive a segment, some buffers, then caps get set and a new segment is received. In that case, in the _setcaps function, we do that :

l 525 :
  gst_video_rate_swap_prev (videorate, NULL, GST_CLOCK_TIME_NONE);
which leads videorate->prevbuf to be NULL.

So when we get a segment event (l 676), we check if we have a prevbuf, and then and only then we reset base_ts. This is wrong, as we should reset out_frame_count and base_ts anyway. The attached patch will do that.

Another, separate problem is that this previous buffer should not be thrown away, at least when caps are the same, and ideally never. I have no idea how to do that though.
Comment 11 Mathieu Duponchelle 2013-05-08 18:32:51 UTC
Created attachment 243609 [details] [review]
New proposed patch to fix the issue.
Comment 12 Sebastian Dröge (slomo) 2013-05-09 14:22:46 UTC
commit aec0e48aa17077daed600468212a632361af7aba
Author: Mathieu Duponchelle <mathieu.duponchelle@epitech.eu>
Date:   Wed May 8 20:31:00 2013 +0200

    videorate: Reset base timestamp and out_frame_count in any case on SEGMENT_EVENT
    
    Fixes #699187