avformat/aviobuf: factorize buffer_size out
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -201,12 +201,14 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
|||||||
int64_t offset1;
|
int64_t offset1;
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
int force = whence & AVSEEK_FORCE;
|
int force = whence & AVSEEK_FORCE;
|
||||||
|
int buffer_size;
|
||||||
whence &= ~AVSEEK_FORCE;
|
whence &= ~AVSEEK_FORCE;
|
||||||
|
|
||||||
if(!s)
|
if(!s)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
pos = s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer));
|
buffer_size = s->buf_end - s->buffer;
|
||||||
|
pos = s->pos - (s->write_flag ? 0 : buffer_size);
|
||||||
|
|
||||||
if (whence != SEEK_CUR && whence != SEEK_SET)
|
if (whence != SEEK_CUR && whence != SEEK_SET)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
@@ -219,7 +221,7 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
|
|||||||
}
|
}
|
||||||
offset1 = offset - pos;
|
offset1 = offset - pos;
|
||||||
if (!s->must_flush && (!s->direct || !s->seek) &&
|
if (!s->must_flush && (!s->direct || !s->seek) &&
|
||||||
offset1 >= 0 && offset1 <= (s->buf_end - s->buffer)) {
|
offset1 >= 0 && offset1 <= buffer_size) {
|
||||||
/* can do the seek inside the buffer */
|
/* can do the seek inside the buffer */
|
||||||
s->buf_ptr = s->buffer + offset1;
|
s->buf_ptr = s->buffer + offset1;
|
||||||
} else if ((!s->seekable ||
|
} else if ((!s->seekable ||
|
||||||
|
Reference in New Issue
Block a user