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 772730 - avdemux: check if we ran outside of the segment
avdemux: check if we ran outside of the segment
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-libav
git master
Other Windows
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-10-11 07:16 UTC by WeiChungChang
Modified: 2018-11-03 12:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposal to fix segment issue (708.49 KB, application/pdf)
2016-11-03 07:31 UTC, WeiChungChang
  Details
Fix the issue to check if we ran outside of the segment (1.53 KB, patch)
2017-01-21 05:22 UTC, WeiChungChang
none Details | Review

Description WeiChungChang 2016-10-11 07:16:27 UTC
Dear all: 

I wonder the correctness about the flow within Gstavdemux to check  if we ran outside of the segment. 

Please see the following flow. 

  /* do timestamps, we do this first so that we can know when we 
   * stepped over the segment stop position. */ 
  timestamp = gst_ffmpeg_time_ff_to_gst (pkt.pts, avstream->time_base); 
  if (GST_CLOCK_TIME_IS_VALID (timestamp)) { 
    stream->last_ts = timestamp; 
  } 
  ... 
  if (GST_CLOCK_TIME_IS_VALID (timestamp)) 
    timestamp -= demux->start_time; 
  ... 

  /* check if we ran outside of the segment */ 
  if (demux->segment.stop != -1 && timestamp > demux->segment.stop) 
    goto drop;

When we are given the settings below and it means we want to playback P1 B3 B4 only. 

Presentation order =  I1 B1 B2 { P1 B3 B4 } I2 
decoding      order =  I1 P1 B1 B2 I2 B3 B4 

PTS of ( I1 B1 B2 P1 B3 B4  I2) = ( 1, 2, 3, 4, 5, 6, 7) 
DTS of ( I1 B1 B2 P1 B3 B4  I2) = (1, 3, 4, 2, 6, 7, 5) 

The segment stop is set to "6" accordingly since the PTS of {P1 B3 B4} = ( 4, 5, 6 ). 

However, notice that the PTS of I2 is "7" which is larger than 6. Also we will demux it before B3 & B4. 

By the flow : "check if we ran outside of the segment", we will go to the drop label & pause where. 

The result is we miss the following two B frames, which should be played originally. 


I think an additional check such as "if we have met the first Key frame whose PTS is greater than segment's stop, go to drop (pause)" will be safe. 


Thanks.
Comment 1 Sebastian Dröge (slomo) 2016-10-20 11:00:14 UTC
(In reply to John Chang from comment #0)

> I think an additional check such as "if we have met the first Key frame
> whose PTS is greater than segment's stop, go to drop (pause)" will be safe. 

I think that's not necessarily safe either, depending on the codec. Maybe looking at the DTS could help here? Also should check how qtdemux is solving the same issue.


Do you want to investigate and propose a patch?
Comment 2 WeiChungChang 2016-11-03 07:31:11 UTC
Created attachment 339009 [details]
Proposal to fix segment issue

Proposal to fix segment issue
Comment 3 WeiChungChang 2016-11-03 07:33:26 UTC
Dear Slomo:

Could you please help to take a loop to the attached (Proposal to fix segment issue)?

It contains 2 proposals & their flowcharts; as well as some execution examples.

If you think the proposed flows are correct, we will make the patch later soon.

Thank you.
Comment 4 WeiChungChang 2017-01-21 05:22:32 UTC
Created attachment 343936 [details] [review]
Fix the issue to check if we ran outside of the segment

proposed patch to fix;

The way to judge is described at the attachment: " Proposal to fix segment issue ";
according to flow chart of fig 9.
Comment 5 GStreamer system administrator 2018-11-03 12:57:59 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-libav/issues/29.