timer.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * libmad - MPEG audio decoder library
  3. * Copyright (C) 2000-2004 Underbit Technologies, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. *
  19. * $Id: timer.h,v 1.16 2004/01/23 09:41:33 rob Exp $
  20. */
  21. # ifndef LIBMAD_TIMER_H
  22. # define LIBMAD_TIMER_H
  23. typedef struct {
  24. signed long seconds; /* whole seconds */
  25. unsigned long fraction; /* 1/MAD_TIMER_RESOLUTION seconds */
  26. } mad_timer_t;
  27. extern mad_timer_t const mad_timer_zero;
  28. # define MAD_TIMER_RESOLUTION 352800000UL
  29. enum mad_units {
  30. MAD_UNITS_HOURS = -2,
  31. MAD_UNITS_MINUTES = -1,
  32. MAD_UNITS_SECONDS = 0,
  33. /* metric units */
  34. MAD_UNITS_DECISECONDS = 10,
  35. MAD_UNITS_CENTISECONDS = 100,
  36. MAD_UNITS_MILLISECONDS = 1000,
  37. /* audio sample units */
  38. MAD_UNITS_8000_HZ = 8000,
  39. MAD_UNITS_11025_HZ = 11025,
  40. MAD_UNITS_12000_HZ = 12000,
  41. MAD_UNITS_16000_HZ = 16000,
  42. MAD_UNITS_22050_HZ = 22050,
  43. MAD_UNITS_24000_HZ = 24000,
  44. MAD_UNITS_32000_HZ = 32000,
  45. MAD_UNITS_44100_HZ = 44100,
  46. MAD_UNITS_48000_HZ = 48000,
  47. /* video frame/field units */
  48. MAD_UNITS_24_FPS = 24,
  49. MAD_UNITS_25_FPS = 25,
  50. MAD_UNITS_30_FPS = 30,
  51. MAD_UNITS_48_FPS = 48,
  52. MAD_UNITS_50_FPS = 50,
  53. MAD_UNITS_60_FPS = 60,
  54. /* CD audio frames */
  55. MAD_UNITS_75_FPS = 75,
  56. /* video drop-frame units */
  57. MAD_UNITS_23_976_FPS = -24,
  58. MAD_UNITS_24_975_FPS = -25,
  59. MAD_UNITS_29_97_FPS = -30,
  60. MAD_UNITS_47_952_FPS = -48,
  61. MAD_UNITS_49_95_FPS = -50,
  62. MAD_UNITS_59_94_FPS = -60
  63. };
  64. # define mad_timer_reset(timer) ((void) (*(timer) = mad_timer_zero))
  65. int mad_timer_compare(mad_timer_t, mad_timer_t);
  66. # define mad_timer_sign(timer) mad_timer_compare((timer), mad_timer_zero)
  67. void mad_timer_negate(mad_timer_t *);
  68. mad_timer_t mad_timer_abs(mad_timer_t);
  69. void mad_timer_set(mad_timer_t *, unsigned long, unsigned long, unsigned long);
  70. void mad_timer_add(mad_timer_t *, mad_timer_t);
  71. void mad_timer_multiply(mad_timer_t *, signed long);
  72. signed long mad_timer_count(mad_timer_t, enum mad_units);
  73. unsigned long mad_timer_fraction(mad_timer_t, unsigned long);
  74. void mad_timer_string(mad_timer_t, char *, char const *,
  75. enum mad_units, enum mad_units, unsigned long);
  76. # endif