Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6127 in orxonox.OLD for branches/avi_play/src


Ignore:
Timestamp:
Dec 15, 2005, 11:54:48 PM (19 years ago)
Author:
hdavid
Message:

branches/avi_play: MediaContainer::getFPS() works

Location:
branches/avi_play/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/lib/graphics/importer/media_container.cc

    r6112 r6127  
    4040  av_register_all();
    4141
    42   current_frame = 0;
     42  fps = 0;
    4343
    4444  if (filename != NULL)
     
    8989      if(frame_finished)
    9090      {
    91         current_frame++;
    92         PRINTF(1)("current_frame: %i\n", current_frame);
    93 
    94                     // Convert the image from its native format to RGB
     91        PRINTF(1)("frame_number: %i\n", codec_context->frame_number);
     92
     93        // Convert the image from its native format to RGB
    9594        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, codec_context->pix_fmt,
    9695                                        codec_context->width, codec_context->height);
     
    145144
    146145  // Open file
    147   sprintf(filename, "frame%i.ppm", current_frame);
     146  sprintf(filename, "frame%i.ppm", codec_context->frame_number);
    148147  file = fopen(filename, "wb");
    149148  if(file == NULL)
     
    215214  avpicture_fill((AVPicture *)RGB_frame, buffer, PIX_FMT_RGB24, codec_context->width, codec_context->height);
    216215
     216  // Calculate fps
     217  fps = av_q2d(format_context->streams[video_stream]->r_frame_rate);
    217218}
    218219
     
    227228}
    228229
    229 int MediaContainer::getCurrentFrame()
    230 {
    231   return this->current_frame;
    232 }
    233 
    234 int MediaContainer::getFrameRate()
    235 {
    236 
    237 }
    238 
    239 void MediaContainer::getStream(/* stream */)
    240 {
    241 
     230int MediaContainer::getFrameNumber()
     231{
     232  return codec_context->frame_number;
     233}
     234
     235double MediaContainer::getFPS()
     236{
     237  return this->fps;
    242238}
    243239
     
    258254  PRINTF(1)("nb_frames: %i\n", format_context->streams[video_stream]->nb_frames);
    259255  PRINTF(1)("r_frame_rate: %i\n", format_context->streams[video_stream]->r_frame_rate.num);
     256  PRINTF(1)("FPS: %f\n", av_q2d(format_context->streams[video_stream]->r_frame_rate));
    260257  PRINTF(1)("========================\n");
    261258  PRINTF(1)("=    AVCodecContext    =\n");
     
    263260  PRINTF(1)("width: %i\n", codec_context->width);
    264261  PRINTF(1)("height: %i\n", codec_context->height);
     262  PRINTF(1)("time_base.den: %i\n", codec_context->time_base.den);
     263  PRINTF(1)("time_base.num: %i\n", codec_context->time_base.num);
    265264  PRINTF(1)("========================\n");
    266265  PRINTF(1)("=       AVCodec        =\n");
     
    286285  PRINTF(1)("========================\n");
    287286}
     287
     288
     289//pts = av_q2d(is->video_st->time_base)*pkt->dts;
     290//pkt = packet
     291//avstrream = viedo_st
     292//pts = double
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6112 r6127  
    2929private:
    3030
    31   int current_frame;
    32   int num_frames;
     31  double fps;
    3332  GLuint texture;
    3433  uint8_t* data;
     
    5756  int getHeight();
    5857  int getWidth();
    59   int getCurrentFrame();
    60   int getFrameRate();
    61   void getStream(/* stream */);
     58  int getFrameNumber();
     59  double getFPS();
    6260
    6361  /* prints some information about the
  • branches/avi_play/src/subprojects/importer/importer.cc

    r6094 r6127  
    6060void Framework::moduleTick(float dt)
    6161{
    62   while(movie->getNextFrame() != NULL)
    63     movie->saveCurrentFrame(); 
     62  //while(movie->getNextFrame() != NULL);
     63  //  movie->saveCurrentFrame();       
    6464}
    6565
  • branches/avi_play/src/subprojects/importer/multitex.cc

    r6112 r6127  
    3737MediaContainer* movie;
    3838
    39 int counter = 0;
     39float counter = 0;
    4040
    4141
    4242void Framework::moduleInit(int argc, char** argv)
    4343{
    44   movie = new MediaContainer("/home/lieni/Desktop/Face2.avi");
     44  movie = new MediaContainer("/home/david/Desktop/Face2.avi");
    4545
    4646  // print information about the media file
     
    5252
    5353  seq = new TextureSequence();
    54   //for (int i = 1; i < argc; i++)
    55   //{
    56   //  seq->addFrame(argv[i]);
    57   //  printf("%s\n", argv[i]);
    58   //}
     54  for (int i = 1; i < argc; i++)
     55  {
     56    seq->addFrame(argv[i]);
     57    printf("%s\n", argv[i]);
     58  }
    5959
    6060  // add one frame from the movie
    61   //seq->addFrame(movie->getNextFrame());
     61  seq->addFrame(movie->getNextFrame());
    6262  GLuint tex;
    63   while((tex = movie->getNextFrame()) != NULL)
    64     seq->addFrame(tex);
     63  //while((tex = movie->getNextFrame()) != NULL)
     64  //  seq->addFrame(tex);
    6565
    6666  test = new Texture(argv[1]);
     
    102102void Framework::moduleTick(float dt)
    103103{
    104   counter++;
     104  counter += dt;
    105105
    106   seq->gotoFrame(counter);
     106  seq->gotoFrame((unsigned int)counter);
    107107
    108   if (counter > seq->getFrameCount())
     108  if ((unsigned int)counter > seq->getFrameCount())
    109109    counter = 0;
    110110
Note: See TracChangeset for help on using the changeset viewer.