You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-23 21:54:53 +02:00
avformat/avio: clarify that AVSEEK_FORCE has no effect
avio_seek() never supported SEEK_END and returned AVERROR(EINVAL) when specified, so the later check "(whence != SEEK_END || force)" was always true. This also means that AVSEEK_FORCE had no effect since7a6fe01f99, that is 15 years ago. Rather than changing behaviour, let's document instead that the flag has no effect. Also fixed other commit41ed7ab45fwhich confused ORing / passing AVSEEK_FORCE and AVSEEK_SIZE in the docs. Signed-off-by: Valerii Zapodovnikov <val.zapod.vz@gmail.com>
This commit is contained in:
committed by
Marton Balint
parent
134fbfd1dc
commit
8426622bb9
@@ -461,17 +461,17 @@ int avio_put_str16be(AVIOContext *s, const char *str);
|
|||||||
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type);
|
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ORing this as the "whence" parameter to a seek function causes it to
|
* Passing this as the "whence" parameter to a seek function causes it to
|
||||||
* return the filesize without seeking anywhere. Supporting this is optional.
|
* return the filesize without seeking anywhere. Supporting this is optional.
|
||||||
* If it is not supported then the seek function will return <0.
|
* If it is not supported then the seek function will return <0.
|
||||||
*/
|
*/
|
||||||
#define AVSEEK_SIZE 0x10000
|
#define AVSEEK_SIZE 0x10000
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passing this flag as the "whence" parameter to a seek function causes it to
|
* OR'ing this flag into the "whence" parameter to a seek function causes it to
|
||||||
* seek by any means (like reopening and linear reading) or other normally unreasonable
|
* seek by any means (like reopening and linear reading) or other normally unreasonable
|
||||||
* means that can be extremely slow.
|
* means that can be extremely slow.
|
||||||
* This may be ignored by the seek code.
|
* This is the default and therefore ignored by the seek code since 2010.
|
||||||
*/
|
*/
|
||||||
#define AVSEEK_FORCE 0x20000
|
#define AVSEEK_FORCE 0x20000
|
||||||
|
|
||||||
|
|||||||
@@ -238,10 +238,9 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
|||||||
FFIOContext *const ctx = ffiocontext(s);
|
FFIOContext *const ctx = ffiocontext(s);
|
||||||
int64_t offset1;
|
int64_t offset1;
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
int force = whence & AVSEEK_FORCE;
|
|
||||||
int buffer_size;
|
int buffer_size;
|
||||||
int short_seek;
|
int short_seek;
|
||||||
whence &= ~AVSEEK_FORCE;
|
whence &= ~AVSEEK_FORCE; // force flag does nothing
|
||||||
|
|
||||||
if(!s)
|
if(!s)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
@@ -282,8 +281,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
|||||||
} else if ((!(s->seekable & AVIO_SEEKABLE_NORMAL) ||
|
} else if ((!(s->seekable & AVIO_SEEKABLE_NORMAL) ||
|
||||||
offset1 <= buffer_size + short_seek) &&
|
offset1 <= buffer_size + short_seek) &&
|
||||||
!s->write_flag && offset1 >= 0 &&
|
!s->write_flag && offset1 >= 0 &&
|
||||||
(!s->direct || !s->seek) &&
|
(!s->direct || !s->seek)) {
|
||||||
(whence != SEEK_END || force)) {
|
|
||||||
while(s->pos < offset && !s->eof_reached)
|
while(s->pos < offset && !s->eof_reached)
|
||||||
fill_buffer(s);
|
fill_buffer(s);
|
||||||
if (s->eof_reached)
|
if (s->eof_reached)
|
||||||
@@ -300,7 +298,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
|||||||
s->pos = pos;
|
s->pos = pos;
|
||||||
s->eof_reached = 0;
|
s->eof_reached = 0;
|
||||||
fill_buffer(s);
|
fill_buffer(s);
|
||||||
return avio_seek(s, offset, SEEK_SET | force);
|
return avio_seek(s, offset, SEEK_SET);
|
||||||
} else {
|
} else {
|
||||||
int64_t res;
|
int64_t res;
|
||||||
if (s->write_flag) {
|
if (s->write_flag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user