···193193}
194194195195/* returns nonzero if found */
196196-static int _lookup_serialno(long s, ogg_uint32_t *serialno_list, int n){
196196+static int _lookup_serialno(ogg_uint32_t s, ogg_uint32_t *serialno_list, int n){
197197 if(serialno_list){
198198 while(n--){
199199 if(*serialno_list == (ogg_uint32_t) s) return 1;
···204204}
205205206206static int _lookup_page_serialno(ogg_page *og, ogg_uint32_t *serialno_list, int n){
207207- long s = ogg_page_serialno(og);
207207+ ogg_uint32_t s = ogg_page_serialno(og);
208208 return _lookup_serialno(s,serialno_list,n);
209209}
210210···245245 ret_gran=ogg_page_granulepos(&og);
246246 offset=ret;
247247248248- if(ret_serialno == (ogg_uint32_t) *serialno){
248248+ if((ogg_uint32_t)ret_serialno == (ogg_uint32_t)*serialno){
249249 prefoffset=ret;
250250 *granpos=ret_gran;
251251 }
252252253253- if(!_lookup_serialno(ret_serialno,serial_list,serial_n)){
253253+ if(!_lookup_serialno((ogg_uint32_t)ret_serialno,serial_list,serial_n)){
254254 /* we fell off the end of the link, which means we seeked
255255 back too far and shouldn't have been looking in that link
256256 to begin with. If we found the preferred serial number,
···12011201 return OV_EBADLINK;
12021202}
1203120312041204+/* rescales the number x from the range of [0,from] to [0,to]
12051205+ x is in the range [0,from]
12061206+ from, to are in the range [1, 1<<62-1] */
12071207+ogg_int64_t rescale64(ogg_int64_t x, ogg_int64_t from, ogg_int64_t to){
12081208+ ogg_int64_t frac=0;
12091209+ ogg_int64_t ret=0;
12101210+ int i;
12111211+ if(x >= from) return to;
12121212+ if(x <= 0) return 0;
12131213+12141214+ for(i=0;i<64;i++){
12151215+ if(x>=from){
12161216+ frac|=1;
12171217+ x-=from;
12181218+ }
12191219+ x<<=1;
12201220+ frac<<=1;
12211221+ }
12221222+12231223+ for(i=0;i<64;i++){
12241224+ if(frac & 1){
12251225+ ret+=to;
12261226+ }
12271227+ frac>>=1;
12281228+ ret>>=1;
12291229+ }
12301230+12311231+ return ret;
12321232+}
12331233+12041234/* Page granularity seek (faster than sample granularity because we
12051235 don't do the last bit of decode to find a specific sample).
12061236···12461276 bisect=begin;
12471277 }else{
12481278 /* take a (pretty decent) guess. */
12491249- bisect=begin +
12501250- (target-begintime)*(end-begin)/(endtime-begintime) - CHUNKSIZE;
12791279+ bisect=begin + rescale64(target-begintime,
12801280+ endtime-begintime,
12811281+ end-begin) - CHUNKSIZE;
12511282 if(bisect<begin+CHUNKSIZE)
12521283 bisect=begin;
12531284 }