Esempio n. 1
0
  public void method545(ByteBuffer buffer0, boolean flag, WaveSample class29) {
    int i = buffer0.getUbyte();
    anIntArray665[0] = i >> 4;
    if (flag) return;
    anIntArray665[1] = i & 0xf;
    if (i != 0) {
      anIntArray668[0] = buffer0.getUword();
      anIntArray668[1] = buffer0.getUword();
      int j = buffer0.getUbyte();
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < anIntArray665[k]; l++) {
          anIntArrayArrayArray666[k][0][l] = buffer0.getUword();
          anIntArrayArrayArray667[k][0][l] = buffer0.getUword();
        }
      }

      for (int i1 = 0; i1 < 2; i1++) {
        for (int j1 = 0; j1 < anIntArray665[i1]; j1++)
          if ((j & 1 << i1 * 4 << j1) != 0) {
            anIntArrayArrayArray666[i1][1][j1] = buffer0.getUword();
            anIntArrayArrayArray667[i1][1][j1] = buffer0.getUword();
          } else {
            anIntArrayArrayArray666[i1][1][j1] = anIntArrayArrayArray666[i1][0][j1];
            anIntArrayArrayArray667[i1][1][j1] = anIntArrayArrayArray667[i1][0][j1];
          }
      }

      if (j != 0 || anIntArray668[1] != anIntArray668[0]) class29.method326((byte) -112, buffer0);
      return;
    } else {
      anIntArray668[0] = anIntArray668[1] = 0;
      return;
    }
  }
 public void writeTo(OutputStream out) throws IOException {
   if (mSpillover == null) {
     mLocalBuffer.writeTo(out);
   } else {
     mSpillover.writeTo(out);
   }
 }
Esempio n. 3
0
 public void setBody(ByteBuffer buffer)
     throws NotEnoughDataInByteBufferException, TerminatingZeroNotFoundException, PDUException {
   setServiceType(buffer.removeCString());
   setMessageId(buffer.removeCString());
   sourceAddr.setData(buffer); // ?
   destAddr.setData(buffer); // ?
 }
Esempio n. 4
0
  /**
   * Read screen and store result in native buffer.
   *
   * @param dim dimension of the video
   * @return true if success, false otherwise
   */
  private ByteBuffer readScreenNative(Dimension dim) {
    int size = dim.width * dim.height * 4 + FFmpeg.FF_INPUT_BUFFER_PADDING_SIZE;
    ByteBuffer data = byteBufferPool.getBuffer(size);

    data.setLength(size);

    /* get desktop screen via native grabber */
    boolean b;

    try {
      b =
          desktopInteract.captureScreen(
              displayIndex, x, y, dim.width, dim.height, data.getPtr(), data.getLength());
    } catch (Throwable t) {
      if (t instanceof ThreadDeath) {
        throw (ThreadDeath) t;
      } else {
        b = false;
        //                logger.error("Failed to grab screen!", t);
      }
    }
    if (!b) {
      data.free();
      data = null;
    }
    return data;
  }
 public long getBaseByteCount() throws IOException {
   if (mSpillover == null) {
     return mLocalBuffer.getBaseByteCount();
   } else {
     return mSpillover.getBaseByteCount();
   }
 }
Esempio n. 6
0
 public ByteBuffer put(ByteBuffer src) {
   int length = src.remaining();
   checkPut(position, length, false);
   src.get(array, arrayOffset + position, length);
   position += length;
   return this;
 }
Esempio n. 7
0
 public ByteBuffer getBody() {
   ByteBuffer buffer = new ByteBuffer();
   buffer.appendCString(getServiceType());
   buffer.appendCString(messageId);
   buffer.appendBuffer(getSourceAddr().getData());
   buffer.appendBuffer(getDestAddr().getData());
   return buffer;
 }
 IntViewBufferImpl(ByteBuffer bb, int capacity) {
   super(capacity, capacity, 0, -1);
   this.bb = bb;
   this.offset = bb.position();
   this.readOnly = bb.isReadOnly();
   this.endian = bb.order();
   if (bb.isDirect()) this.address = VMDirectByteBuffer.adjustAddress(bb.address, offset);
 }
Esempio n. 9
0
  /**
   * Blocks and reads into a <tt>Buffer</tt> from this <tt>PullBufferStream</tt>.
   *
   * @param buffer the <tt>Buffer</tt> this <tt>PullBufferStream</tt> is to read into
   * @throws IOException if an I/O error occurs while this <tt>PullBufferStream</tt> reads into the
   *     specified <tt>Buffer</tt>
   * @see AbstractVideoPullBufferStream#doRead(Buffer)
   */
  @Override
  protected void doRead(Buffer buffer) throws IOException {
    /*
     * Determine the Format in which we're expected to output. We cannot
     * rely on the Format always being specified in the Buffer because it is
     * not its responsibility, the DataSource of this ImageStream knows the
     * output Format.
     */
    Format format = buffer.getFormat();

    if (format == null) {
      format = getFormat();
      if (format != null) buffer.setFormat(format);
    }

    if (format instanceof AVFrameFormat) {
      Object o = buffer.getData();
      AVFrame frame;

      if (o instanceof AVFrame) frame = (AVFrame) o;
      else {
        frame = new AVFrame();
        buffer.setData(frame);
      }

      AVFrameFormat avFrameFormat = (AVFrameFormat) format;
      Dimension size = avFrameFormat.getSize();
      ByteBuffer data = readScreenNative(size);

      if (data != null) {
        if (frame.avpicture_fill(data, avFrameFormat) < 0) {
          data.free();
          throw new IOException("avpicture_fill");
        }
      } else {
        /*
         * This can happen when we disconnect a monitor from computer
         * before or during grabbing.
         */
        throw new IOException("Failed to grab screen.");
      }
    } else {
      byte[] bytes = (byte[]) buffer.getData();
      Dimension size = ((VideoFormat) format).getSize();

      bytes = readScreen(bytes, size);

      buffer.setData(bytes);
      buffer.setOffset(0);
      buffer.setLength(bytes.length);
    }

    buffer.setHeader(null);
    buffer.setTimeStamp(System.nanoTime());
    buffer.setSequenceNumber(seqNo);
    buffer.setFlags(Buffer.FLAG_SYSTEM_TIME | Buffer.FLAG_LIVE_DATA);
    seqNo++;
  }
 /**
  * Encodes a <code>Geometry</code> into a WKB representation using the specified byte-order.
  *
  * @param geom The <code>Geometry</code> to be encoded as WKB.
  * @param wbo The WKB byte order, either {@link ByteOrder#XDR XDR} or {@link ByteOrder#NDR NDR}
  * @return A buffer of bytes that contains the WKB-encoded <code>Geometry</code>.
  */
 public ByteBuffer encode(Geometry geom, ByteOrder wbo) {
   ByteBuffer output = ByteBuffer.allocate(calculateSize(geom, true));
   if (wbo != null) {
     output.setWKBByteOrder(wbo);
   }
   writeGeometry(geom, output);
   output.rewind();
   return output;
 }
Esempio n. 11
0
 static final boolean method1294(byte i, byte[] is) {
   anInt2199++;
   ByteBuffer class348_sub49 = new ByteBuffer(is);
   int i_0_ = class348_sub49.getUByte();
   if (i_0_ != 2) return false;
   boolean bool = (class348_sub49.getUByte() ^ 0xffffffff) == -2;
   if (bool) Class59_Sub2_Sub2.parseLobbyWorldList(class348_sub49);
   Class348_Sub42_Sub6.method3188((byte) -67, class348_sub49);
   return true;
 }
Esempio n. 12
0
  private void spillover() throws IOException {
    mSpillover = mGroup.createFileByteBuffer();
    // TODO: This is bad! By writing out the contents of the existing
    // buffer early, surrogates are evaluated too soon!
    mLocalBuffer.writeTo(new ByteBufferOutputStream(mSpillover));

    long count = mLocalBuffer.getBaseByteCount();
    mLocalBuffer = null;
    mGroup.adjustLevel(-count);
  }
Esempio n. 13
0
 @Override
 public void visit(LineString<P> geom) {
   writeByteOrder(output);
   writeTypeCodeAndSrid(geom, output);
   if (geom.isEmpty()) {
     output.putUInt(0);
   } else {
     output.putUInt(geom.getNumPositions());
     writePoints(geom.getPositions(), geom.getCoordinateDimension(), output);
   }
 }
Esempio n. 14
0
  ByteBufferAsLongBufferB(ByteBuffer bb) { // package-private

    super(-1, 0, bb.remaining() >> 3, bb.remaining() >> 3);
    this.bb = bb;
    // enforce limit == capacity
    int cap = this.capacity();
    this.limit(cap);
    int pos = this.position();
    assert (pos <= cap);
    offset = pos;
  }
 protected void writeTypeCodeAndSrid(
     Geometry geometry, DimensionalFlag dimension, ByteBuffer output) {
   int typeCode = getGeometryType(geometry);
   boolean hasSrid = (geometry.getSRID() > 0);
   if (hasSrid && !hasWrittenSrid) typeCode |= PostgisWkbTypeMasks.SRID_FLAG;
   if (dimension.isMeasured()) typeCode |= PostgisWkbTypeMasks.M_FLAG;
   if (dimension.is3D()) typeCode |= PostgisWkbTypeMasks.Z_FLAG;
   output.putUInt(typeCode);
   if (hasSrid && !hasWrittenSrid) {
     output.putInt(geometry.getSRID());
     hasWrittenSrid = true;
   }
 }
Esempio n. 16
0
  /**
   * Writes the content of the the <code>ByteBUFFER</code> src into the buffer. Before the transfer,
   * it checks if there is fewer than <code>src.remaining()</code> space remaining in this buffer.
   *
   * @param src The source data.
   * @exception BufferOverflowException If there is insufficient space in this buffer for the
   *     remaining <code>byte</code>s in the source buffer.
   * @exception IllegalArgumentException If the source buffer is this buffer.
   * @exception ReadOnlyBufferException If this buffer is read-only.
   */
  public ByteBuffer put(ByteBuffer src) {
    if (src == this) throw new IllegalArgumentException();

    checkForOverflow(src.remaining());

    if (src.remaining() > 0) {
      byte[] toPut = new byte[src.remaining()];
      src.get(toPut);
      put(toPut);
    }

    return this;
  }
  /**
   * Write a portion of an array of characters.
   *
   * @param cbuf Array of characters
   * @param off Offset from which to start writing characters
   * @param len Number of characters to write
   * @throws java.io.IOException If an I/O error occurs
   */
  public void write(final char[] cbuf, final int off, final int len) throws IOException {
    text = Utf16LE.getInstance().decode(cbuf, off, len, text);
    if (buffer != null) {
      buffer.setCursor(0);
    }

    if (errorType == null) {
      buffer = encoding.encode(text, buffer);
    } else {
      buffer = encoding.encode(text, buffer, errorType);
    }

    outputStream.write(buffer.getData(), buffer.getOffset(), buffer.getLength());
  }
Esempio n. 18
0
  public void reset() throws IOException {
    mLocalBuffer.reset();
    if (mSpillover != null) {
      mSpillover.reset();
    }

    List captureBuffers;
    if ((captureBuffers = mCaptureBuffers) != null) {
      int size = captureBuffers.size();
      for (int i = 0; i < size; i++) {
        ((ByteData) captureBuffers.get(i)).reset();
      }
    }
  }
Esempio n. 19
0
  public void mapperInternalStateLoad(ByteBuffer buf) {

    super.mapperInternalStateLoad(buf);

    // Check version:
    if (buf.readByte() == 1) {

      latchLo = buf.readByte();
      latchHi = buf.readByte();
      latchLoVal1 = buf.readByte();
      latchLoVal2 = buf.readByte();
      latchHiVal1 = buf.readByte();
      latchHiVal2 = buf.readByte();
    }
  }
Esempio n. 20
0
  public void mapperInternalStateSave(ByteBuffer buf) {

    super.mapperInternalStateSave(buf);

    // Version:
    buf.putByte((short) 1);

    // State:
    buf.putByte((byte) latchLo);
    buf.putByte((byte) latchHi);
    buf.putByte((byte) latchLoVal1);
    buf.putByte((byte) latchLoVal2);
    buf.putByte((byte) latchHiVal1);
    buf.putByte((byte) latchHiVal2);
  }
Esempio n. 21
0
 protected void finalize() throws IOException {
   if (mLocalBuffer != null) {
     long count = mLocalBuffer.getBaseByteCount();
     mLocalBuffer = null;
     mGroup.adjustLevel(-count);
   }
 }
 @Override
 public void visit(GeometryCollection geom) {
   writeByteOrder(output);
   DimensionalFlag dimension = DimensionalFlag.valueOf(geom.is3D(), geom.isMeasured());
   writeTypeCodeAndSrid(geom, dimension, output);
   output.putUInt(geom.getNumGeometries());
 }
 public static Class387 method4021(ByteBuffer class528_sub42, int i) {
   Class387 class387 = new Class387();
   class387.anInt4071 = class528_sub42.readUnsignedShort(108582832) * 2108924067;
   class387.aClass528_Sub21_Sub4_4070 =
       Class33.aClass46_314.method861(-1007414517 * class387.anInt4071, (byte) -48);
   return class387;
 }
 @Override
 public void visit(LineString geom) {
   writeByteOrder(output);
   DimensionalFlag dimension = DimensionalFlag.valueOf(geom.is3D(), geom.isMeasured());
   writeTypeCodeAndSrid(geom, dimension, output);
   output.putUInt(geom.getNumPoints());
   writePoints(geom.getPoints(), geom.getCoordinateDimension(), output);
 }
Esempio n. 25
0
 /** @see Graphics#dispose() */
 public void dispose() {
   if (kid) return;
   if (!disposeCalled) {
     disposeCalled = true;
     cb.restoreState();
     cb.restoreState();
     dg2.dispose();
     dg2 = null;
     if (kids != null) {
       ByteBuffer buf = new ByteBuffer();
       internalDispose(buf);
       ByteBuffer buf2 = cb.getInternalBuffer();
       buf2.reset();
       buf2.append(buf);
     }
   }
 }
Esempio n. 26
0
  public static void main(String[] args) throws Exception {
    String fromFileName = args[0];
    String toFileName = args[1];
    FileChannel in = new FileInputStream(fromFileName).getChannel();
    FileChannel out = new FileOutputStream(toFileName).getChannel();

    ByteBuffer buff = ByteBuffer.allocate(32 * 1024);

    while (in.read(buff) > 0) {
      buff.flip();
      out.write(buff);
      buff.clear();
    }

    in.close();
    out.close();
  }
Esempio n. 27
0
 Class348_Sub33(int i, byte[] is) {
   ((Class348_Sub33) this).anInt6958 = i;
   ByteBuffer class348_sub49 = new ByteBuffer(is);
   ((Class348_Sub33) this).anInt6965 = class348_sub49.getUByte();
   ((Class348_Sub33) this).anIntArrayArray6959 = new int[((Class348_Sub33) this).anInt6965][];
   ((Class348_Sub33) this).anIntArray6957 = new int[((Class348_Sub33) this).anInt6965];
   ((Class348_Sub33) this).anIntArray6960 = new int[((Class348_Sub33) this).anInt6965];
   ((Class348_Sub33) this).aBooleanArray6954 = new boolean[((Class348_Sub33) this).anInt6965];
   for (int i_8_ = 0;
       ((((Class348_Sub33) this).anInt6965 ^ 0xffffffff) < (i_8_ ^ 0xffffffff));
       i_8_++) {
     ((Class348_Sub33) this).anIntArray6957[i_8_] = class348_sub49.getUByte();
     if (((Class348_Sub33) this).anIntArray6957[i_8_] == 6)
       ((Class348_Sub33) this).anIntArray6957[i_8_] = 2;
   }
   for (int i_9_ = 0;
       ((((Class348_Sub33) this).anInt6965 ^ 0xffffffff) < (i_9_ ^ 0xffffffff));
       i_9_++)
     ((Class348_Sub33) this).aBooleanArray6954[i_9_] =
         (class348_sub49.getUByte() ^ 0xffffffff) == -2;
   for (int i_10_ = 0;
       ((((Class348_Sub33) this).anInt6965 ^ 0xffffffff) < (i_10_ ^ 0xffffffff));
       i_10_++) ((Class348_Sub33) this).anIntArray6960[i_10_] = class348_sub49.getShort();
   for (int i_11_ = 0;
       ((i_11_ ^ 0xffffffff) > (((Class348_Sub33) this).anInt6965 ^ 0xffffffff));
       i_11_++)
     ((Class348_Sub33) this).anIntArrayArray6959[i_11_] = new int[class348_sub49.getUByte()];
   for (int i_12_ = 0; i_12_ < ((Class348_Sub33) this).anInt6965; i_12_++) {
     for (int i_13_ = 0;
         (i_13_ < ((Class348_Sub33) this).anIntArrayArray6959[i_12_].length);
         i_13_++)
       ((Class348_Sub33) this).anIntArrayArray6959[i_12_][i_13_] = class348_sub49.getUByte();
   }
 }
Esempio n. 28
0
 final void method2070(boolean bool, ByteBuffer class348_sub49) {
   if (bool != true) ((Class277) this).aBoolean3561 = false;
   for (; ; ) {
     int i = class348_sub49.getUByte();
     if ((i ^ 0xffffffff) == -1) break;
     method2069(-1, class348_sub49, i);
   }
   anInt3565++;
 }
Esempio n. 29
0
  /**
   * Compares two <code>ByteBuffer</code> objects.
   *
   * @exception ClassCastException If obj is not an object derived from <code>ByteBuffer</code>.
   */
  public int compareTo(ByteBuffer other) {
    int num = Math.min(remaining(), other.remaining());
    int pos_this = position();
    int pos_other = other.position();

    for (int count = 0; count < num; count++) {
      byte a = get(pos_this++);
      byte b = other.get(pos_other++);

      if (a == b) continue;

      if (a < b) return -1;

      return 1;
    }

    return remaining() - other.remaining();
  }
Esempio n. 30
0
 public synchronized void mark(int limit) throws IllegalArgumentException {
   if (limit > buf.length) {
     byte[] new_buf = new byte[limit];
     System.arraycopy(buf, pos, new_buf, pos, avail - pos);
     buf = new_buf;
     if (byteBuffer != null) byteBuffer.setBuffer(buf);
   }
   mark = pos;
 }