mirror of
https://github.com/libretro/RetroArch
synced 2025-02-13 21:40:27 +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
|
||||
|
||||
@ -176,9 +176,9 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
|
||||
uint8_t *sample = (
|
||||
(uint8_t*)chunk->rwav->samples) + i;
|
||||
|
||||
chunk->upsample_buf[i * 2] =
|
||||
chunk->upsample_buf[i * 2] =
|
||||
(int16_t)((sample[0] - 128) << 8);
|
||||
chunk->upsample_buf[(i * 2) + 1] =
|
||||
chunk->upsample_buf[(i * 2) + 1] =
|
||||
(int16_t)((sample[0] - 128) << 8);
|
||||
}
|
||||
}
|
||||
@ -190,9 +190,9 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
|
||||
(uint8_t*)chunk->rwav->samples) +
|
||||
(i * 2);
|
||||
|
||||
chunk->upsample_buf[i * 2] =
|
||||
chunk->upsample_buf[i * 2] =
|
||||
(int16_t)((sample[0] - 128) << 8);
|
||||
chunk->upsample_buf[(i * 2) + 1] =
|
||||
chunk->upsample_buf[(i * 2) + 1] =
|
||||
(int16_t)((sample[1] - 128) << 8);
|
||||
}
|
||||
}
|
||||
@ -238,13 +238,13 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
|
||||
struct resampler_data info;
|
||||
|
||||
chunk->float_buf = (float*)memalign_alloc(128,
|
||||
chunk->rwav->numsamples * 2 *
|
||||
chunk->rwav->numsamples * 2 *
|
||||
chunk->ratio * sizeof(float));
|
||||
|
||||
/* why is *3 needed instead of just *2? Does the
|
||||
/* why is *3 needed instead of just *2? Does the
|
||||
* sinc driver require more space than we know about? */
|
||||
chunk->float_resample_buf = (float*)memalign_alloc(128,
|
||||
chunk->rwav->numsamples * 3 *
|
||||
chunk->rwav->numsamples * 3 *
|
||||
chunk->ratio * sizeof(float));
|
||||
|
||||
convert_s16_to_float(chunk->float_buf,
|
||||
@ -260,7 +260,7 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
|
||||
|
||||
chunk->resampler->process(chunk->resampler_data, &info);
|
||||
|
||||
/* number of output_frames does not increase with
|
||||
/* number of output_frames does not increase with
|
||||
* multiple channels, but assume we need space for 2 */
|
||||
chunk->resample_buf = (int16_t*)memalign_alloc(128,
|
||||
info.output_frames * 2 * sizeof(int16_t));
|
||||
@ -323,11 +323,11 @@ int16_t audio_mix_get_chunk_sample(audio_chunk_t *chunk,
|
||||
|
||||
if (chunk->resample)
|
||||
sample = (uint8_t*)chunk->resample_buf +
|
||||
(sample_size * index * chunk->rwav->numchannels)
|
||||
(sample_size * index * chunk->rwav->numchannels)
|
||||
+ (channel * sample_size);
|
||||
else
|
||||
sample = (uint8_t*)chunk->upsample_buf +
|
||||
(sample_size * index * chunk->rwav->numchannels)
|
||||
(sample_size * index * chunk->rwav->numchannels)
|
||||
+ (channel * sample_size);
|
||||
|
||||
sample_out = (int16_t)*sample;
|
||||
|
@ -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,31 +34,29 @@
|
||||
#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;
|
||||
in += aligned_samples;
|
||||
samples -= aligned_samples;
|
||||
i = 0;
|
||||
s += aligned_samples;
|
||||
in += aligned_samples;
|
||||
samples -= aligned_samples;
|
||||
i = 0;
|
||||
#else
|
||||
int16x4x2_t oreg;
|
||||
int32x4x2_t creg;
|
||||
@ -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);
|
||||
in += 8;
|
||||
out += 8;
|
||||
samples -= 8;
|
||||
vst2_s16(s, oreg);
|
||||
in += 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,17 +161,17 @@ 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)
|
||||
? 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,20 +25,20 @@
|
||||
#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];
|
||||
}
|
||||
}
|
||||
|
||||
/* Why is there no equivalent for int16_t samples?
|
||||
* No inherent reason, I just didn't need one.
|
||||
* If you do, open a pull request. */
|
||||
* If you do, open a pull request. */
|
||||
|
@ -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;
|
||||
in += aligned_samples;
|
||||
samples -= aligned_samples;
|
||||
i = 0;
|
||||
s += aligned_samples;
|
||||
in += aligned_samples;
|
||||
len -= aligned_samples;
|
||||
i = 0;
|
||||
#else
|
||||
float gf = gain / (1 << 15);
|
||||
float32x4_t vgf = {gf, gf, gf, gf};
|
||||
while (samples >= 8)
|
||||
float gf = gain / (1 << 15);
|
||||
float32x4_t vgf = {gf, gf, gf, gf};
|
||||
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))
|
||||
return (char*)haystack + i;
|
||||
|
||||
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,88 +43,81 @@ 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
|
||||
|
||||
static const uint32_t crc32_table[256] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
|
||||
uint32_t encoding_crc32(uint32_t crc, const uint8_t *buf, size_t len)
|
||||
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,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
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,17 +184,16 @@ 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';
|
||||
|
||||
return sb-sb_org;
|
||||
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;
|
||||
uint8_t *utf16_data = NULL;
|
||||
bool ret = utf16_to_char(&utf16_data, &dest_len, in);
|
||||
|
||||
size_t _len = 0;
|
||||
uint8_t *utf16_data = NULL;
|
||||
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;
|
||||
|
||||
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];
|
||||
|
||||
@ -806,17 +805,16 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
|
||||
{
|
||||
if (total_hyphens >= 2)
|
||||
{
|
||||
index = string_index_last_occurance(raw_game_id, '-');
|
||||
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);
|
||||
lgame_id[index] = '\0';
|
||||
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';
|
||||
_len = strlcat(s, lgame_id, len);
|
||||
s[ _len] = '-';
|
||||
s[++_len] = '\0';
|
||||
_len = strlcat(s, lgame_id, len);
|
||||
s[ _len] = '-';
|
||||
s[++_len] = '\0';
|
||||
strlcpy(s + _len, rgame_id, len - _len);
|
||||
}
|
||||
else if (__len <= 7)
|
||||
@ -852,13 +850,12 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
|
||||
|
||||
if (total_hyphens_recalc >= 2)
|
||||
{
|
||||
index = string_index_last_occurance(pre_game_id, '-');
|
||||
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);
|
||||
lgame_id[index] = '\0';
|
||||
___len = strlen(pre_game_id);
|
||||
strncpy(lgame_id, pre_game_id, (size_t)index);
|
||||
lgame_id[index] = '\0';
|
||||
___len = strlen(pre_game_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -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 == '\\')
|
||||
decompress_state_t *dec = userdata->dec;
|
||||
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