summaryrefslogtreecommitdiffstats
path: root/core/mp_core.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-24 19:31:48 +0200
committerwm4 <wm4@nowhere>2013-04-24 20:27:12 +0200
commitff549a2f6ade72ee9af42e911139bbee41daee5a (patch)
treea495c7a77679c306ef1def02a510b21562880fd3 /core/mp_core.h
parent40f822782d036d206a95b8447b709ea2a65b151e (diff)
downloadmpv-ff549a2f6ade72ee9af42e911139bbee41daee5a.tar.bz2
mpv-ff549a2f6ade72ee9af42e911139bbee41daee5a.tar.xz
core: add backstep support
Allows stepping back one frame via the frame_back_step inout command, bound to "," by default. This uses the precise seeking facility, and a perfect frame index built on the fly. The index is built during playback and precise seeking, and contains (as of this commit) the last 100 displayed or skipped frames. This index is used to find the PTS of the previous frame, which is then used as target for a precise seek. If no PTS is found, the core attempts to do a seek before the current frame, and skip decoded frames until the current frame is reached; this will create a sufficient index and the normal backstep algorithm can be applied. This can be rather slow. The worst case for backstepping is about the same as the worst case for precise seeking if the previous frame can be deduced from the index. If not, the worst case will be twice as slow. There's also some minor danger that the index is incorrect in case framedropping is involved. For framedropping due to --framedrop, this problem is ignored (use of --framedrop is discouraged anyway). For framedropping during precise seeking (done to make it faster), we try to not add frames to the index that are produced when this can happen. I'm not sure how well that works (or if the logic is sane), and it's sure to break with some video filters. In the worst case, backstepping might silently skip frames if you backstep after a user-initiated precise seek. (Precise seeks to do indexing are not affected.) Likewise, video filters that somehow change timing of frames and do not do this in a deterministic way (i.e. if you seek to a position, frames with different timings are produced than when the position is reached during normal playback) will make backstepping silently jump to the wrong frame. Enabling/disabling filters during playback (like for example deinterlacing) will have similar bad effects.
Diffstat (limited to 'core/mp_core.h')
-rw-r--r--core/mp_core.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/core/mp_core.h b/core/mp_core.h
index 452cf70d58..82942c32cb 100644
--- a/core/mp_core.h
+++ b/core/mp_core.h
@@ -117,6 +117,10 @@ struct track {
struct sub_data *subdata;
};
+enum {
+ MAX_NUM_VO_PTS = 100,
+};
+
typedef struct MPContext {
struct MPOpts opts;
struct m_config *mconfig;
@@ -219,6 +223,15 @@ typedef struct MPContext {
// Video PTS, or audio PTS if video has ended.
double playback_pts;
+ // History of video frames timestamps that were queued in the VO
+ // This includes even skipped frames during hr-seek
+ double vo_pts_history_pts[MAX_NUM_VO_PTS];
+ // Whether the PTS at vo_pts_history[n] is after a seek reset
+ uint64_t vo_pts_history_seek[MAX_NUM_VO_PTS];
+ uint64_t vo_pts_history_seek_ts;
+ uint64_t backstep_start_seek_ts;
+ bool backstep_active;
+
float audio_delay;
unsigned int last_heartbeat;
@@ -287,7 +300,7 @@ struct track *mp_add_subtitles(struct MPContext *mpctx, char *filename,
int reinit_video_chain(struct MPContext *mpctx);
void pause_player(struct MPContext *mpctx);
void unpause_player(struct MPContext *mpctx);
-void add_step_frame(struct MPContext *mpctx);
+void add_step_frame(struct MPContext *mpctx, int dir);
void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
int exact);
int seek_chapter(struct MPContext *mpctx, int chapter, double *seek_pts);