Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2005, 4:32:29 PM (18 years ago)
Author:
hdavid
Message:

branches\avi_play: textures are displayed fast but not right

File:
1 edited

Legend:

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

    r6127 r6149  
    5252MediaContainer::~MediaContainer()
    5353{
     54
    5455  // Free the RGB image
    5556  delete [] buffer;
     
    7273}
    7374
    74 GLuint MediaContainer::getNextFrame()
     75SDL_Surface * MediaContainer::getNextFrame()
    7576{
    7677  /* get next frame */
     
    9192        PRINTF(1)("frame_number: %i\n", codec_context->frame_number);
    9293
    93         // Convert the image from its native format to RGB
     94        // Conversion from YUV to RGB
     95        // Most codecs return images in YUV 420 format
     96        // (one luminance and two chrominance channels, with the chrominance
     97        // channels samples at half the spatial resolution of the luminance channel)
    9498        img_convert((AVPicture*)RGB_frame, PIX_FMT_RGB24, (AVPicture*)frame, codec_context->pix_fmt,
    9599                                        codec_context->width, codec_context->height);
     
    101105        data = new uint8_t[codec_context->width*codec_context->height*3*sizeof(uint8_t)];
    102106        for(int i = 0; i < codec_context->height; i++)
    103           memcpy(&data[i*codec_context->width*3],
    104                  picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3);
    105 
    106 
    107         glGenTextures(1, &texture);
     107          memcpy(&data[i*codec_context->width*3], picture->data[0]+i * picture->linesize[0],codec_context->width*sizeof(uint8_t)*3);
     108
     109Uint32 rmask, gmask, bmask, amask;
     110
     111    /* SDL interprets each pixel as a 32-bit number, so our masks must depend
     112       on the endianness (byte order) of the machine */
     113#if SDL_BYTEORDER == SDL_BIG_ENDIAN
     114    rmask = 0xff000000;
     115    gmask = 0x00ff0000;
     116    bmask = 0x0000ff00;
     117    amask = 0x000000ff;
     118#else
     119    rmask = 0x000000ff;
     120    gmask = 0x0000ff00;
     121    bmask = 0x00ff0000;
     122    amask = 0xff000000;
     123#endif
     124surface = SDL_CreateRGBSurfaceFrom(data, codec_context->width, codec_context->height,
     125                                   32, codec_context->width*sizeof(uint8_t)*3, rmask, gmask, bmask, 0);
     126
     127return surface;
     128        /*glGenTextures(1, &texture);
    108129        glBindTexture(GL_TEXTURE_2D, texture);
    109130        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     
    113134        //{
    114135          // build the texture
    115         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
     136        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, codec_context->width, codec_context->height, 0, GL_RGB, GL_UNSIGNED_BYTE, picture->data);
    116137        //}
    117138        // if its not the first use glTexSubImage2D <-- faster then creating always a new texture
     
    120141
    121142
    122         glBindTexture(GL_TEXTURE_2D, 0);
     143        glBindTexture(GL_TEXTURE_2D, 0);*/
    123144        //////////////////////////////////////////////
    124145        /////////////////////////////////////////////
     
    127148        //this->saveCurrentFrame();
    128149
    129         return texture;
     150        //return texture;
    130151      }
    131152    }
     
    285306  PRINTF(1)("========================\n");
    286307}
    287 
    288 
    289 //pts = av_q2d(is->video_st->time_base)*pkt->dts;
    290 //pkt = packet
    291 //avstrream = viedo_st
    292 //pts = double
Note: See TracChangeset for help on using the changeset viewer.