[PATCH] fix dvdnav_convert_time to work for full range
Hello, currently the calculation will use int and thus overflow for anything larger or equal to 20 hours. Not sure if this is the best/nicest way, personally I prefer to do this kind of thing with the result = hour >> 4; result *= 10; result += hour; result *= 6; result += minute >> 4; result *= 10; .... scheme, but this is the minimal change required. Index: dvdnav.c =================================================================== --- dvdnav.c (revision 1243) +++ dvdnav.c (working copy) @@ -203,7 +203,7 @@ int64_t result; int64_t frames; - result = (time->hour >> 4 ) * 10 * 60 * 60 * 90000; + result = (time->hour >> 4 ) * 10 * 60 * 60 * 90000ull; result += (time->hour & 0x0f) * 60 * 60 * 90000; result += (time->minute >> 4 ) * 10 * 60 * 90000; result += (time->minute & 0x0f) * 60 * 90000;
Fixed in my tree as of February 2012. I used a cast to int64_t, but otherwise, the same fix. This is slated for push into mplayerhq svn as soon as I get around to it. Thanks for the patch. E On Tue, Nov 6, 2012 at 10:09 AM, Reimar Döffinger <Reimar.Doeffinger@gmx.de> wrote:
Hello, currently the calculation will use int and thus overflow for anything larger or equal to 20 hours. Not sure if this is the best/nicest way, personally I prefer to do this kind of thing with the result = hour >> 4; result *= 10; result += hour; result *= 6; result += minute >> 4; result *= 10; .... scheme, but this is the minimal change required.
Index: dvdnav.c =================================================================== --- dvdnav.c (revision 1243) +++ dvdnav.c (working copy) @@ -203,7 +203,7 @@ int64_t result; int64_t frames;
- result = (time->hour >> 4 ) * 10 * 60 * 60 * 90000; + result = (time->hour >> 4 ) * 10 * 60 * 60 * 90000ull; result += (time->hour & 0x0f) * 60 * 60 * 90000; result += (time->minute >> 4 ) * 10 * 60 * 90000; result += (time->minute & 0x0f) * 60 * 90000;
_______________________________________________ DVDnav-discuss mailing list DVDnav-discuss@mplayerhq.hu https://lists.mplayerhq.hu/mailman/listinfo/dvdnav-discuss
-- Erik Hovland erik@hovland.org http://hovland.org/
On Tuesday, 06 November 2012 at 19:09, Reimar Döffinger wrote:
Hello, currently the calculation will use int and thus overflow for anything larger or equal to 20 hours. Not sure if this is the best/nicest way, personally I prefer to do this kind of thing with the [...] scheme, but this is the minimal change required.
Finally applied to SVN. Regards, Dominik -- Fedora http://fedoraproject.org/wiki/User:Rathann RPMFusion http://rpmfusion.org | MPlayer http://mplayerhq.hu "Faith manages." -- Delenn to Lennier in Babylon 5:"Confessions and Lamentations"
participants (3)
-
Dominik 'Rathann' Mierzejewski -
Erik Hovland -
Reimar Döffinger