#ifndef AVIFILE_CPUINFO_H
#define AVIFILE_CPUINFO_H

#include <default.h>

class CPU_Info
{
    double freq;
    int have_tsc;
    int have_mmx;
    static double old_freq();
    static int64_t longcount_notsc();
    static int64_t longcount_tsc();
    static unsigned int localcount_notsc();
    static unsigned int localcount_tsc();
public:
    CPU_Info();
    /**
     * Returns nonzero if the processor supports MMX instruction set.
     */
    int HaveMMX() const {return have_mmx;}
    /**
     * Returns nonzero if the processor has time-stamp counter feature.
     */
    int HaveTSC() const {return have_tsc;}
    /**
     * Returns processor frequency in kHz.
     */
    operator double() const {return freq;}
};

extern CPU_Info freq;

/**
 *  Returns duration of time interval between two timestamps, received
 *  with longcount().
 */
inline float to_float(int64_t t2, int64_t t1)
{
//  int64_t qw=t2-t1;
//    qw=(int64_t)(qw/freq);//milliseconds;
//    return ((int)qw)/1000.;
	return float((t2-t1)/freq/1000.);
}

#endif // AVIFILE_CPUINFO_H
