static Hashtable imageTable = new Hashtable();
protected int processJPEGtoRGB(Buffer input,Buffer output) {
synchronized(imageTable) {
try {
VideoFormat inputFormat = (VideoFormat)input.getFormat();
RGBFormat outputFormat = (RGBFormat)output.getFormat();
if(outputFormat==null) {
int width = inputFormat.getSize().width;
int height = inputFormat.getSize().height;
outputFormat = new RGBFormat(
new Dimension(width,height),
width*height,
Format.intArray,
inputFormat.getFrameRate(), 32,
0xff0000, 0xff00, 0xff, //RGB masks
1, width, //pixel stride, line stride
RGBFormat.FALSE, RGBFormat.LITTLE_ENDIAN);
output.setFormat(outputFormat);
}
byte[] b = (byte[])input.getData();
Dimension d = inputFormat.getSize();
BufferedImage dest = (BufferedImage)imageTable.get(d);
if(dest==null) {
dest = new BufferedImage(d.width,d.height,BufferedImage.TYPE_INT_RGB);
}
readJPEG(b, dest);