void layer2Step2()

in pedalboard/juce_overrides/juce_PatchedMP3AudioFormat.cpp [2504:2586]


  void layer2Step2(SideInfoLayer2 &si, const int gr,
                   float fraction[2][4][32]) noexcept {
    auto *allocTable = frame.allocationTable;
    auto sblimit = frame.layer2SubBandLimit;
    const auto jsbound =
        (frame.mode == 1 ? jmin((frame.modeExt << 2) + 4, sblimit) : sblimit);

    for (int i = 0; i < jsbound; ++i) {
      auto step = allocTable->bits;

      for (int ch = 0; ch < frame.numChannels; ++ch) {
        if (auto ba = si.allocation[i][ch]) {
          auto x1 = jmin((uint8)63, si.scaleFactor[i][ch][gr]);
          auto *alloc2 = allocTable + ba;
          auto k = jmin((int16)16, alloc2->bits);
          auto d1 = alloc2->d;

          if (d1 < 0) {
            const double cm = constants.muls[k][x1];
            fraction[ch][0][i] = (float)(((int)getBits(k) + d1) * cm);
            fraction[ch][1][i] = (float)(((int)getBits(k) + d1) * cm);
            fraction[ch][2][i] = (float)(((int)getBits(k) + d1) * cm);
          } else {
            auto *tab = constants.getGroupTable(d1, getBits(k));
            fraction[ch][0][i] = (float)constants.muls[tab[0]][x1];
            fraction[ch][1][i] = (float)constants.muls[tab[1]][x1];
            fraction[ch][2][i] = (float)constants.muls[tab[2]][x1];
          }
        } else {
          fraction[ch][0][i] = fraction[ch][1][i] = fraction[ch][2][i] = 0;
        }
      }

      allocTable += (static_cast<intptr_t>(1) << step);
    }

    for (int i = jsbound; i < frame.layer2SubBandLimit; ++i) {
      auto step = allocTable->bits;
      auto ba = si.allocation[i][0];

      if (ba != 0) {
        auto *alloc2 = allocTable + ba;
        int16 k = alloc2->bits;
        int16 d1 = alloc2->d;
        k = (k <= 16) ? k : 16;

        if (d1 < 0) {
          auto v0 = (int)getBits(k);
          auto v1 = (int)getBits(k);
          auto v2 = (int)getBits(k);

          for (int ch = 0; ch < frame.numChannels; ++ch) {
            auto x1 = jmin((uint8)63, si.scaleFactor[i][ch][gr]);
            const double cm = constants.muls[k][x1];
            fraction[ch][0][i] = (float)((v0 + d1) * cm);
            fraction[ch][1][i] = (float)((v1 + d1) * cm);
            fraction[ch][2][i] = (float)((v2 + d1) * cm);
          }
        } else {
          auto *tab = constants.getGroupTable(d1, getBits(k));
          auto k0 = tab[0];
          auto k1 = tab[1];
          auto k2 = tab[2];

          for (int ch = 0; ch < frame.numChannels; ++ch) {
            auto x1 = jmin((uint8)63, si.scaleFactor[i][ch][gr]);
            fraction[ch][0][i] = (float)constants.muls[k0][x1];
            fraction[ch][1][i] = (float)constants.muls[k1][x1];
            fraction[ch][2][i] = (float)constants.muls[k2][x1];
          }
        }
      } else {
        fraction[0][0][i] = fraction[0][1][i] = fraction[0][2][i] = 0;
        fraction[1][0][i] = fraction[1][1][i] = fraction[1][2][i] = 0;
      }

      allocTable += (static_cast<intptr_t>(1) << step);
    }

    for (int ch = 0; ch < frame.numChannels; ++ch)
      for (int i = frame.layer2SubBandLimit; i < 32; ++i)
        fraction[ch][0][i] = fraction[ch][1][i] = fraction[ch][2][i] = 0;
  }