12 messages in net.java.dev.jna.usersRe: [jna-users] Getting pointers from...
FromSent OnAttachments
Douglas AdlerAug 20, 2008 12:03 pm 
Timothy WallAug 20, 2008 12:55 pm 
Wayne MeissnerAug 20, 2008 6:37 pm 
Douglas AdlerAug 21, 2008 11:56 am 
Timothy WallAug 21, 2008 12:18 pm 
Wayne MeissnerAug 21, 2008 3:47 pm 
Wayne MeissnerAug 21, 2008 3:55 pm 
Timothy WallAug 22, 2008 7:41 am 
Wayne MeissnerAug 22, 2008 3:57 pm 
Timothy WallAug 22, 2008 4:04 pm 
Wayne MeissnerAug 22, 2008 4:39 pm 
Scott PalmerAug 22, 2008 6:47 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Getting pointers from javaActions...
From:Wayne Meissner (wmei@gmail.com)
Date:Aug 21, 2008 3:47:17 pm
List:net.java.dev.jna.users

2008/8/22 Douglas Adler <dad@tripleplayint.com>:

2008/8/21 Wayne Meissner [wmei@gmail.com]:

if (ptr != null) { ptr.read(0, vidBuffer, 0, vidWidth * vidHeight); renderImage.setRGB(0, 0, vidWidth, vidHeight, vidBuffer, 0, vidWidth); g2d.drawImage(renderImage, 0, 0, width, height, null); }

You can avoid one copy above with: int[] pixels = ((DataBufferInt) renderImage.getRaster().getDataBuffer()).getData(); ptr.read(0, pixels, 0, vidWidth * vidHeight);

That only works on BufferedImage.TYPE_INT_RGB, but thats what one would normally allocate as a backing buffer anyway.

You can also get some speed on some platforms when scaling the final image by painting that heap buffer into a volatile buffer, then scaling the volatile buffer into the swing buffer (ie. the Graphics passed into paintComponent).

http://trac-hg.assembla.com/gstreamer-java/browser/src/org/gstreamer/swing/VideoComponent.java contains some comments on wringing out video rendering performance on swing.

I am still trying to figure out how to use the directly allocated buffer as the backing store for a raster, but I can't see the path yet. This would remove the need for the at least one of the copies.

As far as I know, there is no way to use a direct ByteBuffer as the source for a Raster - its just not supported by swing.

If you can get the number of superfluous copies down to one (decode to native buffer, copy native buffer to BufferedImage), declare victory and move on. There have been many discussions on teh interwebs about it, and it just isn't possible to do zero-copy decoding -> BufferedImage. At least not yet.