Changeset 9878 for trunk/Jav_EXT/com/scenari/ext/swf/FSCoder.java
- Timestamp:
- 10/26/07 17:54:04 (4 years ago)
- File:
-
- 1 edited
-
trunk/Jav_EXT/com/scenari/ext/swf/FSCoder.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Jav_EXT/com/scenari/ext/swf/FSCoder.java
r6119 r9878 1 1 package com.scenari.ext.swf; 2 3 2 /* 3 * FSCoder.java 4 * 5 * Copyright (c) 2001-2006 Flagstone Software Ltd. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without modification, 8 * are permitted provided that the following conditions are met: 9 * 10 * * Redistributions of source code must retain the above copyright notice, this 11 * list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * * Neither the name of Flagstone Software Ltd. nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 27 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 28 * OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 import java.io.InputStream; 4 32 import java.io.UnsupportedEncodingException; 5 33 … … 227 255 */ 228 256 public FSCoder(int order, int size) { 229 clearContext();230 231 257 byteOrder = order; 232 258 data = new byte[size]; … … 249 275 */ 250 276 public FSCoder(int order, byte[] bytes) { 251 clearContext();252 253 277 byteOrder = order; 254 278 data = bytes; … … 1029 1053 1030 1054 static final int DecodeGlyphs = 20; 1031 1032 int[] context = new int[21]; 1033 1034 private void clearContext() { 1035 for (int i = 0; i < context.length; i++) 1036 context[i] = 0; 1037 } 1038 1039 public int getContext(int key) { 1040 return context[key]; 1041 } 1042 1043 public void setContext(int key, int value) { 1044 context[key] = value; 1055 1056 /** 1057 * Format FLV : Reinitialise les data pour accéder à un nouveau bloc de données situé à pOffset du pointeur courant 1058 * aligné à l'octet près ; éventuellement, en poursuivant la lecture du stream. 1059 * 1060 * @param pOffset décalage en bits pour accéder au début du bloc. Attention : pOffset ne peut PAS être négatif. 1061 * @return true si le bloc suivant a été trouvé, false si plus de block. 1062 */ 1063 public boolean gotoNextBlock(int pByteOffset, InputStream pStreamForMoreData) throws Exception { 1064 int vOffset = pByteOffset; 1065 alignToByte(); 1066 int vByteRemainder = (end - ptr) >>> 3; 1067 if(vOffset > vByteRemainder){ 1068 //L'offset dépasse la fin des datas disponibles. 1069 vOffset -= vByteRemainder; 1070 vByteRemainder = 0; 1071 } else if(vOffset>0) { 1072 //L'offset nous déplace dans les datas disponibles. 1073 vByteRemainder -= vOffset; 1074 vOffset = 0; 1075 } 1076 1077 if(vByteRemainder > 0) { 1078 //Il reste des data à préserver (qui constituent le début du nouveau bloc), on les déplace au début 1079 System.arraycopy(data, data.length-vByteRemainder, data, 0, vByteRemainder); 1080 } else { 1081 //On saute les octets restants 1082 if(vOffset>0) pStreamForMoreData.skip(vOffset); 1083 } 1084 1085 ptr = 0; 1086 1087 int vRead = vByteRemainder; 1088 while(vRead != -1 && vRead < data.length) { 1089 int vRead2 = pStreamForMoreData.read(data, vRead, data.length - vRead); 1090 if(vRead2 == -1) break; 1091 vRead += vRead2; 1092 } 1093 return vRead > 0; 1045 1094 } 1046 1095 }
Note: See TracChangeset
for help on using the changeset viewer.