[Approved] - Fix for TsReader problems with TS files with PCR rollover

Discussion in 'Archive' started by asselin, June 29, 2011.

  1. asselin
    • Premium Supporter

    asselin MP Donator

    Joined:
    May 29, 2010
    Messages:
    9
    Likes Received:
    11
    Ratings:
    +11 / 0
    Home Country:
    United States of America United States of America
    Continuing this from the thread I started over here: https://forum.team-mediaportal.com/...ies-when-dealing-ts-files-pcr-rollover-97975/.

    TsReader has 2 bugs in it when dealing with TS files that have PCR rollover:
    1. When you start playback, MediaPortal freezes, HDD light goes solid, and after a while (could be minutes), the file starts playing back.
    2. While playing, if you try to skip forward or backward, the HDD light goes solid again, and then after a while, the recording restarts from the beginning.

    Problem #1 is a bug in TsDuration. It calculates the duration of the TS file by looking for the max PCR in the TS file before the rollover happens, and does this by a sequential (!) backwards (!!) file search. All that is unnecessary-- the code should just use a constant value (the MAX possible PCR of all binary 1s) as the value. The patch to TsDuration{.cpp,.h} below fixes this.



    Problem #2 is a bug in TsFileSeek. Here, there's a section of code specifically for scanning a TS file with PCR rollover in it, and there's an if() statement where the logic is backwards. Fixing the if() fixes the problem, but beyond that, there's a whole other algorithm in it to deal with skipping around in TS files with PCR rollover that is unnecessary. The standard binary search algorithm works just fine, and is in fact faster. The patch to TsFileSeek below fixes both of these.

    This is my first patch submission for MediaPortal, so if there are some rules (written or unwritten) that I haven't followed for patch submission, please let me know, and I'd be happy to work on the patches to get them into proper shape for inclusion.

    Thanks...
     

    Attached Files:

    Last edited by a moderator: March 15, 2013
    • Like Like x 6
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Owlsroost
    • Team MediaPortal

    Owlsroost Development Group

    Joined:
    October 28, 2008
    Messages:
    5,537
    Likes Received:
    2,829
    Location:
    Cambridge
    Ratings:
    +4,131 / 1
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    I keep getting "The patch seems outdated!" error messages from TortoiseSVN when I try to apply some of the patch files - is anyone else seeing this ?

    Tony
     
  4. asselin
    • Premium Supporter

    asselin MP Donator

    Joined:
    May 29, 2010
    Messages:
    9
    Likes Received:
    11
    Ratings:
    +11 / 0
    Home Country:
    United States of America United States of America
    I'm at work and don't have access to my dev PC right now, but I'll take a look at it tonight. I manually trimmed down the patch files before submitting because there were quite a few lines of just whitespace differences; I probably messed something up. Sorry for the wasted time-- I'll be more careful before submitting next time. :oops:
     
  5. Owlsroost
    • Team MediaPortal

    Owlsroost Development Group

    Joined:
    October 28, 2008
    Messages:
    5,537
    Likes Received:
    2,829
    Location:
    Cambridge
    Ratings:
    +4,131 / 1
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    No problem :) - I think you have to leave the .patch files untouched after generation (it was mis-matched whitespace-only lines generating the error message, as far as I can tell)

    Tony
     
  6. disaster123
    • Premium Supporter

    disaster123 MP Donator

    Joined:
    May 14, 2008
    Messages:
    3,546
    Likes Received:
    417
    Ratings:
    +431 / 2
    Home Country:
    Germany Germany
    AW: Fix for TsReader problems with TS files with PCR rollover

    For me this results in non working seeking for live TV.
     
  7. asselin
    • Premium Supporter

    asselin MP Donator

    Joined:
    May 29, 2010
    Messages:
    9
    Likes Received:
    11
    Ratings:
    +11 / 0
    Home Country:
    United States of America United States of America
    OK, take 2, being more careful this time not to introduce stupid mistakes :oops: (sorry disaster123) and not edit patches after SVN creates them.

    Thanks...
     

    Attached Files:

    • Like Like x 1
  8. disaster123
    • Premium Supporter

    disaster123 MP Donator

    Joined:
    May 14, 2008
    Messages:
    3,546
    Likes Received:
    417
    Ratings:
    +431 / 2
    Home Country:
    Germany Germany
    AW: Fix for TsReader problems with TS files with PCR rollover

    So seeking should work niw on LiveTV even when the ts buffer rollover happens?
     
  9. asselin
    • Premium Supporter

    asselin MP Donator

    Joined:
    May 29, 2010
    Messages:
    9
    Likes Received:
    11
    Ratings:
    +11 / 0
    Home Country:
    United States of America United States of America
    disaster123,

    From what tourettes explained to me on the other thread, PCR rollover should never occur when playing TS files recorded with MediaPortal because TsWriter modifies the PCR it writes into the TS file.

    There was a silly bug in the original patch I submitted that completely broke seek in all cases. I fixed that in the patch I just submitted.

    So in short, yes, this should work for you. If it doesn't, can you post the TsReader.log file?

    Thanks...
     
  10. tourettes
    • Premium Supporter

    tourettes Retired Team Member

    Joined:
    January 7, 2005
    Messages:
    17,301
    Likes Received:
    4,595
    Ratings:
    +4,810 / 3
    True. TsWriter will produce TS buffer files that start always from the 0 PCR value. So it will take 26+ hours to reach the PCR rollover in timeshifting buffer. It is highly likely that the 26+ hour mark is having similar issues as asselin has seen in the local TS files. It is even possible that asselin's fix allows more than 26+ hours of continuous live tv watching (as long as the buffer timespan itself is not bigger than 26+ hours).
     
  11. disaster123
    • Premium Supporter

    disaster123 MP Donator

    Joined:
    May 14, 2008
    Messages:
    3,546
    Likes Received:
    417
    Ratings:
    +431 / 2
    Home Country:
    Germany Germany
    AW: Fix for TsReader problems with TS files with PCR rollover

    OK will try again. Could it be that the Streamingserver component needs the same patch?
     
    • Like Like x 1
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!