예제 #1
0
  public void process(FilterBank filterBank) throws AACException {
    final Profile profile = config.getProfile();
    final SampleFrequency sf = config.getSampleFrequency();
    // final ChannelConfiguration channels = config.getChannelConfiguration();

    int chs = config.getChannelConfiguration().getChannelCount();
    if (chs == 1 && psPresent) chs++;
    final int mult = sbrPresent ? 2 : 1;
    // only reallocate if needed
    if (data == null || chs != data.length || (mult * config.getFrameLength()) != data[0].length)
      data = new float[chs][mult * config.getFrameLength()];

    int channel = 0;
    Element e;
    SCE_LFE scelfe;
    CPE cpe;
    for (int i = 0; i < elements.length && channel < chs; i++) {
      e = elements[i];
      if (e == null) continue;
      if (e instanceof SCE_LFE) {
        scelfe = (SCE_LFE) e;
        channel += processSingle(scelfe, filterBank, channel, profile, sf);
      } else if (e instanceof CPE) {
        cpe = (CPE) e;
        processPair(cpe, filterBank, channel, profile, sf);
        channel += 2;
      } else if (e instanceof CCE) {
        // applies invquant and save the result in the CCE
        ((CCE) e).process();
        channel++;
      }
    }
  }
예제 #2
0
  public void sendToOutput(SampleBuffer buffer) {
    final boolean be = buffer.isBigEndian();

    final int chs = data.length;
    final int mult = (sbrPresent && config.isSBREnabled()) ? 2 : 1;
    final int length = mult * config.getFrameLength();
    final int freq = mult * config.getSampleFrequency().getFrequency();

    byte[] b = buffer.getData();
    if (b.length != chs * length * 2) b = new byte[chs * length * 2];

    float[] cur;
    int i, j, off;
    short s;
    for (i = 0; i < chs; i++) {
      cur = data[i];
      for (j = 0; j < length; j++) {
        s = (short) Math.max(Math.min(Math.round(cur[j]), Short.MAX_VALUE), Short.MIN_VALUE);
        off = (j * chs + i) * 2;
        if (be) {
          b[off] = (byte) ((s >> 8) & BYTE_MASK);
          b[off + 1] = (byte) (s & BYTE_MASK);
        } else {
          b[off + 1] = (byte) ((s >> 8) & BYTE_MASK);
          b[off] = (byte) (s & BYTE_MASK);
        }
      }
    }

    buffer.setData(b, freq, chs, 16, bitsRead);
  }
예제 #3
0
  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(), config.isSBREnabled());
    curFIL++;

    if (prev != null && prev.isSBRPresent()) {
      sbrPresent = true;
      if (!psPresent && prev.getSBR().isPSUsed()) psPresent = true;
    }
  }