VbrTag.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Xing VBR tagging for LAME.
  3. *
  4. * Copyright (c) 1999 A.L. Faber
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef LAME_VRBTAG_H
  22. #define LAME_VRBTAG_H
  23. /* -----------------------------------------------------------
  24. * A Vbr header may be present in the ancillary
  25. * data field of the first frame of an mp3 bitstream
  26. * The Vbr header (optionally) contains
  27. * frames total number of audio frames in the bitstream
  28. * bytes total number of bytes in the bitstream
  29. * toc table of contents
  30. * toc (table of contents) gives seek points
  31. * for random access
  32. * the ith entry determines the seek point for
  33. * i-percent duration
  34. * seek point in bytes = (toc[i]/256.0) * total_bitstream_bytes
  35. * e.g. half duration seek point = (toc[50]/256.0) * total_bitstream_bytes
  36. */
  37. #define FRAMES_FLAG 0x0001
  38. #define BYTES_FLAG 0x0002
  39. #define TOC_FLAG 0x0004
  40. #define VBR_SCALE_FLAG 0x0008
  41. #define NUMTOCENTRIES 100
  42. #ifndef lame_internal_flags_defined
  43. #define lame_internal_flags_defined
  44. struct lame_internal_flags;
  45. typedef struct lame_internal_flags lame_internal_flags;
  46. #endif
  47. /*structure to receive extracted header */
  48. /* toc may be NULL*/
  49. typedef struct {
  50. int h_id; /* from MPEG header, 0=MPEG2, 1=MPEG1 */
  51. int samprate; /* determined from MPEG header */
  52. int flags; /* from Vbr header data */
  53. int frames; /* total bit stream frames from Vbr header data */
  54. int bytes; /* total bit stream bytes from Vbr header data */
  55. int vbr_scale; /* encoded vbr scale from Vbr header data */
  56. unsigned char toc[NUMTOCENTRIES]; /* may be NULL if toc not desired */
  57. int headersize; /* size of VBR header, in bytes */
  58. int enc_delay; /* encoder delay */
  59. int enc_padding; /* encoder paddign added at end of stream */
  60. } VBRTAGDATA;
  61. int GetVbrTag(VBRTAGDATA * pTagData, const unsigned char *buf);
  62. int InitVbrTag(lame_global_flags * gfp);
  63. int PutVbrTag(lame_global_flags const *gfp, FILE * fid);
  64. void AddVbrFrame(lame_internal_flags * gfc);
  65. void UpdateMusicCRC(uint16_t * crc, const unsigned char *buffer, int size);
  66. #endif