You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1004 B

  1. /*
  2. * time.c -- time functions
  3. *
  4. * Copyright (C) 2004 Svend Sorensen
  5. * For license terms, see the file COPYING in this distribution.
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. long time_msf_to_frame (int m, int s, int f)
  10. {
  11. return (m * 60 + s) * 75 + f;
  12. }
  13. void msf_frame_to_msf (long frame, int *m, int *s, int *f)
  14. {
  15. *f = frame % 75; /* 0 <= frames <= 74 */
  16. frame /= 75;
  17. *s = frame % 60; /* 0 <= seconds <= 59 */
  18. frame /= 60;
  19. *m = frame; /* 0 <= minutes */
  20. }
  21. void time_frame_to_msf (long frame, int *m, int *s, int *f)
  22. {
  23. *f = frame % 75; /* 0 <= frames <= 74 */
  24. frame /= 75;
  25. *s = frame % 60; /* 0 <= seconds <= 59 */
  26. frame /= 60;
  27. *m = frame; /* 0 <= minutes */
  28. }
  29. /* print frame in mm:ss:ff format */
  30. char *time_frame_to_mmssff (long f)
  31. {
  32. static char msf[9];
  33. int minutes, seconds, frames;
  34. msf_frame_to_msf(f, &minutes, &seconds, &frames);
  35. sprintf(msf, "%02d:%02d:%02d", minutes, seconds, frames);
  36. return msf;
  37. }