changeset 24450:d8b25c8a4ea4

Small simplifications
author reimar
date Fri, 14 Sep 2007 16:21:12 +0000
parents 1007f99949af
children abcfa91fcc9a
files libmpdemux/demux_ty.c
diffstat 1 files changed, 4 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_ty.c	Fri Sep 14 16:12:33 2007 +0000
+++ b/libmpdemux/demux_ty.c	Fri Sep 14 16:21:12 2007 +0000
@@ -140,7 +140,6 @@
    char    *sizestr;
    int     size;
    int     count;
-   int     blocks;
    int     done;
    off_t   offset;
    off_t   totalsize;
@@ -185,9 +184,8 @@
       sizestr[11] = 0;
       size = strtol(sizestr, NULL, 8);
 
-      blocks = size / 512;
-      if ( size % 512 > 0 ) blocks++;
-      skip = ( blocks + 1 ) * 512;
+      // size rounded up to blocks + header size
+      skip = 512 + ((size + 511) & ~511);
 
       if ( offset + skip > totalsize )
       {
@@ -204,8 +202,7 @@
          tivo->tmfparts[ parts ].fileNo = parts;
          tivo->tmfparts[ parts ].fileSize = size;
          tivo->tmfparts[ parts ].startOffset = offset + 512;
-         tivo->tmfparts[ parts ].chunks = 
-            tivo->tmfparts[ parts ].fileSize / CHUNKSIZE;
+         tivo->tmfparts[ parts ].chunks = size / CHUNKSIZE;
          mp_msg
          ( 
             MSGT_DEMUX, MSGL_DBG3,
@@ -251,7 +248,7 @@
    for( index = 0 ; index < tivo->tmf_totalparts ; index++ )
    {
       tivo->tmf_totalsize += tivo->tmfparts[ index ].fileSize;
-      tivo->tmf_totalchunks += tivo->tmfparts[ index ].fileSize / CHUNKSIZE;
+      tivo->tmf_totalchunks += tivo->tmfparts[ index ].chunks;
    }
    mp_msg( MSGT_DEMUX, MSGL_DBG3,
       "tmf_filetoparts():total size %"PRId64"\n", (int64_t)tivo->tmf_totalsize );