ScummVM API documentation
Video::AVIDecoder Class Reference

#include <avi_decoder.h>

Inheritance diagram for Video::AVIDecoder:
Video::VideoDecoder Titanic::AVIDecoder ZVision::ZorkAVIDecoder

Classes

class  AVIAudioTrack
 
struct  AVIHeader
 
struct  AVIStreamHeader
 
class  AVIVideoTrack
 
struct  BitmapInfoHeader
 
class  IndexEntries
 
struct  OldIndex
 
struct  PCMWaveFormat
 
struct  TrackStatus
 
struct  WaveFormat
 
struct  WaveFormatEX
 

Public Member Functions

 AVIDecoder (const Common::Rational &frameRateOverride)
 
bool loadStream (Common::SeekableReadStream *stream)
 
void close ()
 
uint16 getWidth () const
 
uint16 getHeight () const
 
bool rewind ()
 
bool isRewindable () const
 
bool isSeekable () const
 
virtual const Graphics::SurfacedecodeNextFrame ()
 
const Graphics::SurfacedecodeNextTransparency ()
 
virtual AVIAudioTrackcreateAudioTrack (AVIStreamHeader sHeader, PCMWaveFormat wvInfo)
 
virtual bool seekToFrame (uint frame)
 
- Public Member Functions inherited from Video::VideoDecoder
virtual bool loadFile (const Common::Path &filename)
 
bool isVideoLoaded () const
 
void start ()
 
void stop ()
 
void setRate (const Common::Rational &rate)
 
Common::Rational getRate () const
 
bool isPlaying () const
 
bool seek (const Audio::Timestamp &time)
 
void pauseVideo (bool pause)
 
bool isPaused () const
 
void setEndTime (const Audio::Timestamp &endTime)
 
void setEndFrame (uint frame)
 
Audio::Timestamp getEndTime () const
 
void resetStartTime ()
 
bool endOfVideo () const
 
int getCurFrame () const
 
uint32 getFrameCount () const
 
uint32 getTime () const
 
Graphics::PixelFormat getPixelFormat () const
 
virtual Audio::Timestamp getDuration () const
 
const byte * getPalette ()
 
bool hasDirtyPalette () const
 
void delayMillis (uint msecs)
 
uint32 getTimeToNextFrame () const
 
bool needsUpdate () const
 
bool setReverse (bool reverse)
 
bool setDitheringPalette (const byte *palette)
 
bool setOutputPixelFormat (const Graphics::PixelFormat &format)
 
virtual void setVideoCodecAccuracy (Image::CodecAccuracy accuracy)
 
byte getVolume () const
 
void setVolume (byte volume)
 
int8 getBalance () const
 
void setBalance (int8 balance)
 
Audio::Mixer::SoundType getSoundType () const
 
void setSoundType (Audio::Mixer::SoundType soundType)
 
bool addStreamTrack (Audio::SeekableAudioStream *stream)
 
bool addStreamFileTrack (const Common::Path &baseName)
 
bool setAudioTrack (int index)
 
uint getAudioTrackCount () const
 

Protected Types

enum  IndexFlags { AVIIF_INDEX = 0x10 }
 
enum  AVIFlags {
  AVIF_HASINDEX = 0x00000010, AVIF_MUSTUSEINDEX = 0x00000020, AVIF_ISINTERLEAVED = 0x00000100, AVIF_TRUSTCKTYPE = 0x00000800,
  AVIF_WASCAPTUREFILE = 0x00010000, AVIF_WASCOPYRIGHTED = 0x00020000
}
 
- Protected Types inherited from Video::VideoDecoder
typedef Common::Array< Track * > TrackList
 
typedef TrackList::iterator TrackListIterator
 

Protected Member Functions

void readNextPacket ()
 
bool seekIntern (const Audio::Timestamp &time)
 
bool supportsAudioTrackSwitching () const
 
AudioTrackgetAudioTrack (int index)
 
void addTrack (Track *track, bool isExternal=false)
 
void readOldIndex (uint32 size)
 
void initCommon ()
 
bool parseNextChunk ()
 
void skipChunk (uint32 size)
 
void handleList (uint32 listSize)
 
void handleStreamHeader (uint32 size)
 
void readStreamName (uint32 size)
 
void readPalette8 (uint32 size)
 
uint16 getStreamType (uint32 tag) const
 
void checkTruemotion1 ()
 
uint getVideoTrackOffset (uint trackIndex, uint frameNumber=0)
 
void handleNextPacket (TrackStatus &status)
 
bool shouldQueueAudio (TrackStatus &status)
 
void seekTransparencyFrame (int frame)
 
- Protected Member Functions inherited from Video::VideoDecoder
void resetPauseStartTime ()
 
void addTrack (Track *track, bool isExternal=false)
 
virtual bool useAudioSync () const
 
TrackgetTrack (uint track)
 
const TrackgetTrack (uint track) const
 
bool endOfVideoTracks () const
 
VideoTrackfindNextVideoTrack ()
 
TrackListIterator getTrackListBegin ()
 
TrackListIterator getTrackListEnd ()
 
void eraseTrack (Track *track)
 
void stopAudio ()
 
void setAudioRate (Common::Rational rate)
 
void startAudio ()
 
void startAudioLimit (const Audio::Timestamp &limit)
 
bool hasFramesLeft () const
 
bool hasAudio () const
 

Static Protected Member Functions

static byte getStreamIndex (uint32 tag)
 

Protected Attributes

AVIHeader _header
 
IndexEntries _indexEntries
 
Common::SeekableReadStream_fileStream
 
bool _decodedHeader
 
bool _foundMovieList
 
uint32 _movieListStart
 
uint32 _movieListEnd
 
Common::Rational _frameRateOverride
 
int _videoTrackCounter
 
int _audioTrackCounter
 
Track_lastAddedTrack
 
Common::Array< TrackStatus_videoTracks
 
Common::Array< TrackStatus_audioTracks
 
TrackStatus _transparencyTrack
 
- Protected Attributes inherited from Video::VideoDecoder
Audio::Timestamp _lastTimeChange
 
int32 _startTime
 
VideoTrack_nextVideoTrack
 
Image::CodecAccuracy _videoCodecAccuracy
 

Detailed Description

Decoder for AVI videos.

Video decoder used in engines:

  • petka
  • sci
  • sword1
  • sword2
  • titanic
  • vcruise
  • zvision

Member Function Documentation

◆ loadStream()

bool Video::AVIDecoder::loadStream ( Common::SeekableReadStream stream)
virtual

Load a video from a generic read stream. The ownership of the stream object transfers to this VideoDecoder instance, which is hence also responsible for eventually deleting it.

Implementations of this function are required to call addTrack() for each track in the video upon success.

Parameters
streamthe stream to load
Returns
whether loading the stream succeeded

Implements Video::VideoDecoder.

◆ close()

void Video::AVIDecoder::close ( )
virtual

Close the active video stream and free any associated resources.

All subclasses that need to close their own resources should still call the base class' close() function at the start of their function.

Reimplemented from Video::VideoDecoder.

◆ getWidth()

uint16 Video::AVIDecoder::getWidth ( ) const
inlinevirtual

Returns the width of the video's frames.

By default, this finds the largest width between all of the loaded tracks. However, a subclass may override this if it does any kind of post-processing on it.

Returns
the width of the video's frames

Reimplemented from Video::VideoDecoder.

◆ getHeight()

uint16 Video::AVIDecoder::getHeight ( ) const
inlinevirtual

Returns the height of the video's frames.

By default, this finds the largest height between all of the loaded tracks. However, a subclass may override this if it does any kind of post-processing on it.

Returns
the height of the video's frames

Reimplemented from Video::VideoDecoder.

◆ rewind()

bool Video::AVIDecoder::rewind ( )
virtual

Rewind a video to its beginning.

If the video is playing, it will continue to play. The default implementation will rewind each track.

Returns
true on success, false otherwise

Reimplemented from Video::VideoDecoder.

◆ isRewindable()

bool Video::AVIDecoder::isRewindable ( ) const
inlinevirtual

Returns if a video is rewindable or not. The default implementation polls each track for rewindability.

Reimplemented from Video::VideoDecoder.

◆ isSeekable()

bool Video::AVIDecoder::isSeekable ( ) const
virtual

Returns if a video is seekable or not. The default implementation polls each track for seekability.

Reimplemented from Video::VideoDecoder.

◆ decodeNextFrame()

virtual const Graphics::Surface* Video::AVIDecoder::decodeNextFrame ( )
virtual

Decode the next frame into a surface and return the latter.

A subclass may override this, but must still call this function. As an example, a subclass may do this to apply some global video scale to individual track's frame.

Note that this will call readNextPacket() internally first before calling the next video track's decodeNextFrame() function.

Returns
a surface containing the decoded frame, or 0
Note
Ownership of the returned surface stays with the VideoDecoder, hence the caller must not free it.
this may return 0, in which case the last frame should be kept on screen

Reimplemented from Video::VideoDecoder.

◆ decodeNextTransparency()

const Graphics::Surface* Video::AVIDecoder::decodeNextTransparency ( )

Decodes the next transparency track frame

◆ readNextPacket()

void Video::AVIDecoder::readNextPacket ( )
protectedvirtual

Decode enough data for the next frame and enough audio to last that long.

This function is used by this class' decodeNextFrame() function. A subclass of a Track may decide to just have its decodeNextFrame() function read and decode the frame, but only if it is the only track in the video.

Reimplemented from Video::VideoDecoder.

◆ seekIntern()

bool Video::AVIDecoder::seekIntern ( const Audio::Timestamp time)
protectedvirtual

The internal seek function that does the actual seeking.

See also
seek()
Returns
true on success, false otherwise

Reimplemented from Video::VideoDecoder.

◆ supportsAudioTrackSwitching()

bool Video::AVIDecoder::supportsAudioTrackSwitching ( ) const
inlineprotectedvirtual

Does this video format support switching between audio tracks?

Returning true implies this format supports multiple audio tracks, can switch tracks, and defaults to playing the first found audio track.

Reimplemented from Video::VideoDecoder.

◆ getAudioTrack()

AudioTrack* Video::AVIDecoder::getAudioTrack ( int  index)
protectedvirtual

Get the audio track for the given index.

This is used only if supportsAudioTrackSwitching() returns true.

Parameters
indexThe index of the track, whose meaning is dependent on the container
Returns
The audio track for the index, or 0 if not found

Reimplemented from Video::VideoDecoder.

◆ addTrack()

void Video::AVIDecoder::addTrack ( Track track,
bool  isExternal = false 
)
protected

Define a track to be used by this class.

The pointer is then owned by this base class.

Parameters
trackThe track to add
isExternalIs this an external track not found by loadStream()?

◆ seekToFrame()

virtual bool Video::AVIDecoder::seekToFrame ( uint  frame)
virtual

Seek to a given frame.

This only works when the video track(s) supports getFrameTime(). This calls seek() internally.

Reimplemented from Video::VideoDecoder.


The documentation for this class was generated from the following file: