[mythtv] seeking with pvr / usleep

Jim Paris jim at jtan.com
Thu Apr 24 04:13:55 EDT 2003


> Second step (and a much better way to do it) would be to do some quick 
> demuxing on record and store the start locations of the keyframes, much like 
> the nuppelvideo stuff does now when it generates a seektable.

What about building this table as we play?  For jumping into a
position we've already seen (eg rewinding), we'll have the keyframe
locations cached.  For jumping into unvisited frames, we go to our
last known keyframe and scan frames without decoding them.  Fast
forward would be a bit slower than rewind but I can't imagine it would
be too bad -- would it?

I'd implement either of the methods you suggested, but I've spent the
last few hours looking into how libavformat/codec works and I'm still
not quite at the point where I can just hack this up.. :0

BTW, on an unrelated note, one thing I've noticed throughout the code
is your use of 
     usleep(50);
     usleep(500);
     usleep(5000);
FYI, those will all actually delay about 20 msec on a stock 2.4
i386 kernel; they have a granularity of the system timer (1/HZ = 10
msec) plus 10 msec for scheduling.  See attached program.  Since
that's on the order of a frame period, that may not be what you
intended and could lead to frame drops or something.  Not that there's
any way to really fix it, but it's worth knowing that almost every
usleep in the code waits for exactly the same amount of time, if you
didn't already.

-jim
-------------- next part --------------
#include <stdio.h>
#define __USE_GNU
#include <time.h>
#include <sys/time.h>

int xmain() {
	struct timeval start, end, diff;
	int i, j;
	int test[]={50,500,5000,9000,11000};

	for(j=0;j<sizeof(test)/sizeof(*test);j++) {
		gettimeofday(&start,NULL);
		for(i=0;i<100;i++)
			usleep(test[j]);
		gettimeofday(&end,NULL);
		timersub(&end,&start,&diff);
		printf("usleep(%d): %ld.%06ld sec total (%lf msec each)\n",
		       test[j],
		       diff.tv_sec,diff.tv_usec,
		       10*(diff.tv_sec+diff.tv_usec/1e6));
	}
}


More information about the mythtv-dev mailing list