Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Core/HLE/AtracCtx2.h
3186 views
1
#pragma once
2
3
#include <cstdint>
4
5
#include "Core/HLE/AtracBase.h"
6
7
class Atrac2 : public AtracBase {
8
public:
9
// The default values are only used during save state load, in which case they get restored by DoState.
10
Atrac2(u32 contextAddr = 0, int codecType = 0);
11
~Atrac2();
12
13
AtracStatus BufferState() const override {
14
return context_->info.state;
15
}
16
17
void DoState(PointerWrap &p) override;
18
19
int GetNextDecodePosition(int *pos) const override;
20
21
int RemainingFrames() const override;
22
int LoopStatus() const override;
23
int Bitrate() const override;
24
int LoopNum() const override;
25
int SamplesPerFrame() const override { return context_->info.SamplesPerFrame(); }
26
int Channels() const override { return context_->info.numChan; }
27
int BytesPerFrame() const override { return context_->info.sampleSize; }
28
int SetLoopNum(int loopNum) override;
29
int CodecType() const override { return context_->info.codec; }
30
31
void GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) override;
32
int GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) const override;
33
int AddStreamData(u32 bytesToAdd) override;
34
int ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf, bool *delay) override;
35
int GetBufferInfoForResetting(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) override;
36
int SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize, u32 fileSize, int outputChannels, bool isAA3) override;
37
int SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) override;
38
bool HasSecondBuffer() const override;
39
40
u32 DecodeData(u8 *outbuf, u32 outbufPtr, int *SamplesNum, int *finish, int *remains) override;
41
int DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, int *bytesWritten) override;
42
43
void CheckForSas() override;
44
int EnqueueForSas(u32 address, u32 ptr) override;
45
void DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) override;
46
const AtracSasStreamState *StreamStateForSas() const override { return context_->info.state == 0x10 ? &sas_ : nullptr; }
47
48
u32 GetNextSamples() override;
49
50
void InitLowLevel(const Atrac3LowLevelParams &params, int codecType) override;
51
52
int GetSoundSample(int *endSample, int *loopStartSample, int *loopEndSample) const override;
53
54
// These will not be used by the new implementation.
55
void UpdateContextFromPSPMem() override {}
56
void NotifyGetContextAddress() override {}
57
58
int GetContextVersion() const override { return 2; }
59
u32 GetInternalCodecError() const override;
60
61
private:
62
u32 DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish);
63
void GetResetBufferInfoInternal(AtracResetBufferInfo *bufferInfo, int sample) const;
64
u32 ResetPlayPositionInternal(int seekPos, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf);
65
66
u32 SkipFrames(int *skippedCount);
67
void WrapLastPacket();
68
69
void DumpBufferToFile();
70
71
// Just the current decoded frame, in order to be able to cut off the first part of it
72
// to write the initial partial frame.
73
// Does not need to be saved.
74
int16_t *decodeTemp_ = nullptr;
75
76
// This is hidden state inside sceSas, really. Not visible in the context.
77
// But it doesn't really matter whether it's here or there.
78
AtracSasStreamState sas_;
79
80
std::vector<u8> dumpBuffer_; // Used for dumping audio data to files.
81
bool dumped_ = false; // Whether we already dumped the audio data to a file.
82
};
83
84