Remove redundant constants

This commit is contained in:
Henrik Rydgård
2025-04-12 11:06:19 +02:00
parent 3c4566717c
commit f7ff2e2d20
7 changed files with 38 additions and 38 deletions
+8 -8
View File
@@ -207,7 +207,7 @@ void Atrac::WriteContextToPSPMem() {
if (track_.firstSampleOffset != 0) {
context->info.firstValidSample = track_.FirstSampleOffsetFull();
} else {
context->info.firstValidSample = (track_.codecType == PSP_MODE_AT_3_PLUS ? ATRAC3PLUS_MAX_SAMPLES : ATRAC3_MAX_SAMPLES);
context->info.firstValidSample = (track_.codecType == PSP_CODEC_AT3PLUS ? ATRAC3PLUS_MAX_SAMPLES : ATRAC3_MAX_SAMPLES);
}
context->info.sampleSize = track_.bytesPerFrame;
context->info.numChan = track_.channels;
@@ -226,7 +226,7 @@ void Atrac::WriteContextToPSPMem() {
void Track::DebugLog() const {
DEBUG_LOG(Log::ME, "ATRAC analyzed: %s channels: %d filesize: %d bitrate: %d kbps jointStereo: %d",
codecType == PSP_MODE_AT_3 ? "AT3" : "AT3Plus", channels, fileSize, bitrate / 1024, jointStereo);
codecType == PSP_CODEC_AT3 ? "AT3" : "AT3Plus", channels, fileSize, bitrate / 1024, jointStereo);
DEBUG_LOG(Log::ME, "dataoff: %d firstSampleOffset: %d endSample: %d", dataByteOffset, firstSampleOffset, endSample);
DEBUG_LOG(Log::ME, "loopStartSample: %d loopEndSample: %d", loopStartSample, loopEndSample);
DEBUG_LOG(Log::ME, "sampleSize: %d (%03x", bytesPerFrame, bytesPerFrame);
@@ -308,7 +308,7 @@ void AtracBase::CreateDecoder(int codecType, int bytesPerFrame, int channels) {
}
// First, init the standalone decoder.
if (codecType == PSP_MODE_AT_3) {
if (codecType == PSP_CODEC_AT3) {
// TODO: This is maybe not entirely reliable? Mui Mui house in LocoRoco 2 fails. Although also fails
// when I override this, so maybe the issue is something different...
bool jointStereo = IsAtrac3StreamJointStereo(codecType, bytesPerFrame, channels);
@@ -435,7 +435,7 @@ int Atrac::SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize,
ResetData();
UpdateBufferState();
if (track_.codecType != PSP_MODE_AT_3 && track_.codecType != PSP_MODE_AT_3_PLUS) {
if (track_.codecType != PSP_CODEC_AT3 && track_.codecType != PSP_CODEC_AT3PLUS) {
// Shouldn't have gotten here, Analyze() checks this.
bufferState_ = ATRAC_STATUS_NO_DATA;
ERROR_LOG(Log::ME, "unexpected codec type %d in set data", track_.codecType);
@@ -454,7 +454,7 @@ int Atrac::SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize,
bufferValidBytes_ = first_.size - bufferPos_;
}
const char *codecName = track_.codecType == PSP_MODE_AT_3 ? "atrac3" : "atrac3+";
const char *codecName = track_.codecType == PSP_CODEC_AT3 ? "atrac3" : "atrac3+";
const char *channelName = track_.channels == 1 ? "mono" : "stereo";
// Over-allocate databuf to prevent going off the end if the bitstream is bad or if there are
@@ -897,7 +897,7 @@ int Atrac::ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrit
bufferValidBytes_ = bytesWrittenFirstBuf - bufferPos_;
}
if (track_.codecType == PSP_MODE_AT_3 || track_.codecType == PSP_MODE_AT_3_PLUS) {
if (track_.codecType == PSP_CODEC_AT3 || track_.codecType == PSP_CODEC_AT3PLUS) {
SeekToSample(sample);
}
@@ -916,11 +916,11 @@ void Atrac::InitLowLevel(const Atrac3LowLevelParams &params, int codecType) {
first_.writableBytes = track_.bytesPerFrame;
ResetData();
if (codecType == PSP_MODE_AT_3) {
if (codecType == PSP_CODEC_AT3) {
track_.bitrate = (track_.bytesPerFrame * 352800) / 1000;
track_.bitrate = (track_.bitrate + 511) >> 10;
track_.jointStereo = IsAtrac3StreamJointStereo(codecType, params.bytesPerFrame, params.encodedChannels);
} else if (codecType == PSP_MODE_AT_3_PLUS) {
} else if (codecType == PSP_CODEC_AT3PLUS) {
track_.bitrate = (track_.bytesPerFrame * 352800) / 1000;
track_.bitrate = ((track_.bitrate >> 11) + 8) & 0xFFFFFFF0;
track_.jointStereo = false;
+3 -3
View File
@@ -819,7 +819,7 @@ int Atrac2::SetData(const Track &track, u32 bufferAddr, u32 readSize, u32 buffer
SceAtracIdInfo &info = context_->info;
if (track.codecType != PSP_MODE_AT_3 && track.codecType != PSP_MODE_AT_3_PLUS) {
if (track.codecType != PSP_CODEC_AT3 && track.codecType != PSP_CODEC_AT3PLUS) {
// Shouldn't have gotten here, Analyze() checks this.
ERROR_LOG(Log::ME, "unexpected codec type %d in set data", track.codecType);
return SCE_ERROR_ATRAC_UNKNOWN_FORMAT;
@@ -832,7 +832,7 @@ int Atrac2::SetData(const Track &track, u32 bufferAddr, u32 readSize, u32 buffer
if (readSize >= track.fileSize) {
INFO_LOG(Log::ME, "The full file was set directly - we can dump it.");
char filename[512];
snprintf(filename, sizeof(filename), "%s_%d%s", track.codecType == PSP_MODE_AT_3 ? "at3" : "at3plus", track.endSample, track.channels == 1 ? "_mono" : "");
snprintf(filename, sizeof(filename), "%s_%d%s", track.codecType == PSP_CODEC_AT3 ? "at3" : "at3plus", track.endSample, track.channels == 1 ? "_mono" : "");
DumpFileIfEnabled(Memory::GetPointer(bufferAddr), readSize, filename, DumpFileType::Atrac3);
}
@@ -1004,7 +1004,7 @@ int Atrac2::Bitrate() const {
const SceAtracIdInfo &info = context_->info;
int bitrate = (info.sampleSize * 352800) / 1000;
if (info.codec == PSP_MODE_AT_3_PLUS)
if (info.codec == PSP_CODEC_AT3PLUS)
bitrate = ((bitrate >> 11) + 8) & 0xFFFFFFF0;
else
bitrate = (bitrate + 511) >> 10;
+9 -9
View File
@@ -122,10 +122,10 @@ void __AtracInit() {
memset(g_muteFlag, 0, sizeof(g_muteFlag));
// Start with 2 of each in this order.
atracContextTypes[0] = PSP_MODE_AT_3_PLUS;
atracContextTypes[1] = PSP_MODE_AT_3_PLUS;
atracContextTypes[2] = PSP_MODE_AT_3;
atracContextTypes[3] = PSP_MODE_AT_3;
atracContextTypes[0] = PSP_CODEC_AT3PLUS;
atracContextTypes[1] = PSP_CODEC_AT3PLUS;
atracContextTypes[2] = PSP_CODEC_AT3;
atracContextTypes[3] = PSP_CODEC_AT3;
atracContextTypes[4] = 0;
atracContextTypes[5] = 0;
}
@@ -255,7 +255,7 @@ static int UnregisterAndDeleteAtrac(int atracID) {
// Really, allocate an Atrac context of a specific codec type.
// Useful to initialize a context for low level decode.
static u32 sceAtracGetAtracID(int codecType) {
if (codecType != PSP_MODE_AT_3 && codecType != PSP_MODE_AT_3_PLUS) {
if (codecType != PSP_CODEC_AT3 && codecType != PSP_CODEC_AT3PLUS) {
return hleReportError(Log::ME, SCE_ERROR_ATRAC_INVALID_CODECTYPE, "invalid codecType");
}
@@ -808,13 +808,13 @@ static int sceAtracReinit(int at3Count, int at3plusCount) {
for (int i = 0; i < at3plusCount; ++i) {
space -= 2;
if (space >= 0) {
atracContextTypes[next++] = PSP_MODE_AT_3_PLUS;
atracContextTypes[next++] = PSP_CODEC_AT3PLUS;
}
}
for (int i = 0; i < at3Count; ++i) {
space -= 1;
if (space >= 0) {
atracContextTypes[next++] = PSP_MODE_AT_3;
atracContextTypes[next++] = PSP_CODEC_AT3;
}
}
@@ -1044,7 +1044,7 @@ static const At3HeaderMap at3HeaderMap[] = {
};
bool IsAtrac3StreamJointStereo(int codecType, int bytesPerFrame, int channels) {
if (codecType != PSP_MODE_AT_3) {
if (codecType != PSP_CODEC_AT3) {
// Well, might actually be, but it's not used in codec setup.
return false;
}
@@ -1075,7 +1075,7 @@ static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) {
atrac->InitLowLevel(*params, codecType);
const char *codecName = codecType == PSP_MODE_AT_3 ? "atrac3" : "atrac3+";
const char *codecName = codecType == PSP_CODEC_AT3 ? "atrac3" : "atrac3+";
const char *encodedChannelName = params->encodedChannels == 1 ? "mono" : "stereo";
const char *outputChannelName = params->outputChannels == 1 ? "mono" : "stereo";
return hleLogInfo(Log::ME, 0, "%s %s->%s audio", codecName, encodedChannelName, outputChannelName);
+4 -4
View File
@@ -139,10 +139,10 @@ AudioDecoder *CreateAudioDecoder(PSPAudioType audioType, int sampleRateHz, int c
switch (audioType) {
case PSP_CODEC_MP3:
return new MiniMp3Audio();
case PSP_CODEC_AT3:
return CreateAtrac3Audio(channels, blockAlign, extraData, extraDataSize);
case PSP_CODEC_AT3PLUS:
return CreateAtrac3PlusAudio(channels, blockAlign);
// case PSP_CODEC_AT3:
// return CreateAtrac3Audio(channels, blockAlign, extraData, extraDataSize);
// case PSP_CODEC_AT3PLUS:
// return CreateAtrac3PlusAudio(channels, blockAlign);
default:
// Only AAC falls back to FFMPEG now.
return new FFmpegAudioDecoder(audioType, sampleRateHz, channels);
+8 -4
View File
@@ -4,6 +4,10 @@
#include "Core/HLE/ErrorCodes.h"
#include "Core/MemMap.h"
// Atrac file parsing constants
#define AT3_MAGIC 0x0270
#define AT3_PLUS_MAGIC 0xFFFE // This is normally a marker for WAVE_FORMAT_EXTENSIBLE
const int RIFF_CHUNK_MAGIC = 0x46464952;
const int RIFF_WAVE_MAGIC = 0x45564157;
const int FMT_CHUNK_MAGIC = 0x20746D66;
@@ -110,9 +114,9 @@ int AnalyzeAtracTrack(const u8 *buffer, u32 size, Track *track, std::string *err
}
if (at3fmt->fmtTag == AT3_MAGIC)
track->codecType = PSP_MODE_AT_3;
track->codecType = PSP_CODEC_AT3;
else if (at3fmt->fmtTag == AT3_PLUS_MAGIC)
track->codecType = PSP_MODE_AT_3_PLUS;
track->codecType = PSP_CODEC_AT3PLUS;
else {
*error = "AnalyzeTrack: invalid fmt magic: %04x";
return SCE_ERROR_ATRAC_UNKNOWN_FORMAT;
@@ -288,14 +292,14 @@ int AnalyzeAA3Track(const u8 *buffer, u32 size, u32 fileSize, Track *track, std:
switch (buffer[32]) {
case 0:
track->codecType = PSP_MODE_AT_3;
track->codecType = PSP_CODEC_AT3;
track->bytesPerFrame = (codecParams & 0x03FF) * 8;
track->bitrate = at3SampleRates[(codecParams >> 13) & 7] * track->bytesPerFrame * 8 / 1024;
track->channels = 2;
track->jointStereo = (codecParams >> 17) & 1;
break;
case 1:
track->codecType = PSP_MODE_AT_3_PLUS;
track->codecType = PSP_CODEC_AT3PLUS;
track->bytesPerFrame = ((codecParams & 0x03FF) * 8) + 8;
track->bitrate = at3SampleRates[(codecParams >> 13) & 7] * track->bytesPerFrame * 8 / 2048;
track->channels = (codecParams >> 10) & 7;
+4 -8
View File
@@ -5,11 +5,7 @@
#include <vector>
#include <string>
// Atrac file parsing.
#define AT3_MAGIC 0x0270
#define AT3_PLUS_MAGIC 0xFFFE
#define PSP_MODE_AT_3_PLUS 0x00001000
#define PSP_MODE_AT_3 0x00001001
#include "Core/HLE/sceAudiocodec.h"
constexpr u32 ATRAC3_MAX_SAMPLES = 0x400; // 1024
constexpr u32 ATRAC3PLUS_MAX_SAMPLES = 0x800; // 2048
@@ -72,7 +68,7 @@ struct Track {
inline int FirstOffsetExtra() const {
// These first samples are skipped, after first possibly skipping 0-2 full frames, it seems.
return codecType == PSP_MODE_AT_3_PLUS ? 0x170 : 0x45;
return codecType == PSP_CODEC_AT3PLUS ? 0x170 : 0x45;
}
// Includes the extra offset. See firstSampleOffset comment above.
@@ -82,12 +78,12 @@ struct Track {
// Output frame size, different between the two supported codecs.
int SamplesPerFrame() const {
return codecType == PSP_MODE_AT_3_PLUS ? ATRAC3PLUS_MAX_SAMPLES : ATRAC3_MAX_SAMPLES;
return codecType == PSP_CODEC_AT3PLUS ? ATRAC3PLUS_MAX_SAMPLES : ATRAC3_MAX_SAMPLES;
}
int Bitrate() const {
int bitrate = (bytesPerFrame * 352800) / 1000;
if (codecType == PSP_MODE_AT_3_PLUS)
if (codecType == PSP_CODEC_AT3PLUS)
bitrate = ((bitrate >> 11) + 8) & 0xFFFFFFF0;
else
bitrate = (bitrate + 511) >> 10;
+2 -2
View File
@@ -991,10 +991,10 @@ void DrawAudioDecodersView(ImConfig &cfg, ImControl &control) {
case 0:
ImGui::TextUnformatted("-"); // Uninitialized
break;
case PSP_MODE_AT_3_PLUS:
case PSP_CODEC_AT3PLUS:
ImGui::TextUnformatted("Atrac3+");
break;
case PSP_MODE_AT_3:
case PSP_CODEC_AT3:
ImGui::TextUnformatted("Atrac3");
break;
default: