Do not discard stream buffer on eof, instead reuse it to slightly improve

format autodetection with -nocache and non-seekable streams.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30668 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2010-02-20 18:53:07 +00:00
parent 908f8c91e7
commit 9554a844e9
3 changed files with 7 additions and 5 deletions

View File

@ -247,7 +247,7 @@ demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
"big troubles ahead.");
if (filename) // Filename hack for avs_check_file
d->filename = strdup(filename);
stream_reset(stream);
stream->eof = 0;
stream_seek(stream, stream->start_pos);
return d;
}

View File

@ -264,7 +264,7 @@ stream_t* open_output_stream(char* filename,char** options) {
int stream_fill_buffer(stream_t *s){
int len;
if (/*s->fd == NULL ||*/ s->eof) { s->buf_pos = s->buf_len = 0; return 0; }
if (/*s->fd == NULL ||*/ s->eof) { return 0; }
switch(s->type){
case STREAMTYPE_STREAM:
#ifdef CONFIG_NETWORK
@ -285,7 +285,7 @@ int stream_fill_buffer(stream_t *s){
default:
len= s->fill_buffer ? s->fill_buffer(s,s->buffer,STREAM_BUFFER_SIZE) : 0;
}
if(len<=0){ s->eof=1; s->buf_pos=s->buf_len=0; return 0; }
if(len<=0){ s->eof=1; return 0; }
s->buf_pos=0;
s->buf_len=len;
s->pos+=len;
@ -392,8 +392,8 @@ while(stream_fill_buffer(s) > 0 && pos >= 0) {
void stream_reset(stream_t *s){
if(s->eof){
s->pos=0; //ftell(f);
// s->buf_pos=s->buf_len=0;
s->pos=0;
s->buf_pos=s->buf_len=0;
s->eof=0;
}
if(s->control) s->control(s,STREAM_CTRL_RESET,NULL);

View File

@ -282,6 +282,8 @@ inline static int stream_seek(stream_t *s,off_t pos){
mp_dbg(MSGT_DEMUX, MSGL_DBG3, "seek to 0x%qX\n",(long long)pos);
if(s->eof)
return 0;
if(pos<s->pos){
off_t x=pos-(s->pos-s->buf_len);
if(x>=0){