From 36c1e6278b93371cfe1c7672b830b2a19cee1921 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Mon, 27 Feb 2012 21:49:39 +0330 Subject: [PATCH] fbff: add periodic syncs Now -s argument can accept a number; -s100 means sync every hundred frames (note that there is no space between -s and 100). This is specially helpful for files that get out of sync without -s, and -s results in choppy playback. The -s without any number is equivalent to -s1 and means sync every frame. So to get the best playback I suggest: * try playback with -s; if out of sync, you need to use -/+ commands to set avdiff. The best guide for avdiff is the amount reported in 'i' command just when the playback starts without -s. * try playback with -s100 and just after starting the playback press 'a' command to record the avdiff --- fbff.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fbff.c b/fbff.c index 52e6252..3fe06f2 100644 --- a/fbff.c +++ b/fbff.c @@ -46,6 +46,8 @@ static int afd; /* oss fd */ static int vnum; /* decoded video frame count */ static int sync_diff; /* audio/video frame position diff */ +static int sync_period; /* sync after every this many number of frames */ +static int sync_since; /* frames since th last sync */ static int sync_cnt = 32; /* synchronization steps */ static int sync_cur; /* synchronization steps left */ @@ -217,6 +219,10 @@ static void execkey(void) /* return nonzero if one more video frame can be decoded */ static int vsync(void) { + if (sync_period && sync_since++ >= sync_period) { + sync_cur = sync_cnt; + sync_since = 0; + } if (sync_cur > 0) { sync_cur--; return ffs_avdiff(vffs, affs) >= sync_diff; @@ -348,8 +354,8 @@ static void read_args(int argc, char *argv[]) jump = atoi(argv[++i]); if (!strcmp(argv[i], "-f")) fullscreen = 1; - if (!strcmp(argv[i], "-s")) - sync_cnt = sync_cur = (1 << 30); + if (!strncmp(argv[i], "-s", 2)) + sync_period = isdigit(argv[i][2]) ? atoi(argv[i] + 2) : 1; if (!strcmp(argv[i], "-v")) video = argv[++i][0] == '-' ? 0 : atoi(argv[i]) + 2; if (!strcmp(argv[i], "-a")) -- 2.11.4.GIT