Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

oxp_vidl_moviefile.cxx

Go to the documentation of this file.
00001 // This is oxl/oxp/oxp_vidl_moviefile.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 
00006 #include "oxp_vidl_moviefile.h"
00007 
00008 #include <vcl_compiler.h>
00009 #include <vcl_cassert.h>
00010 
00011 #include <vidl_vil1/vidl_vil1_movie_sptr.h>
00012 #include <vidl_vil1/vidl_vil1_movie.h>
00013 #include <vidl_vil1/vidl_vil1_frame.h>
00014 #include <vidl_vil1/vidl_vil1_io.h>
00015 
00016 #ifdef VCL_WIN32
00017 #include <vidl_vil1/vidl_vil1_avicodec.h>
00018 #endif
00019 #if defined(HAS_MPEG2)
00020 #include <oxp/oxp_vidl_mpeg_codec.h>
00021 #endif
00022 
00023 struct oxp_vidl_moviefile_privates {
00024   vidl_vil1_movie_sptr m;
00025 };
00026 
00027 /////////////////////////////////////////////////////////////////////////////
00028 
00029 static bool init = false;
00030 
00031 void ensure_initialized()
00032 {
00033   if (init) return;
00034 
00035   // Register video codec
00036 #ifdef VCL_WIN32
00037   vidl_vil1_io::register_codec(new vidl_vil1_avicodec);
00038 #endif
00039 #if defined(HAS_MPEG2)
00040   vidl_vil1_io::register_codec(new oxp_vidl_mpeg_codec);
00041 #endif
00042   init = true;
00043 }
00044 
00045 /////////////////////////////////////////////////////////////////////////////
00046 
00047 
00048 oxp_vidl_moviefile::oxp_vidl_moviefile(char const* f)
00049 {
00050   ensure_initialized();
00051 
00052   p = new oxp_vidl_moviefile_privates;
00053   p->m = vidl_vil1_io::load_movie(f);
00054 }
00055 
00056 oxp_vidl_moviefile::~oxp_vidl_moviefile()
00057 {
00058   delete p;
00059 }
00060 
00061 int oxp_vidl_moviefile::GetLength()
00062 {
00063   return p->m->length();
00064 }
00065 
00066 vil1_image oxp_vidl_moviefile::GetImage(int frame)
00067 {
00068   return p->m->get_frame(frame)->get_image();
00069 }
00070 
00071 
00072 int oxp_vidl_moviefile::GetSizeX(int frame)
00073 {
00074   return p->m->get_frame(frame)->width();
00075 }
00076 
00077 int oxp_vidl_moviefile::GetSizeY(int frame)
00078 {
00079   return p->m->get_frame(frame)->height();
00080 }
00081 
00082 int oxp_vidl_moviefile::GetBitsPixel()
00083 {
00084   return p->m->get_frame(0)->get_bits_pixel();
00085 }
00086 
00087 bool oxp_vidl_moviefile::IsInterlaced()
00088 {
00089   assert(0);
00090 #if 0
00091   return p->m->interlaced != 0;
00092 #else
00093   return 0;
00094 #endif
00095 }
00096 
00097 bool oxp_vidl_moviefile::HasFrame(int frame_index)
00098 {
00099   return (0 <= frame_index) && (frame_index < GetLength());
00100 }
00101 
00102 bool oxp_vidl_moviefile::GetFrame(int frame_index, void* buffer)
00103 {
00104   vidl_vil1_frame_sptr f = p->m->get_frame(frame_index);
00105   return f->get_section(buffer, 0,0, f->width(), f->height());
00106 }
00107 
00108 bool oxp_vidl_moviefile::GetField(int /*field_index*/, void* /*buffer*/)
00109 {
00110   return false;
00111 }
00112 

Generated on Thu Jan 10 14:46:06 2008 for contrib/oxl/oxp by  doxygen 1.4.4