aboutsummaryrefslogtreecommitdiff
path: root/video/psx_decoder.h
diff options
context:
space:
mode:
authorMatthew Hoops2012-08-26 15:39:18 -0400
committerMatthew Hoops2012-08-26 15:41:56 -0400
commit857b92f8ffececa9c1f990d21a6a8d1630199a62 (patch)
tree420463df7bf481f8c4e0dcba9bd37e68d999b43d /video/psx_decoder.h
parent1d58ebe133c274643a89f2f4f0d24a2a8ab343c3 (diff)
parent18e7573dafbffdd509943c8f90f91933b17b0435 (diff)
downloadscummvm-rg350-857b92f8ffececa9c1f990d21a6a8d1630199a62.tar.gz
scummvm-rg350-857b92f8ffececa9c1f990d21a6a8d1630199a62.tar.bz2
scummvm-rg350-857b92f8ffececa9c1f990d21a6a8d1630199a62.zip
Merge pull request #268 from clone2727/video-rewrite
VideoDecoder upgrade & partial rewrite
Diffstat (limited to 'video/psx_decoder.h')
-rw-r--r--video/psx_decoder.h110
1 files changed, 68 insertions, 42 deletions
diff --git a/video/psx_decoder.h b/video/psx_decoder.h
index 4364ec4bbb..11f311594d 100644
--- a/video/psx_decoder.h
+++ b/video/psx_decoder.h
@@ -71,59 +71,85 @@ public:
bool loadStream(Common::SeekableReadStream *stream);
void close();
- bool isVideoLoaded() const { return _stream != 0; }
- uint16 getWidth() const { return _surface->w; }
- uint16 getHeight() const { return _surface->h; }
- uint32 getFrameCount() const { return _frameCount; }
- uint32 getTime() const;
- uint32 getTimeToNextFrame() const;
- const Graphics::Surface *decodeNextFrame();
- Graphics::PixelFormat getPixelFormat() const { return _surface->format; }
- bool endOfVideo() const { return _stream->pos() >= _stream->size(); }
-
protected:
- // VideoDecoder API
- void updateVolume();
- void updateBalance();
+ void readNextPacket();
+ bool useAudioSync() const;
private:
- void initCommon();
- Common::SeekableReadStream *_stream;
- Graphics::Surface *_surface;
+ class PSXVideoTrack : public VideoTrack {
+ public:
+ PSXVideoTrack(Common::SeekableReadStream *firstSector, CDSpeed speed, int frameCount);
+ ~PSXVideoTrack();
+
+ uint16 getWidth() const { return _surface->w; }
+ uint16 getHeight() const { return _surface->h; }
+ Graphics::PixelFormat getPixelFormat() const { return _surface->format; }
+ bool endOfTrack() const { return _endOfTrack; }
+ int getCurFrame() const { return _curFrame; }
+ int getFrameCount() const { return _frameCount; }
+ uint32 getNextFrameStartTime() const;
+ const Graphics::Surface *decodeNextFrame();
+
+ void setEndOfTrack() { _endOfTrack = true; }
+ void decodeFrame(Common::SeekableReadStream *frame, uint sectorCount);
+
+ private:
+ Graphics::Surface *_surface;
+ uint32 _frameCount;
+ Audio::Timestamp _nextFrameStartTime;
+ bool _endOfTrack;
+ int _curFrame;
+
+ enum PlaneType {
+ kPlaneY = 0,
+ kPlaneU = 1,
+ kPlaneV = 2
+ };
+
+ uint16 _macroBlocksW, _macroBlocksH;
+ byte *_yBuffer, *_cbBuffer, *_crBuffer;
+ void decodeMacroBlock(Common::BitStream *bits, int mbX, int mbY, uint16 scale, uint16 version);
+ void decodeBlock(Common::BitStream *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane);
+
+ void readAC(Common::BitStream *bits, int *block);
+ Common::Huffman *_acHuffman;
+
+ int readDC(Common::BitStream *bits, uint16 version, PlaneType plane);
+ Common::Huffman *_dcHuffmanLuma, *_dcHuffmanChroma;
+ int _lastDC[3];
+
+ void dequantizeBlock(int *coefficients, float *block, uint16 scale);
+ void idct(float *dequantData, float *result);
+ int readSignedCoefficient(Common::BitStream *bits);
+ };
- uint32 _frameCount;
- Audio::Timestamp _nextFrameStartTime;
+ class PSXAudioTrack : public AudioTrack {
+ public:
+ PSXAudioTrack(Common::SeekableReadStream *sector);
+ ~PSXAudioTrack();
- Audio::SoundHandle _audHandle;
- Audio::QueuingAudioStream *_audStream;
- void queueAudioFromSector(Common::SeekableReadStream *sector);
+ bool endOfTrack() const;
- enum PlaneType {
- kPlaneY = 0,
- kPlaneU = 1,
- kPlaneV = 2
- };
+ void setEndOfTrack() { _endOfTrack = true; }
+ void queueAudioFromSector(Common::SeekableReadStream *sector);
- uint16 _macroBlocksW, _macroBlocksH;
- byte *_yBuffer, *_cbBuffer, *_crBuffer;
- void decodeFrame(Common::SeekableReadStream *frame);
- void decodeMacroBlock(Common::BitStream *bits, int mbX, int mbY, uint16 scale, uint16 version);
- void decodeBlock(Common::BitStream *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane);
+ private:
+ Audio::AudioStream *getAudioStream() const;
- void readAC(Common::BitStream *bits, int *block);
- Common::Huffman *_acHuffman;
+ Audio::QueuingAudioStream *_audStream;
- int readDC(Common::BitStream *bits, uint16 version, PlaneType plane);
- Common::Huffman *_dcHuffmanLuma, *_dcHuffmanChroma;
- int _lastDC[3];
+ struct ADPCMStatus {
+ int16 sample[2];
+ } _adpcmStatus[2];
- void dequantizeBlock(int *coefficients, float *block, uint16 scale);
- void idct(float *dequantData, float *result);
- int readSignedCoefficient(Common::BitStream *bits);
+ bool _endOfTrack;
+ };
- struct ADPCMStatus {
- int16 sample[2];
- } _adpcmStatus[2];
+ CDSpeed _speed;
+ uint32 _frameCount;
+ Common::SeekableReadStream *_stream;
+ PSXVideoTrack *_videoTrack;
+ PSXAudioTrack *_audioTrack;
Common::SeekableReadStream *readSector();
};