VisClient/org/hfbk/vid/AVImageLoader.java

Go to the documentation of this file.
00001 package org.hfbk.vid;
00002 
00003 import java.nio.ByteBuffer;
00004 
00005 import net.sf.ffmpeg_java.AVFormatLibrary.AVPacket;
00006 
00007 import org.hfbk.vis.Prefs;
00008 
00009 import com.sun.jna.Native;
00010 
00023 public class AVImageLoader {
00024         
00027         final int MAXPIXELS=5000000;
00028 
00030         public ByteBuffer pixels;
00031         public int width, height;
00032         
00033         //Pointer pixelPointer; // to release memory on our own
00034         
00035         AVStreamingThread loader;
00036         
00044         public AVImageLoader(String url, boolean thumbnail) {
00045                 
00046                 loader=new AVStreamingThread(url, (thumbnail ? Prefs.current.thumbpixels: MAXPIXELS));
00047                 
00048                 AVVideoThread vt=loader.videoThread;
00049                 
00050                 if(vt==null) throw new RuntimeException("AVStillPicture: Could not open "+url);
00051                 
00052                 width =vt.width;
00053                 height=vt.height;
00054 
00055                 AVPacket packet = new AVPacket();
00056                 
00057                 while (AV.FORMAT.av_read_frame(loader.formatCtx, packet) >= 0)
00058                 {
00059                         if (packet.stream_index == loader.videoTrack){
00060                                 pixels=vt.decodeVideo(packet);
00061                         }
00062                         vt.free(packet);
00063                 }
00064                 
00065                 //pixelPointer=vt.frameRGB.data0;
00066                 vt.frameRGB.data0=null;  //release pixel data from the video engine
00067                                          //we clean up later.
00068                 vt.close();              //so we can free any ressources except the pixel data now.
00069                 loader.close();
00070         }
00071 
00074         public void free(){             
00075                 AV.UTIL.av_free(Native.getDirectBufferPointer(pixels));
00076                 pixels=null;
00077         }       
00078 }

Generated on Tue Apr 7 17:57:20 2009 for visclient by  doxygen 1.5.1