Cosmetics: remove lots of useless () and {}.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24466 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2007-09-14 15:52:46 +00:00
parent 2334d91da4
commit 4fb393a73b
1 changed files with 84 additions and 150 deletions

View File

@ -64,17 +64,17 @@ extern int sub_justify;
// e/02: Extended data services data // e/02: Extended data services data
#define TIVO_PES_FILEID ( 0xf5467abd ) #define TIVO_PES_FILEID 0xf5467abd
#define TIVO_PART_LENGTH ( 0x20000000 ) #define TIVO_PART_LENGTH 0x20000000
#define CHUNKSIZE ( 128 * 1024 ) #define CHUNKSIZE ( 128 * 1024 )
#define MAX_AUDIO_BUFFER ( 16 * 1024 ) #define MAX_AUDIO_BUFFER ( 16 * 1024 )
#define PTS_MHZ ( 90 ) #define PTS_MHZ 90
#define PTS_KHZ ( PTS_MHZ * 1000 ) #define PTS_KHZ ( PTS_MHZ * 1000 )
#define TY_V ( 1 ) #define TY_V 1
#define TY_A ( 2 ) #define TY_A 2
typedef struct stmf_fileParts typedef struct stmf_fileParts
{ {
@ -84,7 +84,7 @@ typedef struct stmf_fileParts
off_t startOffset; off_t startOffset;
} tmf_fileParts; } tmf_fileParts;
#define MAX_TMF_PARTS ( 16 ) #define MAX_TMF_PARTS 16
typedef struct sTivoInfo typedef struct sTivoInfo
{ {
@ -159,7 +159,7 @@ static int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo )
while ( done == 0 ) while ( done == 0 )
{ {
ok = stream_seek( demux->stream, offset ); ok = stream_seek( demux->stream, offset );
if ( ( offset + 512 ) == totalsize ) if ( offset + 512 == totalsize )
{ {
done = 1; done = 1;
break; break;
@ -184,10 +184,10 @@ static int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo )
size = strtol(sizestr, NULL, 8); size = strtol(sizestr, NULL, 8);
blocks = size / 512; blocks = size / 512;
if ( ( size % 512 ) > 0 ) blocks++; if ( size % 512 > 0 ) blocks++;
skip = ( blocks + 1 ) * 512; skip = ( blocks + 1 ) * 512;
if ( ( offset + skip ) > totalsize ) if ( offset + skip > totalsize )
{ {
size = totalsize - offset; size = totalsize - offset;
} }
@ -205,7 +205,7 @@ static int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo )
tivo->tmfparts[ parts ].fileSize = size - CHUNKSIZE; tivo->tmfparts[ parts ].fileSize = size - CHUNKSIZE;
tivo->tmfparts[ parts ].startOffset = offset + 512; tivo->tmfparts[ parts ].startOffset = offset + 512;
tivo->tmfparts[ parts ].chunks = tivo->tmfparts[ parts ].chunks =
( tivo->tmfparts[ parts ].fileSize / CHUNKSIZE ); tivo->tmfparts[ parts ].fileSize / CHUNKSIZE;
mp_msg mp_msg
( (
MSGT_DEMUX, MSGL_DBG3, MSGT_DEMUX, MSGL_DBG3,
@ -228,9 +228,7 @@ static int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo )
); );
parts++; parts++;
if ( parts > MAX_TMF_PARTS ) if ( parts > MAX_TMF_PARTS )
{
mp_msg( MSGT_DEMUX, MSGL_ERR, "ty:tmf too big\n" ); mp_msg( MSGT_DEMUX, MSGL_ERR, "ty:tmf too big\n" );
}
} }
if ( ( offset + skip ) > totalsize ) if ( ( offset + skip ) > totalsize )
@ -239,15 +237,11 @@ static int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo )
error = 1; error = 1;
} }
else else
{
offset += skip; offset += skip;
}
} }
if ( error ) if ( error )
{
mp_msg( MSGT_DEMUX, MSGL_DBG3, mp_msg( MSGT_DEMUX, MSGL_DBG3,
"WARNING : tmf parse error, not intact\n" ); "WARNING : tmf parse error, not intact\n" );
}
tivo->tmf_totalparts = parts; tivo->tmf_totalparts = parts;
mp_msg( MSGT_DEMUX, MSGL_DBG3, mp_msg( MSGT_DEMUX, MSGL_DBG3,
"tmf_filetoparts(): No More Part Files %d\n", parts ); "tmf_filetoparts(): No More Part Files %d\n", parts );
@ -257,14 +251,14 @@ static int ty_tmf_filetoparts( demuxer_t *demux, TiVoInfo *tivo )
for( index = 0 ; index < tivo->tmf_totalparts ; index++ ) for( index = 0 ; index < tivo->tmf_totalparts ; index++ )
{ {
tivo->tmf_totalsize += tivo->tmfparts[ index ].fileSize; tivo->tmf_totalsize += tivo->tmfparts[ index ].fileSize;
tivo->tmf_totalchunks += ( tivo->tmfparts[ index ].fileSize / CHUNKSIZE ); tivo->tmf_totalchunks += tivo->tmfparts[ index ].fileSize / CHUNKSIZE;
} }
mp_msg( MSGT_DEMUX, MSGL_DBG3, mp_msg( MSGT_DEMUX, MSGL_DBG3,
"tmf_filetoparts():total size %"PRId64"\n", (int64_t)tivo->tmf_totalsize ); "tmf_filetoparts():total size %"PRId64"\n", (int64_t)tivo->tmf_totalsize );
mp_msg( MSGT_DEMUX, MSGL_DBG3, mp_msg( MSGT_DEMUX, MSGL_DBG3,
"tmf_filetoparts():total chunks %"PRId64"\n", (int64_t)tivo->tmf_totalchunks ); "tmf_filetoparts():total chunks %"PRId64"\n", (int64_t)tivo->tmf_totalchunks );
return( 1 ); return 1;
} }
@ -278,19 +272,13 @@ static void tmf_filetooffset( TiVoInfo *tivo, int chunk, off_t *offset )
for( index = 0 ; index < tivo->tmf_totalparts ; index++ ) for( index = 0 ; index < tivo->tmf_totalparts ; index++ )
{ {
if ( chunk >= tivo->tmfparts[ index ].chunks ) if ( chunk >= tivo->tmfparts[ index ].chunks )
{
chunk -= tivo->tmfparts[ index ].chunks; chunk -= tivo->tmfparts[ index ].chunks;
}
else else
{
break; break;
}
} }
if ( chunk < tivo->tmfparts[ index ].chunks ) if ( chunk < tivo->tmfparts[ index ].chunks )
{
*offset = tivo->tmfparts[ index ].startOffset + *offset = tivo->tmfparts[ index ].startOffset +
( chunk * CHUNKSIZE ); chunk * CHUNKSIZE;
}
mp_msg mp_msg
( (
MSGT_DEMUX, MSGL_DBG3, MSGT_DEMUX, MSGL_DBG3,
@ -340,7 +328,7 @@ static int tmf_load_chunk( demuxer_t *demux, TiVoInfo *tivo,
mp_msg( MSGT_DEMUX, MSGL_DBG3, "tmf_load_chunk() end\n" ); mp_msg( MSGT_DEMUX, MSGL_DBG3, "tmf_load_chunk() end\n" );
return( count ); return count;
} }
// =========================================================================== // ===========================================================================
@ -349,14 +337,14 @@ static int tmf_load_chunk( demuxer_t *demux, TiVoInfo *tivo,
// SA TiVo 864 // SA TiVo 864
// DTiVo AC-3 1550 // DTiVo AC-3 1550
// //
#define SERIES1_PTS_LENGTH ( 11 ) #define SERIES1_PTS_LENGTH 11
#define SERIES1_PTS_OFFSET ( 6 ) #define SERIES1_PTS_OFFSET 6
#define SERIES2_PTS_LENGTH ( 16 ) #define SERIES2_PTS_LENGTH 16
#define SERIES2_PTS_OFFSET ( 9 ) #define SERIES2_PTS_OFFSET 9
#define AC3_PTS_LENGTH ( 16 ) #define AC3_PTS_LENGTH 16
#define AC3_PTS_OFFSET ( 9 ) #define AC3_PTS_OFFSET 9
#define NUMBER_DIFFERENT_AUDIO_SIZES ( 7 ) #define NUMBER_DIFFERENT_AUDIO_SIZES 7
static int Series1AudioWithPTS[ NUMBER_DIFFERENT_AUDIO_SIZES ] = static int Series1AudioWithPTS[ NUMBER_DIFFERENT_AUDIO_SIZES ] =
{ {
336 + SERIES1_PTS_LENGTH, 336 + SERIES1_PTS_LENGTH,
@ -384,11 +372,11 @@ static int IsValidAudioPacket( int size, int *ptsOffset, int *ptsLen )
*ptsLen = 0; *ptsLen = 0;
// AC-3 // AC-3
if ( ( size == 1550 ) || ( size == 1552 ) ) if ( size == 1550 || size == 1552 )
{ {
*ptsOffset = AC3_PTS_OFFSET; *ptsOffset = AC3_PTS_OFFSET;
*ptsLen = AC3_PTS_LENGTH; *ptsLen = AC3_PTS_LENGTH;
return( 1 ); return 1;
} }
// MPEG // MPEG
@ -417,12 +405,10 @@ static int IsValidAudioPacket( int size, int *ptsOffset, int *ptsLen )
{ {
mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Tossing Audio Packet Size %d\n", mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Tossing Audio Packet Size %d\n",
size ); size );
return( 0 ); return 0;
} }
else else
{ return 1;
return( 1 );
}
} }
@ -448,17 +434,15 @@ static float get_ty_pts( unsigned char *buf )
static void demux_ty_AddToAudioBuffer( TiVoInfo *tivo, unsigned char *buffer, static void demux_ty_AddToAudioBuffer( TiVoInfo *tivo, unsigned char *buffer,
int size ) int size )
{ {
if ( ( tivo->lastAudioEnd + size ) < MAX_AUDIO_BUFFER ) if ( tivo->lastAudioEnd + size < MAX_AUDIO_BUFFER )
{ {
memcpy( &( tivo->lastAudio[ tivo->lastAudioEnd ] ), memcpy( &tivo->lastAudio[ tivo->lastAudioEnd ],
buffer, size ); buffer, size );
tivo->lastAudioEnd += size; tivo->lastAudioEnd += size;
} }
else else
{
mp_msg( MSGT_DEMUX, MSGL_ERR, mp_msg( MSGT_DEMUX, MSGL_ERR,
"ty:WARNING - Would have blown my audio buffer\n" ); "ty:WARNING - Would have blown my audio buffer\n" );
}
} }
static void demux_ty_CopyToDemuxPacket( int type, TiVoInfo *tivo, demux_stream_t *ds, static void demux_ty_CopyToDemuxPacket( int type, TiVoInfo *tivo, demux_stream_t *ds,
@ -480,16 +464,12 @@ static void demux_ty_CopyToDemuxPacket( int type, TiVoInfo *tivo, demux_stream_t
if ( type == TY_V ) if ( type == TY_V )
{ {
if ( tivo->firstVideoPTS == -1 ) if ( tivo->firstVideoPTS == -1 )
{
tivo->firstVideoPTS = pts; tivo->firstVideoPTS = pts;
}
} }
if ( type == TY_A ) if ( type == TY_A )
{ {
if ( tivo->firstAudioPTS == -1 ) if ( tivo->firstAudioPTS == -1 )
{
tivo->firstAudioPTS = pts; tivo->firstAudioPTS = pts;
}
} }
} }
@ -501,16 +481,16 @@ static int demux_ty_FindESHeader( unsigned char *header, int headerSize,
*esOffset1 = -1; *esOffset1 = -1;
for( count = 0 ; count < bufferSize ; count++ ) for( count = 0 ; count < bufferSize ; count++ )
{ {
if ( ( buffer[ count + 0 ] == header[ 0 ] ) && if ( buffer[ count + 0 ] == header[ 0 ] &&
( buffer[ count + 1 ] == header[ 1 ] ) && buffer[ count + 1 ] == header[ 1 ] &&
( buffer[ count + 2 ] == header[ 2 ] ) && buffer[ count + 2 ] == header[ 2 ] &&
( buffer[ count + 3 ] == header[ 3 ] ) ) buffer[ count + 3 ] == header[ 3 ] )
{ {
*esOffset1 = count; *esOffset1 = count;
return( 1 ); return 1;
} }
} }
return( -1 ); return -1;
} }
static void demux_ty_FindESPacket( unsigned char *header, int headerSize, static void demux_ty_FindESPacket( unsigned char *header, int headerSize,
@ -523,10 +503,10 @@ static void demux_ty_FindESPacket( unsigned char *header, int headerSize,
for( count = 0 ; count < bufferSize ; count++ ) for( count = 0 ; count < bufferSize ; count++ )
{ {
if ( ( buffer[ count + 0 ] == header[ 0 ] ) && if ( buffer[ count + 0 ] == header[ 0 ] &&
( buffer[ count + 1 ] == header[ 1 ] ) && buffer[ count + 1 ] == header[ 1 ] &&
( buffer[ count + 2 ] == header[ 2 ] ) && buffer[ count + 2 ] == header[ 2 ] &&
( buffer[ count + 3 ] == header[ 3 ] ) ) buffer[ count + 3 ] == header[ 3 ] )
{ {
*esOffset1 = count; *esOffset1 = count;
break; break;
@ -538,10 +518,10 @@ static void demux_ty_FindESPacket( unsigned char *header, int headerSize,
for( count = *esOffset1 + 1 ; for( count = *esOffset1 + 1 ;
count < bufferSize ; count++ ) count < bufferSize ; count++ )
{ {
if ( ( buffer[ count + 0 ] == header[ 0 ] ) && if ( buffer[ count + 0 ] == header[ 0 ] &&
( buffer[ count + 1 ] == header[ 1 ] ) && buffer[ count + 1 ] == header[ 1 ] &&
( buffer[ count + 2 ] == header[ 2 ] ) && buffer[ count + 2 ] == header[ 2 ] &&
( buffer[ count + 3 ] == header[ 3 ] ) ) buffer[ count + 3 ] == header[ 3 ] )
{ {
*esOffset2 = count; *esOffset2 = count;
break; break;
@ -553,9 +533,7 @@ static void demux_ty_FindESPacket( unsigned char *header, int headerSize,
static int tivobuffer2hostlong( unsigned char *buffer ) static int tivobuffer2hostlong( unsigned char *buffer )
{ {
return return
( buffer[ 0 ] << 24 | buffer[ 1 ] << 16 | buffer[ 2 ] << 8 | buffer[ 3 ];
buffer[ 0 ] << 24 | buffer[ 1 ] << 16 | buffer[ 2 ] << 8 | buffer[ 3 ]
);
} }
static unsigned char ty_VideoPacket[] = { 0x00, 0x00, 0x01, 0xe0 }; static unsigned char ty_VideoPacket[] = { 0x00, 0x00, 0x01, 0xe0 };
@ -596,12 +574,10 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
TiVoInfo *tivo = 0; TiVoInfo *tivo = 0;
if ( demux->stream->type == STREAMTYPE_DVD ) if ( demux->stream->type == STREAMTYPE_DVD )
{ return 0;
return( 0 );
}
mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty processing\n" ); mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty processing\n" );
if ( ( demux->a_streams[ MAX_A_STREAMS - 1 ] ) == 0 ) if ( demux->a_streams[ MAX_A_STREAMS - 1 ] == 0 )
{ {
demux->a_streams[ MAX_A_STREAMS - 1 ] = malloc( sizeof( TiVoInfo ) ); demux->a_streams[ MAX_A_STREAMS - 1 ] = malloc( sizeof( TiVoInfo ) );
tivo = demux->a_streams[ MAX_A_STREAMS - 1 ]; tivo = demux->a_streams[ MAX_A_STREAMS - 1 ];
@ -677,7 +653,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty/ty+Number Parts %"PRId64"\n", mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty/ty+Number Parts %"PRId64"\n",
(int64_t)numberParts ); (int64_t)numberParts );
if ( ( offset + CHUNKSIZE ) < demux->stream->end_pos ) if ( offset + CHUNKSIZE < demux->stream->end_pos )
{ {
stream_seek( demux->stream, offset ); stream_seek( demux->stream, offset );
readSize = stream_read( demux->stream, chunk, CHUNKSIZE ); readSize = stream_read( demux->stream, chunk, CHUNKSIZE );
@ -688,8 +664,8 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
numberParts = tivo->tmf_totalparts; numberParts = tivo->tmf_totalparts;
offset = numberParts * TIVO_PART_LENGTH; offset = numberParts * TIVO_PART_LENGTH;
readSize = tmf_load_chunk( demux, tivo, chunk, CHUNKSIZE, readSize = tmf_load_chunk( demux, tivo, chunk, CHUNKSIZE,
( numberParts * ( TIVO_PART_LENGTH - CHUNKSIZE ) / numberParts * ( TIVO_PART_LENGTH - CHUNKSIZE ) /
CHUNKSIZE ) ); CHUNKSIZE );
} }
if ( readSize == CHUNKSIZE ) if ( readSize == CHUNKSIZE )
@ -710,17 +686,13 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
} }
} }
if ( tivo->size > demux->stream->end_pos ) if ( tivo->size > demux->stream->end_pos )
{
tivo->size = demux->stream->end_pos; tivo->size = demux->stream->end_pos;
}
if ( demux->stream->start_pos > 0 ) if ( demux->stream->start_pos > 0 )
{
filePos = demux->stream->start_pos; filePos = demux->stream->start_pos;
}
stream_seek( demux->stream, filePos ); stream_seek( demux->stream, filePos );
demux->filepos = stream_tell( demux->stream ); demux->filepos = stream_tell( demux->stream );
tivo->whichChunk = ( filePos / CHUNKSIZE ); tivo->whichChunk = filePos / CHUNKSIZE;
} }
demux->movi_start = 0; demux->movi_start = 0;
demux->movi_end = tivo->size; demux->movi_end = tivo->size;
@ -750,14 +722,14 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
if ( tivo->tmf != 1 ) if ( tivo->tmf != 1 )
{ {
// Make sure we are on a 128k boundary // Make sure we are on a 128k boundary
if ( ( demux->filepos % CHUNKSIZE ) != 0 ) if ( demux->filepos % CHUNKSIZE != 0 )
{ {
whichChunk = demux->filepos / CHUNKSIZE; whichChunk = demux->filepos / CHUNKSIZE;
if ( ( demux->filepos % CHUNKSIZE ) > ( CHUNKSIZE / 2 ) ) if ( demux->filepos % CHUNKSIZE > CHUNKSIZE / 2 )
{ {
whichChunk++; whichChunk++;
} }
stream_seek( demux->stream, ( whichChunk * CHUNKSIZE ) ); stream_seek( demux->stream, whichChunk * CHUNKSIZE );
} }
demux->filepos = stream_tell( demux->stream ); demux->filepos = stream_tell( demux->stream );
@ -773,9 +745,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
readSize = tmf_load_chunk( demux, tivo, chunk, CHUNKSIZE, readSize = tmf_load_chunk( demux, tivo, chunk, CHUNKSIZE,
tivo->whichChunk ); tivo->whichChunk );
if ( readSize != CHUNKSIZE ) if ( readSize != CHUNKSIZE )
{ return 0;
return( 0 );
}
tivo->whichChunk++; tivo->whichChunk++;
} }
@ -798,12 +768,12 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
if ( readSize != CHUNKSIZE ) if ( readSize != CHUNKSIZE )
{ {
return( 0 ); return 0;
} }
} }
mp_msg( MSGT_DEMUX, MSGL_DBG3, mp_msg( MSGT_DEMUX, MSGL_DBG3,
"\nty:actual current offset %"PRIx64"\n", ( stream_tell( demux->stream ) - "\nty:actual current offset %"PRIx64"\n", stream_tell( demux->stream ) -
CHUNKSIZE ) ); CHUNKSIZE );
// Let's make a Video Demux Stream for MPlayer // Let's make a Video Demux Stream for MPlayer
@ -822,7 +792,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty parsing a chunk\n" ); mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty parsing a chunk\n" );
numberRecs = chunk[ 0 ]; numberRecs = chunk[ 0 ];
recPtr = &chunk[ 4 ]; recPtr = &chunk[ 4 ];
offset = ( numberRecs * 16 ) + 4; offset = numberRecs * 16 + 4;
for ( counter = 0 ; counter < numberRecs ; counter++ ) for ( counter = 0 ; counter < numberRecs ; counter++ )
{ {
size = ( recPtr[ 0 ] << 8 | recPtr[ 1 ] ) << 4 | ( recPtr[ 2 ] >> 4 ); size = ( recPtr[ 0 ] << 8 | recPtr[ 1 ] ) << 4 | ( recPtr[ 2 ] >> 4 );
@ -838,7 +808,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
// ================================================================ // ================================================================
if ( type == 0xe0 ) if ( type == 0xe0 )
{ {
if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) ) if ( size > 0 && size + offset <= CHUNKSIZE )
{ {
#if 0 #if 0
printf( "Video Chunk Header " ); printf( "Video Chunk Header " );
@ -860,24 +830,20 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
// Do NOT Pass the PES Header onto the MPEG2 Decode // Do NOT Pass the PES Header onto the MPEG2 Decode
if( nybbleType != 0x06 ) if( nybbleType != 0x06 )
{
demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video, demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video,
&chunk[ offset ], size, ( demux->filepos + offset ), &chunk[ offset ], size, demux->filepos + offset,
tivo->lastVideoPTS ); tivo->lastVideoPTS );
}
offset += size; offset += size;
} }
else else
{
errorHeader++; errorHeader++;
}
} }
// ================================================================ // ================================================================
// Audio Parsing // Audio Parsing
// ================================================================ // ================================================================
else if ( type == 0xc0 ) else if ( type == 0xc0 )
{ {
if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) ) if ( size > 0 && size + offset <= CHUNKSIZE )
{ {
#if 0 #if 0
printf( "Audio Chunk Header " ); printf( "Audio Chunk Header " );
@ -891,9 +857,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
if( demux->audio->id == -1 ) if( demux->audio->id == -1 )
{ {
if ( nybbleType == 0x02 ) if ( nybbleType == 0x02 )
{
continue; // DTiVo inconclusive, wait for more continue; // DTiVo inconclusive, wait for more
}
else if ( nybbleType == 0x09 ) else if ( nybbleType == 0x09 )
{ {
mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Setting AC-3 Audio\n" ); mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Setting AC-3 Audio\n" );
@ -932,9 +896,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
if ( nybbleType == 0x02 ) if ( nybbleType == 0x02 )
{ {
if ( tivo->tivoType == 2 ) if ( tivo->tivoType == 2 )
{
demux_ty_AddToAudioBuffer( tivo, &chunk[ offset ], size ); demux_ty_AddToAudioBuffer( tivo, &chunk[ offset ], size );
}
else else
{ {
@ -955,7 +917,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
// SA PES Header, No Audio Data // SA PES Header, No Audio Data
// ================================================ // ================================================
if ( ( esOffset1 == 0 ) && ( size == 16 ) ) if ( esOffset1 == 0 && size == 16 )
{ {
tivo->tivoType = 1; tivo->tivoType = 1;
tivo->lastAudioPTS = get_ty_pts( &chunk[ offset + tivo->lastAudioPTS = get_ty_pts( &chunk[ offset +
@ -974,7 +936,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
tivo->lastAudio, tivo->lastAudioEnd, &esOffset1, tivo->lastAudio, tivo->lastAudioEnd, &esOffset1,
&esOffset2 ); &esOffset2 );
if ( ( esOffset1 != -1 ) && ( esOffset2 != -1 ) ) if ( esOffset1 != -1 && esOffset2 != -1 )
{ {
int packetSize = esOffset2 - esOffset1; int packetSize = esOffset2 - esOffset1;
int headerSize; int headerSize;
@ -1006,9 +968,9 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
} }
// Collapse the Audio Buffer // Collapse the Audio Buffer
memmove( &(tivo->lastAudio[ 0 ] ), memmove( &tivo->lastAudio[ 0 ],
&( tivo->lastAudio[ esOffset2 ] ), &tivo->lastAudio[ esOffset2 ],
( tivo->lastAudioEnd - esOffset2 ) ); tivo->lastAudioEnd - esOffset2 );
tivo->lastAudioEnd -= esOffset2; tivo->lastAudioEnd -= esOffset2;
} }
} }
@ -1036,7 +998,7 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
tivo->lastAudio, tivo->lastAudioEnd, &esOffset1, tivo->lastAudio, tivo->lastAudioEnd, &esOffset1,
&esOffset2 ); &esOffset2 );
if ( ( esOffset1 != -1 ) && ( esOffset2 != -1 ) ) if ( esOffset1 != -1 && esOffset2 != -1 )
{ {
int packetSize = esOffset2 - esOffset1; int packetSize = esOffset2 - esOffset1;
int headerSize; int headerSize;
@ -1060,27 +1022,25 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
TY_A, TY_A,
tivo, tivo,
demux->audio, demux->audio,
&( tivo->lastAudio[ esOffset1 ] ), &tivo->lastAudio[ esOffset1 ],
( packetSize ), packetSize,
( demux->filepos + offset ), demux->filepos + offset,
tivo->lastAudioPTS tivo->lastAudioPTS
); );
} }
// Collapse the Audio Buffer // Collapse the Audio Buffer
memmove( &(tivo->lastAudio[ 0 ] ), memmove( &tivo->lastAudio[ 0 ],
&( tivo->lastAudio[ esOffset2 ] ), &tivo->lastAudio[ esOffset2 ],
( tivo->lastAudioEnd - esOffset2 ) ); tivo->lastAudioEnd - esOffset2 );
tivo->lastAudioEnd -= esOffset2; tivo->lastAudioEnd -= esOffset2;
} }
} }
offset += size; offset += size;
} }
else else
{
errorHeader++; errorHeader++;
}
} }
// ================================================================ // ================================================================
// Closed Caption // Closed Caption
@ -1109,10 +1069,8 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
lastCC[ 0x07 ] = b1; lastCC[ 0x07 ] = b1;
lastCC[ 0x08 ] = b2; lastCC[ 0x08 ] = b2;
if ( subcc_enabled ) if ( subcc_enabled )
{
demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video, lastCC, 0x09, demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video, lastCC, 0x09,
( demux->filepos + offset ), tivo->lastVideoPTS ); ( demux->filepos + offset ), tivo->lastVideoPTS );
}
} }
// ================================================================ // ================================================================
// Extended Data Services // Extended Data Services
@ -1141,47 +1099,37 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
lastXDS[ 0x07 ] = b1; lastXDS[ 0x07 ] = b1;
lastXDS[ 0x08 ] = b2; lastXDS[ 0x08 ] = b2;
if ( subcc_enabled ) if ( subcc_enabled )
{
demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video, lastXDS, 0x09, demux_ty_CopyToDemuxPacket( TY_V, tivo, demux->video, lastXDS, 0x09,
( demux->filepos + offset ), tivo->lastVideoPTS ); ( demux->filepos + offset ), tivo->lastVideoPTS );
}
} }
// ================================================================ // ================================================================
// Found a 0x03 on Droid's TiVo, I have no idea what it is // Found a 0x03 on Droid's TiVo, I have no idea what it is
// ================================================================ // ================================================================
else if ( type == 0x03 ) else if ( type == 0x03 )
{ {
if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) ) if ( size > 0 && size + offset <= CHUNKSIZE )
{
offset += size; offset += size;
}
} }
// ================================================================ // ================================================================
// Found a 0x03 on Hermit's TiVo, I have no idea what it is // Found a 0x03 on Hermit's TiVo, I have no idea what it is
// ================================================================ // ================================================================
else if ( type == 0x03 ) else if ( type == 0x03 )
{ {
if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) ) if ( size > 0 && size + offset <= CHUNKSIZE )
{
offset += size; offset += size;
}
} }
// ================================================================ // ================================================================
// Unknown // Unknown
// ================================================================ // ================================================================
else if ( type == 0x05 ) else if ( type == 0x05 )
{ {
if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) ) if ( size > 0 && size + offset <= CHUNKSIZE )
{
offset += size; offset += size;
}
} }
else else
{ {
if ( ( size > 0 ) && ( ( size + offset ) <= CHUNKSIZE ) ) if ( size > 0 && size + offset <= CHUNKSIZE )
{
offset += size; offset += size;
}
mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Invalid Type %x\n", type ); mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Invalid Type %x\n", type );
invalidType++; invalidType++;
} }
@ -1195,21 +1143,21 @@ static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
numberRecs, recordsDecoded, errorHeader, invalidType ); numberRecs, recordsDecoded, errorHeader, invalidType );
// Invalid MPEG ES Size Check // Invalid MPEG ES Size Check
if ( errorHeader > ( numberRecs / 2 ) ) if ( errorHeader > numberRecs / 2 )
{ {
return( 0 ); return 0;
} }
// Invalid MPEG Stream Type Check // Invalid MPEG Stream Type Check
if ( invalidType > ( numberRecs / 2 ) ) if ( invalidType > numberRecs / 2 )
{ {
return( 0 ); return 0;
} }
} }
demux->filepos = stream_tell( demux->stream ); demux->filepos = stream_tell( demux->stream );
return( 1 ); return 1;
} }
static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags ) static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags )
@ -1224,7 +1172,7 @@ static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_
mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Seeking to %7.1f\n", rel_seek_secs ); mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Seeking to %7.1f\n", rel_seek_secs );
if ( ( demuxer->a_streams[ MAX_A_STREAMS - 1 ] ) != 0 ) if ( demuxer->a_streams[ MAX_A_STREAMS - 1 ] != 0 )
{ {
tivo = demuxer->a_streams[ MAX_A_STREAMS - 1 ]; tivo = demuxer->a_streams[ MAX_A_STREAMS - 1 ];
tivo->lastAudioEnd = 0; tivo->lastAudioEnd = 0;
@ -1246,13 +1194,9 @@ static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_
{ {
// time seek (secs) // time seek (secs)
if( ! sh_video->i_bps ) // unspecified or VBR if( ! sh_video->i_bps ) // unspecified or VBR
{
newpos += 2324 * 75 * rel_seek_secs; // 174.3 kbyte/sec newpos += 2324 * 75 * rel_seek_secs; // 174.3 kbyte/sec
}
else else
{
newpos += sh_video->i_bps * rel_seek_secs; newpos += sh_video->i_bps * rel_seek_secs;
}
} }
if ( newpos < demuxer->movi_start ) if ( newpos < demuxer->movi_start )
@ -1263,18 +1207,12 @@ static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_
res = newpos / CHUNKSIZE; res = newpos / CHUNKSIZE;
if ( rel_seek_secs >= 0 ) if ( rel_seek_secs >= 0 )
{
newpos = ( res + 1 ) * CHUNKSIZE; newpos = ( res + 1 ) * CHUNKSIZE;
}
else else
{
newpos = res * CHUNKSIZE; newpos = res * CHUNKSIZE;
}
if ( newpos < 0 ) if ( newpos < 0 )
{
newpos = 0; newpos = 0;
}
tivo->whichChunk = newpos / CHUNKSIZE; tivo->whichChunk = newpos / CHUNKSIZE;
@ -1285,9 +1223,7 @@ static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_
ds_fill_buffer( d_video ); ds_fill_buffer( d_video );
if( sh_audio ) if( sh_audio )
{
ds_fill_buffer( d_audio ); ds_fill_buffer( d_audio );
}
while( 1 ) while( 1 )
{ {
@ -1308,9 +1244,7 @@ static void demux_seek_ty( demuxer_t *demuxer, float rel_seek_secs, float audio_
if( !i || !skip_video_packet( d_video ) ) break; // EOF? if( !i || !skip_video_packet( d_video ) ) break; // EOF?
} }
if ( subcc_enabled ) if ( subcc_enabled )
{
ty_ClearOSD( 0 ); ty_ClearOSD( 0 );
}
} }
static int demux_ty_control( demuxer_t *demuxer,int cmd, void *arg ) static int demux_ty_control( demuxer_t *demuxer,int cmd, void *arg )
@ -1323,8 +1257,8 @@ static int demux_ty_control( demuxer_t *demuxer,int cmd, void *arg )
case DEMUXER_CTRL_GET_TIME_LENGTH: case DEMUXER_CTRL_GET_TIME_LENGTH:
if(!sh_video->i_bps) // unspecified or VBR if(!sh_video->i_bps) // unspecified or VBR
return DEMUXER_CTRL_DONTKNOW; return DEMUXER_CTRL_DONTKNOW;
*((double *)arg)= *(double *)arg=
((double)demuxer->movi_end-demuxer->movi_start)/sh_video->i_bps; (double)demuxer->movi_end-demuxer->movi_start/sh_video->i_bps;
return DEMUXER_CTRL_GUESS; return DEMUXER_CTRL_GUESS;
case DEMUXER_CTRL_GET_PERCENT_POS: case DEMUXER_CTRL_GET_PERCENT_POS:
@ -1339,7 +1273,7 @@ static void demux_close_ty( demuxer_t *demux )
{ {
TiVoInfo *tivo = 0; TiVoInfo *tivo = 0;
if ( ( demux->a_streams[ MAX_A_STREAMS - 1 ] ) != 0 ) if ( demux->a_streams[ MAX_A_STREAMS - 1 ] != 0 )
{ {
tivo = demux->a_streams[ MAX_A_STREAMS - 1 ]; tivo = demux->a_streams[ MAX_A_STREAMS - 1 ];
free( tivo ); free( tivo );