Read Smacker video and audio data separately
This commit is contained in:
parent
19a4eb79aa
commit
5d00b96e5f
3 changed files with 192 additions and 54 deletions
|
|
@ -48,6 +48,9 @@
|
|||
#include <stdint.h>
|
||||
#include "FileStream.h"
|
||||
#include "BitReader.h"
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
// exportable interface
|
||||
|
|
@ -71,6 +74,7 @@ void Smacker_Close (SmackerHandle &handle);
|
|||
uint32_t Smacker_GetNumAudioTracks (SmackerHandle &handle);
|
||||
SmackerAudioInfo Smacker_GetAudioTrackDetails (SmackerHandle &handle, uint32_t trackIndex);
|
||||
uint32_t Smacker_GetAudioData (SmackerHandle &handle, uint32_t trackIndex, int16_t *data);
|
||||
void Smacker_DisableAudioTrack (SmackerHandle &handle, uint32_t trackIndex);
|
||||
uint32_t Smacker_GetNumFrames (SmackerHandle &handle);
|
||||
void Smacker_GetFrameSize (SmackerHandle &handle, uint32_t &width, uint32_t &height);
|
||||
uint32_t Smacker_GetCurrentFrameNum (SmackerHandle &handle);
|
||||
|
|
@ -86,6 +90,12 @@ const int kMaxAudioTracks = 7;
|
|||
struct HuffContext;
|
||||
struct DBCtx;
|
||||
|
||||
struct SmackerPacket
|
||||
{
|
||||
size_t size = 0;
|
||||
std::unique_ptr<uint8_t[]> data;
|
||||
};
|
||||
|
||||
struct SmackerAudioTrack
|
||||
{
|
||||
uint32_t sizeInBytes;
|
||||
|
|
@ -99,6 +109,7 @@ struct SmackerAudioTrack
|
|||
uint32_t bufferSize;
|
||||
|
||||
uint32_t bytesReadThisFrame;
|
||||
std::deque<SmackerPacket> packetData;
|
||||
};
|
||||
|
||||
class SmackerDecoder
|
||||
|
|
@ -116,6 +127,7 @@ class SmackerDecoder
|
|||
|
||||
SmackerAudioInfo GetAudioTrackDetails(uint32_t trackIndex);
|
||||
uint32_t GetAudioData(uint32_t trackIndex, int16_t *audioBuffer);
|
||||
void DisableAudioTrack(uint32_t trackIndex);
|
||||
uint32_t GetNumFrames();
|
||||
uint32_t GetCurrentFrameNum();
|
||||
float GetFrameRate();
|
||||
|
|
@ -125,6 +137,7 @@ class SmackerDecoder
|
|||
private:
|
||||
SmackerCommon::FileStream file;
|
||||
char signature[4];
|
||||
std::mutex fileMutex;
|
||||
|
||||
// video related members
|
||||
uint32_t nFrames;
|
||||
|
|
@ -135,8 +148,10 @@ class SmackerDecoder
|
|||
|
||||
bool isVer4;
|
||||
|
||||
uint32_t currentReadFrame;
|
||||
std::vector<uint8_t> packetData;
|
||||
uint8_t *packetDataPtr = nullptr;
|
||||
|
||||
std::deque<SmackerPacket> framePacketData;
|
||||
SmackerAudioTrack audioTracks[kMaxAudioTracks];
|
||||
|
||||
uint32_t treeSize;
|
||||
|
|
@ -162,9 +177,9 @@ class SmackerDecoder
|
|||
int DecodeBigTree(SmackerCommon::BitReader &bits, HuffContext *hc, DBCtx *ctx);
|
||||
int GetCode(SmackerCommon::BitReader &bits, std::vector<int> &recode, int *last);
|
||||
int ReadPacket();
|
||||
int DecodeFrame(uint32_t frameSize);
|
||||
int DecodeFrame(const uint8_t *dataPtr, uint32_t frameSize);
|
||||
void GetFrameSize(uint32_t &width, uint32_t &height);
|
||||
int DecodeAudio(uint32_t size, SmackerAudioTrack &track);
|
||||
int DecodeAudio(const uint8_t *dataPtr, uint32_t size, SmackerAudioTrack &track);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue