예제 #1
0
  Object unpack(Info vi, Buffer opb) {
    int acc = 0;
    InfoResidue0 info = new InfoResidue0();
    info.begin = opb.read(24);
    info.end = opb.read(24);
    info.grouping = opb.read(24) + 1;
    info.partitions = opb.read(6) + 1;
    info.groupbook = opb.read(8);

    for (int j = 0; j < info.partitions; j++) {
      int cascade = opb.read(3);
      if (opb.read(1) != 0) {
        cascade |= (opb.read(5) << 3);
      }
      info.secondstages[j] = cascade;
      acc += Util.icount(cascade);
    }

    for (int j = 0; j < acc; j++) {
      info.booklist[j] = opb.read(8);
    }

    if (info.groupbook >= vi.books) {
      free_info(info);
      return (null);
    }

    for (int j = 0; j < acc; j++) {
      if (info.booklist[j] >= vi.books) {
        free_info(info);
        return (null);
      }
    }
    return (info);
  }
 public void unpack(Buffer mpjbuf, Object buf, int offset, int count) throws MPIException {
   try {
     mpjbuf.read((byte[]) buf, offset, count * numEls);
   } catch (Exception e) {
     throw new MPIException(e);
   }
 }
 public void unpackPartial(Buffer mpjbuf, int length, Object buf, int offset) throws MPIException {
   try {
     mpjbuf.read((byte[]) buf, offset, length);
   } catch (Exception e) {
     throw new MPIException(e);
   }
 }
  public void unpack(Buffer mpjbuf, int length, Object buf, int offset, int count)
      throws MPIException {

    if (count * numEls < length) {
      throw new MPIException(
          "Error in SimplePacker : count <"
              + (count * numEls)
              + "> is less than length <"
              + length
              + ">");
    }

    try {
      mpjbuf.read((byte[]) buf, offset, length);
    } catch (Exception e) {
      throw new MPIException(e);
    }
  }
예제 #5
0
  // also responsible for range checking
  Object unpack(Info vi, Buffer opb) {
    InfoMapping0 info = new InfoMapping0();

    if (opb.read(1) != 0) {
      info.submaps = opb.read(4) + 1;
    } else {
      info.submaps = 1;
    }

    if (opb.read(1) != 0) {
      info.coupling_steps = opb.read(8) + 1;

      for (int i = 0; i < info.coupling_steps; i++) {
        int testM = info.coupling_mag[i] = opb.read(Util.ilog2(vi.channels));
        int testA = info.coupling_ang[i] = opb.read(Util.ilog2(vi.channels));

        if (testM < 0
            || testA < 0
            || testM == testA
            || testM >= vi.channels
            || testA >= vi.channels) {
          // goto err_out;
          info.free();
          return (null);
        }
      }
    }

    if (opb.read(2) > 0) {
      /* 2,3:reserved */
      info.free();
      return (null);
    }

    if (info.submaps > 1) {
      for (int i = 0; i < vi.channels; i++) {
        info.chmuxlist[i] = opb.read(4);
        if (info.chmuxlist[i] >= info.submaps) {
          info.free();
          return (null);
        }
      }
    }

    for (int i = 0; i < info.submaps; i++) {
      info.timesubmap[i] = opb.read(8);
      if (info.timesubmap[i] >= vi.times) {
        info.free();
        return (null);
      }
      info.floorsubmap[i] = opb.read(8);
      if (info.floorsubmap[i] >= vi.floors) {
        info.free();
        return (null);
      }
      info.residuesubmap[i] = opb.read(8);
      if (info.residuesubmap[i] >= vi.residues) {
        info.free();
        return (null);
      }
    }
    return info;
  }
예제 #6
0
  // unpacks a codebook from the packet buffer into the codebook struct,
  // readies the codebook auxiliary structures for decode
  int unpack(Buffer opb) {
    int i;
    // memset(s,0,sizeof(static_codebook));

    // make sure alignment is correct
    if (opb.read(24) != 0x564342) {
      //    goto _eofout;
      clear();
      return (-1);
    }

    // first the basic parameters
    dim = opb.read(16);
    entries = opb.read(24);
    if (entries == -1) {
      //    goto _eofout;
      clear();
      return (-1);
    }

    // codeword ordering.... length ordered or unordered?
    switch (opb.read(1)) {
      case 0:
        // unordered
        lengthlist = new int[entries];

        // allocated but unused entries?
        if (opb.read(1) != 0) {
          // yes, unused entries

          for (i = 0; i < entries; i++) {
            if (opb.read(1) != 0) {
              int num = opb.read(5);
              if (num == -1) {
                //            goto _eofout;
                clear();
                return (-1);
              }
              lengthlist[i] = num + 1;
            } else {
              lengthlist[i] = 0;
            }
          }
        } else {
          // all entries used; no tagging
          for (i = 0; i < entries; i++) {
            int num = opb.read(5);
            if (num == -1) {
              //          goto _eofout;
              clear();
              return (-1);
            }
            lengthlist[i] = num + 1;
          }
        }
        break;
      case 1:
        // ordered
        {
          int length = opb.read(5) + 1;
          lengthlist = new int[entries];

          for (i = 0; i < entries; ) {
            int num = opb.read(ilog(entries - i));
            if (num == -1) {
              //          goto _eofout;
              clear();
              return (-1);
            }
            for (int j = 0; j < num; j++, i++) {
              lengthlist[i] = length;
            }
            length++;
          }
        }
        break;
      default:
        // EOF
        return (-1);
    }

    // Do we have a mapping to unpack?
    switch ((maptype = opb.read(4))) {
      case 0:
        // no mapping
        break;
      case 1:
      case 2:
        // implicitly populated value mapping
        // explicitly populated value mapping
        q_min = opb.read(32);
        q_delta = opb.read(32);
        q_quant = opb.read(4) + 1;
        q_sequencep = opb.read(1);

        {
          int quantvals = 0;
          switch (maptype) {
            case 1:
              quantvals = maptype1_quantvals();
              break;
            case 2:
              quantvals = entries * dim;
              break;
          }

          // quantized values
          quantlist = new int[quantvals];
          for (i = 0; i < quantvals; i++) {
            quantlist[i] = opb.read(q_quant);
          }
          if (quantlist[quantvals - 1] == -1) {
            //        goto _eofout;
            clear();
            return (-1);
          }
        }
        break;
      default:
        //    goto _eofout;
        clear();
        return (-1);
    }
    // all set
    return (0);
    //    _errout:
    //    _eofout:
    //    vorbis_staticbook_clear(s);
    //    return(-1);
  }
예제 #7
0
 @Override
 public int read(byte[] buffer, int offset, int bytes) throws IOException {
   return local_buffer.read(buffer, offset, bytes);
 }
예제 #8
0
 @Override
 public int read(byte[] buffer) throws IOException {
   return local_buffer.read(buffer);
 }