forked from mutability/dump1090
-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
nb: regenerated starch files *not* committed yet, in the name of minimizing merge conflicts for the moment.
- Loading branch information
Showing
13 changed files
with
890 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
|
||
void STARCH_BENCHMARK(magnitude_s16) (void) | ||
{ | ||
int16_t *in = NULL; | ||
uint16_t *out_mag = NULL; | ||
const unsigned len = 65535; | ||
|
||
if (!(in = STARCH_BENCHMARK_ALLOC(len, int16_t)) || !(out_mag = STARCH_BENCHMARK_ALLOC(len, uint16_t))) { | ||
goto done; | ||
} | ||
|
||
unsigned i = 0; | ||
|
||
for (; i < len; ++i) { | ||
in[i] = i - 32767; | ||
out_mag[i] = abs(in[i]); | ||
} | ||
|
||
STARCH_BENCHMARK_RUN( magnitude_s16, in, out_mag, len ); | ||
|
||
done: | ||
STARCH_BENCHMARK_FREE(in); | ||
STARCH_BENCHMARK_FREE(out_mag); | ||
} | ||
|
||
bool STARCH_BENCHMARK_VERIFY(magnitude_s16) (const int16_t *in, uint16_t *out, unsigned len) | ||
{ | ||
bool okay = true; | ||
|
||
for (unsigned i = 0; i < len; ++i) { | ||
okay = (out[i] == abs(in[i])); | ||
if (!okay) { | ||
fprintf(stderr, "verification failed: in[%u]=%d out[%u]=%u\n", i, in[i], i, out[i]); | ||
} | ||
} | ||
|
||
return okay; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <math.h> | ||
|
||
void STARCH_BENCHMARK(magnitude_u16o12) (void) | ||
{ | ||
uint16_t *in = NULL; | ||
uint16_t *out_mag = NULL; | ||
const unsigned len = 4096; | ||
unsigned i; | ||
|
||
if (!(in = STARCH_BENCHMARK_ALLOC(len, uint16_t)) || !(out_mag = STARCH_BENCHMARK_ALLOC(len, uint16_t))) { | ||
goto done; | ||
} | ||
|
||
for (i = 1; i < len; i++) { | ||
in[i] = i; | ||
} | ||
|
||
STARCH_BENCHMARK_RUN( magnitude_u16o12, in, out_mag, len ); | ||
|
||
done: | ||
STARCH_BENCHMARK_FREE(in); | ||
STARCH_BENCHMARK_FREE(out_mag); | ||
} | ||
|
||
bool STARCH_BENCHMARK_VERIFY(magnitude_u16o12) (const uint16_t *in, uint16_t *out, unsigned len) | ||
{ | ||
bool okay = true; | ||
|
||
for (unsigned i = 1; i < len; ++i) { | ||
uint16_t j; | ||
if (in[i] < 2048) { | ||
j = 2048 - (out[i] * 2047.0 / 65535.0f - 0.5f); | ||
} else { | ||
j = 2048 + (out[i] * 2047.0 / 65535.0f + 0.5f); | ||
} | ||
okay = (j == in[j]); | ||
if (!okay) { | ||
fprintf(stderr, "verification failed: in[%u]=%d out[%u]=%u\n", i, in[i], i, out[i]); | ||
} | ||
} | ||
|
||
return okay; | ||
} | ||
|
||
#undef CONVERT_AND_SCALE | ||
#undef MAGIC_SCALER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <math.h> | ||
#include <endian.h> | ||
|
||
/* Convert (little-endian) signed 16-bit values to unsigned 16-bit magnitudes */ | ||
|
||
void STARCH_IMPL(magnitude_s16, exact_u32) (const int16_t *in, uint16_t *out, unsigned len) | ||
{ | ||
const int16_t * restrict in_align = STARCH_ALIGNED(in); | ||
uint16_t * restrict out_align = STARCH_ALIGNED(out); | ||
|
||
while (len--) { | ||
out_align[0] = abs((int16_t) le16toh(in_align[0])); | ||
|
||
out_align += 1; | ||
in_align += 1; | ||
} | ||
} |
Oops, something went wrong.