gd_framenum_subset, gd_framenum—perform a reverse look-up on a monotonic dirfile field
#include <getdata.h>
double gd_framenum_subset(DIRFILE *dirfile, const char *field_code, double value, off_t field_start, off_t field_end);
double gd_framenum(DIRFILE *dirfile, const char *field_code, double value);
The gd_framenum_subset() function queries a dirfile(5) database specified by dirfile and returns the fractional frame number at which the field specified by field_code, which may contain a representation suffix, equals value, by considering the field between the frame limits field_start and field_end.
If field_start is zero, the frame offset of the field is used as the lower limit instead (which may, in fact, be zero; see gd_frameoffset(3)). If field_end is zero, the number of frames in the dirfile, as reported by gd_nframes(3), is used instead as the upper limit.
The gd_framenum() function is equivalent to calling gd_framenum_subset() with field_start and field_end equal to zero.
The field must be monotonic (either increasing or decreasing) between the supplied limits. It is not required to be strictly monotonic.
If the value searched for lies between two sample values, the frame number returned will be calculated by linear interpolation of the field between these two samples. If more than one consecutive sample is equal to the value searched for, the fractional frame number of one of these samples will be returned, without specifying which particular one will be used.
If the value searched for is found to lie outside of the supplied limits, the first two or last two samples of the field will be used to linearly extrapolate the returned frame number. If these two samples happen to have the same value, positive or negative infinity will be returned. When extrapolating, this function will never consider data outside the supplied limits, even if such data exists. As a result, the extrapolated value may differ greatly from the value considering all the data.
All computation is done in double precision. As a result, using this function on a 64-bit integer field with more precision than a double precision floating point number, may result in an inaccurate returned value. Attempting to use this function on a complex valued field will result in an error.
If the field is constant across the entire range, an error results, even if the value to search for is equal to the constant value of the field.
On success, these functions return the fractional frame number at which the given function would attain the supplied value, based only on that portion of the field between the given limits. This might be any number, even values outside of the supplied limits, up to and including positive or negative infinity.
On error, these functions return an IEEE-754 conforming not-a-number (NaN), and store a negative-valued error code in the DIRFILE object which may be retrieved by a subsequent call to gd_error(3). Possible error codes are:
A descriptive error string for the error may be obtained by calling gd_error_string(3).
The get_framenum() and get_framenum_subset() functions appeared in GetData-0.6.0.
In GetData-0.7.0, these functions were renamed to gd_framenum() and gd_framenum_subset().
gd_error(3), gd_error_string(3), gd_frameoffset(3), gd_nframes(3), gd_open(3)