Esempio n. 1
0
 public function build()
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->_fields['CharacterId']);
     $writer->putUI16LE($this->_fields['Depth']);
     return $writer->output();
 }
Esempio n. 2
0
 function build()
 {
     $writer = new IO_Bit();
     $writer->putData('RIFF');
     $writer->putUI32LE(0);
     //
     $writer->putData('sfbk');
     $this->buildChunkLIST($writer, 'INFO', $this->sfbk['INFO']);
     $this->buildChunkLIST($writer, 'sdta', $this->sfbk['sdta']);
     $this->buildChunkLIST($writer, 'pdta', $this->sfbk['pdta']);
 }
Esempio n. 3
0
 function _form_26($tag)
 {
     // PlaceObject2
     $reader = new IO_Bit();
     $reader->input($tab['Content']);
     $placeFlag = $reader->getUI8();
     $depth = $reader->getUI16LE();
     if ($placeFlag & 0x2) {
         $characterId = $reader->getUI16LE();
     }
     //
 }
Esempio n. 4
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUIBit($this->Reserved);
     $writer->putUIBit($this->UseDirectBlit);
     $writer->putUIBit($this->UseGPU);
     $writer->putUIBit($this->HasMetadata);
     $writer->putUIBit($this->ActionScript3);
     $writer->putUIBits($this->Reserved2, 2);
     $writer->putUIBit($this->UseNetwork);
     $writer->putUIBits($this->Reserved3, 24);
     return $writer->output();
 }
Esempio n. 5
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     switch ($tagCode) {
         case 5:
             // RemoveObject
             $writer->putUI16LE($this->_characterId);
             $writer->putUI16LE($this->_depth);
             break;
         case 28:
             // RemoveObject2
             $writer->putUI16LE($this->_depth);
             break;
     }
     return $writer->output();
 }
Esempio n. 6
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->SoundId);
     // ----
     $writer->putUIBits($this->SoundFormat, 4);
     $writer->putUIBits($this->SoundRate, 2);
     $writer->putUIBit($this->SoundSize);
     // ---
     $writer->putUI32LE($this->SoundSampleCount);
     $writer->putData($this->SoundData);
     return $writer->output();
 }
Esempio n. 7
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->_CharacterID);
     $bitmapFormat = $this->_BitmapFormat;
     $writer->putUI8($bitmapFormat);
     $writer->putUI16LE($this->_BitmapWidth);
     $writer->putUI16LE($this->_BitmapHeight);
     if ($bitmapFormat == 3) {
         $writer->putUI8($this->_BitmapColorTableSize - 1);
     }
     $writer->putData($this->_ZlibBitmapData);
     return $writer->output();
 }
Esempio n. 8
0
File: Text.php Progetto: yoya/IO_SWF
 function buildContent($tagCode, $opts = array())
 {
     $opts['tagCode'] = $tagCode;
     $writer = new IO_Bit();
     $writer->putUI16LE($this->_CharacterID);
     IO_SWF_TYPE_RECT::build($writer, $this->_TextBounds);
     IO_SWF_Type_MATRIX::build($writer, $this->_TextMatrix);
     $glyphBits = $this->_GlyphBits;
     // XXX
     $advanceBits = $this->_AdvanceBits;
     // XXX
     $writer->putUI8($glyphBits);
     $writer->putUI8($advanceBits);
     $opts['GlyphBits'] = $glyphBits;
     $opts['AdvanceBits'] = $advanceBits;
     foreach ($this->_TextRecords as $textRecord) {
         IO_SWF_Type_TEXTRECORD::build($writer, $textRecord, $opts);
     }
     $writer->putUI8(0);
     // TEXTRECORD TERMINATER
     return $writer->output();
 }
Esempio n. 9
0
File: Tag.php Progetto: yoya/IO_SWF
 function build($opts = array())
 {
     $code = $this->code;
     if (is_null($this->content)) {
         $this->content = $this->buildTagContent();
     }
     $length = strlen($this->content);
     $writer = new IO_Bit();
     switch ($code) {
         case 6:
             // DefineBitsJPEG
         // DefineBitsJPEG
         case 21:
             // DefineBitsJPEG2
         // DefineBitsJPEG2
         case 35:
             // DefineBitsJPEG3
         // DefineBitsJPEG3
         case 20:
             // DefineBitsLossless
         // DefineBitsLossless
         case 36:
             // DefineBitsLossless2
         // DefineBitsLossless2
         case 19:
             // SoundStreamBlock
             $longFormat = true;
             break;
         default:
             $longFormat = false;
             break;
     }
     if ($longFormat === false && $length < 0x3f) {
         $tagAndLength = $code << 6 | $length;
         $writer->putUI16LE($tagAndLength);
     } else {
         $tagAndLength = $code << 6 | 0x3f;
         $writer->putUI16LE($tagAndLength);
         $writer->putUI32LE($length);
     }
     return $writer->output() . $this->content;
 }
Esempio n. 10
0
File: Jpeg.php Progetto: yoya/IO_SWF
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     if ($tagCode != 8) {
         // ! JPEGTablesa
         $writer->putUI16LE($this->_CharacterID);
     }
     if ($tagCode == 35) {
         // DefgineBitsJPEG3
         $this->_AlphaDataOffset = strlen($this->_JPEGData);
         $writer->putUI32LE($this->_AlphaDataOffset);
     }
     if ($tagCode != 35) {
         // ! DefgineBitsJPEG3
         $writer->putData($this->_JPEGData);
     } else {
         $writer->putData($this->_JPEGData);
         $writer->putData($this->_ZlibBitmapAlphaData);
     }
     return $writer->output();
 }
Esempio n. 11
0
File: Font.php Progetto: yoya/IO_SWF
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->FontID);
     //
     $fontFlagsHasLayout = is_null($this->FontAscent) ? 0 : 1;
     //
     $writer->putUIBit($fontFlagsHasLayout);
     $writer->putUIBit($this->FontFlagsShiftJIS);
     $writer->putUIBit($this->FontFlagsSmallText);
     $writer->putUIBit($this->FontFlagsANSI);
     $writer->putUIBit($this->FontFlagsWideOffsets);
     $writer->putUIBit($this->FontFlagsWideCodes);
     $writer->putUIBit($this->FontFlagsItalic);
     $writer->putUIBit($this->FontFlagsBold);
     IO_SWF_Type_LANGCODE::build($writer, $this->LanguageCode);
     $fontNameLen = strlen($this->FontName);
     $writer->putUI8($fontNameLen);
     $writer->putData($this->FontName);
     $numGlyphs = count($this->OffsetTable);
     $writer->putUI16LE($numGlyphs);
     if ($numGlyphs === 0) {
         return $writer->output();
         // no glyphs field.
     }
     list($startOfOffsetTable, $dummy) = $writer->getOffset();
     $startOfOffsetTable2 = array();
     if ($this->FontFlagsWideOffsets) {
         foreach ($this->OffsetTable as $idx => $offset) {
             list($startOfOffsetTables[$idx], $dummy) = $writer->getOffset();
             $writer->putUI32LE(0);
             // dummy
         }
     } else {
         foreach ($this->OffsetTable as $idx => $offset) {
             list($startOfOffsetTables[$idx], $dummy) = $writer->getOffset();
             $writer->putUI16LE(0);
             // dummy
         }
     }
     list($startOfcodeTableOffset, $dummy) = $writer->getOffset();
     if ($this->FontFlagsWideOffsets) {
         $writer->putUI32LE(0);
         // dummy
     } else {
         $writer->putUI16LE(0);
         // dummy
     }
     $opts['fillStyleCount'] = 1;
     $opts['lineStyleCount'] = 0;
     foreach ($this->GlyphShapeTable as $idx => $glyphShape) {
         list($startOfGlyphShape, $dummy) = $writer->getOffset();
         if ($this->FontFlagsWideOffsets) {
             $writer->setUI32LE($startOfGlyphShape - $startOfOffsetTable, $startOfOffsetTables[$idx]);
         } else {
             $writer->setUI16LE($startOfGlyphShape - $startOfOffsetTable, $startOfOffsetTables[$idx]);
         }
         IO_SWF_Type_SHAPE::build($writer, $glyphShape, $opts);
         $writer->byteAlign();
     }
     //
     list($startOfCodeTable, $dummy) = $writer->getOffset();
     $codeTableOffset = $startOfCodeTable - $startOfOffsetTable;
     if ($this->FontFlagsWideOffsets) {
         $writer->setUI32LE($codeTableOffset, $startOfcodeTableOffset);
     } else {
         $writer->setUI16LE($codeTableOffset, $startOfcodeTableOffset);
     }
     if ($this->FontFlagsWideCodes) {
         foreach ($this->CodeTable as $c) {
             $writer->putUI16LE($c);
         }
     } else {
         foreach ($this->CodeTable as $c) {
             $writer->putUI8($c);
         }
     }
     if ($fontFlagsHasLayout) {
         $writer->putSI16LE($this->FontAscent);
         $writer->putSI16LE($this->FontDescent);
         $writer->putSI16LE($this->FontLeading);
         foreach ($this->FontAdvanceTable as $fontAdvance) {
             $writer->putSI16LE($fontAdvance);
         }
         foreach ($this->FontBoundsTable as $fontBounds) {
             IO_SWF_TYPE_RECT::build($writer, $fontBounds);
         }
         if (is_null($this->FontKerningTable)) {
             $writer->putUI16LE(0);
         } else {
             $kerningCount = count($this->FontKerningTable);
             $writer->putUI16LE($kerningCount);
             $opts['FontFlagsWideCodes'] = $this->FontFlagsWideCodes;
             foreach ($this->FontKerningTable as $fontKerning) {
                 IO_SWF_TYPE_KERNINGRECORD::build($writer, $fontKerning, $opts);
             }
         }
     }
     return $writer->output();
 }
Esempio n. 12
0
 function parseContent($tagCode, $content, $opts = array())
 {
     $reader = new IO_Bit();
     $reader->input($content);
     $this->_color = IO_SWF_Type_RGB::parse($reader);
 }
Esempio n. 13
0
<?php

require_once 'IO/Bit.php';
if ($argc < 2) {
    echo "Usage: php iobit_put.php <width>:<value> [<width2>:<value2> [...]]" . PHP_EOL;
    echo "ex) php iobit_put.php 1:0 2:1 3:7 4:0 5:31 6:46 7:6 8:135" . PHP_EOL;
    exit(1);
}
$iobit = new IO_Bit();
foreach (array_slice($argv, 1) as $arg) {
    list($width, $value) = explode(':', $arg);
    $value = $iobit->putUIBits($value, $width);
}
echo $iobit->output();
Esempio n. 14
0
<?php

require_once 'IO/Bit.php';
function usage()
{
    echo "Usage: php iobit_get.php <filename> <width> [<width2> [...]]" . PHP_EOL;
    echo "ex) php iobit_get.php iobit_get.php 1 2 3 4 5 6 7 8" . PHP_EOL;
}
if ($argc < 2) {
    usage();
    exit(1);
}
$filename = $argv[1];
if ($filename === '-') {
    $filename = 'php://stdin';
} else {
    if (is_readable($filename) === false) {
        usage();
        exit(1);
    }
}
$iobit = new IO_Bit();
$filedata = file_get_contents($filename);
$iobit->input($filedata);
foreach (array_slice($argv, 2) as $arg) {
    $value = $iobit->getUIBits($arg);
    echo "{$arg}:{$value} ";
}
echo PHP_EOL;
Esempio n. 15
0
 function buildContent($tagCode, $opts = array())
 {
     $isMorph = $tagCode == 46 || $tagCode == 84;
     $writer = new IO_Bit();
     if (empty($opts['noShapeId'])) {
         $writer->putUI16LE($this->_shapeId);
     }
     $opts = array('tagCode' => $tagCode);
     if ($isMorph === false) {
         IO_SWF_Type_RECT::build($writer, $this->_shapeBounds);
         // 描画スタイル
         IO_SWF_Type_FILLSTYLEARRAY::build($writer, $this->_fillStyles, $opts);
         IO_SWF_Type_LINESTYLEARRAY::build($writer, $this->_lineStyles, $opts);
         // 描画枠
         $opts['fillStyleCount'] = count($this->_fillStyles);
         $opts['lineStyleCount'] = count($this->_lineStyles);
         IO_SWF_Type_SHAPE::build($writer, $this->_shapeRecords, $opts);
     } else {
         IO_SWF_Type_RECT::build($writer, $this->_startBounds);
         IO_SWF_Type_RECT::build($writer, $this->_endBounds);
         $writer->byteAlign();
         list($offset_offset, $dummy) = $writer->getOffset();
         $this->_offset = $writer->putUI32LE(0);
         // at first, write dummy
         // 描画スタイル
         IO_SWF_Type_FILLSTYLEARRAY::build($writer, $this->_morphFillStyles, $opts);
         IO_SWF_Type_LINESTYLEARRAY::build($writer, $this->_morphLineStyles, $opts);
         // 描画枠
         $opts['fillStyleCount'] = count($this->_morphFillStyles);
         $opts['lineStyleCount'] = count($this->_morphLineStyles);
         // StartEdge
         IO_SWF_Type_SHAPE::build($writer, $this->_startEdge, $opts);
         // EndEdge
         $writer->byteAlign();
         list($end_edge_offset, $dummy) = $writer->getOffset();
         $this->_offset = $end_edge_offset - $offset_offset - 4;
         $writer->setUI32LE($this->_offset, $offset_offset);
         IO_SWF_Type_SHAPE::build($writer, $this->_endEdge, $opts);
     }
     return $writer->output();
 }
Esempio n. 16
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->_buttonId);
     $opts['tagCode'] = $tagCode;
     if ($tagCode == 34) {
         // DefineButton2
         $writer->putUIBits($this->_reservedFlags, 7);
         $writer->putUIBit($this->_trackAsMenu);
         list($offset_actionOffset, $dummy) = $writer->getOffset();
         $writer->putUI16LE(0);
         // dummy;
     }
     foreach ($this->_characters as $character) {
         IO_SWF_Type_BUTTONRECORD::build($writer, $character, $opts);
     }
     $writer->putUI8(0);
     // terminater of button record
     if ($tagCode == 34) {
         // DefineButton2
         $actions = array();
         if (is_null($this->_actions) === false) {
             list($offset_buttonCondition, $dummy) = $writer->getOffset();
             $writer->setUI16LE($offset_buttonCondition - $offset_actionOffset, $offset_actionOffset);
             foreach ($this->_actions as $idx => $action) {
                 if (isset($this->_actions[$idx + 1]) === false) {
                     $opts['lastAction'] = true;
                 } else {
                     $opts['lastAction'] = false;
                 }
                 IO_SWF_Type_BUTTONCONDACTION::build($writer, $action, $opts);
             }
         }
     } else {
         foreach ($this->_actions as $action) {
             IO_SWF_Type_Action::build($writer, $action);
         }
         $writer->putUI8(0);
         // terminator of actions
     }
     return $writer->output();
 }
Esempio n. 17
0
 function parseContent($tagCode, $content, $opts = array())
 {
     $reader = new IO_Bit();
     $reader->input($content);
     $this->_label = IO_SWF_Type_String::parse($reader);
 }
Esempio n. 18
0
File: MFi.php Progetto: yoya/IO_MFi
 function parse($mfidata)
 {
     $reader = new IO_Bit();
     $reader->input($mfidata);
     // Header Part
     $identifier = $reader->getData(4);
     if ($identifier != 'melo') {
         throw new Exception('Identifer($identifier) is not melo');
     }
     $this->headers['Identifier'] = $identifier;
     $fileLength = $reader->getUI32BE();
     $realFileLength = strlen($mfidata);
     if ($fileLength != $realFileLength - 8) {
         throw new Exception("FileLength({$fileLength}) is not real FileLength({$realFileLength}) - 8");
     }
     $this->headers['FileLength'] = $fileLength;
     $offsetToTrack = $reader->getUI16BE();
     $this->headers['OffsetToTrack'] = $offsetToTrack;
     $this->headers['DataTypeMajor'] = $reader->getUI8();
     $this->headers['DataTypeMinor'] = $reader->getUI8();
     $this->headers['NumberOfTrack'] = $reader->getUI8();
     // Data Information Part
     $reader_di = new IO_Bit();
     $reader_di->input($reader->getData($offsetToTrack - 3));
     $note_message_length_info = 0;
     while ($reader_di->hasNextData(6)) {
         $info = array();
         $identifer = $reader_di->getData(4);
         $length = $reader_di->getUI16BE();
         $info['Identifer'] = $identifer;
         $info['Length'] = $length;
         switch ($identifer) {
             case 'titl':
             case 'copy':
             case 'prot':
             case 'date':
                 $data = $reader_di->getData($length);
                 break;
             case 'sorc':
                 $data = $reader_di->getUI8($length);
                 break;
             case 'note':
             case 'exst':
                 $data = $reader_di->getUI16BE($length);
                 if ($identifer == 'note') {
                     $note_message_length_info = $data;
                 }
                 break;
             case 'vers':
                 $data = $reader_di->getUI32BE($length);
                 break;
         }
         $info['Data'] = $data;
         $this->datainfos[] = $info;
     }
     // Track Part
     while ($reader->hasNextData(8)) {
         $track = array();
         $track['Identifer'] = $reader->getData(4);
         $length = $reader->getUI32BE();
         $track['Length'] = $length;
         $reader_ev = new IO_Bit();
         $reader_ev->input($reader->getData($length));
         $track['Events'] = array();
         while ($reader_ev->hasNextData(3)) {
             $event = array();
             $event['DeltaTime'] = $reader_ev->getUI8();
             $statusInfo = $reader_ev->getUI8();
             $event['StatusInfo'] = $statusInfo;
             switch ($statusInfo) {
                 default:
                     $event['Data'] = $reader_ev->getUI8();
                     if ($note_message_length_info == 1) {
                         // MFi2
                         $event['Data2'] = $reader_ev->getUI8();
                     }
                     break;
                 case 0xff:
                     $statusInfo2 = $reader_ev->getUI8();
                     $event['StatusInfo2'] = $statusInfo2;
                     switch ($statusInfo2) {
                         default:
                             $event['Data'] = $reader_ev->getUI8();
                             break;
                         case 0xf0:
                         case 0xf1:
                         case 0xff:
                             $length = $reader_ev->getUI16BE();
                             $event['Length'] = $length;
                             $event['Data'] = $reader_ev->getData($length);
                             break;
                     }
             }
             $track['Events'][] = $event;
         }
         $this->tracks[] = $track;
     }
 }
Esempio n. 19
0
 function dump($opts = array())
 {
     if (empty($opts['hexdump']) === false) {
         $bitio = new IO_Bit();
         $bitio->input($this->_swfdata);
     }
     /* SWF Header */
     echo 'Signature: ' . $this->_headers['Signature'] . PHP_EOL;
     echo 'Version: ' . $this->_headers['Version'] . PHP_EOL;
     echo 'FileLength: ' . $this->_headers['FileLength'] . PHP_EOL;
     echo 'FrameSize: ' . IO_SWF_Type_RECT::string($this->_headers['FrameSize']) . "\n";
     echo 'FrameRate: ' . $this->_headers['FrameRate'] / 0x100 . PHP_EOL;
     echo 'FrameCount: ' . $this->_headers['FrameCount'] . PHP_EOL;
     if (empty($opts['hexdump']) === false) {
         $bitio->hexdump(0, $this->_header_size);
         $opts['bitio'] =& $bitio;
         // for tag
     }
     $opts['indent'] = 0;
     /* SWF Tags */
     echo 'Tags:' . PHP_EOL;
     foreach ($this->_tags as $tag) {
         self::parseTagContent($tag, $opts);
     }
     $frame_num = 1;
     $sprite_tags = array();
     for ($i = 0; $i < count($this->_tags); $i++) {
         $tag = $this->_tags[$i];
         switch ($tag->code) {
             case 39:
                 // Sprite
                 $sprite_tags[] = $tag;
                 break;
             case 12:
                 // Action
             // Action
             case 59:
                 // InitAction
                 self::dumpActionTag($tag, $frame_num, $opts);
                 break;
             case 1:
                 // ShowFrame
                 $frame_num++;
                 break;
             case 43:
                 // FrameLabel
                 $tag->dump();
                 break;
             default:
                 break;
         }
     }
     foreach ($sprite_tags as $tag) {
         self::dumpSpriteTag($tag, $opts);
     }
 }
Esempio n. 20
0
 public function build()
 {
     $writer = new IO_Bit();
     foreach ($this->_actions as $index => $d) {
         $writer->putUI8($d['ActionCode']);
         if ($d['Length'] == 0) {
             continue;
         }
         $writer->putUI16LE($d['Length']);
         $writer->putData($d['Content']);
     }
     return $writer->output();
 }
Esempio n. 21
0
 function parseDataChunks(&$reader)
 {
     $chunks = array();
     while ($reader->hasNextData(8)) {
         $chunk = array();
         $chunkID = $reader->getData(4);
         $size = $reader->getUI32BE();
         $chunk['ID'] = $chunkID;
         $chunkID_3byte = substr($chunkID, 0, 3);
         $chunkID_4th_value = ord($chunkID[3]);
         switch ($chunkID_3byte) {
             case 'Dch':
                 $chunk['ID'] = $chunkID_3byte;
                 $chunk['CodeType'] = $chunkID_4th_value;
                 break;
             case 'MTR':
             case 'ATR':
             case 'GTR':
                 $chunk['ID'] = $chunkID_3byte;
                 $chunk['TrackNumber'] = $chunkID_4th_value;
                 break;
         }
         $chunk['Size'] = $size;
         switch (substr($chunkID, 0, 3)) {
             case 'CNT':
                 // CNTI: Contents Information Chunk
                 $chunk['Contents Class'] = $reader->getUI8();
                 $chunk['Contents Type'] = $reader->getUI8();
                 $chunk['Contents Code Type'] = $reader->getUI8();
                 $chunk['Copy Status'] = $reader->getUI8();
                 $chunk['Copy Counts'] = $reader->getUI8();
                 if ($size > 5) {
                     $chunk['Option'] = $reader->getData($size - 5);
                 }
                 break;
             case 'MTR':
                 // MTR*: Score Track Chunk
                 $chunk['Format Type'] = $reader->getUI8();
                 $chunk['Sequence Type'] = $reader->getUI8();
                 $chunk['Timebase D'] = $reader->getUI8();
                 $chunk['Timebase G'] = $reader->getUI8();
                 $chunk['Channnel Status'] = $reader->getUI16BE();
                 $data = $reader->getData($size - 6);
                 $reader_chunkdata = new IO_Bit();
                 $reader_chunkdata->input($data);
                 $this->seekToAlphabet($reader_chunkdata);
                 $chunk[$structure_type] = $this->parseDataChunks($reader_chunkdata);
                 break;
             case 'Mts':
                 // Mtsu, Mtsq, Mts
                 $data = $reader->getData($size);
                 $reader_tracks = new IO_Bit();
                 $reader_tracks->input($data);
                 switch ($chunkID) {
                     case 'Mtsu':
                         // Score Track Setup Data
                     // Score Track Setup Data
                     case 'Mtsq':
                         // Score Track Sequence Data
                         $tracks = array();
                         while ($reader_tracks->hasNextData(4)) {
                             $end_check = $reader_tracks->getUI32BE();
                             if ($end_check == 0) {
                                 break;
                             }
                             $reader_tracks->incrementOffset(-4, 0);
                             $track = array();
                             // Duration
                             if ($chunkID != 'Mtsu') {
                                 // Mtsu は Duration 無し
                                 $duration = $reader_tracks->getUI8();
                                 if ($duration & 0x80) {
                                     $duration = ($duration & 0x7f) << 8;
                                     $duration |= $reader_tracks->getUI8();
                                 }
                                 $track['Duration'] = $duration;
                             }
                             // Event
                             $event = $reader_tracks->getUI8();
                             $eventData = array();
                             if ($event != 0) {
                                 $eventData['Type'] = 'Note Message';
                                 $eventData['GetTime'] = $reader_tracks->getUI8();
                                 // Option ???
                             } else {
                                 $data1 = $reader_tracks->getUI8();
                                 $eventData['Channel'] = $data1 >> 6;
                                 if (($data1 & 0xf) == 0) {
                                     $eventData['Type'] = 'Program change';
                                 } elseif (($data1 & 0xf) == 1) {
                                     $eventData['Type'] = 'Bank Select';
                                 } else {
                                     $msg = sprintf("Unknow Event Data#1=0x%02x", $data1);
                                     //                                throw new Exception($msg);
                                     printf($msg . "\n");
                                     break 2;
                                 }
                                 $eventData['Value'] = $reader_tracks->getUI8();
                             }
                             $track['event'] = $tracks[] = $track;
                         }
                         $chunk['Tracks'] = $tracks;
                         break 2;
                 }
             default:
                 $data = $reader->getData($size);
                 if ($structure_type = $this->nestedChunkIDSize($chunkID)) {
                     $reader_chunkdata = new IO_Bit();
                     $reader_chunkdata->input($data);
                     $method = 'parseData' . $structure_type;
                     $chunk[$structure_type] = $this->{$method}($reader_chunkdata);
                 } else {
                     $chunk['Data'] = $data;
                 }
                 break;
         }
         //            var_dump($chunk);
         $chunks[] = $chunk;
     }
     return $chunks;
 }
Esempio n. 22
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     $writer->putUI16LE($this->CharacterID);
     IO_SWF_Type_RECT::build($writer, $this->Bounds);
     // ----
     $hasText = is_null($this->InitialText) ? 0 : 1;
     $hasTextColor = is_null($this->TextColor) ? 0 : 1;
     $hasMaxLength = is_null($this->MaxLength) ? 0 : 1;
     $hasFont = is_null($this->FontID) ? 0 : 1;
     $hasFontClass = is_null($this->FontClass) ? 0 : 1;
     $hasLayout = is_null($this->Align) ? 0 : 1;
     // ----
     $writer->byteAlign();
     $writer->putUIBit($hasText);
     $writer->putUIBit($this->WordWrap);
     $writer->putUIBit($this->Multiline);
     $writer->putUIBit($this->Password);
     $writer->putUIBit($this->ReadOnly);
     $writer->putUIBit($hasTextColor);
     $writer->putUIBit($hasMaxLength);
     $writer->putUIBit($hasFont);
     // ----
     $writer->putUIBit($hasFontClass);
     $writer->putUIBit($this->AutoSize);
     $writer->putUIBit($hasLayout);
     $writer->putUIBit($this->NoSelect);
     $writer->putUIBit($this->Border);
     $writer->putUIBit($this->WasStatic);
     $writer->putUIBit($this->HTML);
     $writer->putUIBit($this->UseOutlines);
     if ($hasFont) {
         $writer->putUI16LE($this->FontID);
     }
     if ($hasFontClass) {
         IO_SWF_Type_String::build($writer, $this->FontClass);
     }
     if ($hasFont) {
         $writer->putUI16LE($this->FontHeight);
     }
     if ($hasTextColor) {
         IO_SWF_Type_RGBA::build($writer, $this->TextColor);
     }
     if ($hasMaxLength) {
         $writer->putUI16LE($this->MaxLength);
     }
     if ($hasLayout) {
         $writer->putUI8($this->Align);
         $writer->putUI16LE($this->LeftMargin);
         $writer->putUI16LE($this->RightMargin);
         $writer->putUI16LE($this->Indent);
         $writer->putSI16LE($this->Leading);
     }
     IO_SWF_Type_String::build($writer, $this->VariableName);
     if ($hasText) {
         IO_SWF_Type_String::build($writer, $this->InitialText);
     }
     return $writer->output();
 }
Esempio n. 23
0
 static function build(&$writer, $action, $opts = array())
 {
     $code = $action['Code'];
     $writer->putUI8($code);
     if (0x80 <= $code) {
         switch ($code) {
             case 0x81:
                 // ActionGotoFrame
                 $writer->putUI16LE(2);
                 $writer->putUI16LE($action['Frame']);
                 break;
             case 0x83:
                 // ActionGetURL
                 $data = $action['UrlString'] . "" . $action['TargetString'] . "";
                 $writer->putUI16LE(strlen($data));
                 $writer->putData($data);
                 break;
             case 0x88:
                 // ActionConstantPool
                 $count = count($action['ConstantPool']);
                 $data = implode("", $action['ConstantPool']) . "";
                 $writer->putUI16LE(strlen($data) + 2);
                 $writer->putUI16LE($count);
                 $writer->putData($data);
                 break;
             case 0x8a:
                 // ActionWaitForFrame
                 $writer->putUI16LE($action['Frame']);
                 $writer->putUI8($action['SkipCount']);
                 break;
             case 0x8b:
                 // ActionSetTarget
                 $data = $action['TargetName'] . "";
                 $writer->putUI16LE(strlen($data));
                 $writer->putData($data);
                 break;
             case 0x8c:
                 // ActionGoToLabel
                 $data = $action['Label'] . "";
                 $writer->putUI16LE(strlen($data));
                 $writer->putData($data);
                 break;
             case 0x8d:
                 // ActionWaitForFrame2
                 $writer->putUI16LE($action['Frame']);
                 $writer->putUI8($action['SkipCount']);
                 break;
             case 0x8e:
                 // ActionDefineFunction2
                 $writer->putData($action['FunctionName'] . "");
                 //		$numParams = $action['NumParams'];
                 $numParams = count($parameters);
                 $writer->putUI16LE($numParams);
                 $writer->putUI8($action['RegisterCount']);
                 //
                 $writer->putUIBit($action['PreloadParentFlag']);
                 $writer->putUIBit($action['PreloadBootFlag']);
                 $writer->putUIBit($action['SuppressSuperFlag']);
                 $writer->putUIBit($action['PreloadSuperFlag']);
                 $writer->putUIBit($action['SuppressArgumentsFlag']);
                 $writer->putUIBit($action['PreloadArgumentsFlag']);
                 $writer->putUIBit($action['SuppressThisFlag']);
                 $writer->putUIBit($action['PreloadThisFlag']);
                 //
                 if (isset($action['(Reserve)'])) {
                     $writer->putUIBits($action['(Reserve)'], 7);
                 } else {
                     $writer->putUIBits(0, 7);
                 }
                 $writer->putUIBit($action['PreloadGlobalFlag']);
                 //
                 $parameters = $action['Parameters'];
                 foreach ($parameters as $registerParam) {
                     $writer->putUI8($registerParam['Register']);
                     $writer->putData($registerParam['ParamName'] . "");
                 }
                 $writer->putUI16LE($action['codeSize']);
                 break;
                 break;
             case 0x96:
                 // ActionPush
                 $values_writer = new IO_Bit();
                 foreach ($action['Values'] as $value) {
                     $type = $value['Type'];
                     $values_writer->putUI8($type);
                     switch ($type) {
                         case 0:
                             // STRING
                             $str = $value['String'];
                             $pos = strpos($str, "");
                             if ($pos === false) {
                                 $str .= "";
                             } else {
                                 $str = substr($str, 0, $pos + 1);
                             }
                             $values_writer->putData($str);
                             break;
                         case 1:
                             // Float
                             IO_SWF_Type_Float::build($values_writer, $value['Float']);
                             break;
                         case 2:
                             // null
                             // nothing to do.
                             break;
                         case 3:
                             // undefined
                             // nothing to do.
                             break;
                         case 4:
                             // RegisterNumber
                             $values_writer->putUI8($value['RegisterNumber']);
                             break;
                         case 5:
                             // Boolean
                             $values_writer->putUI8($value['Boolean']);
                             break;
                         case 6:
                             // Double
                             IO_SWF_Type_Double::build($values_writer, $value['Double']);
                             break;
                         case 7:
                             // Integer
                             $values_writer->putUI32LE($value['Integer']);
                             break;
                         case 8:
                             // Constant8
                             $values_writer->putUI8($value['Constant8']);
                             break;
                         case 9:
                             // Constant16
                             $values_writer->putUI16LE($value['Constant16']);
                             break;
                         default:
                             throw new IO_SWF_Exception("Illegal ActionPush value's type({$type})");
                             break;
                     }
                 }
                 $values_data = $values_writer->output();
                 $writer->putUI16LE(strlen($values_data));
                 $writer->putData($values_data);
                 break;
             case 0x99:
                 // ActionJump
                 $writer->putUI16LE(2);
                 $writer->putSI16LE($action['BranchOffset']);
                 break;
             case 0x9a:
                 // ActionGetURL2
                 $writer->putUI16LE(1);
                 //                $writer->putUIBits($action['SendVarsMethod'], 2);
                 //                $writer->putUIBits(0, 4); // Reserved
                 //                $writer->putUIBit($action['LoadTargetFlag']);
                 //                $writer->putUIBit($action['LoadVariablesFlag']);
                 // swf_file_format_spec_v10 bug, field reverse.
                 $writer->putUIBit($action['LoadVariablesFlag']);
                 $writer->putUIBit($action['LoadTargetFlag']);
                 $writer->putUIBits(0, 4);
                 // Reserved
                 $writer->putUIBits($action['SendVarsMethod'], 2);
                 break;
             case 0x9d:
                 // ActionIf
                 $writer->putUI16LE(2);
                 $writer->putSI16LE($action['Offset']);
                 break;
             case 0x9f:
                 // ActionGotoFrame2
                 if (isset($action['SceneBias'])) {
                     $sceneBiasFlag = 1;
                     $writer->putUI16LE(3);
                 } else {
                     $sceneBiasFlag = 0;
                     $writer->putUI16LE(1);
                 }
                 $writer->putUIBits(0, 6);
                 // Reserved
                 $writer->putUIBit($sceneBiasFlag);
                 $writer->putUIBit($action['PlayFlag']);
                 if ($sceneBiasFlag) {
                     $writer->putUI16LE($action['SceneBias']);
                 }
                 break;
             default:
                 if (isset($action['Data'])) {
                     $data = $action['Data'];
                     $writer->putUI16LE(strlen($data));
                     $writer->putData($data);
                 } else {
                     $writer->putUI16LE(0);
                 }
                 break;
         }
     }
 }
Esempio n. 24
0
 function dump($opts = array())
 {
     if (empty($opts['hexdump']) === false) {
         $bitio = new IO_Bit();
         $bitio->input($this->_mididata);
     }
     echo "HEADER:\n";
     foreach ($this->header['header'] as $key => $value) {
         echo "  {$key}: {$value}\n";
     }
     if (empty($opts['hexdump']) === false) {
         $bitio->hexdump(0, $this->header['length'] + 8);
     }
     $xfkaraoke_with_track = $this->tracks;
     if ($this->xfkaraoke !== null) {
         $xfkaraoke_with_track["karaoke"] = $this->xfkaraoke;
         $xfkaraoke_with_track["karaoke"]["track"] = $this->xfkaraoke["xfkaraoke"];
     }
     foreach ($xfkaraoke_with_track as $idx => $track) {
         $scaleCharactors = array('C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B');
         echo "TRACK[{$idx}]:\n";
         if (empty($opts['hexdump']) === false) {
             $bitio->hexdump($track['_offset'], 8);
         }
         foreach ($track['track'] as $idx2 => $chunk) {
             if (empty($opts['measure']) === false) {
                 $deltaTime = $chunk['DeltaTime'];
                 $this->_timeInMeasure -= $deltaTime;
                 // XXX
                 if ($this->_timeInMeasure <= 0) {
                     echo "=== Measure:{$this->_measureSeqno}\n";
                     $this->_timeInMeasure = $this->header['header']['Division'] * $this->_measure1 * (4 / $this->_measure2);
                     $this->_measureSeqno++;
                 }
             }
             echo "  [{$idx2}]:";
             foreach ($chunk as $key => $value) {
                 switch ($key) {
                     case 'EventType':
                         if ($value < 0xf) {
                             $eventname = $this->event_name[$value];
                         } else {
                             if (isset($chunk['SystemEx'])) {
                                 $eventname = "System Exclusive";
                             } elseif (isset($chunk['SystemExCont'])) {
                                 $eventname = "System Exclusive Cont";
                             } elseif (isset($chunk['MetaEventType'])) {
                                 $eventname = "Meta Event";
                             } else {
                                 $eventname = "Unknown";
                             }
                         }
                         echo " {$key}:{$value}({$eventname}),";
                         break;
                     case 'MetaEventType':
                         $meta_event_type = $value;
                         if (isset($this->meta_event_name[$value])) {
                             $eventname = $this->meta_event_name[$value];
                             echo " {$key}:{$value}({$eventname}),";
                         } else {
                             echo " {$key}:{$value},";
                         }
                         break;
                     case 'ControllerType':
                         $typename = $this->controller_type_name[$value];
                         echo " {$key}:{$value}({$typename}),";
                         break;
                     case 'SystemEx':
                     case 'SystemExCont':
                     case 'MetaEventData':
                         echo " {$key}:";
                         $dataLen = strlen($value);
                         if ($key === 'MetaEventData') {
                             switch ($meta_event_type) {
                                 case 0x5:
                                     // Lyric
                                     echo mb_convert_encoding($value, "UTF-8", "SJIS");
                                     break;
                                 case 0x7:
                                     // Cue Point
                                     echo $value;
                                     break;
                                 case 0x58:
                                     // time signature
                                     $measure1 = ord($value[0]);
                                     $measure2 = pow(2, ord($value[1]));
                                     echo "{$measure1}/{$measure2}";
                                     $this->_measure1 = $measure1;
                                     $this->_measure2 = $measure2;
                                     break;
                                 default:
                                     break;
                             }
                         }
                         echo "(";
                         for ($i = 0; $i < $dataLen; $i++) {
                             printf("%02x", ord($value[$i]));
                         }
                         echo ")";
                         if ($key === 'SystemEx') {
                             echo "\n";
                             $sysex = new IO_MIDI_SysEx();
                             $sysex->dumpPayload($value);
                         }
                         break;
                     case 'NoteNumber':
                         $noteoct = floor($value / 12);
                         $notekey = $scaleCharactors[$value % 12];
                         echo " {$key}:{$value}({$notekey}{$noteoct}),";
                         break;
                     default:
                         if ($key[0] !== '_' || empty($opts['verbose']) === false) {
                             echo " {$key}:{$value},";
                         }
                         break;
                 }
             }
             echo "\n";
             if (empty($opts['hexdump']) === false) {
                 $bitio->hexdump($chunk['_offset'], $chunk['_length']);
             }
         }
     }
 }
Esempio n. 25
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     switch ($tagCode) {
         case 4:
             // PlaceObject
             $this->_characterId = $writer->getUI16LE();
             $this->_depth = $writer->getUI16LE();
             $this->_matrix = IO_SWF_Type_MATRIX::parse($writer);
             if ($writer->hasNextData()) {
                 // optional
                 $this->_colorTransform = IO_SWF_Type_CXFORM::parse($writer);
             }
             break;
         case 26:
             // PlaceObject2
             //
             if (is_null($this->_characterId) === false) {
                 $this->_placeFlagHasCharacter = 1;
             } else {
                 $this->_placeFlagHasCharacter = 0;
             }
             if (is_null($this->_matrix) === false) {
                 $this->_placeFlagHasMatrix = 1;
             } else {
                 $this->_placeFlagHasMatrix = 0;
             }
             if (is_null($this->_colorTransform) === false) {
                 $this->_placeFlagHasColorTransform = 1;
             } else {
                 $this->_placeFlagHasColorTransform = 0;
             }
             if (is_null($this->_ratio) === false) {
                 $this->_placeFlagHasRatio = 1;
             } else {
                 $this->_placeFlagHasRatio = 0;
             }
             if (is_null($this->_name) === false) {
                 $this->_placeFlagHasName = 1;
             } else {
                 $this->_placeFlagHasName = 0;
             }
             if (is_null($this->_clipDepth) === false) {
                 $this->_placeFlagHasClipDepth = 1;
             } else {
                 $this->_placeFlagHasClipDepth = 0;
             }
             if (is_null($this->_clipActions) === false) {
                 $this->_placeFlagHasClipActions = 1;
             } else {
                 $this->_placeFlagHasClipActions = 0;
             }
             // placeFlag
             $writer->putUIBit($this->_placeFlagHasClipActions);
             $writer->putUIBit($this->_placeFlagHasClipDepth);
             $writer->putUIBit($this->_placeFlagHasName);
             $writer->putUIBit($this->_placeFlagHasRatio);
             $writer->putUIBit($this->_placeFlagHasColorTransform);
             $writer->putUIBit($this->_placeFlagHasMatrix);
             $writer->putUIBit($this->_placeFlagHasCharacter);
             $writer->putUIBit($this->_placeFlagMove);
             //
             $writer->putUI16LE($this->_depth);
             if ($this->_placeFlagHasCharacter) {
                 $writer->putUI16LE($this->_characterId);
             }
             if ($this->_placeFlagHasMatrix) {
                 IO_SWF_Type_MATRIX::build($writer, $this->_matrix);
             }
             if ($this->_placeFlagHasColorTransform) {
                 IO_SWF_Type_CXFORMWITHALPHA::build($writer, $this->_colorTransform);
             }
             if ($this->_placeFlagHasRatio) {
                 $writer->putUI16LE($this->_ratio);
             }
             if ($this->_placeFlagHasName) {
                 IO_SWF_Type_String::build($writer, $this->_name);
             }
             if ($this->_placeFlagHasClipDepth) {
                 $writer->putUI16LE($this->_clipDepth);
             }
             if ($this->_placeFlagHasClipActions) {
                 IO_SWF_Type_CLIPACTIONS::build($writer, $this->_clipActions, $opts);
             }
             break;
     }
     return $writer->output();
 }
Esempio n. 26
0
 function parseChunkData()
 {
     if (isset($this->detail)) {
         return;
     }
     $detailData = array();
     $id = $this->id;
     $reader = new IO_Bit();
     $reader->input($this->data);
     $this->data = null;
     // XXX
     switch ($id) {
         // INFO sub-chunks
         case 'ifil':
             $detailData['sfVersionMajor'] = $reader->getUI16LE();
             $detailData['sfVersionMinor'] = $reader->getUI16LE();
             break;
         case 'INAM':
             $detailData['sfName'] = $this->data;
             // String
             break;
         case 'isng':
             $detailData['sfEngine'] = $this->data;
             // String
             break;
         case 'IENG':
             $detailData['sfEngineers'] = $this->data;
             // String
             break;
         case 'ISFT':
             $detailData['sfTools'] = $this->data;
             // String
             break;
         case 'ICMT':
             $detailData['Comments'] = $this->data;
             // String
             break;
         case 'ICOP':
             $detailData['Copyright'] = $this->data;
             // String
             break;
             // sdta sub-chunks
         // sdta sub-chunks
         case 'smpl':
             $detailData['Samples'] = $this->data;
             // String
             break;
             // pdta sub-chunks
         // pdta sub-chunks
         case 'phdr':
             $detailData = array();
             while ($reader->hasNextData()) {
                 $preset = array();
                 $presetName = explode("", $reader->getData(20));
                 $preset['PresetName'] = $presetName[0];
                 $preset['Preset'] = $reader->getUI16LE();
                 $preset['Bank'] = $reader->getUI16LE();
                 $preset['PresetBagNdx'] = $reader->getUI16LE();
                 $preset['Library'] = $reader->getUI32LE();
                 $preset['Genre'] = $reader->getUI32LE();
                 $preset['MorphologyGenre'] = $reader->getUI32LE();
                 $detailData[] = $preset;
             }
             break;
         case 'pbag':
             $detailData = array();
             while ($reader->hasNextData()) {
                 $presetBag = array();
                 $presetBag['GenNdx'] = $reader->getUI16LE();
                 $presetBag['ModNdx'] = $reader->getUI16LE();
                 $detailData[] = $presetBag;
             }
             break;
         case 'pmod':
         case 'imod':
             $detailData = array();
             while ($reader->hasNextData()) {
                 $sfMod = array();
                 $sfMod['sfModSrcOper'] = IO_SoundFont_Modulator::parse($reader);
                 $sfMod['sfModDestOper'] = $reader->getUI16LE();
                 $sfMod['modAmount'] = $reader->getSI16LE();
                 $sfMod['sfModAmtSrcOper'] = IO_SoundFont_Modulator::parse($reader);
                 $sfMod['sfModTransOper'] = $reader->getUI16LE();
                 $detailData[] = $sfMod;
             }
             break;
         case 'pgen':
         case 'igen':
             $detailData = array();
             while ($reader->hasNextData()) {
                 $detailData[] = IO_SoundFont_Generator::parse($reader);
             }
             break;
         case 'inst':
             $detailData = array();
             while ($reader->hasNextData()) {
                 $sfInst = array();
                 $InstName = explode("", $reader->getData(20));
                 $sfInst['InstName'] = $InstName[0];
                 $sfInst['InstBagNdx'] = $reader->getSI16LE();
                 $detailData[] = $sfInst;
             }
             break;
         case 'ibag':
             $detailData = array();
             while ($reader->hasNextData()) {
                 $presetBag = array();
                 $presetBag['GenNdx'] = $reader->getUI16LE();
                 $presetBag['ModNdx'] = $reader->getUI16LE();
                 $detailData[] = $presetBag;
             }
             break;
         case 'shdr':
             $detailData = array();
             while ($reader->hasNextData()) {
                 $sfSample = array();
                 $SampleName = explode("", $reader->getData(20));
                 $sfSample['SampleName'] = $SampleName[0];
                 $sfSample['Start'] = $reader->getUI32LE();
                 $sfSample['End'] = $reader->getUI32LE();
                 $sfSample['StartLoop'] = $reader->getUI32LE();
                 $sfSample['EndLoop'] = $reader->getUI32LE();
                 $sfSample['SampleRate'] = $reader->getUI32LE();
                 $sfSample['OriginalPitch'] = $reader->getUI8();
                 $sfSample['PitchCorrection'] = $reader->getSI8();
                 $sfSample['SampleLink'] = $reader->getUI16LE();
                 $sfSample['SampleType'] = $reader->getUI16LE();
                 $detailData[] = $sfSample;
             }
             break;
         default:
             return;
             // nothing to do
             break;
     }
     $this->detail = $detailData;
 }
Esempio n. 27
0
File: SWF.php Progetto: yoya/IO_SWF
 function dump($opts = array())
 {
     if (empty($opts['hexdump']) === false) {
         $bitio = new IO_Bit();
         $bitio->input($this->_swfdata);
     }
     /* SWF Header */
     echo 'Signature: ' . $this->_headers['Signature'] . PHP_EOL;
     echo 'Version: ' . $this->_headers['Version'] . PHP_EOL;
     echo 'FileLength: ' . $this->_headers['FileLength'] . PHP_EOL;
     echo 'FrameSize: ' . IO_SWF_Type_RECT::string($this->_headers['FrameSize']) . "\n";
     echo 'FrameRate: ' . $this->_headers['FrameRate'] / 0x100 . PHP_EOL;
     echo 'FrameCount: ' . $this->_headers['FrameCount'] . PHP_EOL;
     if (empty($opts['hexdump']) === false) {
         $bitio->hexdump(0, $this->_header_size);
         $opts['bitio'] =& $bitio;
         // for tag
     }
     $opts['indent'] = 0;
     /* SWF Tags */
     if ($this->_headers['Version'] < 6) {
         ob_start('mb_convert_encoding_from_sjis');
     }
     echo 'Tags:' . PHP_EOL;
     foreach ($this->_tags as $tag) {
         try {
             $tag->dump($opts);
         } catch (IO_Bit_Exception $e) {
             echo "(tag dump failed) {$e}\n";
         }
         if ($this->_headers['Version'] < 6) {
             ob_flush();
         }
     }
 }
Esempio n. 28
0
 function buildContent($tagCode, $opts = array())
 {
     $writer = new IO_Bit();
     if ($tagCode == 59) {
         // DoInitAction
         $writer->putUI16LE($this->_spriteId);
     }
     $action = null;
     for ($i = 0; $i < count($this->_actions); $i++) {
         $action = $this->_actions[$i];
         if ($action['Code'] == 0x99 || $action['Code'] == 0x9d) {
             // Jump
             // Find label to jump
             for ($j = 0; $j <= count($this->_actions); $j++) {
                 if (isset($this->_labels[$j]) && $this->_labels[$j] == $this->_branches[$i]) {
                     break;
                 }
             }
             // Calculate new offset
             $branch_offset = 0;
             if ($i < $j) {
                 for ($k = $i + 1; $k < $j; $k++) {
                     $branch_offset += IO_SWF_Tag_Action::actionLength($this->_actions[$k]);
                 }
             } else {
                 for ($k = $i; $k >= $j; $k--) {
                     $branch_offset -= IO_SWF_Tag_Action::actionLength($this->_actions[$k]);
                 }
             }
             if ($action['Code'] == 0x99) {
                 // Jump
                 $action['BranchOffset'] = $branch_offset;
             }
             if ($action['Code'] == 0x9d) {
                 // If
                 $action['Offset'] = $branch_offset;
             }
         }
         IO_SWF_Type_Action::build($writer, $action);
     }
     if (is_null($action) === false && $action['Code'] !== 0) {
         $writer->putUI8(0);
         // ActionEndFlag
     }
     return $writer->output();
 }
Esempio n. 29
0
File: JPEG.php Progetto: yoya/IO_SWF
 function getStdJpegData()
 {
     if (count($this->_jpegChunk) == 0) {
         $this->_splitChunk(false, false);
     }
     $bitout = new IO_Bit();
     foreach ($this->stdChunkOrder as $stdMarker) {
         foreach ($this->_jpegChunk as $chunk) {
             $marker = $chunk['marker'];
             if ($stdMarker == $marker) {
                 $bitout->putUI8(0xff);
                 $bitout->putUI8($marker);
                 if (!is_null($chunk['length'])) {
                     $bitout->putUI16BE($chunk['length']);
                 }
                 $bitout->putData($chunk['data']);
                 if ($marker == 0xd8 || $marker == 0xd9) {
                     break;
                     // SOI | EOI
                 }
             }
         }
     }
     return $bitout->output();
 }