title: Rendering HD video in Java Swing? Too slow?
body: <p>I would like to enable HD video playback for my Java Swing application but I am concerned about scalability and apparent lack of direct screen write access. I have a native C++ library which will do encoding and decoding (h.264) I will access this library through JNI and it will return an int[] that I will render to the screen.</p>
  
  <p>Encode/decode performance is pretty good thus far through JNI. I am concerned, however, about the rendering overhead. I would like to have multiple renderings of video open at the same time so I would like to ensure that I'm doing things in the most efficient way possible. </p>
  
  <p>Is this the most efficient way of rendering video with Java/Swing? Is there any way I can write directly to the screen and not have to go through the Java paint system?</p>
  
  <p>This is how my code looks:
  `
  public class VideoDisplay extends JLabel {</p>
  
  <pre><code>BufferedImage m_bufferedImage = null;
  
  
  public VideoDisplay(Dimension frameSize) {
      // If there is nothing to show, make sure the widget is black.
      setBackground(Color.black);
  
      m_bufferedImage = new BufferedImage(frameSize.width, frameSize.height,
              BufferedImage.TYPE_INT_ARGB);
  
      ImageIcon frameIcon = new ImageIcon(m_bufferedImage);
      setIcon(frameIcon );
  
  }
  
  public void displayNewFrame(int[] newPixels, Dimension imageSize) {
      m_bufferedImage.setRGB(0, 0, imageSize.width, imageSize.height,
              newPixels, 0, imageSize.width);
      repaint();
  
  }
  </code></pre>
  
  <p>}`</p>
  
  <p>Right now my overhead for displaying 720p video at 24FPS seems to be about 6% of CPU on a Core2 Quad 6600 CPU. </p>
  
  <p>Is there any faster way of doing this?</p>