From 84bbbc3e514f07e92ded8630b7ee4f47e38d0cb4 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 16 Feb 2014 23:15:17 +0800 Subject: [PATCH 1/4] Use GE_CMODE instead of TPSM_PIXEL_STORAGE_MODE --- Core/HW/MediaEngine.cpp | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/Core/HW/MediaEngine.cpp b/Core/HW/MediaEngine.cpp index 4d26155991..b70e91423d 100644 --- a/Core/HW/MediaEngine.cpp +++ b/Core/HW/MediaEngine.cpp @@ -35,11 +35,6 @@ extern "C" { } #endif // USE_FFMPEG -static const int TPSM_PIXEL_STORAGE_MODE_16BIT_BGR5650 = 0x00; -static const int TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR5551 = 0x01; -static const int TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR4444 = 0x02; -static const int TPSM_PIXEL_STORAGE_MODE_32BIT_ABGR8888 = 0x03; - int g_iNumVideos = 0; #ifdef USE_FFMPEG @@ -47,13 +42,13 @@ static AVPixelFormat getSwsFormat(int pspFormat) { switch (pspFormat) { - case TPSM_PIXEL_STORAGE_MODE_16BIT_BGR5650: + case GE_CMODE_16BIT_BGR5650: return AV_PIX_FMT_BGR565LE; - case TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR5551: + case GE_CMODE_16BIT_ABGR5551: return AV_PIX_FMT_BGR555LE; - case TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR4444: + case GE_CMODE_16BIT_ABGR4444: return AV_PIX_FMT_BGR444LE; - case TPSM_PIXEL_STORAGE_MODE_32BIT_ABGR8888: + case GE_CMODE_32BIT_ABGR8888: return AV_PIX_FMT_RGBA; default: ERROR_LOG(ME, "Unknown pixel format"); @@ -101,11 +96,11 @@ static int getPixelFormatBytes(int pspFormat) { switch (pspFormat) { - case TPSM_PIXEL_STORAGE_MODE_16BIT_BGR5650: - case TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR5551: - case TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR4444: + case GE_CMODE_16BIT_BGR5650: + case GE_CMODE_16BIT_ABGR5551: + case GE_CMODE_16BIT_ABGR4444: return 2; - case TPSM_PIXEL_STORAGE_MODE_32BIT_ABGR8888: + case GE_CMODE_32BIT_ABGR8888: return 4; default: @@ -415,7 +410,7 @@ bool MediaEngine::setVideoDim(int width, int height) m_sws_ctx = NULL; m_sws_fmt = -1; - updateSwsFormat(TPSM_PIXEL_STORAGE_MODE_32BIT_ABGR8888); + updateSwsFormat(GE_CMODE_32BIT_ABGR8888); // Allocate video frame for RGB24 m_pFrameRGB = av_frame_alloc(); @@ -572,7 +567,7 @@ int MediaEngine::writeVideoImage(u32 bufferPtr, int frameWidth, int videoPixelMo const u8 *data = m_pFrameRGB->data[0]; switch (videoPixelMode) { - case TPSM_PIXEL_STORAGE_MODE_32BIT_ABGR8888: + case GE_CMODE_32BIT_ABGR8888: for (int y = 0; y < height; y++) { writeVideoLineRGBA(imgbuf, data, width); data += width * sizeof(u32); @@ -581,7 +576,7 @@ int MediaEngine::writeVideoImage(u32 bufferPtr, int frameWidth, int videoPixelMo videoImageSize = frameWidth * sizeof(u32) * height; break; - case TPSM_PIXEL_STORAGE_MODE_16BIT_BGR5650: + case GE_CMODE_16BIT_BGR5650: for (int y = 0; y < height; y++) { writeVideoLineABGR5650(imgbuf, data, width); data += width * sizeof(u16); @@ -590,7 +585,7 @@ int MediaEngine::writeVideoImage(u32 bufferPtr, int frameWidth, int videoPixelMo videoImageSize = frameWidth * sizeof(u16) * height; break; - case TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR5551: + case GE_CMODE_16BIT_ABGR5551: for (int y = 0; y < height; y++) { writeVideoLineABGR5551(imgbuf, data, width); data += width * sizeof(u16); @@ -599,7 +594,7 @@ int MediaEngine::writeVideoImage(u32 bufferPtr, int frameWidth, int videoPixelMo videoImageSize = frameWidth * sizeof(u16) * height; break; - case TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR4444: + case GE_CMODE_16BIT_ABGR4444: for (int y = 0; y < height; y++) { writeVideoLineABGR4444(imgbuf, data, width); data += width * sizeof(u16); @@ -641,7 +636,7 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid height = m_desHeight - ypos; switch (videoPixelMode) { - case TPSM_PIXEL_STORAGE_MODE_32BIT_ABGR8888: + case GE_CMODE_32BIT_ABGR8888: data += (ypos * m_desWidth + xpos) * sizeof(u32); for (int y = 0; y < height; y++) { writeVideoLineRGBA(imgbuf, data, width); @@ -651,7 +646,7 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid videoImageSize = frameWidth * sizeof(u32) * m_desHeight; break; - case TPSM_PIXEL_STORAGE_MODE_16BIT_BGR5650: + case GE_CMODE_16BIT_BGR5650: data += (ypos * m_desWidth + xpos) * sizeof(u16); for (int y = 0; y < height; y++) { writeVideoLineABGR5650(imgbuf, data, width); @@ -661,7 +656,7 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid videoImageSize = frameWidth * sizeof(u16) * m_desHeight; break; - case TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR5551: + case GE_CMODE_16BIT_ABGR5551: data += (ypos * m_desWidth + xpos) * sizeof(u16); for (int y = 0; y < height; y++) { writeVideoLineABGR5551(imgbuf, data, width); @@ -671,7 +666,7 @@ int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int vid videoImageSize = frameWidth * sizeof(u16) * m_desHeight; break; - case TPSM_PIXEL_STORAGE_MODE_16BIT_ABGR4444: + case GE_CMODE_16BIT_ABGR4444: data += (ypos * m_desWidth + xpos) * sizeof(u16); for (int y = 0; y < height; y++) { writeVideoLineABGR4444(imgbuf, data, width); From a5c107e5d17eb1a1fefc7b2265c40d9c8a3f06fd Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 16 Feb 2014 23:21:32 +0800 Subject: [PATCH 2/4] Code cleanup scePsmf --- Core/HLE/scePsmf.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index 5e90a31ba1..60df28c07c 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -57,6 +57,18 @@ int audioSamplesBytes = audioSamples * 4; int videoPixelMode = GE_CMODE_32BIT_ABGR8888; int videoLoopStatus = PSMF_PLAYER_CONFIG_NO_LOOP; +enum PsmfPlayerError { + ERROR_PSMF_NOT_INITIALIZED = 0x80615001, + ERROR_PSMF_BAD_VERSION = 0x80615002, + ERROR_PSMF_NOT_FOUND = 0x80615025, + ERROR_PSMF_INVALID_ID = 0x80615100, + ERROR_PSMF_INVALID_VALUE = 0x806151fe, + ERROR_PSMF_INVALID_TIMESTAMP = 0x80615500, + ERROR_PSMF_INVALID_PSMF = 0x80615501, + ERROR_PSMFPLAYER_NOT_INITIALIZED = 0x80616001, + ERROR_PSMFPLAYER_NO_MORE_DATA = 0x8061600c, +}; + enum PsmfPlayerStatus { PSMF_PLAYER_STATUS_NONE = 0x0, PSMF_PLAYER_STATUS_INIT = 0x1, @@ -898,7 +910,7 @@ int scePsmfPlayerStop(u32 psmfPlayer) int scePsmfPlayerBreak(u32 psmfPlayer) { - ERROR_LOG(ME, "UNIMPL scePsmfPlayerBreak(%08x)", psmfPlayer); + WARN_LOG(ME, "scePsmfPlayerBreak(%08x)", psmfPlayer); PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer); if (!psmfplayer) { ERROR_LOG(ME, "scePsmfPlayerBreak(%08x): invalid psmf player", psmfPlayer); @@ -1058,7 +1070,7 @@ int scePsmfPlayerGetAudioOutSize(u32 psmfPlayer) int scePsmfPlayerStart(u32 psmfPlayer, u32 psmfPlayerData, int initPts) { - WARN_LOG(ME, "UNIMPL scePsmfPlayerStart(%08x, %08x, %08x)", psmfPlayer, psmfPlayerData, initPts); + WARN_LOG(ME, "scePsmfPlayerStart(%08x, %08x, %08x)", psmfPlayer, psmfPlayerData, initPts); PsmfPlayer *psmfplayer = getPsmfPlayer(psmfPlayer); @@ -1169,7 +1181,7 @@ int scePsmfPlayerReleasePsmf(u32 psmfPlayer) return ERROR_PSMFPLAYER_NOT_INITIALIZED; } - ERROR_LOG(ME, "UNIMPL scePsmfPlayerReleasePsmf(%08x)", psmfPlayer); + WARN_LOG(ME, "scePsmfPlayerReleasePsmf(%08x)", psmfPlayer); psmfplayer->status = PSMF_PLAYER_STATUS_INIT; return 0; } From 8bef9c35e918328542b8a69acc3cbba06028dd1d Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 16 Feb 2014 23:22:25 +0800 Subject: [PATCH 3/4] Code cleanup #1 --- Core/HLE/sceMpeg.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Core/HLE/sceMpeg.h b/Core/HLE/sceMpeg.h index 4c3f0fb0e0..fd3cf35f48 100644 --- a/Core/HLE/sceMpeg.h +++ b/Core/HLE/sceMpeg.h @@ -27,34 +27,16 @@ enum { ERROR_MPEG_NO_MEMORY = 0x80610022, ERROR_MPEG_INVALID_ADDR = 0x80610103, ERROR_MPEG_INVALID_VALUE = 0x806101fe, - - ERROR_PSMF_NOT_INITIALIZED = 0x80615001, - ERROR_PSMF_BAD_VERSION = 0x80615002, - ERROR_PSMF_NOT_FOUND = 0x80615025, - ERROR_PSMF_INVALID_ID = 0x80615100, - ERROR_PSMF_INVALID_VALUE = 0x806151fe, - ERROR_PSMF_INVALID_TIMESTAMP = 0x80615500, - ERROR_PSMF_INVALID_PSMF = 0x80615501, - - ERROR_PSMFPLAYER_NOT_INITIALIZED = 0x80616001, - ERROR_PSMFPLAYER_NO_MORE_DATA = 0x8061600c, - ERROR_MPEG_NO_DATA = 0x80618001, ERROR_MPEG_ALREADY_INIT = 0x80618005, ERROR_MPEG_NOT_YET_INIT = 0x80618009, - ERROR_MPEG_AVC_INVALID_VALUE = 0x806201fe, ERROR_MPEG_AVC_DECODE_FATAL = 0x80628002, - ERROR_JPEG_INVALID_VALUE = 0x80650051, }; // MPEG statics. static const u32 PSMF_MAGIC = 0x464D5350; -static const int PSMF_VERSION_0012 = 0x32313030; -static const int PSMF_VERSION_0013 = 0x33313030; -static const int PSMF_VERSION_0014 = 0x34313030; -static const int PSMF_VERSION_0015 = 0x35313030; static const int PSMF_STREAM_VERSION_OFFSET = 0x4; static const int PSMF_STREAM_OFFSET_OFFSET = 0x8; static const int PSMF_STREAM_SIZE_OFFSET = 0xC; From db943fa3cc1ccc49a594428664cbcbf6f9d19766 Mon Sep 17 00:00:00 2001 From: raven02 Date: Sun, 16 Feb 2014 23:23:17 +0800 Subject: [PATCH 4/4] Add PSMF_VERSION_00XX --- Core/HLE/sceMpeg.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index e17f0b3c0b..0af7bc84db 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -51,6 +51,12 @@ static const int MPEG_VERSION_0013 = 1; static const int MPEG_VERSION_0014 = 2; static const int MPEG_VERSION_0015 = 3; +// PSMF analysis results. +static const int PSMF_VERSION_0012 = 0x32313030; +static const int PSMF_VERSION_0013 = 0x33313030; +static const int PSMF_VERSION_0014 = 0x34313030; +static const int PSMF_VERSION_0015 = 0x35313030; + // MPEG streams. static const int MPEG_AVC_STREAM = 0; static const int MPEG_ATRAC_STREAM = 1;