Hello,
avio.h defines AVSEEK_SIZE.
#define AVSEEK_SIZE 0x10000
"""
Passing AVSEEK_SIZE as the "whence" parameter to a seek function causes
it to return the filesize without seeking anywhere. Supporting this is
optional. If it is not supported then the seek function will return <0.
"""
typedef struct URLProtocol {
const char *name;
int (*url_open)(URLContext *h, const char *filename, int flags);
int (*url_read)(URLContext *h, unsigned char *buf, int size);
int (*url_write)(URLContext *h, unsigned char *buf, int size);
int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
int (*url_close)(URLContext *h);
struct URLProtocol *next;
int (*url_read_pause)(URLContext *h, int pause);
int64_t (*url_read_seek)(URLContext *h, int stream_index,
int64_t timestamp, int flags);
} URLProtocol;
"""
int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
"""
http://www.opengroup.org/onlinepubs/000095399/functions/lseek.html
Consider the following implementation of a url_seek() callback.
static int64_t file_seek(URLContext *h, int64_t pos, int whence)
{
...
switch(whence)
{
case SEEK_SET : FFMPEG_Seek=FS_SEEK_SET; break;
case SEEK_CUR : FFMPEG_Seek=FS_SEEK_CUR; break;
case SEEK_END : FFMPEG_Seek=FS_SEEK_END; break;
default : FFMPEG_Seek=FS_SEEK_SET; break;
}
...
}
i.e. treat AVSEEK_SIZE like a SEEK_SET request.
$ grep -r AVSEEK_SIZE .
./libavformat/avio.c: size= url_seek(h, 0, AVSEEK_SIZE);
./libavformat/avio.h:#define AVSEEK_SIZE 0x10000
./libavformat/aviobuf.c: size = s->seek(s->opaque, 0, AVSEEK_SIZE);
./libavformat/http.c: if (whence == AVSEEK_SIZE)
i.e. pos=0 every time whence=AVSEEK_SIZE
thus file_seek(h, 0, AVSEEK_SIZE) will return 0 (instead of the file
size or -1)
As far as I understand, this behavior is incorrect. Either the function
should return the file size or it should return an error.
Is that correct ?
Something else seems wrong in the implementation of file_seek()
if (whence == SEEK_END)
{
pos = 0;
}
file_seek() will ignore whatever offset from the end is requested, seek
to the end of the file, and return the file size.
This behavior seems incorrect too. Do you agree ?
--
Regards.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user