comparison libmpdemux/demux_ty.c @ 24477:8c9d86adb28e

Move variable declarations into the block where they are used
author reimar
date Fri, 14 Sep 2007 19:46:54 +0000
parents b42dd327f81f
children 43c9c72b8c54
comparison
equal deleted inserted replaced
24476:b42dd327f81f 24477:8c9d86adb28e
423 static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds ) 423 static int demux_ty_fill_buffer( demuxer_t *demux, demux_stream_t *dsds )
424 { 424 {
425 int invalidType = 0; 425 int invalidType = 0;
426 int errorHeader = 0; 426 int errorHeader = 0;
427 int recordsDecoded = 0; 427 int recordsDecoded = 0;
428 off_t filePos = 0;
429 428
430 unsigned char chunk[ CHUNKSIZE ]; 429 unsigned char chunk[ CHUNKSIZE ];
431 int whichChunk;
432 int readSize; 430 int readSize;
433 431
434 int numberRecs; 432 int numberRecs;
435 unsigned char *recPtr; 433 unsigned char *recPtr;
436 int offset; 434 int offset;
437 int size;
438
439 int type;
440 int nybbleType;
441 435
442 int counter; 436 int counter;
443 437
444 int aid; 438 int aid;
445 demux_stream_t *ds = NULL;
446 439
447 int esOffset1;
448 int esOffset2;
449
450 unsigned char lastXDS[ 16 ];
451
452 TiVoInfo *tivo = demux->priv; 440 TiVoInfo *tivo = demux->priv;
453 441
454 if ( demux->stream->type == STREAMTYPE_DVD ) 442 if ( demux->stream->type == STREAMTYPE_DVD )
455 return 0; 443 return 0;
456 444
476 // calculate the ACTUAL stream size 464 // calculate the ACTUAL stream size
477 // If we can't find it, go off with the file size and hope the 465 // If we can't find it, go off with the file size and hope the
478 // extract program did the "right thing" 466 // extract program did the "right thing"
479 if ( tivo->readHeader == 0 ) 467 if ( tivo->readHeader == 0 )
480 { 468 {
469 off_t filePos;
481 tivo->readHeader = 1; 470 tivo->readHeader = 1;
482 tivo->size = demux->stream->end_pos; 471 tivo->size = demux->stream->end_pos;
483 472
484 filePos = demux->filepos; 473 filePos = demux->filepos;
485 stream_seek( demux->stream, 0 ); 474 stream_seek( demux->stream, 0 );
528 CHUNKSIZE ); 517 CHUNKSIZE );
529 } 518 }
530 519
531 if ( readSize == CHUNKSIZE && AV_RB32(chunk) == TIVO_PES_FILEID ) 520 if ( readSize == CHUNKSIZE && AV_RB32(chunk) == TIVO_PES_FILEID )
532 { 521 {
533 size = AV_RB24(chunk + 12); 522 int size = AV_RB24(chunk + 12);
534 size -= 4; 523 size -= 4;
535 size *= CHUNKSIZE; 524 size *= CHUNKSIZE;
536 tivo->size = numberParts * TIVO_PART_LENGTH; 525 tivo->size = numberParts * TIVO_PART_LENGTH;
537 tivo->size += size; 526 tivo->size += size;
538 mp_msg( MSGT_DEMUX, MSGL_DBG3, 527 mp_msg( MSGT_DEMUX, MSGL_DBG3,
573 if ( tivo->tmf != 1 ) 562 if ( tivo->tmf != 1 )
574 { 563 {
575 // Make sure we are on a 128k boundary 564 // Make sure we are on a 128k boundary
576 if ( demux->filepos % CHUNKSIZE != 0 ) 565 if ( demux->filepos % CHUNKSIZE != 0 )
577 { 566 {
578 whichChunk = demux->filepos / CHUNKSIZE; 567 int whichChunk = demux->filepos / CHUNKSIZE;
579 if ( demux->filepos % CHUNKSIZE > CHUNKSIZE / 2 ) 568 if ( demux->filepos % CHUNKSIZE > CHUNKSIZE / 2 )
580 whichChunk++; 569 whichChunk++;
581 stream_seek( demux->stream, whichChunk * CHUNKSIZE ); 570 stream_seek( demux->stream, whichChunk * CHUNKSIZE );
582 } 571 }
583 572
624 aid = 0x0; 613 aid = 0x0;
625 if( !demux->v_streams[ aid ] ) new_sh_video( demux, aid ); 614 if( !demux->v_streams[ aid ] ) new_sh_video( demux, aid );
626 if( demux->video->id == -1 ) demux->video->id = aid; 615 if( demux->video->id == -1 ) demux->video->id = aid;
627 if( demux->video->id == aid ) 616 if( demux->video->id == aid )
628 { 617 {
629 ds = demux->video; 618 demux_stream_t *ds = demux->video;
630 if( !ds->sh ) ds->sh = demux->v_streams[ aid ]; 619 if( !ds->sh ) ds->sh = demux->v_streams[ aid ];
631 } 620 }
632 621
633 // ====================================================================== 622 // ======================================================================
634 // Finally, we get to actually parse the chunk 623 // Finally, we get to actually parse the chunk
637 numberRecs = chunk[ 0 ]; 626 numberRecs = chunk[ 0 ];
638 recPtr = &chunk[ 4 ]; 627 recPtr = &chunk[ 4 ];
639 offset = numberRecs * 16 + 4; 628 offset = numberRecs * 16 + 4;
640 for ( counter = 0 ; counter < numberRecs ; counter++ ) 629 for ( counter = 0 ; counter < numberRecs ; counter++ )
641 { 630 {
642 size = AV_RB24(recPtr) >> 4; 631 int size = AV_RB24(recPtr) >> 4;
643 type = recPtr[ 3 ]; 632 int type = recPtr[ 3 ];
644 nybbleType = recPtr[ 2 ] & 0x0f; 633 int nybbleType = recPtr[ 2 ] & 0x0f;
645 recordsDecoded++; 634 recordsDecoded++;
646 635
647 mp_msg( MSGT_DEMUX, MSGL_DBG3, 636 mp_msg( MSGT_DEMUX, MSGL_DBG3,
648 "ty:Record Type %x/%x %d\n", nybbleType, type, size ); 637 "ty:Record Type %x/%x %d\n", nybbleType, type, size );
649 638
652 // ================================================================ 641 // ================================================================
653 if ( type == 0xe0 ) 642 if ( type == 0xe0 )
654 { 643 {
655 if ( size > 0 && size + offset <= CHUNKSIZE ) 644 if ( size > 0 && size + offset <= CHUNKSIZE )
656 { 645 {
646 int esOffset1;
657 #if 0 647 #if 0
658 printf( "Video Chunk Header " ); 648 printf( "Video Chunk Header " );
659 for( count = 0 ; count < 24 ; count++ ) 649 for( count = 0 ; count < 24 ; count++ )
660 { 650 {
661 printf( "%2.2x ", chunk[ offset + count ] ); 651 printf( "%2.2x ", chunk[ offset + count ] );
711 701
712 demux->audio->id = aid; 702 demux->audio->id = aid;
713 if( !demux->a_streams[ aid ] ) new_sh_audio( demux, aid ); 703 if( !demux->a_streams[ aid ] ) new_sh_audio( demux, aid );
714 if( demux->audio->id == aid ) 704 if( demux->audio->id == aid )
715 { 705 {
716 ds = demux->audio; 706 demux_stream_t *ds = demux->audio;
717 if( !ds->sh ) { 707 if( !ds->sh ) {
718 sh_audio_t* sh_a; 708 sh_audio_t* sh_a;
719 ds->sh = demux->a_streams[ aid ]; 709 ds->sh = demux->a_streams[ aid ];
720 sh_a = (sh_audio_t*)ds->sh; 710 sh_a = (sh_audio_t*)ds->sh;
721 switch(aid & 0xE0){ // 1110 0000 b (high 3 bit: type low 5: id) 711 switch(aid & 0xE0){ // 1110 0000 b (high 3 bit: type low 5: id)
751 // 3 - MPEG Audio with PES Header, either SA or DTiVo 741 // 3 - MPEG Audio with PES Header, either SA or DTiVo
752 // 9 - DTiVo AC3 Audio Data with PES Header 742 // 9 - DTiVo AC3 Audio Data with PES Header
753 // ================================================ 743 // ================================================
754 if ( nybbleType == 0x03 || nybbleType == 0x09 ) 744 if ( nybbleType == 0x03 || nybbleType == 0x09 )
755 { 745 {
746 int esOffset1, esOffset2;
756 if ( nybbleType == 0x03 ) 747 if ( nybbleType == 0x03 )
757 demux_ty_FindESHeader( ty_MPEGAudioPacket, 4, &chunk[ offset ], 748 demux_ty_FindESHeader( ty_MPEGAudioPacket, 4, &chunk[ offset ],
758 size, &esOffset1 ); 749 size, &esOffset1 );
759 750
760 // SA PES Header, No Audio Data 751 // SA PES Header, No Audio Data