fixed new_chunk calculation at seeking (seeking not work yet) and added -nosound support

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5439 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2002-03-31 22:44:03 +00:00
parent 45b4de7e32
commit bed8c3279f
1 changed files with 15 additions and 11 deletions

View File

@ -49,16 +49,13 @@ typedef struct _film_data_t
void demux_seek_film(demuxer_t *demuxer, float rel_seek_secs, int flags) void demux_seek_film(demuxer_t *demuxer, float rel_seek_secs, int flags)
{ {
film_data_t *film_data = (film_data_t *)demuxer->priv; film_data_t *film_data = (film_data_t *)demuxer->priv;
int new_current_chunk; int new_current_chunk=(flags&1)?0:film_data->current_chunk;
// bit 2 of the flags apparently means that the seek is relative to if(flags&2)
// the beginning of the file new_current_chunk += rel_seek_secs * film_data->total_chunks; // 0..1
if (flags & 1)
new_current_chunk =
rel_seek_secs * film_data->chunks_per_second;
else else
new_current_chunk = film_data->current_chunk + new_current_chunk += rel_seek_secs * film_data->chunks_per_second; // secs
rel_seek_secs * film_data->chunks_per_second;
printf ("current, total chunks = %d, %d; seek %5.3f sec, new chunk guess = %d\n", printf ("current, total chunks = %d, %d; seek %5.3f sec, new chunk guess = %d\n",
film_data->current_chunk, film_data->total_chunks, film_data->current_chunk, film_data->total_chunks,
@ -110,6 +107,7 @@ int demux_film_fill_buffer(demuxer_t *demuxer)
// (all ones in syncinfo1 indicates an audio chunk) // (all ones in syncinfo1 indicates an audio chunk)
if (film_chunk.syncinfo1 == 0xFFFFFFFF) if (film_chunk.syncinfo1 == 0xFFFFFFFF)
{ {
if(demuxer->audio->id>=-1){ // audio not disabled
dp = new_demux_packet(film_chunk.chunk_size); dp = new_demux_packet(film_chunk.chunk_size);
if (stream_read(demuxer->stream, dp->buffer, film_chunk.chunk_size) != if (stream_read(demuxer->stream, dp->buffer, film_chunk.chunk_size) !=
film_chunk.chunk_size) film_chunk.chunk_size)
@ -134,7 +132,7 @@ int demux_film_fill_buffer(demuxer_t *demuxer)
// append packet to DS stream // append packet to DS stream
ds_add_packet(demuxer->audio, dp); ds_add_packet(demuxer->audio, dp);
film_data->current_chunk++; }
} }
else else
{ {
@ -171,16 +169,15 @@ int demux_film_fill_buffer(demuxer_t *demuxer)
// append packet to DS stream // append packet to DS stream
ds_add_packet(demuxer->video, dp); ds_add_packet(demuxer->video, dp);
film_data->current_chunk++;
} }
else else
{ {
ds_read_packet(demuxer->video, demuxer->stream, film_chunk.chunk_size, ds_read_packet(demuxer->video, demuxer->stream, film_chunk.chunk_size,
film_chunk.pts, film_chunk.pts,
film_chunk.chunk_offset, (film_chunk.syncinfo1 & 0x80000000) ? 1 : 0); film_chunk.chunk_offset, (film_chunk.syncinfo1 & 0x80000000) ? 1 : 0);
}
}
film_data->current_chunk++; film_data->current_chunk++;
}
}
return 1; return 1;
} }
@ -266,6 +263,12 @@ demuxer_t* demux_open_film(demuxer_t* demuxer)
// skip height and width if no video // skip height and width if no video
stream_skip(demuxer->stream, 8); stream_skip(demuxer->stream, 8);
if(demuxer->audio->id<-1){
printf("chunk size = 0x%X \n",chunk_size);
stream_skip(demuxer->stream, chunk_size-12-8);
break; // audio disabled (or no soundcard)
}
// skip over unknown byte, but only if file had non-NULL version // skip over unknown byte, but only if file had non-NULL version
if (film_data->film_version) if (film_data->film_version)
stream_skip(demuxer->stream, 1); stream_skip(demuxer->stream, 1);
@ -378,6 +381,7 @@ demuxer_t* demux_open_film(demuxer_t* demuxer)
// precalculate PTS // precalculate PTS
if (film_chunk.syncinfo1 == 0xFFFFFFFF) if (film_chunk.syncinfo1 == 0xFFFFFFFF)
{ {
if(demuxer->audio->id>=-1)
film_chunk.pts = film_chunk.pts =
(float)total_audio_bytes / (float)sh_audio->wf->nAvgBytesPerSec; (float)total_audio_bytes / (float)sh_audio->wf->nAvgBytesPerSec;
total_audio_bytes += film_chunk.chunk_size; total_audio_bytes += film_chunk.chunk_size;