mirror of
https://github.com/mpv-player/mpv
synced 2025-02-07 23:51:49 +00:00
Simplify tmf_filetooffset
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24471 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
1498c9b7d0
commit
9ec6875d20
@ -260,27 +260,15 @@ static int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo )
|
||||
|
||||
|
||||
// ===========================================================================
|
||||
static void tmf_filetooffset( TiVoInfo *tivo, int chunk, off_t *offset )
|
||||
static off_t tmf_filetooffset(TiVoInfo *tivo, int chunk)
|
||||
{
|
||||
int index;
|
||||
|
||||
*offset = 0;
|
||||
|
||||
for( index = 0 ; index < tivo->tmf_totalparts ; index++ )
|
||||
{
|
||||
if ( chunk >= tivo->tmfparts[ index ].chunks )
|
||||
chunk -= tivo->tmfparts[ index ].chunks;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if ( chunk < tivo->tmfparts[ index ].chunks )
|
||||
*offset = tivo->tmfparts[ index ].startOffset +
|
||||
chunk * CHUNKSIZE;
|
||||
mp_msg
|
||||
(
|
||||
MSGT_DEMUX, MSGL_DBG3,
|
||||
"tmf_filetooffset() offset %"PRIx64"\n", *offset
|
||||
);
|
||||
int i;
|
||||
for (i = 0; i < tivo->tmf_totalparts; i++) {
|
||||
if (chunk < tivo->tmfparts[i].chunks)
|
||||
return tivo->tmfparts[i].startOffset + chunk * CHUNKSIZE;
|
||||
chunk -= tivo->tmfparts[i].chunks;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -305,7 +293,7 @@ static int tmf_load_chunk( demuxer_t *demux, TiVoInfo *tivo,
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
tmf_filetooffset( tivo, readChunk, &fileoffset );
|
||||
fileoffset = tmf_filetooffset(tivo, readChunk);
|
||||
|
||||
if ( stream_seek( demux->stream, fileoffset ) != 1 )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user