aboutsummaryrefslogtreecommitdiff
path: root/video
diff options
context:
space:
mode:
authorMatthew Hoops2014-01-09 21:27:52 -0500
committerMatthew Hoops2014-01-11 18:43:42 -0500
commitd2e31c8d67417d033b89cabc834cf3a1c363799c (patch)
tree923958cb7a5a344204409e6d1d7095628a96ffd8 /video
parentda604b530b37ad1908644e97b816ae34118bd7c1 (diff)
downloadscummvm-rg350-d2e31c8d67417d033b89cabc834cf3a1c363799c.tar.gz
scummvm-rg350-d2e31c8d67417d033b89cabc834cf3a1c363799c.tar.bz2
scummvm-rg350-d2e31c8d67417d033b89cabc834cf3a1c363799c.zip
VIDEO: Improve support for multiple AVI audio tracks
Diffstat (limited to 'video')
-rw-r--r--video/avi_decoder.cpp40
-rw-r--r--video/avi_decoder.h7
2 files changed, 29 insertions, 18 deletions
diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp
index 7f5a557474..a3b45995a1 100644
--- a/video/avi_decoder.cpp
+++ b/video/avi_decoder.cpp
@@ -441,12 +441,10 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
if (time > getDuration())
return false;
- // Track down our video track (optionally audio too).
- // We only support seeking with one track right now.
+ // Track down our video track.
+ // We only support seeking with one video track right now.
AVIVideoTrack *videoTrack = 0;
- AVIAudioTrack *audioTrack = 0;
int videoIndex = -1;
- int audioIndex = -1;
uint trackID = 0;
for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++, trackID++) {
@@ -459,15 +457,6 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
videoTrack = (AVIVideoTrack *)*it;
videoIndex = trackID;
- } else if ((*it)->getTrackType() == Track::kTrackTypeAudio) {
- if (audioTrack) {
- // Already have one
- // -> Not supported
- return false;
- }
-
- audioTrack = (AVIAudioTrack *)*it;
- audioIndex = trackID;
}
}
@@ -480,8 +469,9 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
if (time == getDuration()) {
videoTrack->setCurFrame(videoTrack->getFrameCount() - 1);
- if (audioTrack)
- audioTrack->resetStream();
+ for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++)
+ if ((*it)->getTrackType() == Track::kTrackTypeAudio)
+ ((AVIAudioTrack *)*it)->resetStream();
return true;
}
@@ -542,7 +532,15 @@ bool AVIDecoder::seekIntern(const Audio::Timestamp &time) {
if (frameIndex < 0) // This shouldn't happen.
return false;
- if (audioTrack) {
+ // Update all the audio tracks
+ uint audioIndex = 0;
+
+ for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++, audioIndex++) {
+ if ((*it)->getTrackType() != Track::kTrackTypeAudio)
+ continue;
+
+ AVIAudioTrack *audioTrack = (AVIAudioTrack *)*it;
+
// We need to find where the start of audio should be.
// Which is exactly 'initialFrames' audio chunks back from where
// our found frame is.
@@ -683,6 +681,16 @@ void AVIDecoder::forceVideoEnd() {
((AVIVideoTrack *)*it)->forceTrackEnd();
}
+VideoDecoder::AudioTrack *AVIDecoder::getAudioTrack(int index) {
+ // AVI audio track indexes are relative to the first track
+ Track *track = getTrack(index);
+
+ if (!track || track->getTrackType() != Track::kTrackTypeAudio)
+ return 0;
+
+ return (AudioTrack *)track;
+}
+
AVIDecoder::AVIVideoTrack::AVIVideoTrack(int frameCount, const AVIStreamHeader &streamHeader, const BitmapInfoHeader &bitmapInfoHeader, byte *initialPalette)
: _frameCount(frameCount), _vidsHeader(streamHeader), _bmInfo(bitmapInfoHeader), _initialPalette(initialPalette) {
_videoCodec = createCodec();
diff --git a/video/avi_decoder.h b/video/avi_decoder.h
index 882cce30de..811f7f82f7 100644
--- a/video/avi_decoder.h
+++ b/video/avi_decoder.h
@@ -72,8 +72,11 @@ public:
bool isSeekable() const;
protected:
- void readNextPacket();
- bool seekIntern(const Audio::Timestamp &time);
+ // VideoDecoder API
+ void readNextPacket();
+ bool seekIntern(const Audio::Timestamp &time);
+ bool supportsAudioTrackSwitching() const { return true; }
+ AudioTrack *getAudioTrack(int index);
struct BitmapInfoHeader {
uint32 size;