xoreos  0.0.5
xmv.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef VIDEO_XMV_H
26 #define VIDEO_XMV_H
27 
28 #include <vector>
29 
30 #include "src/common/scopedptr.h"
31 
32 #include "src/video/decoder.h"
33 
34 namespace Common {
35  class SeekableReadStream;
36 }
37 
38 namespace Sound {
39  class AudioStream;
40  class PacketizedAudioStream;
41 }
42 
43 namespace Video {
44 
45 class Codec;
46 
48 class XboxMediaVideo : public VideoDecoder {
49 public:
52 
53 protected:
54  void decodeNextTrackFrame(VideoTrack &track);
55 
56 private:
58  struct AudioInfo {
64  };
65 
66  class XMVVideoTrack : public VideoTrack {
67  public:
68  XMVVideoTrack(uint32 width, uint32 height, uint32 &timestamp);
69 
70  bool endOfTrack() const { return _finished; }
71 
72  uint32 getWidth() const { return _width; }
73  uint32 getHeight() const { return _height; }
74  int getCurFrame() const { return _curFrame; }
76 
77  bool decodeFrame(Graphics::Surface &surface, Common::SeekableReadStream &frameData);
78  void initCodec(Common::SeekableReadStream &extraData);
79  void finish() { _finished = true; }
80 
81  private:
85  int _curFrame;
86  bool _finished;
87 
90  };
91 
93  class XMVAudioTrack : public AudioTrack {
94  public:
96 
99 
101  void finish();
102 
103  // AudioTrack API
104  bool canBufferData() const;
106 
107  private:
111  };
112 
114  class XMVAudioTrack51 : public AudioTrack {
115  public:
117 
118  // AudioTrack API
119  bool canBufferData() const;
120 
121  protected:
122  // AudioTrack API
124 
125  private:
128  };
129 
131  struct PacketVideo {
134 
136 
139 
141 
144  };
145 
147  struct PacketAudio {
150 
153 
154  bool newSlice;
155  };
156 
158  struct Packet {
159  size_t thisPacketSize;
160  size_t nextPacketSize;
161 
164 
167 
169  std::vector<PacketAudio> audio;
170  };
171 
173 
176 
179 
182 
183 
185  void load();
186 
188  void fetchNextPacket(Packet &packet);
189 
191  void processPacketHeader(Packet &packet);
192 
194  void queueNewAudio(PacketAudio &audioPacket);
196  void queueNewAudio(Packet &packet);
197 
199  void processNextFrame(PacketVideo &videoPacket);
200 };
201 
202 } // End of namespace Video
203 
204 #endif // VIDEO_XMV_H
uint32 currentFrameSize
The size of the current frame.
Definition: xmv.h:138
uint16 channels
The number of channels.
Definition: xmv.h:60
void load()
Load an XMV file.
Definition: xmv.cpp:125
Common::Timestamp getNextFrameStartTime() const
Get the start time of the next frame since the start of the video.
Definition: xmv.cpp:369
Common::ScopedPtr< XMVAudioTrack > _realTracks[3]
Definition: xmv.h:126
size_t thisPacketOffset
The current packet&#39;s offset within the XMV stream.
Definition: xmv.h:162
Common::ScopedPtr< Sound::AudioStream > _interleaved
Definition: xmv.h:127
Common::ScopedPtr< Common::SeekableReadStream > _xmv
Definition: xmv.h:172
uint32 getWidth() const
Get the width of this track.
Definition: xmv.h:72
Definition: 2dafile.h:39
An abstract representation of an audio track.
Definition: decoder.h:302
Packet _curPacket
The current packet.
Definition: xmv.h:181
bool endOfTrack() const
Return if the track has finished.
Definition: xmv.h:70
XMVAudioTrack * track
The audio track mapping.
Definition: xmv.h:151
int getCurFrame() const
Get the current frame of this track.
Definition: xmv.h:74
uint32 dataOffset
The video data offset within the XMV stream.
Definition: xmv.h:133
An XMV packet.
Definition: xmv.h:158
PacketVideo video
The video part of the packet.
Definition: xmv.h:166
XboxMediaVideo(Common::SeekableReadStream *xmv)
Definition: xmv.cpp:53
void processPacketHeader(Packet &packet)
Process a packet&#39;s header.
Definition: xmv.cpp:257
XMVAudioTrack51(XMVAudioTrack *info1, XMVAudioTrack *info2, XMVAudioTrack *info3)
Definition: xmv.cpp:423
void decodeNextTrackFrame(VideoTrack &track)
Decode enough data for the next frame.
Definition: xmv.cpp:328
Sound::AudioStream * getAudioStream() const
Get the AudioStream that is the representation of this AudioTrack.
Definition: xmv.cpp:440
bool decodeFrame(Graphics::Surface &surface, Common::SeekableReadStream &frameData)
Definition: xmv.cpp:355
uint32 currentFrameTimestamp
The timestamp of when the current frame should be shown.
Definition: xmv.h:140
A generic interface for video decoders.
Definition: decoder.h:55
void finish()
Mark the stream as finished.
Definition: xmv.cpp:388
AudioInfo * info
The audio info related to this packet.
Definition: xmv.h:152
uint16 compression
The compression method.
Definition: xmv.h:59
A simple scoped smart pointer template.
Sound::AudioStream * getAudioStream() const
Get the AudioStream that is the representation of this AudioTrack.
Definition: xmv.cpp:392
XMVVideoTrack * _videoTrack
The current video track.
Definition: xmv.h:175
uint32 frameCount
Number of frames left in this packet.
Definition: xmv.h:135
Definition: game.h:37
Sound::PacketizedAudioStream * createStream() const
Definition: xmv.cpp:396
An audio packet.
Definition: xmv.h:147
bool newSlice
Is a new slice that needs to be queue available?
Definition: xmv.h:154
size_t thisPacketSize
The current packet&#39;s size.
Definition: xmv.h:159
uint16_t uint16
Definition: types.h:202
A decoder for Microsoft Xbox XMV videos.
Definition: xmv.h:48
An audio track&#39;s information.
Definition: xmv.h:58
An AudioStream designed to work in terms of packets.
Definition: audiostream.h:271
uint32 dataSize
The audio data size.
Definition: xmv.h:148
void info(const char *s,...)
Definition: util.cpp:69
XMVAudioTrack(const AudioInfo &info)
Definition: xmv.cpp:376
size_t nextPacketSize
The next packet&#39;s size.
Definition: xmv.h:160
uint32 getHeight() const
Get the height of this track.
Definition: xmv.h:73
uint32 rate
The sampling rate.
Definition: xmv.h:61
bool canBufferData() const
Can more audio data be buffered?
Definition: xmv.cpp:380
uint32 lastFrameTime
The timestamp of when the current last frame was shown.
Definition: xmv.h:143
XMVVideoTrack(uint32 width, uint32 height, uint32 &timestamp)
Definition: xmv.cpp:352
Common::ScopedPtr< Sound::PacketizedAudioStream > _audioStream
Definition: xmv.h:109
void processNextFrame(PacketVideo &videoPacket)
Process the next frame.
Definition: xmv.cpp:86
An abstract representation of a video track.
Definition: decoder.h:226
uint32 _audioTrackCount
The audio track count.
Definition: xmv.h:178
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
void queueAudio(Common::SeekableReadStream *stream)
Queue audio stream data belonging to this track.
Definition: xmv.cpp:384
Generic audio input stream.
Definition: audiostream.h:70
std::vector< PacketAudio > audio
The audio part of the packet.
Definition: xmv.h:169
size_t nextPacketOffset
The next packet&#39;s offset within the XMV stream.
Definition: xmv.h:163
void queueNewAudio(PacketAudio &audioPacket)
Queue the data from this audio packet.
Definition: xmv.cpp:64
uint32_t uint32
Definition: types.h:204
An XMV 5.1 audio track.
Definition: xmv.h:114
void initCodec(Common::SeekableReadStream &extraData)
Definition: xmv.cpp:365
Timestamps allow specifying points in time and measuring time intervals with a sub-millisecond granul...
Definition: timestamp.h:108
uint32 dataSize
The video data size.
Definition: xmv.h:132
Common::ScopedPtr< Codec > _videoCodec
The video codec.
Definition: xmv.h:89
uint16 bitsPerSample
The number of bits per encoded sample.
Definition: xmv.h:62
Interface for a seekable & readable data stream.
Definition: readstream.h:265
bool canBufferData() const
Can more audio data be buffered?
Definition: xmv.cpp:436
uint32 dataOffset
The audio data offset within the XMV stream.
Definition: xmv.h:149
void fetchNextPacket(Packet &packet)
Fetch the next packet.
Definition: xmv.cpp:240
Generic video decoder interface.
An XMV audio track.
Definition: xmv.h:93