[MPlayer-dev-eng] [PATCH] Writing index in avi files > 2GB
Steven M. Schultz
sms at 2BSD.COM
Tue Nov 11 22:03:46 CET 2003
On Tue, 11 Nov 2003, Attila Kinali wrote:
> On Tue, 11 Nov 2003 21:12:14 +0100
> Boris Schaefer <mplayer at noid-project.de> wrote:
>
> > This patch contains a few changes (ftell -> ftello) to write the
> > avi-index in files > 2GB (but < 4GB) correctly.
>
> I think this is save to apply, any objections ?
No objection but ftello/fseeko need to be tested for at
./configure time and compatibility code used if the routine(s)
are not found. osdep/ would be the logical place I believe.
I've attached a version of the code used by several projects
(libquicktime, Postgresql are two I know of). The prototypes
can go where convenient.
Steven Schultz
-------------- next part --------------
#ifndef HAVE_FSEEKO
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
/*
* On BSD/OS and NetBSD, off_t and fpos_t are the same. Standards
* say off_t is an arithmetic type, but not necessarily integral,
* while fpos_t might be neither.
*/
int
fseeko(FILE *stream, off_t offset, int whence)
{
off_t floc;
struct stat filestat;
switch (whence)
{
case SEEK_CUR:
flockfile(stream);
if (fgetpos(stream, &floc) != 0)
goto failure;
floc += offset;
if (fsetpos(stream, &floc) != 0)
goto failure;
funlockfile(stream);
return 0;
break;
case SEEK_SET:
if (fsetpos(stream, &offset) != 0)
return -1;
return 0;
break;
case SEEK_END:
flockfile(stream);
if (fstat(fileno(stream), &filestat) != 0)
goto failure;
floc = filestat.st_size;
if (fsetpos(stream, &floc) != 0)
goto failure;
funlockfile(stream);
return 0;
break;
default:
errno = EINVAL;
return -1;
}
failure:
funlockfile(stream);
return -1;
}
off_t
fseeko64(FILE *stream, off_t offset, int whence)
{
return(fseeko(stream, offset, whence));
}
off_t
ftello(FILE *stream)
{
off_t floc;
if (fgetpos(stream, &floc) != 0)
return -1;
return floc;
}
off_t
ftello64(FILE *stream)
{
return(ftello(stream));
}
#endif
More information about the MPlayer-dev-eng
mailing list