54 _xmv(xmv), _videoTrack(0), _audioTrackCount(0) {
81 for (std::vector<PacketAudio>::iterator audio = packet.
audio.begin();
82 audio != packet.
audio.end(); ++audio)
102 throw Common::Exception(
"XboxMediaVideo::processNextFrame(): Frame data overrun");
111 warning(
"XboxMediaVideo::processNextFrame(): Video frame without a decoder");
135 if (tag !=
MKTAG(
'X',
'b',
'o',
'x'))
140 if ((version == 0) || (version > 4))
141 throw Common::Exception(
"XboxMediaVideo::load(): Unsupported version %d", version);
149 std::vector<AudioInfo> audioTrackInfo;
156 audioTrackInfo[i].compression =
_xmv->readUint16LE();
157 audioTrackInfo[i].channels =
_xmv->readUint16LE();
158 audioTrackInfo[i].rate =
_xmv->readUint32LE();
159 audioTrackInfo[i].bitsPerSample =
_xmv->readUint16LE();
160 audioTrackInfo[i].flags =
_xmv->readUint16LE();
173 warning(
"Failed to initialize audio track: %s", e.
what());
177 audioTracks[i] = track;
204 if (audioTracks[i + 1] && audioTracks[i + 2]) {
212 audioTracks[i + 1] = 0;
213 audioTracks[i + 2] = 0;
215 warning(
"Could not create 5.1 track");
263 byte videoHeaderData[8];
264 _xmv->read(videoHeaderData, 8);
266 packet.
video.
dataSize = READ_LE_UINT32(videoHeaderData) & 0x007FFFFF;
267 packet.
video.
frameCount = (READ_LE_UINT32(videoHeaderData) >> 23) & 0xFF;
269 bool hasExtraData = (videoHeaderData[3] & 0x80) != 0;
283 for (
size_t i = 0; i < packet.
audio.size(); i++) {
286 byte audioHeaderData[4];
287 _xmv->read(audioHeaderData, 4);
289 audioHeader.
dataSize = READ_LE_UINT32(audioHeaderData) & 0x007FFFFF;
290 if ((audioHeader.
dataSize == 0) && (i != 0))
302 size_t dataOffset =
_xmv->pos();
307 for (
size_t i = 0; i < packet.
audio.size(); i++) {
308 packet.
audio[i].dataOffset = dataOffset;
309 dataOffset += packet.
audio[i].dataSize;
323 warning(
"XboxMediaVideo::processPacketHeader(): Video extra data doesn't fit");
361 _videoCodec->decodeFrame(surface, frameData);
381 return !_audioStream->endOfStream();
385 _audioStream->queuePacket(stream);
389 _audioStream->finish();
393 return _audioStream.get();
398 if (_info.channels == 0 || _info.channels > 2)
401 switch (_info.compression) {
405 if (_info.bitsPerSample == 16) {
407 }
else if (_info.bitsPerSample != 8) {
414 if (_info.bitsPerSample != 4)
424 _realTracks[0].reset(track1);
425 _realTracks[1].reset(track2);
426 _realTracks[2].reset(track3);
428 std::vector<Sound::AudioStream *> interleavedStreams;
430 for (
int i = 0; i < 3; i++)
431 interleavedStreams.push_back(_realTracks[i]->getAudioStream());
437 return !_interleaved->endOfStream();
441 return _interleaved.get();
Common::ScopedPtr< Graphics::Surface > _surface
The video's surface.
PacketizedAudioStream * makePacketizedADPCMStream(ADPCMTypes type, int rate, int channels, uint32 blockAlign)
Creates a PacketizedAudioStream that will automatically queue packets as individual AudioStreams like...
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like 'DATA', to ensure portability.
static const int kAudioFlagADPCM51FrontCenterLow
static const int kAudioFlagADPCM51FrontLeftRight
PacketizedAudioStream * makePacketizedPCMStream(int rate, byte flags, int channels)
Creates a PacketizedAudioStream that will automatically queue packets as individual AudioStreams like...
void reset(PointerType o=0)
Resets the pointer with the new value.
void addTrack(Track *track, bool isExternal=false)
Define a track to be used by this class.
bool _needCopy
Is new frame content available that needs to by copied?
void resize(typename std::vector< T *>::size_type n, typename std::vector< T *>::value_type val=typename std::vector< T *>::value_type())
Implementing the reading stream interfaces for plain memory blocks.
Decoding PCM (Pulse Code Modulation).
Compression types in Microsoft's WAVEFORMAT(EX).
Utility templates and functions for working with strings and streams.
Exception that provides a stack of explanations.
void initVideo()
Create a surface for video of these dimensions.
A vector of pointer to objects, with automatic deletion.
static const int kAudioFlagADPCM51
AudioStream * makeInterleaver(int rate, const std::vector< AudioStream *> &streams, bool disposeAfterUse)
Takes several input audio streams and interleaves the sample data to create an audio stream with x ch...
Basic exceptions to throw.
Decoding ADPCM (Adaptive Differential Pulse Code Modulation).
static const int kAudioFlagADPCM51RearLeftRight
An AudioStream designed to work in terms of packets.
An audio stream interleaving several other audio streams.
Decoding Microsoft Xbox XMV videos.
void info(const char *s,...)
An abstract representation of a video track.
A vector storing pointer to objects, with automatic deletion.
void warning(const char *s,...)
sound is 16 bits wide (default: 8bit)
Generic audio input stream.
PointerType get() const
Returns the plain pointer value.
UString debugTag(uint32 tag, bool trim)
Create an elaborate string from an integer tag, for debugging purposes.
Timestamps allow specifying points in time and measuring time intervals with a sub-millisecond granul...
samples are little endian (default: big endian)
WMV2 video codec, XMV variant.
SeekableSubReadStream provides access to a SeekableReadStream restricted to the range [begin...
const char * what() const
Interface for a seekable & readable data stream.