Example #1
0
 /*
  * Reads a PushEntry instance from a bit stream.
  */
 StackValue(InputBitStream stream) throws IOException {
   type = stream.readUI8();
   switch (type) {
     case TYPE_STRING:
       string = stream.readString();
       break;
     case TYPE_FLOAT:
       floatValue = stream.readFloat();
       break;
     case TYPE_REGISTER:
       registerNumber = stream.readUI8();
       break;
     case TYPE_BOOLEAN:
       booleanValue = (stream.readUI8() != 0);
       break;
     case TYPE_DOUBLE:
       doubleValue = stream.readDouble();
       break;
     case TYPE_INTEGER:
       integerValue = stream.readUI32();
       break;
     case TYPE_CONSTANT_8:
       constant8 = stream.readUI8();
       break;
     case TYPE_CONSTANT_16:
       constant16 = stream.readUI16();
       break;
   }
 }
Example #2
0
 /*
  * Reads a Push action from a bit stream.
  */
 Push(InputBitStream stream) throws IOException {
   code = ActionConstants.PUSH;
   while (stream.available() > 0) {
     StackValue value = new StackValue(stream);
     values.add(value);
   }
 }
Example #3
0
 /**
  * Reads a Matrix instance from a bit stream.
  *
  * @param stream source bit stream
  * @throws IOException if an I/O error has occured
  */
 public Matrix(InputBitStream stream) throws IOException {
   hasScale = stream.readBooleanBit();
   if (hasScale) {
     int nScaleBits = (int) stream.readUnsignedBits(5);
     scaleX = stream.readFPBits(nScaleBits);
     scaleY = stream.readFPBits(nScaleBits);
   }
   hasRotateSkew = stream.readBooleanBit();
   if (hasRotateSkew) {
     int nRotateBits = (int) stream.readUnsignedBits(5);
     rotateSkew0 = stream.readFPBits(nRotateBits);
     rotateSkew1 = stream.readFPBits(nRotateBits);
   }
   int nTranslateBits = (int) stream.readUnsignedBits(5);
   translateX = (int) stream.readSignedBits(nTranslateBits);
   translateY = (int) stream.readSignedBits(nTranslateBits);
   stream.align();
 }
Example #4
0
 /**
  * Reads a ButtonCondAction instance from a bit stream.
  *
  * @param stream the input bit stream
  * @throws IOException if an I/O error has occured
  */
 public ButtonCondAction(InputBitStream stream) throws IOException {
   idleToOverDown = stream.readBooleanBit();
   outDownToIdle = stream.readBooleanBit();
   outDownToOverDown = stream.readBooleanBit();
   overDownToOutDown = stream.readBooleanBit();
   overDownToOverUp = stream.readBooleanBit();
   overUpToOverDown = stream.readBooleanBit();
   overUpToIdle = stream.readBooleanBit();
   idleToOverUp = stream.readBooleanBit();
   keyPress = (byte) stream.readUnsignedBits(7);
   overDownToIdle = stream.readBooleanBit();
   //    actions             = new ActionBlock(stream);
   actions = ActionBlock.getInstance();
   actions.read(stream);
 }
Example #5
0
 void setData(byte[] data) throws IOException {
   InputBitStream inStream = new InputBitStream(data);
   characterId = inStream.readUI16();
   jpegData = new byte[data.length - 2];
   System.arraycopy(data, 2, jpegData, 0, jpegData.length);
 }
Example #6
0
 /*
  * Reads a GoToLabel action from a bit stream.
  */
 GoToLabel(InputBitStream stream) throws IOException {
   super(ActionType.GO_TO_LABEL);
   frameLabel = stream.readString();
 }
Example #7
0
 /**
  * Reads the SWF content from the stream passed to the constructor, and invokes the methods of the
  * registered listeners. Finally, the stream is closed.
  *
  * <p>Returns the SWF document created during parsing.
  *
  * <p>Read errors while processing a tag will cause an exception to be thrown, this behaviour can
  * changed to instead create a MalformedTag (and thus allowing the code to continue albeit with
  * corrupt data) by using {@link SWFListener}. See {@link
  * SWFListener#processTagReadError(TagHeader, byte[], Exception)}.
  *
  * @see SWFListener
  * @return the parsed <code>SWFDocument</code> instance
  * @throws IOException if an error occured while reading
  */
 public SWFDocument read() throws IOException {
   preProcess();
   SWFHeader header;
   try {
     header = new SWFHeader(bitStream);
   } catch (Exception e) {
     // invoke error processing, without header we cannot do anything...
     processHeaderReadError(e);
     IOException ioe = new IOException("Error while reading SWF header");
     ioe.initCause(e);
     throw ioe;
   }
   processHeader(header);
   do {
     // we check this because of an OpenOffice export bug
     // (END tag written as a UI8 (00)instead of an UI16 (00 00))
     if ((header.getFileLength() - bitStream.getOffset()) < 2) {
       break;
     }
     TagHeader tagHeader = null;
     try {
       tagHeader = TagReader.readTagHeader(bitStream);
     } catch (Exception e) {
       // cannot continue without tag header
       processTagHeaderReadError(e);
       IOException ioe = new IOException("Error while reading Tag header");
       ioe.initCause(e);
       throw ioe;
     }
     processTagHeader(tagHeader);
     Tag tag = null;
     byte[] tagData = null;
     try {
       tagData = TagReader.readTagData(bitStream, tagHeader);
       tag = TagReader.readTag(tagHeader, tagData, header.getVersion(), japanese);
       if (TagType.END.equals(tag.tagType())) {
         break;
       }
     } catch (Exception e) {
       // invoke error processing
       if (processTagReadError(tagHeader, tagData, e)) {
         TagType tt = null;
         try {
           tt = TagType.lookup(tagHeader.getCode());
         } catch (InvalidCodeException ive) {
         }
         IOException ioe =
             new IOException(
                 "Error while reading Tag ("
                     + (tt != null ? tt.getNiceName() : "UNKOWN")
                     + ", code:"
                     + tagHeader.getCode()
                     + ", length:"
                     + tagHeader.getLength()
                     + ")");
         ioe.initCause(e);
         throw ioe;
       }
       tag = new MalformedTag(tagHeader, tagData, e);
     }
     processTag(tag, bitStream.getOffset());
   } while (true);
   postProcess();
   try {
     bitStream.close();
   } catch (Exception e) {
     // empty on purpose - don't need to propagate errors which occur while closing
   }
   return document;
 }
 void setData(byte[] data) throws IOException {
   InputBitStream inStream = new InputBitStream(data);
   inStream.readUnsignedBits(4); // 4 reserved bits
   playbackRate = (byte) inStream.readUnsignedBits(2);
   isPlayback16BitSample = inStream.readBooleanBit();
   isPlaybackStereo = inStream.readBooleanBit();
   streamFormat = (byte) inStream.readUnsignedBits(4);
   streamRate = (byte) inStream.readUnsignedBits(2);
   isStream16BitSample = inStream.readBooleanBit();
   isStreamStereo = inStream.readBooleanBit();
   streamSampleCount = inStream.readUI16();
   if ((streamFormat == FORMAT_MP3) && (data.length > 4)) {
     latencySeek = inStream.readSI16();
   }
 }
Example #9
0
 Jump(InputBitStream stream) throws IOException {
   code = ActionConstants.JUMP;
   branchOffset = stream.readSI16();
 }