Logo Search packages:      
Sourcecode: vcdimager version File versions

unsigned int vcdinfo_lsn_get_entry ( const vcdinfo_obj_t *  obj,
lsn_t  lsn 
)

Return the entry number closest and before the given LSN.

Definition at line 760 of file info.c.

References vcdinfo_get_entry_lsn(), vcdinfo_get_num_entries(), and vcdinfo_lsn_get_entry().

Referenced by vcdinfo_get_multi_default_lid(), vcdinfo_lsn_get_entry(), and vcdinfo_track_get_entry().

{

  /* Do a binary search to find the entry. */
  unsigned int i = 0;
  unsigned int j = vcdinfo_get_num_entries(obj);
  unsigned int mid;
  unsigned int mid_lsn;
  do {
    mid = (i+j)/2;
    mid_lsn = vcdinfo_get_entry_lsn(obj, mid);
    if ( lsn <=  mid_lsn ) j = mid-1;
    if ( lsn >=  mid_lsn ) i = mid+1;
  } while (i <= j);

  /* We want the entry closest but before. */
  return (lsn == mid_lsn) ? mid : mid-1;
}


Generated by  Doxygen 1.6.0   Back to index