Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2005, 6:43:39 PM (18 years ago)
Author:
hdavid
Message:

branches\avi_play: added ability to get the frames in a list

File:
1 edited

Legend:

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

    r6160 r6163  
    4242  fps = 0;
    4343
    44   /* SDL interprets each pixel as a 32-bit number, so our masks must depend
    45      on the endianness (byte order) of the machine */
    46 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
    47   rmask = 0xff000000;
    48   gmask = 0x00ff0000;
    49   bmask = 0x0000ff00;
    50 #else
    51   rmask = 0x000000ff;
    52   gmask = 0x0000ff00;
    53   bmask = 0x00ff0000;
    54 #endif
    55 
    5644  if (filename != NULL)
    5745    this->loadMedia(filename);
     
    6452MediaContainer::~MediaContainer()
    6553{
     54  // delete all surfaces in the list
     55  while(!this->surface_list.empty())
     56  {
     57    SDL_FreeSurface(this->surface_list.back());
     58    this->surface_list.pop_back();
     59  }
     60  SDL_FreeSurface(surface);
    6661
    6762  // Free the RGB image
     
    9792      int frame_finished;
    9893      // Decode video frame
    99       avcodec_decode_video(codec_context, frame, &frame_finished, packet.data, packet.size);
     94      avcodec_decode_video(codec_context, frame, &frame_finished,
     95                           packet.data, packet.size);
    10096
    10197      // Did we get a video frame?
    10298      if(frame_finished)
    10399      {
    104         PRINTF(1)("frame_number: %i\n", codec_context->frame_number);
    105 
    106100        // Conversion from YUV to RGB
    107101        // Most codecs return images in YUV 420 format
    108102        // (one luminance and two chrominance channels, with the chrominance
    109103        // channels samples at half the spatial resolution of the luminance channel)
    110         img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, codec_context->pix_fmt,
    111                                         codec_context->width, codec_context->height);
     104        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame,
     105                    codec_context->pix_fmt, codec_context->width, codec_context->height);
    112106
    113107        picture = (AVPicture*)RGB_frame;
     
    119113          memcpy(&data[i*codec_context->width*3], picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3);
    120114
    121         surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, codec_context->height,
    122                                            24, codec_context->width*sizeof(uint8_t)*3, rmask, gmask, bmask, 0);
     115        surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width,
     116                                           codec_context->height,24,
     117                                           codec_context->width*sizeof(uint8_t)*3,
     118#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
     119                                           0x000000FF,
     120                                           0x0000FF00,
     121                                           0x00FF0000,
     122                                           0
     123#else
     124                                           0xFF000000,
     125                                           0x00FF0000,
     126                                           0x0000FF00,
     127                                           0
     128#endif
     129                                            );
    123130
    124131        return surface;
     
    130137  else
    131138    return NULL;
     139}
     140
     141vector<SDL_Surface*> MediaContainer::getFrameList()
     142{
     143
     144  while((surface = this->getNextFrame()) != NULL)
     145    surface_list.push_back(surface);
     146
     147  return surface_list;
    132148}
    133149
     
    200216  // Allocate video frame
    201217  frame = avcodec_alloc_frame();
    202         RGB_frame = avcodec_alloc_frame();
     218  RGB_frame = avcodec_alloc_frame();
    203219
    204220  // Determine required buffer size and allocate buffer
Note: See TracChangeset for help on using the changeset viewer.