subband.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. * subband.c - subband transform (synthesis filterbank implemented via 32-point DCT
  41. * followed by polyphase filter)
  42. **************************************************************************************/
  43. #include "coder.h"
  44. #include "assembly.h"
  45. /**************************************************************************************
  46. * Function: Subband
  47. *
  48. * Description: do subband transform on all the blocks in one granule, all channels
  49. *
  50. * Inputs: filled MP3DecInfo structure, after calling IMDCT for all channels
  51. * vbuf[ch] and vindex[ch] must be preserved between calls
  52. *
  53. * Outputs: decoded PCM data, interleaved LRLRLR... if stereo
  54. *
  55. * Return: 0 on success, -1 if null input pointers
  56. **************************************************************************************/
  57. /*__attribute__ ((section (".data"))) */ int Subband(MP3DecInfo *mp3DecInfo, short *pcmBuf)
  58. {
  59. int b;
  60. //HuffmanInfo *hi;
  61. IMDCTInfo *mi;
  62. SubbandInfo *sbi;
  63. /* validate pointers */
  64. if (!mp3DecInfo || !mp3DecInfo->HuffmanInfoPS || !mp3DecInfo->IMDCTInfoPS || !mp3DecInfo->SubbandInfoPS)
  65. return -1;
  66. //hi = (HuffmanInfo *)mp3DecInfo->HuffmanInfoPS;
  67. mi = (IMDCTInfo *)(mp3DecInfo->IMDCTInfoPS);
  68. sbi = (SubbandInfo*)(mp3DecInfo->SubbandInfoPS);
  69. if (mp3DecInfo->nChans == 2) {
  70. /* stereo */
  71. for (b = 0; b < BLOCK_SIZE; b++) {
  72. FDCT32(mi->outBuf[0][b], sbi->vbuf + 0*32, sbi->vindex, (b & 0x01), mi->gb[0]);
  73. FDCT32(mi->outBuf[1][b], sbi->vbuf + 1*32, sbi->vindex, (b & 0x01), mi->gb[1]);
  74. PolyphaseStereo(pcmBuf, sbi->vbuf + sbi->vindex + VBUF_LENGTH * (b & 0x01), polyCoef);
  75. sbi->vindex = (sbi->vindex - (b & 0x01)) & 7;
  76. pcmBuf += (2 * NBANDS);
  77. }
  78. } else {
  79. /* mono */
  80. for (b = 0; b < BLOCK_SIZE; b++) {
  81. FDCT32(mi->outBuf[0][b], sbi->vbuf + 0*32, sbi->vindex, (b & 0x01), mi->gb[0]);
  82. PolyphaseMono(pcmBuf, sbi->vbuf + sbi->vindex + VBUF_LENGTH * (b & 0x01), polyCoef);
  83. sbi->vindex = (sbi->vindex - (b & 0x01)) & 7;
  84. pcmBuf += NBANDS;
  85. }
  86. }
  87. return 0;
  88. }