mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-06 07:50:00 +01:00
Minor improvement precision media player gap timing
This commit is contained in:
@@ -954,9 +954,14 @@ void MediaPlayer::update()
|
|||||||
// if in a gap, seek to next section
|
// if in a gap, seek to next section
|
||||||
if (gap.is_valid()) {
|
if (gap.is_valid()) {
|
||||||
// jump in one or the other direction
|
// jump in one or the other direction
|
||||||
GstClockTime jumpPts = (rate_>0.f) ? gap.end : gap.begin;
|
GstClockTime jumpPts = timeline_.step(); // round jump time to frame pts
|
||||||
// seek to next valid time (if not beginnig or end of timeline)
|
if ( rate_ > 0.f )
|
||||||
|
jumpPts *= ( gap.end / timeline_.step() ) + 1; // FWD: go to end of gap
|
||||||
|
else
|
||||||
|
jumpPts *= ( gap.begin / timeline_.step() ); // BWD: go to begin of gap
|
||||||
|
// (if not beginnig or end of timeline)
|
||||||
if (jumpPts > timeline_.first() && jumpPts < timeline_.last())
|
if (jumpPts > timeline_.first() && jumpPts < timeline_.last())
|
||||||
|
// seek to jump PTS time
|
||||||
seek( jumpPts );
|
seek( jumpPts );
|
||||||
// otherwise, we should loop
|
// otherwise, we should loop
|
||||||
else
|
else
|
||||||
@@ -1006,9 +1011,12 @@ void MediaPlayer::execute_seek_command(GstClockTime target)
|
|||||||
|
|
||||||
// seek with flush (always)
|
// seek with flush (always)
|
||||||
int seek_flags = GST_SEEK_FLAG_FLUSH;
|
int seek_flags = GST_SEEK_FLAG_FLUSH;
|
||||||
|
|
||||||
// seek with trick mode if fast speed
|
// seek with trick mode if fast speed
|
||||||
if ( ABS(rate_) > 1.0 )
|
if ( ABS(rate_) > 1.5 )
|
||||||
seek_flags |= GST_SEEK_FLAG_TRICKMODE;
|
seek_flags |= GST_SEEK_FLAG_TRICKMODE;
|
||||||
|
else
|
||||||
|
seek_flags |= GST_SEEK_FLAG_ACCURATE;
|
||||||
|
|
||||||
// create seek event depending on direction
|
// create seek event depending on direction
|
||||||
GstEvent *seek_event = nullptr;
|
GstEvent *seek_event = nullptr;
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ struct TimeInterval
|
|||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
inline TimeInterval& operator %= (const GstClockTime& precision)
|
||||||
|
{
|
||||||
|
if (precision != GST_CLOCK_TIME_NONE && precision > 0) {
|
||||||
|
this->begin -= this->begin % precision;
|
||||||
|
this->end += precision - (this->end % precision) ;
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
inline bool includes(const GstClockTime t) const
|
inline bool includes(const GstClockTime t) const
|
||||||
{
|
{
|
||||||
return (is_valid() && t != GST_CLOCK_TIME_NONE && !(t < this->begin) && !(t > this->end) );
|
return (is_valid() && t != GST_CLOCK_TIME_NONE && !(t < this->begin) && !(t > this->end) );
|
||||||
|
|||||||
Reference in New Issue
Block a user