Skip to content

Commit 87a5857

Browse files
committed
Updates
1 parent 716bb5e commit 87a5857

45 files changed

Lines changed: 1578 additions & 379 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

audio/audio_mix.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2121
*/
2222

23-
#include <stdio.h>
2423
#include <stdlib.h>
2524
#include <string.h>
2625
#include <memalign.h>
@@ -133,12 +132,15 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
133132
chunk->resample_buf = NULL;
134133
chunk->len = 0;
135134
chunk->resample_len = 0;
136-
chunk->rwav = (rwav_t*)malloc(sizeof(rwav_t));
137135
chunk->sample_rate = sample_rate;
138136
chunk->resample = false;
139137
chunk->resampler = NULL;
140138
chunk->resampler_data = NULL;
141139
chunk->ratio = 0.00f;
140+
chunk->rwav = (rwav_t*)malloc(sizeof(rwav_t));
141+
142+
if (!chunk->rwav)
143+
goto error;
142144

143145
chunk->rwav->bitspersample = 0;
144146
chunk->rwav->numchannels = 0;
@@ -148,19 +150,13 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
148150
chunk->rwav->samples = NULL;
149151

150152
if (!filestream_read_file(path, &buf, &len))
151-
{
152-
printf("Could not open WAV file for reading.\n");
153153
goto error;
154-
}
155154

156155
chunk->buf = buf;
157156
chunk->len = len;
158157

159158
if (rwav_load(chunk->rwav, chunk->buf, chunk->len) == RWAV_ITERATE_ERROR)
160-
{
161-
printf("error: could not load WAV file\n");
162159
goto error;
163-
}
164160

165161
/* numsamples does not know or care about
166162
* multiple channels, but we need space for 2 */
@@ -223,7 +219,6 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate,
223219
else if (sample_size != 2)
224220
{
225221
/* we don't support any other sample size besides 8 and 16-bit yet */
226-
printf("error: we don't support a sample size of %d\n", sample_size);
227222
goto error;
228223
}
229224

audio/audio_mixer.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,14 +280,14 @@ static bool one_shot_resample(const float* in, size_t samples_in,
280280
return false;
281281

282282
/* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes. We
283-
* add four more samples in the formula below just as safeguard, because
283+
* add 16 more samples in the formula below just as safeguard, because
284284
* resampler->process sometimes reports more output samples than the
285285
* formula below calculates. Ideally, audio resamplers should have a
286286
* function to return the number of samples they will output given a
287287
* count of input samples. */
288288
*samples_out = (size_t)(samples_in * ratio);
289289
*out = (float*)memalign_alloc(16,
290-
(((*samples_out + 4) + 15) & ~15) * sizeof(float));
290+
(((*samples_out + 16) + 15) & ~15) * sizeof(float));
291291

292292
if (*out == NULL)
293293
return false;
@@ -546,14 +546,14 @@ static bool audio_mixer_play_ogg(
546546
}
547547

548548
/* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes. We
549-
* add four more samples in the formula below just as safeguard, because
549+
* add 16 more samples in the formula below just as safeguard, because
550550
* resampler->process sometimes reports more output samples than the
551551
* formula below calculates. Ideally, audio resamplers should have a
552552
* function to return the number of samples they will output given a
553553
* count of input samples. */
554554
samples = (unsigned)(AUDIO_MIXER_TEMP_BUFFER * ratio);
555555
ogg_buffer = (float*)memalign_alloc(16,
556-
(((samples + 4) + 15) & ~15) * sizeof(float));
556+
(((samples + 16) + 15) & ~15) * sizeof(float));
557557

558558
if (!ogg_buffer)
559559
{
@@ -695,14 +695,14 @@ static bool audio_mixer_play_flac(
695695
}
696696

697697
/* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes. We
698-
* add four more samples in the formula below just as safeguard, because
698+
* add 16 more samples in the formula below just as safeguard, because
699699
* resampler->process sometimes reports more output samples than the
700700
* formula below calculates. Ideally, audio resamplers should have a
701701
* function to return the number of samples they will output given a
702702
* count of input samples. */
703703
samples = (unsigned)(AUDIO_MIXER_TEMP_BUFFER * ratio);
704704
flac_buffer = (float*)memalign_alloc(16,
705-
(((samples + 4) + 15) & ~15) * sizeof(float));
705+
(((samples + 16) + 15) & ~15) * sizeof(float));
706706

707707
if (!flac_buffer)
708708
{
@@ -773,14 +773,14 @@ static bool audio_mixer_play_mp3(
773773
}
774774

775775
/* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes. We
776-
* add four more samples in the formula below just as safeguard, because
776+
* add 16 more samples in the formula below just as safeguard, because
777777
* resampler->process sometimes reports more output samples than the
778778
* formula below calculates. Ideally, audio resamplers should have a
779779
* function to return the number of samples they will output given a
780780
* count of input samples. */
781781
samples = (unsigned)(AUDIO_MIXER_TEMP_BUFFER * ratio);
782782
mp3_buffer = (float*)memalign_alloc(16,
783-
(((samples + 4) + 15) & ~15) * sizeof(float));
783+
(((samples + 16) + 15) & ~15) * sizeof(float));
784784

785785
if (!mp3_buffer)
786786
{

audio/resampler/drivers/sinc_resampler.c

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,80 @@ void process_sinc_neon_asm(float *out, const float *left,
9292
const float *right, const float *coeff, unsigned taps);
9393
#else
9494
#include <arm_neon.h>
95+
96+
/* Assumes that taps >= 8, and that taps is a multiple of 8.
97+
* Not bothering to reimplement this one for the external .S
98+
*/
99+
static void resampler_sinc_process_neon_kaiser(void *re_, struct resampler_data *data)
100+
{
101+
rarch_sinc_resampler_t *resamp = (rarch_sinc_resampler_t*)re_;
102+
unsigned phases = 1 << (resamp->phase_bits + resamp->subphase_bits);
103+
uint32_t ratio = phases / data->ratio;
104+
const float *input = data->data_in;
105+
float *output = data->data_out;
106+
size_t frames = data->input_frames;
107+
size_t out_frames = 0;
108+
while (frames)
109+
{
110+
while (frames && resamp->time >= phases)
111+
{
112+
/* Push in reverse to make filter more obvious. */
113+
if (!resamp->ptr)
114+
resamp->ptr = resamp->taps;
115+
resamp->ptr--;
116+
117+
resamp->buffer_l[resamp->ptr + resamp->taps] =
118+
resamp->buffer_l[resamp->ptr] = *input++;
119+
120+
resamp->buffer_r[resamp->ptr + resamp->taps] =
121+
resamp->buffer_r[resamp->ptr] = *input++;
122+
123+
resamp->time -= phases;
124+
frames--;
125+
}
126+
127+
{
128+
const float *buffer_l = resamp->buffer_l + resamp->ptr;
129+
const float *buffer_r = resamp->buffer_r + resamp->ptr;
130+
unsigned taps = resamp->taps;
131+
while (resamp->time < phases)
132+
{
133+
unsigned phase = resamp->time >> resamp->subphase_bits;
134+
const float *phase_table = resamp->phase_table + phase * taps * 2;
135+
const float *delta_table = phase_table + taps;
136+
float32x4_t delta = vdupq_n_f32((resamp->time & resamp->subphase_mask) * resamp->subphase_mod);
137+
unsigned i;
138+
float32x4_t p1 = {0, 0, 0, 0}, p2 = {0, 0, 0, 0};
139+
float32x2_t p3, p4;
140+
141+
for (i = 0; i < taps; i += 8)
142+
{
143+
float32x4x2_t coeff8 = vld2q_f32(&phase_table[i]);
144+
float32x4x2_t delta8 = vld2q_f32(&delta_table[i]);
145+
float32x4x2_t left8 = vld2q_f32(&buffer_l[i]);
146+
float32x4x2_t right8 = vld2q_f32(&buffer_r[i]);
147+
148+
coeff8.val[0] = vmlaq_f32(coeff8.val[0], delta8.val[0], delta);
149+
coeff8.val[1] = vmlaq_f32(coeff8.val[1], delta8.val[1], delta);
150+
151+
p1 = vmlaq_f32(p1, left8.val[0], coeff8.val[0]);
152+
p2 = vmlaq_f32(p2, right8.val[0], coeff8.val[0]);
153+
p1 = vmlaq_f32(p1, left8.val[1], coeff8.val[1]);
154+
p2 = vmlaq_f32(p2, right8.val[1], coeff8.val[1]);
155+
}
156+
157+
p3 = vadd_f32(vget_low_f32(p1), vget_high_f32(p1));
158+
p4 = vadd_f32(vget_low_f32(p2), vget_high_f32(p2));
159+
vst1_f32(output, vpadd_f32(p3, p4));
160+
output += 2;
161+
out_frames++;
162+
resamp->time += ratio;
163+
}
164+
}
165+
}
166+
167+
data->output_frames = out_frames;
168+
}
95169
#endif
96170

97171
/* Assumes that taps >= 8, and that taps is a multiple of 8. */
@@ -914,10 +988,17 @@ static void *resampler_sinc_new(const struct resampler_config *config,
914988
sinc_resampler.process = resampler_sinc_process_sse_kaiser;
915989
#endif
916990
}
917-
else if (mask & RESAMPLER_SIMD_NEON && window_type != SINC_WINDOW_KAISER)
991+
else if (mask & RESAMPLER_SIMD_NEON)
918992
{
919993
#if (defined(__ARM_NEON__) || defined(HAVE_NEON))
994+
#ifdef HAVE_ARM_NEON_ASM_OPTIMIZATIONS
995+
if (window_type != SINC_WINDOW_KAISER)
996+
sinc_resampler.process = resampler_sinc_process_neon;
997+
#else
920998
sinc_resampler.process = resampler_sinc_process_neon;
999+
if (window_type == SINC_WINDOW_KAISER)
1000+
sinc_resampler.process = resampler_sinc_process_neon_kaiser;
1001+
#endif
9211002
#endif
9221003
}
9231004

compat/compat_getopt.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,38 @@ static int parse_short(const char *optstring, char * const *argv)
126126
static int parse_long(const struct option *longopts, char * const *argv)
127127
{
128128
size_t indice;
129+
char *save = NULL;
130+
char *argv0 = strdup(&argv[0][2]);
131+
char *token = strtok_r(argv0, "=", &save);
129132
const struct option *opt = NULL;
133+
130134
for (indice = 0; longopts[indice].name; indice++)
131135
{
132-
if (!strcmp(longopts[indice].name, &argv[0][2]))
136+
if (token && !strcmp(longopts[indice].name, token))
133137
{
134138
opt = &longopts[indice];
135139
break;
136140
}
137141
}
138142

143+
free(argv0);
144+
argv0 = NULL;
145+
139146
if (!opt)
140147
return '?';
141148

149+
/* Handle args with '=' instead of space */
150+
if (opt->has_arg)
151+
{
152+
char *special_arg = strchr(argv[0], '=');
153+
if (special_arg)
154+
{
155+
optarg = ++special_arg;
156+
optind++;
157+
return opt->val;
158+
}
159+
}
160+
142161
/* getopt_long has an "optional" arg, but we don't bother with that. */
143162
if (opt->has_arg && !argv[1])
144163
return '?';

encodings/encoding_base64.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,38 @@
2929
#include <stdlib.h>
3030
#include <encodings/base64.h>
3131

32+
const static char* b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
33+
34+
/* maps A=>0,B=>1.. */
35+
const static unsigned char unb64[]={
36+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
38+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
39+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
40+
0, 0, 0, 62, 0, 0, 0, 63, 52, 53,
41+
54, 55, 56, 57, 58, 59, 60, 61, 0, 0,
42+
0, 0, 0, 0, 0, 0, 1, 2, 3, 4,
43+
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
44+
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
45+
25, 0, 0, 0, 0, 0, 0, 26, 27, 28,
46+
29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
47+
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
48+
49, 50, 51, 0, 0, 0, 0, 0, 0, 0,
49+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
50+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
52+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
53+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
54+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
55+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
58+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
59+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
60+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
61+
0, 0, 0, 0, 0, 0,
62+
}; /* This array has 256 elements */
63+
3264
/*
3365
Converts binary data of length=len to base64 characters.
3466
Length of the resultant string is stored in flen

features/features_cpu.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ retro_time_t cpu_features_get_time_usec(void)
242242
return (svcGetSystemTick() * 10) / 192;
243243
#elif defined(_3DS)
244244
return osGetTime() * 1000;
245-
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__) || defined(DJGPP)
245+
#elif defined(_POSIX_MONOTONIC_CLOCK) || defined(__QNX__) || defined(ANDROID) || defined(__MACH__)
246246
struct timespec tv = {0};
247247
if (ra_clock_gettime(CLOCK_MONOTONIC, &tv) < 0)
248248
return 0;
@@ -253,6 +253,8 @@ retro_time_t cpu_features_get_time_usec(void)
253253
return ps2_clock() / PS2_CLOCKS_PER_MSEC * 1000;
254254
#elif defined(VITA) || defined(PSP)
255255
return sceKernelGetSystemTimeWide();
256+
#elif defined(DJGPP)
257+
return uclock() * 1000000LL / UCLOCKS_PER_SEC;
256258
#else
257259
#error "Your platform does not have a timer function implemented in cpu_features_get_time_usec(). Cannot continue."
258260
#endif

file/archive_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static int file_archive_get_file_list_cb(
6262

6363
/* Skip if directory. */
6464
if (last_char == '/' || last_char == '\\' )
65-
return 0;
65+
return 1;
6666

6767
string_list_initialize(&ext_list);
6868
if (string_split_noalloc(&ext_list, valid_exts, "|"))
@@ -72,7 +72,7 @@ static int file_archive_get_file_list_cb(
7272
if (!file_ext)
7373
{
7474
string_list_deinitialize(&ext_list);
75-
return 0;
75+
return 1;
7676
}
7777

7878
if (!string_list_find_elem_prefix(&ext_list, ".", file_ext))

file/config_file.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,11 +1350,8 @@ bool config_file_write(config_file_t *conf, const char *path, bool sort)
13501350
if (!file)
13511351
return false;
13521352

1353-
/* TODO: this is only useful for a few platforms, find which and add ifdef */
1354-
#if !defined(PSP)
13551353
buf = calloc(1, 0x4000);
13561354
setvbuf(file, (char*)buf, _IOFBF, 0x4000);
1357-
#endif
13581355

13591356
config_file_dump(conf, file, sort);
13601357

0 commit comments

Comments
 (0)