Skip to content

Commit

Permalink
Merge pull request #170 from Crow-bar/upd-mp3
Browse files Browse the repository at this point in the history
mp3: new API definitions
  • Loading branch information
sharkwouter authored Feb 4, 2024
2 parents 1a5045f + b1b14aa commit cf7fc72
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 19 deletions.
5 changes: 4 additions & 1 deletion src/mp3/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ CPPFLAGS = -I$(top_srcdir)/src/base -I$(top_srcdir)/src/kernel
CFLAGS = @PSPSDK_CFLAGS@
CCASFLAGS = $(CFLAGS)

MP3_OBJS = sceMp3_0000.o sceMp3_0001.o sceMp3_0002.o sceMp3_0003.o sceMp3_0004.o sceMp3_0005.o sceMp3_0006.o sceMp3_0007.o sceMp3_0008.o sceMp3_0009.o sceMp3_0010.o sceMp3_0011.o sceMp3_0012.o sceMp3_0013.o sceMp3_0014.o sceMp3_0015.o sceMp3_0016.o sceMp3_0017.o sceMp3_0018.o sceMp3_0019.o
MP3_OBJS = sceMp3_0000.o sceMp3_0001.o sceMp3_0002.o sceMp3_0003.o sceMp3_0004.o sceMp3_0005.o sceMp3_0006.o \
sceMp3_0007.o sceMp3_0008.o sceMp3_0009.o sceMp3_0010.o sceMp3_0011.o sceMp3_0012.o sceMp3_0013.o \
sceMp3_0014.o sceMp3_0015.o sceMp3_0016.o sceMp3_0017.o sceMp3_0018.o sceMp3_0019.o sceMp3_0020.o \
sceMp3_0021.o sceMp3_0022.o sceMp3_0023.o sceMp3_0024.o

libpspmp3includedir = @PSPSDK_INCLUDEDIR@
libpspmp3include_HEADERS = pspmp3.h
Expand Down
79 changes: 63 additions & 16 deletions src/mp3/pspmp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,15 @@ extern "C" {

typedef struct SceMp3InitArg {
/** Stream start position */
SceUInt32 mp3StreamStart;
/** Unknown - set to 0 */
SceUInt32 unk1;
SceOff mp3StreamStart;
/** Stream end position */
SceUInt32 mp3StreamEnd;
/** Unknown - set to 0 */
SceUInt32 unk2;
SceOff mp3StreamEnd;
/** Pointer to a buffer to contain raw mp3 stream data (+1472 bytes workspace) */
SceVoid* mp3Buf;
SceUChar8* mp3Buf;
/** Size of mp3Buf buffer (must be >= 8192) */
SceInt32 mp3BufSize;
/** Pointer to decoded pcm samples buffer */
SceVoid* pcmBuf;
SceUChar8* pcmBuf;
/** Size of pcmBuf buffer (must be >= 9216) */
SceInt32 pcmBufSize;
} SceMp3InitArg;
Expand Down Expand Up @@ -135,7 +131,7 @@ SceInt32 sceMp3SetLoopNum(SceInt32 handle, SceInt32 loop);
*
* @param handle - sceMp3 handle
*
* @return Number of loops
* @return Number of loops, < 0 on error.
*/
SceInt32 sceMp3GetLoopNum(SceInt32 handle);

Expand All @@ -144,7 +140,7 @@ SceInt32 sceMp3GetLoopNum(SceInt32 handle);
*
* @param handle - sceMp3 handle
*
* @return Number of decoded samples
* @return Number of decoded samples, < 0 on error.
*/
SceInt32 sceMp3GetSumDecodedSample(SceInt32 handle);

Expand All @@ -153,7 +149,7 @@ SceInt32 sceMp3GetSumDecodedSample(SceInt32 handle);
*
* @param handle - sceMp3 handle
*
* @return Number of max samples to output
* @return Number of max samples to output, < 0 on error.
*/
SceInt32 sceMp3GetMaxOutputSample(SceInt32 handle);

Expand All @@ -162,7 +158,7 @@ SceInt32 sceMp3GetMaxOutputSample(SceInt32 handle);
*
* @param handle - sceMp3 handle
*
* @return Sampling rate of the mp3
* @return Sampling rate of the mp3, < 0 on error.
*/
SceInt32 sceMp3GetSamplingRate(SceInt32 handle);

Expand All @@ -171,7 +167,7 @@ SceInt32 sceMp3GetSamplingRate(SceInt32 handle);
*
* @param handle - sceMp3 handle
*
* @return Bitrate of the mp3
* @return Bitrate of the mp3, < 0 on error.
*/
SceInt32 sceMp3GetBitRate(SceInt32 handle);

Expand All @@ -180,7 +176,7 @@ SceInt32 sceMp3GetBitRate(SceInt32 handle);
*
* @param handle - sceMp3 handle
*
* @return Number of channels of the mp3
* @return Number of channels of the mp3, < 0 on error.
*/
SceInt32 sceMp3GetMp3ChannelNum(SceInt32 handle);

Expand All @@ -189,9 +185,60 @@ SceInt32 sceMp3GetMp3ChannelNum(SceInt32 handle);
*
* @param handle - sceMp3 handle
*
* @return < 0 on error
* @return 0 if success, < 0 on error.
*/
SceInt32 sceMp3ResetPlayPosition(SceInt32 handle);

/**
* sceMp3GetFrameNum
*
* @param handle - sceMp3 handle
*
* @return Number of audio frames, < 0 on error
*/
SceInt32 sceMp3GetFrameNum(SceInt32 handle);

/**
* sceMp3ResetPlayPositionByFrame
*
* @param handle - sceMp3 handle
* @param frame - frame
*
* @return 0 if success, < 0 on error.
*/
SceInt32 sceMp3ResetPlayPositionByFrame(SceInt32 handle, SceUInt32 frame);

/**
* sceMp3GetMPEGVersion
*
* @param handle - sceMp3 handle
*
* @return MPEG Version, < 0 on error
*/
SceInt32 sceMp3GetMPEGVersion(SceInt32 handle);

/**
* sceMp3LowLevelInit
*
* @param handle - sceMp3 handle
* @param src - Pointer to a buffer to contain raw mp3 stream data
*
* @return 0 if success, < 0 on error.
*/
SceInt32 sceMp3LowLevelInit(SceInt32 handle, SceUChar8* src);

/**
* sceMp3LowLevelDecode
*
* @param handle - sceMp3 handle
* @param mp3src - Pointer to a buffer to contain raw mp3 stream data
* @param mp3srcused - mp3 data size consumed by decoding
* @param pcmdst - Pointer to destination pcm samples buffer
* @param pcmdstoutsz - Size of pcm data output by decoding
*
* @return 0 if success, < 0 on error.
*/
SceInt32 sceMp3ResetPlayPosition(SceInt32 handle);
SceInt32 sceMp3LowLevelDecode(SceInt32 handle, SceUChar8* mp3src, SceUInt32* mp3srcused, SceShort16* pcmdst, SceUInt32* pcmdstoutsz);


#ifdef __cplusplus
Expand Down
15 changes: 15 additions & 0 deletions src/mp3/sceMp3.S
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,18 @@
#ifdef F_sceMp3_0019
IMPORT_FUNC "sceMp3",0xF5478233,sceMp3ReleaseMp3Handle
#endif
#ifdef F_sceMp3_0020
IMPORT_FUNC "sceMp3",0xAE6D2027,sceMp3GetMPEGVersion
#endif
#ifdef F_sceMp3_0021
IMPORT_FUNC "sceMp3",0x3548AEC8,sceMp3GetFrameNum
#endif
#ifdef F_sceMp3_0022
IMPORT_FUNC "sceMp3",0x0840E808,sceMp3ResetPlayPositionByFrame
#endif
#ifdef F_sceMp3_0023
IMPORT_FUNC "sceMp3",0x1B839B83,sceMp3LowLevelInit
#endif
#ifdef F_sceMp3_0024
IMPORT_FUNC "sceMp3",0xE3EE2C81,sceMp3LowLevelDecode
#endif
2 changes: 0 additions & 2 deletions src/samples/mp3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ int main(int argc, char *argv[])
SceMp3InitArg mp3Init;
mp3Init.mp3StreamStart = 0;
mp3Init.mp3StreamEnd = sceIoLseek32( fd, 0, SEEK_END );
mp3Init.unk1 = 0;
mp3Init.unk2 = 0;
mp3Init.mp3Buf = mp3Buf;
mp3Init.mp3BufSize = sizeof(mp3Buf);
mp3Init.pcmBuf = pcmBuf;
Expand Down

0 comments on commit cf7fc72

Please sign in to comment.