framerate is float

This commit is contained in:
honfika@gmail.com
2015-08-12 14:22:04 +02:00
parent 427e7ea70d
commit 809091ea42
16 changed files with 99 additions and 69 deletions

View File

@@ -295,7 +295,6 @@ public class SWFOutputStream extends OutputStream {
public void writeFIXED(double value) throws IOException {
long valueLong = (long) (value * (1 << 16));
int beforePoint = (int) valueLong >> 16;
int afterPoint = (int) valueLong % (1 << 16);
writeUI16(afterPoint);
writeUI16(beforePoint);
@@ -308,10 +307,11 @@ public class SWFOutputStream extends OutputStream {
* @throws IOException
*/
public void writeFIXED8(float value) throws IOException {
int beforePoint = (int) getIntPart(value);
int afterPoint = (int) getIntPart((value + (value < 0 ? beforePoint : -beforePoint)) * 256);
final int divisor = 1 << 8;
int beforePoint = (int) value;
int afterPoint = Math.abs((int) (value * divisor)) % divisor;
writeUI8(afterPoint);
writeUI8(beforePoint);
writeSI8(beforePoint);
}
private void writeLong(long value) throws IOException {
@@ -578,13 +578,6 @@ public class SWFOutputStream extends OutputStream {
return nBits;
}
private static long getIntPart(double value) {
if (value < 0) {
return (long) Math.ceil(value);
}
return (long) Math.floor(value);
}
public static int unsignedSize(final int value) {
final int val = (value < 0) ? -value - 1 : value;