Package net.sourceforge.jaad.aac

Examples of net.sourceforge.jaad.aac.AACException


      case FIXFIX:
        envCount = 1<<in.readBits(2);
        relLead = envCount-1;
        if(envCount==1) ampRes = false;
        //check requirement (4.6.18.6.3):
        else if(envCount>4) throw new AACException("SBR: too many envelopes: "+envCount);

        Arrays.fill(freqRes, in.readBit());

        te[0] = 0;
        te[envCount] = absBordTrail;
        absBordTrail = (absBordTrail+(envCount>>1))/envCount;
        for(int i = 0; i<relLead; i++) {
          te[i+1] = te[i]+absBordTrail;
        }

        break;
      case FIXVAR:
        absBordTrail += in.readBits(2);
        relTrail = in.readBits(2);
        envCount = relTrail+1;
       
        te[0] = 0;
        te[envCount] = absBordTrail;
        for(int i = 0; i<relTrail; i++) {
          te[envCount-1-i] = te[envCount-i]-2*in.readBits(2)-2;
        }

        pointer = in.readBits(CEIL_LOG2[envCount]);

        for(int i = 0; i<envCount; i++) {
          freqRes[envCount-1-i] = in.readBit();
        }
        break;
      case VARFIX:
        te[0] = in.readBits(2);
        relLead = in.readBits(2);
        envCount = relLead+1;

        te[envCount] = absBordTrail;
        for(int i = 0; i<relLead; i++) {
          te[i+1] = te[i]+2*in.readBits(2)+2;
        }

        pointer = in.readBits(CEIL_LOG2[envCount]);

        for(int i = 0; i<envCount; i++) {
          freqRes[i] = in.readBit();
        }
        break;
      default: //VARVAR
        te[0] = in.readBits(2);
        absBordTrail += in.readBits(2);
        relLead = in.readBits(2);
        relTrail = in.readBits(2);
        envCount = relLead+relTrail+1;
        if(envCount>5) throw new AACException("SBR: too many envelopes: "+envCount);

        te[envCount] = absBordTrail;
        for(int i = 0; i<relLead; i++) {
          te[i+1] = te[i]+2*in.readBits(2)+2;
        }
 
View Full Code Here


        coefRes = in.readBit();

        for(filt = 0; filt<nFilt[w]; filt++) {
          length[w][filt] = in.readBits(bits[1]);

          if((order[w][filt] = in.readBits(bits[2]))>20) throw new AACException("TNS filter out of range: "+order[w][filt]);
          else if(order[w][filt]!=0) {
            direction[w][filt] = in.readBool();
            coefCompress = in.readBit();
            coefLen = coefRes+3-coefCompress;
            tmp = 2*coefCompress+coefRes;
 
View Full Code Here

          decodeCPE(in);
          decodeCPE(in);
          decodeSCE_LFE(in);
          break;
        default:
          throw new AACException("unsupported channel configuration for error resilience: "+config.getChannelConfiguration());
      }
    }
    in.byteAlign();

    bitsRead = in.getPosition()-start;
View Full Code Here

    curElem++;
    return elements[curElem-1];
  }

  private void decodeCCE(BitStream in) throws AACException {
    if(curCCE==MAX_ELEMENTS) throw new AACException("too much CCE elements");
    if(cces[curCCE]==null) cces[curCCE] = new CCE(config.getFrameLength());
    cces[curCCE].decode(in, config);
    curCCE++;
  }
View Full Code Here

    cces[curCCE].decode(in, config);
    curCCE++;
  }

  private void decodeDSE(BitStream in) throws AACException {
    if(curDSE==MAX_ELEMENTS) throw new AACException("too much CCE elements");
    if(dses[curDSE]==null) dses[curDSE] = new DSE();
    dses[curDSE].decode(in);
    curDSE++;
  }
View Full Code Here

    config.setSampleFrequency(pce.getSampleFrequency());
    config.setChannelConfiguration(ChannelConfiguration.forInt(pce.getChannelCount()));
  }

  private void decodeFIL(BitStream in, Element prev) throws AACException {
    if(curFIL==MAX_ELEMENTS) throw new AACException("too much FIL elements");
    if(fils[curFIL]==null) fils[curFIL] = new FIL(config.isSBRDownSampled());
    fils[curFIL].decode(in, prev, config.getSampleFrequency());
    curFIL++;

    if(prev!=null&&prev.isSBRPresent()) {
View Full Code Here

   * Reads the next four bytes.
   * @param peek if true, the stream pointer will not be increased
   */
  protected int readCache(boolean peek) throws AACException {
    int i;
    if(pos>buffer.length-WORD_BYTES) throw new AACException("end of stream", true);
    else i = ((buffer[pos]&BYTE_MASK)<<24)
          |((buffer[pos+1]&BYTE_MASK)<<16)
          |((buffer[pos+2]&BYTE_MASK)<<8)
          |(buffer[pos+3]&BYTE_MASK);
    if(!peek) pos += WORD_BYTES;
View Full Code Here

    //check parameter
    final int spDataLen = ics.getReorderedSpectralDataLength();
    if(spDataLen==0) return;

    final int longestLen = ics.getLongestCodewordLength();
    if(longestLen==0||longestLen>=spDataLen) throw new AACException("length of longest HCR codeword out of range");

    //create spOffsets
    final int[] spOffsets = new int[8];
    final int shortFrameLen = spectralData.length/8;
    spOffsets[0] = 0;
    int g;
    for(g = 1; g<windowGroupCount; g++) {
      spOffsets[g] = spOffsets[g-1]+shortFrameLen*info.getWindowGroupLength(g-1);
    }

    final Codeword[] codeword = new Codeword[512];
    final BitsBuffer[] segment = new BitsBuffer[512];

    int lastCB;
    int[] preSortCB;
    if(sectionDataResilience) {
      preSortCB = PRE_SORT_CB_ER;
      lastCB = NUM_CB_ER;
    }
    else {
      preSortCB = PRE_SORT_CB_STD;
      lastCB = NUM_CB;
    }

    int PCWs_done = 0;
    int segmentsCount = 0;
    int numberOfCodewords = 0;
    int bitsread = 0;

    int sfb, w_idx, i, thisCB, thisSectCB, cws;
    //step 1: decode PCW's (set 0), and stuff data in easier-to-use format
    for(int sortloop = 0; sortloop<lastCB; sortloop++) {
      //select codebook to process this pass
      thisCB = preSortCB[sortloop];

      for(sfb = 0; sfb<maxSFB; sfb++) {
        for(w_idx = 0; 4*w_idx<(Math.min(swbOffsets[sfb+1], swbOffsetMax)-swbOffsets[sfb]); w_idx++) {
          for(g = 0; g<windowGroupCount; g++) {
            for(i = 0; i<numSec[g]; i++) {
              if((sectStart[g][i]<=sfb)&&(sectEnd[g][i]>sfb)) {
                /* check whether codebook used here is the one we want to process */
                thisSectCB = sectCB[g][i];

                if(isGoodCB(thisCB, thisSectCB)) {
                  //precalculation
                  int sect_sfb_size = sectSFBOffsets[g][sfb+1]-sectSFBOffsets[g][sfb];
                  int inc = (thisSectCB<HCB.FIRST_PAIR_HCB) ? 4 : 2;
                  int group_cws_count = (4*info.getWindowGroupLength(g))/inc;
                  int segwidth = Math.min(MAX_CW_LEN[thisSectCB], longestLen);

                  //read codewords until end of sfb or end of window group
                  for(cws = 0; (cws<group_cws_count)&&((cws+w_idx*group_cws_count)<sect_sfb_size); cws++) {
                    int sp = spOffsets[g]+sectSFBOffsets[g][sfb]+inc*(cws+w_idx*group_cws_count);

                    //read and decode PCW
                    if(PCWs_done==0) {
                      //read in normal segments
                      if(bitsread+segwidth<=spDataLen) {
                        segment[segmentsCount].readSegment(segwidth, in);
                        bitsread += segwidth;

                        //Huffman.decodeSpectralDataER(segment[segmentsCount], thisSectCB, spectralData, sp);

                        //keep leftover bits
                        segment[segmentsCount].rewindReverse();

                        segmentsCount++;
                      }
                      else {
                        //remaining after last segment
                        if(bitsread<spDataLen) {
                          final int additional_bits = spDataLen-bitsread;

                          segment[segmentsCount].readSegment(additional_bits, in);
                          segment[segmentsCount].len += segment[segmentsCount-1].len;
                          segment[segmentsCount].rewindReverse();

                          if(segment[segmentsCount-1].len>32) {
                            segment[segmentsCount-1].bufb = segment[segmentsCount].bufb
                                +segment[segmentsCount-1].showBits(segment[segmentsCount-1].len-32);
                            segment[segmentsCount-1].bufa = segment[segmentsCount].bufa
                                +segment[segmentsCount-1].showBits(32);
                          }
                          else {
                            segment[segmentsCount-1].bufa = segment[segmentsCount].bufa
                                +segment[segmentsCount-1].showBits(segment[segmentsCount-1].len);
                            segment[segmentsCount-1].bufb = segment[segmentsCount].bufb;
                          }
                          segment[segmentsCount-1].len += additional_bits;
                        }
                        bitsread = spDataLen;
                        PCWs_done = 1;

                        codeword[0].fill(sp, thisSectCB);
                      }
                    }
                    else {
                      codeword[numberOfCodewords-segmentsCount].fill(sp, thisSectCB);
                    }
                    numberOfCodewords++;
                  }
                }
              }
            }
          }
        }
      }
    }

    if(segmentsCount==0) throw new AACException("no segments in HCR");

    final int numberOfSets = numberOfCodewords/segmentsCount;

    //step 2: decode nonPCWs
    int trial, codewordBase, segmentID, codewordID;
View Full Code Here

    }
    else if(n==32) {
      table = IMDCT_TABLE_32;
      table2 = IMDCT_POST_TABLE_32;
    }
    else throw new AACException("gain control: unexpected IMDCT length");

    final float[] tmp = new float[n];
    int i;
    for(i = 0; i<n2; ++i) {
      tmp[i] = in[2*i];
 
View Full Code Here

    if(profile.equals(Profile.AAC_LD)) {
      lagUpdate = in.readBool();
      if(lagUpdate) lag = in.readBits(10);
    }
    else lag = in.readBits(11);
    if(lag>(frameLength<<1)) throw new AACException("LTP lag too large: "+lag);
    coef = in.readBits(3);

    final int windowCount = info.getWindowCount();

    if(info.isEightShortFrame()) {
View Full Code Here

TOP

Related Classes of net.sourceforge.jaad.aac.AACException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.