mirror of
https://github.com/libretro/RetroArch
synced 2025-02-18 18:40:06 +00:00
Style nits/conventions
This commit is contained in:
parent
0be8fe8e3f
commit
91aa8034b1
@ -394,25 +394,24 @@ static void cheat_manager_load_cb_first_pass(char *key, char *value)
|
||||
}
|
||||
}
|
||||
|
||||
static void cheat_manager_load_cb_second_pass(char *key, char *value)
|
||||
static void cheat_manager_load_cb_second_pass(char *s, char *value)
|
||||
{
|
||||
size_t _len;
|
||||
char cheat_num_str[20];
|
||||
unsigned cheat_num;
|
||||
unsigned cheat_idx;
|
||||
unsigned cheat_num, cheat_idx;
|
||||
unsigned idx = 5;
|
||||
size_t key_length = 0;
|
||||
cheat_manager_t *cheat_st = &cheat_manager_state;
|
||||
|
||||
errno = 0;
|
||||
|
||||
if (strncmp(key, "cheat", 5) != 0)
|
||||
if (strncmp(s, "cheat", 5) != 0)
|
||||
return;
|
||||
|
||||
key_length = strlen((const char*)key);
|
||||
_len = strlen((const char*)s);
|
||||
|
||||
while (idx < key_length && key[idx] >= '0' && key[idx] <= '9' && idx < 24)
|
||||
while (idx < _len && s[idx] >= '0' && s[idx] <= '9' && idx < 24)
|
||||
{
|
||||
cheat_num_str[idx - 5] = key[idx];
|
||||
cheat_num_str[idx - 5] = s[idx];
|
||||
idx++;
|
||||
}
|
||||
|
||||
@ -423,55 +422,55 @@ static void cheat_manager_load_cb_second_pass(char *key, char *value)
|
||||
if (cheat_num + cheat_st->loading_cheat_offset >= cheat_st->size)
|
||||
return;
|
||||
|
||||
key = key + idx + 1;
|
||||
s = s + idx + 1;
|
||||
|
||||
cheat_idx = cheat_num + cheat_st->loading_cheat_offset;
|
||||
|
||||
if (string_is_equal(key, "address"))
|
||||
if (string_is_equal(s, "address"))
|
||||
cheat_st->cheats[cheat_idx].address = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "address_bit_position"))
|
||||
else if (string_is_equal(s, "address_bit_position"))
|
||||
cheat_st->cheats[cheat_idx].address_mask = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "big_endian"))
|
||||
else if (string_is_equal(s, "big_endian"))
|
||||
cheat_st->cheats[cheat_idx].big_endian = (string_is_equal(value, "true") || string_is_equal(value, "1"));
|
||||
else if (string_is_equal(key, "cheat_type"))
|
||||
else if (string_is_equal(s, "cheat_type"))
|
||||
cheat_st->cheats[cheat_idx].cheat_type = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "code"))
|
||||
else if (string_is_equal(s, "code"))
|
||||
cheat_st->cheats[cheat_idx].code = strdup(value);
|
||||
else if (string_is_equal(key, "desc"))
|
||||
else if (string_is_equal(s, "desc"))
|
||||
cheat_st->cheats[cheat_idx].desc = strdup(value);
|
||||
else if (string_is_equal(key, "enable"))
|
||||
else if (string_is_equal(s, "enable"))
|
||||
cheat_st->cheats[cheat_idx].state = (string_is_equal(value, "true") || string_is_equal(value, "1"));
|
||||
else if (string_is_equal(key, "handler"))
|
||||
else if (string_is_equal(s, "handler"))
|
||||
cheat_st->cheats[cheat_idx].handler = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "memory_search_size"))
|
||||
else if (string_is_equal(s, "memory_search_size"))
|
||||
cheat_st->cheats[cheat_idx].memory_search_size = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_starts_with_size(key, "repeat_", STRLEN_CONST("repeat_")))
|
||||
else if (string_starts_with_size(s, "repeat_", STRLEN_CONST("repeat_")))
|
||||
{
|
||||
if (string_is_equal(key, "repeat_add_to_address"))
|
||||
if (string_is_equal(s, "repeat_add_to_address"))
|
||||
cheat_st->cheats[cheat_idx].repeat_add_to_address = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "repeat_add_to_value"))
|
||||
else if (string_is_equal(s, "repeat_add_to_value"))
|
||||
cheat_st->cheats[cheat_idx].repeat_add_to_value = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "repeat_count"))
|
||||
else if (string_is_equal(s, "repeat_count"))
|
||||
cheat_st->cheats[cheat_idx].repeat_count = (unsigned)strtoul(value, NULL, 0);
|
||||
}
|
||||
else if (string_starts_with_size(key, "rumble", STRLEN_CONST("rumble")))
|
||||
else if (string_starts_with_size(s, "rumble", STRLEN_CONST("rumble")))
|
||||
{
|
||||
if (string_is_equal(key, "rumble_port"))
|
||||
if (string_is_equal(s, "rumble_port"))
|
||||
cheat_st->cheats[cheat_idx].rumble_port = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "rumble_primary_duration"))
|
||||
else if (string_is_equal(s, "rumble_primary_duration"))
|
||||
cheat_st->cheats[cheat_idx].rumble_primary_duration = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "rumble_primary_strength"))
|
||||
else if (string_is_equal(s, "rumble_primary_strength"))
|
||||
cheat_st->cheats[cheat_idx].rumble_primary_strength = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "rumble_secondary_duration"))
|
||||
else if (string_is_equal(s, "rumble_secondary_duration"))
|
||||
cheat_st->cheats[cheat_idx].rumble_secondary_duration = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "rumble_secondary_strength"))
|
||||
else if (string_is_equal(s, "rumble_secondary_strength"))
|
||||
cheat_st->cheats[cheat_idx].rumble_secondary_strength = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "rumble_type"))
|
||||
else if (string_is_equal(s, "rumble_type"))
|
||||
cheat_st->cheats[cheat_idx].rumble_type = (unsigned)strtoul(value, NULL, 0);
|
||||
else if (string_is_equal(key, "rumble_value"))
|
||||
else if (string_is_equal(s, "rumble_value"))
|
||||
cheat_st->cheats[cheat_idx].rumble_value = (unsigned)strtoul(value, NULL, 0);
|
||||
}
|
||||
else if (string_is_equal(key, "value"))
|
||||
else if (string_is_equal(s, "value"))
|
||||
cheat_st->cheats[cheat_idx].value = (unsigned)strtoul(value, NULL, 0);
|
||||
}
|
||||
|
||||
@ -708,8 +707,7 @@ bool cheat_manager_get_code_state(unsigned i)
|
||||
|
||||
static size_t cheat_manager_get_game_specific_filename(
|
||||
char *s, size_t len,
|
||||
const char *path_cheat_database,
|
||||
bool saving)
|
||||
const char *path_cheat_database, bool saving)
|
||||
{
|
||||
char s1[PATH_MAX_LENGTH];
|
||||
struct retro_system_info sysinfo;
|
||||
|
@ -38,29 +38,29 @@
|
||||
#include <audio/conversion/float_to_s16.h>
|
||||
#include <audio/conversion/s16_to_float.h>
|
||||
|
||||
void audio_mix_volume_C(float *out, const float *in, float vol, size_t samples)
|
||||
void audio_mix_volume_C(float *s, const float *in, float vol, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < samples; i++)
|
||||
out[i] += in[i] * vol;
|
||||
for (i = 0; i < len; i++)
|
||||
s[i] += in[i] * vol;
|
||||
}
|
||||
|
||||
#ifdef __SSE2__
|
||||
void audio_mix_volume_SSE2(float *out, const float *in, float vol, size_t samples)
|
||||
void audio_mix_volume_SSE2(float *s, const float *in, float vol, size_t len)
|
||||
{
|
||||
size_t i, remaining_samples;
|
||||
__m128 volume = _mm_set1_ps(vol);
|
||||
|
||||
for (i = 0; i + 16 <= samples; i += 16, out += 16, in += 16)
|
||||
for (i = 0; i + 16 <= len; i += 16, s += 16, in += 16)
|
||||
{
|
||||
unsigned j;
|
||||
__m128 input[4];
|
||||
__m128 additive[4];
|
||||
|
||||
input[0] = _mm_loadu_ps(out + 0);
|
||||
input[1] = _mm_loadu_ps(out + 4);
|
||||
input[2] = _mm_loadu_ps(out + 8);
|
||||
input[3] = _mm_loadu_ps(out + 12);
|
||||
input[0] = _mm_loadu_ps(s + 0);
|
||||
input[1] = _mm_loadu_ps(s + 4);
|
||||
input[2] = _mm_loadu_ps(s + 8);
|
||||
input[3] = _mm_loadu_ps(s + 12);
|
||||
|
||||
additive[0] = _mm_mul_ps(volume, _mm_loadu_ps(in + 0));
|
||||
additive[1] = _mm_mul_ps(volume, _mm_loadu_ps(in + 4));
|
||||
@ -68,13 +68,13 @@ void audio_mix_volume_SSE2(float *out, const float *in, float vol, size_t sample
|
||||
additive[3] = _mm_mul_ps(volume, _mm_loadu_ps(in + 12));
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
_mm_storeu_ps(out + 4 * j, _mm_add_ps(input[j], additive[j]));
|
||||
_mm_storeu_ps(s + 4 * j, _mm_add_ps(input[j], additive[j]));
|
||||
}
|
||||
|
||||
remaining_samples = samples - i;
|
||||
remaining_samples = len - i;
|
||||
|
||||
for (i = 0; i < remaining_samples; i++)
|
||||
out[i] += in[i] * vol;
|
||||
s[i] += in[i] * vol;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -205,12 +205,12 @@ static unsigned s_rate = 0;
|
||||
static void audio_mixer_release(audio_mixer_voice_t* voice);
|
||||
|
||||
#ifdef HAVE_RWAV
|
||||
static bool wav_to_float(const rwav_t* wav, float** pcm, size_t samples_out)
|
||||
static bool wav_to_float(const rwav_t* wav, float** pcm, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
/* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes */
|
||||
float *f = (float*)memalign_alloc(16,
|
||||
((samples_out + 15) & ~15) * sizeof(float));
|
||||
((len + 15) & ~15) * sizeof(float));
|
||||
|
||||
if (!f)
|
||||
return false;
|
||||
|
@ -34,28 +34,26 @@
|
||||
#if (defined(__ARM_NEON__) || defined(HAVE_NEON))
|
||||
static bool float_to_s16_neon_enabled = false;
|
||||
#ifdef HAVE_ARM_NEON_ASM_OPTIMIZATIONS
|
||||
void convert_float_s16_asm(int16_t *out,
|
||||
const float *in, size_t samples);
|
||||
void convert_float_s16_asm(int16_t *s, const float *in, size_t len);
|
||||
#else
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
void convert_float_to_s16(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
void convert_float_to_s16(int16_t *s, const float *in, size_t len)
|
||||
{
|
||||
size_t i = 0;
|
||||
if (float_to_s16_neon_enabled)
|
||||
{
|
||||
float gf = (1<<15);
|
||||
float32x4_t vgf = {gf, gf, gf, gf};
|
||||
while (samples >= 8)
|
||||
while (len >= 8)
|
||||
{
|
||||
#ifdef HAVE_ARM_NEON_ASM_OPTIMIZATIONS
|
||||
size_t aligned_samples = samples & ~7;
|
||||
size_t aligned_samples = len & ~7;
|
||||
if (aligned_samples)
|
||||
convert_float_s16_asm(out, in, aligned_samples);
|
||||
convert_float_s16_asm(s, in, aligned_samples);
|
||||
|
||||
out += aligned_samples;
|
||||
s += aligned_samples;
|
||||
in += aligned_samples;
|
||||
samples -= aligned_samples;
|
||||
i = 0;
|
||||
@ -67,18 +65,18 @@ void convert_float_to_s16(int16_t *out,
|
||||
creg.val[1] = vcvtq_s32_f32(vmulq_f32(inreg.val[1], vgf));
|
||||
oreg.val[0] = vqmovn_s32(creg.val[0]);
|
||||
oreg.val[1] = vqmovn_s32(creg.val[1]);
|
||||
vst2_s16(out, oreg);
|
||||
vst2_s16(s, oreg);
|
||||
in += 8;
|
||||
out += 8;
|
||||
samples -= 8;
|
||||
s += 8;
|
||||
len -= 8;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < samples; i++)
|
||||
for (; i < len; i++)
|
||||
{
|
||||
int32_t val = (int32_t)(in[i] * 0x8000);
|
||||
out[i] = (val > 0x7FFF) ? 0x7FFF :
|
||||
s[i] = (val > 0x7FFF) ? 0x7FFF :
|
||||
(val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||
}
|
||||
}
|
||||
@ -91,15 +89,14 @@ void convert_float_to_s16_init_simd(void)
|
||||
float_to_s16_neon_enabled = true;
|
||||
}
|
||||
#else
|
||||
void convert_float_to_s16(int16_t *out,
|
||||
const float *in, size_t samples)
|
||||
void convert_float_to_s16(int16_t *s, const float *in, size_t len)
|
||||
{
|
||||
size_t i = 0;
|
||||
#if defined(__SSE2__)
|
||||
__m128 factor = _mm_set1_ps((float)0x8000);
|
||||
/* Initialize a 4D vector with 32768.0 for its elements */
|
||||
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
for (i = 0; i + 8 <= len; i += 8, in += 8, s += 8)
|
||||
{ /* Skip forward 8 samples at a time... */
|
||||
__m128 input_a = _mm_loadu_ps(in + 0); /* Create a 4-float vector from the next four samples... */
|
||||
__m128 input_b = _mm_loadu_ps(in + 4); /* ...and another from the *next* next four. */
|
||||
@ -109,34 +106,34 @@ void convert_float_to_s16(int16_t *out,
|
||||
__m128i ints_b = _mm_cvtps_epi32(res_b); /* Convert the samples to 32-bit integers */
|
||||
__m128i packed = _mm_packs_epi32(ints_a, ints_b); /* Then convert them to 16-bit ints, clamping to [-32768, 32767] */
|
||||
|
||||
_mm_storeu_si128((__m128i *)out, packed); /* Then put the result in the output array */
|
||||
_mm_storeu_si128((__m128i *)s, packed); /* Then put the result in the output array */
|
||||
}
|
||||
|
||||
samples = samples - i;
|
||||
len = len - i;
|
||||
i = 0;
|
||||
/* If there are any stray samples at the end, we need to convert them
|
||||
* (maybe the original array didn't contain a multiple of 8 samples) */
|
||||
#elif defined(__ALTIVEC__)
|
||||
int samples_in = samples;
|
||||
int samples_in = len;
|
||||
|
||||
/* Unaligned loads/store is a bit expensive,
|
||||
* so we optimize for the good path (very likely). */
|
||||
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
||||
if (((uintptr_t)s & 15) + ((uintptr_t)in & 15) == 0)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
for (i = 0; i + 8 <= len; i += 8, in += 8, s += 8)
|
||||
{
|
||||
vector float input0 = vec_ld( 0, in);
|
||||
vector float input1 = vec_ld(16, in);
|
||||
vector signed int result0 = vec_cts(input0, 15);
|
||||
vector signed int result1 = vec_cts(input1, 15);
|
||||
vec_st(vec_packs(result0, result1), 0, out);
|
||||
vec_st(vec_packs(result0, result1), 0, s);
|
||||
}
|
||||
|
||||
samples_in -= i;
|
||||
}
|
||||
|
||||
samples = samples_in;
|
||||
len = samples_in;
|
||||
i = 0;
|
||||
#elif defined(_MIPS_ARCH_ALLEGREX)
|
||||
#ifdef DEBUG
|
||||
@ -144,10 +141,10 @@ void convert_float_to_s16(int16_t *out,
|
||||
* the default behaviour of malloc in the PSPSDK.
|
||||
* Assume alignment. */
|
||||
retro_assert(((uintptr_t)in & 0xf) == 0);
|
||||
retro_assert(((uintptr_t)out & 0xf) == 0);
|
||||
retro_assert(((uintptr_t)s & 0xf) == 0);
|
||||
#endif
|
||||
|
||||
for (i = 0; i + 8 <= samples; i += 8)
|
||||
for (i = 0; i + 8 <= len; i += 8)
|
||||
{
|
||||
__asm__ (
|
||||
".set push \n"
|
||||
@ -164,16 +161,16 @@ void convert_float_to_s16(int16_t *out,
|
||||
"sv.q c100, 0(%1) \n"
|
||||
|
||||
".set pop \n"
|
||||
:: "r"(in + i), "r"(out + i));
|
||||
:: "r"(in + i), "r"(s + i));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This loop converts stray samples to the right format,
|
||||
* but it's also a fallback in case no SIMD instructions are available. */
|
||||
for (; i < samples; i++)
|
||||
for (; i < len; i++)
|
||||
{
|
||||
int32_t val = (int32_t)(in[i] * 0x8000);
|
||||
out[i] = (val > 0x7FFF)
|
||||
s[i] = (val > 0x7FFF)
|
||||
? 0x7FFF
|
||||
: (val < -0x8000 ? -0x8000 : (int16_t)val);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
asm(
|
||||
DECL_ARMMODE("convert_float_s16_asm")
|
||||
DECL_ARMMODE("_convert_float_s16_asm")
|
||||
"# convert_float_s16_asm(int16_t *out, const float *in, size_t samples)\n"
|
||||
"# convert_float_s16_asm(int16_t *s, const float *in, size_t len)\n"
|
||||
" # Hacky way to get a constant of 2^15.\n"
|
||||
" # ((2^4)^2)^2 * 0.5 = 2^15\n"
|
||||
" vmov.f32 q8, #16.0\n"
|
||||
|
@ -25,17 +25,17 @@
|
||||
#include <audio/conversion/dual_mono.h>
|
||||
|
||||
/* TODO: Use SIMD instructions to make this faster (or show that it's not needed) */
|
||||
void convert_to_dual_mono_float(float *out, const float *in, size_t frames)
|
||||
void convert_to_dual_mono_float(float *s, const float *in, size_t len)
|
||||
{
|
||||
unsigned i = 0;
|
||||
|
||||
if (!out || !in || !frames)
|
||||
if (!s || !in || !len)
|
||||
return;
|
||||
|
||||
for (; i < frames; i++)
|
||||
for (; i < len; i++)
|
||||
{
|
||||
out[i * 2] = in[i];
|
||||
out[i * 2 + 1] = in[i];
|
||||
s[i * 2] = in[i];
|
||||
s[i * 2 + 1] = in[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,33 +34,33 @@ static bool s16_to_float_neon_enabled = false;
|
||||
|
||||
#ifdef HAVE_ARM_NEON_ASM_OPTIMIZATIONS
|
||||
/* Avoid potential hard-float/soft-float ABI issues. */
|
||||
void convert_s16_float_asm(float *out, const int16_t *in,
|
||||
size_t samples, const float *gain);
|
||||
void convert_s16_float_asm(float *s, const int16_t *in,
|
||||
size_t len, const float *gain);
|
||||
#else
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
void convert_s16_to_float(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
void convert_s16_to_float(float *s,
|
||||
const int16_t *in, size_t len, float gain)
|
||||
{
|
||||
unsigned i = 0;
|
||||
|
||||
if (s16_to_float_neon_enabled)
|
||||
{
|
||||
#ifdef HAVE_ARM_NEON_ASM_OPTIMIZATIONS
|
||||
size_t aligned_samples = samples & ~7;
|
||||
size_t aligned_samples = len & ~7;
|
||||
if (aligned_samples)
|
||||
convert_s16_float_asm(out, in, aligned_samples, &gain);
|
||||
convert_s16_float_asm(s, in, aligned_samples, &gain);
|
||||
|
||||
/* Could do all conversion in ASM, but keep it simple for now. */
|
||||
out += aligned_samples;
|
||||
s += aligned_samples;
|
||||
in += aligned_samples;
|
||||
samples -= aligned_samples;
|
||||
len -= aligned_samples;
|
||||
i = 0;
|
||||
#else
|
||||
float gf = gain / (1 << 15);
|
||||
float32x4_t vgf = {gf, gf, gf, gf};
|
||||
while (samples >= 8)
|
||||
while (len >= 8)
|
||||
{
|
||||
float32x4x2_t oreg;
|
||||
int16x4x2_t inreg = vld2_s16(in);
|
||||
@ -68,18 +68,18 @@ void convert_s16_to_float(float *out,
|
||||
int32x4_t p2 = vmovl_s16(inreg.val[1]);
|
||||
oreg.val[0] = vmulq_f32(vcvtq_f32_s32(p1), vgf);
|
||||
oreg.val[1] = vmulq_f32(vcvtq_f32_s32(p2), vgf);
|
||||
vst2q_f32(out, oreg);
|
||||
vst2q_f32(s, oreg);
|
||||
in += 8;
|
||||
out += 8;
|
||||
samples -= 8;
|
||||
s += 8;
|
||||
len -= 8;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
gain /= 0x8000;
|
||||
|
||||
for (; i < samples; i++)
|
||||
out[i] = (float)in[i] * gain;
|
||||
for (; i < len; i++)
|
||||
s[i] = (float)in[i] * gain;
|
||||
}
|
||||
|
||||
void convert_s16_to_float_init_simd(void)
|
||||
@ -90,8 +90,8 @@ void convert_s16_to_float_init_simd(void)
|
||||
s16_to_float_neon_enabled = true;
|
||||
}
|
||||
#else
|
||||
void convert_s16_to_float(float *out,
|
||||
const int16_t *in, size_t samples, float gain)
|
||||
void convert_s16_to_float(float *s,
|
||||
const int16_t *in, size_t len, float gain)
|
||||
{
|
||||
unsigned i = 0;
|
||||
|
||||
@ -99,7 +99,7 @@ void convert_s16_to_float(float *out,
|
||||
float fgain = gain / UINT32_C(0x80000000);
|
||||
__m128 factor = _mm_set1_ps(fgain);
|
||||
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
for (i = 0; i + 8 <= len; i += 8, in += 8, s += 8)
|
||||
{
|
||||
__m128i input = _mm_loadu_si128((const __m128i *)in);
|
||||
__m128i regs_l = _mm_unpacklo_epi16(_mm_setzero_si128(), input);
|
||||
@ -107,23 +107,23 @@ void convert_s16_to_float(float *out,
|
||||
__m128 output_l = _mm_mul_ps(_mm_cvtepi32_ps(regs_l), factor);
|
||||
__m128 output_r = _mm_mul_ps(_mm_cvtepi32_ps(regs_r), factor);
|
||||
|
||||
_mm_storeu_ps(out + 0, output_l);
|
||||
_mm_storeu_ps(out + 4, output_r);
|
||||
_mm_storeu_ps(s + 0, output_l);
|
||||
_mm_storeu_ps(s + 4, output_r);
|
||||
}
|
||||
|
||||
samples = samples - i;
|
||||
len = len - i;
|
||||
i = 0;
|
||||
#elif defined(__ALTIVEC__)
|
||||
size_t samples_in = samples;
|
||||
size_t samples_in = len;
|
||||
|
||||
/* Unaligned loads/store is a bit expensive, so we
|
||||
* optimize for the good path (very likely). */
|
||||
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
|
||||
if (((uintptr_t)s & 15) + ((uintptr_t)in & 15) == 0)
|
||||
{
|
||||
const vector float gain_vec = { gain, gain , gain, gain };
|
||||
const vector float zero_vec = { 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
|
||||
for (i = 0; i + 8 <= len; i += 8, in += 8, s += 8)
|
||||
{
|
||||
vector signed short input = vec_ld(0, in);
|
||||
vector signed int hi = vec_unpackh(input);
|
||||
@ -131,14 +131,14 @@ void convert_s16_to_float(float *out,
|
||||
vector float out_hi = vec_madd(vec_ctf(hi, 15), gain_vec, zero_vec);
|
||||
vector float out_lo = vec_madd(vec_ctf(lo, 15), gain_vec, zero_vec);
|
||||
|
||||
vec_st(out_hi, 0, out);
|
||||
vec_st(out_lo, 16, out);
|
||||
vec_st(out_hi, 0, s);
|
||||
vec_st(out_lo, 16, s);
|
||||
}
|
||||
|
||||
samples_in -= i;
|
||||
}
|
||||
|
||||
samples = samples_in;
|
||||
len = samples_in;
|
||||
i = 0;
|
||||
#endif
|
||||
|
||||
@ -149,7 +149,7 @@ void convert_s16_to_float(float *out,
|
||||
/* Make sure the buffer is 16 byte aligned, this should be the
|
||||
* default behaviour of malloc in the PSPSDK.
|
||||
* Only the output buffer can be assumed to be 16-byte aligned. */
|
||||
retro_assert(((uintptr_t)out & 0xf) == 0);
|
||||
retro_assert(((uintptr_t)s & 0xf) == 0);
|
||||
#endif
|
||||
|
||||
__asm__ (
|
||||
@ -159,7 +159,7 @@ void convert_s16_to_float(float *out,
|
||||
".set pop \n"
|
||||
::"r"(gain));
|
||||
|
||||
for (i = 0; i + 16 <= samples; i += 16)
|
||||
for (i = 0; i + 16 <= len; i += 16)
|
||||
{
|
||||
__asm__ (
|
||||
".set push \n"
|
||||
@ -192,12 +192,12 @@ void convert_s16_to_float(float *out,
|
||||
"sv.q c130, 48(%1) \n"
|
||||
|
||||
".set pop \n"
|
||||
:: "r"(in + i), "r"(out + i));
|
||||
:: "r"(in + i), "r"(s + i));
|
||||
}
|
||||
#endif
|
||||
|
||||
for (; i < samples; i++)
|
||||
out[i] = (float)in[i] * gain;
|
||||
for (; i < len; i++)
|
||||
s[i] = (float)in[i] * gain;
|
||||
}
|
||||
|
||||
void convert_s16_to_float_init_simd(void) { }
|
||||
|
@ -30,7 +30,7 @@
|
||||
asm(
|
||||
DECL_ARMMODE("convert_s16_float_asm")
|
||||
DECL_ARMMODE("_convert_s16_float_asm")
|
||||
"# convert_s16_float_asm(float *out, const int16_t *in, size_t samples, const float *gain)\n"
|
||||
"# convert_s16_float_asm(float *s, const int16_t *in, size_t len, const float *gain)\n"
|
||||
" # Hacky way to get a constant of 2^-15.\n"
|
||||
" # Might be faster to just load a constant from memory.\n"
|
||||
" # It's just done once however ...\n"
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <compat/fnmatch.h>
|
||||
|
||||
/* Implemnentation of fnmatch(3) so it can be
|
||||
/* Implementation of fnmatch(3) so it can be
|
||||
* distributed to non *nix platforms.
|
||||
*
|
||||
* No flags are implemented ATM.
|
||||
|
@ -123,17 +123,17 @@ static int parse_short(const char *optstring, char * const *argv)
|
||||
|
||||
static int parse_long(const struct option *longopts, char * const *argv)
|
||||
{
|
||||
size_t indice;
|
||||
size_t i;
|
||||
char *save = NULL;
|
||||
char *argv0 = strdup(&argv[0][2]);
|
||||
char *token = strtok_r(argv0, "=", &save);
|
||||
const struct option *opt = NULL;
|
||||
|
||||
for (indice = 0; longopts[indice].name; indice++)
|
||||
for (i = 0; longopts[i].name; i++)
|
||||
{
|
||||
if (token && !strcmp(longopts[indice].name, token))
|
||||
if (token && !strcmp(longopts[i].name, token))
|
||||
{
|
||||
opt = &longopts[indice];
|
||||
opt = &longopts[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -42,17 +42,15 @@ static int casencmp(const char *a, const char *b, size_t n)
|
||||
|
||||
char *strcasestr_retro__(const char *haystack, const char *needle)
|
||||
{
|
||||
size_t i, search_off;
|
||||
size_t hay_len = strlen(haystack);
|
||||
size_t needle_len = strlen(needle);
|
||||
|
||||
if (needle_len > hay_len)
|
||||
return NULL;
|
||||
|
||||
search_off = hay_len - needle_len;
|
||||
for (i = 0; i <= search_off; i++)
|
||||
if (!casencmp(haystack + i, needle, needle_len))
|
||||
size_t _len = strlen(needle);
|
||||
size_t __len = strlen(haystack);
|
||||
if (_len <= __len)
|
||||
{
|
||||
size_t i;
|
||||
__len -= _len; /* offset */
|
||||
for (i = 0; i <= __len; i++)
|
||||
if (!casencmp(haystack + i, needle, _len))
|
||||
return (char*)haystack + i;
|
||||
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@
|
||||
uint32_t encoding_crc32(uint32_t crc, const uint8_t *data, size_t len)
|
||||
{
|
||||
crc = ~crc;
|
||||
|
||||
/* Align data if it is not aligned */
|
||||
while (((uintptr_t)data & 7) && len > 0)
|
||||
{
|
||||
@ -44,26 +43,24 @@ uint32_t encoding_crc32(uint32_t crc, const uint8_t *data, size_t len)
|
||||
data++;
|
||||
len--;
|
||||
}
|
||||
|
||||
while (len >= 8)
|
||||
{
|
||||
crc = __crc32d(crc, *(uint64_t *)data);
|
||||
data += 8;
|
||||
len -= 8;
|
||||
}
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
crc = __crc32b(crc, *(uint8_t *)data);
|
||||
data++;
|
||||
len--;
|
||||
}
|
||||
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
uint32_t encoding_crc32(uint32_t crc, const uint8_t *s, size_t len)
|
||||
{
|
||||
static const uint32_t crc32_table[256] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
@ -118,14 +115,9 @@ static const uint32_t crc32_table[256] = {
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
|
||||
uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len)
|
||||
{
|
||||
crc = ~crc;
|
||||
|
||||
while (len--)
|
||||
crc = crc32_table[(crc ^ (*buf++)) & 0xff] ^ (crc >> 8);
|
||||
|
||||
crc = crc32_table[(crc ^ (*s++)) & 0xff] ^ (crc >> 8);
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,6 @@ size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
|
||||
out_chars--;
|
||||
ret++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -162,20 +161,20 @@ bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
|
||||
* Acts mostly like strlcpy.
|
||||
*
|
||||
* Copies the given number of UTF-8 characters,
|
||||
* but at most @d_len bytes.
|
||||
* but at most @len bytes.
|
||||
*
|
||||
* Always NULL terminates. Does not copy half a character.
|
||||
* @s is assumed valid UTF-8.
|
||||
* Use only if @chars is considerably less than @d_len.
|
||||
* Use only if @chars is considerably less than @len.
|
||||
*
|
||||
* @return Number of bytes.
|
||||
**/
|
||||
size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
|
||||
size_t utf8cpy(char *s, size_t len, const char *in, size_t chars)
|
||||
{
|
||||
const uint8_t *sb = (const uint8_t*)s;
|
||||
const uint8_t *sb = (const uint8_t*)in;
|
||||
const uint8_t *sb_org = sb;
|
||||
|
||||
if (!s)
|
||||
if (!in)
|
||||
return 0;
|
||||
|
||||
while (*sb && chars-- > 0)
|
||||
@ -185,16 +184,15 @@ size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
|
||||
sb++;
|
||||
}
|
||||
|
||||
if ((size_t)(sb - sb_org) > d_len-1)
|
||||
if ((size_t)(sb - sb_org) > len - 1)
|
||||
{
|
||||
sb = sb_org + d_len-1;
|
||||
sb = sb_org + len - 1;
|
||||
while ((*sb & 0xC0) == 0x80)
|
||||
sb--;
|
||||
}
|
||||
|
||||
memcpy(d, sb_org, sb-sb_org);
|
||||
d[sb-sb_org] = '\0';
|
||||
|
||||
memcpy(s, sb_org, sb - sb_org);
|
||||
s[sb-sb_org] = '\0';
|
||||
return sb - sb_org;
|
||||
}
|
||||
|
||||
@ -292,19 +290,16 @@ static bool utf16_to_char(uint8_t **utf_data,
|
||||
**/
|
||||
bool utf16_to_char_string(const uint16_t *in, char *s, size_t len)
|
||||
{
|
||||
size_t dest_len = 0;
|
||||
size_t _len = 0;
|
||||
uint8_t *utf16_data = NULL;
|
||||
bool ret = utf16_to_char(&utf16_data, &dest_len, in);
|
||||
|
||||
bool ret = utf16_to_char(&utf16_data, &_len, in);
|
||||
if (ret)
|
||||
{
|
||||
utf16_data[dest_len] = 0;
|
||||
utf16_data[_len] = 0;
|
||||
strlcpy(s, (const char*)utf16_data, len);
|
||||
}
|
||||
|
||||
free(utf16_data);
|
||||
utf16_data = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -840,8 +840,8 @@ end:
|
||||
if (!s)
|
||||
return;
|
||||
{
|
||||
size_t len_size = len;
|
||||
sysctlbyname("machdep.cpu.brand_string", s, &len_size, NULL, 0);
|
||||
size_t __len = len;
|
||||
sysctlbyname("machdep.cpu.brand_string", s, &__len, NULL, 0);
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
if (!s)
|
||||
|
@ -54,9 +54,9 @@ static int file_archive_get_file_list_cb(
|
||||
|
||||
if (valid_exts)
|
||||
{
|
||||
size_t path_len = strlen(path);
|
||||
size_t _len = strlen(path);
|
||||
/* Checks if this entry is a directory or a file. */
|
||||
char last_char = path[path_len - 1];
|
||||
char last_char = path[_len - 1];
|
||||
struct string_list ext_list = {0};
|
||||
|
||||
/* Skip if directory. */
|
||||
@ -157,7 +157,8 @@ static int file_archive_parse_file_init(file_archive_transfer_t *state,
|
||||
state->archive_mmap_fd = open(path, O_RDONLY);
|
||||
if (state->archive_mmap_fd)
|
||||
{
|
||||
state->archive_mmap_data = (uint8_t*)mmap(NULL, (size_t)state->archive_size,
|
||||
state->archive_mmap_data = (uint8_t*)mmap(NULL,
|
||||
(size_t)state->archive_size,
|
||||
PROT_READ, MAP_SHARED, state->archive_mmap_fd, 0);
|
||||
|
||||
if (state->archive_mmap_data == (uint8_t*)MAP_FAILED)
|
||||
|
@ -1168,24 +1168,24 @@ size_t config_get_config_path(config_file_t *conf, char *s, size_t len)
|
||||
}
|
||||
|
||||
bool config_get_array(config_file_t *conf, const char *key,
|
||||
char *buf, size_t len)
|
||||
char *s, size_t len)
|
||||
{
|
||||
const struct config_entry_list *entry = config_get_entry(conf, key);
|
||||
if (entry)
|
||||
return strlcpy(buf, entry->value, len) < len;
|
||||
return strlcpy(s, entry->value, len) < len;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool config_get_path(config_file_t *conf, const char *key,
|
||||
char *buf, size_t len)
|
||||
char *s, size_t len)
|
||||
{
|
||||
#if defined(RARCH_CONSOLE) || !defined(RARCH_INTERNAL)
|
||||
return config_get_array(conf, key, buf, len);
|
||||
return config_get_array(conf, key, s, len);
|
||||
#else
|
||||
const struct config_entry_list *entry = config_get_entry(conf, key);
|
||||
if (entry)
|
||||
{
|
||||
fill_pathname_expand_special(buf, entry->value, len);
|
||||
fill_pathname_expand_special(s, entry->value, len);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -770,7 +770,6 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
|
||||
char pre_game_id[50];
|
||||
char raw_game_id[50];
|
||||
int index;
|
||||
size_t size_t_var;
|
||||
char lgame_id[20];
|
||||
char rgame_id[20];
|
||||
|
||||
@ -809,8 +808,7 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
|
||||
index = string_index_last_occurance(raw_game_id, '-');
|
||||
if (index < 0)
|
||||
return false;
|
||||
size_t_var = (size_t)index;
|
||||
strncpy(lgame_id, &raw_game_id[0], size_t_var);
|
||||
strncpy(lgame_id, &raw_game_id[0], (size_t)index);
|
||||
lgame_id[index] = '\0';
|
||||
strncpy(rgame_id, &raw_game_id[index + 1], __len - 1);
|
||||
rgame_id[__len - 1] = '\0';
|
||||
@ -855,8 +853,7 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
|
||||
index = string_index_last_occurance(pre_game_id, '-');
|
||||
if (index < 0)
|
||||
return false;
|
||||
size_t_var = (size_t)index;
|
||||
strncpy(lgame_id, pre_game_id, size_t_var);
|
||||
strncpy(lgame_id, pre_game_id, (size_t)index);
|
||||
lgame_id[index] = '\0';
|
||||
___len = strlen(pre_game_id);
|
||||
}
|
||||
@ -1054,11 +1051,11 @@ int detect_system(intfstream_t *fd, const char **system_name, const char * filen
|
||||
{
|
||||
if (intfstream_seek(fd, MAGIC_NUMBERS[i].offset, SEEK_SET) >= 0)
|
||||
{
|
||||
size_t magic_len = strlen(MAGIC_NUMBERS[i].magic);
|
||||
if (intfstream_read(fd, magic, magic_len) > 0)
|
||||
size_t _len = strlen(MAGIC_NUMBERS[i].magic);
|
||||
if (intfstream_read(fd, magic, _len) > 0)
|
||||
{
|
||||
magic[magic_len] = '\0';
|
||||
if (memcmp(MAGIC_NUMBERS[i].magic, magic, magic_len) == 0)
|
||||
magic[_len] = '\0';
|
||||
if (memcmp(MAGIC_NUMBERS[i].magic, magic, _len) == 0)
|
||||
{
|
||||
*system_name = MAGIC_NUMBERS[i].system_name;
|
||||
#ifdef DEBUG
|
||||
|
@ -27,12 +27,10 @@
|
||||
#define CALLBACK_ERROR_SIZE 4200
|
||||
|
||||
static int file_decompressed_target_file(const char *name,
|
||||
const char *valid_exts,
|
||||
const uint8_t *cdata,
|
||||
const char *valid_exts, const uint8_t *cdata,
|
||||
unsigned cmode, uint32_t csize, uint32_t size,
|
||||
uint32_t crc32, struct archive_extract_userdata *userdata)
|
||||
{
|
||||
/* TODO/FIXME */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -42,13 +40,11 @@ static int file_decompressed_subdir(const char *name,
|
||||
unsigned cmode, uint32_t csize,uint32_t size,
|
||||
uint32_t crc32, struct archive_extract_userdata *userdata)
|
||||
{
|
||||
size_t _len;
|
||||
char path_dir[DIR_MAX_LENGTH];
|
||||
char path[PATH_MAX_LENGTH];
|
||||
size_t name_len = strlen(name);
|
||||
char last_char = name[name_len - 1];
|
||||
/* Ignore directories, go to next file. */
|
||||
if (last_char == '/' || last_char == '\\')
|
||||
size_t _len = strlen(name);
|
||||
/* Look at last character. Ignore directories, go to next file. */
|
||||
if (name[_len - 1] == '/' || name[_len - 1] == '\\')
|
||||
return 1;
|
||||
if (strstr(name, userdata->dec->subdir) != name)
|
||||
return 1;
|
||||
@ -89,13 +85,11 @@ static int file_decompressed(const char *name, const char *valid_exts,
|
||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
||||
uint32_t crc32, struct archive_extract_userdata *userdata)
|
||||
{
|
||||
size_t _len;
|
||||
char path[PATH_MAX_LENGTH];
|
||||
decompress_state_t *dec = userdata->dec;
|
||||
size_t name_len = strlen(name);
|
||||
char last_char = name[name_len - 1];
|
||||
/* Ignore directories, go to next file. */
|
||||
if (last_char == '/' || last_char == '\\')
|
||||
size_t _len = strlen(name);
|
||||
/* Look at last character. Ignore directories, go to next file. */
|
||||
if (name[_len - 1] == '/' || name[_len - 1] == '\\')
|
||||
return 1;
|
||||
/* Make directory */
|
||||
fill_pathname_join_special(path, dec->target_dir, name, sizeof(path));
|
||||
@ -227,8 +221,7 @@ static void task_decompress_handler_subdir(retro_task_t *task)
|
||||
sizeof(dec->userdata->archive_path));
|
||||
|
||||
ret = file_archive_parse_file_iterate(
|
||||
&dec->archive,
|
||||
&retdec, dec->source_file,
|
||||
&dec->archive, &retdec, dec->source_file,
|
||||
dec->valid_ext, file_decompressed_subdir, dec->userdata);
|
||||
|
||||
task_set_progress(task,
|
||||
|
Loading…
x
Reference in New Issue
Block a user