libsmackerdec: Implement GotoFrame() function

# Conflicts:
#	source/libsmackerdec/src/SmackerDecoder.cpp
This commit is contained in:
sirlemonhead 2020-05-14 00:32:27 +01:00 committed by Christoph Oelckers
parent 9428c88e29
commit e2569d9980
2 changed files with 9 additions and 8 deletions

View file

@ -152,6 +152,7 @@ class SmackerDecoder
uint32_t currentFrame; uint32_t currentFrame;
int32_t nextPos; int32_t nextPos;
int32_t firstFrameFilePos;
bool DecodeHeaderTrees(); bool DecodeHeaderTrees();
int DecodeHeaderTree(SmackerCommon::BitReader &bits, std::vector<int> &recodes, int *last, int size); int DecodeHeaderTree(SmackerCommon::BitReader &bits, std::vector<int> &recodes, int *last, int size);

View file

@ -406,9 +406,10 @@ bool SmackerDecoder::Open(const char *fileName)
// set nextPos to where we are now, as next data is frame 1 // set nextPos to where we are now, as next data is frame 1
nextPos = file.GetPosition(); nextPos = file.GetPosition();
firstFrameFilePos = nextPos;
// determine max buffer sizes for audio tracks // determine max buffer sizes for audio tracks
file.Seek(nextPos, SmackerCommon::FileStream::kSeekStart); // file.Seek(nextPos, SmackerCommon::FileStream::kSeekStart);
uint32_t UNUSED(frameSize) = frameSizes[0] & (~3); uint32_t UNUSED(frameSize) = frameSizes[0] & (~3);
uint8_t frameFlag = frameFlags[0]; uint8_t frameFlag = frameFlags[0];
@ -1111,21 +1112,20 @@ float SmackerDecoder::GetFrameRate()
void SmackerDecoder::GotoFrame(uint32_t frameNum) void SmackerDecoder::GotoFrame(uint32_t frameNum)
{ {
if (frameNum >= nFrames) { if (frameNum > nFrames) {
Printf("SmackerDecoder::GotoFrame() - Invalid frame number\n"); Printf("SmackerDecoder::GotoFrame() - Invalid frame number\n");
return; return;
} }
// file.Seek(firstFrameFilePos, SmackerCommon::FileStream::kSeekStart);
// TODO currentFrame = 0;
nextPos = firstFrameFilePos;
// seek to the desired frame (just set currentFrame) for (int i = 0; i < frameNum + 1; i++)
// currentFrame = frameNum; GetNextFrame();
// what else? (memset some stuff?)
} }
SmackerAudioInfo SmackerDecoder::GetAudioTrackDetails(uint32_t trackIndex) SmackerAudioInfo SmackerDecoder::GetAudioTrackDetails(uint32_t trackIndex)
{ {
SmackerAudioInfo info; SmackerAudioInfo info;