22#include "common/scummsys.h"
26#ifndef VIDEO_THEORA_DECODER_H
27#define VIDEO_THEORA_DECODER_H
29#include "common/rational.h"
30#include "video/video_decoder.h"
31#include "audio/mixer.h"
32#include "graphics/surface.h"
34#include <theora/theoradec.h>
37#include <tremor/ivorbiscodec.h>
39#include <vorbis/codec.h>
43class SeekableReadStream;
48class QueuingAudioStream;
65class TheoraDecoder :
public VideoDecoder {
68 virtual ~TheoraDecoder();
75 void close()
override;
81 void readNextPacket()
override;
84 class TheoraVideoTrack :
public VideoTrack {
86 TheoraVideoTrack(th_info &theoraInfo, th_setup_info *theoraSetup);
89 bool endOfTrack()
const override {
return _endOfVideo; }
90 uint16 getWidth()
const override {
return _width; }
91 uint16 getHeight()
const override {
return _height; }
94 if (format.bytesPerPixel != 2 && format.bytesPerPixel != 4)
96 _pixelFormat = format;
100 int getCurFrame()
const override {
return _curFrame; }
102 uint32 getNextFrameStartTime()
const override {
return (uint32)(_nextFrameStartTime * 1000); }
105 bool decodePacket(ogg_packet &oggPacket);
106 void setEndOfVideo() { _endOfVideo =
true; }
112 double _nextFrameStartTime;
121 uint16 _surfaceWidth;
122 uint16 _surfaceHeight;
124 th_dec_ctx *_theoraDecode;
125 th_pixel_fmt _theoraPixelFormat;
127 void translateYUVtoRGBA(th_ycbcr_buffer &YUVBuffer);
130 class VorbisAudioTrack :
public AudioTrack {
135 bool decodeSamples();
136 bool hasAudio()
const;
137 bool needsAudio()
const;
138 void synthesizePacket(ogg_packet &oggPacket);
139 void setEndOfAudio() { _endOfAudio =
true; }
146 int _audioBufferFill;
147 ogg_int16_t *_audioBuffer;
151 vorbis_block _vorbisBlock;
152 vorbis_dsp_state _vorbisDSP;
157 void queuePage(ogg_page *page);
160 void ensureAudioBufferSize();
164 ogg_sync_state _oggSync;
166 ogg_packet _oggPacket;
168 ogg_stream_state _theoraOut, _vorbisOut;
169 bool _hasVideo, _hasAudio;
171 vorbis_info _vorbisInfo;
173 TheoraVideoTrack *_videoTrack;
174 VorbisAudioTrack *_audioTrack;
Definition: audiostream.h:50
SoundType
Definition: mixer.h:73
Definition: audiostream.h:370
Definition: rational.h:40
Definition: algorithm.h:29