Changeset 9910

Show
Ignore:
Timestamp:
03/11/09 16:12:46 (6 years ago)
Author:
robert
Message:

From Tanguy Fautre,

Clean up of the FFmpeg plugin's class API/AudioStream API.
Implementation of isImageTransparent().
Implementation of Image:g/setPixelAspectRatio()

Location:
OpenSceneGraph/trunk
Files:
11 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osg/AudioStream

    r9847 r9910  
    6060        virtual void consumeAudioBuffer(void * const buffer, const size_t size) = 0; 
    6161         
    62         virtual bool audioStream() const = 0; 
    6362        virtual int audioFrequency() const = 0; 
    6463        virtual int audioNbChannels() const = 0; 
  • OpenSceneGraph/trunk/include/osg/Image

    r9888 r9910  
    186186        void setPacking(unsigned int packing) { _packing = packing; } 
    187187        inline unsigned int getPacking() const { return _packing; } 
     188 
     189        inline void setPixelAspectRatio(float pixelAspectRatio) { _pixelAspectRatio = pixelAspectRatio; } 
     190        inline float getPixelAspectRatio() const { return _pixelAspectRatio; } 
    188191         
    189192        /** Return the number of bits required for each pixel. */ 
     
    347350        GLenum _dataType; 
    348351        unsigned int _packing; 
     352        float _pixelAspectRatio; 
    349353 
    350354        AllocationMode _allocationMode; 
  • OpenSceneGraph/trunk/include/osg/ImageStream

    r9827 r9910  
    7979 
    8080        virtual double getLength() const { return 0.0; } 
    81          
     81        virtual double getFrameRate() const { return 0.0; }  
     82 
    8283        virtual void setReferenceTime(double) {} 
    8384        virtual double getReferenceTime() const { return 0.0; } 
     
    8889        virtual void setVolume(float) {} 
    8990        virtual float getVolume() const { return 0.0f; } 
    90  
    9191 
    9292        typedef std::vector< osg::ref_ptr<osg::AudioStream> > AudioStreams; 
  • OpenSceneGraph/trunk/src/osg/Image.cpp

    r9682 r9910  
    3434 
    3535Image::Image() 
    36     :Object(true) 
     36    :Object(true), 
     37    _fileName(""), 
     38    _writeHint(NO_PREFERENCE), 
     39    _origin(BOTTOM_LEFT), 
     40    _s(0), _t(0), _r(0), 
     41    _internalTextureFormat(0), 
     42    _pixelFormat(0), 
     43    _dataType(0), 
     44    _packing(4), 
     45    _pixelAspectRatio(1.0), 
     46    _allocationMode(USE_NEW_DELETE), 
     47    _data(0L), 
     48    _modifiedCount(0) 
    3749{ 
    3850    setDataVariance(STATIC);  
    39  
    40     _fileName               = ""; 
    41     _writeHint              = NO_PREFERENCE; 
    42     _origin                 = BOTTOM_LEFT; 
    43     _s = _t = _r            = 0; 
    44     _internalTextureFormat  = 0; 
    45     _pixelFormat            = (unsigned int)0; 
    46     _dataType               = (unsigned int)0; 
    47     _packing                = 4; 
    48  
    49     _allocationMode         = USE_NEW_DELETE; 
    50     _data                   = (unsigned char *)0L; 
    51  
    52     _modifiedCount = 0; 
    5351} 
    5452 
     
    6361    _dataType(image._dataType), 
    6462    _packing(image._packing), 
     63    _pixelAspectRatio(image._pixelAspectRatio), 
    6564    _data(0L), 
    6665    _modifiedCount(image._modifiedCount), 
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegAudioStream.cpp

    r9850 r9910  
    5252 
    5353 
    54 bool FFmpegAudioStream::audioStream() const  
    55 {  
    56     return m_decoder->audio_decoder().validContext();  
    57 } 
    58  
    59  
    6054 
    6155int FFmpegAudioStream::audioFrequency() const  
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegAudioStream.hpp

    r9847 r9910  
    2222        void consumeAudioBuffer(void * const buffer, const size_t size); 
    2323         
    24         bool audioStream() const; 
    2524        int audioFrequency() const; 
    2625        int audioNbChannels() const; 
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderAudio.cpp

    r9869 r9910  
    131131void FFmpegDecoderAudio::fillBuffer(void * const buffer, size_t size) 
    132132{ 
    133     size_t filled = 0; 
    134133    uint8_t * dst_buffer = reinterpret_cast<uint8_t*>(buffer); 
    135134 
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.cpp

    r9869 r9910  
    223223void FFmpegDecoderVideo::findAspectRatio() 
    224224{ 
    225     double ratio = 0.0; 
     225    float ratio = 0.0f; 
    226226 
    227227    if (m_context->sample_aspect_ratio.num != 0) 
    228         ratio = (av_q2d(m_context->sample_aspect_ratio) * m_width) / m_height; 
    229  
    230     if (ratio <= 0.0) 
    231         ratio = double(m_width) / double(m_height); 
    232  
    233     m_aspect_ratio = ratio; 
     228        ratio = float(av_q2d(m_context->sample_aspect_ratio)); 
     229 
     230    if (ratio <= 0.0f) 
     231        ratio = 1.0f; 
     232 
     233    m_pixel_aspect_ratio = ratio; 
    234234} 
    235235 
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegDecoderVideo.hpp

    r9869 r9910  
    7575    int width() const; 
    7676    int height() const; 
    77     double aspectRatio() const; 
     77    float pixelAspectRatio() const; 
    7878    bool alphaChannel() const; 
    7979    double frameRate() const; 
     
    115115 
    116116    double                  m_frame_rate; 
    117     double                  m_aspect_ratio; 
     117    float                   m_pixel_aspect_ratio; 
    118118    int                     m_width; 
    119119    int                     m_height; 
     
    156156 
    157157 
    158 inline double FFmpegDecoderVideo::aspectRatio() const 
     158inline float FFmpegDecoderVideo::pixelAspectRatio() const 
    159159{ 
    160     return m_aspect_ratio; 
     160    return m_pixel_aspect_ratio; 
    161161} 
    162162 
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp

    r9869 r9910  
    1919    m_frame_published_flag(false) 
    2020{ 
    21     setOrigin(osg::Image::BOTTOM_LEFT); 
     21    setOrigin(osg::Image::TOP_LEFT); 
    2222 
    2323    std::auto_ptr<FFmpegDecoder> decoder(new FFmpegDecoder); 
     
    7272        const_cast<unsigned char *>(m_decoder->video_decoder().image()), NO_DELETE 
    7373    ); 
    74      
    75     setOrigin(osg::Image::TOP_LEFT); 
    76  
     74 
     75    setPixelAspectRatio(m_decoder->video_decoder().pixelAspectRatio()); 
     76     
    7777    m_decoder->video_decoder().setUserData(this); 
    7878    m_decoder->video_decoder().setPublishCallback(publishNewFrame); 
     
    141141 
    142142 
    143 double FFmpegImageStream::duration() const 
     143double FFmpegImageStream::getLength() const 
    144144{  
    145145    return m_decoder->duration();  
     
    148148 
    149149 
    150 bool FFmpegImageStream::videoAlphaChannel() const  
     150double FFmpegImageStream::getFrameRate() const 
     151{  
     152    return m_decoder->video_decoder().frameRate();  
     153} 
     154 
     155 
     156 
     157bool FFmpegImageStream::isImageTranslucent() const  
    151158{  
    152159    return m_decoder->video_decoder().alphaChannel();  
    153160} 
    154161 
    155  
    156  
    157 double FFmpegImageStream::videoAspectRatio() const 
    158 {  
    159     return m_decoder->video_decoder().aspectRatio(); 
    160 } 
    161  
    162  
    163  
    164 double FFmpegImageStream::videoFrameRate() const 
    165 {  
    166     return m_decoder->video_decoder().frameRate();  
    167 } 
    168162 
    169163 
  • OpenSceneGraph/trunk/src/osgPlugins/ffmpeg/FFmpegImageStream.hpp

    r9847 r9910  
    3333        virtual void quit(bool waitForThreadToExit = true); 
    3434 
    35         double duration() const; 
     35        virtual double getLength() const; 
     36        virtual double getFrameRate() const; 
    3637 
    37         bool videoAlphaChannel() const; 
    38         double videoAspectRatio() const; 
    39         double videoFrameRate() const; 
    40  
     38        virtual bool isImageTranslucent() const; 
    4139 
    4240    private: