home *** CD-ROM | disk | FTP | other *** search
/ Geek 6 / Geek-006.iso / linux / video / xmovie-1.5.3.tar.gz / xmovie-1.5.3.tar / xmovie-1.5.3 / xmovie / test.C < prev    next >
C/C++ Source or Header  |  2000-11-29  |  2KB  |  67 lines

  1. #include "guicast.h"
  2. #include "libmpeg3.h"
  3.  
  4. #define TESTW 720
  5. #define TESTH 576
  6. #define BITMAPW 720
  7. #define BITMAPH 480
  8.  
  9. int main(int argc, char *argv[])
  10. {
  11.     mpeg3_t *file;
  12.     BC_SubWindow *canvas;
  13.     BC_Bitmap *bitmap = 0;
  14.     Timer timer;
  15.     int i, result, j;
  16.     long total_frames = 0, fps_denominator = 0, total_frames2 = 0;
  17.     double total_fps = 0;
  18.  
  19.     if(argc < 2) exit(1);
  20.  
  21.     if(!(file = mpeg3_open(argv[1]))) exit(1);
  22.     mpeg3_set_cpus(file, 1);
  23.  
  24.     BC_Window window("Test", TESTW, TESTH, TESTW, TESTH);
  25.     window.add_subwindow(canvas = new BC_SubWindow(10, 10, window.get_w() - 20, window.get_h()));
  26.     printf("YUV possible %d\n", window.accel_available(BC_YUV420_601));
  27.     canvas->start_video();
  28.     timer.update();
  29.     j = 0;
  30.     bitmap = canvas->new_bitmap(BITMAPW, BITMAPH, BC_YUV420_601);
  31.  
  32.     mpeg3_seek_percentage(file, 0.10);
  33.     do
  34.     {
  35.         if(bitmap->depth == BC_YUV420_601)
  36.             mpeg3_read_yuvframe(file,
  37.                 (char*)bitmap->get_y_plane(),
  38.                 (char*)bitmap->get_u_plane(),
  39.                 (char*)bitmap->get_v_plane(),
  40.                 0,
  41.                 0,
  42.                 bitmap->get_w(),
  43.                 bitmap->get_h(),
  44.                 0);
  45.  
  46.         canvas->draw_bitmap(bitmap, 0);
  47.  
  48.         total_frames++;
  49.         if(total_frames > 30)
  50.         {
  51.             printf("%.02f fps\n", 15000 / (double)timer.get_difference());
  52.             total_fps += 15000 / (double)timer.get_difference();
  53.             fps_denominator++;
  54.             timer.update();
  55.             total_frames = 0;
  56.         }
  57.         else
  58.             total_frames++;
  59.  
  60.         total_frames2++;
  61.     }while(!mpeg3_end_of_video(file, 0) && total_frames2 < 600);
  62.  
  63.     printf("Avg fps .02f\n", total_fps / fps_denominator);
  64.     canvas->stop_video();
  65.     mpeg3_close(file);
  66. }
  67.