mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-29 14:42:26 +00:00
VIDEO: Use new BitStreamMemory class for PSXStreamDecoder
This commit is contained in:
parent
e72f681ceb
commit
47539e1939
@ -27,7 +27,6 @@
|
||||
#include "audio/decoders/raw.h"
|
||||
#include "common/bitstream.h"
|
||||
#include "common/huffman.h"
|
||||
#include "common/memstream.h"
|
||||
#include "common/stream.h"
|
||||
#include "common/system.h"
|
||||
#include "common/textconsole.h"
|
||||
@ -232,7 +231,7 @@ void PSXStreamDecoder::readNextPacket() {
|
||||
|
||||
if (curSector == sectorCount - 1) {
|
||||
// Done assembling the frame
|
||||
Common::SeekableReadStream *frame = new Common::MemoryReadStream(partialFrame, frameSize, DisposeAfterUse::YES);
|
||||
Common::BitStreamMemoryStream *frame = new Common::BitStreamMemoryStream(partialFrame, frameSize, DisposeAfterUse::YES);
|
||||
|
||||
_videoTrack->decodeFrame(frame, sectorsRead);
|
||||
|
||||
@ -464,10 +463,10 @@ const Graphics::Surface *PSXStreamDecoder::PSXVideoTrack::decodeNextFrame() {
|
||||
return _surface;
|
||||
}
|
||||
|
||||
void PSXStreamDecoder::PSXVideoTrack::decodeFrame(Common::SeekableReadStream *frame, uint sectorCount) {
|
||||
void PSXStreamDecoder::PSXVideoTrack::decodeFrame(Common::BitStreamMemoryStream *frame, uint sectorCount) {
|
||||
// A frame is essentially an MPEG-1 intra frame
|
||||
|
||||
Common::BitStream16LEMSB bits(frame);
|
||||
Common::BitStreamMemory16LEMSB bits(frame);
|
||||
|
||||
bits.skip(16); // unknown
|
||||
bits.skip(16); // 0x3800
|
||||
@ -499,7 +498,7 @@ void PSXStreamDecoder::PSXVideoTrack::decodeFrame(Common::SeekableReadStream *fr
|
||||
_nextFrameStartTime = _nextFrameStartTime.addFrames(sectorCount);
|
||||
}
|
||||
|
||||
void PSXStreamDecoder::PSXVideoTrack::decodeMacroBlock(Common::BitStream16LEMSB *bits, int mbX, int mbY, uint16 scale, uint16 version) {
|
||||
void PSXStreamDecoder::PSXVideoTrack::decodeMacroBlock(Common::BitStreamMemory16LEMSB *bits, int mbX, int mbY, uint16 scale, uint16 version) {
|
||||
int pitchY = _macroBlocksW * 16;
|
||||
int pitchC = _macroBlocksW * 8;
|
||||
|
||||
@ -546,7 +545,7 @@ void PSXStreamDecoder::PSXVideoTrack::dequantizeBlock(int *coefficients, float *
|
||||
}
|
||||
}
|
||||
|
||||
int PSXStreamDecoder::PSXVideoTrack::readDC(Common::BitStream16LEMSB *bits, uint16 version, PlaneType plane) {
|
||||
int PSXStreamDecoder::PSXVideoTrack::readDC(Common::BitStreamMemory16LEMSB *bits, uint16 version, PlaneType plane) {
|
||||
// Version 2 just has its coefficient as 10-bits
|
||||
if (version == 2)
|
||||
return readSignedCoefficient(bits);
|
||||
@ -576,7 +575,7 @@ int PSXStreamDecoder::PSXVideoTrack::readDC(Common::BitStream16LEMSB *bits, uint
|
||||
if (count > 63) \
|
||||
error("PSXStreamDecoder::readAC(): Too many coefficients")
|
||||
|
||||
void PSXStreamDecoder::PSXVideoTrack::readAC(Common::BitStream16LEMSB *bits, int *block) {
|
||||
void PSXStreamDecoder::PSXVideoTrack::readAC(Common::BitStreamMemory16LEMSB *bits, int *block) {
|
||||
// Clear the block first
|
||||
for (int i = 0; i < 63; i++)
|
||||
block[i] = 0;
|
||||
@ -611,7 +610,7 @@ void PSXStreamDecoder::PSXVideoTrack::readAC(Common::BitStream16LEMSB *bits, int
|
||||
}
|
||||
}
|
||||
|
||||
int PSXStreamDecoder::PSXVideoTrack::readSignedCoefficient(Common::BitStream16LEMSB *bits) {
|
||||
int PSXStreamDecoder::PSXVideoTrack::readSignedCoefficient(Common::BitStreamMemory16LEMSB *bits) {
|
||||
uint val = bits->getBits(10);
|
||||
|
||||
// extend the sign
|
||||
@ -672,7 +671,7 @@ void PSXStreamDecoder::PSXVideoTrack::idct(float *dequantData, float *result) {
|
||||
}
|
||||
}
|
||||
|
||||
void PSXStreamDecoder::PSXVideoTrack::decodeBlock(Common::BitStream16LEMSB *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane) {
|
||||
void PSXStreamDecoder::PSXVideoTrack::decodeBlock(Common::BitStreamMemory16LEMSB *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane) {
|
||||
// Version 2 just has signed 10 bits for DC
|
||||
// Version 3 has them huffman coded
|
||||
int coefficients[8 * 8];
|
||||
|
@ -37,7 +37,6 @@ class QueuingAudioStream;
|
||||
|
||||
namespace Common {
|
||||
class Huffman;
|
||||
class SeekableReadStream;
|
||||
}
|
||||
|
||||
namespace Graphics {
|
||||
@ -91,7 +90,7 @@ private:
|
||||
const Graphics::Surface *decodeNextFrame();
|
||||
|
||||
void setEndOfTrack() { _endOfTrack = true; }
|
||||
void decodeFrame(Common::SeekableReadStream *frame, uint sectorCount);
|
||||
void decodeFrame(Common::BitStreamMemoryStream *frame, uint sectorCount);
|
||||
|
||||
private:
|
||||
Graphics::Surface *_surface;
|
||||
@ -108,19 +107,19 @@ private:
|
||||
|
||||
uint16 _macroBlocksW, _macroBlocksH;
|
||||
byte *_yBuffer, *_cbBuffer, *_crBuffer;
|
||||
void decodeMacroBlock(Common::BitStream16LEMSB *bits, int mbX, int mbY, uint16 scale, uint16 version);
|
||||
void decodeBlock(Common::BitStream16LEMSB *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane);
|
||||
void decodeMacroBlock(Common::BitStreamMemory16LEMSB *bits, int mbX, int mbY, uint16 scale, uint16 version);
|
||||
void decodeBlock(Common::BitStreamMemory16LEMSB *bits, byte *block, int pitch, uint16 scale, uint16 version, PlaneType plane);
|
||||
|
||||
void readAC(Common::BitStream16LEMSB *bits, int *block);
|
||||
void readAC(Common::BitStreamMemory16LEMSB *bits, int *block);
|
||||
Common::Huffman *_acHuffman;
|
||||
|
||||
int readDC(Common::BitStream16LEMSB *bits, uint16 version, PlaneType plane);
|
||||
int readDC(Common::BitStreamMemory16LEMSB *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::BitStream16LEMSB *bits);
|
||||
int readSignedCoefficient(Common::BitStreamMemory16LEMSB *bits);
|
||||
};
|
||||
|
||||
class PSXAudioTrack : public AudioTrack {
|
||||
|
Loading…
x
Reference in New Issue
Block a user