1
0

DXHEAD.C 979 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*---- DXhead.c --------------------------------------------
  2. decoder MPEG Layer III
  3. handle Xing header
  4. mod 12/7/98 add vbr scale
  5. Copyright 1998 Xing Technology Corp.
  6. -----------------------------------------------------------*/
  7. #include <windows.h>
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10. #include <float.h>
  11. #include <math.h>
  12. #include "dxhead.h"
  13. /*-------------------------------------------------------------*/
  14. int SeekPoint(unsigned char TOC[100], int file_bytes, float percent)
  15. {
  16. // interpolate in TOC to get file seek point in bytes
  17. int a, seekpoint;
  18. float fa, fb, fx;
  19. if (percent < 0.0f)
  20. percent = 0.0f;
  21. if (percent > 100.0f)
  22. percent = 100.0f;
  23. a = (int)percent;
  24. if (a > 99) a = 99;
  25. fa = TOC[a];
  26. if (a < 99)
  27. {
  28. fb = TOC[a + 1];
  29. }
  30. else
  31. {
  32. fb = 256.0f;
  33. }
  34. fx = fa + (fb - fa) * (percent - a);
  35. seekpoint = (int) ((1.0f / 256.0f) * fx * file_bytes);
  36. return seekpoint;
  37. }
  38. /*-------------------------------------------------------------*/