public class AnimationCodec extends AbstractVideoCodec
Supports lossless delta- and key-frame encoding of images onlyWith 8, 16 or 24 bits per pixel.
The QuickTime player requires that a keyframe is written once per second. This codec enforces this.
An encoded frame has the following format:
Header: uint32 chunkSize uint16 header 0x0000 => decode entire image 0x0008 => starting line and number of lines follows if header==0x0008 { uint16 startingLine at which to begin updating frame uint16 reserved 0x0000 uint16 numberOfLines to update uint16 reserved 0x0000 } n-bytes compressed linesThe first 4 bytes defines the chunk length. This field also carries some other unknown flags, since at least one of the high bits is sometimes set.
2 bytes starting line at which to begin updating frame 2 bytes unknown 2 bytes the number of lines to update 2 bytes unknownIf the header is 0x0000, then the decode begins from the first line and continues through the entire height of the image.
1 byte skip code 1 byte RLE code n bytes pixel data 1 byte RLE code n bytes pixel dataEach line begins onlyWith a byte that defines the number of pixels to skip in a particular line in the output line before outputting new pixel data. Actually, the skip count is set to one more than the number of pixels to skip. For example, a skip byte of 15 means "skip 14 pixels", while a skip byte of 1 means "don't skip any pixels". If the skip byte is 0, then the frame decode is finished. Therefore, the maximum skip byte value of 255 allows for a maximum of 254 pixels to be skipped.
After the skip byte is the first RLE code, which is a single signed
byte. The RLE code can have the following meanings:
The pixel data has the following format:
xrrrrrgg gggbbbbb
. Pixel data is
rendered to the output frame one pixel at a time.rrrrrrrr gggggggg bbbbbbbb
. Pixel data is rendered to the output
frame one pixel at a time.aaaaaaaa rrrrrrrr gggggggg bbbbbbbb
. Pixel data is rendered to the
output frame one pixel at a time.inputFormat, inputFormats, name, outputFormat, outputFormats
CODEC_FAILED, CODEC_INPUT_NOT_CONSUMED, CODEC_OK, CODEC_OUTPUT_NOT_FILLED
Constructor and Description |
---|
AnimationCodec() |
Modifier and Type | Method and Description |
---|---|
void |
decodeDelta16(javax.imageio.stream.ImageInputStream in,
short[] data,
short[] prev,
int width,
int height,
int offset,
int scanlineStride)
Decodes a 16-bit delta frame.
|
void |
encodeDelta16(javax.imageio.stream.ImageOutputStream out,
short[] data,
short[] prev,
int width,
int height,
int offset,
int scanlineStride)
Encodes a 16-bit delta frame.
|
void |
encodeDelta24(javax.imageio.stream.ImageOutputStream out,
int[] data,
int[] prev,
int width,
int height,
int offset,
int scanlineStride)
Encodes a 24-bit delta frame.
|
void |
encodeDelta32(javax.imageio.stream.ImageOutputStream out,
int[] data,
int[] prev,
int width,
int height,
int offset,
int scanlineStride)
Encodes a 32-bit delta frame.
|
void |
encodeDelta8(javax.imageio.stream.ImageOutputStream out,
byte[] data,
byte[] prev,
int width,
int height,
int offset,
int scanlineStride)
Encodes an 8-bit delta frame.
|
void |
encodeKey16(javax.imageio.stream.ImageOutputStream out,
short[] data,
int width,
int height,
int offset,
int scanlineStride)
Encodes a 16-bit key frame.
|
void |
encodeKey24(javax.imageio.stream.ImageOutputStream out,
int[] data,
int width,
int height,
int offset,
int scanlineStride)
Encodes a 24-bit key frame.
|
void |
encodeKey32(javax.imageio.stream.ImageOutputStream out,
int[] data,
int width,
int height,
int offset,
int scanlineStride)
Encodes a 32-bit key frame.
|
void |
encodeKey8(javax.imageio.stream.ImageOutputStream out,
byte[] data,
int width,
int height,
int offset,
int scanlineStride)
Encodes an 8-bit key frame.
|
int |
process(Buffer in,
Buffer out)
Performs the media processing defined by this codec.
|
void |
reset()
Empty implementation of the reset method.
|
Format |
setOutputFormat(Format f)
Sets the output format.
|
copyImage, getARGB32, getBufferedImage, getIndexed8, getRGB15, getRGB16, getRGB24, writeInt24, writeInt24LE, writeInts24, writeInts24LE
getInputFormat, getInputFormats, getName, getOutputFormat, getOutputFormats, setInputFormat, toString
public Format setOutputFormat(Format f)
Codec
setOutputFormat
in interface Codec
setOutputFormat
in class AbstractCodec
public void reset()
AbstractCodec
reset
in interface Codec
reset
in class AbstractCodec
public int process(Buffer in, Buffer out)
Codec
Copies the data from the input buffer into the output buffer.
public void encodeKey8(javax.imageio.stream.ImageOutputStream out, byte[] data, int width, int height, int offset, int scanlineStride) throws java.io.IOException
out
- The output stream.data
- The image data.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException
public void encodeDelta8(javax.imageio.stream.ImageOutputStream out, byte[] data, byte[] prev, int width, int height, int offset, int scanlineStride) throws java.io.IOException
out
- The output stream.data
- The image data.prev
- The image data of the previous frame.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException
public void encodeKey16(javax.imageio.stream.ImageOutputStream out, short[] data, int width, int height, int offset, int scanlineStride) throws java.io.IOException
out
- The output stream.data
- The image data.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException
public void encodeDelta16(javax.imageio.stream.ImageOutputStream out, short[] data, short[] prev, int width, int height, int offset, int scanlineStride) throws java.io.IOException
out
- The output stream.data
- The image data.prev
- The image data of the previous frame.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException
public void encodeKey24(javax.imageio.stream.ImageOutputStream out, int[] data, int width, int height, int offset, int scanlineStride) throws java.io.IOException
out
- The output stream.data
- The image data.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException
public void encodeDelta24(javax.imageio.stream.ImageOutputStream out, int[] data, int[] prev, int width, int height, int offset, int scanlineStride) throws java.io.IOException
out
- The output stream.data
- The image data.prev
- The image data of the previous frame.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException
public void encodeKey32(javax.imageio.stream.ImageOutputStream out, int[] data, int width, int height, int offset, int scanlineStride) throws java.io.IOException
out
- The output stream.data
- The image data.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException
public void encodeDelta32(javax.imageio.stream.ImageOutputStream out, int[] data, int[] prev, int width, int height, int offset, int scanlineStride) throws java.io.IOException
out
- The output stream.data
- The image data.prev
- The image data of the previous frame.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException
public void decodeDelta16(javax.imageio.stream.ImageInputStream in, short[] data, short[] prev, int width, int height, int offset, int scanlineStride) throws java.io.IOException
in
- The input stream.data
- The image data.prev
- The image data of the previous frame. This may be the same
object as data.width
- The width of the image in data elements.height
- The height of the image in data elements.offset
- The offset to the first pixel in the data array.scanlineStride
- The number to append to offset to get to the next scanline.java.io.IOException