mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-25 16:41:04 +00:00
Merge pull request #4797 from unknownbrackets/video-minor
Ignore bad video decode addresses.
This commit is contained in:
commit
8ecc161c7f
@ -668,7 +668,7 @@ u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr, u32 i
|
||||
DEBUG_LOG(ME, "*buffer = %08x, *init = %08x", buffer, init);
|
||||
|
||||
if (ctx->mediaengine->stepVideo(ctx->videoPixelMode)) {
|
||||
int bufferSize = ctx->mediaengine->writeVideoImage(Memory::GetPointer(buffer), frameWidth, ctx->videoPixelMode);
|
||||
int bufferSize = ctx->mediaengine->writeVideoImage(buffer, frameWidth, ctx->videoPixelMode);
|
||||
gpu->InvalidateCache(buffer, bufferSize, GPU_INVALIDATE_SAFE);
|
||||
ctx->avc.avcFrameStatus = 1;
|
||||
ctx->videoFrameCount++;
|
||||
@ -1256,7 +1256,7 @@ u32 sceMpegAtracDecode(u32 mpeg, u32 auAddr, u32 bufferAddr, int init)
|
||||
avcAu.read(auAddr);
|
||||
|
||||
Memory::Memset(bufferAddr, 0, MPEG_ATRAC_ES_OUTPUT_SIZE);
|
||||
ctx->mediaengine->getAudioSamples(Memory::GetPointer(bufferAddr));
|
||||
ctx->mediaengine->getAudioSamples(bufferAddr);
|
||||
avcAu.pts = ctx->mediaengine->getAudioTimeStamp() + ctx->mpegFirstTimestamp;
|
||||
|
||||
avcAu.write(auAddr);
|
||||
@ -1280,7 +1280,7 @@ u32 sceMpegAvcCsc(u32 mpeg, u32 sourceAddr, u32 rangeAddr, int frameWidth, u32 d
|
||||
int y = Memory::Read_U32(rangeAddr + 4);
|
||||
int width = Memory::Read_U32(rangeAddr + 8);
|
||||
int height = Memory::Read_U32(rangeAddr + 12);
|
||||
int destSize = ctx->mediaengine->writeVideoImageWithRange(Memory::GetPointer(destAddr), frameWidth, ctx->videoPixelMode,
|
||||
int destSize = ctx->mediaengine->writeVideoImageWithRange(destAddr, frameWidth, ctx->videoPixelMode,
|
||||
x, y, width, height);
|
||||
|
||||
gpu->InvalidateCache(destAddr, destSize, GPU_INVALIDATE_SAFE);
|
||||
|
@ -1019,7 +1019,7 @@ int scePsmfPlayerGetVideoData(u32 psmfPlayer, u32 videoDataAddr)
|
||||
u32 displaybuf = Memory::Read_U32(videoDataAddr + 4);
|
||||
int displaypts = Memory::Read_U32(videoDataAddr + 8);
|
||||
if (psmfplayer->mediaengine->stepVideo(videoPixelMode)) {
|
||||
int displaybufSize = psmfplayer->mediaengine->writeVideoImage(Memory::GetPointer(displaybuf), frameWidth, videoPixelMode);
|
||||
int displaybufSize = psmfplayer->mediaengine->writeVideoImage(displaybuf, frameWidth, videoPixelMode);
|
||||
gpu->InvalidateCache(displaybuf, displaybufSize, GPU_INVALIDATE_SAFE);
|
||||
}
|
||||
psmfplayer->psmfPlayerAvcAu.pts = psmfplayer->mediaengine->getVideoTimeStamp();
|
||||
@ -1050,7 +1050,7 @@ int scePsmfPlayerGetAudioData(u32 psmfPlayer, u32 audioDataAddr)
|
||||
DEBUG_LOG(ME, "scePsmfPlayerGetAudioData(%08x, %08x)", psmfPlayer, audioDataAddr);
|
||||
if (Memory::IsValidAddress(audioDataAddr)) {
|
||||
Memory::Memset(audioDataAddr, 0, audioSamplesBytes);
|
||||
psmfplayer->mediaengine->getAudioSamples(Memory::GetPointer(audioDataAddr));
|
||||
psmfplayer->mediaengine->getAudioSamples(audioDataAddr);
|
||||
}
|
||||
int ret = psmfplayer->mediaengine->IsNoAudioData() ? (int)ERROR_PSMFPLAYER_NO_MORE_DATA : 0;
|
||||
return hleDelayResult(ret, "psmfPlayer audio decode", 3000);
|
||||
|
@ -495,7 +495,15 @@ inline void writeVideoLineABGR4444(void *destp, const void *srcp, int width) {
|
||||
}
|
||||
}
|
||||
|
||||
int MediaEngine::writeVideoImage(u8* buffer, int frameWidth, int videoPixelMode) {
|
||||
int MediaEngine::writeVideoImage(u32 bufferPtr, int frameWidth, int videoPixelMode) {
|
||||
if (!Memory::IsValidAddress(bufferPtr) || frameWidth > 2048) {
|
||||
// Clearly invalid values. Let's just not.
|
||||
ERROR_LOG_REPORT(ME, "Ignoring invalid video decode address %08x/%x", bufferPtr, frameWidth);
|
||||
return false;
|
||||
}
|
||||
|
||||
u8 *buffer = Memory::GetPointer(bufferPtr);
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
if ((!m_pFrame)||(!m_pFrameRGB))
|
||||
return false;
|
||||
@ -544,7 +552,7 @@ int MediaEngine::writeVideoImage(u8* buffer, int frameWidth, int videoPixelMode)
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(ME, "Unsupported video pixel format %d", videoPixelMode);
|
||||
ERROR_LOG_REPORT(ME, "Unsupported video pixel format %d", videoPixelMode);
|
||||
break;
|
||||
}
|
||||
return videoImageSize;
|
||||
@ -552,8 +560,16 @@ int MediaEngine::writeVideoImage(u8* buffer, int frameWidth, int videoPixelMode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MediaEngine::writeVideoImageWithRange(u8* buffer, int frameWidth, int videoPixelMode,
|
||||
int MediaEngine::writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int videoPixelMode,
|
||||
int xpos, int ypos, int width, int height) {
|
||||
if (!Memory::IsValidAddress(bufferPtr) || frameWidth > 2048) {
|
||||
// Clearly invalid values. Let's just not.
|
||||
ERROR_LOG_REPORT(ME, "Ignoring invalid video decode address %08x/%x", bufferPtr, frameWidth);
|
||||
return false;
|
||||
}
|
||||
|
||||
u8 *buffer = Memory::GetPointer(bufferPtr);
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
if ((!m_pFrame)||(!m_pFrameRGB))
|
||||
return false;
|
||||
@ -631,7 +647,12 @@ int MediaEngine::getRemainSize() {
|
||||
return std::max(m_pdata->getRemainSize() - m_decodingsize - 2048, 0);
|
||||
}
|
||||
|
||||
int MediaEngine::getAudioSamples(u8* buffer) {
|
||||
int MediaEngine::getAudioSamples(u32 bufferPtr) {
|
||||
if (!Memory::IsValidAddress(bufferPtr)) {
|
||||
ERROR_LOG_REPORT(ME, "Ignoring bad audio decode address %08x during video playback", bufferPtr);
|
||||
}
|
||||
|
||||
u8 *buffer = Memory::GetPointer(bufferPtr);
|
||||
if (!m_demux) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -71,10 +71,10 @@ public:
|
||||
int getRemainSize();
|
||||
|
||||
bool stepVideo(int videoPixelMode);
|
||||
int writeVideoImage(u8* buffer, int frameWidth = 512, int videoPixelMode = 3);
|
||||
int writeVideoImageWithRange(u8* buffer, int frameWidth, int videoPixelMode,
|
||||
int writeVideoImage(u32 bufferPtr, int frameWidth = 512, int videoPixelMode = 3);
|
||||
int writeVideoImageWithRange(u32 bufferPtr, int frameWidth, int videoPixelMode,
|
||||
int xpos, int ypos, int width, int height);
|
||||
int getAudioSamples(u8* buffer);
|
||||
int getAudioSamples(u32 bufferPtr);
|
||||
|
||||
bool setVideoDim(int width = 0, int height = 0);
|
||||
s64 getVideoTimeStamp();
|
||||
|
Loading…
x
Reference in New Issue
Block a user