void layer2Step1()

in pedalboard/juce_overrides/juce_PatchedMP3AudioFormat.cpp [2431:2502]


  void layer2Step1(SideInfoLayer2 &si) noexcept {
    zerostruct(si);
    const auto sblimit = frame.layer2SubBandLimit;
    const auto jsbound =
        (frame.mode == 1 ? jmin((frame.modeExt << 2) + 4, sblimit) : sblimit);
    auto *allocTable = frame.allocationTable;
    uint8 scfsi[32][2];

    if (frame.numChannels == 2) {
      for (int i = 0; i < jsbound; ++i) {
        auto step = allocTable->bits;
        allocTable += (static_cast<intptr_t>(1) << step);
        si.allocation[i][0] = getBitsUint8(step);
        si.allocation[i][1] = getBitsUint8(step);
      }

      for (int i = jsbound; i < sblimit; ++i) {
        auto step = allocTable->bits;
        auto b0 = getBitsUint8(step);
        allocTable += (static_cast<intptr_t>(1) << step);
        si.allocation[i][0] = b0;
        si.allocation[i][1] = b0;
      }

      for (int i = 0; i < sblimit; ++i) {
        scfsi[i][0] = si.allocation[i][0] ? getBitsUint8(2) : 0;
        scfsi[i][1] = si.allocation[i][1] ? getBitsUint8(2) : 0;
      }
    } else {
      for (int i = 0; i < sblimit; ++i) {
        const int16 step = allocTable->bits;
        allocTable += (static_cast<intptr_t>(1) << step);
        si.allocation[i][0] = getBitsUint8(step);
      }

      for (int i = 0; i < sblimit; ++i)
        scfsi[i][0] = si.allocation[i][0] ? getBitsUint8(2) : 0;
    }

    for (int i = 0; i < sblimit; ++i) {
      for (int ch = 0; ch < frame.numChannels; ++ch) {
        uint8 s0 = 0, s1 = 0, s2 = 0;

        if (si.allocation[i][ch]) {
          switch (scfsi[i][ch]) {
          case 0:
            s0 = getBitsUint8(6);
            s1 = getBitsUint8(6);
            s2 = getBitsUint8(6);
            break;
          case 1:
            s1 = s0 = getBitsUint8(6);
            s2 = getBitsUint8(6);
            break;
          case 2:
            s2 = s1 = s0 = getBitsUint8(6);
            break;
          case 3:
            s0 = getBitsUint8(6);
            s2 = s1 = getBitsUint8(6);
            break;
          default:
            break;
          }
        }

        si.scaleFactor[i][ch][0] = s0;
        si.scaleFactor[i][ch][1] = s1;
        si.scaleFactor[i][ch][2] = s2;
      }
    }
  }