Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
wrandelshofer committed Mar 5, 2023
2 parents 5526162 + e75a4ea commit 9fcf160
Show file tree
Hide file tree
Showing 14 changed files with 315 additions and 285 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static void main(String[] args) {
test(new File("avidemo-raw8.avi"), new Format(EncodingKey, ENCODING_AVI_DIB, DepthKey, 8));
test(new File("avidemo-rle8.avi"), new Format(EncodingKey, ENCODING_AVI_RLE8, DepthKey, 8));
test(new File("avidemo-tscc8.avi"), new Format(EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 8));
test(new File("avidemo-tscc16.avi"), new Format(EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 16));
test(new File("avidemo-raw8gray.avi"), new Format(EncodingKey, ENCODING_AVI_DIB, DepthKey, 8, PixelFormatKey, PixelFormat.GRAY));
test(new File("avidemo-rle8gray.avi"), new Format(EncodingKey, ENCODING_AVI_RLE8, DepthKey, 8, PixelFormatKey, PixelFormat.GRAY));
test(new File("avidemo-tscc8gray.avi"), new Format(EncodingKey, ENCODING_AVI_TECHSMITH_SCREEN_CAPTURE, DepthKey, 8, PixelFormatKey, PixelFormat.GRAY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
import java.util.Random;

/**
* Main.
* Demonstrates how to use the Monte Media {@link TSCCCodec}
* with the Java Media Framework (JMF).
*
* @author Werner Randelshofer
*/
Expand Down Expand Up @@ -213,7 +214,9 @@ public void run() {
private void generateVideos(String path) {
try {
doGenerateVideo(new File(path, "avidemo-tscc8.avi"), new AviVideoFormat("tscc", null, Format.NOT_SPECIFIED, null, 30f, Format.NOT_SPECIFIED, 8, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, null));
} catch (IOException | NoProcessorException | NoDataSinkException e) {
//doGenerateVideo(new File(path, "avidemo-tscc16.avi"), new AviVideoFormat("tscc", null, Format.NOT_SPECIFIED, null, 30f, Format.NOT_SPECIFIED, 16, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, null));
doGenerateVideo(new File(path, "avidemo-tscc24.avi"), new AviVideoFormat("tscc", null, Format.NOT_SPECIFIED, null, 30f, Format.NOT_SPECIFIED, 24, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, Format.NOT_SPECIFIED, null));
} catch (Throwable e) {
e.printStackTrace();
}
}
Expand Down Expand Up @@ -270,6 +273,7 @@ private static void doGenerateVideo(File file, AviVideoFormat format) throws IOE
p.close();
sink.close();
}
System.out.println("* Wrote " + file);
}

private static class ImageStream implements PullBufferStream {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package org.monte.media.iff;

import org.monte.media.io.ByteArray;

import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
Expand All @@ -21,7 +23,8 @@
public class MC68000InputStream
extends FilterInputStream {

private long scan_, mark_;
private long scan, mark;
private byte byteBuffer[] = new byte[8];

/**
* Creates a new instance.
Expand All @@ -42,7 +45,7 @@ public int readUBYTE()
if (b0 == -1) {
throw new EOFException();
}
scan_ += 1;
scan += 1;

return b0 & 0xff;
}
Expand All @@ -53,14 +56,8 @@ public int readUBYTE()
*/
public short readWORD()
throws IOException {
int b0 = in.read();
int b1 = in.read();
if (b1 == -1) {
throw new EOFException();
}
scan_ += 2;

return (short) (((b0 & 0xff) << 8) | (b1 & 0xff));
readFully(byteBuffer, 0, 2);
return ByteArray.getShortBE(byteBuffer, 0);
}

/**
Expand All @@ -78,19 +75,8 @@ public int readUWORD()
*/
public int readLONG()
throws IOException {
int b0 = in.read();
int b1 = in.read();
int b2 = in.read();
int b3 = in.read();
if (b3 == -1) {
throw new EOFException();
}
scan_ += 4;

return ((b0 & 0xff) << 24)
| ((b1 & 0xff) << 16)
| ((b2 & 0xff) << 8)
| (b3 & 0xff);
readFully(byteBuffer, 0, 4);
return ByteArray.getIntBE(byteBuffer, 0);
}

/**
Expand All @@ -99,27 +85,8 @@ public int readLONG()
*/
public long readINT64()
throws IOException {
int b0 = in.read();
int b1 = in.read();
int b2 = in.read();
int b3 = in.read();
int b4 = in.read();
int b5 = in.read();
int b6 = in.read();
int b7 = in.read();
if (b7 == -1) {
throw new EOFException();
}
scan_ += 4;

return ((b0 & 0xffL) << 56)
| ((b1 & 0xffL) << 48)
| ((b2 & 0xffL) << 40)
| ((b3 & 0xffL) << 32)
| ((b4 & 0xffL) << 24)
| ((b5 & 0xffL) << 16)
| ((b6 & 0xffL) << 8)
| (b7 & 0xffL);
readFully(byteBuffer, 0, 8);
return ByteArray.getLongBE(byteBuffer, 0);
}

/**
Expand All @@ -137,7 +104,7 @@ public long readULONG()
*/
public void align()
throws IOException {
if (scan_ % 2 == 1) {
if (scan % 2 == 1) {
skipFully(1);
}
}
Expand All @@ -147,7 +114,7 @@ public void align()
* stream filter).
*/
public long getScan() {
return scan_;
return scan;
}

/**
Expand All @@ -156,7 +123,7 @@ public long getScan() {
public int read()
throws IOException {
int data = in.read();
scan_++;
scan++;
return data;
}

Expand All @@ -172,7 +139,7 @@ public void readFully(byte[] b, int offset, int length)
throw new EOFException();
}
count += current;
scan_ += current;
scan += current;
}
}

Expand All @@ -183,7 +150,7 @@ public int read(byte[] b, int offset, int length)
throws IOException {
int count = in.read(b, offset, length);
if (count > 0) {
scan_ += count;
scan += count;
}
return count;
}
Expand All @@ -196,7 +163,7 @@ public int read(byte[] b, int offset, int length)
*/
public void mark(int readlimit) {
in.mark(readlimit);
mark_ = scan_;
mark = scan;
}

/**
Expand All @@ -208,7 +175,7 @@ public void mark(int readlimit) {
public void reset()
throws IOException {
in.reset();
scan_ = mark_;
scan = mark;
}

/**
Expand All @@ -218,7 +185,7 @@ public void reset()
public long skip(long n)
throws IOException {
long skipped = in.skip(n);
scan_ += skipped;
scan += skipped;
return skipped;
}

Expand All @@ -240,7 +207,7 @@ public void skipFully(long n)
if (cur == 0) {
throw new EOFException();
}
scan_ += total;
scan += total;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package org.monte.media.iff;

import org.monte.media.io.ByteArray;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -20,6 +22,7 @@ public class MC68000OutputStream extends FilterOutputStream {
* If this counter overflows, it will be wrapped to Integer.MAX_VALUE.
*/
protected long written;
private byte byteBuffer[] = new byte[8];

/**
* Creates a new instance.
Expand All @@ -29,35 +32,31 @@ public MC68000OutputStream(OutputStream out) {
}

public void writeLONG(int v) throws IOException {
out.write((v >>> 24) & 0xFF);
out.write((v >>> 16) & 0xFF);
out.write((v >>> 8) & 0xFF);
out.write((v >>> 0) & 0xFF);
ByteArray.setIntBE(byteBuffer, 0, v);
out.write(byteBuffer, 0, 4);
incCount(4);
}

public void writeULONG(long v) throws IOException {
out.write((int) ((v >>> 24) & 0xFF));
out.write((int) ((v >>> 16) & 0xFF));
out.write((int) ((v >>> 8) & 0xFF));
out.write((int) ((v >>> 0) & 0xFF));
ByteArray.setIntBE(byteBuffer, 0, (int) v);
out.write(byteBuffer, 0, 4);
incCount(4);
}

public void writeWORD(int v) throws IOException {
out.write((v >>> 8) & 0xFF);
out.write((v >>> 0) & 0xFF);
ByteArray.setShortBE(byteBuffer, 0, (short) v);
out.write(byteBuffer, 0, 2);
incCount(2);
}

public void writeUWORD(int v) throws IOException {
out.write((v >>> 8) & 0xFF);
out.write((v >>> 0) & 0xFF);
ByteArray.setShortBE(byteBuffer, 0, (short) v);
out.write(byteBuffer, 0, 2);
incCount(2);
}

public void writeUBYTE(int v) throws IOException {
out.write((v >>> 0) & 0xFF);
out.write(v & 0xFF);
incCount(1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,10 @@ protected void copyMetaTo(Buffer in, Buffer out) {
}

protected int encode(Buffer in, Buffer out) {
copyMetaTo(in, out);
if (in.isDiscard()) {
out.setDiscard(true);
return BUFFER_PROCESSED_OK;
}
copyMetaTo(in, out);
out.setFormat(outputFormat);

SeekableByteArrayOutputStream tmp;
Expand Down
Loading

0 comments on commit 9fcf160

Please sign in to comment.