Do not use first key frame in timeline.

This commit is contained in:
brunoherbelin
2020-08-24 22:18:43 +02:00
parent e41868d405
commit f90964bac8
4 changed files with 12 additions and 12 deletions

View File

@@ -313,8 +313,12 @@ void MediaPlayer::execute_open()
// all good
Log::Info("MediaPlayer %s Opened '%s' (%s %d x %d)", std::to_string(id_).c_str(),
Log::Info("MediaPlayer %d Opened '%s' (%s %d x %d)", id_,
uri_.c_str(), media_.codec_name.c_str(), media_.width, media_.height);
Log::Info("MediaPlayer %d Timeline [%ld %ld] %ld frames, %d gaps", id_,
media_.timeline.begin(), media_.timeline.end(), media_.timeline.numFrames(), media_.timeline.numGaps());
ready_ = true;
// register media player
@@ -581,7 +585,7 @@ void MediaPlayer::seek(GstClockTime pos)
return;
// apply seek
GstClockTime target = CLAMP(pos, media_.timeline.start(), media_.timeline.end());
GstClockTime target = CLAMP(pos, media_.timeline.begin(), media_.timeline.end());
execute_seek_command(target);
}
@@ -984,10 +988,8 @@ bool MediaPlayer::fill_frame(GstBuffer *buf, FrameStatus status)
frame_[write_index_].position = buf->pts;
// set the start position (i.e. pts of first frame we got)
if (media_.timeline.start() == GST_CLOCK_TIME_NONE) {
if (media_.timeline.begin() == GST_CLOCK_TIME_NONE) {
media_.timeline.setFirst(buf->pts);
Log::Info("Timeline %ld [%ld %ld] %d gaps", media_.timeline.numFrames(),
media_.timeline.first(), media_.timeline.end(), media_.timeline.numGaps());
}
}
// full but invalid frame : will be deleted next iteration
@@ -998,7 +1000,7 @@ bool MediaPlayer::fill_frame(GstBuffer *buf, FrameStatus status)
// else; null buffer for EOS: give a position
else {
frame_[write_index_].status = EOS;
frame_[write_index_].position = rate_ > 0.0 ? media_.timeline.end() : media_.timeline.start();
frame_[write_index_].position = rate_ > 0.0 ? media_.timeline.end() : media_.timeline.begin();
}
// unlock access to frame

View File

@@ -44,7 +44,8 @@ void Timeline::reset()
{
// reset timing
timing_.reset();
first_ = GST_CLOCK_TIME_NONE;
timing_.begin = 0;
first_ = 0;
step_ = GST_CLOCK_TIME_NONE;
clearGaps();
@@ -59,9 +60,6 @@ bool Timeline::is_valid()
void Timeline::setFirst(GstClockTime first)
{
first_ = first;
// validate timing
if (first_ != GST_CLOCK_TIME_NONE)
timing_.begin = 0;
}
void Timeline::setEnd(GstClockTime end)

View File

@@ -93,7 +93,7 @@ public:
void setStep(GstClockTime dt);
// Timing manipulation
inline GstClockTime start() const { return timing_.begin; }
inline GstClockTime begin() const { return timing_.begin; }
inline GstClockTime end() const { return timing_.end; }
inline GstClockTime first() const { return first_; }
inline GstClockTime last() const { return timing_.end - step_; }

View File

@@ -1334,7 +1334,7 @@ void MediaController::Render()
}
// custom timeline slider
slider_pressed_ = ImGuiToolkit::TimelineSlider("##timeline", &seek_t, mp_->timeline()->first(),
slider_pressed_ = ImGuiToolkit::TimelineSlider("##timeline", &seek_t, mp_->timeline()->begin(),
mp_->timeline()->end(), mp_->timeline()->step(), size.x);
ImGui::PopStyleVar(2);