--- pvrparse.cpp.orig 2016-04-18 23:22:34.155792970 +0100 +++ pvrparse.cpp 2016-04-18 23:21:41.827558146 +0100 @@ -413,7 +413,8 @@ while (count > (structure_cache_size/4)) { int step = count >> 1; - ::lseek(m_structure_read_fd, (i + step) * entry_size, SEEK_SET); +// Read entry at top end of current range (== i+step-1) + ::lseek(m_structure_read_fd, (i + step - 1) * entry_size, SEEK_SET); unsigned long long d; if (::read(m_structure_read_fd, &d, sizeof(d)) < (ssize_t)sizeof(d)) { @@ -423,9 +424,12 @@ d = be64toh(d); if (d < (unsigned long long)offset) { - i += step + 1; - count -= step + 1; +// Move start of range to *be* the last test (+1 more may be too high!!) +// and remove tested count + i += step; + count -= step; } else +// Keep start of range but change range to that below test count = step; } //eDebug("[eMPEGStreamInformation] getStructureEntryFirst i=%d size=%d count=%d", i, l, count);