I'm currently working on a new JNI wrapper for ffmpeg to play videos in Java
without using the out-dated (and buggy) JMF library. This would allow to play
virtually any audio/video file from the local file system, http, or rtp. The
SWT version is already working fine, but the Java2D-based version for Swing
does not have the needed performance. I have to display 25 frames per second
and get the data either as int[] or byte[]. Any of a rather large number of
palettes can be choosen within ffmpeg and scaling is also already done. In
Java2D, I allocate a new image before the first frame is shown:
int[] data = new int[width * height];
DataBufferInt dataBuffer = new DataBufferInt(data, data.length);
DirectColorModel colorModel = new DirectColorModel(24, rMask, ...);
SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, width,
height, new int[] { rMask, gMask, bMask });
WritableRaster wr = Raster.createWritableRaster(sm, dataBuffer, new Point(0,
0));
image = new BufferedImage(colorModel, wr, true, null);
Afterwards I just fill the data array with the new data and call
g2d.drawImage(image, 0, 0, null);
However, drawImage(..) takes about 15 to 30ms for a frame of size 608x336.
Doing it almost the same way in SWT with an ImageData object takes only 0.5ms.
Is there a way to improve performance? Or do I have to use either DirectX or
OpenGL?
It would be nice if it is compatible with JXPanel to support, for example,
overlays. Moreover, as far as I have seen there is no NIO support in Java2D?
Because this way I could get the data from ffmpeg without having to copy
anything.
Thanks, Remo
[Message sent by forum member 'remmeier' (remmeier)]
http://forums.java.net/jive/thread.jspa?messageID=215811
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".