mp3common.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: RCSL 1.0/RPSL 1.0
  3. *
  4. * Portions Copyright (c) 1995-2002 RealNetworks, Inc. All Rights Reserved.
  5. *
  6. * The contents of this file, and the files included with this file, are
  7. * subject to the current version of the RealNetworks Public Source License
  8. * Version 1.0 (the "RPSL") available at
  9. * http://www.helixcommunity.org/content/rpsl unless you have licensed
  10. * the file under the RealNetworks Community Source License Version 1.0
  11. * (the "RCSL") available at http://www.helixcommunity.org/content/rcsl,
  12. * in which case the RCSL will apply. You may also obtain the license terms
  13. * directly from RealNetworks. You may not use this file except in
  14. * compliance with the RPSL or, if you have a valid RCSL with RealNetworks
  15. * applicable to this file, the RCSL. Please see the applicable RPSL or
  16. * RCSL for the rights, obligations and limitations governing use of the
  17. * contents of the file.
  18. *
  19. * This file is part of the Helix DNA Technology. RealNetworks is the
  20. * developer of the Original Code and owns the copyrights in the portions
  21. * it created.
  22. *
  23. * This file, and the files included with this file, is distributed and made
  24. * available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  25. * EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  26. * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS
  27. * FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
  28. *
  29. * Technology Compatibility Kit Test Suite(s) Location:
  30. * http://www.helixcommunity.org/content/tck
  31. *
  32. * Contributor(s):
  33. *
  34. * ***** END LICENSE BLOCK ***** */
  35. /**************************************************************************************
  36. * Fixed-point MP3 decoder
  37. * Jon Recker (jrecker@real.com), Ken Cooke (kenc@real.com)
  38. * June 2003
  39. *
  40. * mp3common.h - implementation-independent API's, datatypes, and definitions
  41. **************************************************************************************/
  42. #ifndef _MP3COMMON_H
  43. #define _MP3COMMON_H
  44. #include <contrib/hxmp3/mp3dec.h>
  45. #include <contrib/hxmp3/statname.h> /* do name-mangling for static linking */
  46. #define MAX_SCFBD 4 /* max scalefactor bands per channel */
  47. #define NGRANS_MPEG1 2
  48. #define NGRANS_MPEG2 1
  49. /* 11-bit syncword if MPEG 2.5 extensions are enabled */
  50. #define SYNCWORDH 0xff
  51. #define SYNCWORDL 0xe0
  52. /* 12-bit syncword if MPEG 1,2 only are supported */
  53. //#define SYNCWORDH 0xff
  54. //#define SYNCWORDL 0xf0
  55. typedef struct _MP3DecInfo {
  56. /* pointers to platform-specific data structures */
  57. void *FrameHeaderPS;
  58. void *SideInfoPS;
  59. void *ScaleFactorInfoPS;
  60. void *HuffmanInfoPS;
  61. void *DequantInfoPS;
  62. void *IMDCTInfoPS;
  63. void *SubbandInfoPS;
  64. /* buffer which must be large enough to hold largest possible main_data section */
  65. unsigned char mainBuf[MAINBUF_SIZE];
  66. /* special info for "free" bitrate files */
  67. int freeBitrateFlag;
  68. int freeBitrateSlots;
  69. /* user-accessible info */
  70. int bitrate;
  71. int nChans;
  72. int samprate;
  73. int nGrans; /* granules per frame */
  74. int nGranSamps; /* samples per granule */
  75. int nSlots;
  76. int layer;
  77. MPEGVersion version;
  78. int mainDataBegin;
  79. int mainDataBytes;
  80. int part23Length[MAX_NGRAN][MAX_NCHAN];
  81. } MP3DecInfo;
  82. typedef struct _SFBandTable {
  83. short l[23];
  84. short s[14];
  85. } SFBandTable;
  86. /* decoder functions which must be implemented for each platform */
  87. MP3DecInfo *AllocateBuffers(void);
  88. void FreeBuffers(MP3DecInfo *mp3DecInfo);
  89. int CheckPadBit(MP3DecInfo *mp3DecInfo);
  90. int UnpackFrameHeader(MP3DecInfo *mp3DecInfo, unsigned char *buf);
  91. int UnpackSideInfo(MP3DecInfo *mp3DecInfo, unsigned char *buf);
  92. int DecodeHuffman(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int huffBlockBits, int gr, int ch);
  93. int Dequantize(MP3DecInfo *mp3DecInfo, int gr);
  94. int IMDCT(MP3DecInfo *mp3DecInfo, int gr, int ch);
  95. int UnpackScaleFactors(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int bitsAvail, int gr, int ch);
  96. int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf);
  97. /* mp3tabs.c - global ROM tables */
  98. extern const int samplerateTab[3][3];
  99. extern const short bitrateTab[3][3][15];
  100. extern const short samplesPerFrameTab[3][3];
  101. extern const short bitsPerSlotTab[3];
  102. extern const short sideBytesTab[3][2];
  103. extern const short slotTab[3][3][15];
  104. extern const SFBandTable sfBandTable[3][3];
  105. #endif /* _MP3COMMON_H */