diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-04-01 06:09:12 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-04-01 06:09:12 +0000 |
commit | d64c82776f12435589aa3c3d146e69a31f108949 (patch) | |
tree | 46c4f477074aa407be0bf698ebbd283e0b470ae5 | |
parent | 3c8d93e091c23a6f0db157c2a2e30f187ce5b263 (diff) | |
download | rockbox-d64c82776f12435589aa3c3d146e69a31f108949.tar.gz rockbox-d64c82776f12435589aa3c3d146e69a31f108949.zip |
Place a limit on the estimate fudging when searching timestamps in mpegplayer. It doesn't have to be very much.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16907 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_parser.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/plugins/mpegplayer/mpeg_parser.c b/apps/plugins/mpegplayer/mpeg_parser.c index 345aa73111..cd54e84452 100644 --- a/apps/plugins/mpegplayer/mpeg_parser.c +++ b/apps/plugins/mpegplayer/mpeg_parser.c @@ -378,6 +378,8 @@ static off_t mpeg_parser_seek_PTS(uint32_t time, unsigned id) if (currpts != INVALID_TIMESTAMP) { + ssize_t pos_adj; /* Adjustment to over or under-estimate */ + /* Found a valid timestamp - see were it lies in relation to * target */ if (currpts < time) @@ -401,10 +403,14 @@ static off_t mpeg_parser_seek_PTS(uint32_t time, unsigned id) pos_new = muldiv_uint32(time - time_left, pos_right - pos_left, - time_right - time_left) + pos_left; + time_right - time_left); /* Point is ahead of us - fudge estimate a bit high */ - pos_new = muldiv_uint32(11, pos_new - pos_left, 10) - + pos_left; + pos_adj = pos_new / 10; + + if (pos_adj > 512*1024) + pos_adj = 512*1024; + + pos_new += pos_left + pos_adj; if (pos_new >= pos_right) { @@ -431,9 +437,14 @@ static off_t mpeg_parser_seek_PTS(uint32_t time, unsigned id) pos_new = muldiv_uint32(time - time_left, pos_right - pos_left, - time_right - time_left) + pos_left; + time_right - time_left); /* Overshot the seek point - fudge estimate a bit low */ - pos_new = muldiv_uint32(9, pos_new - pos_left, 10) + pos_left; + pos_adj = pos_new / 10; + + if (pos_adj > 512*1024) + pos_adj = 512*1024; + + pos_new += pos_left - pos_adj; state = state3; /* Last scan was late */ sk.dir = SSCAN_REVERSE; |