comparison searching.c @ 303:52cda7471a24 src

fixed off-by-one bug in scan_admap (copied reference code from ifo_print.c); reported by ggurov+abv-bg
author nicodvb
date Thu, 12 Jul 2007 20:09:45 +0000
parents ef017423e37c
children 0110b591bf9c
comparison
equal deleted inserted replaced
302:ef017423e37c 303:52cda7471a24
77 } 77 }
78 if(admap) { 78 if(admap) {
79 uint32_t address = 0; 79 uint32_t address = 0;
80 uint32_t vobu_start, next_vobu; 80 uint32_t vobu_start, next_vobu;
81 int32_t found = 0; 81 int32_t found = 0;
82 int admap_entries = (admap->last_byte + 1 - VOBU_ADMAP_SIZE)/VOBU_ADMAP_SIZE;
82 83
83 /* Search through ADMAP for best sector */ 84 /* Search through ADMAP for best sector */
84 vobu_start = SRI_END_OF_CELL; 85 vobu_start = SRI_END_OF_CELL;
85 /* FIXME: Implement a faster search algorithm */ 86 /* FIXME: Implement a faster search algorithm */
86 while((!found) && ((address<<2) < admap->last_byte)) { 87 while((!found) && (address < admap_entries)) {
87 next_vobu = admap->vobu_start_sectors[address]; 88 next_vobu = admap->vobu_start_sectors[address];
88 89
89 /* fprintf(MSG_OUT, "libdvdnav: Found block %u\n", next_vobu); */ 90 /* fprintf(MSG_OUT, "libdvdnav: Found block %u\n", next_vobu); */
90 91
91 if(vobu_start <= seekto_block && 92 if(vobu_start <= seekto_block &&