mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-16 16:21:03 +00:00
C-style cast cleanup IV
This commit is contained in:
parent
d45fbc331c
commit
bf11a28fb5
@ -298,7 +298,7 @@ public:
|
||||
{
|
||||
auto ptr = ::mmap(nullptr, max_size, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_32BIT, -1, 0);
|
||||
if (ptr != MAP_FAILED)
|
||||
found_segs[num_segs++] = Segment(ptr, u32(max_size));
|
||||
found_segs[num_segs++] = Segment(ptr, static_cast<u32>(max_size));
|
||||
else if (max_size > 0x1000000)
|
||||
max_size -= 0x1000000;
|
||||
else
|
||||
@ -314,7 +314,7 @@ public:
|
||||
{
|
||||
for (auto curr_size = max_size; (0x80000000u - curr_size) >= addr; curr_size += 0x1000000)
|
||||
{
|
||||
if (auto ptr = utils::memory_reserve(curr_size, (void*)addr))
|
||||
if (auto ptr = utils::memory_reserve(curr_size, reinterpret_cast<void*>(addr)))
|
||||
{
|
||||
if (max_addr == 0 || max_size < curr_size)
|
||||
{
|
||||
@ -331,8 +331,8 @@ public:
|
||||
if (max_addr == 0)
|
||||
break;
|
||||
|
||||
if (auto ptr = utils::memory_reserve(max_size, (void*)max_addr))
|
||||
found_segs[num_segs++] = Segment(ptr, u32(max_size));
|
||||
if (auto ptr = utils::memory_reserve(max_size, reinterpret_cast<void*>(max_addr)))
|
||||
found_segs[num_segs++] = Segment(ptr, static_cast<u32>(max_size));
|
||||
|
||||
start_addr = max_addr + max_size;
|
||||
}
|
||||
@ -353,7 +353,7 @@ public:
|
||||
|
||||
if (auto ptr = utils::memory_reserve(DEFAULT_SEGMENT_SIZE))
|
||||
{
|
||||
m_curr.addr = (u8*)ptr;
|
||||
m_curr.addr = static_cast<u8*>(ptr);
|
||||
m_curr.size = DEFAULT_SEGMENT_SIZE;
|
||||
m_curr.used = 0;
|
||||
}
|
||||
@ -378,7 +378,7 @@ public:
|
||||
store_curr();
|
||||
|
||||
u32 best_idx = UINT_MAX;
|
||||
for (u32 i = 0, segs_size = (u32)m_segs.size(); i < segs_size; i++)
|
||||
for (u32 i = 0, segs_size = ::size32(m_segs); i < segs_size; i++)
|
||||
{
|
||||
const auto seg_remaining = m_segs[i].remaining();
|
||||
if (seg_remaining < size)
|
||||
@ -393,7 +393,7 @@ public:
|
||||
const auto size_to_reserve = (size > DEFAULT_SEGMENT_SIZE) ? ::align(size+4096, 4096) : DEFAULT_SEGMENT_SIZE;
|
||||
if (auto ptr = utils::memory_reserve(size_to_reserve))
|
||||
{
|
||||
best_idx = (u32)m_segs.size();
|
||||
best_idx = ::size32(m_segs);
|
||||
m_segs.emplace_back(ptr, size_to_reserve);
|
||||
}
|
||||
else
|
||||
@ -407,17 +407,22 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::pair<u64, u32> current_segment() const { return std::make_pair(u64(m_curr.addr), m_curr.size); }
|
||||
std::pair<u64, u32> current_segment() const
|
||||
{
|
||||
return std::make_pair(reinterpret_cast<u64>(m_curr.addr), m_curr.size);
|
||||
}
|
||||
|
||||
std::pair<u64, u32> find_segment(u64 addr) const
|
||||
{
|
||||
for (const auto& seg: m_segs)
|
||||
{
|
||||
if (addr < (u64)seg.addr)
|
||||
const u64 seg_addr = reinterpret_cast<u64>(seg.addr);
|
||||
if (addr < seg_addr)
|
||||
continue;
|
||||
|
||||
const auto end_addr = u64(seg.addr) + seg.size;
|
||||
const auto end_addr = seg_addr + seg.size;
|
||||
if (addr < end_addr)
|
||||
return std::make_pair(u64(seg.addr), seg.size);
|
||||
return std::make_pair(seg_addr, seg.size);
|
||||
}
|
||||
|
||||
return std::make_pair(0, 0);
|
||||
@ -438,7 +443,10 @@ public:
|
||||
if (store_curr())
|
||||
m_curr = Segment();
|
||||
|
||||
auto allocated_it = std::remove_if(m_segs.begin(), m_segs.end(), [](const Segment& seg) { return u64(seg.addr + seg.size) > 0x80000000u; });
|
||||
auto allocated_it = std::remove_if(m_segs.begin(), m_segs.end(), [](const Segment& seg)
|
||||
{
|
||||
return reinterpret_cast<u64>(seg.addr + seg.size) > 0x80000000u;
|
||||
});
|
||||
if (allocated_it != m_segs.end())
|
||||
{
|
||||
for (auto it = allocated_it; it != m_segs.end(); ++it)
|
||||
@ -475,7 +483,10 @@ private:
|
||||
struct Segment
|
||||
{
|
||||
Segment() {}
|
||||
Segment(void* addr, u32 size) : addr((u8*)addr), size(size) {}
|
||||
Segment(void* addr, u32 size)
|
||||
: addr(static_cast<u8*>(addr))
|
||||
, size(size)
|
||||
{}
|
||||
|
||||
u8* addr = nullptr;
|
||||
u32 size = 0;
|
||||
@ -572,12 +583,12 @@ struct MemoryManager : llvm::RTDyldMemoryManager
|
||||
else
|
||||
{
|
||||
LOG_ERROR(GENERAL, "LLVM: Linkage failed: %s", name);
|
||||
addr = (u64)null;
|
||||
addr = reinterpret_cast<u64>(null);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify address for small code model
|
||||
const u64 code_start = u64(m_code_addr);
|
||||
const u64 code_start = reinterpret_cast<u64>(m_code_addr);
|
||||
const s64 addr_diff = addr - code_start;
|
||||
if (addr_diff < INT_MIN || addr_diff > INT_MAX)
|
||||
{
|
||||
@ -587,7 +598,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager
|
||||
// Allocate memory for trampolines
|
||||
if (m_tramps)
|
||||
{
|
||||
const s64 tramps_diff = u64(m_tramps) - code_start;
|
||||
const s64 tramps_diff = reinterpret_cast<u64>(m_tramps) - code_start;
|
||||
if (tramps_diff < INT_MIN || tramps_diff > INT_MAX)
|
||||
m_tramps = nullptr; //previously allocated trampoline section too far away now
|
||||
}
|
||||
@ -609,10 +620,10 @@ struct MemoryManager : llvm::RTDyldMemoryManager
|
||||
data[0x6] = 0x48; // MOV rax, imm64 (not executed)
|
||||
data[0x7] = 0xb8;
|
||||
std::memcpy(data.data() + 8, &addr, 8);
|
||||
addr = (u64)&data;
|
||||
addr = reinterpret_cast<u64>(&data);
|
||||
|
||||
// Reset pointer (memory page exhausted)
|
||||
if (((u64)m_tramps % 4096) == 0)
|
||||
if ((reinterpret_cast<u64>(m_tramps) % 4096) == 0)
|
||||
{
|
||||
m_tramps = nullptr;
|
||||
}
|
||||
@ -624,9 +635,9 @@ struct MemoryManager : llvm::RTDyldMemoryManager
|
||||
bool needsToReserveAllocationSpace() override { return true; }
|
||||
void reserveAllocationSpace(uintptr_t CodeSize, uint32_t CodeAlign, uintptr_t RODataSize, uint32_t RODataAlign, uintptr_t RWDataSize, uint32_t RWDataAlign) override
|
||||
{
|
||||
const u32 wanted_code_size = ::align(u32(CodeSize), std::min(4096u, CodeAlign));
|
||||
const u32 wanted_rodata_size = ::align(u32(RODataSize), std::min(4096u, RODataAlign));
|
||||
const u32 wanted_rwdata_size = ::align(u32(RWDataSize), std::min(4096u, RWDataAlign));
|
||||
const u32 wanted_code_size = ::align(static_cast<u32>(CodeSize), std::min(4096u, CodeAlign));
|
||||
const u32 wanted_rodata_size = ::align(static_cast<u32>(RODataSize), std::min(4096u, RODataAlign));
|
||||
const u32 wanted_rwdata_size = ::align(static_cast<u32>(RWDataSize), std::min(4096u, RWDataAlign));
|
||||
|
||||
// Lock memory manager
|
||||
std::lock_guard lock(s_mutex);
|
||||
@ -638,7 +649,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager
|
||||
u8* allocateCodeSection(std::uintptr_t size, uint align, uint sec_id, llvm::StringRef sec_name) override
|
||||
{
|
||||
void* ptr = nullptr;
|
||||
const u32 wanted_size = ::align(u32(size), 4096);
|
||||
const u32 wanted_size = ::align(static_cast<u32>(size), 4096);
|
||||
{
|
||||
// Lock memory manager
|
||||
std::lock_guard lock(s_mutex);
|
||||
@ -653,16 +664,16 @@ struct MemoryManager : llvm::RTDyldMemoryManager
|
||||
return nullptr;
|
||||
}
|
||||
utils::memory_commit(ptr, size, utils::protection::wx);
|
||||
m_code_addr = (u8*)ptr;
|
||||
m_code_addr = static_cast<u8*>(ptr);
|
||||
|
||||
LOG_NOTICE(GENERAL, "LLVM: Code section %u '%s' allocated -> %p (size=0x%llx, aligned 0x%x)", sec_id, sec_name.data(), ptr, size, align);
|
||||
return (u8*)ptr;
|
||||
return static_cast<u8*>(ptr);
|
||||
}
|
||||
|
||||
u8* allocateDataSection(std::uintptr_t size, uint align, uint sec_id, llvm::StringRef sec_name, bool is_ro) override
|
||||
{
|
||||
void* ptr = nullptr;
|
||||
const u32 wanted_size = ::align(u32(size), 4096);
|
||||
const u32 wanted_size = ::align(static_cast<u32>(size), 4096);
|
||||
{
|
||||
// Lock memory manager
|
||||
std::lock_guard lock(s_mutex);
|
||||
@ -684,7 +695,7 @@ struct MemoryManager : llvm::RTDyldMemoryManager
|
||||
utils::memory_commit(ptr, size);
|
||||
|
||||
LOG_NOTICE(GENERAL, "LLVM: Data section %u '%s' allocated -> %p (size=0x%llx, aligned 0x%x, %s)", sec_id, sec_name.data(), ptr, size, align, is_ro ? "ro" : "rw");
|
||||
return (u8*)ptr;
|
||||
return static_cast<u8*>(ptr);
|
||||
}
|
||||
|
||||
bool finalizeMemory(std::string* = nullptr) override
|
||||
@ -868,7 +879,7 @@ struct EventListener : llvm::JITEventListener
|
||||
|
||||
// Use current memory segment as a BASE, compute the difference
|
||||
const u64 segment_start = s_alloc.current_segment().first;
|
||||
const u64 code_diff = u64(m_mem.m_code_addr) - segment_start;
|
||||
const u64 code_diff = reinterpret_cast<u64>(m_mem.m_code_addr) - segment_start;
|
||||
|
||||
// Fix RUNTIME_FUNCTION records (.pdata section)
|
||||
for (auto& rf : rfs)
|
||||
|
@ -351,7 +351,7 @@ public:
|
||||
{
|
||||
fmt::throw_exception("avformat_alloc_context() failed" HERE);
|
||||
}
|
||||
io_buf = (u8*)av_malloc(4096);
|
||||
io_buf = static_cast<u8*>(av_malloc(4096));
|
||||
fmt->pb = avio_alloc_context(io_buf, 256, 0, this, adecRead, NULL, NULL);
|
||||
if (!fmt->pb)
|
||||
{
|
||||
@ -457,7 +457,7 @@ public:
|
||||
|
||||
if (size)
|
||||
{
|
||||
data = (u8*)av_calloc(1, size + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
data = static_cast<u8*>(av_calloc(1, size + AV_INPUT_BUFFER_PADDING_SIZE));
|
||||
this->size = size + AV_INPUT_BUFFER_PADDING_SIZE;
|
||||
}
|
||||
else
|
||||
@ -579,10 +579,10 @@ public:
|
||||
// frame.pts = ts/* - first_pts*/;
|
||||
// last_pts = frame.pts;
|
||||
//}
|
||||
last_pts += ((u64)frame.data->nb_samples) * 90000 / frame.data->sample_rate;
|
||||
last_pts += frame.data->nb_samples * 90000ull / frame.data->sample_rate;
|
||||
frame.pts = last_pts;
|
||||
|
||||
s32 nbps = av_get_bytes_per_sample((AVSampleFormat)frame.data->format);
|
||||
s32 nbps = av_get_bytes_per_sample(static_cast<AVSampleFormat>(frame.data->format));
|
||||
switch (frame.data->format)
|
||||
{
|
||||
case AV_SAMPLE_FMT_FLTP: break;
|
||||
@ -621,7 +621,7 @@ public:
|
||||
|
||||
default:
|
||||
{
|
||||
fmt::throw_exception("Unknown task(%d)" HERE, (u32)task.type);
|
||||
fmt::throw_exception("Unknown task(%d)" HERE, +task.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -632,7 +632,7 @@ public:
|
||||
|
||||
int adecRead(void* opaque, u8* buf, int buf_size)
|
||||
{
|
||||
AudioDecoder& adec = *(AudioDecoder*)opaque;
|
||||
AudioDecoder& adec = *static_cast<AudioDecoder*>(opaque);
|
||||
|
||||
int res = 0;
|
||||
|
||||
@ -642,7 +642,7 @@ next:
|
||||
u8 code1 = vm::read8(adec.reader.addr + 2);
|
||||
u8 code2 = vm::read8(adec.reader.addr + 3);
|
||||
adec.ch_cfg = (code1 >> 2) & 0x7;
|
||||
adec.frame_size = ((((u32)code1 & 0x3) << 8) | (u32)code2) * 8 + 8;
|
||||
adec.frame_size = (((u32{code1} & 0x3) << 8) | code2) * 8 + 8;
|
||||
adec.sample_rate = at3freq[code1 >> 5];
|
||||
|
||||
adec.reader.size -= 8;
|
||||
@ -668,7 +668,7 @@ next:
|
||||
adec.reader.init = true;
|
||||
}
|
||||
|
||||
if (adec.reader.size < (u32)buf_size /*&& !adec.just_started*/)
|
||||
if (adec.reader.size < static_cast<u32>(buf_size) /*&& !adec.just_started*/)
|
||||
{
|
||||
AdecTask task;
|
||||
if (!adec.job.peek(task, 0, &adec.is_closed))
|
||||
@ -707,7 +707,7 @@ next:
|
||||
|
||||
default:
|
||||
{
|
||||
cellAdec.error("adecRawRead(): unknown task (%d)", (u32)task.type);
|
||||
cellAdec.error("adecRawRead(): unknown task (%d)", +task.type);
|
||||
Emu.Pause();
|
||||
return -1;
|
||||
}
|
||||
@ -716,7 +716,7 @@ next:
|
||||
goto next;
|
||||
}
|
||||
// TODO:: Syphurith: I don't know whether we should keep this else-if now. Since the if condition is same with this one.
|
||||
else if (adec.reader.size < (u32)buf_size)
|
||||
else if (adec.reader.size < static_cast<u32>(buf_size))
|
||||
{
|
||||
buf_size = adec.reader.size;
|
||||
}
|
||||
@ -864,8 +864,10 @@ error_code cellAdecStartSeq(u32 handle, u32 param)
|
||||
task.at3p.output = atx->bw_pcm;
|
||||
task.at3p.downmix = atx->downmix_flag;
|
||||
task.at3p.ats_header = atx->au_includes_ats_hdr_flg;
|
||||
cellAdec.todo("*** CellAdecParamAtracX: sr=%d, ch_cfg=%d(%d), frame_size=0x%x, extra=0x%x, output=%d, downmix=%d, ats_header=%d",
|
||||
task.at3p.sample_rate, task.at3p.channel_config, task.at3p.channels, task.at3p.frame_size, (u32&)task.at3p.extra_config, task.at3p.output, task.at3p.downmix, task.at3p.ats_header);
|
||||
cellAdec.todo("*** CellAdecParamAtracX: sr=%d, ch_cfg=%d(%d), frame_size=0x%x, extra=%u:%u:%u:%u, output=%d, downmix=%d, ats_header=%d",
|
||||
task.at3p.sample_rate, task.at3p.channel_config, task.at3p.channels, task.at3p.frame_size,
|
||||
task.at3p.extra_config[0], task.at3p.extra_config[1], task.at3p.extra_config[2], task.at3p.extra_config[3],
|
||||
task.at3p.output, task.at3p.downmix, task.at3p.ats_header);
|
||||
break;
|
||||
}
|
||||
case CELL_ADEC_TYPE_MP3:
|
||||
@ -917,7 +919,7 @@ error_code cellAdecDecodeAu(u32 handle, vm::ptr<CellAdecAuInfo> auInfo)
|
||||
task.au.auInfo_addr = auInfo.addr();
|
||||
task.au.addr = auInfo->startAddr;
|
||||
task.au.size = auInfo->size;
|
||||
task.au.pts = ((u64)auInfo->pts.upper << 32) | (u64)auInfo->pts.lower;
|
||||
task.au.pts = (u64{auInfo->pts.upper} << 32) | u64{auInfo->pts.lower};
|
||||
task.au.userdata = auInfo->userData;
|
||||
|
||||
//cellAdec.notice("cellAdecDecodeAu(): addr=0x%x, size=0x%x, pts=0x%llx", task.au.addr, task.au.size, task.au.pts);
|
||||
@ -954,7 +956,7 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
|
||||
// reverse byte order:
|
||||
if (frame->format == AV_SAMPLE_FMT_FLTP && frame->channels == 1)
|
||||
{
|
||||
float* in_f = (float*)frame->extended_data[0];
|
||||
float* in_f = reinterpret_cast<float*>(frame->extended_data[0]);
|
||||
for (u32 i = 0; i < af.size / 4; i++)
|
||||
{
|
||||
outBuffer[i] = in_f[i];
|
||||
@ -963,8 +965,8 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
|
||||
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->channels == 2)
|
||||
{
|
||||
float* in_f[2];
|
||||
in_f[0] = (float*)frame->extended_data[0];
|
||||
in_f[1] = (float*)frame->extended_data[1];
|
||||
in_f[0] = reinterpret_cast<float*>(frame->extended_data[0]);
|
||||
in_f[1] = reinterpret_cast<float*>(frame->extended_data[1]);
|
||||
for (u32 i = 0; i < af.size / 8; i++)
|
||||
{
|
||||
outBuffer[i * 2 + 0] = in_f[0][i];
|
||||
@ -974,12 +976,12 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
|
||||
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->channels == 6)
|
||||
{
|
||||
float* in_f[6];
|
||||
in_f[0] = (float*)frame->extended_data[0];
|
||||
in_f[1] = (float*)frame->extended_data[1];
|
||||
in_f[2] = (float*)frame->extended_data[2];
|
||||
in_f[3] = (float*)frame->extended_data[3];
|
||||
in_f[4] = (float*)frame->extended_data[4];
|
||||
in_f[5] = (float*)frame->extended_data[5];
|
||||
in_f[0] = reinterpret_cast<float*>(frame->extended_data[0]);
|
||||
in_f[1] = reinterpret_cast<float*>(frame->extended_data[1]);
|
||||
in_f[2] = reinterpret_cast<float*>(frame->extended_data[2]);
|
||||
in_f[3] = reinterpret_cast<float*>(frame->extended_data[3]);
|
||||
in_f[4] = reinterpret_cast<float*>(frame->extended_data[4]);
|
||||
in_f[5] = reinterpret_cast<float*>(frame->extended_data[5]);
|
||||
for (u32 i = 0; i < af.size / 24; i++)
|
||||
{
|
||||
outBuffer[i * 6 + 0] = in_f[0][i];
|
||||
@ -993,14 +995,14 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
|
||||
else if (frame->format == AV_SAMPLE_FMT_FLTP && frame->channels == 8)
|
||||
{
|
||||
float* in_f[8];
|
||||
in_f[0] = (float*)frame->extended_data[0];
|
||||
in_f[1] = (float*)frame->extended_data[1];
|
||||
in_f[2] = (float*)frame->extended_data[2];
|
||||
in_f[3] = (float*)frame->extended_data[3];
|
||||
in_f[4] = (float*)frame->extended_data[4];
|
||||
in_f[5] = (float*)frame->extended_data[5];
|
||||
in_f[6] = (float*)frame->extended_data[6];
|
||||
in_f[7] = (float*)frame->extended_data[7];
|
||||
in_f[0] = reinterpret_cast<float*>(frame->extended_data[0]);
|
||||
in_f[1] = reinterpret_cast<float*>(frame->extended_data[1]);
|
||||
in_f[2] = reinterpret_cast<float*>(frame->extended_data[2]);
|
||||
in_f[3] = reinterpret_cast<float*>(frame->extended_data[3]);
|
||||
in_f[4] = reinterpret_cast<float*>(frame->extended_data[4]);
|
||||
in_f[5] = reinterpret_cast<float*>(frame->extended_data[5]);
|
||||
in_f[6] = reinterpret_cast<float*>(frame->extended_data[6]);
|
||||
in_f[7] = reinterpret_cast<float*>(frame->extended_data[7]);
|
||||
for (u32 i = 0; i < af.size / 24; i++)
|
||||
{
|
||||
outBuffer[i * 8 + 0] = in_f[0][i];
|
||||
@ -1015,21 +1017,21 @@ error_code cellAdecGetPcm(u32 handle, vm::ptr<float> outBuffer)
|
||||
}
|
||||
else if (frame->format == AV_SAMPLE_FMT_S16P && frame->channels == 1)
|
||||
{
|
||||
s16* in_i = (s16*)frame->extended_data[0];
|
||||
s16* in_i = reinterpret_cast<s16*>(frame->extended_data[0]);
|
||||
for (u32 i = 0; i < af.size / 2; i++)
|
||||
{
|
||||
outBuffer[i] = (float)in_i[i] / 0x8000;
|
||||
outBuffer[i] = in_i[i] / 32768.f;
|
||||
}
|
||||
}
|
||||
else if (frame->format == AV_SAMPLE_FMT_S16P && frame->channels == 2)
|
||||
{
|
||||
s16* in_i[2];
|
||||
in_i[0] = (s16*)frame->extended_data[0];
|
||||
in_i[1] = (s16*)frame->extended_data[1];
|
||||
in_i[0] = reinterpret_cast<s16*>(frame->extended_data[0]);
|
||||
in_i[1] = reinterpret_cast<s16*>(frame->extended_data[1]);
|
||||
for (u32 i = 0; i < af.size / 4; i++)
|
||||
{
|
||||
outBuffer[i * 2 + 0] = (float)in_i[0][i] / 0x8000;
|
||||
outBuffer[i * 2 + 1] = (float)in_i[1][i] / 0x8000;
|
||||
outBuffer[i * 2 + 0] = in_i[0][i] / 32768.f;
|
||||
outBuffer[i * 2 + 1] = in_i[1][i] / 32768.f;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1074,8 +1076,8 @@ error_code cellAdecGetPcmItem(u32 handle, vm::pptr<CellAdecPcmItem> pcmItem)
|
||||
pcm->startAddr = 0x00000312; // invalid address (no output)
|
||||
pcm->size = af.size;
|
||||
pcm->status = CELL_OK;
|
||||
pcm->auInfo.pts.lower = (u32)(af.pts);
|
||||
pcm->auInfo.pts.upper = (u32)(af.pts >> 32);
|
||||
pcm->auInfo.pts.lower = static_cast<u32>(af.pts);
|
||||
pcm->auInfo.pts.upper = static_cast<u32>(af.pts >> 32);
|
||||
pcm->auInfo.size = af.auSize;
|
||||
pcm->auInfo.startAddr = af.auAddr;
|
||||
pcm->auInfo.userData = af.userdata;
|
||||
|
@ -1119,7 +1119,7 @@ error_code cellAudioGetPortConfig(u32 portNum, vm::ptr<CellAudioPortConfig> port
|
||||
case audio_port_state::closed: portConfig->status = CELL_AUDIO_STATUS_CLOSE; break;
|
||||
case audio_port_state::opened: portConfig->status = CELL_AUDIO_STATUS_READY; break;
|
||||
case audio_port_state::started: portConfig->status = CELL_AUDIO_STATUS_RUN; break;
|
||||
default: fmt::throw_exception("Invalid port state (%d: %d)", portNum, (u32)state);
|
||||
default: fmt::throw_exception("Invalid port state (%d: %d)", portNum, static_cast<u32>(state));
|
||||
}
|
||||
|
||||
portConfig->nChannel = port.num_channels;
|
||||
@ -1152,7 +1152,7 @@ error_code cellAudioPortStart(u32 portNum)
|
||||
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
|
||||
case audio_port_state::started: return CELL_AUDIO_ERROR_PORT_ALREADY_RUN;
|
||||
case audio_port_state::opened: return CELL_OK;
|
||||
default: fmt::throw_exception("Invalid port state (%d: %d)", portNum, (u32)state);
|
||||
default: fmt::throw_exception("Invalid port state (%d: %d)", portNum, static_cast<u32>(state));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1179,7 +1179,7 @@ error_code cellAudioPortClose(u32 portNum)
|
||||
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_OPEN;
|
||||
case audio_port_state::started: return CELL_OK;
|
||||
case audio_port_state::opened: return CELL_OK;
|
||||
default: fmt::throw_exception("Invalid port state (%d: %d)", portNum, (u32)state);
|
||||
default: fmt::throw_exception("Invalid port state (%d: %d)", portNum, static_cast<u32>(state));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1206,7 +1206,7 @@ error_code cellAudioPortStop(u32 portNum)
|
||||
case audio_port_state::closed: return CELL_AUDIO_ERROR_PORT_NOT_RUN;
|
||||
case audio_port_state::started: return CELL_OK;
|
||||
case audio_port_state::opened: return CELL_AUDIO_ERROR_PORT_NOT_RUN;
|
||||
default: fmt::throw_exception("Invalid port state (%d: %d)", portNum, (u32)state);
|
||||
default: fmt::throw_exception("Invalid port state (%d: %d)", portNum, static_cast<u32>(state));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,14 +213,14 @@ error_code cellAudioInGetAvailableDeviceInfo(u32 count, vm::ptr<CellAudioInDevic
|
||||
|
||||
auto av_manager = g_fxo->get<avconf_manager>();
|
||||
|
||||
u32 num_devices_returned = std::min(count, (u32)av_manager->devices.size());
|
||||
u32 num_devices_returned = std::min<u32>(count, ::size32(av_manager->devices));
|
||||
|
||||
for (u32 index = 0; index < num_devices_returned; index++)
|
||||
{
|
||||
av_manager->copy_device_info(index, device_info + index);
|
||||
}
|
||||
|
||||
return not_an_error((s32)num_devices_returned);
|
||||
return not_an_error(num_devices_returned);
|
||||
}
|
||||
|
||||
error_code cellAudioOutGetAvailableDeviceInfo(u32 count, vm::ptr<CellAudioOutDeviceInfo2> info)
|
||||
|
@ -4,8 +4,6 @@
|
||||
|
||||
#include "cellBgdl.h"
|
||||
|
||||
|
||||
|
||||
LOG_CHANNEL(cellBGDL);
|
||||
|
||||
error_code cellBGDLGetInfo(vm::cptr<char> content_id, vm::ptr<CellBGDLInfo> info, s32 num)
|
||||
@ -22,7 +20,7 @@ error_code cellBGDLGetInfo2(vm::cptr<char> service_id, vm::ptr<CellBGDLInfo> inf
|
||||
|
||||
error_code cellBGDLSetMode(CellBGDLMode mode)
|
||||
{
|
||||
cellBGDL.todo("cellBGDLSetMode(mode=%d)", (s32) mode);
|
||||
cellBGDL.todo("cellBGDLSetMode(mode=%d)", +mode);
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ struct DemuxerStream
|
||||
{
|
||||
if (sizeof(T) > size) return false;
|
||||
|
||||
out = vm::_ref<T>(addr);
|
||||
std::memcpy(&out, vm::base(addr), sizeof(T));
|
||||
addr += sizeof(T);
|
||||
size -= sizeof(T);
|
||||
|
||||
@ -51,7 +51,7 @@ struct DemuxerStream
|
||||
{
|
||||
if (sizeof(T) + shift > size) return false;
|
||||
|
||||
out = vm::_ref<T>(addr + shift);
|
||||
std::memcpy(&out, vm::base(addr + shift), sizeof(T));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -68,12 +68,12 @@ struct DemuxerStream
|
||||
|
||||
u64 get_ts(u8 c)
|
||||
{
|
||||
u8 v[4]; get((u32&)v);
|
||||
u8 v[4]; get(v);
|
||||
return
|
||||
(((u64)c & 0x0e) << 29) |
|
||||
(((u64)v[0]) << 21) |
|
||||
(((u64)v[1] & 0x7e) << 15) |
|
||||
(((u64)v[2]) << 7) | ((u64)v[3] >> 1);
|
||||
((u64{c} & 0x0e) << 29) |
|
||||
((u64{v[0]}) << 21) |
|
||||
((u64{v[1]} & 0x7e) << 15) |
|
||||
((u64{v[2]}) << 7) | (u64{v[3]} >> 1);
|
||||
}
|
||||
};
|
||||
|
||||
@ -380,10 +380,10 @@ public:
|
||||
|
||||
if (data[0] != 0x0f || data[1] != 0xd0)
|
||||
{
|
||||
fmt::throw_exception("ATX: 0x0fd0 header not found (ats=0x%llx)" HERE, *(be_t<u64>*)data);
|
||||
fmt::throw_exception("ATX: 0x0fd0 header not found (ats=0x%llx)" HERE, *reinterpret_cast<be_t<u64>*>(data));
|
||||
}
|
||||
|
||||
u32 frame_size = ((((u32)data[2] & 0x3) << 8) | (u32)data[3]) * 8 + 8;
|
||||
u32 frame_size = (((u32{data[2]} & 0x3) << 8) | u32{data[3]}) * 8 + 8;
|
||||
|
||||
if (size < frame_size + 8) break; // skip non-complete AU
|
||||
|
||||
@ -445,7 +445,7 @@ public:
|
||||
{
|
||||
ElementaryStream& es = *esAVC[ch];
|
||||
|
||||
const u32 old_size = (u32)es.raw_data.size();
|
||||
const u32 old_size = ::size32(es.raw_data);
|
||||
if (es.isfull(old_size))
|
||||
{
|
||||
stream = backup;
|
||||
@ -611,7 +611,7 @@ public:
|
||||
{
|
||||
ElementaryStream& es = *task.es.es_ptr;
|
||||
|
||||
const u32 old_size = (u32)es.raw_data.size();
|
||||
const u32 old_size = ::size32(es.raw_data);
|
||||
if (old_size && (es.fidMajor & -0x10) == 0xe0)
|
||||
{
|
||||
// TODO (it's only for AVC, some ATX data may be lost)
|
||||
@ -634,7 +634,7 @@ public:
|
||||
|
||||
if (es.raw_data.size())
|
||||
{
|
||||
cellDmux.error("dmuxFlushEs: 0x%x bytes lost (es_id=%d)", (u32)es.raw_data.size(), es.id);
|
||||
cellDmux.error("dmuxFlushEs: 0x%x bytes lost (es_id=%d)", ::size32(es.raw_data), es.id);
|
||||
}
|
||||
|
||||
// callback
|
||||
@ -659,7 +659,7 @@ public:
|
||||
|
||||
default:
|
||||
{
|
||||
fmt::throw_exception("Demuxer thread error: unknown task (0x%x)" HERE, (u32)task.type);
|
||||
fmt::throw_exception("Demuxer thread error: unknown task (0x%x)" HERE, +task.type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -816,10 +816,10 @@ void ElementaryStream::push_au(u32 size, u64 dts, u64 pts, u64 userdata, bool ra
|
||||
auto info = vm::ptr<CellDmuxAuInfoEx>::make(put);
|
||||
info->auAddr = put + 128;
|
||||
info->auSize = size;
|
||||
info->dts.lower = (u32)(dts);
|
||||
info->dts.upper = (u32)(dts >> 32);
|
||||
info->pts.lower = (u32)(pts);
|
||||
info->pts.upper = (u32)(pts >> 32);
|
||||
info->dts.lower = static_cast<u32>(dts);
|
||||
info->dts.upper = static_cast<u32>(dts >> 32);
|
||||
info->pts.lower = static_cast<u32>(pts);
|
||||
info->pts.upper = static_cast<u32>(pts >> 32);
|
||||
info->isRap = rap;
|
||||
info->reserved = 0;
|
||||
info->userData = userdata;
|
||||
@ -830,10 +830,10 @@ void ElementaryStream::push_au(u32 size, u64 dts, u64 pts, u64 userdata, bool ra
|
||||
auto inf = vm::ptr<CellDmuxAuInfo>::make(put + 64);
|
||||
inf->auAddr = put + 128;
|
||||
inf->auSize = size;
|
||||
inf->dtsLower = (u32)(dts);
|
||||
inf->dtsUpper = (u32)(dts >> 32);
|
||||
inf->ptsLower = (u32)(pts);
|
||||
inf->ptsUpper = (u32)(pts >> 32);
|
||||
inf->dtsLower = static_cast<u32>(dts);
|
||||
inf->dtsUpper = static_cast<u32>(dts >> 32);
|
||||
inf->ptsLower = static_cast<u32>(pts);
|
||||
inf->ptsUpper = static_cast<u32>(pts >> 32);
|
||||
inf->auMaxSize = 0; // ?????
|
||||
inf->userData = userdata;
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/Cell/PPUModule.h"
|
||||
|
||||
// Defines STB_TRUETYPE_IMPLEMENTATION *once* before including stb_truetype.h (as noted in stb_truetype.h's comments)
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include <stb_truetype.h>
|
||||
|
||||
#include "cellFont.h"
|
||||
@ -51,7 +49,7 @@ s32 cellFontOpenFontMemory(vm::ptr<CellFontLibrary> library, u32 fontAddr, u32 f
|
||||
{
|
||||
cellFont.warning("cellFontOpenFontMemory(library=*0x%x, fontAddr=0x%x, fontSize=%d, subNum=%d, uniqueId=%d, font=*0x%x)", library, fontAddr, fontSize, subNum, uniqueId, font);
|
||||
|
||||
font->stbfont = (stbtt_fontinfo*)((u8*)&(font->stbfont) + sizeof(void*)); // hack: use next bytes of the struct
|
||||
font->stbfont = vm::_ptr<stbtt_fontinfo>(font.addr() + font.size()); // hack: use next bytes of the struct
|
||||
|
||||
if (!stbtt_InitFont(font->stbfont, vm::_ptr<unsigned char>(fontAddr), 0))
|
||||
return CELL_FONT_ERROR_FONT_OPEN_FAILED;
|
||||
@ -92,7 +90,7 @@ s32 cellFontOpenFontset(ppu_thread& ppu, vm::ptr<CellFontLibrary> library, vm::p
|
||||
}
|
||||
|
||||
std::string file;
|
||||
switch((u32)fontType->type)
|
||||
switch (fontType->type)
|
||||
{
|
||||
case CELL_FONT_TYPE_RODIN_SANS_SERIF_LATIN: file = "/dev_flash/data/font/SCE-PS3-RD-R-LATIN.TTF"; break;
|
||||
case CELL_FONT_TYPE_RODIN_SANS_SERIF_LIGHT_LATIN: file = "/dev_flash/data/font/SCE-PS3-RD-L-LATIN.TTF"; break;
|
||||
@ -321,22 +319,22 @@ s32 cellFontRenderCharGlyphImage(vm::ptr<CellFont> font, u32 code, vm::ptr<CellF
|
||||
s32 baseLineY;
|
||||
s32 ascent, descent, lineGap;
|
||||
stbtt_GetFontVMetrics(font->stbfont, &ascent, &descent, &lineGap);
|
||||
baseLineY = (int)((float)ascent * scale); // ???
|
||||
baseLineY = static_cast<int>(ascent * scale); // ???
|
||||
|
||||
// Move the rendered character to the surface
|
||||
unsigned char* buffer = vm::_ptr<unsigned char>(surface->buffer.addr());
|
||||
for (u32 ypos = 0; ypos < (u32)height; ypos++)
|
||||
for (u32 ypos = 0; ypos < static_cast<u32>(height); ypos++)
|
||||
{
|
||||
if ((u32)y + ypos + yoff + baseLineY >= (u32)surface->height)
|
||||
if (static_cast<u32>(y) + ypos + yoff + baseLineY >= static_cast<u32>(surface->height))
|
||||
break;
|
||||
|
||||
for (u32 xpos = 0; xpos < (u32)width; xpos++)
|
||||
for (u32 xpos = 0; xpos < static_cast<u32>(width); xpos++)
|
||||
{
|
||||
if ((u32)x + xpos >= (u32)surface->width)
|
||||
if (static_cast<u32>(x) + xpos >= static_cast<u32>(surface->width))
|
||||
break;
|
||||
|
||||
// TODO: There are some oddities in the position of the character in the final buffer
|
||||
buffer[((s32)y + ypos + yoff + baseLineY)*surface->width + (s32)x + xpos] = box[ypos * width + xpos];
|
||||
buffer[(static_cast<s32>(y) + ypos + yoff + baseLineY) * surface->width + static_cast<s32>(x) + xpos] = box[ypos * width + xpos];
|
||||
}
|
||||
}
|
||||
stbtt_FreeBitmap(box, 0);
|
||||
@ -407,9 +405,9 @@ s32 cellFontGetCharGlyphMetrics(vm::ptr<CellFont> font, u32 code, vm::ptr<CellFo
|
||||
// TODO: Add the rest of the information
|
||||
metrics->width = (x1-x0) * scale;
|
||||
metrics->height = (y1-y0) * scale;
|
||||
metrics->h_bearingX = (float)leftSideBearing * scale;
|
||||
metrics->h_bearingX = leftSideBearing * scale;
|
||||
metrics->h_bearingY = 0.f;
|
||||
metrics->h_advance = (float)advanceWidth * scale;
|
||||
metrics->h_advance = advanceWidth * scale;
|
||||
metrics->v_bearingX = 0.f;
|
||||
metrics->v_bearingY = 0.f;
|
||||
metrics->v_advance = 0.f;
|
||||
|
@ -572,7 +572,7 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr<char>
|
||||
|
||||
funcStat(ppu, cbResult, cbGet, cbSet);
|
||||
|
||||
switch ((s32)cbResult->result)
|
||||
switch (cbResult->result)
|
||||
{
|
||||
case CELL_GAMEDATA_CBRESULT_OK_CANCEL:
|
||||
{
|
||||
|
@ -105,8 +105,8 @@ s32 cellGifDecReadHeader(PMainHandle mainHandle, PSubHandle subHandle, PInfo inf
|
||||
}
|
||||
}
|
||||
|
||||
if (*(be_t<u32>*)buffer != 0x47494638 ||
|
||||
(*(le_t<u16>*)(buffer + 4) != 0x6139 && *(le_t<u16>*)(buffer + 4) != 0x6137)) // Error: The first 6 bytes are not a valid GIF signature
|
||||
if (*reinterpret_cast<be_t<u32>*>(buffer) != 0x47494638 ||
|
||||
(*reinterpret_cast<le_t<u16>*>(buffer + 4) != 0x6139 && *reinterpret_cast<le_t<u16>*>(buffer + 4) != 0x6137)) // Error: The first 6 bytes are not a valid GIF signature
|
||||
{
|
||||
return CELL_GIFDEC_ERROR_STREAM_FORMAT; // Surprisingly there is no error code related with headerss
|
||||
}
|
||||
@ -143,7 +143,7 @@ s32 cellGifDecSetParameter(PMainHandle mainHandle, PSubHandle subHandle, PInPara
|
||||
current_outParam.outputWidth = current_info.SWidth;
|
||||
current_outParam.outputHeight = current_info.SHeight;
|
||||
current_outParam.outputColorSpace = inParam->colorSpace;
|
||||
switch ((u32)current_outParam.outputColorSpace)
|
||||
switch (current_outParam.outputColorSpace)
|
||||
{
|
||||
case CELL_GIFDEC_RGBA:
|
||||
case CELL_GIFDEC_ARGB: current_outParam.outputComponents = 4; break;
|
||||
@ -169,8 +169,8 @@ s32 cellGifDecDecodeData(PMainHandle mainHandle, PSubHandle subHandle, vm::ptr<u
|
||||
|
||||
dataOutInfo->status = CELL_GIFDEC_DEC_STATUS_STOP;
|
||||
|
||||
const u32& fd = subHandle->fd;
|
||||
const u64& fileSize = subHandle->fileSize;
|
||||
const u32 fd = subHandle->fd;
|
||||
const u64 fileSize = subHandle->fileSize;
|
||||
const CellGifDecOutParam& current_outParam = subHandle->outParam;
|
||||
|
||||
//Copy the GIF file to a buffer
|
||||
@ -195,18 +195,18 @@ s32 cellGifDecDecodeData(PMainHandle mainHandle, PSubHandle subHandle, vm::ptr<u
|
||||
int width, height, actual_components;
|
||||
auto image = std::unique_ptr<unsigned char,decltype(&::free)>
|
||||
(
|
||||
stbi_load_from_memory(gif.get(), (s32)fileSize, &width, &height, &actual_components, 4),
|
||||
stbi_load_from_memory(gif.get(), ::narrow<int>(fileSize), &width, &height, &actual_components, 4),
|
||||
&::free
|
||||
);
|
||||
|
||||
if (!image)
|
||||
return CELL_GIFDEC_ERROR_STREAM_FORMAT;
|
||||
|
||||
const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine;
|
||||
const int bytesPerLine = static_cast<int>(dataCtrlParam->outputBytesPerLine);
|
||||
const char nComponents = 4;
|
||||
uint image_size = width * height * nComponents;
|
||||
|
||||
switch((u32)current_outParam.outputColorSpace)
|
||||
switch(current_outParam.outputColorSpace)
|
||||
{
|
||||
case CELL_GIFDEC_RGBA:
|
||||
{
|
||||
@ -233,7 +233,7 @@ s32 cellGifDecDecodeData(PMainHandle mainHandle, PSubHandle subHandle, vm::ptr<u
|
||||
{
|
||||
//TODO: find out if we can't do padding without an extra copy
|
||||
const int linesize = std::min(bytesPerLine, width * nComponents);
|
||||
char *output = (char *) malloc(linesize);
|
||||
const auto output = std::make_unique<char[]>(linesize);
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
@ -245,15 +245,14 @@ s32 cellGifDecDecodeData(PMainHandle mainHandle, PSubHandle subHandle, vm::ptr<u
|
||||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
memcpy(&data[dstOffset], output, linesize);
|
||||
std::memcpy(&data[dstOffset], output.get(), linesize);
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint* img = (uint*)new char[image_size];
|
||||
uint* source_current = (uint*)&(image.get()[0]);
|
||||
uint* dest_current = img;
|
||||
const auto img = std::make_unique<uint[]>(image_size);
|
||||
uint* source_current = reinterpret_cast<uint*>(image.get());
|
||||
uint* dest_current = img.get();
|
||||
for (uint i = 0; i < image_size / nComponents; i++)
|
||||
{
|
||||
uint val = *source_current;
|
||||
@ -261,8 +260,7 @@ s32 cellGifDecDecodeData(PMainHandle mainHandle, PSubHandle subHandle, vm::ptr<u
|
||||
source_current++;
|
||||
dest_current++;
|
||||
}
|
||||
memcpy(data.get_ptr(), img, image_size);
|
||||
delete[] img;
|
||||
std::memcpy(data.get_ptr(), img.get(), image_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -40,11 +40,11 @@ s32 cellHttpUtilParseUri(vm::ptr<CellHttpUri> uri, vm::cptr<char> str, vm::ptr<v
|
||||
}
|
||||
else
|
||||
{
|
||||
std::strncpy((char*)vm::base(pool.addr() + schemeOffset), (char*)scheme.c_str(), scheme.length() + 1);
|
||||
std::strncpy((char*)vm::base(pool.addr() + hostOffset), (char*)host.c_str(), host.length() + 1);
|
||||
std::strncpy((char*)vm::base(pool.addr() + pathOffset), (char*)path.c_str(), path.length() + 1);
|
||||
std::strncpy((char*)vm::base(pool.addr() + usernameOffset), (char*)username.c_str(), username.length() + 1);
|
||||
std::strncpy((char*)vm::base(pool.addr() + passwordOffset), (char*)password.c_str(), password.length() + 1);
|
||||
std::memcpy(vm::base(pool.addr() + schemeOffset), scheme.c_str(), scheme.length() + 1);
|
||||
std::memcpy(vm::base(pool.addr() + hostOffset), host.c_str(), host.length() + 1);
|
||||
std::memcpy(vm::base(pool.addr() + pathOffset), path.c_str(), path.length() + 1);
|
||||
std::memcpy(vm::base(pool.addr() + usernameOffset), username.c_str(), username.length() + 1);
|
||||
std::memcpy(vm::base(pool.addr() + passwordOffset), password.c_str(), password.length() + 1);
|
||||
|
||||
uri->scheme.set(pool.addr() + schemeOffset);
|
||||
uri->hostname.set(pool.addr() + hostOffset);
|
||||
@ -59,7 +59,7 @@ s32 cellHttpUtilParseUri(vm::ptr<CellHttpUri> uri, vm::cptr<char> str, vm::ptr<v
|
||||
}
|
||||
else
|
||||
{
|
||||
uri->port = (u32)80;
|
||||
uri->port = 80;
|
||||
}
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -118,8 +118,8 @@ s32 cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDecInfo>
|
||||
}
|
||||
}
|
||||
|
||||
if ((le_t<u32>&)(buffer[0]) != 0xE0FFD8FF || // Error: Not a valid SOI header
|
||||
(le_t<u32>&)(buffer[6]) != 0x4649464A) // Error: Not a valid JFIF string
|
||||
if (*reinterpret_cast<le_t<u32>*>(buffer.get()) != 0xE0FFD8FF || // Error: Not a valid SOI header
|
||||
*reinterpret_cast<u32*>(buffer.get() + 6) != "JFIF"_u32) // Error: Not a valid JFIF string
|
||||
{
|
||||
return CELL_JPGDEC_ERROR_HEADER;
|
||||
}
|
||||
@ -202,7 +202,7 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::cp
|
||||
int width, height, actual_components;
|
||||
auto image = std::unique_ptr<unsigned char,decltype(&::free)>
|
||||
(
|
||||
stbi_load_from_memory(jpg.get(), (s32)fileSize, &width, &height, &actual_components, 4),
|
||||
stbi_load_from_memory(jpg.get(), ::narrow<int>(fileSize), &width, &height, &actual_components, 4),
|
||||
&::free
|
||||
);
|
||||
|
||||
@ -210,10 +210,10 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::cp
|
||||
return CELL_JPGDEC_ERROR_STREAM_FORMAT;
|
||||
|
||||
const bool flip = current_outParam.outputMode == CELL_JPGDEC_BOTTOM_TO_TOP;
|
||||
const int bytesPerLine = (u32)dataCtrlParam->outputBytesPerLine;
|
||||
const int bytesPerLine = static_cast<int>(dataCtrlParam->outputBytesPerLine);
|
||||
size_t image_size = width * height;
|
||||
|
||||
switch((u32)current_outParam.outputColorSpace)
|
||||
switch(current_outParam.outputColorSpace)
|
||||
{
|
||||
case CELL_JPG_RGB:
|
||||
case CELL_JPG_RGBA:
|
||||
@ -245,7 +245,7 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::cp
|
||||
{
|
||||
//TODO: Find out if we can't do padding without an extra copy
|
||||
const int linesize = std::min(bytesPerLine, width * nComponents);
|
||||
char *output = (char *) malloc(linesize);
|
||||
const auto output = std::make_unique<char[]>(linesize);
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
const int dstOffset = i * bytesPerLine;
|
||||
@ -257,15 +257,14 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::cp
|
||||
output[j + 2] = image.get()[srcOffset + j + 1];
|
||||
output[j + 3] = image.get()[srcOffset + j + 2];
|
||||
}
|
||||
memcpy(&data[dstOffset], output, linesize);
|
||||
std::memcpy(&data[dstOffset], output.get(), linesize);
|
||||
}
|
||||
free(output);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint* img = (uint*)new char[image_size];
|
||||
uint* source_current = (uint*)&(image.get()[0]);
|
||||
uint* dest_current = img;
|
||||
const auto img = std::make_unique<uint[]>(image_size);
|
||||
uint* source_current = reinterpret_cast<uint*>(image.get());
|
||||
uint* dest_current = img.get();
|
||||
for (uint i = 0; i < image_size / nComponents; i++)
|
||||
{
|
||||
uint val = *source_current;
|
||||
@ -273,8 +272,7 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::cp
|
||||
source_current++;
|
||||
dest_current++;
|
||||
}
|
||||
memcpy(data.get_ptr(), img, image_size);
|
||||
delete[] img;
|
||||
std::memcpy(data.get_ptr(), img.get(), image_size);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -294,7 +292,7 @@ s32 cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data, vm::cp
|
||||
dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_FINISH;
|
||||
|
||||
if(dataCtrlParam->outputBytesPerLine)
|
||||
dataOutInfo->outputLines = (u32)(image_size / dataCtrlParam->outputBytesPerLine);
|
||||
dataOutInfo->outputLines = static_cast<u32>(image_size / dataCtrlParam->outputBytesPerLine);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
@ -324,7 +322,7 @@ s32 cellJpgDecSetParameter(u32 mainHandle, u32 subHandle, vm::cptr<CellJpgDecInP
|
||||
current_outParam.outputHeight = current_info.imageHeight;
|
||||
current_outParam.outputColorSpace = inParam->outputColorSpace;
|
||||
|
||||
switch ((u32)current_outParam.outputColorSpace)
|
||||
switch (current_outParam.outputColorSpace)
|
||||
{
|
||||
case CELL_JPG_GRAYSCALE: current_outParam.outputComponents = 1; break;
|
||||
|
||||
|
@ -290,7 +290,7 @@ error_code cellKbRead(u32 port_no, vm::ptr<CellKbData> data)
|
||||
KbData& current_data = handler->GetData(port_no);
|
||||
data->led = current_data.led;
|
||||
data->mkey = current_data.mkey;
|
||||
data->len = std::min((s32)CELL_KB_MAX_KEYCODES, current_data.len);
|
||||
data->len = std::min<s32>(CELL_KB_MAX_KEYCODES, current_data.len);
|
||||
|
||||
for (s32 i = 0; i < current_data.len; i++)
|
||||
{
|
||||
|
@ -243,7 +243,7 @@ error_code cellMouseGetDataList(u32 port_no, vm::ptr<CellMouseDataList> data)
|
||||
// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_MOUSE_MODE) has any impact
|
||||
|
||||
auto& list = handler->GetDataList(port_no);
|
||||
data->list_num = std::min((u32)CELL_MOUSE_MAX_DATA_LIST_NUM, (u32)list.size());
|
||||
data->list_num = std::min<u32>(CELL_MOUSE_MAX_DATA_LIST_NUM, static_cast<u32>(list.size()));
|
||||
|
||||
int i = 0;
|
||||
for (auto it = list.begin(); it != list.end() && i < CELL_MOUSE_MAX_DATA_LIST_NUM; ++it, ++i)
|
||||
@ -324,7 +324,7 @@ error_code cellMouseGetTabletDataList(u32 port_no, vm::ptr<CellMouseTabletDataLi
|
||||
// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_TABLET_MODE) has any impact
|
||||
|
||||
auto& list = handler->GetTabletDataList(port_no);
|
||||
data->list_num = std::min((u32)CELL_MOUSE_MAX_DATA_LIST_NUM, (u32)list.size());
|
||||
data->list_num = std::min<u32>(CELL_MOUSE_MAX_DATA_LIST_NUM, static_cast<u32>(list.size()));
|
||||
|
||||
int i = 0;
|
||||
for (auto it = list.begin(); it != list.end() && i < CELL_MOUSE_MAX_DATA_LIST_NUM; ++it, ++i)
|
||||
|
@ -89,14 +89,14 @@ void sys_spu_image::deploy(u32 loc, sys_spu_segment* segs, u32 nsegs)
|
||||
|
||||
fmt::append(dump, "\n\t[%d] t=0x%x, ls=0x%x, size=0x%x, addr=0x%x", i, seg.type, seg.ls, seg.size, seg.addr);
|
||||
|
||||
sha1_update(&sha, (uchar*)&seg.type, sizeof(seg.type));
|
||||
sha1_update(&sha, reinterpret_cast<uchar*>(&seg.type), sizeof(seg.type));
|
||||
|
||||
// Hash big-endian values
|
||||
if (seg.type == SYS_SPU_SEGMENT_TYPE_COPY)
|
||||
{
|
||||
std::memcpy(vm::base(loc + seg.ls), vm::base(seg.addr), seg.size);
|
||||
sha1_update(&sha, (uchar*)&seg.size, sizeof(seg.size));
|
||||
sha1_update(&sha, (uchar*)&seg.ls, sizeof(seg.ls));
|
||||
sha1_update(&sha, reinterpret_cast<uchar*>(&seg.size), sizeof(seg.size));
|
||||
sha1_update(&sha, reinterpret_cast<uchar*>(&seg.ls), sizeof(seg.ls));
|
||||
sha1_update(&sha, vm::_ptr<uchar>(seg.addr), seg.size);
|
||||
}
|
||||
else if (seg.type == SYS_SPU_SEGMENT_TYPE_FILL)
|
||||
@ -107,14 +107,14 @@ void sys_spu_image::deploy(u32 loc, sys_spu_segment* segs, u32 nsegs)
|
||||
}
|
||||
|
||||
std::fill_n(vm::_ptr<u32>(loc + seg.ls), seg.size / 4, seg.addr);
|
||||
sha1_update(&sha, (uchar*)&seg.size, sizeof(seg.size));
|
||||
sha1_update(&sha, (uchar*)&seg.ls, sizeof(seg.ls));
|
||||
sha1_update(&sha, (uchar*)&seg.addr, sizeof(seg.addr));
|
||||
sha1_update(&sha, reinterpret_cast<uchar*>(&seg.size), sizeof(seg.size));
|
||||
sha1_update(&sha, reinterpret_cast<uchar*>(&seg.ls), sizeof(seg.ls));
|
||||
sha1_update(&sha, reinterpret_cast<uchar*>(&seg.addr), sizeof(seg.addr));
|
||||
}
|
||||
else if (seg.type == SYS_SPU_SEGMENT_TYPE_INFO)
|
||||
{
|
||||
const be_t<u32> size = seg.size + 0x14; // Workaround
|
||||
sha1_update(&sha, (uchar*)&size, sizeof(size));
|
||||
sha1_update(&sha, reinterpret_cast<const uchar*>(&size), sizeof(size));
|
||||
}
|
||||
}
|
||||
|
||||
@ -881,9 +881,9 @@ error_code sys_spu_thread_write_ls(ppu_thread& ppu, u32 id, u32 lsa, u64 value,
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 1: thread->_ref<u8>(lsa) = (u8)value; break;
|
||||
case 2: thread->_ref<u16>(lsa) = (u16)value; break;
|
||||
case 4: thread->_ref<u32>(lsa) = (u32)value; break;
|
||||
case 1: thread->_ref<u8>(lsa) = static_cast<u8>(value); break;
|
||||
case 2: thread->_ref<u16>(lsa) = static_cast<u16>(value); break;
|
||||
case 4: thread->_ref<u32>(lsa) = static_cast<u32>(value); break;
|
||||
case 8: thread->_ref<u64>(lsa) = value; break;
|
||||
default: ASSUME(0);
|
||||
}
|
||||
@ -1235,7 +1235,7 @@ error_code sys_spu_thread_bind_queue(ppu_thread& ppu, u32 id, u32 spuq, u32 spuq
|
||||
continue;
|
||||
}
|
||||
|
||||
if (v.first == spuq_num ||
|
||||
if (v.first == spuq_num ||
|
||||
(!v.second.owner_before(queue) && !queue.owner_before(v.second)))
|
||||
{
|
||||
return CELL_EBUSY;
|
||||
@ -1747,7 +1747,7 @@ error_code sys_raw_spu_get_spu_cfg(ppu_thread& ppu, u32 id, vm::ptr<u32> value)
|
||||
return CELL_ESRCH;
|
||||
}
|
||||
|
||||
*value = (u32)thread->snr_config;
|
||||
*value = static_cast<u32>(thread->snr_config);
|
||||
|
||||
return CELL_OK;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void fmt_class_string<libusb_transfer>::format(std::string& out, u64 arg)
|
||||
datrace += ' ';
|
||||
}
|
||||
|
||||
fmt::append(out, "TR[r:%d][sz:%d] => %s", (u8)transfer.status, transfer.actual_length, datrace);
|
||||
fmt::append(out, "TR[r:%d][sz:%d] => %s", +transfer.status, transfer.actual_length, datrace);
|
||||
}
|
||||
|
||||
struct UsbLdd
|
||||
@ -46,7 +46,8 @@ struct UsbLdd
|
||||
struct UsbPipe
|
||||
{
|
||||
std::shared_ptr<usb_device> device = nullptr;
|
||||
u8 endpoint = 0;
|
||||
|
||||
u8 endpoint = 0;
|
||||
};
|
||||
|
||||
class usb_handler_thread
|
||||
@ -274,11 +275,11 @@ void usb_handler_thread::send_message(u32 message, u32 tr_id)
|
||||
|
||||
void usb_handler_thread::transfer_complete(struct libusb_transfer* transfer)
|
||||
{
|
||||
UsbTransfer* usbd_transfer = (UsbTransfer*)transfer->user_data;
|
||||
UsbTransfer* usbd_transfer = static_cast<UsbTransfer*>(transfer->user_data);
|
||||
|
||||
if (transfer->status != 0)
|
||||
{
|
||||
sys_usbd.error("Transfer Error: %d", (s32)transfer->status);
|
||||
sys_usbd.error("Transfer Error: %d", +transfer->status);
|
||||
}
|
||||
|
||||
switch (transfer->status)
|
||||
@ -324,13 +325,13 @@ u32 usb_handler_thread::add_ldd(vm::ptr<char> s_product, u16 slen_product, u16 i
|
||||
{
|
||||
UsbLdd new_ldd;
|
||||
new_ldd.name.resize(slen_product);
|
||||
memcpy(new_ldd.name.data(), s_product.get_ptr(), (u32)slen_product);
|
||||
memcpy(new_ldd.name.data(), s_product.get_ptr(), slen_product);
|
||||
new_ldd.id_vendor = id_vendor;
|
||||
new_ldd.id_product_min = id_product_min;
|
||||
new_ldd.id_product_max = id_product_max;
|
||||
ldds.push_back(new_ldd);
|
||||
|
||||
return (u32)ldds.size(); // TODO: to check
|
||||
return ::size32(ldds); // TODO: to check
|
||||
}
|
||||
|
||||
u32 usb_handler_thread::open_pipe(u32 device_handle, u8 endpoint)
|
||||
@ -341,7 +342,7 @@ u32 usb_handler_thread::open_pipe(u32 device_handle, u8 endpoint)
|
||||
|
||||
bool usb_handler_thread::close_pipe(u32 pipe_id)
|
||||
{
|
||||
return (bool)open_pipes.erase(pipe_id);
|
||||
return open_pipes.erase(pipe_id) != 0;
|
||||
}
|
||||
|
||||
bool usb_handler_thread::is_pipe(u32 pipe_id) const
|
||||
@ -482,7 +483,8 @@ s32 sys_usbd_get_device_list(u32 handle, vm::ptr<UsbInternalDevice> device_list,
|
||||
if (!usbh->is_init)
|
||||
return CELL_EINVAL;
|
||||
|
||||
u32 i_tocopy = std::min((s32)max_devices, (s32)usbh->handled_devices.size());
|
||||
// TODO: was std::min<s32>
|
||||
u32 i_tocopy = std::min<u32>(max_devices, ::size32(usbh->handled_devices));
|
||||
|
||||
for (u32 index = 0; index < i_tocopy; index++)
|
||||
{
|
||||
@ -538,7 +540,7 @@ s32 sys_usbd_get_descriptor(u32 handle, u32 device_handle, vm::ptr<void> descrip
|
||||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
u8* ptr = (u8*)descriptor.get_ptr();
|
||||
u8* ptr = static_cast<u8*>(descriptor.get_ptr());
|
||||
usbh->handled_devices[device_handle].second->device.write_data(ptr);
|
||||
|
||||
return CELL_OK;
|
||||
@ -572,7 +574,7 @@ s32 sys_usbd_open_pipe(u32 handle, u32 device_handle, u32 unk1, u64 unk2, u64 un
|
||||
return CELL_EINVAL;
|
||||
}
|
||||
|
||||
return usbh->open_pipe(device_handle, (u8)endpoint);
|
||||
return usbh->open_pipe(device_handle, static_cast<u8>(endpoint));
|
||||
}
|
||||
|
||||
s32 sys_usbd_open_default_pipe(u32 handle, u32 device_handle)
|
||||
@ -716,7 +718,7 @@ s32 sys_usbd_transfer_data(u32 handle, u32 id_pipe, vm::ptr<u8> buf, u32 buf_siz
|
||||
// Claiming interface
|
||||
if (request->bmRequestType == 0 && request->bRequest == 0x09)
|
||||
{
|
||||
pipe.device->set_configuration((u8)request->wValue);
|
||||
pipe.device->set_configuration(static_cast<u8>(+request->wValue));
|
||||
pipe.device->set_interface(0);
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ public:
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
for (u32 p = 0; p < (u32)m_mice.size(); ++p)
|
||||
for (u32 p = 0; p < m_mice.size(); ++p)
|
||||
{
|
||||
if (m_info.status[p] != CELL_MOUSE_STATUS_CONNECTED)
|
||||
{
|
||||
@ -186,7 +186,7 @@ public:
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
for (u32 p = 0; p < (u32)m_mice.size(); ++p)
|
||||
for (u32 p = 0; p < m_mice.size(); ++p)
|
||||
{
|
||||
if (m_info.status[p] != CELL_MOUSE_STATUS_CONNECTED)
|
||||
{
|
||||
@ -213,7 +213,7 @@ public:
|
||||
{
|
||||
std::lock_guard lock(mutex);
|
||||
|
||||
for (u32 p = 0; p < (u32)m_mice.size(); ++p)
|
||||
for (u32 p = 0; p < m_mice.size(); ++p)
|
||||
{
|
||||
if (m_info.status[p] != CELL_MOUSE_STATUS_CONNECTED)
|
||||
{
|
||||
|
@ -2,28 +2,21 @@
|
||||
// Defines STB_IMAGE_IMPLEMENTATION *once* for stb_image.h includes (Should this be placed somewhere else?)
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
|
||||
// This header generates lots of errors, so we ignore those (not rpcs3 code)
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Weverything"
|
||||
#include <stb_image.h>
|
||||
#pragma clang diagnostic pop
|
||||
// Sneak in truetype as well.
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
|
||||
#elif defined(__GNUC__) || defined(__GNUG__)
|
||||
// This header generates lots of errors, so we ignore those (not rpcs3 code)
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push, 0)
|
||||
#include <stb_image.h>
|
||||
#include <stb_truetype.h>
|
||||
#pragma warning(pop)
|
||||
#else
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wall"
|
||||
#pragma GCC diagnostic ignored "-Wextra"
|
||||
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||
#include <stb_image.h>
|
||||
#include <stb_truetype.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
// TODO Turn off warnings for MSVC. Using the normal push warning levels simply
|
||||
// creates a new warning about warnings being supressed (ie fuck msvc)
|
||||
// #pragma warning( push, 4 )
|
||||
#include <stb_image.h>
|
||||
// #pragma warning( pop )
|
||||
|
||||
#else
|
||||
#include <stb_image.h>
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user