Ticket #1006: tydemux.diff

File tydemux.diff, 1.4 KB (added by mplayer@…, 18 years ago)

Hunt for chained PES headers at the end of non-TMF ty files

  • /build/local/MPlayer-1.0rc2/libmpdemux/demux_ty.c

    old new  
    427427
    428428               if ( readSize == CHUNKSIZE && AV_RB32(chunk) == TIVO_PES_FILEID )
    429429               {
    430                      int size = AV_RB24(chunk + 12);
    431                      size -= 4;
     430                     off_t size = AV_RB24(chunk + 12);
    432431                     size *= CHUNKSIZE;
    433                      tivo->size = numberParts * TIVO_PART_LENGTH;
    434                      tivo->size += size;
     432                     size += numberParts * TIVO_PART_LENGTH;
     433
     434                     if (tivo->tmf != 1) {
     435                         /* If this isn't TMF, there may be more chained
     436                          * PES headers on the end of this PART */
     437                         while ( size + CHUNKSIZE * 2 <
     438                                 demux->stream->end_pos ) {
     439                             stream_seek( demux->stream, size + CHUNKSIZE );
     440                             readSize = stream_read(demux->stream, chunk,
     441                                                    CHUNKSIZE);
     442                             if ( readSize != CHUNKSIZE ||
     443                                  AV_RB32(chunk) != TIVO_PES_FILEID ) break;
     444                             size += (AV_RB24(chunk + 12) + 1) * CHUNKSIZE;
     445                         }
     446                     }
     447                     size -= 4 * CHUNKSIZE;
     448                     tivo->size = size;
    435449                     mp_msg( MSGT_DEMUX, MSGL_DBG3,
    436450                        "ty:Header Calc Stream Size %"PRId64"\n", tivo->size );
    437451               }