- return -EINVAL;
-
-#ifdef CONFIG_ENCODERS
- if (s->write_flag) {
- if (whence == SEEK_CUR) {
- offset1 = s->pos + (s->buf_ptr - s->buffer);
- if (offset == 0)
- return offset1;
- offset += offset1;
- }
- offset1 = offset - s->pos;
- if (!s->must_flush &&
- offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
- /* can do the seek inside the buffer */
- s->buf_ptr = s->buffer + offset1;
- } else {
- if (!s->seek)
- return -EPIPE;
+ return AVERROR(EINVAL);
+
+ if (whence == SEEK_CUR) {
+ offset1 = pos + (s->buf_ptr - s->buffer);
+ if (offset == 0)
+ return offset1;
+ offset += offset1;
+ }
+ offset1 = offset - pos;
+ if (!s->must_flush &&
+ offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
+ /* can do the seek inside the buffer */
+ s->buf_ptr = s->buffer + offset1;
+ } else if(s->is_streamed && !s->write_flag &&
+ offset1 >= 0 && offset1 < (s->buf_end - s->buffer) + (1<<16)){
+ while(s->pos < offset && !s->eof_reached)
+ fill_buffer(s);
+ s->buf_ptr = s->buf_end + offset - s->pos;
+ } else {
+ offset_t res = AVERROR(EPIPE);
+
+#if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK)
+ if (s->write_flag) {