From Tanguy Fautre,
Clean up of the FFmpeg plugin's class API/AudioStream API. Implementation of isImageTransparent(). Implementation of Image:g/setPixelAspectRatio()
This commit is contained in:
@@ -59,7 +59,6 @@ class OSG_EXPORT AudioStream : public osg::Object
|
||||
|
||||
virtual void consumeAudioBuffer(void * const buffer, const size_t size) = 0;
|
||||
|
||||
virtual bool audioStream() const = 0;
|
||||
virtual int audioFrequency() const = 0;
|
||||
virtual int audioNbChannels() const = 0;
|
||||
|
||||
|
||||
@@ -185,6 +185,9 @@ class OSG_EXPORT Image : public Object
|
||||
|
||||
void setPacking(unsigned int packing) { _packing = packing; }
|
||||
inline unsigned int getPacking() const { return _packing; }
|
||||
|
||||
inline void setPixelAspectRatio(float pixelAspectRatio) { _pixelAspectRatio = pixelAspectRatio; }
|
||||
inline float getPixelAspectRatio() const { return _pixelAspectRatio; }
|
||||
|
||||
/** Return the number of bits required for each pixel. */
|
||||
inline unsigned int getPixelSizeInBits() const { return computePixelSizeInBits(_pixelFormat,_dataType); }
|
||||
@@ -346,6 +349,7 @@ class OSG_EXPORT Image : public Object
|
||||
GLenum _pixelFormat;
|
||||
GLenum _dataType;
|
||||
unsigned int _packing;
|
||||
float _pixelAspectRatio;
|
||||
|
||||
AllocationMode _allocationMode;
|
||||
unsigned char* _data;
|
||||
|
||||
@@ -78,7 +78,8 @@ class OSG_EXPORT ImageStream : public Image
|
||||
|
||||
|
||||
virtual double getLength() const { return 0.0; }
|
||||
|
||||
virtual double getFrameRate() const { return 0.0; }
|
||||
|
||||
virtual void setReferenceTime(double) {}
|
||||
virtual double getReferenceTime() const { return 0.0; }
|
||||
|
||||
@@ -88,7 +89,6 @@ class OSG_EXPORT ImageStream : public Image
|
||||
virtual void setVolume(float) {}
|
||||
virtual float getVolume() const { return 0.0f; }
|
||||
|
||||
|
||||
typedef std::vector< osg::ref_ptr<osg::AudioStream> > AudioStreams;
|
||||
void setAudioStreams(const AudioStreams& asl) { _audioStreams = asl; }
|
||||
AudioStreams& getAudioStreams() { return _audioStreams; }
|
||||
|
||||
@@ -33,23 +33,21 @@ using namespace osg;
|
||||
using namespace std;
|
||||
|
||||
Image::Image()
|
||||
:Object(true)
|
||||
:Object(true),
|
||||
_fileName(""),
|
||||
_writeHint(NO_PREFERENCE),
|
||||
_origin(BOTTOM_LEFT),
|
||||
_s(0), _t(0), _r(0),
|
||||
_internalTextureFormat(0),
|
||||
_pixelFormat(0),
|
||||
_dataType(0),
|
||||
_packing(4),
|
||||
_pixelAspectRatio(1.0),
|
||||
_allocationMode(USE_NEW_DELETE),
|
||||
_data(0L),
|
||||
_modifiedCount(0)
|
||||
{
|
||||
setDataVariance(STATIC);
|
||||
|
||||
_fileName = "";
|
||||
_writeHint = NO_PREFERENCE;
|
||||
_origin = BOTTOM_LEFT;
|
||||
_s = _t = _r = 0;
|
||||
_internalTextureFormat = 0;
|
||||
_pixelFormat = (unsigned int)0;
|
||||
_dataType = (unsigned int)0;
|
||||
_packing = 4;
|
||||
|
||||
_allocationMode = USE_NEW_DELETE;
|
||||
_data = (unsigned char *)0L;
|
||||
|
||||
_modifiedCount = 0;
|
||||
}
|
||||
|
||||
Image::Image(const Image& image,const CopyOp& copyop):
|
||||
@@ -62,6 +60,7 @@ Image::Image(const Image& image,const CopyOp& copyop):
|
||||
_pixelFormat(image._pixelFormat),
|
||||
_dataType(image._dataType),
|
||||
_packing(image._packing),
|
||||
_pixelAspectRatio(image._pixelAspectRatio),
|
||||
_data(0L),
|
||||
_modifiedCount(image._modifiedCount),
|
||||
_mipmapData(image._mipmapData)
|
||||
|
||||
@@ -51,12 +51,6 @@ double FFmpegAudioStream::duration() const
|
||||
}
|
||||
|
||||
|
||||
bool FFmpegAudioStream::audioStream() const
|
||||
{
|
||||
return m_decoder->audio_decoder().validContext();
|
||||
}
|
||||
|
||||
|
||||
|
||||
int FFmpegAudioStream::audioFrequency() const
|
||||
{
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace osgFFmpeg
|
||||
|
||||
void consumeAudioBuffer(void * const buffer, const size_t size);
|
||||
|
||||
bool audioStream() const;
|
||||
int audioFrequency() const;
|
||||
int audioNbChannels() const;
|
||||
osg::AudioStream::SampleFormat audioSampleFormat() const;
|
||||
|
||||
@@ -130,7 +130,6 @@ void FFmpegDecoderAudio::setAudioSink(osg::ref_ptr<osg::AudioSink> audio_sink)
|
||||
|
||||
void FFmpegDecoderAudio::fillBuffer(void * const buffer, size_t size)
|
||||
{
|
||||
size_t filled = 0;
|
||||
uint8_t * dst_buffer = reinterpret_cast<uint8_t*>(buffer);
|
||||
|
||||
while (size != 0)
|
||||
|
||||
@@ -222,15 +222,15 @@ void FFmpegDecoderVideo::decodeLoop()
|
||||
|
||||
void FFmpegDecoderVideo::findAspectRatio()
|
||||
{
|
||||
double ratio = 0.0;
|
||||
float ratio = 0.0f;
|
||||
|
||||
if (m_context->sample_aspect_ratio.num != 0)
|
||||
ratio = (av_q2d(m_context->sample_aspect_ratio) * m_width) / m_height;
|
||||
ratio = float(av_q2d(m_context->sample_aspect_ratio));
|
||||
|
||||
if (ratio <= 0.0)
|
||||
ratio = double(m_width) / double(m_height);
|
||||
if (ratio <= 0.0f)
|
||||
ratio = 1.0f;
|
||||
|
||||
m_aspect_ratio = ratio;
|
||||
m_pixel_aspect_ratio = ratio;
|
||||
}
|
||||
|
||||
int FFmpegDecoderVideo::convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src,
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
|
||||
int width() const;
|
||||
int height() const;
|
||||
double aspectRatio() const;
|
||||
float pixelAspectRatio() const;
|
||||
bool alphaChannel() const;
|
||||
double frameRate() const;
|
||||
const uint8_t * image() const;
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
PublishFunc m_publish_func;
|
||||
|
||||
double m_frame_rate;
|
||||
double m_aspect_ratio;
|
||||
float m_pixel_aspect_ratio;
|
||||
int m_width;
|
||||
int m_height;
|
||||
size_t m_next_frame_index;
|
||||
@@ -155,9 +155,9 @@ inline int FFmpegDecoderVideo::height() const
|
||||
}
|
||||
|
||||
|
||||
inline double FFmpegDecoderVideo::aspectRatio() const
|
||||
inline float FFmpegDecoderVideo::pixelAspectRatio() const
|
||||
{
|
||||
return m_aspect_ratio;
|
||||
return m_pixel_aspect_ratio;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ FFmpegImageStream::FFmpegImageStream() :
|
||||
m_commands(0),
|
||||
m_frame_published_flag(false)
|
||||
{
|
||||
setOrigin(osg::Image::BOTTOM_LEFT);
|
||||
setOrigin(osg::Image::TOP_LEFT);
|
||||
|
||||
std::auto_ptr<FFmpegDecoder> decoder(new FFmpegDecoder);
|
||||
std::auto_ptr<CommandQueue> commands(new CommandQueue);
|
||||
@@ -71,9 +71,9 @@ bool FFmpegImageStream::open(const std::string & filename)
|
||||
m_decoder->video_decoder().width(), m_decoder->video_decoder().height(), 1, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE,
|
||||
const_cast<unsigned char *>(m_decoder->video_decoder().image()), NO_DELETE
|
||||
);
|
||||
|
||||
setOrigin(osg::Image::TOP_LEFT);
|
||||
|
||||
setPixelAspectRatio(m_decoder->video_decoder().pixelAspectRatio());
|
||||
|
||||
m_decoder->video_decoder().setUserData(this);
|
||||
m_decoder->video_decoder().setPublishCallback(publishNewFrame);
|
||||
|
||||
@@ -140,33 +140,27 @@ void FFmpegImageStream::quit(bool waitForThreadToExit)
|
||||
}
|
||||
|
||||
|
||||
double FFmpegImageStream::duration() const
|
||||
double FFmpegImageStream::getLength() const
|
||||
{
|
||||
return m_decoder->duration();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FFmpegImageStream::videoAlphaChannel() const
|
||||
double FFmpegImageStream::getFrameRate() const
|
||||
{
|
||||
return m_decoder->video_decoder().frameRate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FFmpegImageStream::isImageTranslucent() const
|
||||
{
|
||||
return m_decoder->video_decoder().alphaChannel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
double FFmpegImageStream::videoAspectRatio() const
|
||||
{
|
||||
return m_decoder->video_decoder().aspectRatio();
|
||||
}
|
||||
|
||||
|
||||
|
||||
double FFmpegImageStream::videoFrameRate() const
|
||||
{
|
||||
return m_decoder->video_decoder().frameRate();
|
||||
}
|
||||
|
||||
|
||||
void FFmpegImageStream::run()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -32,12 +32,10 @@ namespace osgFFmpeg
|
||||
virtual void rewind();
|
||||
virtual void quit(bool waitForThreadToExit = true);
|
||||
|
||||
double duration() const;
|
||||
|
||||
bool videoAlphaChannel() const;
|
||||
double videoAspectRatio() const;
|
||||
double videoFrameRate() const;
|
||||
virtual double getLength() const;
|
||||
virtual double getFrameRate() const;
|
||||
|
||||
virtual bool isImageTranslucent() const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user