// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include <map>2021class PointerWrap;2223// audioType24enum PSPAudioType {25PSP_CODEC_AT3PLUS = 0x00001000,26PSP_CODEC_AT3 = 0x00001001,27PSP_CODEC_MP3 = 0x00001002,28PSP_CODEC_AAC = 0x00001003, // sceMp4 decodes this in an mp4 container29PSP_CODEC_WMA = 0x00001005,30};3132struct SceAudiocodecCodec {33s32 unk_init;34s32 unk4;35s32 err; // 836s32 edramAddr; // c // presumably in ME memory?37s32 neededMem; // 10 // 0x102400 for Atrac3+38s32 inited; // 1439u32 inBuf; // 18 // Before decoding, set this to the start of the raw frame.40s32 srcBytesRead; // 1c41u32 outBuf; // 20 // This is where the decoded data is written.42s32 dstSamplesWritten; // 2443// Probably, from here on out is a union with different fields for different codecs.44union { // offset 40 / 0x2845struct {46s8 unk40; // 28 format or looping related . Aka tailrelated47s8 unk41; // 29 format or looping related . Aka tailflag48s8 unk42;49s8 unk43;50};51u32 formatOutSamples;52};53union { // offset 44 / 0x2C54struct {55u8 unk44;56s8 unk45;57s8 unk46;58s8 unk47;59};60struct {61s16 unk44_16;62s16 unk46_16;63};64u32 unk44_32;65};66s32 unk48; // 30 Atrac3 (non-+) related. Zero with Atrac3+.67s32 unk52; // 3468s32 mp3_9999; // 38 // unk5669s32 mp3_3; // unk60 gets the value 370s32 unk64; // Atrac3+ size related71s32 mp3_9;72s32 mp3_0;73s32 unk76;74s32 unk80;75s32 mp3_1_first;76s32 unk88;77s32 unk92;78s32 mp3_1;79s32 unk100;80u32 allocMem; // 10481// make sure the size is 12882u8 unk[20];83};8485void __AudioCodecInit();86void __AudioCodecShutdown();87void Register_sceAudiocodec();88void __sceAudiocodecDoState(PointerWrap &p);8990class AudioDecoder;91extern std::map<u32, AudioDecoder *> g_audioDecoderContexts;9293bool IsAtrac3StreamJointStereo(int codecType, int bytesPerFrame, int channels);949596