Show
Ignore:
Timestamp:
03/04/09 12:05:55 (4 years ago)
Author:
robert
Message:

Added support for using libswscale

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp

    r9837 r9854  
    66#include <string.h> 
    77 
     8#if 0 
    89extern "C"  
    910{ 
     
    1213 
    1314}; 
     15#endif 
    1416 
    1517namespace osgFFmpeg { 
     
    2830    m_user_data(0), 
    2931    m_publish_func(0), 
    30     m_exit(false) 
     32    m_exit(false), 
     33    m_swscale_ctx(0) 
    3134{ 
    3235 
     
    4144        m_exit = true; 
    4245        join(); 
     46    } 
     47     
     48    if (m_swscale_ctx) 
     49    { 
     50        sws_freeContext(m_swscale_ctx); 
     51        m_swscale_ctx = 0; 
    4352    } 
    4453} 
     
    211220} 
    212221 
     222int FFmpegDecoderVideo::convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src, 
     223            int src_pix_fmt, int src_width, int src_height) 
     224{ 
     225#ifdef USE_SWSCALE 
     226    if (m_swscale_ctx==0) 
     227    { 
     228        m_swscale_ctx = sws_getContext(src_width, src_height, src_pix_fmt, 
     229                                      src_width, src_height, dst_pix_fmt,                                     
     230                                      SWS_BILINEAR, NULL, NULL, NULL); 
     231    } 
     232     
     233    return sws_scale(m_swscale_ctx, 
     234           src->data, src->linesize, 0, src_height, 
     235           dst->data, dst->linesize); 
     236#else 
     237    return convert(dst, dst_pix_fmt, src, 
     238                   src_pix_fmt, src_width, src_height) 
     239#endif 
     240} 
    213241 
    214242 
     
    231259        yuva420pToRgba(dst, src, width(), height()); 
    232260    else 
    233         img_convert(dst, PIX_FMT_RGB32, src, m_context->pix_fmt, width(), height()); 
     261        convert(dst, PIX_FMT_RGB32, src, m_context->pix_fmt, width(), height()); 
    234262 
    235263    // Flip and swap buffer 
     
    267295void FFmpegDecoderVideo::yuva420pToRgba(AVPicture * const dst, const AVPicture * const src, int width, int height) 
    268296{ 
    269     img_convert(dst, PIX_FMT_RGB32, src, m_context->pix_fmt, width, height); 
     297    convert(dst, PIX_FMT_RGB32, src, m_context->pix_fmt, width, height); 
    270298 
    271299    const size_t bpp = 4;