mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-02 14:51:40 +00:00
VIDEO: Improve support for multiple AVI audio tracks
This commit is contained in:
parent
da604b530b
commit
d2e31c8d67
@ -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();
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user