Changeset 258844 in webkit


Ignore:
Timestamp:
Mar 23, 2020 8:27:38 AM (4 years ago)
Author:
aboya@igalia.com
Message:

[MSE][GStreamer] Clean and explain first sample PTS hack
https://bugs.webkit.org/show_bug.cgi?id=209335

Reviewed by Philippe Normand.

MediaSample::applyPtsOffset() had a rather confusing name, so it has
been changed to something more descriptive of its actual function:
extendToTheBeginning().

Also, its only argument has been removed, as it's always zero.

An explanation of the hack has also been added.

This patch introduces no behavior changes.

  • platform/graphics/gstreamer/MediaSampleGStreamer.cpp:

(WebCore::MediaSampleGStreamer::extendToTheBeginning):
(WebCore::MediaSampleGStreamer::applyPtsOffset): Deleted.

  • platform/graphics/gstreamer/MediaSampleGStreamer.h:
  • platform/graphics/gstreamer/mse/AppendPipeline.cpp:

(WebCore::AppendPipeline::appsinkNewSample):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r258843 r258844  
     12020-03-23  Alicia Boya García  <aboya@igalia.com>
     2
     3        [MSE][GStreamer] Clean and explain first sample PTS hack
     4        https://bugs.webkit.org/show_bug.cgi?id=209335
     5
     6        Reviewed by Philippe Normand.
     7
     8        MediaSample::applyPtsOffset() had a rather confusing name, so it has
     9        been changed to something more descriptive of its actual function:
     10        extendToTheBeginning().
     11
     12        Also, its only argument has been removed, as it's always zero.
     13
     14        An explanation of the hack has also been added.
     15
     16        This patch introduces no behavior changes.
     17
     18        * platform/graphics/gstreamer/MediaSampleGStreamer.cpp:
     19        (WebCore::MediaSampleGStreamer::extendToTheBeginning):
     20        (WebCore::MediaSampleGStreamer::applyPtsOffset): Deleted.
     21        * platform/graphics/gstreamer/MediaSampleGStreamer.h:
     22        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
     23        (WebCore::AppendPipeline::appsinkNewSample):
     24
    1252020-03-23  Zalan Bujtas  <zalan@apple.com>
    226
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.cpp

    r251365 r258844  
    9696}
    9797
    98 void MediaSampleGStreamer::applyPtsOffset(MediaTime timestampOffset)
     98void MediaSampleGStreamer::extendToTheBeginning()
    9999{
    100     if (m_pts > timestampOffset) {
    101         m_duration = m_duration + (m_pts - timestampOffset);
    102         m_pts = timestampOffset;
    103     }
     100    // Only to be used with the first sample, as a hack for lack of support for edit lists.
     101    // See AppendPipeline::appsinkNewSample()
     102    ASSERT(m_dts == MediaTime::zeroTime());
     103    m_duration += m_pts;
     104    m_pts = MediaTime::zeroTime();
    104105}
    105106
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaSampleGStreamer.h

    r246490 r258844  
    3939    static Ref<MediaSampleGStreamer> createFakeSample(GstCaps*, MediaTime pts, MediaTime dts, MediaTime duration, const FloatSize& presentationSize, const AtomString& trackId);
    4040
    41     void applyPtsOffset(MediaTime);
     41    void extendToTheBeginning();
    4242    MediaTime presentationTime() const override { return m_pts; }
    4343    MediaTime decodeTime() const override { return m_dts; }
  • trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp

    r251365 r258844  
    475475    }
    476476
    477     // Add a gap sample if a gap is detected before the first sample.
     477    // Hack, rework when GStreamer >= 1.16 becomes a requirement:
     478    // We're not applying edit lists. GStreamer < 1.16 doesn't emit the correct segments to do so.
     479    // GStreamer fix in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/commit/c2a0da8096009f0f99943f78dc18066965be60f9
     480    // Also, in order to apply them we would need to convert the timestamps to stream time, which we're not currently
     481    // doing for consistency between GStreamer versions.
     482    //
     483    // In consequence, the timestamps we're handling here are unedited track time. In track time, the first sample is
     484    // guaranteed to have DTS == 0, but in the case of streams with B-frames, often PTS > 0. Edit lists fix this by
     485    // offsetting all timestamps by that amount in movie time, but we can't do that if we don't have access to them.
     486    // (We could assume the track PTS of the sample with track DTS = 0 is the offset, but we don't have any guarantee
     487    // we will get appended that sample first, or ever).
     488    //
     489    // Because a track presentation time starting at some close to zero, but not exactly zero time can cause unexpected
     490    // results for applications, we extend the duration of this first sample to the left so that it starts at zero.
    478491    if (mediaSample->decodeTime() == MediaTime::zeroTime() && mediaSample->presentationTime() > MediaTime::zeroTime() && mediaSample->presentationTime() <= MediaTime(1, 10)) {
    479         GST_DEBUG("Adding gap offset");
    480         mediaSample->applyPtsOffset(MediaTime::zeroTime());
     492        GST_DEBUG("Extending first sample to make it start at PTS=0");
     493        mediaSample->extendToTheBeginning();
    481494    }
    482495
Note: See TracChangeset for help on using the changeset viewer.