mp3common.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 "mp3dec.h"
  45. #include "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. */
  56. typedef struct _MP3DecInfo {
  57. /* pointers to platform-specific data structures */
  58. void *FrameHeaderPS;
  59. void *SideInfoPS;
  60. void *ScaleFactorInfoPS;
  61. void *HuffmanInfoPS;
  62. void *DequantInfoPS;
  63. void *IMDCTInfoPS;
  64. void *SubbandInfoPS;
  65. /* buffer which must be large enough to hold largest possible main_data section */
  66. unsigned char mainBuf[MAINBUF_SIZE];
  67. /* special info for "free" bitrate files */
  68. int freeBitrateFlag;
  69. int freeBitrateSlots;
  70. /* user-accessible info */
  71. int bitrate;
  72. int nChans;
  73. int samprate;
  74. int nGrans; /* granules per frame */
  75. int nGranSamps; /* samples per granule */
  76. int nSlots;
  77. int layer;
  78. MPEGVersion version;
  79. int mainDataBegin;
  80. int mainDataBytes;
  81. int part23Length[MAX_NGRAN][MAX_NCHAN];
  82. } MP3DecInfo;
  83. typedef struct _SFBandTable {
  84. short l[23];
  85. short s[14];
  86. } SFBandTable;
  87. /* decoder functions which must be implemented for each platform */
  88. MP3DecInfo *AllocateBuffers(void);
  89. void FreeBuffers(MP3DecInfo *mp3DecInfo);
  90. int CheckPadBit(MP3DecInfo *mp3DecInfo);
  91. int UnpackFrameHeader(MP3DecInfo *mp3DecInfo, unsigned char *buf);
  92. int UnpackSideInfo(MP3DecInfo *mp3DecInfo, unsigned char *buf);
  93. int DecodeHuffman(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int huffBlockBits, int gr, int ch);
  94. int Dequantize(MP3DecInfo *mp3DecInfo, int gr);
  95. int IMDCT(MP3DecInfo *mp3DecInfo, int gr, int ch);
  96. int UnpackScaleFactors(MP3DecInfo *mp3DecInfo, unsigned char *buf, int *bitOffset, int bitsAvail, int gr, int ch);
  97. int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf);
  98. /* mp3tabs.c - global ROM tables */
  99. extern const int samplerateTab[3][3];
  100. extern const short bitrateTab[3][3][15];
  101. extern const short samplesPerFrameTab[3][3];
  102. extern const short bitsPerSlotTab[3];
  103. extern const short sideBytesTab[3][2];
  104. extern const short slotTab[3][3][15];
  105. extern const SFBandTable sfBandTable[3][3];
  106. #endif /* _MP3COMMON_H */