Package net.sourceforge.jaad.aac

Examples of net.sourceforge.jaad.aac.AACException


    else if(cb==11||cb>15) {
      signValues(in, data, off, cb<5 ? QUAD_LEN : PAIR_LEN); //virtual codebooks are always unsigned
      if(Math.abs(data[off])==16) data[off] = getEscape(in, data[off]);
      if(Math.abs(data[off+1])==16) data[off+1] = getEscape(in, data[off+1]);
    }
    else throw new AACException("Huffman: unknown spectral codebook: "+cb);
  }
View Full Code Here


    if(stop==15) x = 3*k0;
    else if(stop==14) x = 2*k0;
    else x = MFT_STOP_MIN[sfIndex]+MFT_STOP_OFFSETS[sfOff][header.getStopFrequency(false)-1];
    k2 = Math.min(MAX_BANDS, x);

    if(k0>=k2) throw new AACException("SBR: MFT borders out of range: lower="+k0+", higher="+k2);
    //check requirement (4.6.18.3.6):
    final int max;
    if(sampleRate==44100) max = 35;
    else if(sampleRate>=48000) max = 32;
    else max = 48;
    if((k2-k0)>max) throw new AACException("SBR: too many subbands: "+(k2-k0)+", maximum number for samplerate "+sampleRate+": "+max);

    //MFT calculation
    if(header.getFrequencyScale(false)==0) calculateMFT1(header, k0, k2);
    else calculateMFT2(header, k0, k2);

    //check requirement (4.6.18.3.6):
    if(header.getXOverBand(false)>=nMaster) throw new AACException("SBR: illegal length of master frequency table: "+nMaster+", xOverBand: "+header.getXOverBand(false));
  }
View Full Code Here

    else {
      dk = 1;
      nMaster = 2*(int) ((float) (k2-k0)/2.0f);
    }
    //check requirement (4.6.18.6.3):
    if(nMaster<=0) throw new AACException("SBR: illegal number of bands for master frequency table: "+nMaster);

    final int k2Achieved = k0+nMaster*dk;
    int k2Diff = k2-k2Achieved;

    final int[] vDk = new int[nMaster];
View Full Code Here

    final float div2 = (float) k1/(float) k0;
    float log = (float) Math.log(div2)/(float) (2*LOG2);
    final int bandCount0 = 2*Math.round(bands*log);
    //check requirement (4.6.18.6.3):
    if(bandCount0<=0) throw new AACException("SBR: illegal band count for master frequency table: "+bandCount0);

    final int[] vDk0 = new int[bandCount0];
    float pow1, pow2;
    for(int i = 0; i<bandCount0; i++) {
      pow1 = (float) Math.pow(div2, (float) (i+1)/bandCount0);
      pow2 = (float) Math.pow(div2, (float) i/bandCount0);
      vDk0[i] = Math.round(k0*pow1)-Math.round(k0*pow2);
      //check requirement (4.6.18.6.3):
      if(vDk0[i]<=0) throw new AACException("SBR: illegal value in master frequency table: "+vDk0[i]);
    }
    Arrays.sort(vDk0);

    final int[] vk0 = new int[bandCount0+1];
    vk0[0] = k0;
    for(int i = 1; i<=bandCount0; i++) {
      vk0[i] = vk0[i-1]+vDk0[i-1];
    }

    if(twoRegions) {
      div1 = (float) k2/(float) k1;
      log = (float) Math.log(div1);
      final int bandCount1 = 2*(int) Math.round(bands*log/(2*LOG2*warp));
      final int[] vDk1 = new int[bandCount1];
      int min = -1;
      for(int i = 0; i<bandCount1; i++) {
        pow1 = (float) Math.pow(div1, (float) (i+1)/bandCount1);
        pow2 = (float) Math.pow(div1, (float) i/bandCount1);
        vDk1[i] = Math.round(k1*pow1)-Math.round(k1*pow2);
        if(min<0||vDk1[i]<min) min = vDk1[i];
        //check requirement (4.6.18.6.3):
        else if(vDk1[i]<=0) throw new AACException("SBR: illegal value in master frequency table: "+vDk1[i]);
      }

      if(min<vDk0[vDk0.length-1]) {
        Arrays.sort(vDk1);
        int change = vDk0[vDk0.length-1]-vDk1[0];
View Full Code Here

    kxPrev = kx;
    kx = fTable[HIGH][0];
    mPrev = m;
    m = fTable[HIGH][getN(HIGH)]-kx;
    //check requirements (4.6.18.3.6):
    if(kx>32) throw new AACException("SBR: start frequency border out of range: "+kx);
    if((kx+m)>64) throw new AACException("SBR: stop frequency border out of range: "+(kx+m));

    final int half = (int) ((float) n[HIGH]/2.0);
    n[LOW] = half+(n[HIGH]-2*half);
    fTable[LOW] = new int[n[LOW]+1];
    fTable[LOW][0] = fTable[HIGH][0];
View Full Code Here

  private void calculateNoiseTable(SBRHeader header) throws AACException {
    final float log = (float) Math.log((float) k2/(float) kx)/(float) LOG2;
    final int x = Math.round(header.getNoiseBands(false)*log);
    nq = Math.max(1, x);
    //check requirement (4.6.18.6.3):
    if(nq>5) throw new AACException("SBR: too many noise floor scalefactors: "+nq);

    fNoise = new int[nq+1];
    fNoise[0] = fTable[LOW][0];
    int i = 0;
    for(int k = 1; k<=nq; k++) {
View Full Code Here

    while(sb!=(kx+m));

    if(patchSubbands[patchCount-1]<3&&patchCount>1) patchCount--;

    //check requirement (4.6.18.6.3):
    if(patchCount>5) throw new AACException("SBR: too many patches: "+patchCount);
  }
View Full Code Here

    }

    final int pos2 = in.getPosition()-pos;
    final int bitsLeft = cpy-pos2;
    if(bitsLeft>0) in.skipBits(pos2);
    else if(bitsLeft<0) throw new AACException("FIL element overread: "+bitsLeft);
  }
View Full Code Here

        if(prev instanceof SCE_LFE||prev instanceof CPE||prev instanceof CCE) {
          prev.decodeSBR(in, sf, ret, (prev instanceof CPE), (type==TYPE_SBR_DATA_CRC), downSampledSBR);
          ret = 0;
          break;
        }
        else throw new AACException("SBR applied on unexpected element: "+prev);
      case TYPE_FILL:
      case TYPE_FILL_DATA:
      case TYPE_EXT_DATA_ELEMENT:
      default:
        in.skipBits(ret);
View Full Code Here

  }

  void decode(BitStream in, DecoderConfig conf) throws AACException {
    final Profile profile = conf.getProfile();
    final SampleFrequency sf = conf.getSampleFrequency();
    if(sf.equals(SampleFrequency.SAMPLE_FREQUENCY_NONE)) throw new AACException("invalid sample frequency");

    readElementInstanceTag(in);

    commonWindow = in.readBool();
    final ICSInfo info = icsL.getInfo();
    if(commonWindow) {
      info.decode(in, conf, commonWindow);
      icsR.getInfo().setData(info);

      msMask = MSMask.forInt(in.readBits(2));
      if(msMask.equals(MSMask.TYPE_USED)) {
        final int maxSFB = info.getMaxSFB();
        final int windowGroupCount = info.getWindowGroupCount();

        for(int idx = 0; idx<windowGroupCount*maxSFB; idx++) {
          msUsed[idx] = in.readBool();
        }
      }
      else if(msMask.equals(MSMask.TYPE_ALL_1)) Arrays.fill(msUsed, true);
      else if(msMask.equals(MSMask.TYPE_ALL_0)) Arrays.fill(msUsed, false);
      else throw new AACException("reserved MS mask type used");
    }
    else {
      msMask = MSMask.TYPE_ALL_0;
      Arrays.fill(msUsed, false);
    }
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.