Esempio n. 1
0
static void
gmStage0(SECTION_INFO * section,
         int bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1],
         const int maxSfb)
{
  int i;

  COUNT_sub_start("gmStage0");

  PTR_INIT(2); /* pointers for section[],
                               bitLookUp[]
               */
  LOOP(1);
  for (i = 0; i < maxSfb; i++)
  {
    ADD(1); BRANCH(1);
    if (section[i].sectionBits == INVALID_BITCOUNT)
    {
      PTR_INIT(1); FUNC(2); STORE(1);
      section[i].sectionBits = findBestBook(bitLookUp[i], &(section[i].codeBook));

    }
  }

  COUNT_sub_end();
}
Esempio n. 2
0
static void
gmStage0(SECTION_INFO * sectionInfo,
         Word16 bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1],
         const Word16 maxSfb)
{
  Word32 i;

  for (i=0; i<maxSfb; i++) {
    /* Side-Info bits will be calculated in Stage 1!  */

    if (sectionInfo[i].sectionBits == INVALID_BITCOUNT) {
      sectionInfo[i].sectionBits = findBestBook(bitLookUp[i], &(sectionInfo[i].codeBook));
    }
  }
}
Esempio n. 3
0
/*
   count bits used by the noiseless coder
 */
static void
noiselessCounter(SECTION_DATA * sectionData,
                 int mergeGainLookUp[MAX_SFB_LONG],
                 int bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1],
                 const short *quantSpectrum,
                 const unsigned short *maxValueInSfb,
                 const int *sfbOffset,
                 const int blockType)
{
  int grpNdx, i;
  int *sideInfoTab = NULL;
  SECTION_INFO *section;

  COUNT_sub_start("noiselessCounter");

  PTR_INIT(1); /* counting previous operations */

  BRANCH(2);
  switch (blockType)
  {
  case LONG_WINDOW:
  case START_WINDOW:
  case STOP_WINDOW:

    MOVE(1);
    sideInfoTab = sideInfoTabLong;
    break;
  case SHORT_WINDOW:

    MOVE(1);
    sideInfoTab = sideInfoTabShort;
    break;
  }


  INDIRECT(3); MOVE(3);
  sectionData->noOfSections = 0;
  sectionData->huffmanBits = 0;
  sectionData->sideInfoBits = 0;



  INDIRECT(1); BRANCH(1);
  if (sectionData->maxSfbPerGroup == 0) {

    COUNT_sub_end();
    return;
  }

  INDIRECT(2); LOOP(1);
  for (grpNdx = 0; grpNdx < sectionData->sfbCnt; grpNdx += sectionData->sfbPerGroup)
  {

    INDIRECT(2); ADD(1);
    section = sectionData->section + sectionData->noOfSections;

    INDIRECT(1); ADD(2); FUNC(6);
    buildBitLookUp(quantSpectrum,
                   sectionData->maxSfbPerGroup,
                   sfbOffset + grpNdx,
                   maxValueInSfb + grpNdx,
                   bitLookUp,
                   section);

    INDIRECT(1); FUNC(3);
    gmStage0(section, bitLookUp, sectionData->maxSfbPerGroup);

    FUNC(4);
    gmStage1(section, bitLookUp, sectionData->maxSfbPerGroup, sideInfoTab);

    INDIRECT(1); FUNC(5);
    gmStage2(section,
             mergeGainLookUp,
             bitLookUp,
             sectionData->maxSfbPerGroup,
             sideInfoTab);


    PTR_INIT(2); /* pointers for section[],
                                 bitLookUp[]
                 */
    INDIRECT(1); LOOP(1);
    for (i = 0; i < sectionData->maxSfbPerGroup; i += section[i].sfbCnt)
    {
      PTR_INIT(1); FUNC(2);
      findBestBook(bitLookUp[i], &(section[i].codeBook));

      ADD(1); STORE(1);
      section[i].sfbStart += grpNdx;

      INDIRECT(2); ADD(2); STORE(1);
      sectionData->huffmanBits += section[i].sectionBits - sideInfoTab[section[i].sfbCnt];

      INDIRECT(2); ADD(1); STORE(1);
      sectionData->sideInfoBits += sideInfoTab[section[i].sfbCnt];

      ADD(1); INDIRECT(1); MOVE(1);
      sectionData->section[sectionData->noOfSections++] = section[i];
    }
  }
  COUNT_sub_end();
}
Esempio n. 4
0
/*
  count bits used by the noiseless coder
*/
static void
noiselessCounter(SECTION_DATA *sectionData,
                 Word16 mergeGainLookUp[MAX_SFB_LONG],
                 Word16 bitLookUp[MAX_SFB_LONG][CODE_BOOK_ESC_NDX + 1],
                 const Word16 *quantSpectrum,
                 const UWord16 *maxValueInSfb,
                 const Word16 *sfbOffset,
                 const Word32 blockType)
{
  Word32 grpNdx, i;
  const Word16 *sideInfoTab = NULL;
  SECTION_INFO *sectionInfo;

  /*
    use appropriate side info table
  */
  switch (blockType)
  {
    case LONG_WINDOW:
    case START_WINDOW:
    case STOP_WINDOW:
      sideInfoTab = sideInfoTabLong;
      break;
    case SHORT_WINDOW:
      sideInfoTab = sideInfoTabShort;
      break;
  }


  sectionData->noOfSections = 0;
  sectionData->huffmanBits = 0;
  sectionData->sideInfoBits = 0;


  if (sectionData->maxSfbPerGroup == 0)
    return;

  /*
    loop trough groups
  */
  for (grpNdx=0; grpNdx<sectionData->sfbCnt; grpNdx+=sectionData->sfbPerGroup) {

    sectionInfo = sectionData->sectionInfo + sectionData->noOfSections;

    buildBitLookUp(quantSpectrum,
                   sectionData->maxSfbPerGroup,
                   sfbOffset + grpNdx,
                   maxValueInSfb + grpNdx,
                   bitLookUp,
                   sectionInfo);

    /*
       0.Stage
    */
    gmStage0(sectionInfo, bitLookUp, sectionData->maxSfbPerGroup);

    /*
       1.Stage
    */
    gmStage1(sectionInfo, bitLookUp, sectionData->maxSfbPerGroup, sideInfoTab);


    /*
       2.Stage
    */
    gmStage2(sectionInfo,
             mergeGainLookUp,
             bitLookUp,
             sectionData->maxSfbPerGroup,
             sideInfoTab);


    /*
       compress output, calculate total huff and side bits
    */
    for (i=0; i<sectionData->maxSfbPerGroup; i+=sectionInfo[i].sfbCnt) {
      findBestBook(bitLookUp[i], &(sectionInfo[i].codeBook));
      sectionInfo[i].sfbStart = sectionInfo[i].sfbStart + grpNdx;

      sectionData->huffmanBits = (sectionData->huffmanBits +
                                     (sectionInfo[i].sectionBits - sideInfoTab[sectionInfo[i].sfbCnt]));
      sectionData->sideInfoBits = (sectionData->sideInfoBits + sideInfoTab[sectionInfo[i].sfbCnt]);
      sectionData->sectionInfo[sectionData->noOfSections] = sectionInfo[i];
      sectionData->noOfSections = sectionData->noOfSections + 1;
    }
  }
}